break_eternity and eternal_notations. cmd line option for time
This commit is contained in:
@@ -12,7 +12,11 @@
|
||||
"license": "ISC",
|
||||
"type": "commonjs",
|
||||
"dependencies": {
|
||||
"@formatjs/intl-durationformat": "^0.10.1",
|
||||
"@idle-economy/engine": "*",
|
||||
"@formatjs/intl-durationformat": "^0.10.1"
|
||||
"command-line-args": "^6.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/command-line-args": "^5.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const durationFormat = new DurationFormat("en", { style: "short" });
|
||||
|
||||
export type SimulationStats = {
|
||||
actions: Action[],
|
||||
finalTime: number;
|
||||
finalSnapshot: GameSnapshot,
|
||||
}
|
||||
|
||||
@@ -50,6 +51,7 @@ export class Simulator {
|
||||
time += deltaTime;
|
||||
}
|
||||
|
||||
stats.finalTime = time;
|
||||
stats.finalSnapshot = this.makeGameSnapshot();
|
||||
|
||||
this.log(time, "done");
|
||||
@@ -82,8 +84,8 @@ export class Simulator {
|
||||
lastTime = action.time;
|
||||
maxDeltaTime = Math.max(maxDeltaTime, deltaTime);
|
||||
}
|
||||
this.log(0, `max action wait fime is ${maxDeltaTime}`)
|
||||
this.log(0, `final data:: ${JSON.stringify(stats.finalSnapshot, undefined, 2)}`);
|
||||
this.log(stats.finalTime, `max action wait fime is ${maxDeltaTime}`)
|
||||
this.log(stats.finalTime, `final data: ${JSON.stringify(stats.finalSnapshot, undefined, 2)}`);
|
||||
}
|
||||
|
||||
private logResources(time: number, resources: ResourceSet): void {
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import { makeGame } from '@idle-economy/engine';
|
||||
import { Simulator } from './Simulator'
|
||||
import { Player } from './player/Player';
|
||||
import commandLineArgs from 'command-line-args'
|
||||
|
||||
process.on('SIGTERM', () => {
|
||||
// Clean up resources and exit
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
const optionDefinitions: commandLineArgs.OptionDefinition[] = [
|
||||
{ name: 'time', alias: 't', type: Number, defaultValue: 60 },
|
||||
];
|
||||
const options = commandLineArgs(optionDefinitions);
|
||||
|
||||
const game = makeGame();
|
||||
|
||||
const player = new Player(game);
|
||||
|
||||
const simulator = new Simulator(player);
|
||||
simulator.simulate(3600);
|
||||
simulator.simulate(options.time);
|
||||
|
||||
Reference in New Issue
Block a user