🧐 (engine) Store version in engine's JSON
This commit is contained in:
parent
d59baa96e5
commit
b7035b8aee
3 changed files with 16 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { AssertionError } from "assert";
|
||||
import { expect } from "chai";
|
||||
import { BoardAction, Booster, PlayerEnum } from "..";
|
||||
import { version } from "../package.json";
|
||||
import Engine, { createMoveToShow } from "./engine";
|
||||
import { Command, Condition, Operator, Phase, Planet, Player } from "./enums";
|
||||
import PlayerData from "./player-data";
|
||||
|
|
@ -308,6 +309,7 @@ describe("Engine", () => {
|
|||
baseLine.players[Player.Player2].data.ores,
|
||||
"Error loading move " + move
|
||||
);
|
||||
expect(state.version).to.equal(version);
|
||||
}
|
||||
|
||||
const endEngine = Engine.fromData(state);
|
||||
|
|
@ -333,6 +335,15 @@ describe("Engine", () => {
|
|||
expect(() => Engine.fromData(JSON.parse(JSON.stringify(new Engine())))).to.not.throw();
|
||||
});
|
||||
|
||||
it("should keep version info", () => {
|
||||
expect(Engine.fromData(null).version).to.be.undefined;
|
||||
expect(Engine.fromData(JSON.parse(JSON.stringify(new Engine()))).version).to.equal(version);
|
||||
|
||||
const engine = new Engine();
|
||||
engine.version = "1.0.0";
|
||||
expect(Engine.fromData(JSON.parse(JSON.stringify(engine))).version).to.equal("1.0.0");
|
||||
});
|
||||
|
||||
describe("transform board actions for older games", () => {
|
||||
const tests: {
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import assert from "assert";
|
||||
import { isEqual, range, set, uniq } from "lodash";
|
||||
import shuffleSeed from "shuffle-seed";
|
||||
import { version } from "../package.json";
|
||||
import { boardActions } from "./actions";
|
||||
import { finalRankings, gainFinalScoringVictoryPoints } from "./algorithms/scoring";
|
||||
import { ChargeDecision, ChargeRequest, decideChargeRequest } from "./auto-charge";
|
||||
|
|
@ -150,6 +151,7 @@ export default class Engine {
|
|||
phase: Phase = Phase.SetupInit;
|
||||
subPhase: SubPhase = SubPhase.BeforeMove;
|
||||
oldPhase: Phase;
|
||||
version = version;
|
||||
|
||||
get expansions() {
|
||||
return 0;
|
||||
|
|
@ -586,6 +588,7 @@ export default class Engine {
|
|||
|
||||
static fromData(data: Record<string, any>) {
|
||||
const engine = new Engine();
|
||||
delete engine.version;
|
||||
|
||||
if (!data) {
|
||||
return engine;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
"sourceMap": true /* Generates corresponding '.map' file. */,
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist" /* Redirect output structure to the directory. */
|
||||
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"types": ["node"],
|
||||
"include": ["src/**/*.ts", "index.ts", "wrapper.ts"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue