mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-13 11:13:50 +01:00
19 lines
480 B
TypeScript
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;
|
|
}
|