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
|
|
|
|
2021-11-12 03:35:26 +01:00
|
|
|
return Math.min(p.money * 0.1, (p.max_hp - p.hp) * 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 {
|
2021-09-05 01:09:30 +02:00
|
|
|
const oldhp = p.hp;
|
|
|
|
p.hp -= damage;
|
|
|
|
const cost = getHospitalizationCost(p);
|
|
|
|
p.hp = oldhp;
|
|
|
|
return cost;
|
|
|
|
}
|