diff --git a/src/game/combat.ts b/src/game/combat.ts index 7adf216..cc8aad6 100644 --- a/src/game/combat.ts +++ b/src/game/combat.ts @@ -90,12 +90,6 @@ export interface CombatTest { explain: (user: Creature, target: Creature) => LogEntry; } -export interface Effect { - name: string; - desc: string; - apply: (target: Creature) => LogEntry; -} - /** * An instance of damage. Contains zero or more [[DamageInstance]] objects */ @@ -374,41 +368,3 @@ export abstract class StatusEffect implements VisibleStatus { } } } - -export class StunEffect extends StatusEffect { - constructor (private duration: number) { - super('Stun', 'Cannot act!', 'fas fa-sun') - this.desc = new DynText('Stunned for your next ', new LiveText(this, x => x.duration), ' actions!') - } - - get topLeft () { - return this.duration.toString() - } - - onApply (creature: Creature) { - return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} is stunned!`) - } - - onRemove (creature: Creature) { - return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} no longer stunned.`) - } - - preAction (creature: Creature): { prevented: boolean; log: LogEntry } { - if (--this.duration <= 0) { - return { - prevented: true, - log: new LogLines( - `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move.`, - creature.removeEffect(this) - ) - } - } else { - return { - prevented: true, - log: new LogLines( - `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move!` - ) - } - } - } -} diff --git a/src/game/combat/effects.ts b/src/game/combat/effects.ts index 2c302e6..b29541d 100644 --- a/src/game/combat/effects.ts +++ b/src/game/combat/effects.ts @@ -1,18 +1,58 @@ +import { StatusEffect, Damage } from '../combat' +import { DynText, LiveText, ToBe } from '../language' import { Creature } from '../entity' -import { LogEntry, LogLine, FAElem } from '../interface' -import { Effect } from '../combat' -import { SoloLine, ToBe } from '../language' +import { LogLine, LogEntry, LogLines, FAElem } from '../interface' -export class InstantKill implements Effect { - line: SoloLine = (victim) => new LogLine( - `${victim.name.capital} ${victim.name.conjugate(new ToBe())} killed instantly!`, - new FAElem('fas fa-skull') - ) +export class InstantKillEffect extends StatusEffect { + constructor () { + super('Instant Kill', 'Instant kill!', 'fas fa-skull') + } + + onApply (creature: Creature) { + creature.vigors.Health = 0 + return new LogLines( + new LogLine( + `${creature.name.capital} ${creature.name.conjugate(new ToBe())} killed instantly! `, + new FAElem('fas fa-skull') + ), + creature.takeDamage(new Damage()) + ) + } +} +export class StunEffect extends StatusEffect { + constructor (private duration: number) { + super('Stun', 'Cannot act!', 'fas fa-sun') + this.desc = new DynText('Stunned for your next ', new LiveText(this, x => x.duration), ' actions!') + } + + get topLeft () { + return this.duration.toString() + } + + onApply (creature: Creature) { + return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} is stunned!`) + } + + onRemove (creature: Creature) { + return new LogLine(`${creature.name.capital} ${creature.name.conjugate(new ToBe())} no longer stunned.`) + } - name = "Instant Kill" - desc = "Instantly kills its victim" - apply (target: Creature): LogEntry { - target.vigors.Health = Math.min(0, target.vigors.Health) - return this.line(target) + preAction (creature: Creature): { prevented: boolean; log: LogEntry } { + if (--this.duration <= 0) { + return { + prevented: true, + log: new LogLines( + `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move.`, + creature.removeEffect(this) + ) + } + } else { + return { + prevented: true, + log: new LogLines( + `${creature.name.capital} ${creature.name.conjugate(new ToBe())} stunned! ${creature.pronouns.capital.subjective} can't move!` + ) + } + } } } diff --git a/src/game/creatures/cafat.ts b/src/game/creatures/cafat.ts index 131e213..7f3626d 100644 --- a/src/game/creatures/cafat.ts +++ b/src/game/creatures/cafat.ts @@ -4,7 +4,7 @@ import { ProperNoun, TheyPronouns, ImproperNoun, FemalePronouns, Verb, POV, Pair import { VoreType, Stomach, InnerStomach, VoreContainer } from '../vore' import { LogLine, LogLines, LogEntry, FAElem, CompositeLog, ImgElem } from '../interface' import { AttackAction, EatenAction, TransferAction, FeedAction } from '../combat/actions' -import { InstantKill } from '../combat/effects' +import { InstantKillEffect } from '../combat/effects' import * as Words from '../words' class BellyCrushAction extends AttackAction { @@ -56,7 +56,7 @@ class CrushAction extends EatenAction { } execute (user: Creature, target: Creature): LogEntry { - return new LogLines(this.line(user, target, { container: this._container }), new InstantKill().apply(target)) + return new LogLines(this.line(user, target, { container: this._container }), target.applyEffect(new InstantKillEffect())) } describe (user: Creature, target: Creature): LogEntry { diff --git a/src/game/creatures/kenzie.ts b/src/game/creatures/kenzie.ts index 5572c9d..0e8f095 100644 --- a/src/game/creatures/kenzie.ts +++ b/src/game/creatures/kenzie.ts @@ -1,10 +1,11 @@ import { Creature } from '../entity' import { ProperNoun, ImproperNoun, FemalePronouns, Verb } from '../language' import { VoreType, Stomach } from '../vore' -import { Side, Damage, DamageType, Vigor, StatDamageFormula, Stat, VoreStat, DamageFormula, StunEffect } from '../combat' +import { Side, Damage, DamageType, Vigor, StatDamageFormula, Stat, VoreStat, DamageFormula } from '../combat' import { AttackAction } from '../combat/actions' import { LogEntry, LogLines } from '../interface' import { StatTest } from '../combat/tests' +import { StunEffect } from '../combat/effects' class StompAttack extends AttackAction { execute (user: Creature, target: Creature): LogEntry { diff --git a/src/game/creatures/withers.ts b/src/game/creatures/withers.ts index c104473..a5a3f68 100644 --- a/src/game/creatures/withers.ts +++ b/src/game/creatures/withers.ts @@ -2,10 +2,10 @@ import { Creature } from '../entity' import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, CombatTest, Stat, DamageFormula, UniformRandomDamageFormula, Action, DamageInstance, StatDamageFormula, VoreStat } from '../combat' import { ImproperNoun, ProperNoun, FemalePronouns, RandomWord, Adjective, Verb, POV, PairLine } from '../language' import { LogLine, LogLines, LogEntry, Newline } from '../interface' -import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore' +import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container, InnerStomach } from '../vore' import { AttackAction, FeedAction, TransferAction, EatenAction } from '../combat/actions' import { TogetherCondition, ContainsCondition, EnemyCondition, AllyCondition, PairCondition, CapableCondition } from '../combat/conditions' -import { InstantKill } from '../combat/effects' +import { InstantKillEffect } from '../combat/effects' import * as Words from '../words' import { StatVigorTest } from '../combat/tests' @@ -197,7 +197,7 @@ class StompAction extends GroupAction { ) execute (user: Creature, target: Creature): LogEntry { - return new LogLines(this.line(user, target), new InstantKill().apply(target)) + return new LogLines(this.line(user, target), target.applyEffect(new InstantKillEffect())) } describe (user: Creature, target: Creature): LogEntry { @@ -237,7 +237,7 @@ class StompAllyAction extends Action { return new LogLines( this.line(user, target), - new InstantKill().apply(target), + target.applyEffect(new InstantKillEffect()), new LogLine(`${user.name.capital} absorbs ${target.pronouns.possessive} power, gaining `, heal.renderShort()) ) }