Ver código fonte

Add a damage formula that combines other formulas

vintage
Fen Dweller 5 anos atrás
pai
commit
0f35aa64dd
1 arquivos alterados com 18 adições e 0 exclusões
  1. +18
    -0
      src/game/combat.ts

+ 18
- 0
src/game/combat.ts Ver arquivo

@@ -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.
*/


Carregando…
Cancelar
Salvar