labag 2.0.3 → 2.1.1
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 +3 -1
- package/dist/index.js +2 -1
- package/dist/labag.js +3 -6
- package/dist/mode.js +0 -3
- package/dist/test.js +10 -13
- package/package.json +1 -1
- package/src/index.ts +9 -2
- package/src/labag.ts +3 -6
- package/src/mode.ts +0 -3
- package/src/test.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { LaBaG } from "./labag";
|
|
2
|
+
import { ModeName } from "./modes";
|
|
3
|
+
import { LaBaGEvent, Pattern, PatternName } from "./types";
|
|
2
4
|
declare const labag: LaBaG;
|
|
3
|
-
export
|
|
5
|
+
export { labag, type LaBaGEvent, type Pattern, type PatternName, type ModeName, };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.labag = void 0;
|
|
3
4
|
const labag_1 = require("./labag");
|
|
4
5
|
const modes_1 = require("./modes");
|
|
5
6
|
const labag = new labag_1.LaBaG();
|
|
7
|
+
exports.labag = labag;
|
|
6
8
|
modes_1.modeList.forEach((mode) => {
|
|
7
9
|
console.log(mode);
|
|
8
10
|
if (mode.active) {
|
|
@@ -12,4 +14,3 @@ modes_1.modeList.forEach((mode) => {
|
|
|
12
14
|
labag.addMode(mode);
|
|
13
15
|
}
|
|
14
16
|
});
|
|
15
|
-
exports.default = labag;
|
package/dist/labag.js
CHANGED
|
@@ -85,8 +85,7 @@ class LaBaG {
|
|
|
85
85
|
getCurrentConfig() {
|
|
86
86
|
const activeModes = this.modes.filter((m) => m.active);
|
|
87
87
|
if (activeModes.length === 0) {
|
|
88
|
-
|
|
89
|
-
return { modes: activeModes, ranges: [] };
|
|
88
|
+
throw new Error("目前沒有啟用中的模式,無法轉動拉霸機。");
|
|
90
89
|
}
|
|
91
90
|
// 合併所有啟用中模式的機率設定
|
|
92
91
|
const combinedRates = {
|
|
@@ -164,8 +163,7 @@ class LaBaG {
|
|
|
164
163
|
calculateScore() {
|
|
165
164
|
const [p1, p2, p3] = this.patterns;
|
|
166
165
|
if (!p1 || !p2 || !p3) {
|
|
167
|
-
|
|
168
|
-
return;
|
|
166
|
+
throw new Error("圖案未正確生成,無法計算分數。");
|
|
169
167
|
}
|
|
170
168
|
if (p1.name === p2.name && p2.name === p3.name) {
|
|
171
169
|
// 三個圖案相同
|
|
@@ -207,8 +205,7 @@ class LaBaG {
|
|
|
207
205
|
}
|
|
208
206
|
play() {
|
|
209
207
|
if (!this.isRunning()) {
|
|
210
|
-
|
|
211
|
-
return;
|
|
208
|
+
throw new Error("遊戲次數已達上限,無法繼續遊玩。");
|
|
212
209
|
}
|
|
213
210
|
this.roundStart();
|
|
214
211
|
this.rollSlots();
|
package/dist/mode.js
CHANGED
package/dist/test.js
CHANGED
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const index_1 =
|
|
7
|
-
index_1.
|
|
3
|
+
const index_1 = require("./index");
|
|
4
|
+
index_1.labag.addEventListener("gameStart", (game) => {
|
|
8
5
|
console.log("Game Started!");
|
|
9
6
|
console.log(`Total Rounds: ${game.times}\n`);
|
|
10
7
|
});
|
|
11
|
-
index_1.
|
|
8
|
+
index_1.labag.addEventListener("roundStart", (game) => {
|
|
12
9
|
console.log(`--- Round ${game.rounds} Start ---`);
|
|
13
10
|
});
|
|
14
|
-
index_1.
|
|
11
|
+
index_1.labag.addEventListener("rollSlots", (game) => {
|
|
15
12
|
const { modes, ranges } = game.getCurrentConfig();
|
|
16
13
|
console.log(`Active Modes: ${modes.map((m) => m.name).join(", ")}`);
|
|
17
14
|
console.log(`Probability Ranges: ${ranges
|
|
18
15
|
.map((r) => `${r.pattern.name}<=${r.threshold}`)
|
|
19
16
|
.join(", ")}`);
|
|
20
17
|
});
|
|
21
|
-
index_1.
|
|
18
|
+
index_1.labag.addEventListener("roundEnd", (game) => {
|
|
22
19
|
console.log(game.patterns.map((p) => (p ? p.name : "null")).join(" | "));
|
|
23
20
|
console.log(`Margin Score: ${game.marginScore}`);
|
|
24
21
|
console.log(`Score: ${game.score}\n`);
|
|
25
22
|
});
|
|
26
|
-
index_1.
|
|
27
|
-
while (index_1.
|
|
28
|
-
index_1.
|
|
23
|
+
index_1.labag.init();
|
|
24
|
+
while (index_1.labag.isRunning()) {
|
|
25
|
+
index_1.labag.play();
|
|
29
26
|
}
|
|
30
27
|
console.log("Game Over");
|
|
31
|
-
console.log(`Final Score: ${index_1.
|
|
32
|
-
console.log(`Active Modes at end: ${index_1.
|
|
28
|
+
console.log(`Final Score: ${index_1.labag.score}`);
|
|
29
|
+
console.log(`Active Modes at end: ${index_1.labag
|
|
33
30
|
.getCurrentConfig()
|
|
34
31
|
.modes.map((m) => m.name)
|
|
35
32
|
.join(", ")}`);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LaBaG } from "./labag";
|
|
2
|
-
import { modeList } from "./modes";
|
|
2
|
+
import { modeList, ModeName } from "./modes";
|
|
3
|
+
import { LaBaGEvent, Pattern, PatternName } from "./types";
|
|
3
4
|
|
|
4
5
|
const labag = new LaBaG();
|
|
5
6
|
modeList.forEach((mode) => {
|
|
@@ -10,4 +11,10 @@ modeList.forEach((mode) => {
|
|
|
10
11
|
labag.addMode(mode);
|
|
11
12
|
}
|
|
12
13
|
});
|
|
13
|
-
export
|
|
14
|
+
export {
|
|
15
|
+
labag,
|
|
16
|
+
type LaBaGEvent,
|
|
17
|
+
type Pattern,
|
|
18
|
+
type PatternName,
|
|
19
|
+
type ModeName,
|
|
20
|
+
};
|
package/src/labag.ts
CHANGED
|
@@ -93,8 +93,7 @@ export class LaBaG {
|
|
|
93
93
|
getCurrentConfig() {
|
|
94
94
|
const activeModes = this.modes.filter((m) => m.active);
|
|
95
95
|
if (activeModes.length === 0) {
|
|
96
|
-
|
|
97
|
-
return { modes: activeModes, ranges: [] };
|
|
96
|
+
throw new Error("目前沒有啟用中的模式,無法轉動拉霸機。");
|
|
98
97
|
}
|
|
99
98
|
// 合併所有啟用中模式的機率設定
|
|
100
99
|
const combinedRates: Record<PatternName, number> = {
|
|
@@ -180,8 +179,7 @@ export class LaBaG {
|
|
|
180
179
|
private calculateScore() {
|
|
181
180
|
const [p1, p2, p3] = this.patterns;
|
|
182
181
|
if (!p1 || !p2 || !p3) {
|
|
183
|
-
|
|
184
|
-
return;
|
|
182
|
+
throw new Error("圖案未正確生成,無法計算分數。");
|
|
185
183
|
}
|
|
186
184
|
if (p1.name === p2.name && p2.name === p3.name) {
|
|
187
185
|
// 三個圖案相同
|
|
@@ -225,8 +223,7 @@ export class LaBaG {
|
|
|
225
223
|
|
|
226
224
|
play() {
|
|
227
225
|
if (!this.isRunning()) {
|
|
228
|
-
|
|
229
|
-
return;
|
|
226
|
+
throw new Error("遊戲次數已達上限,無法繼續遊玩。");
|
|
230
227
|
}
|
|
231
228
|
this.roundStart();
|
|
232
229
|
this.rollSlots();
|
package/src/mode.ts
CHANGED
package/src/test.ts
CHANGED