From c3b2c6396c30159b1cd980262d3d5b51ec6836de Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sun, 16 Oct 2022 14:25:42 -0400 Subject: [PATCH] lint and made a some code more robust to older save file --- src/NetscriptFunctions.ts | 9 +-------- src/PersonObjects/PersonMethods.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 516f57dfd..b4a49d830 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -61,14 +61,7 @@ import { NetscriptCorporation } from "./NetscriptFunctions/Corporation"; import { NetscriptFormulas } from "./NetscriptFunctions/Formulas"; import { NetscriptStockMarket } from "./NetscriptFunctions/StockMarket"; import { NetscriptGrafting } from "./NetscriptFunctions/Grafting"; -import { - NS, - RecentScript as IRecentScript, - BasicHGWOptions, - ProcessInfo, - MoneySource as IMoneySource, - MoneySources as IMoneySources, -} from "./ScriptEditor/NetscriptDefinitions"; +import { NS, RecentScript as IRecentScript, BasicHGWOptions, ProcessInfo } from "./ScriptEditor/NetscriptDefinitions"; import { NetscriptSingularity } from "./NetscriptFunctions/Singularity"; import { dialogBoxCreate } from "./ui/React/DialogBox"; diff --git a/src/PersonObjects/PersonMethods.ts b/src/PersonObjects/PersonMethods.ts index 2866c7da4..9f2388075 100644 --- a/src/PersonObjects/PersonMethods.ts +++ b/src/PersonObjects/PersonMethods.ts @@ -51,8 +51,10 @@ export function gainDefenseExp(this: Person, exp: number): void { this.mults.defense * BitNodeMultipliers.DefenseLevelMultiplier, ); const ratio = this.hp.current / this.hp.max; - this.hp.max = Math.floor(10 + this.skills.defense / 10); - this.hp.current = Math.round(this.hp.max * ratio); + this.hp = { + max: Math.floor(10 + this.skills.defense / 10), + current: Math.round(this.hp.max * ratio), + }; } export function gainDexterityExp(this: Person, exp: number): void { @@ -194,8 +196,10 @@ 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); - this.hp.current = Math.round(this.hp.max * ratio); + this.hp = { + max: Math.floor(10 + this.skills.defense / 10), + current: Math.round(this.hp.max * ratio), + }; } export function hasAugmentation(this: Person, augName: string, ignoreQueued = false) {