mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
engine in ts
This commit is contained in:
parent
ad75fa5ebc
commit
43723a3fbb
@ -3,32 +3,25 @@
|
|||||||
* to TypeScript at the moment
|
* to TypeScript at the moment
|
||||||
*/
|
*/
|
||||||
export interface IEngine {
|
export interface IEngine {
|
||||||
indexedDb: any;
|
|
||||||
_lastUpdate: number;
|
_lastUpdate: number;
|
||||||
hideAllContent: () => void;
|
updateGame: (numCycles?: number) => void;
|
||||||
loadTerminalContent: () => void;
|
Counters: {
|
||||||
loadScriptEditorContent: (filename?: string, code?: string) => void;
|
[key: string]: number | undefined;
|
||||||
loadActiveScriptsContent: () => void;
|
autoSaveCounter: number;
|
||||||
loadCreateProgramContent: () => void;
|
updateSkillLevelsCounter: number;
|
||||||
loadCharacterContent: () => void;
|
updateDisplays: number;
|
||||||
loadFactionsContent: () => void;
|
updateDisplaysLong: number;
|
||||||
loadAugmentationsContent: () => void;
|
updateActiveScriptsDisplay: number;
|
||||||
loadHacknetNodesContent: () => void;
|
createProgramNotifications: number;
|
||||||
loadSleevesContent: () => void;
|
augmentationsNotifications: number;
|
||||||
loadLocationContent: () => void;
|
checkFactionInvitations: number;
|
||||||
loadTravelContent: () => void;
|
passiveFactionGrowth: number;
|
||||||
loadJobContent: () => void;
|
messages: number;
|
||||||
loadStockMarketContent: () => void;
|
mechanicProcess: number;
|
||||||
loadBladeburnerContent: () => void;
|
contractGeneration: number;
|
||||||
loadCorporationContent: () => void;
|
};
|
||||||
loadGangContent: () => void;
|
decrementAllCounters: (numCycles?: number) => void;
|
||||||
loadMilestonesContent: () => void;
|
checkCounters: () => void;
|
||||||
loadTutorialContent: () => void;
|
load: (saveString: string) => void;
|
||||||
loadDevMenuContent: () => void;
|
start: () => void;
|
||||||
loadFactionContent: () => void;
|
|
||||||
loadInfiltrationContent: (name: string, difficulty: number, maxLevel: number) => void;
|
|
||||||
loadMissionContent: () => void;
|
|
||||||
loadResleevingContent: () => void;
|
|
||||||
loadGameOptionsContent: () => void;
|
|
||||||
load: (save: string) => void;
|
|
||||||
}
|
}
|
||||||
|
2
src/Missions.d.ts
vendored
2
src/Missions.d.ts
vendored
@ -2,5 +2,7 @@ export declare let inMission: boolean;
|
|||||||
export declare class HackingMission {
|
export declare class HackingMission {
|
||||||
constructor(reputation: number, faction: Faction);
|
constructor(reputation: number, faction: Faction);
|
||||||
init(): void;
|
init(): void;
|
||||||
|
process(numCycles: number): void;
|
||||||
}
|
}
|
||||||
export declare function setInMission(inMission: boolean, mission: HackingMission): void;
|
export declare function setInMission(inMission: boolean, mission: HackingMission): void;
|
||||||
|
export declare let currMission: HackingMission;
|
||||||
|
@ -270,7 +270,7 @@ export interface IPlayer {
|
|||||||
createProgramWork(numCycles: number): boolean;
|
createProgramWork(numCycles: number): boolean;
|
||||||
takeClass(numCycles: number): boolean;
|
takeClass(numCycles: number): boolean;
|
||||||
commitCrime(numCycles: number): boolean;
|
commitCrime(numCycles: number): boolean;
|
||||||
checkForFactionInvitations(): void;
|
checkForFactionInvitations(): Faction[];
|
||||||
setBitNodeNumber(n: number): void;
|
setBitNodeNumber(n: number): void;
|
||||||
getMult(name: string): number;
|
getMult(name: string): number;
|
||||||
setMult(name: string, mult: number): void;
|
setMult(name: string, mult: number): void;
|
||||||
|
@ -277,7 +277,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
createProgramWork: (numCycles: number) => boolean;
|
createProgramWork: (numCycles: number) => boolean;
|
||||||
takeClass: (numCycles: number) => boolean;
|
takeClass: (numCycles: number) => boolean;
|
||||||
commitCrime: (numCycles: number) => boolean;
|
commitCrime: (numCycles: number) => boolean;
|
||||||
checkForFactionInvitations: () => void;
|
checkForFactionInvitations: () => Faction[];
|
||||||
setBitNodeNumber: (n: number) => void;
|
setBitNodeNumber: (n: number) => void;
|
||||||
getMult: (name: string) => number;
|
getMult: (name: string) => number;
|
||||||
setMult: (name: string, mult: number) => void;
|
setMult: (name: string, mult: number) => void;
|
||||||
|
@ -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
|
//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
|
//those requirements and will return an array of all factions that the Player should
|
||||||
//receive an invitation to
|
//receive an invitation to
|
||||||
export function checkForFactionInvitations(this: IPlayer) {
|
export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
||||||
let invitedFactions = []; //Array which will hold all Factions the player should be invited to
|
let invitedFactions: Faction[] = []; //Array which will hold all Factions the player should be invited to
|
||||||
|
|
||||||
var numAugmentations = this.augmentations.length;
|
var numAugmentations = this.augmentations.length;
|
||||||
|
|
||||||
|
@ -85,8 +85,7 @@ function prestigeAugmentation(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop a Terminal action if there is onerror
|
// Stop a Terminal action if there is onerror
|
||||||
if (Engine._actionInProgress) {
|
if (Terminal.action !== null) {
|
||||||
Engine._actionInProgress = false;
|
|
||||||
Terminal.finishAction(Router, Player, true);
|
Terminal.finishAction(Router, Player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +194,7 @@ function prestigeSourceFile(flume: boolean): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop a Terminal action if there is one
|
// Stop a Terminal action if there is one
|
||||||
if (Engine._actionInProgress) {
|
if (Terminal.action !== null) {
|
||||||
Engine._actionInProgress = false;
|
|
||||||
Terminal.finishAction(Router, Player, true);
|
Terminal.finishAction(Router, Player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,29 @@ import { startUnclickable } from "./Exploits/unclickable";
|
|||||||
|
|
||||||
import React from "react";
|
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)
|
// Time variables (milliseconds unix epoch time)
|
||||||
_lastUpdate: new Date().getTime(),
|
_lastUpdate: new Date().getTime(),
|
||||||
|
|
||||||
@ -106,7 +128,7 @@ const Engine = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gang, if applicable
|
// Gang, if applicable
|
||||||
if (Player.inGang()) {
|
if (Player.inGang() && Player.gang !== null) {
|
||||||
Player.gang.process(numCycles, Player);
|
Player.gang.process(numCycles, Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,10 +197,10 @@ const Engine = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
decrementAllCounters: function (numCycles = 1) {
|
decrementAllCounters: function (numCycles = 1) {
|
||||||
for (var counter in Engine.Counters) {
|
for (const counterName in Engine.Counters) {
|
||||||
if (Engine.Counters.hasOwnProperty(counter)) {
|
const counter = Engine.Counters[counterName];
|
||||||
Engine.Counters[counter] = Engine.Counters[counter] - numCycles;
|
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
|
// Gang progress for BitNode 2
|
||||||
if (Player.inGang()) {
|
const gang = Player.gang;
|
||||||
Player.gang.process(numCyclesOffline, Player);
|
if (Player.inGang() && gang !== null) {
|
||||||
|
gang.process(numCyclesOffline, Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Corporation offline progress
|
// Corporation offline progress
|
@ -5,17 +5,17 @@ interface IError {
|
|||||||
lineNumber?: number;
|
lineNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exceptionAlert(e: IError): void {
|
export function exceptionAlert(e: IError | string): void {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
"Caught an exception: " +
|
"Caught an exception: " +
|
||||||
e +
|
e +
|
||||||
"<br><br>" +
|
"<br><br>" +
|
||||||
"Filename: " +
|
"Filename: " +
|
||||||
(e.fileName || "UNKNOWN FILE NAME") +
|
((e as any).fileName || "UNKNOWN FILE NAME") +
|
||||||
"<br><br>" +
|
"<br><br>" +
|
||||||
"Line Number: " +
|
"Line Number: " +
|
||||||
(e.lineNumber || "UNKNOWN LINE NUMBER") +
|
((e as any).lineNumber || "UNKNOWN LINE NUMBER") +
|
||||||
"<br><br>" +
|
"<br><br>" +
|
||||||
"This is a bug, please report to game developer with this " +
|
"This is a bug, please report to game developer with this " +
|
||||||
"message as well as details about how to reproduce the bug.<br><br>" +
|
"message as well as details about how to reproduce the bug.<br><br>" +
|
||||||
|
Loading…
Reference in New Issue
Block a user