import { ITank } from "./Tank"; type CritMultiplier = (health: number) => number; export const critMultiplier: CritMultiplier = (health) => Math.floor(Math.random() * 10) >= 10 - health / 10 ? 1 : 2; type SetStats = (tank: ITank) => ITank; export const setStats: SetStats = (tank) => ({ ...tank, attackDelay: tank.attackDelay === 0 ? Math.floor(tank.health / 10) : tank.attackDelay - 1, } as ITank); type IsLive = (tank: ITank) => boolean; export const isLive: IsLive = (tank) => tank.health >= 0; type IsOther = (name: string) => (tank: ITank) => boolean; export const isOther: IsOther = (name) => (tank) => tank.name !== name;