mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 01:23:49 +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;
|
const ratio: number = Math.min(this.hp.current / this.hp.max, 1);
|
||||||
this.hp = {
|
this.hp.max = Math.floor(10 + this.skills.defense / 10);
|
||||||
max: Math.floor(10 + this.skills.defense / 10),
|
this.hp.current = Math.round(this.hp.max * ratio);
|
||||||
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. */
|
/** Initializes a PlayerObject object from a JSON save state. */
|
||||||
static fromJSON(value: IReviverValue): PlayerObject {
|
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);
|
const player = Generic_fromJSON(PlayerObject, value.data);
|
||||||
if (player.money === null) player.money = 0;
|
if (player.money === null) player.money = 0;
|
||||||
return player;
|
return player;
|
||||||
|
@ -133,6 +133,10 @@ export class Sleeve extends Person implements SleevePerson {
|
|||||||
|
|
||||||
/** Called on every sleeve for a Source File Prestige */
|
/** Called on every sleeve for a Source File Prestige */
|
||||||
prestige(): void {
|
prestige(): void {
|
||||||
|
// Reset augs and multipliers
|
||||||
|
this.augmentations = [];
|
||||||
|
this.resetMultipliers();
|
||||||
|
|
||||||
// Reset exp
|
// Reset exp
|
||||||
this.exp.hacking = 0;
|
this.exp.hacking = 0;
|
||||||
this.exp.strength = 0;
|
this.exp.strength = 0;
|
||||||
@ -147,12 +151,7 @@ export class Sleeve extends Person implements SleevePerson {
|
|||||||
this.stopWork();
|
this.stopWork();
|
||||||
this.shockRecovery();
|
this.shockRecovery();
|
||||||
|
|
||||||
// Reset augs and multipliers
|
|
||||||
this.augmentations = [];
|
|
||||||
this.resetMultipliers();
|
|
||||||
|
|
||||||
// Reset Location
|
// Reset Location
|
||||||
|
|
||||||
this.city = CityName.Sector12;
|
this.city = CityName.Sector12;
|
||||||
|
|
||||||
// Reset sleeve-related stats
|
// Reset sleeve-related stats
|
||||||
@ -470,6 +469,7 @@ export class Sleeve extends Person implements SleevePerson {
|
|||||||
|
|
||||||
/** Initializes a Sleeve object from a JSON save state. */
|
/** Initializes a Sleeve object from a JSON save state. */
|
||||||
static fromJSON(value: IReviverValue): Sleeve {
|
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);
|
return Generic_fromJSON(Sleeve, value.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user