bitburner-src/src/Hospital/Hospital.ts

19 lines
480 B
TypeScript
Raw Normal View History

2022-05-21 00:18:42 +02:00
import { IPlayer } from "../PersonObjects/IPlayer";
import { CONSTANTS } from "../Constants";
2022-05-21 00:18:42 +02:00
export function getHospitalizationCost(p: IPlayer): number {
2021-11-12 03:35:26 +01:00
if (p.money < 0) {
2021-09-05 01:09:30 +02:00
return 0;
}
2021-11-12 03:35:26 +01:00
return Math.min(p.money * 0.1, (p.max_hp - p.hp) * CONSTANTS.HospitalCostPerHp);
}
2022-05-21 00:18:42 +02:00
export function calculateHospitalizationCost(p: IPlayer, damage: number): number {
2021-09-05 01:09:30 +02:00
const oldhp = p.hp;
p.hp -= damage;
const cost = getHospitalizationCost(p);
p.hp = oldhp;
return cost;
}