Merge pull request #3367 from danielyxie/dev

Few bugfix
This commit is contained in:
hydroflame 2022-04-06 15:21:20 -04:00 committed by GitHub
commit ddf0ee6d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 125 additions and 47 deletions

42
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

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) { async function createWindow(killall) {
const setStopProcessHandler = global.app_handlers.stopProcess; const setStopProcessHandler = global.app_handlers.stopProcess;
app.setAppUserModelId("Bitburner")
let icon; let icon;
if (process.platform == 'linux') { 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())]; return bonuses[Math.floor(bonuses.length * randomNumber.random())];
} }
export const generalAugmentations = [ export const initGeneralAugmentations = (): Augmentation[] => [
new Augmentation({ new Augmentation({
name: AugmentationNames.HemoRecirculator, name: AugmentationNames.HemoRecirculator,
moneyCost: 4.5e7, moneyCost: 4.5e7,
@ -1486,7 +1486,7 @@ export const generalAugmentations = [
}), }),
]; ];
export const bladeburnerAugmentations = [ export const initBladeburnerAugmentations = (): Augmentation[] => [
new Augmentation({ new Augmentation({
name: AugmentationNames.EsperEyewear, name: AugmentationNames.EsperEyewear,
repCost: 1.25e3, repCost: 1.25e3,
@ -1751,7 +1751,7 @@ export const bladeburnerAugmentations = [
}), }),
]; ];
export const churchOfTheMachineGodAugmentations = [ export const initChurchOfTheMachineGodAugmentations = (): Augmentation[] => [
new Augmentation({ new Augmentation({
name: AugmentationNames.StaneksGift1, name: AugmentationNames.StaneksGift1,
repCost: 0, repCost: 0,

@ -15,9 +15,9 @@ import { clearObject } from "../utils/helpers/clearObject";
import { FactionNames } from "../Faction/data/FactionNames"; import { FactionNames } from "../Faction/data/FactionNames";
import { import {
bladeburnerAugmentations, initBladeburnerAugmentations,
churchOfTheMachineGodAugmentations, initChurchOfTheMachineGodAugmentations,
generalAugmentations, initGeneralAugmentations,
initNeuroFluxGovernor, initNeuroFluxGovernor,
initUnstableCircadianModulator, initUnstableCircadianModulator,
} from "./AugmentationCreator"; } from "./AugmentationCreator";
@ -49,9 +49,9 @@ function createAugmentations(): void {
[ [
initNeuroFluxGovernor(), initNeuroFluxGovernor(),
initUnstableCircadianModulator(), initUnstableCircadianModulator(),
...generalAugmentations, ...initGeneralAugmentations(),
...(factionExists(FactionNames.Bladeburners) ? bladeburnerAugmentations : []), ...(factionExists(FactionNames.Bladeburners) ? initBladeburnerAugmentations() : []),
...(factionExists(FactionNames.ChurchOfTheMachineGod) ? churchOfTheMachineGodAugmentations : []), ...(factionExists(FactionNames.ChurchOfTheMachineGod) ? initChurchOfTheMachineGodAugmentations() : []),
].map(resetAugmentation); ].map(resetAugmentation);
} }

@ -17,7 +17,6 @@ import { Employee } from "./Employee";
import { IndustryUpgrades } from "./IndustryUpgrades"; import { IndustryUpgrades } from "./IndustryUpgrades";
import { ResearchMap } from "./ResearchMap"; import { ResearchMap } from "./ResearchMap";
import { isRelevantMaterial } from "./ui/Helpers"; import { isRelevantMaterial } from "./ui/Helpers";
import { CityName } from "src/Locations/data/CityNames";
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void { export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
if (corporation.divisions.find(({ type }) => industry == type)) if (corporation.divisions.find(({ type }) => industry == type))

@ -61,7 +61,7 @@ export function Effect(tpe: FragmentType): string {
return "+x% hacknet production"; return "+x% hacknet production";
} }
case FragmentType.HacknetCost: { case FragmentType.HacknetCost: {
return "x% cheaper hacknet cost"; return "-x% cheaper hacknet cost";
} }
case FragmentType.Rep: { case FragmentType.Rep: {
return "+x% reputation from factions and companies"; 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)) { if ([FragmentType.Booster, FragmentType.None, FragmentType.Delete].includes(f.type)) {
charge = "N/A"; charge = "N/A";
effect = `${f.power}x adjacent fragment power`; 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)); 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 ( return (

@ -32,8 +32,6 @@ type IProps = {
export function AugmentationsPage(props: IProps): React.ReactElement { export function AugmentationsPage(props: IProps): React.ReactElement {
const player = use.Player(); 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]; 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 { 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 { IPlayer } from "../../PersonObjects/IPlayer";
import { Table, TableCell } from "../../ui/React/Table"; import { Table, TableCell } from "../../ui/React/Table";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";

@ -226,7 +226,7 @@ export const RamCosts: IMap<any> = {
universityCourse: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost), universityCourse: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
gymWorkout: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost), gymWorkout: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
travelToCity: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost), travelToCity: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
goToLocation: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost), goToLocation: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
purchaseTor: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost), purchaseTor: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
purchaseProgram: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost), purchaseProgram: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
getCurrentServer: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost), getCurrentServer: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),

@ -3,7 +3,7 @@ import { BaseServer } from "../Server/BaseServer";
export interface INetscriptHelper { export interface INetscriptHelper {
updateDynamicRam(functionName: string, ram: number): void; 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; string(funcName: string, argName: string, v: unknown): string;
number(funcName: string, argName: string, v: unknown): number; number(funcName: string, argName: string, v: unknown): number;
city(funcName: string, argName: string, v: unknown): CityName; city(funcName: string, argName: string, v: unknown): CityName;

@ -1104,6 +1104,7 @@ export function NetscriptSingularity(
return true; return true;
default: default:
workerScript.log("workForFaction", () => `Invalid work type: '${type}`); workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
return false;
} }
return true; return true;
}, },

@ -122,7 +122,11 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
return player.sleeves[sleeveNumber].workForCompany(player, companyName); 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 sleeveNumber = helper.number("setToFactionWork", "sleeveNumber", _sleeveNumber);
const factionName = helper.string("setToUniversityCourse", "factionName", _factionName); const factionName = helper.string("setToUniversityCourse", "factionName", _factionName);
const workType = helper.string("setToUniversityCourse", "workType", _workType); 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); return player.sleeves[sleeveNumber].workForFaction(player, factionName, workType);
}, },
setToGymWorkout: function (_sleeveNumber: unknown, _gymName: unknown, _stat: unknown): boolean { setToGymWorkout: function (_sleeveNumber: unknown, _gymName: unknown, _stat: unknown): boolean {

@ -3637,9 +3637,9 @@ export interface Sleeve {
* @param sleeveNumber - Index of the sleeve to work for the faction. * @param sleeveNumber - Index of the sleeve to work for the faction.
* @param factionName - Name of the faction to work for. * @param factionName - Name of the faction to work for.
* @param factionWorkType - Name of the action to perform for this faction. * @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. * Set a sleeve to work for a company.

@ -72,6 +72,7 @@ import { vim } from "./commands/vim";
import { weaken } from "./commands/weaken"; import { weaken } from "./commands/weaken";
import { wget } from "./commands/wget"; import { wget } from "./commands/wget";
import { hash } from "../hash/hash"; import { hash } from "../hash/hash";
import { apr1 } from "./commands/apr1";
export class Terminal implements ITerminal { export class Terminal implements ITerminal {
// Flags to determine whether the player is currently running a hack or an analyze // 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, scp: scp,
sudov: sudov, sudov: sudov,
tail: tail, tail: tail,
apr1: apr1,
top: top, top: top,
unalias: unalias, unalias: unalias,
vim: vim, vim: vim,

@ -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 React, { useEffect, useState } from "react";
import { EventEmitter } from "../utils/EventEmitter";
import { Modal } from "./React/Modal"; import { Modal } from "./React/Modal";
const frames = [ const frames = [
@ -37,6 +38,8 @@ function isApr1(): boolean {
return d.getMonth() === 3 && d.getDate() === 1; return d.getMonth() === 3 && d.getDate() === 1;
} }
export const Apr1Events = new EventEmitter();
export function Apr1(): React.ReactElement { export function Apr1(): React.ReactElement {
const [open, setOpen] = useState(isApr1()); const [open, setOpen] = useState(isApr1());
const [n, setN] = useState(0); const [n, setN] = useState(0);
@ -45,6 +48,15 @@ export function Apr1(): React.ReactElement {
const id = setInterval(() => setN((n) => (n + 1) % frames.length), 100); const id = setInterval(() => setN((n) => (n + 1) % frames.length), 100);
return () => clearInterval(id); return () => clearInterval(id);
}, []); }, []);
useEffect(
() =>
Apr1Events.subscribe(() => {
setOpen(true);
}),
[],
);
if (!open) return <></>; if (!open) return <></>;
return ( return (

@ -18,7 +18,6 @@ import { Theme } from "@mui/material";
import { findRunningScript } from "../../Script/ScriptHelpers"; import { findRunningScript } from "../../Script/ScriptHelpers";
import { Player } from "../../Player"; import { Player } from "../../Player";
import { debounce } from "lodash"; import { debounce } from "lodash";
import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptStartStopEventEmitter";
let layerCounter = 0; let layerCounter = 0;

@ -66,6 +66,39 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
expect(multipleCallsCalculated).toEqual(ScriptBaseCost); 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 () { describe("Basic Functions", function () {
it("hack()", async function () { it("hack()", async function () {
const f = ["hack"]; const f = ["hack"];
@ -466,6 +499,11 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
const f = ["getFavorToDonate"]; const f = ["getFavorToDonate"];
await expectNonZeroRamCost(f); await expectNonZeroRamCost(f);
}); });
it("goToLocation()", async function () {
const f = ["goToLocation"];
await expectSpecificRamCost(f, RamCostConstants.ScriptSingularityFn3RamCost);
});
}); });
describe("Advanced Functions", function () { describe("Advanced Functions", function () {