Procházet zdrojové kódy

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

master
Fen Dweller před 5 roky
rodič
revize
70a490bf26
2 změnil soubory, kde provedl 17 přidání a 7 odebrání
  1. +9
    -0
      src/game/combat.ts
  2. +8
    -7
      src/game/creatures/withers.ts

+ 9
- 0
src/game/combat.ts Zobrazit soubor

@@ -161,6 +161,7 @@ export class Damage {
export interface DamageFormula {
calc (user: Creature, target: Creature): Damage;
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 {
return this.explain(user)
}

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

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.')
}
}


+ 8
- 7
src/game/creatures/withers.ts Zobrazit soubor

@@ -1,5 +1,5 @@
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 { LogLine, LogLines, LogEntry, Newline } from '../interface'
import { VoreType, Stomach, VoreContainer, Vore, NormalContainer, Container } from '../vore'
@@ -63,14 +63,15 @@ class ChewAction extends GroupAction {
])

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 {
const damage = this.damage.calc(user, target)
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(target.takeDamage(this.damage))
results.push(target.takeDamage(damage))

if (target.vigors.Health <= 0) {
if (this.killAction.allowed(user, target)) {
@@ -86,7 +87,7 @@ class ChewAction extends GroupAction {
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', [
new ContainerCondition(container)
])
@@ -206,9 +207,9 @@ export class Withers extends Creature {

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 }
),
), 0.5),
grapple,
new TransferAction(grapple, stomach)))
}


Načítá se…
Zrušit
Uložit