Procházet zdrojové kódy

Add a damage formula that combines other formulas

master
Fen Dweller před 5 roky
rodič
revize
0f35aa64dd
1 změnil soubory, kde provedl 18 přidání a 0 odebrání
  1. +18
    -0
      src/game/combat.ts

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

@@ -165,6 +165,24 @@ export interface DamageFormula {
explain (user: Creature): LogEntry;
}

export class CompositeDamageFormula implements DamageFormula {
constructor (private formulas: DamageFormula[]) {

}

calc (user: Creature, target: Creature): Damage {
return this.formulas.reduce((total: Damage, next: DamageFormula) => total.combine(next.calc(user, target)), new Damage())
}

describe (user: Creature, target: Creature): LogEntry {
return new LogLines(...this.formulas.map(formula => formula.describe(user, target)))
}

explain (user: Creature): LogEntry {
return new LogLines(...this.formulas.map(formula => formula.explain(user)))
}
}

/**
* Simply returns the damage it was given.
*/


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