This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
wrapper.spec.ts
134 lines (104 loc) · 3.88 KB
/
wrapper.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { expect } from "chai";
import Engine from "./src/engine";
import { automove, move, setPlayerSettings } from "./wrapper";
describe("wrapper", () => {
describe("automove", () => {
it("should automatically charge 1pw", () => {
const moves = Engine.parseMoves(`
init 2 randomSeed
p1 faction terrans
p2 faction nevlas
terrans build m -1x2
nevlas build m -1x0
nevlas build m 0x-4
terrans build m -4x-1
nevlas booster booster7
terrans booster booster3
terrans build ts -1x2.
`);
const engine = new Engine(moves);
automove(engine);
expect(engine.moveHistory.length).to.equal(moves.length + 1);
expect(engine.moveHistory.slice(-1).pop()).to.equal("nevlas charge 1pw");
});
it("should not automatically charge 2pw", () => {
const engine = new Engine(moves2pw);
expect(engine.moveHistory.length).to.equal(moves2pw.length);
});
it("should automatically charge 2pw when the setting is set", () => {
const engine = new Engine(moves2pw.slice(0, 5));
setPlayerSettings(engine, 0, { autoCharge: "2" });
engine.loadMoves(moves2pw.slice(5));
automove(engine);
expect(engine.moveHistory.length).to.equal(moves2pw.length + 1);
expect(engine.moveHistory.slice(-1).pop()).to.equal("terrans charge 2pw");
});
it("should automatically decline 2pw when the setting is set to 0", () => {
const engine = new Engine(moves2pw.slice(0, 5));
setPlayerSettings(engine, 0, { autoCharge: "0" });
engine.loadMoves(moves2pw.slice(5));
automove(engine);
expect(engine.moveHistory.length).to.equal(moves2pw.length + 1);
expect(engine.moveHistory.slice(-1).pop()).to.equal("terrans decline 2pw");
});
it("should be able to automatically charge 2 pw and move brainstone at the same time with correct settings", () => {
const engine = new Engine(move2pwAndBrainstone);
setPlayerSettings(engine, 0, { autoCharge: "2", autoBrainstone: true });
automove(engine);
expect(engine.moveHistory.length).to.equal(move2pwAndBrainstone.length + 1);
expect(engine.moveHistory.slice(-1)[0]).to.equal("taklons charge 2pw. brainstone area2");
});
it("should NOT be able to automatically charge 2 pw and move brainstone if only autobrainstone is set", () => {
const engine = new Engine(move2pwAndBrainstone);
setPlayerSettings(engine, 0, { autoCharge: "1", autoBrainstone: true });
automove(engine);
expect(engine.moveHistory.length).to.equal(move2pwAndBrainstone.length);
});
it("should be able to automatically move the brainstone if the player manually charges power", () => {
const engine = new Engine(move2pwAndBrainstone);
setPlayerSettings(engine, 0, { autoCharge: "1", autoBrainstone: true });
const newEngine = move(engine, "taklons charge 2pw", 0);
expect(newEngine.moveHistory.length).to.equal(move2pwAndBrainstone.length + 1);
expect(newEngine.moveHistory.slice(-1)[0]).to.equal("taklons charge 2pw. brainstone area2");
});
});
});
const moves2pw = Engine.parseMoves(`
init 4 randomSeed
p1 faction terrans
p2 faction xenos
p3 faction geodens
p4 faction nevlas
p1 build m -1x6
p2 build m -3x-1
p3 build m -4x1
p4 build m -1x3
p4 build m 1x4
p3 build m -9x6
p2 build m 1x5
p1 build m -5x4
p2 build m -8x5
p4 booster booster1
p3 booster booster2
p2 booster booster3
p1 booster booster4
p1 build ts -1x6.
p2 charge 1pw
p4 charge 1pw
p2 build ts 1x5.
p4 charge 1pw
`);
const move2pwAndBrainstone = Engine.parseMoves(`
init 2 Curious-supply-341
p1 faction taklons
p2 faction itars
taklons build m 1B1
itars build m 2B0
itars build m 4A11
taklons build m 2B3
itars booster booster2
taklons booster booster7
taklons build ts 2B3.
itars charge 1pw
itars build ts 2B0.
`);