diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index 9419df504..658a64641 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -236,13 +236,13 @@ export class Bladeburner implements IBladeburner { } } - upgradeSkill(skill: Skill): void { + upgradeSkill(skill: Skill, count = 1): void { // This does NOT handle deduction of skill points const skillName = skill.name; if (this.skills[skillName]) { - ++this.skills[skillName]; + this.skills[skillName] += count; } else { - this.skills[skillName] = 1; + this.skills[skillName] = count; } if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) { throw new Error("Level of Skill " + skillName + " is invalid: " + this.skills[skillName]); @@ -671,15 +671,15 @@ export class Bladeburner implements IBladeburner { this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled")); this.postToConsole( "When your stamina drops to " + - formatNumber(this.automateThreshLow, 0) + - ", you will automatically switch to " + - this.automateActionLow.name + - ". When your stamina recovers to " + - formatNumber(this.automateThreshHigh, 0) + - ", you will automatically " + - "switch to " + - this.automateActionHigh.name + - ".", + formatNumber(this.automateThreshLow, 0) + + ", you will automatically switch to " + + this.automateActionLow.name + + ". When your stamina recovers to " + + formatNumber(this.automateThreshHigh, 0) + + ", you will automatically " + + "switch to " + + this.automateActionHigh.name + + ".", ); } else if (flag.toLowerCase().includes("en")) { if ( @@ -974,8 +974,8 @@ export class Bladeburner implements IBladeburner { if (this.logging.events) { this.log( "Intelligence indicates that a large number of Synthoids migrated from " + - sourceCityName + - " to some other city", + sourceCityName + + " to some other city", ); } } else if (chance <= 0.7) { @@ -1314,19 +1314,19 @@ export class Bladeburner implements IBladeburner { if (isOperation && this.logging.ops) { this.log( `${person.whoAmI()}: ` + - action.name + - " successfully completed! Gained " + - formatNumber(gain, 3) + - " rank", + action.name + + " successfully completed! Gained " + + formatNumber(gain, 3) + + " rank", ); } else if (!isOperation && this.logging.contracts) { this.log( `${person.whoAmI()}: ` + - action.name + - " contract successfully completed! Gained " + - formatNumber(gain, 3) + - " rank and " + - numeralWrapper.formatMoney(moneyGain), + action.name + + " contract successfully completed! Gained " + + formatNumber(gain, 3) + + " rank and " + + numeralWrapper.formatMoney(moneyGain), ); } } @@ -1432,12 +1432,12 @@ export class Bladeburner implements IBladeburner { if (this.logging.blackops) { this.log( `${person.whoAmI()}: ` + - action.name + - " failed! Lost " + - formatNumber(rankLoss, 1) + - " rank and took " + - formatNumber(damage, 0) + - " damage", + action.name + + " failed! Lost " + + formatNumber(rankLoss, 1) + + " rank and took " + + formatNumber(damage, 0) + + " damage", ); } } @@ -1482,17 +1482,17 @@ export class Bladeburner implements IBladeburner { if (this.logging.general) { this.log( `${person.whoAmI()}: ` + - "Training completed. Gained: " + - formatNumber(strExpGain, 1) + - " str exp, " + - formatNumber(defExpGain, 1) + - " def exp, " + - formatNumber(dexExpGain, 1) + - " dex exp, " + - formatNumber(agiExpGain, 1) + - " agi exp, " + - formatNumber(staminaGain, 3) + - " max stamina", + "Training completed. Gained: " + + formatNumber(strExpGain, 1) + + " str exp, " + + formatNumber(defExpGain, 1) + + " def exp, " + + formatNumber(dexExpGain, 1) + + " dex exp, " + + formatNumber(agiExpGain, 1) + + " agi exp, " + + formatNumber(staminaGain, 3) + + " max stamina", ); } break; @@ -1519,9 +1519,9 @@ export class Bladeburner implements IBladeburner { if (this.logging.general) { this.log( `${person.whoAmI()}: ` + - `Field analysis completed. Gained ${formatNumber(rankGain, 2)} rank, ` + - `${formatNumber(hackingExpGain, 1)} hacking exp, and ` + - `${formatNumber(charismaExpGain, 1)} charisma exp`, + `Field analysis completed. Gained ${formatNumber(rankGain, 2)} rank, ` + + `${formatNumber(hackingExpGain, 1)} hacking exp, and ` + + `${formatNumber(charismaExpGain, 1)} charisma exp`, ); } break; @@ -1536,9 +1536,9 @@ export class Bladeburner implements IBladeburner { if (this.logging.general) { this.log( `${person.whoAmI()}: ` + - "Successfully recruited a team member! Gained " + - formatNumber(expGain, 1) + - " charisma exp", + "Successfully recruited a team member! Gained " + + formatNumber(expGain, 1) + + " charisma exp", ); } } else { @@ -1547,9 +1547,9 @@ export class Bladeburner implements IBladeburner { if (this.logging.general) { this.log( `${person.whoAmI()}: ` + - "Failed to recruit a team member. Gained " + - formatNumber(expGain, 1) + - " charisma exp", + "Failed to recruit a team member. Gained " + + formatNumber(expGain, 1) + + " charisma exp", ); } } @@ -1577,8 +1577,7 @@ export class Bladeburner implements IBladeburner { this.stamina = Math.min(this.maxStamina, this.stamina + staminaGain); if (this.logging.general) { this.log( - `${person.whoAmI()}: Rested in Hyperbolic Regeneration Chamber. Restored ${ - BladeburnerConstants.HrcHpGain + `${person.whoAmI()}: Rested in Hyperbolic Regeneration Chamber. Restored ${BladeburnerConstants.HrcHpGain } HP and gained ${numeralWrapper.formatStamina(staminaGain)} stamina`, ); } @@ -2290,7 +2289,7 @@ export class Bladeburner implements IBladeburner { } } - upgradeSkillNetscriptFn(skillName: string, workerScript: WorkerScript): boolean { + upgradeSkillNetscriptFn(skillName: string, count: number, workerScript: WorkerScript): boolean { const errorLogText = `Invalid skill: '${skillName}'`; if (!Skills.hasOwnProperty(skillName)) { workerScript.log("bladeburner.upgradeSkill", () => errorLogText); @@ -2302,10 +2301,10 @@ export class Bladeburner implements IBladeburner { if (this.skills[skillName] && !isNaN(this.skills[skillName])) { currentLevel = this.skills[skillName]; } - const cost = skill.calculateCost(currentLevel); + const cost = skill.calculateCost(currentLevel, count); - if (skill.maxLvl && currentLevel >= skill.maxLvl) { - workerScript.log("bladeburner.upgradeSkill", () => `Skill '${skillName}' is already maxed.`); + if (skill.maxLvl && currentLevel + count > skill.maxLvl) { + workerScript.log("bladeburner.upgradeSkill", () => `Skill '${skillName}' cannot be upgraded ${count} time(s).`); return false; } @@ -2313,13 +2312,13 @@ export class Bladeburner implements IBladeburner { workerScript.log( "bladeburner.upgradeSkill", () => - `You do not have enough skill points to upgrade ${skillName} (You have ${this.skillPoints}, you need ${cost})`, + `You do not have enough skill points to upgrade ${skillName} ${count} time(s). (You have ${this.skillPoints}, you need ${cost})`, ); return false; } this.skillPoints -= cost; - this.upgradeSkill(skill); + this.upgradeSkill(skill, count); workerScript.log("bladeburner.upgradeSkill", () => `'${skillName}' upgraded to level ${this.skills[skillName]}`); return true; } diff --git a/src/Bladeburner/IBladeburner.ts b/src/Bladeburner/IBladeburner.ts index 66f97e0f7..eb5e24615 100644 --- a/src/Bladeburner/IBladeburner.ts +++ b/src/Bladeburner/IBladeburner.ts @@ -77,7 +77,7 @@ export interface IBladeburner { getActionCountRemainingNetscriptFn(type: string, name: string, workerScript: WorkerScript): number; getSkillLevelNetscriptFn(skillName: string, workerScript: WorkerScript): number; getSkillUpgradeCostNetscriptFn(skillName: string, workerScript: WorkerScript): number; - upgradeSkillNetscriptFn(skillName: string, workerScript: WorkerScript): boolean; + upgradeSkillNetscriptFn(skillName: string, count: number, workerScript: WorkerScript): boolean; getTeamSizeNetscriptFn(type: string, name: string, workerScript: WorkerScript): number; setTeamSizeNetscriptFn(type: string, name: string, size: number, workerScript: WorkerScript): number; joinBladeburnerFactionNetscriptFn(workerScript: WorkerScript): boolean; diff --git a/src/Bladeburner/Skill.ts b/src/Bladeburner/Skill.ts index 160429ed5..6f0e92347 100644 --- a/src/Bladeburner/Skill.ts +++ b/src/Bladeburner/Skill.ts @@ -133,8 +133,13 @@ export class Skill { } } - calculateCost(currentLevel: number): number { - return Math.floor((this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost); + calculateCost(currentLevel: number, count = 1): number { + //unFloored is roughly equivalent to + //(this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost + //being repeated for increasing currentLevel + const preMult = (count + 1) * (2 * this.baseCost + this.costInc * (2 * currentLevel + count)) / 2; + const unFloored = (preMult * BitNodeMultipliers.BladeburnerSkillCost) - count / 2; + return Math.floor(unFloored); } getMultiplier(name: string): number { diff --git a/src/NetscriptFunctions/Bladeburner.ts b/src/NetscriptFunctions/Bladeburner.ts index 72458cb06..6f57dcf8c 100644 --- a/src/NetscriptFunctions/Bladeburner.ts +++ b/src/NetscriptFunctions/Bladeburner.ts @@ -72,12 +72,12 @@ export function NetscriptBladeburner(player: IPlayer, workerScript: WorkerScript }, getBlackOpRank: (ctx: NetscriptContext) => - (_blackOpName: unknown): number => { - const blackOpName = ctx.helper.string("blackOpName", _blackOpName); - checkBladeburnerAccess(ctx); - const action: any = getBladeburnerActionObject(ctx, "blackops", blackOpName); - return action.reqdRank; - }, + (_blackOpName: unknown): number => { + const blackOpName = ctx.helper.string("blackOpName", _blackOpName); + checkBladeburnerAccess(ctx); + const action: any = getBladeburnerActionObject(ctx, "blackops", blackOpName); + return action.reqdRank; + }, getGeneralActionNames: (ctx: NetscriptContext) => (): string[] => { checkBladeburnerAccess(ctx); const bladeburner = player.bladeburner; @@ -92,18 +92,18 @@ export function NetscriptBladeburner(player: IPlayer, workerScript: WorkerScript }, startAction: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): boolean => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - return bladeburner.startActionNetscriptFn(player, type, name, workerScript); - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + (_type: unknown, _name: unknown): boolean => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + return bladeburner.startActionNetscriptFn(player, type, name, workerScript); + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); + } + }, stopBladeburnerAction: (ctx: NetscriptContext) => (): void => { checkBladeburnerAccess(ctx); const bladeburner = player.bladeburner; @@ -118,25 +118,25 @@ export function NetscriptBladeburner(player: IPlayer, workerScript: WorkerScript }, getActionTime: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): number => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - const time = bladeburner.getActionTimeNetscriptFn(player, type, name); - if (typeof time === "string") { - const errorLogText = `Invalid action: type='${type}' name='${name}'`; - ctx.log(() => errorLogText); - return -1; - } else { - return time; + (_type: unknown, _name: unknown): number => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + const time = bladeburner.getActionTimeNetscriptFn(player, type, name); + if (typeof time === "string") { + const errorLogText = `Invalid action: type='${type}' name='${name}'`; + ctx.log(() => errorLogText); + return -1; + } else { + return time; + } + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); } - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + }, getActionCurrentTime: (ctx: NetscriptContext) => (): number => { checkBladeburnerAccess(ctx); const bladeburner = player.bladeburner; @@ -152,106 +152,106 @@ export function NetscriptBladeburner(player: IPlayer, workerScript: WorkerScript }, getActionEstimatedSuccessChance: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): [number, number] => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - const chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name); - if (typeof chance === "string") { - const errorLogText = `Invalid action: type='${type}' name='${name}'`; - ctx.log(() => errorLogText); - return [-1, -1]; - } else { - return chance; + (_type: unknown, _name: unknown): [number, number] => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + const chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name); + if (typeof chance === "string") { + const errorLogText = `Invalid action: type='${type}' name='${name}'`; + ctx.log(() => errorLogText); + return [-1, -1]; + } else { + return chance; + } + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); } - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + }, getActionRepGain: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown, _level: unknown): number => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - const level = ctx.helper.number("level", _level); - checkBladeburnerAccess(ctx); - const action = getBladeburnerActionObject(ctx, type, name); - let rewardMultiplier; - if (level == null || isNaN(level)) { - rewardMultiplier = Math.pow(action.rewardFac, action.level - 1); - } else { - rewardMultiplier = Math.pow(action.rewardFac, level - 1); - } + (_type: unknown, _name: unknown, _level: unknown): number => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + const level = ctx.helper.number("level", _level); + checkBladeburnerAccess(ctx); + const action = getBladeburnerActionObject(ctx, type, name); + let rewardMultiplier; + if (level == null || isNaN(level)) { + rewardMultiplier = Math.pow(action.rewardFac, action.level - 1); + } else { + rewardMultiplier = Math.pow(action.rewardFac, level - 1); + } - return action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank; - }, + return action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank; + }, getActionCountRemaining: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): number => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - return bladeburner.getActionCountRemainingNetscriptFn(type, name, workerScript); - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + (_type: unknown, _name: unknown): number => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + return bladeburner.getActionCountRemainingNetscriptFn(type, name, workerScript); + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); + } + }, getActionMaxLevel: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): number => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const action = getBladeburnerActionObject(ctx, type, name); - return action.maxLevel; - }, + (_type: unknown, _name: unknown): number => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const action = getBladeburnerActionObject(ctx, type, name); + return action.maxLevel; + }, getActionCurrentLevel: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): number => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const action = getBladeburnerActionObject(ctx, type, name); - return action.level; - }, + (_type: unknown, _name: unknown): number => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const action = getBladeburnerActionObject(ctx, type, name); + return action.level; + }, getActionAutolevel: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): boolean => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const action = getBladeburnerActionObject(ctx, type, name); - return action.autoLevel; - }, + (_type: unknown, _name: unknown): boolean => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const action = getBladeburnerActionObject(ctx, type, name); + return action.autoLevel; + }, setActionAutolevel: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown, _autoLevel: unknown = true): void => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - const autoLevel = ctx.helper.boolean(_autoLevel); - checkBladeburnerAccess(ctx); - const action = getBladeburnerActionObject(ctx, type, name); - action.autoLevel = autoLevel; - }, + (_type: unknown, _name: unknown, _autoLevel: unknown = true): void => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + const autoLevel = ctx.helper.boolean(_autoLevel); + checkBladeburnerAccess(ctx); + const action = getBladeburnerActionObject(ctx, type, name); + action.autoLevel = autoLevel; + }, setActionLevel: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown, _level: unknown = 1): void => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - const level = ctx.helper.number("level", _level); - checkBladeburnerAccess(ctx); - const action = getBladeburnerActionObject(ctx, type, name); - if (level < 1 || level > action.maxLevel) { - ctx.helper.makeRuntimeErrorMsg(`Level must be between 1 and ${action.maxLevel}, is ${level}`); - } - action.level = level; - }, + (_type: unknown, _name: unknown, _level: unknown = 1): void => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + const level = ctx.helper.number("level", _level); + checkBladeburnerAccess(ctx); + const action = getBladeburnerActionObject(ctx, type, name); + if (level < 1 || level > action.maxLevel) { + ctx.helper.makeRuntimeErrorMsg(`Level must be between 1 and ${action.maxLevel}, is ${level}`); + } + action.level = level; + }, getRank: (ctx: NetscriptContext) => (): number => { checkBladeburnerAccess(ctx); const bladeburner = player.bladeburner; @@ -266,107 +266,107 @@ export function NetscriptBladeburner(player: IPlayer, workerScript: WorkerScript }, getSkillLevel: (ctx: NetscriptContext) => - (_skillName: unknown): number => { - const skillName = ctx.helper.string("skillName", _skillName); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - return bladeburner.getSkillLevelNetscriptFn(skillName, workerScript); - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + (_skillName: unknown): number => { + const skillName = ctx.helper.string("skillName", _skillName); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + return bladeburner.getSkillLevelNetscriptFn(skillName, workerScript); + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); + } + }, getSkillUpgradeCost: (ctx: NetscriptContext) => - (_skillName: unknown): number => { - const skillName = ctx.helper.string("skillName", _skillName); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - return bladeburner.getSkillUpgradeCostNetscriptFn(skillName, workerScript); - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + (_skillName: unknown): number => { + const skillName = ctx.helper.string("skillName", _skillName); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + return bladeburner.getSkillUpgradeCostNetscriptFn(skillName, workerScript); + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); + } + }, upgradeSkill: (ctx: NetscriptContext) => - (_skillName: unknown, count = 1): number => { - const skillName = ctx.helper.string("skillName", _skillName); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - for(let i=0; i { + const skillName = ctx.helper.string("skillName", _skillName); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + if(bladeburner.upgradeSkillNetscriptFn(skillName, count, workerScript)){ + return count; } + else{ + return 0; + } + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); } - return count; - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + }, getTeamSize: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown): number => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - return bladeburner.getTeamSizeNetscriptFn(type, name, workerScript); - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + (_type: unknown, _name: unknown): number => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + return bladeburner.getTeamSizeNetscriptFn(type, name, workerScript); + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); + } + }, setTeamSize: (ctx: NetscriptContext) => - (_type: unknown, _name: unknown, _size: unknown): number => { - const type = ctx.helper.string("type", _type); - const name = ctx.helper.string("name", _name); - const size = ctx.helper.number("size", _size); - checkBladeburnerAccess(ctx); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - try { - return bladeburner.setTeamSizeNetscriptFn(type, name, size, workerScript); - } catch (e: any) { - throw ctx.makeRuntimeErrorMsg(e); - } - }, + (_type: unknown, _name: unknown, _size: unknown): number => { + const type = ctx.helper.string("type", _type); + const name = ctx.helper.string("name", _name); + const size = ctx.helper.number("size", _size); + checkBladeburnerAccess(ctx); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + try { + return bladeburner.setTeamSizeNetscriptFn(type, name, size, workerScript); + } catch (e: any) { + throw ctx.makeRuntimeErrorMsg(e); + } + }, getCityEstimatedPopulation: (ctx: NetscriptContext) => - (_cityName: unknown): number => { - const cityName = ctx.helper.string("cityName", _cityName); - checkBladeburnerAccess(ctx); - checkBladeburnerCity(ctx, cityName); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - return bladeburner.cities[cityName].popEst; - }, + (_cityName: unknown): number => { + const cityName = ctx.helper.string("cityName", _cityName); + checkBladeburnerAccess(ctx); + checkBladeburnerCity(ctx, cityName); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + return bladeburner.cities[cityName].popEst; + }, getCityCommunities: (ctx: NetscriptContext) => - (_cityName: unknown): number => { - const cityName = ctx.helper.string("cityName", _cityName); - checkBladeburnerAccess(ctx); - checkBladeburnerCity(ctx, cityName); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - return bladeburner.cities[cityName].comms; - }, + (_cityName: unknown): number => { + const cityName = ctx.helper.string("cityName", _cityName); + checkBladeburnerAccess(ctx); + checkBladeburnerCity(ctx, cityName); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + return bladeburner.cities[cityName].comms; + }, getCityChaos: (ctx: NetscriptContext) => - (_cityName: unknown): number => { - const cityName = ctx.helper.string("cityName", _cityName); - checkBladeburnerAccess(ctx); - checkBladeburnerCity(ctx, cityName); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - return bladeburner.cities[cityName].chaos; - }, + (_cityName: unknown): number => { + const cityName = ctx.helper.string("cityName", _cityName); + checkBladeburnerAccess(ctx); + checkBladeburnerCity(ctx, cityName); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + return bladeburner.cities[cityName].chaos; + }, getCity: (ctx: NetscriptContext) => (): string => { checkBladeburnerAccess(ctx); const bladeburner = player.bladeburner; @@ -375,15 +375,15 @@ export function NetscriptBladeburner(player: IPlayer, workerScript: WorkerScript }, switchCity: (ctx: NetscriptContext) => - (_cityName: unknown): boolean => { - const cityName = ctx.helper.string("cityName", _cityName); - checkBladeburnerAccess(ctx); - checkBladeburnerCity(ctx, cityName); - const bladeburner = player.bladeburner; - if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); - bladeburner.city = cityName; - return true; - }, + (_cityName: unknown): boolean => { + const cityName = ctx.helper.string("cityName", _cityName); + checkBladeburnerAccess(ctx); + checkBladeburnerCity(ctx, cityName); + const bladeburner = player.bladeburner; + if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); + bladeburner.city = cityName; + return true; + }, getStamina: (ctx: NetscriptContext) => (): [number, number] => { checkBladeburnerAccess(ctx); const bladeburner = player.bladeburner;