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