mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
engine in ts
This commit is contained in:
parent
ad75fa5ebc
commit
43723a3fbb
@ -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;
|
||||
}
|
||||
|
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 {
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
@ -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 +
|
||||
"<br><br>" +
|
||||
"Filename: " +
|
||||
(e.fileName || "UNKNOWN FILE NAME") +
|
||||
((e as any).fileName || "UNKNOWN FILE NAME") +
|
||||
"<br><br>" +
|
||||
"Line Number: " +
|
||||
(e.lineNumber || "UNKNOWN LINE NUMBER") +
|
||||
((e as any).lineNumber || "UNKNOWN LINE NUMBER") +
|
||||
"<br><br>" +
|
||||
"This is a bug, please report to game developer with this " +
|
||||
"message as well as details about how to reproduce the bug.<br><br>" +
|
||||
|
Loading…
Reference in New Issue
Block a user