mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
commit
ddf0ee6d0c
42
dist/vendor.bundle.js
vendored
42
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/vendor.bundle.js.map
vendored
2
dist/vendor.bundle.js.map
vendored
File diff suppressed because one or more lines are too long
@ -15,6 +15,7 @@ const debug = process.argv.includes("--debug");
|
||||
|
||||
async function createWindow(killall) {
|
||||
const setStopProcessHandler = global.app_handlers.stopProcess;
|
||||
app.setAppUserModelId("Bitburner")
|
||||
|
||||
let icon;
|
||||
if (process.platform == 'linux') {
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -94,7 +94,7 @@ function getRandomBonus(): any {
|
||||
return bonuses[Math.floor(bonuses.length * randomNumber.random())];
|
||||
}
|
||||
|
||||
export const generalAugmentations = [
|
||||
export const initGeneralAugmentations = (): Augmentation[] => [
|
||||
new Augmentation({
|
||||
name: AugmentationNames.HemoRecirculator,
|
||||
moneyCost: 4.5e7,
|
||||
@ -1486,7 +1486,7 @@ export const generalAugmentations = [
|
||||
}),
|
||||
];
|
||||
|
||||
export const bladeburnerAugmentations = [
|
||||
export const initBladeburnerAugmentations = (): Augmentation[] => [
|
||||
new Augmentation({
|
||||
name: AugmentationNames.EsperEyewear,
|
||||
repCost: 1.25e3,
|
||||
@ -1751,7 +1751,7 @@ export const bladeburnerAugmentations = [
|
||||
}),
|
||||
];
|
||||
|
||||
export const churchOfTheMachineGodAugmentations = [
|
||||
export const initChurchOfTheMachineGodAugmentations = (): Augmentation[] => [
|
||||
new Augmentation({
|
||||
name: AugmentationNames.StaneksGift1,
|
||||
repCost: 0,
|
||||
|
@ -15,9 +15,9 @@ import { clearObject } from "../utils/helpers/clearObject";
|
||||
|
||||
import { FactionNames } from "../Faction/data/FactionNames";
|
||||
import {
|
||||
bladeburnerAugmentations,
|
||||
churchOfTheMachineGodAugmentations,
|
||||
generalAugmentations,
|
||||
initBladeburnerAugmentations,
|
||||
initChurchOfTheMachineGodAugmentations,
|
||||
initGeneralAugmentations,
|
||||
initNeuroFluxGovernor,
|
||||
initUnstableCircadianModulator,
|
||||
} from "./AugmentationCreator";
|
||||
@ -49,9 +49,9 @@ function createAugmentations(): void {
|
||||
[
|
||||
initNeuroFluxGovernor(),
|
||||
initUnstableCircadianModulator(),
|
||||
...generalAugmentations,
|
||||
...(factionExists(FactionNames.Bladeburners) ? bladeburnerAugmentations : []),
|
||||
...(factionExists(FactionNames.ChurchOfTheMachineGod) ? churchOfTheMachineGodAugmentations : []),
|
||||
...initGeneralAugmentations(),
|
||||
...(factionExists(FactionNames.Bladeburners) ? initBladeburnerAugmentations() : []),
|
||||
...(factionExists(FactionNames.ChurchOfTheMachineGod) ? initChurchOfTheMachineGodAugmentations() : []),
|
||||
].map(resetAugmentation);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ import { Employee } from "./Employee";
|
||||
import { IndustryUpgrades } from "./IndustryUpgrades";
|
||||
import { ResearchMap } from "./ResearchMap";
|
||||
import { isRelevantMaterial } from "./ui/Helpers";
|
||||
import { CityName } from "src/Locations/data/CityNames";
|
||||
|
||||
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
||||
if (corporation.divisions.find(({ type }) => industry == type))
|
||||
|
@ -61,7 +61,7 @@ export function Effect(tpe: FragmentType): string {
|
||||
return "+x% hacknet production";
|
||||
}
|
||||
case FragmentType.HacknetCost: {
|
||||
return "x% cheaper hacknet cost";
|
||||
return "-x% cheaper hacknet cost";
|
||||
}
|
||||
case FragmentType.Rep: {
|
||||
return "+x% reputation from factions and companies";
|
||||
|
@ -54,8 +54,12 @@ export function FragmentInspector(props: IProps): React.ReactElement {
|
||||
if ([FragmentType.Booster, FragmentType.None, FragmentType.Delete].includes(f.type)) {
|
||||
charge = "N/A";
|
||||
effect = `${f.power}x adjacent fragment power`;
|
||||
} else {
|
||||
} else if (Effect(f.type).includes("+x%")) {
|
||||
effect = Effect(f.type).replace(/-*x%/, numeralWrapper.formatPercentage(props.gift.effect(props.fragment) - 1));
|
||||
} else if (Effect(f.type).includes("-x%")) {
|
||||
const effectAmt = props.gift.effect(props.fragment);
|
||||
const perc = numeralWrapper.formatPercentage(1 - 1 / effectAmt);
|
||||
effect = Effect(f.type).replace(/-x%/, perc);
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -32,8 +32,6 @@ type IProps = {
|
||||
|
||||
export function AugmentationsPage(props: IProps): React.ReactElement {
|
||||
const player = use.Player();
|
||||
// Flag for whether the player has a gang with this faction
|
||||
const isPlayersGang = player.inGang() && player.getGangName() === props.faction.name;
|
||||
|
||||
const setRerender = useState(false)[1];
|
||||
|
||||
|
@ -2,8 +2,6 @@ import React, { useEffect, useState } from "react";
|
||||
|
||||
import { Box, Button, Container, Paper, TableBody, TableRow, Typography } from "@mui/material";
|
||||
|
||||
import { Augmentations } from "../../Augmentation/Augmentations";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { Table, TableCell } from "../../ui/React/Table";
|
||||
import { IRouter } from "../../ui/Router";
|
||||
|
@ -226,7 +226,7 @@ export const RamCosts: IMap<any> = {
|
||||
universityCourse: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||
gymWorkout: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||
travelToCity: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||
goToLocation: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||
goToLocation: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
|
||||
purchaseTor: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||
purchaseProgram: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||
getCurrentServer: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||
|
@ -3,7 +3,7 @@ import { BaseServer } from "../Server/BaseServer";
|
||||
|
||||
export interface INetscriptHelper {
|
||||
updateDynamicRam(functionName: string, ram: number): void;
|
||||
makeRuntimeErrorMsg(functionName: string, message: string): void;
|
||||
makeRuntimeErrorMsg(functionName: string, message: string): string;
|
||||
string(funcName: string, argName: string, v: unknown): string;
|
||||
number(funcName: string, argName: string, v: unknown): number;
|
||||
city(funcName: string, argName: string, v: unknown): CityName;
|
||||
|
@ -1104,6 +1104,7 @@ export function NetscriptSingularity(
|
||||
return true;
|
||||
default:
|
||||
workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
@ -122,7 +122,11 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
|
||||
return player.sleeves[sleeveNumber].workForCompany(player, companyName);
|
||||
},
|
||||
setToFactionWork: function (_sleeveNumber: unknown, _factionName: unknown, _workType: unknown): boolean {
|
||||
setToFactionWork: function (
|
||||
_sleeveNumber: unknown,
|
||||
_factionName: unknown,
|
||||
_workType: unknown,
|
||||
): boolean | undefined {
|
||||
const sleeveNumber = helper.number("setToFactionWork", "sleeveNumber", _sleeveNumber);
|
||||
const factionName = helper.string("setToUniversityCourse", "factionName", _factionName);
|
||||
const workType = helper.string("setToUniversityCourse", "workType", _workType);
|
||||
@ -144,6 +148,13 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
}
|
||||
}
|
||||
|
||||
if (player.gang && player.gang.facName == factionName) {
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
"sleeve.setToFactionWork",
|
||||
`Sleeve ${sleeveNumber} cannot work for faction ${factionName} because you have started a gang with them.`,
|
||||
);
|
||||
}
|
||||
|
||||
return player.sleeves[sleeveNumber].workForFaction(player, factionName, workType);
|
||||
},
|
||||
setToGymWorkout: function (_sleeveNumber: unknown, _gymName: unknown, _stat: unknown): boolean {
|
||||
|
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -3637,9 +3637,9 @@ export interface Sleeve {
|
||||
* @param sleeveNumber - Index of the sleeve to work for the faction.
|
||||
* @param factionName - Name of the faction to work for.
|
||||
* @param factionWorkType - Name of the action to perform for this faction.
|
||||
* @returns True if the sleeve started working on this faction, false otherwise.
|
||||
* @returns True if the sleeve started working on this faction, false otherwise, can also throw on errors
|
||||
*/
|
||||
setToFactionWork(sleeveNumber: number, factionName: string, factionWorkType: string): boolean;
|
||||
setToFactionWork(sleeveNumber: number, factionName: string, factionWorkType: string): boolean | undefined;
|
||||
|
||||
/**
|
||||
* Set a sleeve to work for a company.
|
||||
|
@ -72,6 +72,7 @@ import { vim } from "./commands/vim";
|
||||
import { weaken } from "./commands/weaken";
|
||||
import { wget } from "./commands/wget";
|
||||
import { hash } from "../hash/hash";
|
||||
import { apr1 } from "./commands/apr1";
|
||||
|
||||
export class Terminal implements ITerminal {
|
||||
// Flags to determine whether the player is currently running a hack or an analyze
|
||||
@ -805,6 +806,7 @@ export class Terminal implements ITerminal {
|
||||
scp: scp,
|
||||
sudov: sudov,
|
||||
tail: tail,
|
||||
apr1: apr1,
|
||||
top: top,
|
||||
unalias: unalias,
|
||||
vim: vim,
|
||||
|
15
src/Terminal/commands/apr1.ts
Normal file
15
src/Terminal/commands/apr1.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { ITerminal } from "../ITerminal";
|
||||
import { IRouter } from "../../ui/Router";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { BaseServer } from "../../Server/BaseServer";
|
||||
import { Apr1Events } from "../../ui/Apr1";
|
||||
|
||||
export function apr1(
|
||||
terminal: ITerminal,
|
||||
router: IRouter,
|
||||
player: IPlayer,
|
||||
server: BaseServer,
|
||||
commandArray: (string | number | boolean)[],
|
||||
): void {
|
||||
Apr1Events.emit();
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { EventEmitter } from "../utils/EventEmitter";
|
||||
import { Modal } from "./React/Modal";
|
||||
|
||||
const frames = [
|
||||
@ -37,6 +38,8 @@ function isApr1(): boolean {
|
||||
return d.getMonth() === 3 && d.getDate() === 1;
|
||||
}
|
||||
|
||||
export const Apr1Events = new EventEmitter();
|
||||
|
||||
export function Apr1(): React.ReactElement {
|
||||
const [open, setOpen] = useState(isApr1());
|
||||
const [n, setN] = useState(0);
|
||||
@ -45,6 +48,15 @@ export function Apr1(): React.ReactElement {
|
||||
const id = setInterval(() => setN((n) => (n + 1) % frames.length), 100);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
Apr1Events.subscribe(() => {
|
||||
setOpen(true);
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
if (!open) return <></>;
|
||||
|
||||
return (
|
||||
|
@ -18,7 +18,6 @@ import { Theme } from "@mui/material";
|
||||
import { findRunningScript } from "../../Script/ScriptHelpers";
|
||||
import { Player } from "../../Player";
|
||||
import { debounce } from "lodash";
|
||||
import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptStartStopEventEmitter";
|
||||
|
||||
let layerCounter = 0;
|
||||
|
||||
|
@ -66,6 +66,39 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
|
||||
expect(multipleCallsCalculated).toEqual(ScriptBaseCost);
|
||||
}
|
||||
|
||||
// simplyfied version from RamCostGenerator.ts
|
||||
function SF4Cost(player, cost) {
|
||||
if (player.bitNodeN === 4) return cost;
|
||||
const sf4 = player.sourceFileLvl(4);
|
||||
if (sf4 <= 1) return cost * 16;
|
||||
if (sf4 === 2) return cost * 4;
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that:
|
||||
* 1. A function has a specific RAM cost
|
||||
* 2. The calculator and the generator result in equal values
|
||||
* 3. Running multiple calls of the function does not result in additional RAM cost
|
||||
* @param {string[]} fnDesc - describes the name of the function being tested,
|
||||
* including the namespace(s). e.g. ["gang", "getMemberNames"]
|
||||
* @param {number} cost - expected cost
|
||||
*/
|
||||
async function expectSpecificRamCost(fnDesc, cost) {
|
||||
if (!Array.isArray(fnDesc)) {
|
||||
expect.fail("Non-array passed to expectZeroRamCost()");
|
||||
}
|
||||
const expected = getRamCost(Player, ...fnDesc);
|
||||
expect(expected).toEqual(SF4Cost(Player, cost));
|
||||
|
||||
const code = fnDesc.join(".") + "(); ";
|
||||
const calculated = (await calculateRamUsage(Player, code, [])).cost;
|
||||
testEquality(calculated, ScriptBaseCost+SF4Cost(Player, cost));
|
||||
|
||||
const multipleCallsCalculated = (await calculateRamUsage(Player, code, [])).cost;
|
||||
expect(multipleCallsCalculated).toEqual(ScriptBaseCost+SF4Cost(Player, cost));
|
||||
}
|
||||
|
||||
describe("Basic Functions", function () {
|
||||
it("hack()", async function () {
|
||||
const f = ["hack"];
|
||||
@ -466,6 +499,11 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
|
||||
const f = ["getFavorToDonate"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("goToLocation()", async function () {
|
||||
const f = ["goToLocation"];
|
||||
await expectSpecificRamCost(f, RamCostConstants.ScriptSingularityFn3RamCost);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Advanced Functions", function () {
|
||||
|
Loading…
Reference in New Issue
Block a user