From e849d8c75ac1bdec7946c73cae30963a2b692dbe Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Fri, 14 Aug 2020 16:28:51 -0400 Subject: [PATCH] Require all Consequences to have a description --- src/game/combat.ts | 11 ++--------- src/game/combat/consequences.ts | 30 ++++++++++++++++++------------ src/game/creatures/geta.ts | 6 ++++-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/game/combat.ts b/src/game/combat.ts index 3779998..5a397e2 100644 --- a/src/game/combat.ts +++ b/src/game/combat.ts @@ -432,7 +432,7 @@ export class CompositionAction extends Action { describe (user: Creature, target: Creature): LogEntry { return new LogLines( - ...this.consequences.map(consequence => consequence.describePair(user, target)).concat( + ...this.consequences.map(consequence => consequence.describe(user, target)).concat( new Newline(), super.describe(user, target) ) @@ -705,13 +705,6 @@ export abstract class Consequence { 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 } diff --git a/src/game/combat/consequences.ts b/src/game/combat/consequences.ts index aa78748..e011db3 100644 --- a/src/game/combat/consequences.ts +++ b/src/game/combat/consequences.ts @@ -8,17 +8,13 @@ import { Container } from '../vore' * Takes a function, and thus can do anything. */ 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) } - - 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 { 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( 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( `Heals for `, this.damageFormula.describe(user, target) @@ -94,7 +94,7 @@ export class StatusConsequence extends Consequence { return target.applyEffect(this.statusMaker(user, target)) } - describePair (user: Creature, target: Creature): LogEntry { + describe (user: Creature, target: Creature): LogEntry { return new LogLine( `Applies a ${this.statusMaker(user, target)} effect.` ) @@ -112,4 +112,10 @@ export class ConsumeConsequence extends Consequence { apply (user: Creature, target: Creature): LogEntry { return this.container.consume(target) } + + describe (user: Creature, target: Creature): LogEntry { + return new LogLine( + `Devours the target.` + ) + } } diff --git a/src/game/creatures/geta.ts b/src/game/creatures/geta.ts index 73842c3..b845e56 100644 --- a/src/game/creatures/geta.ts +++ b/src/game/creatures/geta.ts @@ -78,7 +78,8 @@ export class Geta extends Creature { () => new InstantKillEffect() ), 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: [ new ArbitraryConsequence( - (user, target) => stomach.consume(target) + (user, target) => stomach.consume(target), + (user, target) => new LogLine(`Devours the target.`) ) ] }