2023-06-24 16:08:21 +02:00
|
|
|
import { saveObject } from "../../src/SaveObject";
|
2023-06-26 04:53:35 +02:00
|
|
|
import { Factions } from "../../src/Faction/Factions";
|
2023-06-24 16:08:21 +02:00
|
|
|
import { Player, setPlayer } from "../../src/Player";
|
|
|
|
import { PlayerObject } from "../../src/PersonObjects/Player/PlayerObject";
|
|
|
|
import { joinFaction } from "../../src/Faction/FactionHelpers";
|
2023-07-11 15:23:17 +02:00
|
|
|
import { AugmentationName, CompanyName, CrimeType, FactionName } from "../../src/Enums";
|
2023-06-24 16:08:21 +02:00
|
|
|
import { Augmentations } from "../../src/Augmentation/Augmentations";
|
|
|
|
import { SleeveCrimeWork } from "../../src/PersonObjects/Sleeve/Work/SleeveCrimeWork";
|
2023-07-11 15:23:17 +02:00
|
|
|
import { Companies } from "../../src/Company/Companies";
|
2023-06-24 16:08:21 +02:00
|
|
|
|
|
|
|
describe("Check Save File Continuity", () => {
|
|
|
|
establishInitialConditions();
|
|
|
|
// Calling getSaveString forces save info to update
|
2024-03-28 05:08:09 +01:00
|
|
|
saveObject.getSaveData();
|
2023-06-24 16:08:21 +02:00
|
|
|
|
2024-02-26 14:05:10 +01:00
|
|
|
const savesToTest = ["FactionsSave", "PlayerSave", "CompaniesSave", "GoSave"] as const;
|
2023-06-24 16:08:21 +02:00
|
|
|
for (const saveToTest of savesToTest) {
|
|
|
|
test(`${saveToTest} continuity`, () => {
|
|
|
|
const parsed = JSON.parse(saveObject[saveToTest]);
|
|
|
|
expect(parsed).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function establishInitialConditions() {
|
|
|
|
// Jest overrides to produce static savedata
|
|
|
|
jest.useFakeTimers().setSystemTime(1687611703623);
|
|
|
|
let i = 0.5;
|
|
|
|
Math.random = () => {
|
|
|
|
return (++i % 37) / 37;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Game initializers
|
|
|
|
setPlayer(new PlayerObject());
|
|
|
|
Player.init();
|
|
|
|
Player.identifier = "Overwritten identifier";
|
|
|
|
Player.sleevesFromCovenant = 1;
|
|
|
|
Player.sourceFiles.set(10, 1);
|
|
|
|
Player.prestigeAugmentation();
|
|
|
|
/* Not comparing servers yet
|
|
|
|
// Just to reduce snapshot size, reduce server map to home + 2 servers
|
|
|
|
for (let i = serverMetadata.length - 1; i >= 0; i--) {
|
|
|
|
if (!["zer0", "n00dles"].includes(serverMetadata[i].hostname)) serverMetadata.splice(i, 1);
|
|
|
|
}
|
|
|
|
initForeignServers(Player.getHomeComputer());
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Sleeves (already added in game initializers section)
|
|
|
|
Player.sleeves[0].installAugmentation(Augmentations[AugmentationName.BionicArms]);
|
|
|
|
Player.sleeves[0].startWork(new SleeveCrimeWork(CrimeType.homicide));
|
|
|
|
|
|
|
|
// Factions
|
|
|
|
const bladeburnerFaction = Factions[FactionName.Bladeburners];
|
|
|
|
const csec = Factions[FactionName.CyberSec];
|
|
|
|
const slumSnakes = Factions[FactionName.SlumSnakes];
|
|
|
|
joinFaction(bladeburnerFaction);
|
|
|
|
joinFaction(csec);
|
|
|
|
joinFaction(slumSnakes);
|
|
|
|
csec.playerReputation = 1e6;
|
2024-05-28 21:04:16 +02:00
|
|
|
csec.setFavor(20);
|
2023-06-24 16:08:21 +02:00
|
|
|
|
2023-07-11 15:23:17 +02:00
|
|
|
// Companies
|
|
|
|
const noodleBar = Companies[CompanyName.NoodleBar];
|
2024-05-28 21:04:16 +02:00
|
|
|
noodleBar.setFavor(100);
|
2023-07-11 15:23:17 +02:00
|
|
|
noodleBar.playerReputation = 100000;
|
|
|
|
|
2023-06-24 16:08:21 +02:00
|
|
|
// Bladeburner. Adding rank will also add bladeburner faction rep.
|
|
|
|
Player.startBladeburner();
|
|
|
|
Player.bladeburner?.changeRank(Player, 2000);
|
|
|
|
|
|
|
|
// Corp
|
|
|
|
Player.startCorporation("Test Corp", false);
|
|
|
|
|
|
|
|
// Gang
|
|
|
|
Player.startGang(FactionName.SlumSnakes, false);
|
|
|
|
}
|