few more bugfixes

This commit is contained in:
Olivier Gagnon 2021-11-11 23:28:08 -05:00
parent a54e613e42
commit 3112dc60c0
24 changed files with 72 additions and 86 deletions

@ -16,7 +16,7 @@
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
module.exports = (/*on, config*/) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

34
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

File diff suppressed because one or more lines are too long

@ -102,8 +102,7 @@
"start:container": "webpack-dev-server --progress --env.devServer --mode development --env.runInContainer",
"build": "webpack --mode production",
"build:dev": "webpack --mode development",
"lint": "npm run lint:jsts & npm run lint:style",
"lint:jsts": "eslint --fix . --ext js,jsx,ts,tsx",
"lint": "eslint --fix . --ext js,jsx,ts,tsx",
"preinstall": "node ./scripts/engines-check.js",
"test": "jest",
"test:watch": "jest --watch",

@ -132,7 +132,6 @@ module.exports = {
],
"new-cap": ["error"],
"new-parens": ["error"],
// TODO: configure this...
"newline-before-return": ["error"],
"newline-per-chained-call": ["error"],
"no-alert": ["error"],

@ -3,7 +3,7 @@ import { IMap } from "../types";
export const GeneralActions: IMap<Action> = {};
let actionNames : Array<string> = [
const actionNames : Array<string> = [
"Training",
"Field Analysis",
"Recruitment",
@ -12,7 +12,7 @@ let actionNames : Array<string> = [
"Incite Violence"
];
for (let actionName of actionNames){
for (const actionName of actionNames){
GeneralActions[actionName] = new Action({
name: actionName,
});

@ -147,7 +147,7 @@ export class Corporation {
const cycleProfit = profit * CorporationConstants.SecsPerMarketCycle;
const totalDividends = (this.dividendPercentage / 100) * cycleProfit;
const dividendsPerShare = totalDividends / this.totalShares;
const dividends = this.numShares * dividendsPerShare * (1 - this.dividendTaxPercentage / 100);
const dividends = this.numShares * dividendsPerShare;
let upgrades = -0.15;
if (this.unlockUpgrades[5] === 1) {
upgrades += 0.05;

@ -78,7 +78,6 @@ interface IProps {
// Create a popup that lets the player use the Market TA research for Products
export function ProductMarketTaModal(props: IProps): React.ReactElement {
const division = useDivision();
const markupLimit = props.product.rat / props.product.mku;
const setRerender = useState(false)[1];
function rerender(): void {

@ -14,7 +14,6 @@ import { CONSTANTS } from "../../Constants";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
import { Faction } from "../../Faction/Faction";
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
import { use } from "../../ui/Context";
import { CreateGangModal } from "./CreateGangModal";

@ -508,7 +508,6 @@ export function purchaseHashUpgrade(player: IPlayer, upgName: string, upgTarget:
}
if (!(target instanceof Server)) throw new Error(`'${upgTarget}' is not a normal server.`);
const old = target.moneyMax;
target.changeMaximumMoney(upg.value);
} catch (e) {
player.hashManager.refundUpgrade(upgName);

@ -136,7 +136,7 @@ function iTutorialPrevStep(): void {
function iTutorialEnd(): void {
ITutorial.isRunning = false;
ITutorial.currStep = iTutorialSteps.Start;
Player.getHomeComputer().messages.push(LiteratureNames.HackersStartingHandbook);
ITutorialEvents.emit();
}

@ -430,7 +430,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
const hacknet = NetscriptHacknet(Player, workerScript, helper);
const bladeburner = NetscriptBladeburner(Player, workerScript, helper);
const codingcontract = NetscriptCodingContract(Player, workerScript, helper);
const corporation = NetscriptCorporation(Player, workerScript, helper);
const corporation = NetscriptCorporation(Player);
const formulas = NetscriptFormulas(Player, workerScript, helper);
const singularity = NetscriptSingularity(Player, workerScript, helper);
const stockmarket = NetscriptStockMarket(Player, workerScript, helper);

@ -1,5 +1,3 @@
import { INetscriptHelper } from "./INetscriptHelper";
import { WorkerScript } from "../Netscript/WorkerScript";
import { IPlayer } from "../PersonObjects/IPlayer";
import { OfficeSpace } from "../Corporation/OfficeSpace";
@ -88,11 +86,7 @@ export interface INetscriptCorporation {
getEmployee(divisionName: any, cityName: any, employeeName: any): any;
}
export function NetscriptCorporation(
player: IPlayer,
workerScript: WorkerScript,
helper: INetscriptHelper,
): INetscriptCorporation {
export function NetscriptCorporation(player: IPlayer): INetscriptCorporation {
function getDivision(divisionName: any): IIndustry {
const corporation = player.corporation;
if (corporation === null) throw new Error("cannot be called without a corporation");

@ -1,4 +1,3 @@
import { Corporation } from "./Corporation/Corporation";
import { PlayerObject } from "./PersonObjects/Player/PlayerObject";
import { sanitizeExploits } from "./Exploits/Exploit";

@ -75,24 +75,7 @@ class BitburnerSaveObject {
const epochTime = Math.round(Date.now() / 1000);
const bn = Player.bitNodeN;
const filename = `bitburnerSave_BN${bn}x${SourceFileFlags[bn]}_${epochTime}.json`;
const file = new Blob([saveString], { type: "text/plain" });
const navigator = window.navigator as any;
if (navigator.msSaveOrOpenBlob) {
// IE10+
navigator.msSaveOrOpenBlob(file, filename);
} else {
// Others
const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function () {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
download(filename, saveString);
}
toJSON(): any {
@ -372,8 +355,29 @@ function createBetaUpdateText(): void {
);
}
function download(filename: string, content: string): void {
const file = new Blob([content], { type: "text/plain" });
const navigator = window.navigator as any;
if (navigator.msSaveOrOpenBlob) {
// IE10+
navigator.msSaveOrOpenBlob(file, filename);
} else {
// Others
const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function () {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject;
export { saveObject, loadGame };
export { saveObject, loadGame, download };
const saveObject = new BitburnerSaveObject();

@ -4,7 +4,6 @@ import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer";
import { getFirstParentDirectory, isValidDirectoryPath, evaluateDirectoryPath } from "../../Terminal/DirectoryHelpers";
import Typography from "@mui/material/Typography";
export function ls(
terminal: ITerminal,

@ -3,6 +3,7 @@ import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer";
import { isScriptFilename } from "../../Script/isScriptFilename";
import { CursorPositions } from "../../ScriptEditor/CursorPositions";
export function nano(
terminal: ITerminal,
@ -24,13 +25,15 @@ export function nano(
if (script == null) {
let code = "";
if (filename.endsWith(".ns") || filename.endsWith(".js")) {
code = `/**
* @param {NS} ns
**/
code = `/** @param {NS} ns **/
export async function main(ns) {
}`;
}
CursorPositions.saveCursor(filename, {
row: 3,
column: 5,
});
router.toScriptEditor(filepath, code);
} else {
router.toScriptEditor(filepath, script.code);

@ -2,7 +2,6 @@ import { ITerminal } from "../ITerminal";
import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer";
import { Message } from "../../Message/Message";
import { GetServer } from "../../Server/AllServers";
import { isScriptFilename } from "../../Script/isScriptFilename";

@ -33,8 +33,8 @@ function getDB(): Promise<IDBObjectStore> {
}
export function load(): Promise<string> {
return new Promise(async (resolve, reject) => {
await getDB()
return new Promise((resolve, reject) => {
getDB()
.then((db) => {
return new Promise<string>((resolve, reject) => {
const request: IDBRequest<string> = db.get("save");

@ -480,7 +480,13 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
<TextField
InputProps={{
startAdornment: (
<Typography color={formatTime(timestampFormat) === "format error" ? "error" : "success"}>
<Typography
color={
formatTime(timestampFormat) === "format error" && timestampFormat !== ""
? "error"
: "success"
}
>
Timestamp&nbsp;format:&nbsp;
</Typography>
),

@ -3,8 +3,9 @@ import Typography from "@mui/material/Typography";
import Link from "@mui/material/Link";
import Button from "@mui/material/Button";
import { Settings } from "../../Settings/Settings";
import { saveObject } from "../../SaveObject";
import { load } from "../../db";
import { IRouter } from "../Router";
import { download } from "../../SaveObject";
export let RecoveryMode = false;
@ -22,7 +23,9 @@ export function RecoveryRoot({ router }: IProps): React.ReactElement {
router.toTerminal();
}
Settings.AutosaveInterval = 0;
saveObject.exportGame();
load().then((content) => {
download("RECOVERY.json", content);
});
return (
<>
<Typography variant="h3">RECOVERY MODE ACTIVATED</Typography>

@ -1,21 +1,6 @@
/**
* Generic Event Emitter class following a subscribe/publish paradigm.
*/
type cbFn = (...args: any[]) => any;
interface ISubscriber {
/**
* Callback function that will be run when an event is emitted
*/
cb: cbFn;
/**
* Name/identifier for this subscriber
*/
id: string;
}
function uuidv4(): string {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
const r = (Math.random() * 16) | 0,

@ -3,7 +3,6 @@ import { determineAllPossibilitiesForTabCompletion } from "../../src/Terminal/de
import { Server } from "../../src/Server/Server";
import { AddToAllServers, prestigeAllServers } from "../../src/Server/AllServers";
import { LocationName } from "../../src/Locations/data/LocationNames";
import { Message } from "../../src/Message/Message";
import { CodingContract } from "../../src/CodingContracts";
describe("determineAllPossibilitiesForTabCompletion", function () {