Quellcode durchsuchen

Allow damage formulas to be explained with just the user's info

vintage
Fen Dweller vor 5 Jahren
Ursprung
Commit
70a490bf26
2 geänderte Dateien mit 17 neuen und 7 gelöschten Zeilen
  1. +9
    -0
      src/game/combat.ts
  2. +8
    -7
      src/game/creatures/withers.ts

+ 9
- 0
src/game/combat.ts Datei anzeigen

@@ -161,6 +161,7 @@ export class Damage {
export interface DamageFormula { export interface DamageFormula {
calc (user: Creature, target: Creature): Damage; calc (user: Creature, target: Creature): Damage;
describe (user: Creature, target: Creature): LogEntry; describe (user: Creature, target: Creature): LogEntry;
explain (user: Creature): LogEntry;
} }


/** /**
@@ -176,6 +177,10 @@ export class ConstantDamageFormula implements DamageFormula {
} }


describe (user: Creature, target: Creature): LogEntry { describe (user: Creature, target: Creature): LogEntry {
return this.explain(user)
}

explain (user: Creature): LogEntry {
return new LogLine('Deal ', this.damage.renderShort(), ' damage') return new LogLine('Deal ', this.damage.renderShort(), ' damage')
} }
} }
@@ -193,6 +198,10 @@ export class UniformRandomDamageFormula implements DamageFormula {
} }


describe (user: Creature, target: Creature): LogEntry { describe (user: Creature, target: Creature): LogEntry {
return this.explain(user)
}

explain (user: Creature): LogEntry {
return new LogLine('Deal between ', this.damage.scale(1 - this.variance).renderShort(), ' and ', this.damage.scale(1 + this.variance).renderShort(), ' damage.') return new LogLine('Deal between ', this.damage.scale(1 - this.variance).renderShort(), ' and ', this.damage.scale(1 + this.variance).renderShort(), ' damage.')
} }
} }


+ 8
- 7
src/game/creatures/withers.ts Datei anzeigen

@@ -1,5 +1,5 @@
import { Creature, POV } from '../entity' import { Creature, POV } from '../entity'
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, CombatTest, Stat, Action } from '../combat'
import { Damage, DamageType, ConstantDamageFormula, Vigor, Side, GroupAction, CombatTest, Stat, Action, DamageFormula, UniformRandomDamageFormula } from '../combat'
import { ImproperNoun, POVPair, ProperNoun, FemalePronouns, RandomWord, Adjective, POVPairArgs, POVSoloArgs, Verb } from '../language' import { ImproperNoun, POVPair, ProperNoun, FemalePronouns, RandomWord, Adjective, POVPairArgs, POVSoloArgs, Verb } from '../language'
import { LogLine, LogLines, LogEntry, Newline } from '../interface' import { LogLine, LogLines, LogEntry, Newline } from '../interface'
import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore' import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore'
@@ -63,14 +63,15 @@ class ChewAction extends GroupAction {
]) ])


describeGroup (user: Creature, targets: Creature[]): LogEntry { describeGroup (user: Creature, targets: Creature[]): LogEntry {
return new LogLine('CRUNCH')
return new LogLine('Crunch \'em all. ', this.damage.explain(user))
} }


execute (user: Creature, target: Creature): LogEntry { execute (user: Creature, target: Creature): LogEntry {
const damage = this.damage.calc(user, target)
const results: Array<LogEntry> = [] const results: Array<LogEntry> = []
results.push(this.lines.run(user, target, { damage: this.damage }))
results.push(this.lines.run(user, target, { damage: damage }))
results.push(new LogLine(' ')) results.push(new LogLine(' '))
results.push(target.takeDamage(this.damage))
results.push(target.takeDamage(damage))


if (target.vigors.Health <= 0) { if (target.vigors.Health <= 0) {
if (this.killAction.allowed(user, target)) { if (this.killAction.allowed(user, target)) {
@@ -86,7 +87,7 @@ class ChewAction extends GroupAction {
return new LogLine('Do the crunch') return new LogLine('Do the crunch')
} }


constructor (private damage: Damage, container: Container, private killAction: Action) {
constructor (private damage: DamageFormula, container: Container, private killAction: Action) {
super('Chew', 'Give them the big chew', [ super('Chew', 'Give them the big chew', [
new ContainerCondition(container) new ContainerCondition(container)
]) ])
@@ -206,9 +207,9 @@ export class Withers extends Creature {


this.otherContainers.push(grapple) this.otherContainers.push(grapple)


this.actions.push(new ChewAction(new Damage(
this.actions.push(new ChewAction(new UniformRandomDamageFormula(new Damage(
{ target: Vigor.Health, type: DamageType.Crush, amount: 10000 } { target: Vigor.Health, type: DamageType.Crush, amount: 10000 }
),
), 0.5),
grapple, grapple,
new TransferAction(grapple, stomach))) new TransferAction(grapple, stomach)))
} }


Laden…
Abbrechen
Speichern