2022-09-06 15:07:12 +02:00
|
|
|
import { Player } from "../Player";
|
2021-10-14 09:22:02 +02:00
|
|
|
import { Bladeburner } from "../Bladeburner/Bladeburner";
|
|
|
|
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
2021-11-04 01:19:52 +01:00
|
|
|
import { Bladeburner as INetscriptBladeburner, BladeburnerCurAction } from "../ScriptEditor/NetscriptDefinitions";
|
2022-03-30 02:44:27 +02:00
|
|
|
import { IAction } from "src/Bladeburner/IAction";
|
2022-05-08 01:08:07 +02:00
|
|
|
import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper";
|
2022-07-20 00:25:06 +02:00
|
|
|
import { BlackOperation } from "../Bladeburner/BlackOperation";
|
2022-08-08 19:43:41 +02:00
|
|
|
import { helpers } from "../Netscript/NetscriptHelpers";
|
2021-10-14 09:22:02 +02:00
|
|
|
|
2022-08-09 21:41:47 +02:00
|
|
|
export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
|
2022-09-06 15:07:12 +02:00
|
|
|
const checkBladeburnerAccess = function (ctx: NetscriptContext): void {
|
|
|
|
getBladeburner(ctx);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
const getBladeburner = function (ctx: NetscriptContext): Bladeburner {
|
|
|
|
const apiAccess = Player.bitNodeN === 7 || Player.sourceFiles.some((a) => a.n === 7);
|
2021-10-14 09:22:02 +02:00
|
|
|
if (!apiAccess) {
|
2022-09-06 15:07:12 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, "You have not unlocked the bladeburner API.", "API ACCESS");
|
2021-10-14 09:22:02 +02:00
|
|
|
}
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = Player.bladeburner;
|
|
|
|
if (!bladeburner)
|
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, "You must be a member of the Bladeburner division to use this API.");
|
|
|
|
return bladeburner;
|
2021-10-14 09:22:02 +02:00
|
|
|
};
|
|
|
|
|
2022-05-08 01:08:07 +02:00
|
|
|
const checkBladeburnerCity = function (ctx: NetscriptContext, city: string): void {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = Player.bladeburner;
|
2021-10-14 09:22:02 +02:00
|
|
|
if (bladeburner === null) throw new Error("Must have joined bladeburner");
|
|
|
|
if (!bladeburner.cities.hasOwnProperty(city)) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, `Invalid city: ${city}`);
|
2021-10-14 09:22:02 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-05-08 01:08:07 +02:00
|
|
|
const getBladeburnerActionObject = function (ctx: NetscriptContext, type: string, name: string): IAction {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = Player.bladeburner;
|
2021-10-14 09:22:02 +02:00
|
|
|
if (bladeburner === null) throw new Error("Must have joined bladeburner");
|
|
|
|
const actionId = bladeburner.getActionIdFromTypeAndName(type, name);
|
|
|
|
if (!actionId) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, `Invalid action type='${type}', name='${name}'`);
|
2021-10-14 09:22:02 +02:00
|
|
|
}
|
|
|
|
const actionObj = bladeburner.getActionObject(actionId);
|
|
|
|
if (!actionObj) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, `Invalid action type='${type}', name='${name}'`);
|
2021-10-14 09:22:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return actionObj;
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
2022-05-08 01:08:07 +02:00
|
|
|
getContractNames: (ctx: NetscriptContext) => (): string[] => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.getContractNamesNetscriptFn();
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getOperationNames: (ctx: NetscriptContext) => (): string[] => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.getOperationNamesNetscriptFn();
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getBlackOpNames: (ctx: NetscriptContext) => (): string[] => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.getBlackOpNamesNetscriptFn();
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getBlackOpRank:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_blackOpName: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const blackOpName = helpers.string(ctx, "blackOpName", _blackOpName);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
2022-07-20 00:25:06 +02:00
|
|
|
const action = getBladeburnerActionObject(ctx, "blackops", blackOpName);
|
|
|
|
if (!(action instanceof BlackOperation)) throw new Error("action was not a black operation");
|
2022-05-08 01:08:07 +02:00
|
|
|
return action.reqdRank;
|
|
|
|
},
|
|
|
|
getGeneralActionNames: (ctx: NetscriptContext) => (): string[] => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.getGeneralActionNamesNetscriptFn();
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getSkillNames: (ctx: NetscriptContext) => (): string[] => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.getSkillNamesNetscriptFn();
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
startAction:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): boolean => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-09-06 15:07:12 +02:00
|
|
|
return bladeburner.startActionNetscriptFn(type, name, ctx.workerScript);
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
stopBladeburnerAction: (ctx: NetscriptContext) => (): void => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.resetAction();
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getCurrentAction: (ctx: NetscriptContext) => (): BladeburnerCurAction => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.getTypeAndNameFromActionId(bladeburner.action);
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getActionTime:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-09-06 15:07:12 +02:00
|
|
|
const time = bladeburner.getActionTimeNetscriptFn(Player, type, name);
|
2022-05-20 21:58:33 +02:00
|
|
|
if (typeof time === "string") {
|
|
|
|
const errorLogText = `Invalid action: type='${type}' name='${name}'`;
|
2022-08-08 21:51:50 +02:00
|
|
|
helpers.log(ctx, () => errorLogText);
|
2022-05-20 21:58:33 +02:00
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return time;
|
|
|
|
}
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-04-14 17:40:59 +02:00
|
|
|
}
|
2022-05-08 01:08:07 +02:00
|
|
|
},
|
2022-05-22 06:40:08 +02:00
|
|
|
getActionCurrentTime: (ctx: NetscriptContext) => (): number => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-22 06:40:08 +02:00
|
|
|
try {
|
2022-05-22 06:40:32 +02:00
|
|
|
const timecomputed =
|
|
|
|
Math.min(bladeburner.actionTimeCurrent + bladeburner.actionTimeOverflow, bladeburner.actionTimeToComplete) *
|
|
|
|
1000;
|
2022-05-22 06:40:08 +02:00
|
|
|
return timecomputed;
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-22 06:40:08 +02:00
|
|
|
}
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getActionEstimatedSuccessChance:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): [number, number] => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-09-06 15:07:12 +02:00
|
|
|
const chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(Player, type, name);
|
2022-05-20 21:58:33 +02:00
|
|
|
if (typeof chance === "string") {
|
|
|
|
const errorLogText = `Invalid action: type='${type}' name='${name}'`;
|
2022-08-08 21:51:50 +02:00
|
|
|
helpers.log(ctx, () => errorLogText);
|
2022-05-20 21:58:33 +02:00
|
|
|
return [-1, -1];
|
|
|
|
} else {
|
|
|
|
return chance;
|
|
|
|
}
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getActionRepGain:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown, _level: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
|
|
|
const level = helpers.number(ctx, "level", _level);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
const action = getBladeburnerActionObject(ctx, type, name);
|
|
|
|
let rewardMultiplier;
|
|
|
|
if (level == null || isNaN(level)) {
|
|
|
|
rewardMultiplier = Math.pow(action.rewardFac, action.level - 1);
|
2022-04-14 17:40:59 +02:00
|
|
|
} else {
|
2022-05-08 01:08:07 +02:00
|
|
|
rewardMultiplier = Math.pow(action.rewardFac, level - 1);
|
2022-04-14 17:40:59 +02:00
|
|
|
}
|
2021-10-14 09:22:02 +02:00
|
|
|
|
2022-05-08 01:08:07 +02:00
|
|
|
return action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank;
|
|
|
|
},
|
|
|
|
getActionCountRemaining:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-08-09 21:41:47 +02:00
|
|
|
return bladeburner.getActionCountRemainingNetscriptFn(type, name, ctx.workerScript);
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getActionMaxLevel:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
const action = getBladeburnerActionObject(ctx, type, name);
|
|
|
|
return action.maxLevel;
|
|
|
|
},
|
|
|
|
getActionCurrentLevel:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
const action = getBladeburnerActionObject(ctx, type, name);
|
|
|
|
return action.level;
|
|
|
|
},
|
|
|
|
getActionAutolevel:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): boolean => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
const action = getBladeburnerActionObject(ctx, type, name);
|
|
|
|
return action.autoLevel;
|
|
|
|
},
|
|
|
|
setActionAutolevel:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown, _autoLevel: unknown = true): void => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
|
|
|
const autoLevel = !!_autoLevel;
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
const action = getBladeburnerActionObject(ctx, type, name);
|
|
|
|
action.autoLevel = autoLevel;
|
|
|
|
},
|
|
|
|
setActionLevel:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown, _level: unknown = 1): void => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
|
|
|
const level = helpers.number(ctx, "level", _level);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
const action = getBladeburnerActionObject(ctx, type, name);
|
|
|
|
if (level < 1 || level > action.maxLevel) {
|
2022-08-26 20:59:26 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, `Level must be between 1 and ${action.maxLevel}, is ${level}`);
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
action.level = level;
|
|
|
|
},
|
|
|
|
getRank: (ctx: NetscriptContext) => (): number => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.rank;
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getSkillPoints: (ctx: NetscriptContext) => (): number => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.skillPoints;
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getSkillLevel:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_skillName: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const skillName = helpers.string(ctx, "skillName", _skillName);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-08-09 21:41:47 +02:00
|
|
|
return bladeburner.getSkillLevelNetscriptFn(skillName, ctx.workerScript);
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getSkillUpgradeCost:
|
|
|
|
(ctx: NetscriptContext) =>
|
2022-06-01 04:27:04 +02:00
|
|
|
(_skillName: unknown, _count: unknown = 1): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const skillName = helpers.string(ctx, "skillName", _skillName);
|
|
|
|
const count = helpers.number(ctx, "count", _count);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-08-09 21:41:47 +02:00
|
|
|
return bladeburner.getSkillUpgradeCostNetscriptFn(skillName, count, ctx.workerScript);
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
upgradeSkill:
|
|
|
|
(ctx: NetscriptContext) =>
|
2022-06-01 04:27:04 +02:00
|
|
|
(_skillName: unknown, _count: unknown = 1): boolean => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const skillName = helpers.string(ctx, "skillName", _skillName);
|
|
|
|
const count = helpers.number(ctx, "count", _count);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-08-09 21:41:47 +02:00
|
|
|
return bladeburner.upgradeSkillNetscriptFn(skillName, count, ctx.workerScript);
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getTeamSize:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-08-09 21:41:47 +02:00
|
|
|
return bladeburner.getTeamSizeNetscriptFn(type, name, ctx.workerScript);
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
setTeamSize:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_type: unknown, _name: unknown, _size: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const type = helpers.string(ctx, "type", _type);
|
|
|
|
const name = helpers.string(ctx, "name", _name);
|
|
|
|
const size = helpers.number(ctx, "size", _size);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-05-08 01:08:07 +02:00
|
|
|
try {
|
2022-08-09 21:41:47 +02:00
|
|
|
return bladeburner.setTeamSizeNetscriptFn(type, name, size, ctx.workerScript);
|
2022-07-15 07:51:30 +02:00
|
|
|
} catch (e: unknown) {
|
2022-08-08 19:43:41 +02:00
|
|
|
throw helpers.makeRuntimeErrorMsg(ctx, String(e));
|
2022-05-08 01:08:07 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getCityEstimatedPopulation:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_cityName: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const cityName = helpers.string(ctx, "cityName", _cityName);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
checkBladeburnerCity(ctx, cityName);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = Player.bladeburner;
|
2022-05-08 01:08:07 +02:00
|
|
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
|
|
|
return bladeburner.cities[cityName].popEst;
|
|
|
|
},
|
|
|
|
getCityCommunities:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_cityName: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const cityName = helpers.string(ctx, "cityName", _cityName);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
checkBladeburnerCity(ctx, cityName);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = Player.bladeburner;
|
2022-05-08 01:08:07 +02:00
|
|
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
|
|
|
return bladeburner.cities[cityName].comms;
|
|
|
|
},
|
|
|
|
getCityChaos:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_cityName: unknown): number => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const cityName = helpers.string(ctx, "cityName", _cityName);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
checkBladeburnerCity(ctx, cityName);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = Player.bladeburner;
|
2022-05-08 01:08:07 +02:00
|
|
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
|
|
|
return bladeburner.cities[cityName].chaos;
|
|
|
|
},
|
|
|
|
getCity: (ctx: NetscriptContext) => (): string => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return bladeburner.city;
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
switchCity:
|
|
|
|
(ctx: NetscriptContext) =>
|
|
|
|
(_cityName: unknown): boolean => {
|
2022-08-08 19:43:41 +02:00
|
|
|
const cityName = helpers.string(ctx, "cityName", _cityName);
|
2022-05-08 01:08:07 +02:00
|
|
|
checkBladeburnerAccess(ctx);
|
|
|
|
checkBladeburnerCity(ctx, cityName);
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = Player.bladeburner;
|
2022-05-08 01:08:07 +02:00
|
|
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
|
|
|
bladeburner.city = cityName;
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
getStamina: (ctx: NetscriptContext) => (): [number, number] => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2021-10-14 09:22:02 +02:00
|
|
|
return [bladeburner.stamina, bladeburner.maxStamina];
|
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
joinBladeburnerFaction: (ctx: NetscriptContext) => (): boolean => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-08-09 21:41:47 +02:00
|
|
|
return bladeburner.joinBladeburnerFactionNetscriptFn(ctx.workerScript);
|
2021-10-14 09:22:02 +02:00
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
joinBladeburnerDivision: (ctx: NetscriptContext) => (): boolean => {
|
2022-09-06 15:07:12 +02:00
|
|
|
if (Player.bitNodeN === 7 || Player.sourceFileLvl(7) > 0) {
|
2022-09-23 05:45:00 +02:00
|
|
|
if (BitNodeMultipliers.BladeburnerRank === 0) {
|
2022-09-12 16:46:16 +02:00
|
|
|
return false; // Disabled in this bitnode
|
2021-10-14 09:22:02 +02:00
|
|
|
}
|
2022-09-06 15:07:12 +02:00
|
|
|
if (Player.bladeburner instanceof Bladeburner) {
|
2021-10-14 09:22:02 +02:00
|
|
|
return true; // Already member
|
|
|
|
} else if (
|
2022-09-06 15:07:12 +02:00
|
|
|
Player.skills.strength >= 100 &&
|
|
|
|
Player.skills.defense >= 100 &&
|
|
|
|
Player.skills.dexterity >= 100 &&
|
|
|
|
Player.skills.agility >= 100
|
2021-10-14 09:22:02 +02:00
|
|
|
) {
|
2022-09-06 15:07:12 +02:00
|
|
|
Player.bladeburner = new Bladeburner();
|
2022-08-08 21:51:50 +02:00
|
|
|
helpers.log(ctx, () => "You have been accepted into the Bladeburner division");
|
2021-10-14 09:22:02 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
2022-08-08 21:51:50 +02:00
|
|
|
helpers.log(ctx, () => "You do not meet the requirements for joining the Bladeburner division");
|
2021-10-14 09:22:02 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-11-04 01:19:52 +01:00
|
|
|
return false;
|
2021-10-14 09:22:02 +02:00
|
|
|
},
|
2022-05-08 01:08:07 +02:00
|
|
|
getBonusTime: (ctx: NetscriptContext) => (): number => {
|
2022-09-06 15:07:12 +02:00
|
|
|
const bladeburner = getBladeburner(ctx);
|
2022-03-30 02:44:27 +02:00
|
|
|
return Math.round(bladeburner.storedCycles / 5) * 1000;
|
2021-10-14 09:22:02 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|