From 332b8033327adb3ec4ae32a79bb5c07a5121aa4d Mon Sep 17 00:00:00 2001 From: rderfler <44448965+rderfler@users.noreply.github.com> Date: Thu, 14 Apr 2022 15:28:13 -0400 Subject: [PATCH] Fmt and lint --- src/Bladeburner/Bladeburner.tsx | 6 +- src/PersonObjects/Person.ts | 203 ++++++++++++------ src/PersonObjects/Player/PlayerObject.ts | 7 +- .../Player/PlayerObjectGeneralMethods.tsx | 4 +- src/PersonObjects/Sleeve/Sleeve.ts | 4 +- src/PersonObjects/Sleeve/ui/SleeveElem.tsx | 3 +- src/PersonObjects/Sleeve/ui/TaskSelector.tsx | 2 +- 7 files changed, 154 insertions(+), 75 deletions(-) diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index 4dd630242..b7fa6664e 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -1456,9 +1456,7 @@ export class Bladeburner implements IBladeburner { } this.teamLost += losses; if (this.logging.blackops) { - this.log( - `${person.whoAmI()}: ` + "You lost " + formatNumber(losses, 0) + " team members during " + action.name, - ); + this.log(`${person.whoAmI()}: You lost ${formatNumber(losses, 0)} team members during ${action.name}`); } } } catch (e: any) { @@ -1595,7 +1593,7 @@ export class Bladeburner implements IBladeburner { this.operations[operation].count += (60 * 3 * growthF()) / BladeburnerConstants.ActionCountGrowthPeriod; } if (this.logging.general) { - this.log(`${person.whoAmI()}: ` + `Incited violence in the synthoid communities.`); + this.log(`${person.whoAmI()}: Incited violence in the synthoid communities.`); } for (const cityName of Object.keys(this.cities)) { const city = this.cities[cityName]; diff --git a/src/PersonObjects/Person.ts b/src/PersonObjects/Person.ts index 3b87840af..70daf5ba2 100644 --- a/src/PersonObjects/Person.ts +++ b/src/PersonObjects/Person.ts @@ -15,74 +15,74 @@ export abstract class Person implements IPerson { /** * Stats */ - hacking = 1; - strength = 1; - defense = 1; - dexterity = 1; - agility = 1; - charisma = 1; - intelligence = 1; - hp = 10; - max_hp = 10; - money = 0; + hacking; + strength; + defense; + dexterity; + agility; + charisma; + intelligence; + hp; + max_hp; + money; /** * Experience */ - hacking_exp = 0; - strength_exp = 0; - defense_exp = 0; - dexterity_exp = 0; - agility_exp = 0; - charisma_exp = 0; - intelligence_exp = 0; + hacking_exp; + strength_exp; + defense_exp; + dexterity_exp; + agility_exp; + charisma_exp; + intelligence_exp; /** * Multipliers */ - hacking_mult = 1; - strength_mult = 1; - defense_mult = 1; - dexterity_mult = 1; - agility_mult = 1; - charisma_mult = 1; + hacking_mult; + strength_mult; + defense_mult; + dexterity_mult; + agility_mult; + charisma_mult; - hacking_exp_mult = 1; - strength_exp_mult = 1; - defense_exp_mult = 1; - dexterity_exp_mult = 1; - agility_exp_mult = 1; - charisma_exp_mult = 1; + hacking_exp_mult; + strength_exp_mult; + defense_exp_mult; + dexterity_exp_mult; + agility_exp_mult; + charisma_exp_mult; - hacking_chance_mult = 1; - hacking_speed_mult = 1; - hacking_money_mult = 1; - hacking_grow_mult = 1; + hacking_chance_mult; + hacking_speed_mult; + hacking_money_mult; + hacking_grow_mult; - company_rep_mult = 1; - faction_rep_mult = 1; + company_rep_mult; + faction_rep_mult; - crime_money_mult = 1; - crime_success_mult = 1; + crime_money_mult; + crime_success_mult; - work_money_mult = 1; + work_money_mult; - hacknet_node_money_mult = 1; - hacknet_node_purchase_cost_mult = 1; - hacknet_node_ram_cost_mult = 1; - hacknet_node_core_cost_mult = 1; - hacknet_node_level_cost_mult = 1; + hacknet_node_money_mult; + hacknet_node_purchase_cost_mult; + hacknet_node_ram_cost_mult; + hacknet_node_core_cost_mult; + hacknet_node_level_cost_mult; - bladeburner_max_stamina_mult = 1; - bladeburner_stamina_gain_mult = 1; - bladeburner_analysis_mult = 1; - bladeburner_success_chance_mult = 1; + bladeburner_max_stamina_mult; + bladeburner_stamina_gain_mult; + bladeburner_analysis_mult; + bladeburner_success_chance_mult; /** * Augmentations */ - augmentations: IPlayerOwnedAugmentation[] = []; - queuedAugmentations: IPlayerOwnedAugmentation[] = []; + augmentations: IPlayerOwnedAugmentation[]; + queuedAugmentations: IPlayerOwnedAugmentation[]; /** * City that the person is in @@ -101,6 +101,97 @@ export abstract class Person implements IPerson { regenerateHp: (amt: number) => void; queryStatFromString: (str: string) => number; + constructor() { + /** + * Stats + */ + this.hacking = 1; + this.strength = 1; + this.defense = 1; + this.dexterity = 1; + this.agility = 1; + this.charisma = 1; + this.intelligence = 1; + this.hp = 10; + this.max_hp = 10; + this.money = 0; + + /** + * Experience + */ + this.hacking_exp = 0; + this.strength_exp = 0; + this.defense_exp = 0; + this.dexterity_exp = 0; + this.agility_exp = 0; + this.charisma_exp = 0; + this.intelligence_exp = 0; + + /** + * Multipliers + */ + this.hacking_mult = 1; + this.strength_mult = 1; + this.defense_mult = 1; + this.dexterity_mult = 1; + this.agility_mult = 1; + this.charisma_mult = 1; + + this.hacking_exp_mult = 1; + this.strength_exp_mult = 1; + this.defense_exp_mult = 1; + this.dexterity_exp_mult = 1; + this.agility_exp_mult = 1; + this.charisma_exp_mult = 1; + + this.hacking_chance_mult = 1; + this.hacking_speed_mult = 1; + this.hacking_money_mult = 1; + this.hacking_grow_mult = 1; + + this.company_rep_mult = 1; + this.faction_rep_mult = 1; + + this.crime_money_mult = 1; + this.crime_success_mult = 1; + + this.work_money_mult = 1; + + this.hacknet_node_money_mult = 1; + this.hacknet_node_purchase_cost_mult = 1; + this.hacknet_node_ram_cost_mult = 1; + this.hacknet_node_core_cost_mult = 1; + this.hacknet_node_level_cost_mult = 1; + + this.bladeburner_max_stamina_mult = 1; + this.bladeburner_stamina_gain_mult = 1; + this.bladeburner_analysis_mult = 1; + this.bladeburner_success_chance_mult = 1; + + /** + * Augmentations + */ + this.augmentations = []; + this.queuedAugmentations = []; + + /** + * City that the person is in + */ + this.city = CityName.Sector12; + + this.gainHackingExp = generalMethods.gainHackingExp; + this.gainStrengthExp = generalMethods.gainStrengthExp; + this.gainDefenseExp = generalMethods.gainDefenseExp; + this.gainDexterityExp = generalMethods.gainDexterityExp; + this.gainAgilityExp = generalMethods.gainAgilityExp; + this.gainCharismaExp = generalMethods.gainCharismaExp; + this.gainIntelligenceExp = generalMethods.gainIntelligenceExp; + this.gainStats = generalMethods.gainStats; + this.calculateSkill = generalMethods.calculateSkill; + this.regenerateHp = generalMethods.regenerateHp; + this.queryStatFromString = generalMethods.queryStatFromString; + } + /** * Updates this object's multipliers for the given augmentation */ @@ -237,20 +328,6 @@ export abstract class Person implements IPerson { abstract takeDamage(amt: number): boolean; abstract whoAmI(): string; - - constructor() { - this.gainHackingExp = generalMethods.gainHackingExp; - this.gainStrengthExp = generalMethods.gainStrengthExp; - this.gainDefenseExp = generalMethods.gainDefenseExp; - this.gainDexterityExp = generalMethods.gainDexterityExp; - this.gainAgilityExp = generalMethods.gainAgilityExp; - this.gainCharismaExp = generalMethods.gainCharismaExp; - this.gainIntelligenceExp = generalMethods.gainIntelligenceExp; - this.gainStats = generalMethods.gainStats; - this.calculateSkill = generalMethods.calculateSkill; - this.regenerateHp = generalMethods.regenerateHp; - this.queryStatFromString = generalMethods.queryStatFromString; - } } Reviver.constructors.Person = Person; diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index b2c089c6b..d420ddce0 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -304,9 +304,6 @@ export class PlayerObject implements IPlayer { graftAugmentationWork: (numCycles: number) => boolean; finishGraftAugmentationWork: (cancelled: boolean) => string; applyEntropy: (stacks?: number) => void; - whoAmI(): string { - return "Player"; - } constructor() { //Skills and stats @@ -634,6 +631,10 @@ export class PlayerObject implements IPlayer { this.applyEntropy = augmentationMethods.applyEntropy; } + whoAmI(): string { + return "Player"; + } + /** * Serialize the current object to a JSON save state. */ diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index d14b2b81e..493af8a1c 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -67,6 +67,7 @@ import { achievements } from "../../Achievements/Achievements"; import { FactionNames } from "../../Faction/data/FactionNames"; import { ITaskTracker } from "../ITaskTracker"; import { IPerson } from "../IPerson"; +import { use } from "../../ui/Context"; export function init(this: IPlayer): void { /* Initialize Player's home computer */ @@ -468,7 +469,8 @@ export function gainIntelligenceExp(this: IPerson, exp: number): void { console.error("ERROR: NaN passed into Player.gainIntelligenceExp()"); return; } - if (this.sourceFileLvl(5) > 0 || this.intelligence > 0) { + const player = use.Player(); + if (player.sourceFileLvl(5) > 0 || this.intelligence > 0) { this.intelligence_exp += exp; this.intelligence = Math.floor(this.calculateSkill(this.intelligence_exp, 1)); } diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index 9d80e01e2..52a27dd69 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -1091,8 +1091,8 @@ export class Sleeve extends Person { break; case "Recruitment": time = this.getBladeburnerActionTime(p, "General", action); - const recruitTime = (p.bladeburner?.getRecruitmentTime(this) ?? 0) * 1000; - this.gainRatesForTask.cha = 2 * BladeburnerConstants.BaseStatGain * recruitTime; + this.gainRatesForTask.cha = + 2 * BladeburnerConstants.BaseStatGain * (p.bladeburner?.getRecruitmentTime(this) ?? 0) * 1000; this.currentTaskLocation = (p.bladeburner?.getRecruitmentSuccessChance(this) ?? 0).toString() + "%"; break; case "Diplomacy": diff --git a/src/PersonObjects/Sleeve/ui/SleeveElem.tsx b/src/PersonObjects/Sleeve/ui/SleeveElem.tsx index 355f17f43..2c5cba2c4 100644 --- a/src/PersonObjects/Sleeve/ui/SleeveElem.tsx +++ b/src/PersonObjects/Sleeve/ui/SleeveElem.tsx @@ -113,7 +113,7 @@ export function SleeveElem(props: IProps): React.ReactElement { case SleeveTaskType.Gym: desc = <>This sleeve is currently working out at {props.sleeve.currentTaskLocation}.; break; - case SleeveTaskType.Bladeburner: + case SleeveTaskType.Bladeburner: { let contract = ""; if (props.sleeve.bbContract !== "------") { contract = ` - ${props.sleeve.bbContract} (Success Rate: ${props.sleeve.currentTaskLocation})`; @@ -125,6 +125,7 @@ export function SleeveElem(props: IProps): React.ReactElement { ); break; + } case SleeveTaskType.Recovery: desc = ( <> diff --git a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx index 0e81213f5..a5fb04c59 100644 --- a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx +++ b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx @@ -236,7 +236,7 @@ const canDo: { [CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city), "Workout at Gym": (player: IPlayer, sleeve: Sleeve) => [CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city), - "Perform Bladeburner Actions": (player: IPlayer, sleeve: Sleeve) => player.inBladeburner(), + "Perform Bladeburner Actions": (player: IPlayer, _: Sleeve) => player.inBladeburner(), "Shock Recovery": (player: IPlayer, sleeve: Sleeve) => sleeve.shock < 100, Synchronize: (player: IPlayer, sleeve: Sleeve) => sleeve.sync < 100, };