mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 05:47:14 +02:00
BUGFIX: Running scripts may be loaded before main UI (#1726)
This commit is contained in:
@@ -11,10 +11,14 @@ import { scriptKey } from "../utils/helpers/scriptKey";
|
||||
|
||||
import type { ScriptFilePath } from "../Paths/ScriptFilePath";
|
||||
|
||||
export function scriptCalculateOfflineProduction(runningScript: RunningScript): void {
|
||||
export function scriptCalculateOfflineProduction(
|
||||
runningScript: RunningScript,
|
||||
playerLastUpdate: number,
|
||||
playerPlaytimeSinceLastAug: number,
|
||||
): void {
|
||||
//The Player object stores the last update time from when we were online
|
||||
const thisUpdate = new Date().getTime();
|
||||
const lastUpdate = Player.lastUpdate;
|
||||
const lastUpdate = playerLastUpdate;
|
||||
const timePassed = Math.max((thisUpdate - lastUpdate) / 1000, 0); //Seconds
|
||||
|
||||
//Calculate the "confidence" rating of the script's true production. This is based
|
||||
@@ -59,7 +63,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
||||
Player.gainHackingExp(expGain);
|
||||
|
||||
let moneyGain =
|
||||
(runningScript.onlineMoneyMade / Player.playtimeSinceLastAug) * timePassed * CONSTANTS.OfflineHackingIncome;
|
||||
(runningScript.onlineMoneyMade / playerPlaytimeSinceLastAug) * timePassed * CONSTANTS.OfflineHackingIncome;
|
||||
if (!Number.isFinite(moneyGain)) {
|
||||
moneyGain = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user