diff --git a/src/IEngine.ts b/src/IEngine.ts
index a7938c696..d495e5e20 100644
--- a/src/IEngine.ts
+++ b/src/IEngine.ts
@@ -3,32 +3,25 @@
* to TypeScript at the moment
*/
export interface IEngine {
- indexedDb: any;
_lastUpdate: number;
- hideAllContent: () => void;
- loadTerminalContent: () => void;
- loadScriptEditorContent: (filename?: string, code?: string) => void;
- loadActiveScriptsContent: () => void;
- loadCreateProgramContent: () => void;
- loadCharacterContent: () => void;
- loadFactionsContent: () => void;
- loadAugmentationsContent: () => void;
- loadHacknetNodesContent: () => void;
- loadSleevesContent: () => void;
- loadLocationContent: () => void;
- loadTravelContent: () => void;
- loadJobContent: () => void;
- loadStockMarketContent: () => void;
- loadBladeburnerContent: () => void;
- loadCorporationContent: () => void;
- loadGangContent: () => void;
- loadMilestonesContent: () => void;
- loadTutorialContent: () => void;
- loadDevMenuContent: () => void;
- loadFactionContent: () => void;
- loadInfiltrationContent: (name: string, difficulty: number, maxLevel: number) => void;
- loadMissionContent: () => void;
- loadResleevingContent: () => void;
- loadGameOptionsContent: () => void;
- load: (save: string) => void;
+ updateGame: (numCycles?: number) => void;
+ Counters: {
+ [key: string]: number | undefined;
+ autoSaveCounter: number;
+ updateSkillLevelsCounter: number;
+ updateDisplays: number;
+ updateDisplaysLong: number;
+ updateActiveScriptsDisplay: number;
+ createProgramNotifications: number;
+ augmentationsNotifications: number;
+ checkFactionInvitations: number;
+ passiveFactionGrowth: number;
+ messages: number;
+ mechanicProcess: number;
+ contractGeneration: number;
+ };
+ decrementAllCounters: (numCycles?: number) => void;
+ checkCounters: () => void;
+ load: (saveString: string) => void;
+ start: () => void;
}
diff --git a/src/Missions.d.ts b/src/Missions.d.ts
index 31c9a7777..8a1e7d522 100644
--- a/src/Missions.d.ts
+++ b/src/Missions.d.ts
@@ -2,5 +2,7 @@ export declare let inMission: boolean;
export declare class HackingMission {
constructor(reputation: number, faction: Faction);
init(): void;
+ process(numCycles: number): void;
}
export declare function setInMission(inMission: boolean, mission: HackingMission): void;
+export declare let currMission: HackingMission;
diff --git a/src/PersonObjects/IPlayer.ts b/src/PersonObjects/IPlayer.ts
index c20a051e6..cbf0e6203 100644
--- a/src/PersonObjects/IPlayer.ts
+++ b/src/PersonObjects/IPlayer.ts
@@ -270,7 +270,7 @@ export interface IPlayer {
createProgramWork(numCycles: number): boolean;
takeClass(numCycles: number): boolean;
commitCrime(numCycles: number): boolean;
- checkForFactionInvitations(): void;
+ checkForFactionInvitations(): Faction[];
setBitNodeNumber(n: number): void;
getMult(name: string): number;
setMult(name: string, mult: number): void;
diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts
index 302664adf..717db70f1 100644
--- a/src/PersonObjects/Player/PlayerObject.ts
+++ b/src/PersonObjects/Player/PlayerObject.ts
@@ -277,7 +277,7 @@ export class PlayerObject implements IPlayer {
createProgramWork: (numCycles: number) => boolean;
takeClass: (numCycles: number) => boolean;
commitCrime: (numCycles: number) => boolean;
- checkForFactionInvitations: () => void;
+ checkForFactionInvitations: () => Faction[];
setBitNodeNumber: (n: number) => void;
getMult: (name: string) => number;
setMult: (name: string, mult: number) => void;
diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx
index 74fa37f3a..9ed815455 100644
--- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx
+++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx
@@ -2015,8 +2015,8 @@ export function reapplyAllSourceFiles(this: IPlayer): void {
//This function sets the requirements to join a Faction. It checks whether the Player meets
//those requirements and will return an array of all factions that the Player should
//receive an invitation to
-export function checkForFactionInvitations(this: IPlayer) {
- let invitedFactions = []; //Array which will hold all Factions the player should be invited to
+export function checkForFactionInvitations(this: IPlayer): Faction[] {
+ let invitedFactions: Faction[] = []; //Array which will hold all Factions the player should be invited to
var numAugmentations = this.augmentations.length;
diff --git a/src/Prestige.ts b/src/Prestige.ts
index 55a3920ca..be21e1352 100755
--- a/src/Prestige.ts
+++ b/src/Prestige.ts
@@ -85,8 +85,7 @@ function prestigeAugmentation(): void {
}
// Stop a Terminal action if there is onerror
- if (Engine._actionInProgress) {
- Engine._actionInProgress = false;
+ if (Terminal.action !== null) {
Terminal.finishAction(Router, Player, true);
}
@@ -195,8 +194,7 @@ function prestigeSourceFile(flume: boolean): void {
}
// Stop a Terminal action if there is one
- if (Engine._actionInProgress) {
- Engine._actionInProgress = false;
+ if (Terminal.action !== null) {
Terminal.finishAction(Router, Player, true);
}
diff --git a/src/engine.jsx b/src/engine.tsx
similarity index 92%
rename from src/engine.jsx
rename to src/engine.tsx
index 0008931c1..fe4213429 100644
--- a/src/engine.jsx
+++ b/src/engine.tsx
@@ -50,7 +50,29 @@ import { startUnclickable } from "./Exploits/unclickable";
import React from "react";
-const Engine = {
+const Engine: {
+ _lastUpdate: number;
+ updateGame: (numCycles?: number) => void;
+ Counters: {
+ [key: string]: number | undefined;
+ autoSaveCounter: number;
+ updateSkillLevelsCounter: number;
+ updateDisplays: number;
+ updateDisplaysLong: number;
+ updateActiveScriptsDisplay: number;
+ createProgramNotifications: number;
+ augmentationsNotifications: number;
+ checkFactionInvitations: number;
+ passiveFactionGrowth: number;
+ messages: number;
+ mechanicProcess: number;
+ contractGeneration: number;
+ };
+ decrementAllCounters: (numCycles?: number) => void;
+ checkCounters: () => void;
+ load: (saveString: string) => void;
+ start: () => void;
+} = {
// Time variables (milliseconds unix epoch time)
_lastUpdate: new Date().getTime(),
@@ -106,7 +128,7 @@ const Engine = {
}
// Gang, if applicable
- if (Player.inGang()) {
+ if (Player.inGang() && Player.gang !== null) {
Player.gang.process(numCycles, Player);
}
@@ -175,10 +197,10 @@ const Engine = {
},
decrementAllCounters: function (numCycles = 1) {
- for (var counter in Engine.Counters) {
- if (Engine.Counters.hasOwnProperty(counter)) {
- Engine.Counters[counter] = Engine.Counters[counter] - numCycles;
- }
+ for (const counterName in Engine.Counters) {
+ const counter = Engine.Counters[counterName];
+ if (counter === undefined) throw new Error("counter should not be undefined");
+ Engine.Counters[counterName] = counter - numCycles;
}
},
@@ -328,8 +350,9 @@ const Engine = {
}
// Gang progress for BitNode 2
- if (Player.inGang()) {
- Player.gang.process(numCyclesOffline, Player);
+ const gang = Player.gang;
+ if (Player.inGang() && gang !== null) {
+ gang.process(numCyclesOffline, Player);
}
// Corporation offline progress
diff --git a/utils/helpers/exceptionAlert.ts b/utils/helpers/exceptionAlert.ts
index 1c8ab60a6..8269ddd6a 100644
--- a/utils/helpers/exceptionAlert.ts
+++ b/utils/helpers/exceptionAlert.ts
@@ -5,17 +5,17 @@ interface IError {
lineNumber?: number;
}
-export function exceptionAlert(e: IError): void {
+export function exceptionAlert(e: IError | string): void {
console.error(e);
dialogBoxCreate(
"Caught an exception: " +
e +
"
" +
"Filename: " +
- (e.fileName || "UNKNOWN FILE NAME") +
+ ((e as any).fileName || "UNKNOWN FILE NAME") +
"
" +
"Line Number: " +
- (e.lineNumber || "UNKNOWN LINE NUMBER") +
+ ((e as any).lineNumber || "UNKNOWN LINE NUMBER") +
"
" +
"This is a bug, please report to game developer with this " +
"message as well as details about how to reproduce the bug.
" +