labag 2.6.2 → 2.6.4
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 +1 -1
- package/dist/labag.d.ts +2 -2
- package/dist/labag.js +7 -3
- package/dist/modes/index.d.ts +3 -3
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/labag.ts +13 -5
- package/src/modes/index.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Mode } from "./mode";
|
|
|
5
5
|
import { patterns } from "./pattern";
|
|
6
6
|
import { Recorder, GameRecord } from "./recorder";
|
|
7
7
|
import { RecordChecker } from "./recordChecker";
|
|
8
|
-
import { ModeName } from "./types
|
|
8
|
+
import { ModeName } from "./types";
|
|
9
9
|
declare const labag: LaBaG;
|
|
10
10
|
declare const recorder: Recorder;
|
|
11
11
|
declare const checker: RecordChecker;
|
package/dist/labag.d.ts
CHANGED
|
@@ -19,10 +19,10 @@ export declare class LaBaG {
|
|
|
19
19
|
/** 當前轉出的圖案組合 */
|
|
20
20
|
patterns: [Pattern | null, Pattern | null, Pattern | null];
|
|
21
21
|
/** 遊戲模式列表 */
|
|
22
|
-
modes: Mode
|
|
22
|
+
modes: Mode[];
|
|
23
23
|
/** 事件監聽器列表 */
|
|
24
24
|
eventListeners: Record<LaBaGEvent, ((game: LaBaG) => void)[]>;
|
|
25
|
-
__defaultMode__: Mode
|
|
25
|
+
__defaultMode__: Mode;
|
|
26
26
|
constructor(times?: number);
|
|
27
27
|
/**
|
|
28
28
|
* 觸發指定事件。
|
package/dist/labag.js
CHANGED
|
@@ -86,7 +86,7 @@ class LaBaG {
|
|
|
86
86
|
game.patterns[i] = matchedPattern;
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
calculateScore: (game) => {
|
|
89
|
+
calculateScore: (game, mode) => {
|
|
90
90
|
const [p1, p2, p3] = game.patterns;
|
|
91
91
|
if (!p1 || !p2 || !p3) {
|
|
92
92
|
game.marginScore = 0;
|
|
@@ -112,20 +112,24 @@ class LaBaG {
|
|
|
112
112
|
this.marginScore += p1.scores[1];
|
|
113
113
|
this.marginScore += p2.scores[2];
|
|
114
114
|
}
|
|
115
|
-
this.marginScore = Math.round(this.marginScore /
|
|
115
|
+
this.marginScore = Math.round(this.marginScore / mode.variable.twoMatchDivisor);
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
118
|
// 三個圖案皆不同
|
|
119
119
|
this.marginScore += p1.scores[2];
|
|
120
120
|
this.marginScore += p2.scores[2];
|
|
121
121
|
this.marginScore += p3.scores[2];
|
|
122
|
-
this.marginScore = Math.round(this.marginScore /
|
|
122
|
+
this.marginScore = Math.round(this.marginScore / mode.variable.allDifferentDivisor);
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
roundEnd: (game) => {
|
|
126
126
|
game.score += game.marginScore;
|
|
127
127
|
},
|
|
128
128
|
},
|
|
129
|
+
variable: {
|
|
130
|
+
twoMatchDivisor: 1.4,
|
|
131
|
+
allDifferentDivisor: 3,
|
|
132
|
+
},
|
|
129
133
|
});
|
|
130
134
|
this.addMode(this.__defaultMode__);
|
|
131
135
|
}
|
package/dist/modes/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const _modes: {
|
|
2
|
-
pikachu: import("..").Mode<{
|
|
2
|
+
readonly pikachu: import("..").Mode<{
|
|
3
3
|
times: number;
|
|
4
4
|
pattern: {
|
|
5
5
|
name: string;
|
|
@@ -11,7 +11,7 @@ export declare const _modes: {
|
|
|
11
11
|
};
|
|
12
12
|
bonusRounds: number;
|
|
13
13
|
}, "pikachu">;
|
|
14
|
-
superhhh: import("..").Mode<{
|
|
14
|
+
readonly superhhh: import("..").Mode<{
|
|
15
15
|
times: number;
|
|
16
16
|
rate: number;
|
|
17
17
|
score: number;
|
|
@@ -27,7 +27,7 @@ export declare const _modes: {
|
|
|
27
27
|
};
|
|
28
28
|
extendTimes: number;
|
|
29
29
|
}, "superhhh">;
|
|
30
|
-
greenwei: import("..").Mode<{
|
|
30
|
+
readonly greenwei: import("..").Mode<{
|
|
31
31
|
times: number;
|
|
32
32
|
rate: number;
|
|
33
33
|
randNum: number;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Mode } from "./mode";
|
|
|
5
5
|
import { patterns } from "./pattern";
|
|
6
6
|
import { Recorder, GameRecord } from "./recorder";
|
|
7
7
|
import { RecordChecker } from "./recordChecker";
|
|
8
|
-
import { ModeName } from "./types
|
|
8
|
+
import { ModeName } from "./types";
|
|
9
9
|
|
|
10
10
|
const labag = new LaBaG();
|
|
11
11
|
modes.forEach((mode) => {
|
package/src/labag.ts
CHANGED
|
@@ -22,11 +22,11 @@ export class LaBaG {
|
|
|
22
22
|
/** 當前轉出的圖案組合 */
|
|
23
23
|
patterns: [Pattern | null, Pattern | null, Pattern | null];
|
|
24
24
|
/** 遊戲模式列表 */
|
|
25
|
-
modes: Mode
|
|
25
|
+
modes: Mode[];
|
|
26
26
|
/** 事件監聽器列表 */
|
|
27
27
|
eventListeners: Record<LaBaGEvent, ((game: LaBaG) => void)[]>;
|
|
28
28
|
|
|
29
|
-
__defaultMode__: Mode
|
|
29
|
+
__defaultMode__: Mode;
|
|
30
30
|
|
|
31
31
|
constructor(times: number = 30) {
|
|
32
32
|
this.times = times;
|
|
@@ -92,7 +92,7 @@ export class LaBaG {
|
|
|
92
92
|
game.patterns[i] = matchedPattern;
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
|
-
calculateScore: (game) => {
|
|
95
|
+
calculateScore: (game, mode) => {
|
|
96
96
|
const [p1, p2, p3] = game.patterns;
|
|
97
97
|
if (!p1 || !p2 || !p3) {
|
|
98
98
|
game.marginScore = 0;
|
|
@@ -117,19 +117,27 @@ export class LaBaG {
|
|
|
117
117
|
this.marginScore += p1.scores[1];
|
|
118
118
|
this.marginScore += p2.scores[2];
|
|
119
119
|
}
|
|
120
|
-
this.marginScore = Math.round(
|
|
120
|
+
this.marginScore = Math.round(
|
|
121
|
+
this.marginScore / mode.variable.twoMatchDivisor,
|
|
122
|
+
);
|
|
121
123
|
} else {
|
|
122
124
|
// 三個圖案皆不同
|
|
123
125
|
this.marginScore += p1.scores[2];
|
|
124
126
|
this.marginScore += p2.scores[2];
|
|
125
127
|
this.marginScore += p3.scores[2];
|
|
126
|
-
this.marginScore = Math.round(
|
|
128
|
+
this.marginScore = Math.round(
|
|
129
|
+
this.marginScore / mode.variable.allDifferentDivisor,
|
|
130
|
+
);
|
|
127
131
|
}
|
|
128
132
|
},
|
|
129
133
|
roundEnd: (game) => {
|
|
130
134
|
game.score += game.marginScore;
|
|
131
135
|
},
|
|
132
136
|
},
|
|
137
|
+
variable: {
|
|
138
|
+
twoMatchDivisor: 1.4,
|
|
139
|
+
allDifferentDivisor: 3,
|
|
140
|
+
},
|
|
133
141
|
});
|
|
134
142
|
this.addMode(this.__defaultMode__);
|
|
135
143
|
}
|
package/src/modes/index.ts
CHANGED
|
@@ -2,5 +2,5 @@ import greenwei from "./greenwei";
|
|
|
2
2
|
import pikachu from "./pikachu";
|
|
3
3
|
import superhhh from "./superhhh";
|
|
4
4
|
|
|
5
|
-
export const _modes = { pikachu, superhhh, greenwei };
|
|
5
|
+
export const _modes = { pikachu, superhhh, greenwei } as const;
|
|
6
6
|
export const modes = Object.values(_modes);
|