mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 01:32:55 +02:00
merge dev
This commit is contained in:
@@ -344,13 +344,13 @@ export function NetscriptBladeburner(
|
||||
player.agility >= 100
|
||||
) {
|
||||
player.bladeburner = new Bladeburner(player);
|
||||
workerScript.log("joinBladeburnerDivision", "You have been accepted into the Bladeburner division");
|
||||
workerScript.log("joinBladeburnerDivision", () => "You have been accepted into the Bladeburner division");
|
||||
|
||||
return true;
|
||||
} else {
|
||||
workerScript.log(
|
||||
"joinBladeburnerDivision",
|
||||
"You do not meet the requirements for joining the Bladeburner division",
|
||||
() => "You do not meet the requirements for joining the Bladeburner division",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,14 @@ export function NetscriptCodingContract(
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): ICodingContract {
|
||||
const getCodingContract = function (func: any, ip: any, fn: any): CodingContract {
|
||||
const server = helper.getServer(ip, func);
|
||||
const contract = server.getContract(fn);
|
||||
const getCodingContract = function (func: any, hostname: any, filename: any): CodingContract {
|
||||
const server = helper.getServer(hostname, func);
|
||||
const contract = server.getContract(filename);
|
||||
if (contract == null) {
|
||||
throw helper.makeRuntimeErrorMsg(`codingcontract.${func}`, `Cannot find contract '${fn}' on server '${ip}'`);
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`codingcontract.${func}`,
|
||||
`Cannot find contract '${filename}' on server '${hostname}'`,
|
||||
);
|
||||
}
|
||||
|
||||
return contract;
|
||||
@@ -24,12 +27,12 @@ export function NetscriptCodingContract(
|
||||
return {
|
||||
attempt: function (
|
||||
answer: any,
|
||||
fn: any,
|
||||
ip: any = workerScript.hostname,
|
||||
filename: any,
|
||||
hostname: any = workerScript.hostname,
|
||||
{ returnReward }: any = {},
|
||||
): boolean | string {
|
||||
helper.updateDynamicRam("attempt", getRamCost("codingcontract", "attempt"));
|
||||
const contract = getCodingContract("attempt", ip, fn);
|
||||
const contract = getCodingContract("attempt", hostname, filename);
|
||||
|
||||
// Convert answer to string. If the answer is a 2D array, then we have to
|
||||
// manually add brackets for the inner arrays
|
||||
@@ -47,35 +50,41 @@ export function NetscriptCodingContract(
|
||||
const creward = contract.reward;
|
||||
if (creward === null) throw new Error("Somehow solved a contract that didn't have a reward");
|
||||
|
||||
const serv = helper.getServer(ip, "codingcontract.attempt");
|
||||
const serv = helper.getServer(hostname, "codingcontract.attempt");
|
||||
if (contract.isSolution(answer)) {
|
||||
const reward = player.gainCodingContractReward(creward, contract.getDifficulty());
|
||||
workerScript.log("attempt", `Successfully completed Coding Contract '${fn}'. Reward: ${reward}`);
|
||||
serv.removeContract(fn);
|
||||
workerScript.log("attempt", () => `Successfully completed Coding Contract '${filename}'. Reward: ${reward}`);
|
||||
serv.removeContract(filename);
|
||||
return returnReward ? reward : true;
|
||||
} else {
|
||||
++contract.tries;
|
||||
if (contract.tries >= contract.getMaxNumTries()) {
|
||||
workerScript.log("attempt", `Coding Contract attempt '${fn}' failed. Contract is now self-destructing`);
|
||||
serv.removeContract(fn);
|
||||
workerScript.log(
|
||||
"attempt",
|
||||
() => `Coding Contract attempt '${filename}' failed. Contract is now self-destructing`,
|
||||
);
|
||||
serv.removeContract(filename);
|
||||
} else {
|
||||
workerScript.log(
|
||||
"attempt",
|
||||
`Coding Contract attempt '${fn}' failed. ${contract.getMaxNumTries() - contract.tries} attempts remaining.`,
|
||||
() =>
|
||||
`Coding Contract attempt '${filename}' failed. ${
|
||||
contract.getMaxNumTries() - contract.tries
|
||||
} attempts remaining.`,
|
||||
);
|
||||
}
|
||||
|
||||
return returnReward ? "" : false;
|
||||
}
|
||||
},
|
||||
getContractType: function (fn: any, ip: any = workerScript.hostname): string {
|
||||
getContractType: function (filename: any, hostname: any = workerScript.hostname): string {
|
||||
helper.updateDynamicRam("getContractType", getRamCost("codingcontract", "getContractType"));
|
||||
const contract = getCodingContract("getContractType", ip, fn);
|
||||
const contract = getCodingContract("getContractType", hostname, filename);
|
||||
return contract.getType();
|
||||
},
|
||||
getData: function (fn: any, ip: any = workerScript.hostname): any {
|
||||
getData: function (filename: any, hostname: any = workerScript.hostname): any {
|
||||
helper.updateDynamicRam("getData", getRamCost("codingcontract", "getData"));
|
||||
const contract = getCodingContract("getData", ip, fn);
|
||||
const contract = getCodingContract("getData", hostname, filename);
|
||||
const data = contract.getData();
|
||||
if (data.constructor === Array) {
|
||||
// For two dimensional arrays, we have to copy the internal arrays using
|
||||
@@ -93,14 +102,14 @@ export function NetscriptCodingContract(
|
||||
return data;
|
||||
}
|
||||
},
|
||||
getDescription: function (fn: any, ip: any = workerScript.hostname): string {
|
||||
getDescription: function (filename: any, hostname: any = workerScript.hostname): string {
|
||||
helper.updateDynamicRam("getDescription", getRamCost("codingcontract", "getDescription"));
|
||||
const contract = getCodingContract("getDescription", ip, fn);
|
||||
const contract = getCodingContract("getDescription", hostname, filename);
|
||||
return contract.getDescription();
|
||||
},
|
||||
getNumTriesRemaining: function (fn: any, ip: any = workerScript.hostname): number {
|
||||
getNumTriesRemaining: function (filename: any, hostname: any = workerScript.hostname): number {
|
||||
helper.updateDynamicRam("getNumTriesRemaining", getRamCost("codingcontract", "getNumTriesRemaining"));
|
||||
const contract = getCodingContract("getNumTriesRemaining", ip, fn);
|
||||
const contract = getCodingContract("getNumTriesRemaining", hostname, filename);
|
||||
return contract.getMaxNumTries() - contract.tries;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -167,9 +167,9 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
if (gang === null) throw new Error("Should not be called without Gang");
|
||||
const recruited = gang.recruitMember(name);
|
||||
if (recruited) {
|
||||
workerScript.log("recruitMember", `Successfully recruited Gang Member '${name}'`);
|
||||
workerScript.log("gang.recruitMember", () => `Successfully recruited Gang Member '${name}'`);
|
||||
} else {
|
||||
workerScript.log("recruitMember", `Failed to recruit Gang Member '${name}'`);
|
||||
workerScript.log("gang.recruitMember", () => `Failed to recruit Gang Member '${name}'`);
|
||||
}
|
||||
|
||||
return recruited;
|
||||
@@ -189,11 +189,14 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
const member = getGangMember("setMemberTask", memberName);
|
||||
const success = member.assignToTask(taskName);
|
||||
if (success) {
|
||||
workerScript.log("setMemberTask", `Successfully assigned Gang Member '${memberName}' to '${taskName}' task`);
|
||||
workerScript.log(
|
||||
"gang.setMemberTask",
|
||||
() => `Successfully assigned Gang Member '${memberName}' to '${taskName}' task`,
|
||||
);
|
||||
} else {
|
||||
workerScript.log(
|
||||
"setMemberTask",
|
||||
`Failed to assign Gang Member '${memberName}' to '${taskName}' task. '${memberName}' is now Unassigned`,
|
||||
"gang.setMemberTask",
|
||||
() => `Failed to assign Gang Member '${memberName}' to '${taskName}' task. '${memberName}' is now Unassigned`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,9 +251,12 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
if (!equipment) return false;
|
||||
const res = member.buyUpgrade(equipment, player, gang);
|
||||
if (res) {
|
||||
workerScript.log("purchaseEquipment", `Purchased '${equipName}' for Gang member '${memberName}'`);
|
||||
workerScript.log("gang.purchaseEquipment", () => `Purchased '${equipName}' for Gang member '${memberName}'`);
|
||||
} else {
|
||||
workerScript.log("purchaseEquipment", `Failed to purchase '${equipName}' for Gang member '${memberName}'`);
|
||||
workerScript.log(
|
||||
"gang.purchaseEquipment",
|
||||
() => `Failed to purchase '${equipName}' for Gang member '${memberName}'`,
|
||||
);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -271,10 +277,10 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
if (gang === null) throw new Error("Should not be called without Gang");
|
||||
if (engage) {
|
||||
gang.territoryWarfareEngaged = true;
|
||||
workerScript.log("setTerritoryWarfare", "Engaging in Gang Territory Warfare");
|
||||
workerScript.log("gang.setTerritoryWarfare", () => "Engaging in Gang Territory Warfare");
|
||||
} else {
|
||||
gang.territoryWarfareEngaged = false;
|
||||
workerScript.log("setTerritoryWarfare", "Disengaging in Gang Territory Warfare");
|
||||
workerScript.log("gang.setTerritoryWarfare", () => "Disengaging in Gang Territory Warfare");
|
||||
}
|
||||
},
|
||||
getChanceToWinClash: function (otherGang: any): number {
|
||||
|
||||
@@ -109,7 +109,7 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
|
||||
}
|
||||
const node = getHacknetNode(i, "upgradeCache");
|
||||
if (!(node instanceof HacknetServer)) {
|
||||
workerScript.log("upgradeCache", "Can only be called on hacknet servers");
|
||||
workerScript.log("upgradeCache", () => "Can only be called on hacknet servers");
|
||||
return false;
|
||||
}
|
||||
const res = purchaseCacheUpgrade(player, node, n);
|
||||
@@ -136,7 +136,7 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
|
||||
}
|
||||
const node = getHacknetNode(i, "upgradeCache");
|
||||
if (!(node instanceof HacknetServer)) {
|
||||
workerScript.log("getCacheUpgradeCost", "Can only be called on hacknet servers");
|
||||
workerScript.log("getCacheUpgradeCost", () => "Can only be called on hacknet servers");
|
||||
return -1;
|
||||
}
|
||||
return node.calculateCacheUpgradeCost(n);
|
||||
|
||||
@@ -105,18 +105,6 @@ export function NetscriptSingularity(
|
||||
}
|
||||
return res;
|
||||
},
|
||||
getOwnedSourceFiles: function (): any {
|
||||
helper.updateDynamicRam("getOwnedSourceFiles", getRamCost("getOwnedSourceFiles"));
|
||||
helper.checkSingularityAccess("getOwnedSourceFiles", 3);
|
||||
const res = [];
|
||||
for (let i = 0; i < player.sourceFiles.length; ++i) {
|
||||
res.push({
|
||||
n: player.sourceFiles[i].n,
|
||||
lvl: player.sourceFiles[i].lvl,
|
||||
});
|
||||
}
|
||||
return res;
|
||||
},
|
||||
getAugmentationsFromFaction: function (facname: any): any {
|
||||
helper.updateDynamicRam("getAugmentationsFromFaction", getRamCost("getAugmentationsFromFaction"));
|
||||
helper.checkSingularityAccess("getAugmentationsFromFaction", 3);
|
||||
@@ -126,6 +114,8 @@ export function NetscriptSingularity(
|
||||
if (player.hasGangWith(facname)) {
|
||||
const res = [];
|
||||
for (const augName in Augmentations) {
|
||||
if (augName === AugmentationNames.NeuroFluxGovernor) continue;
|
||||
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
|
||||
const aug = Augmentations[augName];
|
||||
if (!aug.isSpecial) {
|
||||
res.push(augName);
|
||||
@@ -186,7 +176,10 @@ export function NetscriptSingularity(
|
||||
}
|
||||
|
||||
if (!augs.includes(name)) {
|
||||
workerScript.log("purchaseAugmentation", `Faction '${faction}' does not have the '${name}' augmentation.`);
|
||||
workerScript.log(
|
||||
"purchaseAugmentation",
|
||||
() => `Faction '${faction}' does not have the '${name}' augmentation.`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -194,25 +187,25 @@ export function NetscriptSingularity(
|
||||
if (!isNeuroflux) {
|
||||
for (let j = 0; j < player.queuedAugmentations.length; ++j) {
|
||||
if (player.queuedAugmentations[j].name === aug.name) {
|
||||
workerScript.log("purchaseAugmentation", `You already have the '${name}' augmentation.`);
|
||||
workerScript.log("purchaseAugmentation", () => `You already have the '${name}' augmentation.`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (let j = 0; j < player.augmentations.length; ++j) {
|
||||
if (player.augmentations[j].name === aug.name) {
|
||||
workerScript.log("purchaseAugmentation", `You already have the '${name}' augmentation.`);
|
||||
workerScript.log("purchaseAugmentation", () => `You already have the '${name}' augmentation.`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fac.playerReputation < aug.baseRepRequirement) {
|
||||
workerScript.log("purchaseAugmentation", `You do not have enough reputation with '${fac.name}'.`);
|
||||
workerScript.log("purchaseAugmentation", () => `You do not have enough reputation with '${fac.name}'.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const res = purchaseAugmentation(aug, fac, true);
|
||||
workerScript.log("purchaseAugmentation", res);
|
||||
workerScript.log("purchaseAugmentation", () => res);
|
||||
if (isString(res) && res.startsWith("You purchased")) {
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
return true;
|
||||
@@ -224,7 +217,7 @@ export function NetscriptSingularity(
|
||||
helper.updateDynamicRam("softReset", getRamCost("softReset"));
|
||||
helper.checkSingularityAccess("softReset", 3);
|
||||
|
||||
workerScript.log("softReset", "Soft resetting. This will cause this script to be killed");
|
||||
workerScript.log("softReset", () => "Soft resetting. This will cause this script to be killed");
|
||||
setTimeout(() => {
|
||||
prestigeAugmentation();
|
||||
runAfterReset(cbScript);
|
||||
@@ -239,11 +232,14 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("installAugmentations", 3);
|
||||
|
||||
if (player.queuedAugmentations.length === 0) {
|
||||
workerScript.log("installAugmentations", "You do not have any Augmentations to be installed.");
|
||||
workerScript.log("installAugmentations", () => "You do not have any Augmentations to be installed.");
|
||||
return false;
|
||||
}
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.log("installAugmentations", "Installing Augmentations. This will cause this script to be killed");
|
||||
workerScript.log(
|
||||
"installAugmentations",
|
||||
() => "Installing Augmentations. This will cause this script to be killed",
|
||||
);
|
||||
setTimeout(() => {
|
||||
installAugmentations();
|
||||
runAfterReset(cbScript);
|
||||
@@ -258,11 +254,11 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("goToLocation", 1);
|
||||
const location = Object.values(Locations).find((l) => l.name === locationName);
|
||||
if (!location) {
|
||||
workerScript.log("goToLocation", `No location named ${locationName}`);
|
||||
workerScript.log("goToLocation", () => `No location named ${locationName}`);
|
||||
return false;
|
||||
}
|
||||
if (player.city !== location.city) {
|
||||
workerScript.log("goToLocation", `No location named ${locationName} in ${player.city}`);
|
||||
workerScript.log("goToLocation", () => `No location named ${locationName} in ${player.city}`);
|
||||
return false;
|
||||
}
|
||||
Router.toLocation(location);
|
||||
@@ -274,7 +270,7 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("universityCourse", 1);
|
||||
if (player.isWorking) {
|
||||
const txt = player.singularityStopWork();
|
||||
workerScript.log("universityCourse", txt);
|
||||
workerScript.log("universityCourse", () => txt);
|
||||
}
|
||||
|
||||
let costMult, expMult;
|
||||
@@ -283,7 +279,7 @@ export function NetscriptSingularity(
|
||||
if (player.city != CityName.Aevum) {
|
||||
workerScript.log(
|
||||
"universityCourse",
|
||||
"You cannot study at 'Summit University' because you are not in 'Aevum'.",
|
||||
() => "You cannot study at 'Summit University' because you are not in 'Aevum'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -295,7 +291,7 @@ export function NetscriptSingularity(
|
||||
if (player.city != CityName.Sector12) {
|
||||
workerScript.log(
|
||||
"universityCourse",
|
||||
"You cannot study at 'Rothman University' because you are not in 'Sector-12'.",
|
||||
() => "You cannot study at 'Rothman University' because you are not in 'Sector-12'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -307,7 +303,7 @@ export function NetscriptSingularity(
|
||||
if (player.city != CityName.Volhaven) {
|
||||
workerScript.log(
|
||||
"universityCourse",
|
||||
"You cannot study at 'ZB Institute of Technology' because you are not in 'Volhaven'.",
|
||||
() => "You cannot study at 'ZB Institute of Technology' because you are not in 'Volhaven'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -316,11 +312,11 @@ export function NetscriptSingularity(
|
||||
expMult = 4;
|
||||
break;
|
||||
default:
|
||||
workerScript.log("universityCourse", `Invalid university name: '${universityName}'.`);
|
||||
workerScript.log("universityCourse", () => `Invalid university name: '${universityName}'.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let task;
|
||||
let task = "";
|
||||
switch (className.toLowerCase()) {
|
||||
case "Study Computer Science".toLowerCase():
|
||||
task = CONSTANTS.ClassStudyComputerScience;
|
||||
@@ -341,11 +337,11 @@ export function NetscriptSingularity(
|
||||
task = CONSTANTS.ClassLeadership;
|
||||
break;
|
||||
default:
|
||||
workerScript.log("universityCourse", `Invalid class name: ${className}.`);
|
||||
workerScript.log("universityCourse", () => `Invalid class name: ${className}.`);
|
||||
return false;
|
||||
}
|
||||
player.startClass(Router, costMult, expMult, task);
|
||||
workerScript.log("universityCourse", `Started ${task} at ${universityName}`);
|
||||
workerScript.log("universityCourse", () => `Started ${task} at ${universityName}`);
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -354,13 +350,16 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("gymWorkout", 1);
|
||||
if (player.isWorking) {
|
||||
const txt = player.singularityStopWork();
|
||||
workerScript.log("gymWorkout", txt);
|
||||
workerScript.log("gymWorkout", () => txt);
|
||||
}
|
||||
let costMult, expMult;
|
||||
switch (gymName.toLowerCase()) {
|
||||
case LocationName.AevumCrushFitnessGym.toLowerCase():
|
||||
if (player.city != CityName.Aevum) {
|
||||
workerScript.log("gymWorkout", "You cannot workout at 'Crush Fitness' because you are not in 'Aevum'.");
|
||||
workerScript.log(
|
||||
"gymWorkout",
|
||||
() => "You cannot workout at 'Crush Fitness' because you are not in 'Aevum'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
player.location = LocationName.AevumCrushFitnessGym;
|
||||
@@ -369,7 +368,10 @@ export function NetscriptSingularity(
|
||||
break;
|
||||
case LocationName.AevumSnapFitnessGym.toLowerCase():
|
||||
if (player.city != CityName.Aevum) {
|
||||
workerScript.log("gymWorkout", "You cannot workout at 'Snap Fitness' because you are not in 'Aevum'.");
|
||||
workerScript.log(
|
||||
"gymWorkout",
|
||||
() => "You cannot workout at 'Snap Fitness' because you are not in 'Aevum'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
player.location = LocationName.AevumSnapFitnessGym;
|
||||
@@ -378,7 +380,10 @@ export function NetscriptSingularity(
|
||||
break;
|
||||
case LocationName.Sector12IronGym.toLowerCase():
|
||||
if (player.city != CityName.Sector12) {
|
||||
workerScript.log("gymWorkout", "You cannot workout at 'Iron Gym' because you are not in 'Sector-12'.");
|
||||
workerScript.log(
|
||||
"gymWorkout",
|
||||
() => "You cannot workout at 'Iron Gym' because you are not in 'Sector-12'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
player.location = LocationName.Sector12IronGym;
|
||||
@@ -389,7 +394,7 @@ export function NetscriptSingularity(
|
||||
if (player.city != CityName.Sector12) {
|
||||
workerScript.log(
|
||||
"gymWorkout",
|
||||
"You cannot workout at 'Powerhouse Gym' because you are not in 'Sector-12'.",
|
||||
() => "You cannot workout at 'Powerhouse Gym' because you are not in 'Sector-12'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -401,7 +406,7 @@ export function NetscriptSingularity(
|
||||
if (player.city != CityName.Volhaven) {
|
||||
workerScript.log(
|
||||
"gymWorkout",
|
||||
"You cannot workout at 'Millenium Fitness Gym' because you are not in 'Volhaven'.",
|
||||
() => "You cannot workout at 'Millenium Fitness Gym' because you are not in 'Volhaven'.",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -410,7 +415,7 @@ export function NetscriptSingularity(
|
||||
expMult = 4;
|
||||
break;
|
||||
default:
|
||||
workerScript.log("gymWorkout", `Invalid gym name: ${gymName}. gymWorkout() failed`);
|
||||
workerScript.log("gymWorkout", () => `Invalid gym name: ${gymName}. gymWorkout() failed`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -432,10 +437,10 @@ export function NetscriptSingularity(
|
||||
player.startClass(Router, costMult, expMult, CONSTANTS.ClassGymAgility);
|
||||
break;
|
||||
default:
|
||||
workerScript.log("gymWorkout", `Invalid stat: ${stat}.`);
|
||||
workerScript.log("gymWorkout", () => `Invalid stat: ${stat}.`);
|
||||
return false;
|
||||
}
|
||||
workerScript.log("gymWorkout", `Started training ${stat} at ${gymName}`);
|
||||
workerScript.log("gymWorkout", () => `Started training ${stat} at ${gymName}`);
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -455,11 +460,11 @@ export function NetscriptSingularity(
|
||||
}
|
||||
player.loseMoney(CONSTANTS.TravelCost, "other");
|
||||
player.city = cityname;
|
||||
workerScript.log("travelToCity", `Traveled to ${cityname}`);
|
||||
workerScript.log("travelToCity", () => `Traveled to ${cityname}`);
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50);
|
||||
return true;
|
||||
default:
|
||||
workerScript.log("travelToCity", `Invalid city name: '${cityname}'.`);
|
||||
workerScript.log("travelToCity", () => `Invalid city name: '${cityname}'.`);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@@ -469,12 +474,12 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("purchaseTor", 1);
|
||||
|
||||
if (player.hasTorRouter()) {
|
||||
workerScript.log("purchaseTor", "You already have a TOR router!");
|
||||
workerScript.log("purchaseTor", () => "You already have a TOR router!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.money < CONSTANTS.TorRouterCost) {
|
||||
workerScript.log("purchaseTor", "You cannot afford to purchase a Tor router.");
|
||||
workerScript.log("purchaseTor", () => "You cannot afford to purchase a Tor router.");
|
||||
return false;
|
||||
}
|
||||
player.loseMoney(CONSTANTS.TorRouterCost, "other");
|
||||
@@ -493,7 +498,7 @@ export function NetscriptSingularity(
|
||||
player.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
|
||||
darkweb.serversOnNetwork.push(player.getHomeComputer().hostname);
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.log("purchaseTor", "You have purchased a Tor router!");
|
||||
workerScript.log("purchaseTor", () => "You have purchased a Tor router!");
|
||||
return true;
|
||||
},
|
||||
purchaseProgram: function (programName: any): any {
|
||||
@@ -501,35 +506,28 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("purchaseProgram", 1);
|
||||
|
||||
if (!player.hasTorRouter()) {
|
||||
workerScript.log("purchaseProgram", "You do not have the TOR router.");
|
||||
workerScript.log("purchaseProgram", () => "You do not have the TOR router.");
|
||||
return false;
|
||||
}
|
||||
|
||||
programName = programName.toLowerCase();
|
||||
|
||||
let item = null;
|
||||
for (const key in DarkWebItems) {
|
||||
const i = DarkWebItems[key];
|
||||
if (i.program.toLowerCase() == programName) {
|
||||
item = i;
|
||||
}
|
||||
}
|
||||
|
||||
const item = Object.values(DarkWebItems).find((i) => i.program.toLowerCase() === programName);
|
||||
if (item == null) {
|
||||
workerScript.log("purchaseProgram", `Invalid program name: '${programName}.`);
|
||||
workerScript.log("purchaseProgram", () => `Invalid program name: '${programName}.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.money < item.price) {
|
||||
workerScript.log(
|
||||
"purchaseProgram",
|
||||
`Not enough money to purchase '${item.program}'. Need ${numeralWrapper.formatMoney(item.price)}`,
|
||||
() => `Not enough money to purchase '${item.program}'. Need ${numeralWrapper.formatMoney(item.price)}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.hasProgram(item.program)) {
|
||||
workerScript.log("purchaseProgram", `You already have the '${item.program}' program`);
|
||||
workerScript.log("purchaseProgram", () => `You already have the '${item.program}' program`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -537,7 +535,7 @@ export function NetscriptSingularity(
|
||||
player.getHomeComputer().programs.push(item.program);
|
||||
workerScript.log(
|
||||
"purchaseProgram",
|
||||
`You have purchased the '${item.program}' program. The new program can be found on your home computer.`,
|
||||
() => `You have purchased the '${item.program}' program. The new program can be found on your home computer.`,
|
||||
);
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50);
|
||||
return true;
|
||||
@@ -593,7 +591,7 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("installBackdoor", 1);
|
||||
const baseserver = player.getCurrentServer();
|
||||
if (!(baseserver instanceof Server)) {
|
||||
workerScript.log("installBackdoor", "cannot backdoor this kind of server");
|
||||
workerScript.log("installBackdoor", () => "cannot backdoor this kind of server");
|
||||
return Promise.resolve();
|
||||
}
|
||||
const server = baseserver as Server;
|
||||
@@ -607,14 +605,14 @@ export function NetscriptSingularity(
|
||||
|
||||
workerScript.log(
|
||||
"installBackdoor",
|
||||
`Installing backdoor on '${server.hostname}' in ${convertTimeMsToTimeElapsedString(installTime, true)}`,
|
||||
() => `Installing backdoor on '${server.hostname}' in ${convertTimeMsToTimeElapsedString(installTime, true)}`,
|
||||
);
|
||||
|
||||
return netscriptDelay(installTime, workerScript).then(function () {
|
||||
if (workerScript.env.stopFlag) {
|
||||
return Promise.reject(workerScript);
|
||||
}
|
||||
workerScript.log("installBackdoor", `Successfully installed backdoor on '${server.hostname}'`);
|
||||
workerScript.log("installBackdoor", () => `Successfully installed backdoor on '${server.hostname}'`);
|
||||
|
||||
server.backdoorInstalled = true;
|
||||
|
||||
@@ -627,7 +625,7 @@ export function NetscriptSingularity(
|
||||
getStats: function (): any {
|
||||
helper.updateDynamicRam("getStats", getRamCost("getStats"));
|
||||
helper.checkSingularityAccess("getStats", 1);
|
||||
workerScript.log("getStats", `getStats is deprecated, please use getplayer`);
|
||||
workerScript.log("getStats", () => `getStats is deprecated, please use getplayer`);
|
||||
|
||||
return {
|
||||
hacking: player.hacking,
|
||||
@@ -642,7 +640,7 @@ export function NetscriptSingularity(
|
||||
getCharacterInformation: function (): any {
|
||||
helper.updateDynamicRam("getCharacterInformation", getRamCost("getCharacterInformation"));
|
||||
helper.checkSingularityAccess("getCharacterInformation", 1);
|
||||
workerScript.log("getCharacterInformation", `getCharacterInformation is deprecated, please use getplayer`);
|
||||
workerScript.log("getCharacterInformation", () => `getCharacterInformation is deprecated, please use getplayer`);
|
||||
|
||||
return {
|
||||
bitnode: player.bitNodeN,
|
||||
@@ -691,7 +689,7 @@ export function NetscriptSingularity(
|
||||
helper.updateDynamicRam("hospitalize", getRamCost("hospitalize"));
|
||||
helper.checkSingularityAccess("hospitalize", 1);
|
||||
if (player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
|
||||
workerScript.log("hospitalize", "Cannot go to the hospital because the player is busy.");
|
||||
workerScript.log("hospitalize", () => "Cannot go to the hospital because the player is busy.");
|
||||
return;
|
||||
}
|
||||
return player.hospitalize();
|
||||
@@ -707,7 +705,7 @@ export function NetscriptSingularity(
|
||||
if (player.isWorking) {
|
||||
Router.toTerminal();
|
||||
const txt = player.singularityStopWork();
|
||||
workerScript.log("stopAction", txt);
|
||||
workerScript.log("stopAction", () => txt);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -719,13 +717,16 @@ export function NetscriptSingularity(
|
||||
// Check if we're at max cores
|
||||
const homeComputer = player.getHomeComputer();
|
||||
if (homeComputer.cpuCores >= 8) {
|
||||
workerScript.log("upgradeHomeCores", `Your home computer is at max cores.`);
|
||||
workerScript.log("upgradeHomeCores", () => `Your home computer is at max cores.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const cost = player.getUpgradeHomeCoresCost();
|
||||
if (player.money < cost) {
|
||||
workerScript.log("upgradeHomeCores", `You don't have enough money. Need ${numeralWrapper.formatMoney(cost)}`);
|
||||
workerScript.log(
|
||||
"upgradeHomeCores",
|
||||
() => `You don't have enough money. Need ${numeralWrapper.formatMoney(cost)}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -735,7 +736,7 @@ export function NetscriptSingularity(
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.log(
|
||||
"upgradeHomeCores",
|
||||
`Purchased an additional core for home computer! It now has ${homeComputer.cpuCores} cores.`,
|
||||
() => `Purchased an additional core for home computer! It now has ${homeComputer.cpuCores} cores.`,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
@@ -752,13 +753,16 @@ export function NetscriptSingularity(
|
||||
// Check if we're at max RAM
|
||||
const homeComputer = player.getHomeComputer();
|
||||
if (homeComputer.maxRam >= CONSTANTS.HomeComputerMaxRam) {
|
||||
workerScript.log("upgradeHomeRam", `Your home computer is at max RAM.`);
|
||||
workerScript.log("upgradeHomeRam", () => `Your home computer is at max RAM.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const cost = player.getUpgradeHomeRamCost();
|
||||
if (player.money < cost) {
|
||||
workerScript.log("upgradeHomeRam", `You don't have enough money. Need ${numeralWrapper.formatMoney(cost)}`);
|
||||
workerScript.log(
|
||||
"upgradeHomeRam",
|
||||
() => `You don't have enough money. Need ${numeralWrapper.formatMoney(cost)}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -768,9 +772,10 @@ export function NetscriptSingularity(
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.log(
|
||||
"upgradeHomeRam",
|
||||
`Purchased additional RAM for home computer! It now has ${numeralWrapper.formatRAM(
|
||||
homeComputer.maxRam,
|
||||
)} of RAM.`,
|
||||
() =>
|
||||
`Purchased additional RAM for home computer! It now has ${numeralWrapper.formatRAM(
|
||||
homeComputer.maxRam,
|
||||
)} of RAM.`,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
@@ -791,13 +796,13 @@ export function NetscriptSingularity(
|
||||
|
||||
// Make sure its a valid company
|
||||
if (companyName == null || companyName === "" || !(Companies[companyName] instanceof Company)) {
|
||||
workerScript.log("workForCompany", `Invalid company: '${companyName}'`);
|
||||
workerScript.log("workForCompany", () => `Invalid company: '${companyName}'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure player is actually employed at the comapny
|
||||
if (!Object.keys(player.jobs).includes(companyName)) {
|
||||
workerScript.log("workForCompany", `You do not have a job at '${companyName}'`);
|
||||
workerScript.log("workForCompany", () => `You do not have a job at '${companyName}'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -805,13 +810,13 @@ export function NetscriptSingularity(
|
||||
const companyPositionName = player.jobs[companyName];
|
||||
const companyPosition = CompanyPositions[companyPositionName];
|
||||
if (companyPositionName === "" || !(companyPosition instanceof CompanyPosition)) {
|
||||
workerScript.log("workForCompany", "You do not have a job");
|
||||
workerScript.log("workForCompany", () => "You do not have a job");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isWorking) {
|
||||
const txt = player.singularityStopWork();
|
||||
workerScript.log("workForCompany", txt);
|
||||
workerScript.log("workForCompany", () => txt);
|
||||
}
|
||||
|
||||
if (companyPosition.isPartTimeJob()) {
|
||||
@@ -819,7 +824,10 @@ export function NetscriptSingularity(
|
||||
} else {
|
||||
player.startWork(Router, companyName);
|
||||
}
|
||||
workerScript.log("workForCompany", `Began working at '${player.companyName}' as a '${companyPositionName}'`);
|
||||
workerScript.log(
|
||||
"workForCompany",
|
||||
() => `Began working at '${player.companyName}' as a '${companyPositionName}'`,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
applyToCompany: function (companyName: any, field: any): any {
|
||||
@@ -870,24 +878,24 @@ export function NetscriptSingularity(
|
||||
res = player.applyForPartTimeWaiterJob(true);
|
||||
break;
|
||||
default:
|
||||
workerScript.log("applyToCompany", `Invalid job: '${field}'.`);
|
||||
workerScript.log("applyToCompany", () => `Invalid job: '${field}'.`);
|
||||
return false;
|
||||
}
|
||||
// TODO https://github.com/danielyxie/bitburner/issues/1378
|
||||
// The player object's applyForJob function can return string with special error messages
|
||||
// if (isString(res)) {
|
||||
// workerScript.log("applyToCompany", res);
|
||||
// workerScript.log("applyToCompany",()=> res);
|
||||
// return false;
|
||||
// }
|
||||
if (res) {
|
||||
workerScript.log(
|
||||
"applyToCompany",
|
||||
`You were offered a new job at '${companyName}' as a '${player.jobs[companyName]}'`,
|
||||
() => `You were offered a new job at '${companyName}' as a '${player.jobs[companyName]}'`,
|
||||
);
|
||||
} else {
|
||||
workerScript.log(
|
||||
"applyToCompany",
|
||||
`You failed to get a new job/promotion at '${companyName}' in the '${field}' field.`,
|
||||
() => `You failed to get a new job/promotion at '${companyName}' in the '${field}' field.`,
|
||||
);
|
||||
}
|
||||
return res;
|
||||
@@ -922,7 +930,7 @@ export function NetscriptSingularity(
|
||||
getFaction("joinFaction", name);
|
||||
|
||||
if (!player.factionInvitations.includes(name)) {
|
||||
workerScript.log("joinFaction", `You have not been invited by faction '${name}'`);
|
||||
workerScript.log("joinFaction", () => `You have not been invited by faction '${name}'`);
|
||||
return false;
|
||||
}
|
||||
const fac = Factions[name];
|
||||
@@ -936,7 +944,7 @@ export function NetscriptSingularity(
|
||||
}
|
||||
}
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.log("joinFaction", `Joined the '${name}' faction.`);
|
||||
workerScript.log("joinFaction", () => `Joined the '${name}' faction.`);
|
||||
return true;
|
||||
},
|
||||
workForFaction: function (name: any, type: any): any {
|
||||
@@ -946,18 +954,18 @@ export function NetscriptSingularity(
|
||||
|
||||
// if the player is in a gang and the target faction is any of the gang faction, fail
|
||||
if (player.inGang() && AllGangs[name] !== undefined) {
|
||||
workerScript.log("workForFaction", `Faction '${name}' does not offer work at the moment.`);
|
||||
return;
|
||||
workerScript.log("workForFaction", () => `Faction '${name}' does not offer work at the moment.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.factions.includes(name)) {
|
||||
workerScript.log("workForFaction", `You are not a member of '${name}'`);
|
||||
workerScript.log("workForFaction", () => `You are not a member of '${name}'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isWorking) {
|
||||
const txt = player.singularityStopWork();
|
||||
workerScript.log("workForFaction", txt);
|
||||
workerScript.log("workForFaction", () => txt);
|
||||
}
|
||||
|
||||
const fac = Factions[name];
|
||||
@@ -1049,34 +1057,34 @@ export function NetscriptSingularity(
|
||||
case "hacking contracts":
|
||||
case "hackingcontracts":
|
||||
if (!hackAvailable.includes(fac.name)) {
|
||||
workerScript.log("workForFaction", `Faction '${fac.name}' do not need help with hacking contracts.`);
|
||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with hacking contracts.`);
|
||||
return false;
|
||||
}
|
||||
player.startFactionHackWork(Router, fac);
|
||||
workerScript.log("workForFaction", `Started carrying out hacking contracts for '${fac.name}'`);
|
||||
workerScript.log("workForFaction", () => `Started carrying out hacking contracts for '${fac.name}'`);
|
||||
return true;
|
||||
case "field":
|
||||
case "fieldwork":
|
||||
case "field work":
|
||||
if (!fdWkAvailable.includes(fac.name)) {
|
||||
workerScript.log("workForFaction", `Faction '${fac.name}' do not need help with field missions.`);
|
||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with field missions.`);
|
||||
return false;
|
||||
}
|
||||
player.startFactionFieldWork(Router, fac);
|
||||
workerScript.log("workForFaction", `Started carrying out field missions for '${fac.name}'`);
|
||||
workerScript.log("workForFaction", () => `Started carrying out field missions for '${fac.name}'`);
|
||||
return true;
|
||||
case "security":
|
||||
case "securitywork":
|
||||
case "security work":
|
||||
if (!scWkAvailable.includes(fac.name)) {
|
||||
workerScript.log("workForFaction", `Faction '${fac.name}' do not need help with security work.`);
|
||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with security work.`);
|
||||
return false;
|
||||
}
|
||||
player.startFactionSecurityWork(Router, fac);
|
||||
workerScript.log("workForFaction", `Started carrying out security work for '${fac.name}'`);
|
||||
workerScript.log("workForFaction", () => `Started carrying out security work for '${fac.name}'`);
|
||||
return true;
|
||||
default:
|
||||
workerScript.log("workForFaction", `Invalid work type: '${type}`);
|
||||
workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -1104,13 +1112,13 @@ export function NetscriptSingularity(
|
||||
const faction = getFaction("donateToFaction", name);
|
||||
|
||||
if (typeof amt !== "number" || amt <= 0) {
|
||||
workerScript.log("donateToFaction", `Invalid donation amount: '${amt}'.`);
|
||||
workerScript.log("donateToFaction", () => `Invalid donation amount: '${amt}'.`);
|
||||
return false;
|
||||
}
|
||||
if (player.money < amt) {
|
||||
workerScript.log(
|
||||
"donateToFaction",
|
||||
`You do not have enough money to donate ${numeralWrapper.formatMoney(amt)} to '${name}'`,
|
||||
() => `You do not have enough money to donate ${numeralWrapper.formatMoney(amt)} to '${name}'`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -1118,7 +1126,8 @@ export function NetscriptSingularity(
|
||||
if (faction.favor < repNeededToDonate) {
|
||||
workerScript.log(
|
||||
"donateToFaction",
|
||||
`You do not have enough favor to donate to this faction. Have ${faction.favor}, need ${repNeededToDonate}`,
|
||||
() =>
|
||||
`You do not have enough favor to donate to this faction. Have ${faction.favor}, need ${repNeededToDonate}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -1127,9 +1136,10 @@ export function NetscriptSingularity(
|
||||
player.loseMoney(amt, "other");
|
||||
workerScript.log(
|
||||
"donateToFaction",
|
||||
`${numeralWrapper.formatMoney(amt)} donated to '${name}' for ${numeralWrapper.formatReputation(
|
||||
repGain,
|
||||
)} reputation`,
|
||||
() =>
|
||||
`${numeralWrapper.formatMoney(amt)} donated to '${name}' for ${numeralWrapper.formatReputation(
|
||||
repGain,
|
||||
)} reputation`,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
@@ -1139,41 +1149,39 @@ export function NetscriptSingularity(
|
||||
|
||||
if (player.isWorking) {
|
||||
const txt = player.singularityStopWork();
|
||||
workerScript.log("createProgram", txt);
|
||||
workerScript.log("createProgram", () => txt);
|
||||
}
|
||||
|
||||
name = name.toLowerCase();
|
||||
|
||||
let p = null;
|
||||
for (const key in Programs) {
|
||||
if (Programs[key].name.toLowerCase() == name) {
|
||||
p = Programs[key];
|
||||
}
|
||||
}
|
||||
const p = Object.values(Programs).find((p) => p.name.toLowerCase() === name);
|
||||
|
||||
if (p == null) {
|
||||
workerScript.log("createProgram", `The specified program does not exist: '${name}`);
|
||||
workerScript.log("createProgram", () => `The specified program does not exist: '${name}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.hasProgram(p.name)) {
|
||||
workerScript.log("createProgram", `You already have the '${p.name}' program`);
|
||||
workerScript.log("createProgram", () => `You already have the '${p.name}' program`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const create = p.create;
|
||||
if (create === null) {
|
||||
workerScript.log("createProgram", `You cannot create the '${p.name}' program`);
|
||||
workerScript.log("createProgram", () => `You cannot create the '${p.name}' program`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!create.req(player)) {
|
||||
workerScript.log("createProgram", `Hacking level is too low to create '${p.name}' (level ${create.level} req)`);
|
||||
workerScript.log(
|
||||
"createProgram",
|
||||
() => `Hacking level is too low to create '${p.name}' (level ${create.level} req)`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
player.startCreateProgramWork(Router, p.name, create.time, create.level);
|
||||
workerScript.log("createProgram", `Began creating program: '${name}'`);
|
||||
workerScript.log("createProgram", () => `Began creating program: '${name}'`);
|
||||
return true;
|
||||
},
|
||||
commitCrime: function (crimeRoughName: any): any {
|
||||
@@ -1182,7 +1190,7 @@ export function NetscriptSingularity(
|
||||
|
||||
if (player.isWorking) {
|
||||
const txt = player.singularityStopWork();
|
||||
workerScript.log("commitCrime", txt);
|
||||
workerScript.log("commitCrime", () => txt);
|
||||
}
|
||||
|
||||
// Set Location to slums
|
||||
@@ -1193,7 +1201,7 @@ export function NetscriptSingularity(
|
||||
// couldn't find crime
|
||||
throw helper.makeRuntimeErrorMsg("commitCrime", `Invalid crime: '${crimeRoughName}'`);
|
||||
}
|
||||
workerScript.log("commitCrime", `Attempting to commit ${crime.name}...`);
|
||||
workerScript.log("commitCrime", () => `Attempting to commit ${crime.name}...`);
|
||||
return crime.commit(Router, player, 1, workerScript);
|
||||
},
|
||||
getCrimeChance: function (crimeRoughName: any): any {
|
||||
@@ -1218,5 +1226,19 @@ export function NetscriptSingularity(
|
||||
|
||||
return Object.assign({}, crime);
|
||||
},
|
||||
isFocused: function (): boolean {
|
||||
helper.updateDynamicRam("isFocused", getRamCost("isFocused"));
|
||||
helper.checkSingularityAccess("isFocused", 2);
|
||||
return player.focus;
|
||||
},
|
||||
setFocus: function (focus: any): void {
|
||||
helper.updateDynamicRam("setFocus", getRamCost("setFocus"));
|
||||
helper.checkSingularityAccess("setFocus", 2);
|
||||
if (focus === true) {
|
||||
player.startFocusing();
|
||||
} else if (focus === false) {
|
||||
player.stopFocusing();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
const checkSleeveNumber = function (func: any, sleeveNumber: any): void {
|
||||
if (sleeveNumber >= player.sleeves.length || sleeveNumber < 0) {
|
||||
const msg = `Invalid sleeve number: ${sleeveNumber}`;
|
||||
workerScript.log(func, msg);
|
||||
workerScript.log(func, () => msg);
|
||||
throw helper.makeRuntimeErrorMsg(`sleeve.${func}`, msg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,20 +42,20 @@ export function NetscriptStanek(player: IPlayer, workerScript: WorkerScript, hel
|
||||
return Promise.reject(workerScript);
|
||||
}
|
||||
const charge = staneksGift.charge(player, fragment, workerScript.scriptRef.threads);
|
||||
workerScript.log("stanek.charge", `Charged fragment for ${charge} charge.`);
|
||||
workerScript.log("stanek.charge", () => `Charged fragment for ${charge} charge.`);
|
||||
return Promise.resolve();
|
||||
});
|
||||
},
|
||||
fragmentDefinitions: function (): IFragment[] {
|
||||
helper.updateDynamicRam("fragmentDefinitions", getRamCost("stanek", "fragmentDefinitions"));
|
||||
checkStanekAPIAccess("fragmentDefinitions");
|
||||
workerScript.log("stanek.fragmentDefinitions", `Returned ${Fragments.length} fragments`);
|
||||
workerScript.log("stanek.fragmentDefinitions", () => `Returned ${Fragments.length} fragments`);
|
||||
return Fragments.map((f) => f.copy());
|
||||
},
|
||||
activeFragments: function (): IActiveFragment[] {
|
||||
helper.updateDynamicRam("activeFragments", getRamCost("stanek", "activeFragments"));
|
||||
checkStanekAPIAccess("activeFragments");
|
||||
workerScript.log("stanek.activeFragments", `Returned ${staneksGift.fragments.length} fragments`);
|
||||
workerScript.log("stanek.activeFragments", () => `Returned ${staneksGift.fragments.length} fragments`);
|
||||
return staneksGift.fragments.map((af) => {
|
||||
return { ...af.copy(), ...af.fragment().copy() };
|
||||
});
|
||||
@@ -63,7 +63,7 @@ export function NetscriptStanek(player: IPlayer, workerScript: WorkerScript, hel
|
||||
clear: function (): void {
|
||||
helper.updateDynamicRam("clear", getRamCost("stanek", "clear"));
|
||||
checkStanekAPIAccess("clear");
|
||||
workerScript.log("stanek.clear", `Cleared Stanek's Gift.`);
|
||||
workerScript.log("stanek.clear", () => `Cleared Stanek's Gift.`);
|
||||
staneksGift.clear();
|
||||
},
|
||||
canPlace: function (arootX: any, arootY: any, arotation: any, afragmentId: any): boolean {
|
||||
|
||||
@@ -151,7 +151,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
|
||||
const stock = getStockFromSymbol(symbol, "short");
|
||||
const res = shortStock(stock, shares, workerScript, {});
|
||||
|
||||
return res ? stock.price : 0;
|
||||
return res ? stock.getBidPrice() : 0;
|
||||
},
|
||||
sellShort: function (symbol: any, shares: any): any {
|
||||
helper.updateDynamicRam("sellShort", getRamCost("stock", "sellShort"));
|
||||
@@ -167,7 +167,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
|
||||
const stock = getStockFromSymbol(symbol, "sellShort");
|
||||
const res = sellShort(stock, shares, workerScript, {});
|
||||
|
||||
return res ? stock.price : 0;
|
||||
return res ? stock.getAskPrice() : 0;
|
||||
},
|
||||
placeOrder: function (symbol: any, shares: any, price: any, type: any, pos: any): any {
|
||||
helper.updateDynamicRam("placeOrder", getRamCost("stock", "placeOrder"));
|
||||
@@ -315,18 +315,18 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
|
||||
checkTixApiAccess("purchase4SMarketData");
|
||||
|
||||
if (player.has4SData) {
|
||||
workerScript.log("purchase4SMarketData", "Already purchased 4S Market Data.");
|
||||
workerScript.log("stock.purchase4SMarketData", () => "Already purchased 4S Market Data.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.money < getStockMarket4SDataCost()) {
|
||||
workerScript.log("purchase4SMarketData", "Not enough money to purchase 4S Market Data.");
|
||||
workerScript.log("stock.purchase4SMarketData", () => "Not enough money to purchase 4S Market Data.");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.has4SData = true;
|
||||
player.loseMoney(getStockMarket4SDataCost(), "stock");
|
||||
workerScript.log("purchase4SMarketData", "Purchased 4S Market Data");
|
||||
workerScript.log("stock.purchase4SMarketData", () => "Purchased 4S Market Data");
|
||||
return true;
|
||||
},
|
||||
purchase4SMarketDataTixApi: function () {
|
||||
@@ -334,18 +334,21 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
|
||||
checkTixApiAccess("purchase4SMarketDataTixApi");
|
||||
|
||||
if (player.has4SDataTixApi) {
|
||||
workerScript.log("purchase4SMarketDataTixApi", "Already purchased 4S Market Data TIX API");
|
||||
workerScript.log("stock.purchase4SMarketDataTixApi", () => "Already purchased 4S Market Data TIX API");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.money < getStockMarket4STixApiCost()) {
|
||||
workerScript.log("purchase4SMarketDataTixApi", "Not enough money to purchase 4S Market Data TIX API");
|
||||
workerScript.log(
|
||||
"stock.purchase4SMarketDataTixApi",
|
||||
() => "Not enough money to purchase 4S Market Data TIX API",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
player.has4SDataTixApi = true;
|
||||
player.loseMoney(getStockMarket4STixApiCost(), "stock");
|
||||
workerScript.log("purchase4SMarketDataTixApi", "Purchased 4S Market Data TIX API");
|
||||
workerScript.log("stock.purchase4SMarketDataTixApi", () => "Purchased 4S Market Data TIX API");
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user