bitburner-src/src/Hospital/Hospital.ts

19 lines
512 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;
}
return Math.min(p.money * 0.1, (p.hp.max - p.hp.current) * CONSTANTS.HospitalCostPerHp);
}
2022-05-21 00:18:42 +02:00
export function calculateHospitalizationCost(p: IPlayer, damage: number): number {
const oldhp = p.hp.current;
p.hp.current -= damage;
2021-09-05 01:09:30 +02:00
const cost = getHospitalizationCost(p);
p.hp.current = oldhp;
2021-09-05 01:09:30 +02:00
return cost;
}