'Functional version' broke, cba to fix :)

This commit is contained in:
2023-12-06 01:41:04 +01:00
parent 545f8b4366
commit 74c40576cf
6 changed files with 9 additions and 54 deletions

View File

@@ -1,6 +1,6 @@
import { mapR } from "./reducers";
import { doIf, tap } from "./combinators";
import { isLive, setProp, dealDamageToRandom, isReadyToAttack } from "./helpers";
import { mapR, pipe } from "./reducers";
export interface ITank {
name: string;
@@ -23,7 +23,7 @@ const attack: Attack = (_acc, tank, _iTank, tanks) => {
dealDamageToRandom(tanks)
)
)(tank);
return mapR(setProp("attackDelay", tank))(tanks);
return mapR(setProp("attackDelay", isReadyToAttack(tank) ? Math.floor(tank.health / 10) : tank.attackDelay - 1))(tanks);
};
type Attacks = (tanks: ITank[]) => ITank[];