bitburner-src/src/Hospital/Hospital.ts

19 lines
506 B
TypeScript
Raw Normal View History

import { Player } from "@player";
import { CONSTANTS } from "../Constants";
2022-09-06 15:07:12 +02:00
export function getHospitalizationCost(): number {
if (Player.money < 0) {
2021-09-05 01:09:30 +02:00
return 0;
}
2022-09-06 15:07:12 +02:00
return Math.min(Player.money * 0.1, (Player.hp.max - Player.hp.current) * CONSTANTS.HospitalCostPerHp);
}
2022-09-06 15:07:12 +02:00
export function calculateHospitalizationCost(damage: number): number {
const oldhp = Player.hp.current;
Player.hp.current -= damage;
const cost = getHospitalizationCost();
Player.hp.current = oldhp;
2021-09-05 01:09:30 +02:00
return cost;
}