Browse Source

Require all Consequences to have a description

master
Fen Dweller 5 years ago
parent
commit
e849d8c75a
3 changed files with 24 additions and 23 deletions
  1. +2
    -9
      src/game/combat.ts
  2. +18
    -12
      src/game/combat/consequences.ts
  3. +4
    -2
      src/game/creatures/geta.ts

+ 2
- 9
src/game/combat.ts View File

@@ -432,7 +432,7 @@ export class CompositionAction extends Action {


describe (user: Creature, target: Creature): LogEntry { describe (user: Creature, target: Creature): LogEntry {
return new LogLines( return new LogLines(
...this.consequences.map(consequence => consequence.describePair(user, target)).concat(
...this.consequences.map(consequence => consequence.describe(user, target)).concat(
new Newline(), new Newline(),
super.describe(user, target) super.describe(user, target)
) )
@@ -705,13 +705,6 @@ export abstract class Consequence {
return this.conditions.every(cond => cond.allowed(user, target)) return this.conditions.every(cond => cond.allowed(user, target))
} }


describeSolo (user: Creature): LogEntry {
return nilLog
}

describePair (user: Creature, target: Creature): LogEntry {
return nilLog
}

abstract describe (user: Creature, target: Creature): LogEntry
abstract apply (user: Creature, target: Creature): LogEntry abstract apply (user: Creature, target: Creature): LogEntry
} }

+ 18
- 12
src/game/combat/consequences.ts View File

@@ -8,17 +8,13 @@ import { Container } from '../vore'
* Takes a function, and thus can do anything. * Takes a function, and thus can do anything.
*/ */
export class ArbitraryConsequence extends Consequence { export class ArbitraryConsequence extends Consequence {
constructor (public apply: (user: Creature, target: Creature) => LogEntry, conditions: Condition[] = []) {
constructor (
public apply: (user: Creature, target: Creature) => LogEntry,
public describe: (user: Creature, target: Creature) => LogEntry,
conditions: Condition[] = []
) {
super(conditions) super(conditions)
} }

describeSolo (user: Creature): LogEntry {
return nilLog
}

describePair (user: Creature): LogEntry {
return nilLog
}
} }


/** /**
@@ -33,6 +29,10 @@ export class LogConsequence extends Consequence {
apply (user: Creature, target: Creature): LogEntry { apply (user: Creature, target: Creature): LogEntry {
return this.line(user, target) return this.line(user, target)
} }

describe (user: Creature, target: Creature): LogEntry {
return nilLog
}
} }


/** /**
@@ -51,7 +51,7 @@ export class DamageConsequence extends Consequence {
) )
} }


describePair (user: Creature, target: Creature): LogEntry {
describe (user: Creature, target: Creature): LogEntry {
return new LogLine( return new LogLine(
this.damageFormula.describe(user, target) this.damageFormula.describe(user, target)
) )
@@ -74,7 +74,7 @@ export class HealingConsequence extends Consequence {
) )
} }


describePair (user: Creature, target: Creature): LogEntry {
describe (user: Creature, target: Creature): LogEntry {
return new LogLine( return new LogLine(
`Heals for `, `Heals for `,
this.damageFormula.describe(user, target) this.damageFormula.describe(user, target)
@@ -94,7 +94,7 @@ export class StatusConsequence extends Consequence {
return target.applyEffect(this.statusMaker(user, target)) return target.applyEffect(this.statusMaker(user, target))
} }


describePair (user: Creature, target: Creature): LogEntry {
describe (user: Creature, target: Creature): LogEntry {
return new LogLine( return new LogLine(
`Applies a ${this.statusMaker(user, target)} effect.` `Applies a ${this.statusMaker(user, target)} effect.`
) )
@@ -112,4 +112,10 @@ export class ConsumeConsequence extends Consequence {
apply (user: Creature, target: Creature): LogEntry { apply (user: Creature, target: Creature): LogEntry {
return this.container.consume(target) return this.container.consume(target)
} }

describe (user: Creature, target: Creature): LogEntry {
return new LogLine(
`Devours the target.`
)
}
} }

+ 4
- 2
src/game/creatures/geta.ts View File

@@ -78,7 +78,8 @@ export class Geta extends Creature {
() => new InstantKillEffect() () => new InstantKillEffect()
), ),
new ArbitraryConsequence( new ArbitraryConsequence(
(user, target) => cock.tick(0)
(user, target) => cock.tick(0),
(user, target) => nilLog
) )
] ]
} }
@@ -168,7 +169,8 @@ export class Geta extends Creature {
], ],
consequences: [ consequences: [
new ArbitraryConsequence( new ArbitraryConsequence(
(user, target) => stomach.consume(target)
(user, target) => stomach.consume(target),
(user, target) => new LogLine(`Devours the target.`)
) )
] ]
} }


Loading…
Cancel
Save