labag 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -3
- package/dist/labag.d.ts +45 -35
- package/dist/labag.js +132 -94
- package/dist/mode.d.ts +32 -10
- package/dist/mode.js +29 -6
- package/dist/modes/greenwei.d.ts +1 -1
- package/dist/modes/greenwei.js +80 -74
- package/dist/modes/index.d.ts +8 -10
- package/dist/modes/index.js +3 -9
- package/dist/modes/pikachu.d.ts +1 -1
- package/dist/modes/pikachu.js +41 -35
- package/dist/modes/superhhh.d.ts +1 -1
- package/dist/modes/superhhh.js +72 -66
- package/dist/recordChecker.js +13 -13
- package/dist/test.js +7 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/index.ts +6 -5
- package/src/labag.ts +143 -107
- package/src/mode.ts +37 -18
- package/src/modes/greenwei.ts +9 -9
- package/src/modes/index.ts +2 -11
- package/src/modes/pikachu.ts +10 -10
- package/src/modes/superhhh.ts +9 -9
- package/src/recordChecker.ts +14 -15
- package/src/test.ts +13 -4
- package/src/types/index.ts +3 -0
- package/src/modes/normal.ts +0 -10
package/dist/modes/greenwei.js
CHANGED
|
@@ -3,87 +3,93 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const pattern_1 = require("../pattern");
|
|
4
4
|
const mode_1 = require("../mode");
|
|
5
5
|
const randInt_1 = require("../utils/randInt");
|
|
6
|
-
exports.default = new mode_1.Mode(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
mode.variable.times = 0;
|
|
17
|
-
mode.variable.count = 0;
|
|
6
|
+
exports.default = new mode_1.Mode({
|
|
7
|
+
active: false,
|
|
8
|
+
name: "greenwei",
|
|
9
|
+
rates: {
|
|
10
|
+
gss: 0,
|
|
11
|
+
hhh: 0,
|
|
12
|
+
hentai: 0,
|
|
13
|
+
handson: 0,
|
|
14
|
+
kachu: 0,
|
|
15
|
+
rrr: 0,
|
|
18
16
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let allGSS = true;
|
|
37
|
-
for (const p of patterns) {
|
|
38
|
-
if (p?.name === mode.variable.bindPattern.name) {
|
|
39
|
-
gssCount++;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
allGSS = false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
variable.count += gssCount;
|
|
46
|
-
if (mode.active) {
|
|
47
|
-
if (allGSS) {
|
|
48
|
-
variable.times += mode.variable.extendTimes;
|
|
49
|
-
}
|
|
50
|
-
if (variable.times <= 0) {
|
|
51
|
-
mode.active = false;
|
|
17
|
+
eventListener: {
|
|
18
|
+
gameStart: (_, mode) => {
|
|
19
|
+
mode.active = false;
|
|
20
|
+
mode.variable.times = 0;
|
|
21
|
+
mode.variable.count = 0;
|
|
22
|
+
},
|
|
23
|
+
roundStart: (_, mode) => {
|
|
24
|
+
if (!mode.active)
|
|
25
|
+
return;
|
|
26
|
+
mode.variable.times -= 1;
|
|
27
|
+
},
|
|
28
|
+
rollSlots: (_, mode) => {
|
|
29
|
+
mode.variable.randNum = (0, randInt_1.randInt)(1, 100);
|
|
30
|
+
},
|
|
31
|
+
calculateScore: (game, mode) => {
|
|
32
|
+
if (mode.active) {
|
|
33
|
+
game.marginScore = Math.round(game.marginScore * mode.variable.mutiplier);
|
|
52
34
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
},
|
|
36
|
+
roundEnd: (game, mode) => {
|
|
37
|
+
const { patterns } = game;
|
|
38
|
+
const { variable } = mode;
|
|
39
|
+
let gssCount = 0;
|
|
40
|
+
let allGSS = true;
|
|
41
|
+
for (const p of patterns) {
|
|
42
|
+
if (p?.name === mode.variable.bindPattern.name) {
|
|
43
|
+
gssCount++;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
allGSS = false;
|
|
47
|
+
}
|
|
59
48
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
variable.count += gssCount;
|
|
50
|
+
if (mode.active) {
|
|
51
|
+
if (allGSS) {
|
|
52
|
+
variable.times += mode.variable.extendTimes;
|
|
53
|
+
}
|
|
54
|
+
if (variable.times <= 0) {
|
|
55
|
+
mode.active = false;
|
|
56
|
+
}
|
|
64
57
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
if (!mode.active) {
|
|
59
|
+
let activated = false;
|
|
60
|
+
if (variable.randNum <= variable.rate && allGSS) {
|
|
61
|
+
activated = true;
|
|
62
|
+
variable.times += mode.variable.extendTimes;
|
|
63
|
+
}
|
|
64
|
+
else if (variable.count >= mode.variable.requiredBindPatternCount) {
|
|
65
|
+
activated = true;
|
|
66
|
+
variable.times += mode.variable.bonusTimes;
|
|
67
|
+
variable.count -= mode.variable.requiredBindPatternCount;
|
|
68
|
+
}
|
|
69
|
+
if (activated) {
|
|
70
|
+
mode.active = true;
|
|
71
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
72
|
+
if (patterns[i]?.name === mode.variable.bindPattern.name) {
|
|
73
|
+
patterns[i] = variable.pattern;
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
|
-
}
|
|
78
|
+
},
|
|
74
79
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
variable: {
|
|
81
|
+
times: 0,
|
|
82
|
+
rate: 35,
|
|
83
|
+
randNum: 0,
|
|
84
|
+
count: 0,
|
|
85
|
+
pattern: {
|
|
86
|
+
name: "greenwei",
|
|
87
|
+
scores: [800, 400, 180],
|
|
88
|
+
},
|
|
89
|
+
extendTimes: 2,
|
|
90
|
+
bindPattern: pattern_1.patterns[0],
|
|
91
|
+
bonusTimes: 2,
|
|
92
|
+
requiredBindPatternCount: 20,
|
|
93
|
+
mutiplier: 3,
|
|
83
94
|
},
|
|
84
|
-
extendTimes: 2,
|
|
85
|
-
bindPattern: pattern_1.patterns[0],
|
|
86
|
-
bonusTimes: 2,
|
|
87
|
-
requiredBindPatternCount: 20,
|
|
88
|
-
mutiplier: 3,
|
|
89
95
|
});
|
package/dist/modes/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const _modes: {
|
|
2
2
|
pikachu: import("..").Mode<{
|
|
3
3
|
times: number;
|
|
4
4
|
pattern: {
|
|
@@ -10,7 +10,7 @@ export declare const modes: {
|
|
|
10
10
|
readonly scores: [12000, 8000, 1250];
|
|
11
11
|
};
|
|
12
12
|
bonusRounds: number;
|
|
13
|
-
}>;
|
|
13
|
+
}, "pikachu">;
|
|
14
14
|
superhhh: import("..").Mode<{
|
|
15
15
|
times: number;
|
|
16
16
|
rate: number;
|
|
@@ -26,7 +26,7 @@ export declare const modes: {
|
|
|
26
26
|
scores: number[];
|
|
27
27
|
};
|
|
28
28
|
extendTimes: number;
|
|
29
|
-
}>;
|
|
29
|
+
}, "superhhh">;
|
|
30
30
|
greenwei: import("..").Mode<{
|
|
31
31
|
times: number;
|
|
32
32
|
rate: number;
|
|
@@ -44,11 +44,9 @@ export declare const modes: {
|
|
|
44
44
|
bonusTimes: number;
|
|
45
45
|
requiredBindPatternCount: number;
|
|
46
46
|
mutiplier: number;
|
|
47
|
-
}>;
|
|
48
|
-
normal: import("..").Mode<Record<string, any>>;
|
|
47
|
+
}, "greenwei">;
|
|
49
48
|
};
|
|
50
|
-
export
|
|
51
|
-
export declare const modeList: (import("..").Mode<{
|
|
49
|
+
export declare const modes: (import("..").Mode<{
|
|
52
50
|
times: number;
|
|
53
51
|
rate: number;
|
|
54
52
|
randNum: number;
|
|
@@ -65,7 +63,7 @@ export declare const modeList: (import("..").Mode<{
|
|
|
65
63
|
bonusTimes: number;
|
|
66
64
|
requiredBindPatternCount: number;
|
|
67
65
|
mutiplier: number;
|
|
68
|
-
}
|
|
66
|
+
}, "greenwei"> | import("..").Mode<{
|
|
69
67
|
times: number;
|
|
70
68
|
pattern: {
|
|
71
69
|
name: string;
|
|
@@ -76,7 +74,7 @@ export declare const modeList: (import("..").Mode<{
|
|
|
76
74
|
readonly scores: [12000, 8000, 1250];
|
|
77
75
|
};
|
|
78
76
|
bonusRounds: number;
|
|
79
|
-
}> | import("..").Mode<{
|
|
77
|
+
}, "pikachu"> | import("..").Mode<{
|
|
80
78
|
times: number;
|
|
81
79
|
rate: number;
|
|
82
80
|
score: number;
|
|
@@ -91,4 +89,4 @@ export declare const modeList: (import("..").Mode<{
|
|
|
91
89
|
scores: number[];
|
|
92
90
|
};
|
|
93
91
|
extendTimes: number;
|
|
94
|
-
}>)[];
|
|
92
|
+
}, "superhhh">)[];
|
package/dist/modes/index.js
CHANGED
|
@@ -3,15 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.modes = exports._modes = void 0;
|
|
7
7
|
const greenwei_1 = __importDefault(require("./greenwei"));
|
|
8
|
-
const normal_1 = __importDefault(require("./normal"));
|
|
9
8
|
const pikachu_1 = __importDefault(require("./pikachu"));
|
|
10
9
|
const superhhh_1 = __importDefault(require("./superhhh"));
|
|
11
|
-
exports.
|
|
12
|
-
|
|
13
|
-
superhhh: superhhh_1.default,
|
|
14
|
-
greenwei: greenwei_1.default,
|
|
15
|
-
normal: normal_1.default,
|
|
16
|
-
};
|
|
17
|
-
exports.modeList = Object.values(exports.modes);
|
|
10
|
+
exports._modes = { pikachu: pikachu_1.default, superhhh: superhhh_1.default, greenwei: greenwei_1.default };
|
|
11
|
+
exports.modes = Object.values(exports._modes);
|
package/dist/modes/pikachu.d.ts
CHANGED
package/dist/modes/pikachu.js
CHANGED
|
@@ -2,42 +2,48 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const pattern_1 = require("../pattern");
|
|
4
4
|
const mode_1 = require("../mode");
|
|
5
|
-
exports.default = new mode_1.Mode(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
mode.variable.times = 0;
|
|
5
|
+
exports.default = new mode_1.Mode({
|
|
6
|
+
active: false,
|
|
7
|
+
name: "pikachu",
|
|
8
|
+
rates: {
|
|
9
|
+
gss: 0,
|
|
10
|
+
hhh: 0,
|
|
11
|
+
hentai: 0,
|
|
12
|
+
handson: 0,
|
|
13
|
+
kachu: 0,
|
|
14
|
+
rrr: 0,
|
|
16
15
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
patterns.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
eventListener: {
|
|
17
|
+
gameStart: (_, mode) => {
|
|
18
|
+
mode.active = false;
|
|
19
|
+
mode.variable.times = 0;
|
|
20
|
+
},
|
|
21
|
+
roundEnd: (game, mode) => {
|
|
22
|
+
const { patterns } = game;
|
|
23
|
+
const hasBindPattern = patterns.some((p) => p && p.name === mode.variable.bindPattern.name);
|
|
24
|
+
if (!game.isRunning && hasBindPattern) {
|
|
25
|
+
mode.active = true;
|
|
26
|
+
game.played -= mode.variable.bonusRounds;
|
|
27
|
+
mode.variable.times += 1;
|
|
28
|
+
patterns.forEach((p, i) => {
|
|
29
|
+
if (p?.name === mode.variable.bindPattern.name) {
|
|
30
|
+
patterns[i] = mode.variable.pattern;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (mode.active && hasBindPattern) {
|
|
36
|
+
game.played -= Math.min(mode.variable.times, mode.variable.bonusRounds);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
34
39
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
variable: {
|
|
41
|
+
times: 0,
|
|
42
|
+
pattern: {
|
|
43
|
+
name: "pikachu",
|
|
44
|
+
scores: [12000, 8000, 1250],
|
|
45
|
+
},
|
|
46
|
+
bindPattern: pattern_1.patterns[4],
|
|
47
|
+
bonusRounds: 3,
|
|
40
48
|
},
|
|
41
|
-
bindPattern: pattern_1.patterns[4],
|
|
42
|
-
bonusRounds: 3,
|
|
43
49
|
});
|
package/dist/modes/superhhh.d.ts
CHANGED
package/dist/modes/superhhh.js
CHANGED
|
@@ -3,78 +3,84 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const pattern_1 = require("../pattern");
|
|
4
4
|
const mode_1 = require("../mode");
|
|
5
5
|
const randInt_1 = require("../utils/randInt");
|
|
6
|
-
exports.default = new mode_1.Mode(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
mode.variable.times = 0;
|
|
17
|
-
mode.variable.score = 0;
|
|
6
|
+
exports.default = new mode_1.Mode({
|
|
7
|
+
active: false,
|
|
8
|
+
name: "superhhh",
|
|
9
|
+
rates: {
|
|
10
|
+
gss: -19, // 36 -> 17
|
|
11
|
+
hhh: -19, // 24 -> 5
|
|
12
|
+
hentai: 1, // 17 -> 18
|
|
13
|
+
handson: 7, // 12 -> 19
|
|
14
|
+
kachu: 12, // 8 -> 20
|
|
15
|
+
rrr: 18, // 3 -> 21
|
|
18
16
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
mode.variable.randNum
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let allHHH = true;
|
|
42
|
-
for (const p of patterns) {
|
|
43
|
-
if (p?.name === mode.variable.bindPattern.name)
|
|
44
|
-
hhhCount++;
|
|
45
|
-
else
|
|
46
|
-
allHHH = false;
|
|
47
|
-
}
|
|
48
|
-
if (mode.active) {
|
|
49
|
-
if (allHHH) {
|
|
50
|
-
variable.times += mode.variable.extendTimes;
|
|
17
|
+
eventListener: {
|
|
18
|
+
gameStart: (_, mode) => {
|
|
19
|
+
mode.active = false;
|
|
20
|
+
mode.variable.times = 0;
|
|
21
|
+
mode.variable.score = 0;
|
|
22
|
+
},
|
|
23
|
+
roundStart: (_, mode) => {
|
|
24
|
+
if (!mode.active)
|
|
25
|
+
return;
|
|
26
|
+
mode.variable.score = 0;
|
|
27
|
+
mode.variable.times -= 1;
|
|
28
|
+
},
|
|
29
|
+
rollSlots: (_, mode) => {
|
|
30
|
+
mode.variable.randNum = (0, randInt_1.randInt)(1, 100);
|
|
31
|
+
},
|
|
32
|
+
calculateScore: (game, mode) => {
|
|
33
|
+
if (mode.active)
|
|
34
|
+
return;
|
|
35
|
+
if (game.patterns.every((p) => p?.name === mode.variable.bindPattern.name) &&
|
|
36
|
+
mode.variable.randNum <= mode.variable.rate) {
|
|
37
|
+
mode.variable.score += Math.round(game.score / 2);
|
|
38
|
+
game.marginScore += mode.variable.score;
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
},
|
|
41
|
+
roundEnd: (game, mode) => {
|
|
42
|
+
const { patterns } = game;
|
|
43
|
+
const { variable } = mode;
|
|
44
|
+
let hhhCount = 0;
|
|
45
|
+
let allHHH = true;
|
|
46
|
+
for (const p of patterns) {
|
|
47
|
+
if (p?.name === mode.variable.bindPattern.name)
|
|
48
|
+
hhhCount++;
|
|
49
|
+
else
|
|
50
|
+
allHHH = false;
|
|
51
|
+
}
|
|
52
|
+
if (mode.active) {
|
|
53
|
+
if (allHHH) {
|
|
54
|
+
variable.times += mode.variable.extendTimes;
|
|
55
|
+
}
|
|
56
|
+
if (variable.times <= 0) {
|
|
57
|
+
mode.active = false;
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if (!mode.active) {
|
|
61
|
+
if (variable.randNum <= variable.rate && hhhCount > 0) {
|
|
62
|
+
mode.active = true;
|
|
63
|
+
variable.times += variable.bonusTimes;
|
|
64
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
65
|
+
if (patterns[i]?.name === mode.variable.bindPattern.name) {
|
|
66
|
+
patterns[i] = variable.pattern;
|
|
67
|
+
}
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
|
-
}
|
|
71
|
+
},
|
|
67
72
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
variable: {
|
|
74
|
+
times: 0,
|
|
75
|
+
rate: 15,
|
|
76
|
+
score: 0,
|
|
77
|
+
randNum: 0,
|
|
78
|
+
bindPattern: pattern_1.patterns[1],
|
|
79
|
+
bonusTimes: 6,
|
|
80
|
+
pattern: {
|
|
81
|
+
name: "superhhh",
|
|
82
|
+
scores: [1500, 800, 300],
|
|
83
|
+
},
|
|
84
|
+
extendTimes: 2,
|
|
78
85
|
},
|
|
79
|
-
extendTimes: 2,
|
|
80
86
|
});
|
package/dist/recordChecker.js
CHANGED
|
@@ -25,12 +25,14 @@ class RecordChecker {
|
|
|
25
25
|
this.game.init();
|
|
26
26
|
this.game.times = record.times;
|
|
27
27
|
for (const round of record.rounds) {
|
|
28
|
-
if (!this.game.isRunning
|
|
29
|
-
|
|
28
|
+
if (!this.game.isRunning) {
|
|
29
|
+
break;
|
|
30
30
|
}
|
|
31
31
|
// 1. 回合開始
|
|
32
|
-
this.game
|
|
33
|
-
// 2.
|
|
32
|
+
this.game.roundStart();
|
|
33
|
+
// 2. 觸發 rollSlots 事件,這會執行所有模式的隨機邏輯
|
|
34
|
+
this.game.rollSlots();
|
|
35
|
+
// 3. 覆蓋隨機數字與圖案 (確保使用紀錄中的數值)
|
|
34
36
|
const { ranges } = this.game.getCurrentConfig();
|
|
35
37
|
for (let i = 0; i < 3; i++) {
|
|
36
38
|
const num = round.randNums?.[i.toString()] ?? 0;
|
|
@@ -38,22 +40,20 @@ class RecordChecker {
|
|
|
38
40
|
const match = ranges.find((r) => num <= r.threshold);
|
|
39
41
|
this.game.patterns[i] = match ? match.pattern : null;
|
|
40
42
|
}
|
|
41
|
-
//
|
|
42
|
-
this.game["emit"]("rollSlots");
|
|
43
|
-
// 3. 覆蓋模式的隨機變數 (確保使用紀錄中的數值)
|
|
43
|
+
// 4. 覆蓋模式的隨機變數 (確保使用紀錄中的數值)
|
|
44
44
|
this.game.modes.forEach((mode) => {
|
|
45
45
|
const recordedNum = round.randNums?.[mode.name];
|
|
46
46
|
if (recordedNum !== undefined && mode.variable) {
|
|
47
47
|
mode.variable.randNum = recordedNum;
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
//
|
|
51
|
-
this.game
|
|
52
|
-
//
|
|
53
|
-
this.game
|
|
50
|
+
// 5. 計算分數
|
|
51
|
+
this.game.calculateScore();
|
|
52
|
+
// 6. 回合結束
|
|
53
|
+
this.game.roundEnd();
|
|
54
54
|
}
|
|
55
|
-
if (!this.game.isRunning
|
|
56
|
-
this.game
|
|
55
|
+
if (!this.game.isRunning) {
|
|
56
|
+
this.game.gameOver();
|
|
57
57
|
}
|
|
58
58
|
return this.game.score;
|
|
59
59
|
}
|
package/dist/test.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const index_1 = require("./index");
|
|
4
|
+
const index_2 = require("./index");
|
|
4
5
|
index_1.labag.addEventListener("gameStart", (game) => {
|
|
5
6
|
console.log("Game Started!");
|
|
6
7
|
console.log(`Total Rounds: ${game.times}\n`);
|
|
@@ -21,7 +22,8 @@ index_1.labag.addEventListener("roundEnd", (game) => {
|
|
|
21
22
|
console.log(`Score: ${game.score}\n`);
|
|
22
23
|
});
|
|
23
24
|
index_1.labag.init();
|
|
24
|
-
|
|
25
|
+
index_2.recorder.init();
|
|
26
|
+
while (index_1.labag.isRunning) {
|
|
25
27
|
index_1.labag.play();
|
|
26
28
|
}
|
|
27
29
|
console.log("Game Over");
|
|
@@ -30,3 +32,7 @@ console.log(`Active Modes at end: ${index_1.labag
|
|
|
30
32
|
.getCurrentConfig()
|
|
31
33
|
.modes.map((m) => m.name)
|
|
32
34
|
.join(", ")}`);
|
|
35
|
+
console.log(`record: ${JSON.stringify(index_2.recorder.getRecord(), null, 2)}`);
|
|
36
|
+
console.log(index_1.checker.check(index_2.recorder.getRecord())
|
|
37
|
+
? "Record is valid!"
|
|
38
|
+
: "Record is invalid!");
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modes } from "src/modes";
|
|
1
2
|
import { patterns } from "src/pattern";
|
|
2
3
|
/**
|
|
3
4
|
* 拉霸遊戲的事件類型。
|
|
@@ -16,3 +17,4 @@ export type Pattern = {
|
|
|
16
17
|
* 圖案名稱的型別。
|
|
17
18
|
*/
|
|
18
19
|
export type PatternName = (typeof patterns)[number]["name"];
|
|
20
|
+
export type ModeName = (typeof modes)[number]["name"] | "normal";
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { LaBaG } from "./labag";
|
|
2
|
-
import {
|
|
2
|
+
import { modes } from "./modes";
|
|
3
3
|
import { LaBaGEvent, Pattern, PatternName } from "./types";
|
|
4
4
|
import { Mode } from "./mode";
|
|
5
5
|
import { patterns } from "./pattern";
|
|
6
|
-
import { Recorder, GameRecord } from
|
|
6
|
+
import { Recorder, GameRecord } from "./recorder";
|
|
7
7
|
import { RecordChecker } from "./recordChecker";
|
|
8
|
+
import { ModeName } from "./types/index";
|
|
8
9
|
|
|
9
10
|
const labag = new LaBaG();
|
|
10
|
-
|
|
11
|
+
modes.forEach((mode) => {
|
|
11
12
|
labag.addMode(mode);
|
|
12
13
|
});
|
|
13
14
|
const recorder = new Recorder(labag);
|
|
@@ -16,7 +17,7 @@ export {
|
|
|
16
17
|
labag,
|
|
17
18
|
recorder,
|
|
18
19
|
checker,
|
|
19
|
-
|
|
20
|
+
modes,
|
|
20
21
|
patterns,
|
|
21
22
|
LaBaG,
|
|
22
23
|
Recorder,
|
|
@@ -25,6 +26,6 @@ export {
|
|
|
25
26
|
type LaBaGEvent,
|
|
26
27
|
type Pattern,
|
|
27
28
|
type PatternName,
|
|
29
|
+
type GameRecord,
|
|
28
30
|
type ModeName,
|
|
29
|
-
type GameRecord
|
|
30
31
|
};
|