2022-05-21 00:18:42 +02:00
|
|
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
2021-04-06 09:50:09 +02:00
|
|
|
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-04-06 09:50:09 +02:00
|
|
|
|
2022-07-27 05:54:17 +02:00
|
|
|
return Math.min(p.money * 0.1, (p.hp.max - p.hp.current) * CONSTANTS.HospitalCostPerHp);
|
2021-04-06 09:50:09 +02:00
|
|
|
}
|
|
|
|
|
2022-05-21 00:18:42 +02:00
|
|
|
export function calculateHospitalizationCost(p: IPlayer, damage: number): number {
|
2022-07-27 05:54:17 +02:00
|
|
|
const oldhp = p.hp.current;
|
|
|
|
p.hp.current -= damage;
|
2021-09-05 01:09:30 +02:00
|
|
|
const cost = getHospitalizationCost(p);
|
2022-07-27 05:54:17 +02:00
|
|
|
p.hp.current = oldhp;
|
2021-09-05 01:09:30 +02:00
|
|
|
return cost;
|
|
|
|
}
|