mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
Fix broken HP
This commit is contained in:
parent
7021b905b7
commit
7c6d7206dd
@ -193,10 +193,9 @@ export function updateSkillLevels(this: Person): void {
|
||||
),
|
||||
);
|
||||
|
||||
const ratio: number = this.hp.current / this.hp.max;
|
||||
this.hp = {
|
||||
max: Math.floor(10 + this.skills.defense / 10),
|
||||
current: Math.round(this.hp.max * ratio),
|
||||
const ratio: number = Math.min(this.hp.current / this.hp.max, 1);
|
||||
this.hp.max = Math.floor(10 + this.skills.defense / 10);
|
||||
this.hp.current = Math.round(this.hp.max * ratio);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,7 @@ export class PlayerObject extends Person implements IPlayer {
|
||||
|
||||
/** Initializes a PlayerObject object from a JSON save state. */
|
||||
static fromJSON(value: IReviverValue): PlayerObject {
|
||||
if (!value.data.hp?.current || !value.data.hp?.max) value.data.hp = { current: 10, max: 10 };
|
||||
const player = Generic_fromJSON(PlayerObject, value.data);
|
||||
if (player.money === null) player.money = 0;
|
||||
return player;
|
||||
|
@ -133,6 +133,10 @@ export class Sleeve extends Person implements SleevePerson {
|
||||
|
||||
/** Called on every sleeve for a Source File Prestige */
|
||||
prestige(): void {
|
||||
// Reset augs and multipliers
|
||||
this.augmentations = [];
|
||||
this.resetMultipliers();
|
||||
|
||||
// Reset exp
|
||||
this.exp.hacking = 0;
|
||||
this.exp.strength = 0;
|
||||
@ -147,12 +151,7 @@ export class Sleeve extends Person implements SleevePerson {
|
||||
this.stopWork();
|
||||
this.shockRecovery();
|
||||
|
||||
// Reset augs and multipliers
|
||||
this.augmentations = [];
|
||||
this.resetMultipliers();
|
||||
|
||||
// Reset Location
|
||||
|
||||
this.city = CityName.Sector12;
|
||||
|
||||
// Reset sleeve-related stats
|
||||
@ -470,6 +469,7 @@ export class Sleeve extends Person implements SleevePerson {
|
||||
|
||||
/** Initializes a Sleeve object from a JSON save state. */
|
||||
static fromJSON(value: IReviverValue): Sleeve {
|
||||
if (!value.data.hp?.current || !value.data.hp?.max) value.data.hp = { current: 10, max: 10 };
|
||||
return Generic_fromJSON(Sleeve, value.data);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user