linter
This commit is contained in:
rderfler 2022-04-14 11:57:01 -04:00
parent d1388a62aa
commit 0406272942
8 changed files with 40 additions and 41 deletions

@ -38,7 +38,6 @@ import { WorkerScript } from "../Netscript/WorkerScript";
import { FactionNames } from "../Faction/data/FactionNames"; import { FactionNames } from "../Faction/data/FactionNames";
import { BlackOperationNames } from "./data/BlackOperationNames"; import { BlackOperationNames } from "./data/BlackOperationNames";
import { KEY } from "../utils/helpers/keyCodes"; import { KEY } from "../utils/helpers/keyCodes";
import { Player } from "src/Player";
interface BlackOpsAttempt { interface BlackOpsAttempt {
error?: string; error?: string;
@ -1022,7 +1021,7 @@ export class Bladeburner implements IBladeburner {
const unweightedGain = time * BladeburnerConstants.BaseStatGain * successMult * difficultyMult; const unweightedGain = time * BladeburnerConstants.BaseStatGain * successMult * difficultyMult;
const unweightedIntGain = time * BladeburnerConstants.BaseIntGain * successMult * difficultyMult; const unweightedIntGain = time * BladeburnerConstants.BaseIntGain * successMult * difficultyMult;
const skillMult = this.skillMultipliers.expGain; const skillMult = this.skillMultipliers.expGain;
return { return {
hack: unweightedGain * action.weights.hack * skillMult, hack: unweightedGain * action.weights.hack * skillMult,
str: unweightedGain * action.weights.str * skillMult, str: unweightedGain * action.weights.str * skillMult,
@ -1136,7 +1135,7 @@ export class Bladeburner implements IBladeburner {
const losses = getRandomInt(0, max); const losses = getRandomInt(0, max);
this.teamSize -= losses; this.teamSize -= losses;
if(this.teamSize < this.sleeveSize) { 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--){ for(let i = 0; i > (this.teamSize-this.sleeveSize); i--){
const r = Math.floor(Math.random() * sup.length); const r = Math.floor(Math.random() * sup.length);
sup[r].takeDamage(sup[r].max_hp); 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"); this.log(`${person.whoAmI()}: ` + action.name + " successfully completed! Gained " + formatNumber(gain, 3) + " rank");
} else if (!isOperation && this.logging.contracts) { } else if (!isOperation && this.logging.contracts) {
this.log( this.log(
`${person.whoAmI()}: ` + `${person.whoAmI()}: ` +
action.name + action.name +
" contract successfully completed! Gained " + " contract successfully completed! Gained " +
formatNumber(gain, 3) + formatNumber(gain, 3) +
@ -1422,7 +1421,7 @@ export class Bladeburner implements IBladeburner {
if (this.logging.blackops) { if (this.logging.blackops) {
this.log( this.log(
`${person.whoAmI()}: ` + `${person.whoAmI()}: ` +
action.name + action.name +
" failed! Lost " + " failed! Lost " +
formatNumber(rankLoss, 1) + formatNumber(rankLoss, 1) +
@ -1440,7 +1439,7 @@ export class Bladeburner implements IBladeburner {
const losses = getRandomInt(1, teamLossMax); const losses = getRandomInt(1, teamLossMax);
this.teamSize -= losses; this.teamSize -= losses;
if(this.teamSize < this.sleeveSize) { 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--){ for(let i = 0; i > (this.teamSize-this.sleeveSize); i--){
const r = Math.floor(Math.random() * sup.length); const r = Math.floor(Math.random() * sup.length);
sup[r].takeDamage(sup[r].max_hp); sup[r].takeDamage(sup[r].max_hp);
@ -1472,7 +1471,7 @@ export class Bladeburner implements IBladeburner {
this.staminaBonus += staminaGain; this.staminaBonus += staminaGain;
if (this.logging.general) { if (this.logging.general) {
this.log( this.log(
`${person.whoAmI()}: ` + `${person.whoAmI()}: ` +
"Training completed. Gained: " + "Training completed. Gained: " +
formatNumber(strExpGain, 1) + formatNumber(strExpGain, 1) +
" str exp, " + " str exp, " +
@ -1509,7 +1508,7 @@ export class Bladeburner implements IBladeburner {
this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate); this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate);
if (this.logging.general) { if (this.logging.general) {
this.log( this.log(
`${person.whoAmI()}: ` + `${person.whoAmI()}: ` +
`Field analysis completed. Gained ${formatNumber(rankGain, 2)} rank, ` + `Field analysis completed. Gained ${formatNumber(rankGain, 2)} rank, ` +
`${formatNumber(hackingExpGain, 1)} hacking exp, and ` + `${formatNumber(hackingExpGain, 1)} hacking exp, and ` +
`${formatNumber(charismaExpGain, 1)} charisma exp`, `${formatNumber(charismaExpGain, 1)} charisma exp`,
@ -1655,7 +1654,7 @@ export class Bladeburner implements IBladeburner {
this.actionTimeOverflow = 0; this.actionTimeOverflow = 0;
if (this.actionTimeCurrent >= this.actionTimeToComplete) { if (this.actionTimeCurrent >= this.actionTimeToComplete) {
this.actionTimeOverflow = 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.gainMoney(retValue.money, "bladeburner");
player.gainStats(retValue); player.gainStats(retValue);
// Operation Daedalus // Operation Daedalus

@ -137,7 +137,7 @@ export function NetscriptBladeburner(
const bladeburner = player.bladeburner; const bladeburner = player.bladeburner;
if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
try { try {
let time = bladeburner.getActionTimeNetscriptFn(player, type, name); const time = bladeburner.getActionTimeNetscriptFn(player, type, name);
if(typeof time === 'string'){ if(typeof time === 'string'){
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
workerScript.log("bladeburner.getActionTime", () => errorLogText); workerScript.log("bladeburner.getActionTime", () => errorLogText);
@ -157,7 +157,7 @@ export function NetscriptBladeburner(
const bladeburner = player.bladeburner; const bladeburner = player.bladeburner;
if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
try { try {
let chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name); const chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name);
if(typeof chance === 'string'){ if(typeof chance === 'string'){
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
workerScript.log("bladeburner.getActionTime", () => errorLogText); workerScript.log("bladeburner.getActionTime", () => errorLogText);

@ -15,7 +15,7 @@ export interface IPerson {
hp: number; hp: number;
max_hp: number; max_hp: number;
money: number; money: number;
// Experience // Experience
hacking_exp: number; hacking_exp: number;
strength_exp: number; strength_exp: number;
@ -24,7 +24,7 @@ export interface IPerson {
agility_exp: number; agility_exp: number;
charisma_exp: number; charisma_exp: number;
intelligence_exp: number; intelligence_exp: number;
// Multipliers // Multipliers
hacking_exp_mult: number; hacking_exp_mult: number;
strength_exp_mult: number; strength_exp_mult: number;
@ -46,7 +46,7 @@ export interface IPerson {
crime_success_mult: number; crime_success_mult: number;
bladeburner_analysis_mult: number; bladeburner_analysis_mult: number;
getIntelligenceBonus(weight: number): number; getIntelligenceBonus(weight: number): number;
gainHackingExp(exp: number): void; gainHackingExp(exp: number): void;
gainStrengthExp(exp: number): void; gainStrengthExp(exp: number): void;
@ -61,4 +61,4 @@ export interface IPerson {
regenerateHp: (amt: number) => void; regenerateHp: (amt: number) => void;
queryStatFromString: (str: string) => number; queryStatFromString: (str: string) => number;
whoAmI: () => string; whoAmI: () => string;
} }

@ -10,7 +10,7 @@ export interface ITaskTracker {
int: number; int: number;
money: number; money: number;
} }
export function createTaskTracker(): ITaskTracker { export function createTaskTracker(): ITaskTracker {
return { return {
hack: 0, hack: 0,
@ -22,4 +22,4 @@ export interface ITaskTracker {
int: 0, int: 0,
money: 0, money: 0,
}; };
} }

@ -89,6 +89,18 @@ export abstract class Person implements IPerson {
*/ */
city: CityName = CityName.Sector12; 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 * Updates this object's multipliers for the given augmentation
*/ */
@ -226,17 +238,6 @@ export abstract class Person implements IPerson {
abstract whoAmI(): string; 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() { constructor() {
this.gainHackingExp = generalMethods.gainHackingExp; this.gainHackingExp = generalMethods.gainHackingExp;
this.gainStrengthExp = generalMethods.gainStrengthExp; this.gainStrengthExp = generalMethods.gainStrengthExp;
@ -252,4 +253,4 @@ export abstract class Person implements IPerson {
} }
} }
Reviver.constructors.Person = Person; Reviver.constructors.Person = Person;

@ -189,7 +189,7 @@ export class Sleeve extends Person {
*/ */
finishTask(p: IPlayer): ITaskTracker { finishTask(p: IPlayer): ITaskTracker {
let retValue: ITaskTracker = createTaskTracker(); // Amount of exp to be gained by other sleeves let retValue: ITaskTracker = createTaskTracker(); // Amount of exp to be gained by other sleeves
if (this.currentTask === SleeveTaskType.Crime) { if (this.currentTask === SleeveTaskType.Crime) {
// For crimes, all experience and money is gained at the end // For crimes, all experience and money is gained at the end
if (this.currentTaskTime >= this.currentTaskMaxTime) { if (this.currentTaskTime >= this.currentTaskMaxTime) {
@ -229,7 +229,7 @@ export class Sleeve extends Person {
this.resetTaskStatus(p); this.resetTaskStatus(p);
return retValue; return retValue;
} }
if (this.currentTaskTime >= this.currentTaskMaxTime) { if (this.currentTaskTime >= this.currentTaskMaxTime) {
if (this.bbAction === "Infiltrate synthoids") { if (this.bbAction === "Infiltrate synthoids") {
bb.infiltrateSynthoidCommunities(); bb.infiltrateSynthoidCommunities();
@ -637,7 +637,7 @@ export class Sleeve extends Person {
p.bladeburner?.sleeveSupport(false); p.bladeburner?.sleeveSupport(false);
} }
if (this.currentTask == SleeveTaskType.Class) { if (this.currentTask == SleeveTaskType.Class) {
let retVal = createTaskTracker(); const retVal = createTaskTracker();
retVal.int = CONSTANTS.IntelligenceClassBaseExpGain * Math.round(this.currentTaskTime / 1000); retVal.int = CONSTANTS.IntelligenceClassBaseExpGain * Math.round(this.currentTaskTime / 1000);
this.gainExperience(p, retVal);//Wont be shared with other sleeves this.gainExperience(p, retVal);//Wont be shared with other sleeves
} }
@ -1091,7 +1091,7 @@ export class Sleeve extends Person {
break; break;
case "Recruitment": case "Recruitment":
time = this.getBladeburnerActionTime(p, 'General', action); 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.gainRatesForTask.cha = 2 * BladeburnerConstants.BaseStatGain * recruitTime;
this.currentTaskLocation = (p.bladeburner?.getRecruitmentSuccessChance(this) ?? 0).toString() + '%'; this.currentTaskLocation = (p.bladeburner?.getRecruitmentSuccessChance(this) ?? 0).toString() + '%';
break; break;
@ -1167,7 +1167,7 @@ export class Sleeve extends Person {
this.gainRatesForTask.agi = retValue.agi; this.gainRatesForTask.agi = retValue.agi;
this.gainRatesForTask.cha = retValue.cha; this.gainRatesForTask.cha = retValue.cha;
const rewardMultiplier = Math.pow(action.rewardFac, action.level - 1); 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 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}'`) console.error(`Function: sleeves.getBladeburnerActionTime; Message: '${errorLogText}'`)
return -1; return -1;
} }
const time = bb.getActionTimeNetscriptFn(this, type, name); const time = bb.getActionTimeNetscriptFn(this, type, name);
if(typeof time === 'string'){ if(typeof time === 'string'){
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;

@ -186,8 +186,8 @@ export function SleeveElem(props: IProps): React.ReactElement {
</Button> </Button>
<Typography>{desc}</Typography> <Typography>{desc}</Typography>
<Typography> <Typography>
{(props.sleeve.currentTask === SleeveTaskType.Crime {(props.sleeve.currentTask === SleeveTaskType.Crime
|| props.sleeve.currentTask === SleeveTaskType.Bladeburner) || props.sleeve.currentTask === SleeveTaskType.Bladeburner)
&& props.sleeve.currentTaskMaxTime > 0 && props.sleeve.currentTaskMaxTime > 0
&& createProgressBarText({ && createProgressBarText({
progress: props.sleeve.currentTaskTime / props.sleeve.currentTaskMaxTime, progress: props.sleeve.currentTaskTime / props.sleeve.currentTaskMaxTime,

@ -10,7 +10,6 @@ import { FactionWorkType } from "../../../Faction/FactionWorkTypeEnum";
import Select, { SelectChangeEvent } from "@mui/material/Select"; import Select, { SelectChangeEvent } from "@mui/material/Select";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import { FactionNames } from "../../../Faction/data/FactionNames"; import { FactionNames } from "../../../Faction/data/FactionNames";
import { Contract } from "../../../Bladeburner/Contract";
const universitySelectorOptions: string[] = [ const universitySelectorOptions: string[] = [
"Study Computer Science", "Study Computer Science",
@ -95,7 +94,7 @@ function possibleContracts(player: IPlayer, sleeve: Sleeve): string[] {
if (sleeve === otherSleeve) { if (sleeve === otherSleeve) {
continue; continue;
} }
if (otherSleeve.currentTask === SleeveTaskType.Bladeburner if (otherSleeve.currentTask === SleeveTaskType.Bladeburner
&& otherSleeve.bbAction == 'Take on Contracts') { && otherSleeve.bbAction == 'Take on Contracts') {
contracts = contracts.filter(x => x != otherSleeve.bbContract); contracts = contracts.filter(x => x != otherSleeve.bbContract);
} }
@ -192,8 +191,8 @@ const tasks: {
return { first: gymSelectorOptions, second: () => gyms }; return { first: gymSelectorOptions, second: () => gyms };
}, },
"Perform Bladeburner Actions": (player: IPlayer, sleeve: Sleeve): ITaskDetails => { "Perform Bladeburner Actions": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
return { return {
first: bladeburnerSelectorOptions, first: bladeburnerSelectorOptions,
second: (s1: string) => { second: (s1: string) => {
if(s1 === "Take on Contracts"){ if(s1 === "Take on Contracts"){
return possibleContracts(player, sleeve); return possibleContracts(player, sleeve);