bitburner-src/src/Hospital/Hospital.ts
Olivier Gagnon 0d437e5b73 lint
2022-05-20 18:20:04 -04:00

19 lines
480 B
TypeScript

import { IPlayer } from "../PersonObjects/IPlayer";
import { CONSTANTS } from "../Constants";
export function getHospitalizationCost(p: IPlayer): number {
if (p.money < 0) {
return 0;
}
return Math.min(p.money * 0.1, (p.max_hp - p.hp) * CONSTANTS.HospitalCostPerHp);
}
export function calculateHospitalizationCost(p: IPlayer, damage: number): number {
const oldhp = p.hp;
p.hp -= damage;
const cost = getHospitalizationCost(p);
p.hp = oldhp;
return cost;
}