UI: fix scripts recorded offline income (#1025)

This commit is contained in:
Caldwell 2024-02-10 13:24:55 +01:00 committed by GitHub
parent fccc27fe58
commit 84c4dba1e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

@ -56,7 +56,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
Player.gainHackingExp(expGain);
const moneyGain =
(runningScript.onlineMoneyMade / runningScript.onlineRunningTime) * timePassed * CONSTANTS.OfflineHackingIncome;
(runningScript.onlineMoneyMade / Player.playtimeSinceLastAug) * timePassed * CONSTANTS.OfflineHackingIncome;
// money is given to player during engine load
Player.scriptProdSinceLastAug += moneyGain;

@ -3,7 +3,8 @@ import "../../src/Player";
import { loadAllServers, saveAllServers } from "../../src/Server/AllServers";
import { loadAllRunningScripts } from "../../src/NetscriptWorker";
import { Settings } from "../../src/Settings/Settings";
import { Player, setPlayer } from "../../src/Player";
import { PlayerObject } from "../../src/PersonObjects/Player/PlayerObject";
jest.useFakeTimers();
// Direct tests of loading and saving.
@ -151,6 +152,9 @@ test("load/saveAllServers", () => {
// Feed a JSON object through loadAllServers/saveAllServers.
// The object is a pruned set of servers that was extracted from a real (dev) game.
jest.setSystemTime(123456789000);
setPlayer(new PlayerObject());
Player.playtimeSinceLastAug = 123456;
loadStandardServers();
// Re-stringify with indenting for nicer diffs