From 04062729423f2de35d173236467f3644a8ec5dfe Mon Sep 17 00:00:00 2001 From: rderfler <44448965+rderfler@users.noreply.github.com> Date: Thu, 14 Apr 2022 11:57:01 -0400 Subject: [PATCH] Clean up linter --- src/Bladeburner/Bladeburner.tsx | 17 +++++++------ src/NetscriptFunctions/Bladeburner.ts | 4 ++-- src/PersonObjects/IPerson.ts | 8 +++---- src/PersonObjects/ITaskTracker.ts | 4 ++-- src/PersonObjects/Person.ts | 25 ++++++++++---------- src/PersonObjects/Sleeve/Sleeve.ts | 12 +++++----- src/PersonObjects/Sleeve/ui/SleeveElem.tsx | 4 ++-- src/PersonObjects/Sleeve/ui/TaskSelector.tsx | 7 +++--- 8 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index 7dee7aae3..8294114bd 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -38,7 +38,6 @@ import { WorkerScript } from "../Netscript/WorkerScript"; import { FactionNames } from "../Faction/data/FactionNames"; import { BlackOperationNames } from "./data/BlackOperationNames"; import { KEY } from "../utils/helpers/keyCodes"; -import { Player } from "src/Player"; interface BlackOpsAttempt { error?: string; @@ -1022,7 +1021,7 @@ export class Bladeburner implements IBladeburner { const unweightedGain = time * BladeburnerConstants.BaseStatGain * successMult * difficultyMult; const unweightedIntGain = time * BladeburnerConstants.BaseIntGain * successMult * difficultyMult; const skillMult = this.skillMultipliers.expGain; - + return { hack: unweightedGain * action.weights.hack * skillMult, str: unweightedGain * action.weights.str * skillMult, @@ -1136,7 +1135,7 @@ export class Bladeburner implements IBladeburner { const losses = getRandomInt(0, max); this.teamSize -= losses; if(this.teamSize < this.sleeveSize) { - let sup = player.sleeves.filter(x => x.bbAction == 'Support main sleeve'); + const sup = player.sleeves.filter(x => x.bbAction == 'Support main sleeve'); for(let i = 0; i > (this.teamSize-this.sleeveSize); i--){ const r = Math.floor(Math.random() * sup.length); sup[r].takeDamage(sup[r].max_hp); @@ -1314,7 +1313,7 @@ export class Bladeburner implements IBladeburner { this.log(`${person.whoAmI()}: ` + action.name + " successfully completed! Gained " + formatNumber(gain, 3) + " rank"); } else if (!isOperation && this.logging.contracts) { this.log( - `${person.whoAmI()}: ` + + `${person.whoAmI()}: ` + action.name + " contract successfully completed! Gained " + formatNumber(gain, 3) + @@ -1422,7 +1421,7 @@ export class Bladeburner implements IBladeburner { if (this.logging.blackops) { this.log( - `${person.whoAmI()}: ` + + `${person.whoAmI()}: ` + action.name + " failed! Lost " + formatNumber(rankLoss, 1) + @@ -1440,7 +1439,7 @@ export class Bladeburner implements IBladeburner { const losses = getRandomInt(1, teamLossMax); this.teamSize -= losses; if(this.teamSize < this.sleeveSize) { - let sup = player.sleeves.filter(x => x.bbAction == 'Support main sleeve'); + const sup = player.sleeves.filter(x => x.bbAction == 'Support main sleeve'); for(let i = 0; i > (this.teamSize-this.sleeveSize); i--){ const r = Math.floor(Math.random() * sup.length); sup[r].takeDamage(sup[r].max_hp); @@ -1472,7 +1471,7 @@ export class Bladeburner implements IBladeburner { this.staminaBonus += staminaGain; if (this.logging.general) { this.log( - `${person.whoAmI()}: ` + + `${person.whoAmI()}: ` + "Training completed. Gained: " + formatNumber(strExpGain, 1) + " str exp, " + @@ -1509,7 +1508,7 @@ export class Bladeburner implements IBladeburner { this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate); if (this.logging.general) { this.log( - `${person.whoAmI()}: ` + + `${person.whoAmI()}: ` + `Field analysis completed. Gained ${formatNumber(rankGain, 2)} rank, ` + `${formatNumber(hackingExpGain, 1)} hacking exp, and ` + `${formatNumber(charismaExpGain, 1)} charisma exp`, @@ -1655,7 +1654,7 @@ export class Bladeburner implements IBladeburner { this.actionTimeOverflow = 0; if (this.actionTimeCurrent >= this.actionTimeToComplete) { this.actionTimeOverflow = this.actionTimeCurrent - this.actionTimeToComplete; - let retValue = this.completeAction(player, player, this.action); + const retValue = this.completeAction(player, player, this.action); player.gainMoney(retValue.money, "bladeburner"); player.gainStats(retValue); // Operation Daedalus diff --git a/src/NetscriptFunctions/Bladeburner.ts b/src/NetscriptFunctions/Bladeburner.ts index 73ea9756a..e3bc2281e 100644 --- a/src/NetscriptFunctions/Bladeburner.ts +++ b/src/NetscriptFunctions/Bladeburner.ts @@ -137,7 +137,7 @@ export function NetscriptBladeburner( const bladeburner = player.bladeburner; if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); try { - let time = bladeburner.getActionTimeNetscriptFn(player, type, name); + const time = bladeburner.getActionTimeNetscriptFn(player, type, name); if(typeof time === 'string'){ const errorLogText = `Invalid action: type='${type}' name='${name}'`; workerScript.log("bladeburner.getActionTime", () => errorLogText); @@ -157,7 +157,7 @@ export function NetscriptBladeburner( const bladeburner = player.bladeburner; if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); try { - let chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name); + const chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name); if(typeof chance === 'string'){ const errorLogText = `Invalid action: type='${type}' name='${name}'`; workerScript.log("bladeburner.getActionTime", () => errorLogText); diff --git a/src/PersonObjects/IPerson.ts b/src/PersonObjects/IPerson.ts index ab51f85c0..fbafd3505 100644 --- a/src/PersonObjects/IPerson.ts +++ b/src/PersonObjects/IPerson.ts @@ -15,7 +15,7 @@ export interface IPerson { hp: number; max_hp: number; money: number; - + // Experience hacking_exp: number; strength_exp: number; @@ -24,7 +24,7 @@ export interface IPerson { agility_exp: number; charisma_exp: number; intelligence_exp: number; - + // Multipliers hacking_exp_mult: number; strength_exp_mult: number; @@ -46,7 +46,7 @@ export interface IPerson { crime_success_mult: number; bladeburner_analysis_mult: number; - + getIntelligenceBonus(weight: number): number; gainHackingExp(exp: number): void; gainStrengthExp(exp: number): void; @@ -61,4 +61,4 @@ export interface IPerson { regenerateHp: (amt: number) => void; queryStatFromString: (str: string) => number; whoAmI: () => string; - } \ No newline at end of file + } diff --git a/src/PersonObjects/ITaskTracker.ts b/src/PersonObjects/ITaskTracker.ts index 8b2d92efa..91bbad453 100644 --- a/src/PersonObjects/ITaskTracker.ts +++ b/src/PersonObjects/ITaskTracker.ts @@ -10,7 +10,7 @@ export interface ITaskTracker { int: number; money: number; } - + export function createTaskTracker(): ITaskTracker { return { hack: 0, @@ -22,4 +22,4 @@ export interface ITaskTracker { int: 0, money: 0, }; - } \ No newline at end of file + } diff --git a/src/PersonObjects/Person.ts b/src/PersonObjects/Person.ts index 0bee0658a..3b87840af 100644 --- a/src/PersonObjects/Person.ts +++ b/src/PersonObjects/Person.ts @@ -89,6 +89,18 @@ export abstract class Person implements IPerson { */ city: CityName = CityName.Sector12; + gainHackingExp: (exp: number) => void; + gainStrengthExp: (exp: number) => void; + gainDefenseExp: (exp: number) => void; + gainDexterityExp: (exp: number) => void; + gainAgilityExp: (exp: number) => void; + gainCharismaExp: (exp: number) => void; + gainIntelligenceExp: (exp: number) => void; + gainStats: (retValue: ITaskTracker) => void; + calculateSkill: (exp: number, mult: number) => number; + regenerateHp: (amt: number) => void; + queryStatFromString: (str: string) => number; + /** * Updates this object's multipliers for the given augmentation */ @@ -226,17 +238,6 @@ export abstract class Person implements IPerson { abstract whoAmI(): string; - gainHackingExp: (exp: number) => void; - gainStrengthExp: (exp: number) => void; - gainDefenseExp: (exp: number) => void; - gainDexterityExp: (exp: number) => void; - gainAgilityExp: (exp: number) => void; - gainCharismaExp: (exp: number) => void; - gainIntelligenceExp: (exp: number) => void; - gainStats: (retValue: ITaskTracker) => void; - calculateSkill: (exp: number, mult: number) => number; - regenerateHp: (amt: number) => void; - queryStatFromString: (str: string) => number; constructor() { this.gainHackingExp = generalMethods.gainHackingExp; this.gainStrengthExp = generalMethods.gainStrengthExp; @@ -252,4 +253,4 @@ export abstract class Person implements IPerson { } } -Reviver.constructors.Person = Person; \ No newline at end of file +Reviver.constructors.Person = Person; diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index 364e0f57f..6de0e5c49 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -189,7 +189,7 @@ export class Sleeve extends Person { */ finishTask(p: IPlayer): ITaskTracker { let retValue: ITaskTracker = createTaskTracker(); // Amount of exp to be gained by other sleeves - + if (this.currentTask === SleeveTaskType.Crime) { // For crimes, all experience and money is gained at the end if (this.currentTaskTime >= this.currentTaskMaxTime) { @@ -229,7 +229,7 @@ export class Sleeve extends Person { this.resetTaskStatus(p); return retValue; } - + if (this.currentTaskTime >= this.currentTaskMaxTime) { if (this.bbAction === "Infiltrate synthoids") { bb.infiltrateSynthoidCommunities(); @@ -637,7 +637,7 @@ export class Sleeve extends Person { p.bladeburner?.sleeveSupport(false); } if (this.currentTask == SleeveTaskType.Class) { - let retVal = createTaskTracker(); + const retVal = createTaskTracker(); retVal.int = CONSTANTS.IntelligenceClassBaseExpGain * Math.round(this.currentTaskTime / 1000); this.gainExperience(p, retVal);//Wont be shared with other sleeves } @@ -1091,7 +1091,7 @@ export class Sleeve extends Person { break; case "Recruitment": time = this.getBladeburnerActionTime(p, 'General', action); - const recruitTime = p.bladeburner?.getRecruitmentTime(this) ?? 0 * 1000; + const recruitTime = (p.bladeburner?.getRecruitmentTime(this) ?? 0) * 1000; this.gainRatesForTask.cha = 2 * BladeburnerConstants.BaseStatGain * recruitTime; this.currentTaskLocation = (p.bladeburner?.getRecruitmentSuccessChance(this) ?? 0).toString() + '%'; break; @@ -1167,7 +1167,7 @@ export class Sleeve extends Person { this.gainRatesForTask.agi = retValue.agi; this.gainRatesForTask.cha = retValue.cha; const rewardMultiplier = Math.pow(action.rewardFac, action.level - 1); - this.gainRatesForTask.money = BladeburnerConstants.ContractBaseMoneyGain * rewardMultiplier * bb.skillMultipliers.money;; + this.gainRatesForTask.money = BladeburnerConstants.ContractBaseMoneyGain * rewardMultiplier * bb.skillMultipliers.money; } getBladeburnerActionTime(p: IPlayer, type: string, name: string): number{//Maybe find workerscript and use original @@ -1177,7 +1177,7 @@ export class Sleeve extends Person { console.error(`Function: sleeves.getBladeburnerActionTime; Message: '${errorLogText}'`) return -1; } - + const time = bb.getActionTimeNetscriptFn(this, type, name); if(typeof time === 'string'){ const errorLogText = `Invalid action: type='${type}' name='${name}'`; diff --git a/src/PersonObjects/Sleeve/ui/SleeveElem.tsx b/src/PersonObjects/Sleeve/ui/SleeveElem.tsx index 734d45522..ec288ff34 100644 --- a/src/PersonObjects/Sleeve/ui/SleeveElem.tsx +++ b/src/PersonObjects/Sleeve/ui/SleeveElem.tsx @@ -186,8 +186,8 @@ export function SleeveElem(props: IProps): React.ReactElement { {desc} - {(props.sleeve.currentTask === SleeveTaskType.Crime - || props.sleeve.currentTask === SleeveTaskType.Bladeburner) + {(props.sleeve.currentTask === SleeveTaskType.Crime + || props.sleeve.currentTask === SleeveTaskType.Bladeburner) && props.sleeve.currentTaskMaxTime > 0 && createProgressBarText({ progress: props.sleeve.currentTaskTime / props.sleeve.currentTaskMaxTime, diff --git a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx index 574115770..7d8086817 100644 --- a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx +++ b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx @@ -10,7 +10,6 @@ import { FactionWorkType } from "../../../Faction/FactionWorkTypeEnum"; import Select, { SelectChangeEvent } from "@mui/material/Select"; import MenuItem from "@mui/material/MenuItem"; import { FactionNames } from "../../../Faction/data/FactionNames"; -import { Contract } from "../../../Bladeburner/Contract"; const universitySelectorOptions: string[] = [ "Study Computer Science", @@ -95,7 +94,7 @@ function possibleContracts(player: IPlayer, sleeve: Sleeve): string[] { if (sleeve === otherSleeve) { continue; } - if (otherSleeve.currentTask === SleeveTaskType.Bladeburner + if (otherSleeve.currentTask === SleeveTaskType.Bladeburner && otherSleeve.bbAction == 'Take on Contracts') { contracts = contracts.filter(x => x != otherSleeve.bbContract); } @@ -192,8 +191,8 @@ const tasks: { return { first: gymSelectorOptions, second: () => gyms }; }, "Perform Bladeburner Actions": (player: IPlayer, sleeve: Sleeve): ITaskDetails => { - return { - first: bladeburnerSelectorOptions, + return { + first: bladeburnerSelectorOptions, second: (s1: string) => { if(s1 === "Take on Contracts"){ return possibleContracts(player, sleeve);