Actually format + lint

This commit is contained in:
omuretsu 2022-10-12 09:54:13 -04:00
parent 7a384d53f4
commit e192ad53ec
2 changed files with 668 additions and 707 deletions

@ -202,7 +202,7 @@ const base: InternalAPI<NS> = {
}, },
sleep: sleep:
(ctx) => (ctx) =>
async (_time = 0) => { (_time = 0) => {
const time = helpers.number(ctx, "time", _time); const time = helpers.number(ctx, "time", _time);
if (time === undefined) { if (time === undefined) {
throw helpers.makeRuntimeErrorMsg(ctx, "Takes 1 argument."); throw helpers.makeRuntimeErrorMsg(ctx, "Takes 1 argument.");
@ -212,15 +212,16 @@ const base: InternalAPI<NS> = {
return Promise.resolve(true); return Promise.resolve(true);
}); });
}, },
asleep: (ctx) => asleep:
function (_time = 0) { (ctx) =>
(_time = 0) => {
const time = helpers.number(ctx, "time", _time); const time = helpers.number(ctx, "time", _time);
helpers.log(ctx, () => `Sleeping for ${time} milliseconds`); helpers.log(ctx, () => `Sleeping for ${time} milliseconds`);
return new Promise((resolve) => setTimeout(() => resolve(true), time)); return new Promise((resolve) => setTimeout(() => resolve(true), time));
}, },
grow: grow:
(ctx) => (ctx) =>
async (_hostname, opts = {}) => { (_hostname, opts = {}) => {
const hostname = helpers.string(ctx, "hostname", _hostname); const hostname = helpers.string(ctx, "hostname", _hostname);
const optsValidator: BasicHGWOptions = {}; const optsValidator: BasicHGWOptions = {};
assertObjectType(ctx, "opts", opts, optsValidator); assertObjectType(ctx, "opts", opts, optsValidator);
@ -384,7 +385,7 @@ const base: InternalAPI<NS> = {
const coreBonus = 1 + (cores - 1) / 16; const coreBonus = 1 + (cores - 1) / 16;
return CONSTANTS.ServerWeakenAmount * threads * coreBonus * BitNodeMultipliers.ServerWeakenRate; return CONSTANTS.ServerWeakenAmount * threads * coreBonus * BitNodeMultipliers.ServerWeakenRate;
}, },
share: (ctx) => async (): Promise<void> => { share: (ctx) => () => {
helpers.log(ctx, () => "Sharing this computer."); helpers.log(ctx, () => "Sharing this computer.");
const end = StartSharing( const end = StartSharing(
ctx.workerScript.scriptRef.threads * calculateIntelligenceBonus(Player.skills.intelligence, 2), ctx.workerScript.scriptRef.threads * calculateIntelligenceBonus(Player.skills.intelligence, 2),

@ -11,11 +11,7 @@ import { isString } from "../utils/helpers/isString";
import { RunningScript } from "../Script/RunningScript"; import { RunningScript } from "../Script/RunningScript";
import { calculateAchievements } from "../Achievements/Achievements"; import { calculateAchievements } from "../Achievements/Achievements";
import { import { Singularity as ISingularity } from "../ScriptEditor/NetscriptDefinitions";
Multipliers,
CrimeStats,
Singularity as ISingularity,
} from "../ScriptEditor/NetscriptDefinitions";
import { findCrime } from "../Crime/CrimeHelpers"; import { findCrime } from "../Crime/CrimeHelpers";
import { CompanyPositions } from "../Company/CompanyPositions"; import { CompanyPositions } from "../Company/CompanyPositions";
@ -97,8 +93,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
}; };
return { return {
getOwnedAugmentations: (ctx) => getOwnedAugmentations: (ctx) => (_purchased) => {
function (_purchased = false) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const purchased = !!_purchased; const purchased = !!_purchased;
const res: string[] = []; const res: string[] = [];
@ -117,59 +112,51 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return { n: sf.n, lvl: sf.lvl }; return { n: sf.n, lvl: sf.lvl };
}); });
}, },
getAugmentationsFromFaction: (ctx) => getAugmentationsFromFaction: (ctx) => (_facName) => {
function (_facName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
const faction = getFaction(ctx, facName); const faction = getFaction(ctx, facName);
return getFactionAugmentationsFiltered(faction); return getFactionAugmentationsFiltered(faction);
}, },
getAugmentationCost: (ctx) => getAugmentationCost: (ctx) => (_augName) => {
function (_augName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const augName = helpers.string(ctx, "augName", _augName); const augName = helpers.string(ctx, "augName", _augName);
const aug = getAugmentation(ctx, augName); const aug = getAugmentation(ctx, augName);
const costs = aug.getCost(); const costs = aug.getCost();
return [costs.repCost, costs.moneyCost]; return [costs.repCost, costs.moneyCost];
}, },
getAugmentationPrereq: (ctx) => getAugmentationPrereq: (ctx) => (_augName) => {
function (_augName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const augName = helpers.string(ctx, "augName", _augName); const augName = helpers.string(ctx, "augName", _augName);
const aug = getAugmentation(ctx, augName); const aug = getAugmentation(ctx, augName);
return aug.prereqs.slice(); return aug.prereqs.slice();
}, },
getAugmentationBasePrice: (ctx) => getAugmentationBasePrice: (ctx) => (_augName) => {
function (_augName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const augName = helpers.string(ctx, "augName", _augName); const augName = helpers.string(ctx, "augName", _augName);
const aug = getAugmentation(ctx, augName); const aug = getAugmentation(ctx, augName);
return aug.baseCost * BitNodeMultipliers.AugmentationMoneyCost; return aug.baseCost * BitNodeMultipliers.AugmentationMoneyCost;
}, },
getAugmentationPrice: (ctx) => getAugmentationPrice: (ctx) => (_augName) => {
function (_augName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const augName = helpers.string(ctx, "augName", _augName); const augName = helpers.string(ctx, "augName", _augName);
const aug = getAugmentation(ctx, augName); const aug = getAugmentation(ctx, augName);
return aug.getCost().moneyCost; return aug.getCost().moneyCost;
}, },
getAugmentationRepReq: (ctx) => getAugmentationRepReq: (ctx) => (_augName) => {
function (_augName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const augName = helpers.string(ctx, "augName", _augName); const augName = helpers.string(ctx, "augName", _augName);
const aug = getAugmentation(ctx, augName); const aug = getAugmentation(ctx, augName);
return aug.getCost().repCost; return aug.getCost().repCost;
}, },
getAugmentationStats: (ctx) => getAugmentationStats: (ctx) => (_augName) => {
function (_augName): Multipliers {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const augName = helpers.string(ctx, "augName", _augName); const augName = helpers.string(ctx, "augName", _augName);
const aug = getAugmentation(ctx, augName); const aug = getAugmentation(ctx, augName);
return Object.assign({}, aug.mults); return Object.assign({}, aug.mults);
}, },
purchaseAugmentation: (ctx) => purchaseAugmentation: (ctx) => (_facName, _augName) => {
function (_facName, _augName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
const augName = helpers.string(ctx, "augName", _augName); const augName = helpers.string(ctx, "augName", _augName);
@ -218,10 +205,9 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return false; return false;
} }
}, },
softReset: (ctx) => softReset: (ctx) => (_cbScript) => {
function (_cbScript = "") {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const cbScript = helpers.string(ctx, "cbScript", _cbScript); const cbScript = _cbScript ? helpers.string(ctx, "cbScript", _cbScript) : "";
helpers.log(ctx, () => "Soft resetting. This will cause this script to be killed"); helpers.log(ctx, () => "Soft resetting. This will cause this script to be killed");
setTimeout(() => { setTimeout(() => {
@ -231,10 +217,9 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
killWorkerScript(ctx.workerScript); killWorkerScript(ctx.workerScript);
}, },
installAugmentations: (ctx) => installAugmentations: (ctx) => (_cbScript) => {
function (_cbScript = "") {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const cbScript = helpers.string(ctx, "cbScript", _cbScript); const cbScript = _cbScript ? helpers.string(ctx, "cbScript", _cbScript) : "";
if (Player.queuedAugmentations.length === 0) { if (Player.queuedAugmentations.length === 0) {
helpers.log(ctx, () => "You do not have any Augmentations to be installed."); helpers.log(ctx, () => "You do not have any Augmentations to be installed.");
@ -251,8 +236,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return true; return true;
}, },
goToLocation: (ctx) => goToLocation: (ctx) => (_locationName) => {
function (_locationName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const locationName = helpers.string(ctx, "locationName", _locationName); const locationName = helpers.string(ctx, "locationName", _locationName);
const location = Object.values(Locations).find((l) => l.name === locationName); const location = Object.values(Locations).find((l) => l.name === locationName);
@ -274,8 +258,9 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
return true; return true;
}, },
universityCourse: (ctx) => universityCourse:
function (_universityName, _className, _focus = true) { (ctx) =>
(_universityName, _className, _focus = true) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const universityName = helpers.string(ctx, "universityName", _universityName); const universityName = helpers.string(ctx, "universityName", _universityName);
const className = helpers.string(ctx, "className", _className); const className = helpers.string(ctx, "className", _className);
@ -360,8 +345,9 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return true; return true;
}, },
gymWorkout: (ctx) => gymWorkout:
function (_gymName, _stat, _focus = true) { (ctx) =>
(_gymName, _stat, _focus = true) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const gymName = helpers.string(ctx, "gymName", _gymName); const gymName = helpers.string(ctx, "gymName", _gymName);
const stat = helpers.string(ctx, "stat", _stat); const stat = helpers.string(ctx, "stat", _stat);
@ -469,8 +455,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return true; return true;
}, },
travelToCity: (ctx) => travelToCity: (ctx) => (_cityName) => {
function (_cityName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const cityName = helpers.city(ctx, "cityName", _cityName); const cityName = helpers.city(ctx, "cityName", _cityName);
@ -495,8 +480,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
} }
}, },
purchaseTor: (ctx) => purchaseTor: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
if (Player.hasTorRouter()) { if (Player.hasTorRouter()) {
@ -519,8 +503,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
helpers.log(ctx, () => "You have purchased a Tor router!"); helpers.log(ctx, () => "You have purchased a Tor router!");
return true; return true;
}, },
purchaseProgram: (ctx) => purchaseProgram: (ctx) => (_programName) => {
function (_programName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const programName = helpers.string(ctx, "programName", _programName).toLowerCase(); const programName = helpers.string(ctx, "programName", _programName).toLowerCase();
@ -562,13 +545,11 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 5000); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 5000);
return true; return true;
}, },
getCurrentServer: (ctx) => getCurrentServer: (ctx) => () => {
function (): string {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
return Player.getCurrentServer().hostname; return Player.getCurrentServer().hostname;
}, },
connect: (ctx) => connect: (ctx) => (_hostname) => {
function (_hostname) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const hostname = helpers.string(ctx, "hostname", _hostname); const hostname = helpers.string(ctx, "hostname", _hostname);
if (!hostname) { if (!hostname) {
@ -616,8 +597,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
//Failure case //Failure case
return false; return false;
}, },
manualHack: (ctx) => manualHack: (ctx) => () => {
function (): Promise<number> {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const server = Player.getCurrentServer(); const server = Player.getCurrentServer();
return helpers.hack(ctx, server.hostname, true); return helpers.hack(ctx, server.hostname, true);
@ -654,13 +634,11 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return Promise.resolve(); return Promise.resolve();
}); });
}, },
isFocused: (ctx) => isFocused: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
return Player.focus; return Player.focus;
}, },
setFocus: (ctx) => setFocus: (ctx) => (_focus) => {
function (_focus) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const focus = !!_focus; const focus = !!_focus;
if (Player.currentWork === null) { if (Player.currentWork === null) {
@ -678,8 +656,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
} }
return false; return false;
}, },
hospitalize: (ctx) => hospitalize: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
if (Player.currentWork || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) { if (Player.currentWork || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
helpers.log(ctx, () => "Cannot go to the hospital because the player is busy."); helpers.log(ctx, () => "Cannot go to the hospital because the player is busy.");
@ -687,20 +664,17 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
} }
Player.hospitalize(); Player.hospitalize();
}, },
isBusy: (ctx) => isBusy: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
return Player.currentWork !== null || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse; return Player.currentWork !== null || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
}, },
stopAction: (ctx) => stopAction: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const wasWorking = Player.currentWork !== null; const wasWorking = Player.currentWork !== null;
Player.finishWork(true); Player.finishWork(true);
return wasWorking; return wasWorking;
}, },
upgradeHomeCores: (ctx) => upgradeHomeCores: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
// Check if we're at max cores // Check if we're at max cores
@ -726,14 +700,12 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
); );
return true; return true;
}, },
getUpgradeHomeCoresCost: (ctx) => getUpgradeHomeCoresCost: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
return Player.getUpgradeHomeCoresCost(); return Player.getUpgradeHomeCoresCost();
}, },
upgradeHomeRam: (ctx) => upgradeHomeRam: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
// Check if we're at max RAM // Check if we're at max RAM
@ -762,14 +734,14 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
); );
return true; return true;
}, },
getUpgradeHomeRamCost: (ctx) => getUpgradeHomeRamCost: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
return Player.getUpgradeHomeRamCost(); return Player.getUpgradeHomeRamCost();
}, },
workForCompany: (ctx) => workForCompany:
function (_companyName, _focus = true) { (ctx) =>
(_companyName, _focus = true) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const companyName = helpers.string(ctx, "companyName", _companyName); const companyName = helpers.string(ctx, "companyName", _companyName);
const focus = !!_focus; const focus = !!_focus;
@ -812,8 +784,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
helpers.log(ctx, () => `Began working at '${companyName}' with position '${companyPositionName}'`); helpers.log(ctx, () => `Began working at '${companyName}' with position '${companyPositionName}'`);
return true; return true;
}, },
applyToCompany: (ctx) => applyToCompany: (ctx) => (_companyName, _field) => {
function (_companyName, _field) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const companyName = helpers.string(ctx, "companyName", _companyName); const companyName = helpers.string(ctx, "companyName", _companyName);
const field = helpers.string(ctx, "field", _field); const field = helpers.string(ctx, "field", _field);
@ -881,41 +852,35 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
} }
return res; return res;
}, },
quitJob: (ctx) => quitJob: (ctx) => (_companyName) => {
function (_companyName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const companyName = helpers.string(ctx, "companyName", _companyName); const companyName = helpers.string(ctx, "companyName", _companyName);
Player.quitJob(companyName); Player.quitJob(companyName);
}, },
getCompanyRep: (ctx) => getCompanyRep: (ctx) => (_companyName) => {
function (_companyName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const companyName = helpers.string(ctx, "companyName", _companyName); const companyName = helpers.string(ctx, "companyName", _companyName);
const company = getCompany(ctx, companyName); const company = getCompany(ctx, companyName);
return company.playerReputation; return company.playerReputation;
}, },
getCompanyFavor: (ctx) => getCompanyFavor: (ctx) => (_companyName) => {
function (_companyName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const companyName = helpers.string(ctx, "companyName", _companyName); const companyName = helpers.string(ctx, "companyName", _companyName);
const company = getCompany(ctx, companyName); const company = getCompany(ctx, companyName);
return company.favor; return company.favor;
}, },
getCompanyFavorGain: (ctx) => getCompanyFavorGain: (ctx) => (_companyName) => {
function (_companyName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const companyName = helpers.string(ctx, "companyName", _companyName); const companyName = helpers.string(ctx, "companyName", _companyName);
const company = getCompany(ctx, companyName); const company = getCompany(ctx, companyName);
return company.getFavorGain(); return company.getFavorGain();
}, },
checkFactionInvitations: (ctx) => checkFactionInvitations: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
// Make a copy of player.factionInvitations // Make a copy of player.factionInvitations
return Player.factionInvitations.slice(); return Player.factionInvitations.slice();
}, },
joinFaction: (ctx) => joinFaction: (ctx) => (_facName) => {
function (_facName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
getFaction(ctx, facName); getFaction(ctx, facName);
@ -938,8 +903,9 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
helpers.log(ctx, () => `Joined the '${facName}' faction.`); helpers.log(ctx, () => `Joined the '${facName}' faction.`);
return true; return true;
}, },
workForFaction: (ctx) => workForFaction:
function (_facName, _type, _focus = true) { (ctx) =>
(_facName, _type, _focus = true) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
const type = helpers.string(ctx, "type", _type); const type = helpers.string(ctx, "type", _type);
@ -1034,29 +1000,25 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return false; return false;
} }
}, },
getFactionRep: (ctx) => getFactionRep: (ctx) => (_facName) => {
function (_facName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
const faction = getFaction(ctx, facName); const faction = getFaction(ctx, facName);
return faction.playerReputation; return faction.playerReputation;
}, },
getFactionFavor: (ctx) => getFactionFavor: (ctx) => (_facName) => {
function (_facName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
const faction = getFaction(ctx, facName); const faction = getFaction(ctx, facName);
return faction.favor; return faction.favor;
}, },
getFactionFavorGain: (ctx) => getFactionFavorGain: (ctx) => (_facName) => {
function (_facName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
const faction = getFaction(ctx, facName); const faction = getFaction(ctx, facName);
return faction.getFavorGain(); return faction.getFavorGain();
}, },
donateToFaction: (ctx) => donateToFaction: (ctx) => (_facName, _amt) => {
function (_facName, _amt) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = helpers.string(ctx, "facName", _facName); const facName = helpers.string(ctx, "facName", _facName);
const amt = helpers.number(ctx, "amt", _amt); const amt = helpers.number(ctx, "amt", _amt);
@ -1105,8 +1067,9 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
); );
return true; return true;
}, },
createProgram: (ctx) => createProgram:
function (_programName, _focus = true) { (ctx) =>
(_programName, _focus = true) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const programName = helpers.string(ctx, "programName", _programName).toLowerCase(); const programName = helpers.string(ctx, "programName", _programName).toLowerCase();
const focus = !!_focus; const focus = !!_focus;
@ -1152,8 +1115,9 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
helpers.log(ctx, () => `Began creating program: '${programName}'`); helpers.log(ctx, () => `Began creating program: '${programName}'`);
return true; return true;
}, },
commitCrime: (ctx) => commitCrime:
function (_crimeRoughName, _focus = true) { (ctx) =>
(_crimeRoughName, _focus = true) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const crimeRoughName = helpers.string(ctx, "crimeRoughName", _crimeRoughName); const crimeRoughName = helpers.string(ctx, "crimeRoughName", _crimeRoughName);
const focus = !!_focus; const focus = !!_focus;
@ -1182,8 +1146,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
} }
return crimeTime; return crimeTime;
}, },
getCrimeChance: (ctx) => getCrimeChance: (ctx) => (_crimeRoughName) => {
function (_crimeRoughName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const crimeRoughName = helpers.string(ctx, "crimeRoughName", _crimeRoughName); const crimeRoughName = helpers.string(ctx, "crimeRoughName", _crimeRoughName);
@ -1194,8 +1157,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return crime.successRate(Player); return crime.successRate(Player);
}, },
getCrimeStats: (ctx) => getCrimeStats: (ctx) => (_crimeRoughName) => {
function (_crimeRoughName): CrimeStats {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const crimeRoughName = helpers.string(ctx, "crimeRoughName", _crimeRoughName); const crimeRoughName = helpers.string(ctx, "crimeRoughName", _crimeRoughName);
@ -1218,8 +1180,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
intelligence_exp: crimeStatsWithMultipliers.intExp, intelligence_exp: crimeStatsWithMultipliers.intExp,
}); });
}, },
getDarkwebPrograms: (ctx) => getDarkwebPrograms: (ctx) => () => {
function () {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
// If we don't have Tor, log it and return [] (empty list) // If we don't have Tor, log it and return [] (empty list)
@ -1229,8 +1190,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
} }
return Object.values(DarkWebItems).map((p) => p.program); return Object.values(DarkWebItems).map((p) => p.program);
}, },
getDarkwebProgramCost: (ctx) => getDarkwebProgramCost: (ctx) => (_programName) => {
function (_programName) {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const programName = helpers.string(ctx, "programName", _programName).toLowerCase(); const programName = helpers.string(ctx, "programName", _programName).toLowerCase();