labag 2.6.2 → 2.6.3

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/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<Record<string, any>>[];
22
+ modes: Mode[];
23
23
  /** 事件監聽器列表 */
24
24
  eventListeners: Record<LaBaGEvent, ((game: LaBaG) => void)[]>;
25
- __defaultMode__: Mode<{}, "normal">;
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 / 1.4);
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 / 3);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labag",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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<Record<string, any>>[];
25
+ modes: Mode[];
26
26
  /** 事件監聽器列表 */
27
27
  eventListeners: Record<LaBaGEvent, ((game: LaBaG) => void)[]>;
28
28
 
29
- __defaultMode__: Mode<{}, "normal">;
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(this.marginScore / 1.4);
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(this.marginScore / 3);
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
  }