mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
merge base
This commit is contained in:
@@ -59,17 +59,20 @@ export function NetscriptExtra(player: IPlayer, workerScript: WorkerScript, help
|
||||
player.giveExploit(Exploit.RealityAlteration);
|
||||
}
|
||||
},
|
||||
rainbow: function (guess: unknown): void {
|
||||
async function tryGuess(): Promise<void> {
|
||||
const verified = await bcrypt.compare(
|
||||
rainbow: function (guess: unknown): boolean {
|
||||
function tryGuess(): boolean {
|
||||
// eslint-disable-next-line no-sync
|
||||
const verified = bcrypt.compareSync(
|
||||
helper.string("rainbow", "guess", guess),
|
||||
"$2a$10$aertxDEkgor8baVtQDZsLuMwwGYmkRM/ohcA6FjmmzIHQeTCsrCcO",
|
||||
);
|
||||
if (verified) {
|
||||
player.giveExploit(Exploit.INeedARainbow);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
tryGuess();
|
||||
return tryGuess();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
calculateAscensionPointsGain,
|
||||
} from "../Gang/formulas/formulas";
|
||||
import { favorToRep as calculateFavorToRep, repToFavor as calculateRepToFavor } from "../Faction/formulas/favor";
|
||||
import { repFromDonation } from "../Faction/formulas/donation";
|
||||
|
||||
export function NetscriptFormulas(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): IFormulas {
|
||||
const checkFormulasAccess = function (func: string): void {
|
||||
@@ -57,6 +58,11 @@ export function NetscriptFormulas(player: IPlayer, workerScript: WorkerScript, h
|
||||
checkFormulasAccess("reputation.calculateRepToFavor");
|
||||
return calculateRepToFavor(rep);
|
||||
},
|
||||
repFromDonation: function (_amount: unknown, player: any): number {
|
||||
const amount = helper.number("repFromDonation", "amount", _amount);
|
||||
checkFormulasAccess("reputation.repFromDonation");
|
||||
return repFromDonation(amount, player);
|
||||
},
|
||||
},
|
||||
skills: {
|
||||
calculateSkill: function (_exp: unknown, _mult: unknown = 1): number {
|
||||
|
||||
@@ -23,7 +23,6 @@ import { findCrime } from "../Crime/CrimeHelpers";
|
||||
import { CompanyPosition } from "../Company/CompanyPosition";
|
||||
import { CompanyPositions } from "../Company/CompanyPositions";
|
||||
import { DarkWebItems } from "../DarkWeb/DarkWebItems";
|
||||
import { AllGangs } from "../Gang/AllGangs";
|
||||
import { CityName } from "../Locations/data/CityNames";
|
||||
import { LocationName } from "../Locations/data/LocationNames";
|
||||
import { Router } from "../ui/GameRoot";
|
||||
@@ -49,6 +48,7 @@ import { FactionInfos } from "../Faction/FactionInfo";
|
||||
import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper";
|
||||
import { BlackOperationNames } from "../Bladeburner/data/BlackOperationNames";
|
||||
import { enterBitNode } from "../RedPill";
|
||||
import { FactionNames } from "../Faction/data/FactionNames";
|
||||
|
||||
export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript): InternalAPI<ISingularity> {
|
||||
const getAugmentation = function (_ctx: NetscriptContext, name: string): Augmentation {
|
||||
@@ -1047,11 +1047,14 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
||||
const facName = _ctx.helper.string("facName", _facName);
|
||||
const type = _ctx.helper.string("type", _type);
|
||||
const focus = _ctx.helper.boolean(_focus);
|
||||
getFaction(_ctx, facName);
|
||||
const faction = getFaction(_ctx, facName);
|
||||
|
||||
// if the player is in a gang and the target faction is any of the gang faction, fail
|
||||
if (player.inGang() && AllGangs[facName] !== undefined) {
|
||||
workerScript.log("workForFaction", () => `Faction '${facName}' does not offer work at the moment.`);
|
||||
if (player.inGang() && faction.name === player.getGangFaction().name) {
|
||||
workerScript.log(
|
||||
"workForFaction",
|
||||
() => `You can't work for '${facName}' because youre managing a gang for it`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1066,21 +1069,18 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
||||
workerScript.log("workForFaction", () => txt);
|
||||
}
|
||||
|
||||
const fac = Factions[facName];
|
||||
// Arrays listing factions that allow each time of work
|
||||
|
||||
switch (type.toLowerCase()) {
|
||||
case "hacking":
|
||||
case "hacking contracts":
|
||||
case "hackingcontracts":
|
||||
if (!FactionInfos[fac.name].offerHackingWork) {
|
||||
if (!FactionInfos[faction.name].offerHackingWork) {
|
||||
workerScript.log(
|
||||
"workForFaction",
|
||||
() => `Faction '${fac.name}' do not need help with hacking contracts.`,
|
||||
() => `Faction '${faction.name}' do not need help with hacking contracts.`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
player.startFactionHackWork(fac);
|
||||
player.startFactionHackWork(faction);
|
||||
if (focus) {
|
||||
player.startFocusing();
|
||||
Router.toWork();
|
||||
@@ -1088,16 +1088,19 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
||||
player.stopFocusing();
|
||||
Router.toTerminal();
|
||||
}
|
||||
workerScript.log("workForFaction", () => `Started carrying out hacking contracts for '${fac.name}'`);
|
||||
workerScript.log("workForFaction", () => `Started carrying out hacking contracts for '${faction.name}'`);
|
||||
return true;
|
||||
case "field":
|
||||
case "fieldwork":
|
||||
case "field work":
|
||||
if (!FactionInfos[fac.name].offerFieldWork) {
|
||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with field missions.`);
|
||||
if (!FactionInfos[faction.name].offerFieldWork) {
|
||||
workerScript.log(
|
||||
"workForFaction",
|
||||
() => `Faction '${faction.name}' do not need help with field missions.`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
player.startFactionFieldWork(fac);
|
||||
player.startFactionFieldWork(faction);
|
||||
if (focus) {
|
||||
player.startFocusing();
|
||||
Router.toWork();
|
||||
@@ -1105,16 +1108,19 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
||||
player.stopFocusing();
|
||||
Router.toTerminal();
|
||||
}
|
||||
workerScript.log("workForFaction", () => `Started carrying out field missions for '${fac.name}'`);
|
||||
workerScript.log("workForFaction", () => `Started carrying out field missions for '${faction.name}'`);
|
||||
return true;
|
||||
case "security":
|
||||
case "securitywork":
|
||||
case "security work":
|
||||
if (!FactionInfos[fac.name].offerSecurityWork) {
|
||||
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with security work.`);
|
||||
if (!FactionInfos[faction.name].offerSecurityWork) {
|
||||
workerScript.log(
|
||||
"workForFaction",
|
||||
() => `Faction '${faction.name}' do not need help with security work.`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
player.startFactionSecurityWork(fac);
|
||||
player.startFactionSecurityWork(faction);
|
||||
if (focus) {
|
||||
player.startFocusing();
|
||||
Router.toWork();
|
||||
@@ -1122,7 +1128,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
||||
player.stopFocusing();
|
||||
Router.toTerminal();
|
||||
}
|
||||
workerScript.log("workForFaction", () => `Started carrying out security work for '${fac.name}'`);
|
||||
workerScript.log("workForFaction", () => `Started carrying out security work for '${faction.name}'`);
|
||||
return true;
|
||||
default:
|
||||
workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
|
||||
@@ -1168,6 +1174,13 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (faction.name === FactionNames.ChurchOfTheMachineGod || faction.name === FactionNames.Bladeburners) {
|
||||
workerScript.log(
|
||||
"donateToFaction",
|
||||
() => `You can't donate to '${facName}' because they do not accept donations`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (typeof amt !== "number" || amt <= 0 || isNaN(amt)) {
|
||||
workerScript.log("donateToFaction", () => `Invalid donation amount: '${amt}'.`);
|
||||
return false;
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
SleeveSkills,
|
||||
SleeveTask,
|
||||
} from "../ScriptEditor/NetscriptDefinitions";
|
||||
import { checkEnum } from "../utils/helpers/checkEnum";
|
||||
|
||||
export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): ISleeve {
|
||||
const checkSleeveAPIAccess = function (func: string): void {
|
||||
@@ -99,7 +100,11 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
const cityName = helper.string("travel", "cityName", _cityName);
|
||||
checkSleeveAPIAccess("travel");
|
||||
checkSleeveNumber("travel", sleeveNumber);
|
||||
return player.sleeves[sleeveNumber].travel(player, cityName as CityName);
|
||||
if (checkEnum(CityName, cityName)) {
|
||||
return player.sleeves[sleeveNumber].travel(player, cityName);
|
||||
} else {
|
||||
throw helper.makeRuntimeErrorMsg("sleeve.setToCompanyWork", `Invalid city name: '${cityName}'.`);
|
||||
}
|
||||
},
|
||||
setToCompanyWork: function (_sleeveNumber: unknown, acompanyName: unknown): boolean {
|
||||
updateRam("setToCompanyWork");
|
||||
|
||||
Reference in New Issue
Block a user