@konoui/mjimage 0.0.25 → 0.0.27
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/mjs/lib/calculator/calc.d.ts +21 -9
- package/dist/mjs/lib/calculator/calc.js +59 -40
- package/dist/mjs/lib/calculator/efficiency.d.ts +5 -0
- package/dist/mjs/lib/calculator/helper.d.ts +6 -0
- package/dist/mjs/lib/calculator/helper.js +21 -0
- package/dist/mjs/lib/calculator/index.d.ts +1 -0
- package/dist/mjs/lib/calculator/index.js +1 -0
- package/dist/mjs/lib/controller/controller.d.ts +3 -3
- package/dist/mjs/lib/controller/controller.js +61 -44
- package/dist/mjs/lib/controller/events.d.ts +28 -28
- package/dist/mjs/lib/controller/managers.d.ts +0 -6
- package/dist/mjs/lib/controller/managers.js +6 -21
- package/dist/mjs/lib/controller/player.js +2 -2
- package/dist/mjs/lib/controller/state-machine.js +72 -34
- package/dist/mjs/lib/controller/wall.d.ts +6 -12
- package/dist/mjs/lib/controller/wall.js +17 -15
- package/dist/mjs/lib/core/constants.d.ts +4 -4
- package/dist/mjs/lib/core/constants.js +4 -4
- package/dist/mjs/lib/core/parser.d.ts +15 -5
- package/dist/mjs/lib/core/parser.js +26 -14
- package/dist/mjs/lib/image/image.js +2 -2
- package/dist/mjs/lib/table/table.js +1 -1
- package/package.json +1 -1
|
@@ -163,8 +163,11 @@ var Controller = (function () {
|
|
|
163
163
|
this.actor.send({
|
|
164
164
|
type: selected.type,
|
|
165
165
|
iam: e.wind,
|
|
166
|
-
ret: e.choices.RON,
|
|
167
|
-
targetInfo:
|
|
166
|
+
ret: (0, calculator_1.deserializeWinResult)(e.choices.RON),
|
|
167
|
+
targetInfo: {
|
|
168
|
+
wind: e.discarterInfo.wind,
|
|
169
|
+
tile: parser_1.Tile.from(e.discarterInfo.tile),
|
|
170
|
+
},
|
|
168
171
|
});
|
|
169
172
|
break;
|
|
170
173
|
case "DAI_KAN":
|
|
@@ -172,7 +175,7 @@ var Controller = (function () {
|
|
|
172
175
|
this.actor.send({
|
|
173
176
|
type: selected.type,
|
|
174
177
|
iam: e.wind,
|
|
175
|
-
block: e.choices.DAI_KAN,
|
|
178
|
+
block: parser_1.Block.from(e.choices.DAI_KAN),
|
|
176
179
|
});
|
|
177
180
|
break;
|
|
178
181
|
case "CHI":
|
|
@@ -183,7 +186,7 @@ var Controller = (function () {
|
|
|
183
186
|
this.actor.send({
|
|
184
187
|
type: selected.type,
|
|
185
188
|
iam: e.wind,
|
|
186
|
-
block: c[0],
|
|
189
|
+
block: parser_1.Block.from(c[0]),
|
|
187
190
|
});
|
|
188
191
|
}
|
|
189
192
|
}
|
|
@@ -197,8 +200,8 @@ var Controller = (function () {
|
|
|
197
200
|
(0, assert_1.default)(e.choices.TSUMO, "tsumo choice is none");
|
|
198
201
|
this.actor.send({
|
|
199
202
|
type: selected.type,
|
|
200
|
-
ret: e.choices.TSUMO,
|
|
201
|
-
lastTile: e.
|
|
203
|
+
ret: (0, calculator_1.deserializeWinResult)(e.choices.TSUMO),
|
|
204
|
+
lastTile: parser_1.Tile.from(e.drawerInfo.tile),
|
|
202
205
|
iam: w,
|
|
203
206
|
});
|
|
204
207
|
break;
|
|
@@ -207,7 +210,7 @@ var Controller = (function () {
|
|
|
207
210
|
(0, assert_1.default)(candidates, "".concat(selected.type, " candidates is none"));
|
|
208
211
|
this.actor.send({
|
|
209
212
|
type: selected.type,
|
|
210
|
-
tile: candidates[0].tile,
|
|
213
|
+
tile: parser_1.Tile.from(candidates[0].tile),
|
|
211
214
|
iam: w,
|
|
212
215
|
});
|
|
213
216
|
break;
|
|
@@ -216,7 +219,7 @@ var Controller = (function () {
|
|
|
216
219
|
(0, assert_1.default)(tiles, "".concat(selected.type, " choice is none"));
|
|
217
220
|
this.actor.send({
|
|
218
221
|
type: selected.type,
|
|
219
|
-
tile: tiles[0].clone({ remove: core_1.OPERATOR.TSUMO }),
|
|
222
|
+
tile: parser_1.Tile.from(tiles[0]).clone({ remove: core_1.OPERATOR.TSUMO }),
|
|
220
223
|
iam: w,
|
|
221
224
|
});
|
|
222
225
|
break;
|
|
@@ -225,7 +228,7 @@ var Controller = (function () {
|
|
|
225
228
|
(0, assert_1.default)(choices, "".concat(selected.type, " choice is none"));
|
|
226
229
|
this.actor.send({
|
|
227
230
|
type: selected.type,
|
|
228
|
-
block: choices[0],
|
|
231
|
+
block: parser_1.BlockAnKan.from(choices[0]),
|
|
229
232
|
iam: w,
|
|
230
233
|
});
|
|
231
234
|
break;
|
|
@@ -235,7 +238,7 @@ var Controller = (function () {
|
|
|
235
238
|
(0, assert_1.default)(choices, "".concat(selected.type, " choice is none"));
|
|
236
239
|
this.actor.send({
|
|
237
240
|
type: selected.type,
|
|
238
|
-
block: choices[0],
|
|
241
|
+
block: parser_1.Block.from(choices[0]),
|
|
239
242
|
iam: w,
|
|
240
243
|
});
|
|
241
244
|
break;
|
|
@@ -248,7 +251,7 @@ var Controller = (function () {
|
|
|
248
251
|
else if (sample.type == "CHOICE_AFTER_CALLED") {
|
|
249
252
|
(0, assert_1.default)(sample.choices.DISCARD, "discard candidate tile is none: ".concat(JSON.stringify(sample, null, 2), " ").concat(this.hand(sample.wind).toString()));
|
|
250
253
|
var w = sample.wind;
|
|
251
|
-
var t = sample.choices.DISCARD[0];
|
|
254
|
+
var t = parser_1.Tile.from(sample.choices.DISCARD[0]);
|
|
252
255
|
(0, assert_1.default)(t != null, "undefined tile ".concat(this.hand(w).toString()));
|
|
253
256
|
this.actor.send({ type: "DISCARD", tile: t, iam: w });
|
|
254
257
|
}
|
|
@@ -266,9 +269,12 @@ var Controller = (function () {
|
|
|
266
269
|
this.actor.send({
|
|
267
270
|
type: "RON",
|
|
268
271
|
iam: e.wind,
|
|
269
|
-
ret: e.choices.RON,
|
|
272
|
+
ret: (0, calculator_1.deserializeWinResult)(e.choices.RON),
|
|
270
273
|
quadWin: true,
|
|
271
|
-
targetInfo:
|
|
274
|
+
targetInfo: {
|
|
275
|
+
wind: e.callerInfo.wind,
|
|
276
|
+
tile: parser_1.Tile.from(e.callerInfo.tile),
|
|
277
|
+
},
|
|
272
278
|
});
|
|
273
279
|
}
|
|
274
280
|
};
|
|
@@ -329,7 +335,7 @@ var Controller = (function () {
|
|
|
329
335
|
var blindDoraMarkers = hand.reached
|
|
330
336
|
? this.wall.blindDoraMarkers
|
|
331
337
|
: undefined;
|
|
332
|
-
var final = new calculator_1.DoubleCalculator(hand, __assign(__assign({}, ret.
|
|
338
|
+
var final = new calculator_1.DoubleCalculator(hand, __assign(__assign({}, ret.boardContext), { sticks: this.placeManager.sticks, blindDoraMarkers: blindDoraMarkers })).calc([ret.hand]);
|
|
333
339
|
(0, assert_1.default)(final);
|
|
334
340
|
return final;
|
|
335
341
|
};
|
|
@@ -637,7 +643,7 @@ var Controller = (function () {
|
|
|
637
643
|
return num >= 9;
|
|
638
644
|
};
|
|
639
645
|
Controller.prototype.initialHands = function () {
|
|
640
|
-
var m = (0,
|
|
646
|
+
var m = (0, calculator_1.createWindMap)("");
|
|
641
647
|
for (var i = 0; i < 3; i++) {
|
|
642
648
|
for (var _i = 0, _a = Object.values(core_1.WIND); _i < _a.length; _i++) {
|
|
643
649
|
var w = _a[_i];
|
|
@@ -672,16 +678,14 @@ var ActorHand = (function (_super) {
|
|
|
672
678
|
};
|
|
673
679
|
ActorHand.prototype.clone = function () {
|
|
674
680
|
var c = new ActorHand(this.toString());
|
|
675
|
-
c.data.called = this.called.map(function (b) { return b.clone(); });
|
|
676
681
|
c.data.reached = this.data.reached;
|
|
677
|
-
c.data.tsumo = this.data.tsumo == null ? null : this.data.tsumo;
|
|
678
682
|
return c;
|
|
679
683
|
};
|
|
680
684
|
ActorHand.prototype.dec = function (tiles) {
|
|
681
685
|
if (!this.isBackHand())
|
|
682
686
|
return _super.prototype.dec.call(this, tiles);
|
|
683
687
|
_super.prototype.dec.call(this, tiles.map(function () { return new parser_1.Tile(core_1.TYPE.BACK, 0); }));
|
|
684
|
-
return tiles;
|
|
688
|
+
return __spreadArray([], tiles, true);
|
|
685
689
|
};
|
|
686
690
|
return ActorHand;
|
|
687
691
|
}(calculator_1.Hand));
|
|
@@ -691,7 +695,7 @@ var BaseActor = (function () {
|
|
|
691
695
|
this.river = new _1.River();
|
|
692
696
|
this.placeManager = new _1.PlaceManager({});
|
|
693
697
|
this.scoreManager = new _1.ScoreManager({});
|
|
694
|
-
this.hands = (0,
|
|
698
|
+
this.hands = (0, calculator_1.createWindMap)(new ActorHand(""));
|
|
695
699
|
this.counter = new _1.Counter();
|
|
696
700
|
this.doraMarkers = [];
|
|
697
701
|
this.id = id;
|
|
@@ -711,14 +715,15 @@ var BaseActor = (function () {
|
|
|
711
715
|
break;
|
|
712
716
|
case "DISTRIBUTE":
|
|
713
717
|
this.counter.reset();
|
|
718
|
+
var doraMarker = parser_1.Tile.from(e.doraMarker);
|
|
714
719
|
this.setHands(e);
|
|
715
720
|
this.placeManager = new _1.PlaceManager(structuredClone(e.places), {
|
|
716
721
|
round: structuredClone(e.round),
|
|
717
722
|
sticks: structuredClone(e.sticks),
|
|
718
723
|
});
|
|
719
724
|
this.scoreManager = new _1.ScoreManager(structuredClone(e.scores));
|
|
720
|
-
this.doraMarkers = [
|
|
721
|
-
this.counter.dec(
|
|
725
|
+
this.doraMarkers = [doraMarker];
|
|
726
|
+
this.counter.dec(doraMarker);
|
|
722
727
|
for (var _i = 0, _d = Object.values(core_1.WIND); _i < _d.length; _i++) {
|
|
723
728
|
var w = _d[_i];
|
|
724
729
|
if (w != e.wind)
|
|
@@ -726,56 +731,68 @@ var BaseActor = (function () {
|
|
|
726
731
|
(_a = this.counter).dec.apply(_a, this.hand(w).hands);
|
|
727
732
|
}
|
|
728
733
|
break;
|
|
729
|
-
case "DRAW":
|
|
730
|
-
|
|
731
|
-
this.
|
|
734
|
+
case "DRAW": {
|
|
735
|
+
var t = parser_1.Tile.from(e.tile);
|
|
736
|
+
this.hands[e.iam].draw(t);
|
|
737
|
+
this.counter.dec(t);
|
|
732
738
|
break;
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
739
|
+
}
|
|
740
|
+
case "DISCARD": {
|
|
741
|
+
var t = parser_1.Tile.from(e.tile);
|
|
742
|
+
this.river.discard(t, e.iam);
|
|
743
|
+
this.hands[e.iam].discard(t);
|
|
736
744
|
if (e.iam != e.wind) {
|
|
737
|
-
this.counter.dec(
|
|
738
|
-
this.counter.addTileToSafeMap(
|
|
745
|
+
this.counter.dec(t);
|
|
746
|
+
this.counter.addTileToSafeMap(t, e.iam);
|
|
739
747
|
for (var _e = 0, _f = Object.values(core_1.WIND); _e < _f.length; _e++) {
|
|
740
748
|
var w = _f[_e];
|
|
741
749
|
if (this.hand(w).reached)
|
|
742
|
-
this.counter.addTileToSafeMap(
|
|
750
|
+
this.counter.addTileToSafeMap(t, w);
|
|
743
751
|
}
|
|
744
752
|
}
|
|
745
753
|
break;
|
|
754
|
+
}
|
|
746
755
|
case "PON":
|
|
747
756
|
case "CHI":
|
|
748
|
-
case "DAI_KAN":
|
|
749
|
-
|
|
757
|
+
case "DAI_KAN": {
|
|
758
|
+
var block = parser_1.Block.from(e.block);
|
|
759
|
+
this.hands[e.iam].call(block);
|
|
750
760
|
this.river.markCalled();
|
|
751
761
|
if (e.iam != e.wind)
|
|
752
|
-
(_b = this.counter).dec.apply(_b,
|
|
762
|
+
(_b = this.counter).dec.apply(_b, block.tiles.filter(function (t) { return !t.has(core_1.OPERATOR.HORIZONTAL); }));
|
|
753
763
|
break;
|
|
754
|
-
|
|
755
|
-
|
|
764
|
+
}
|
|
765
|
+
case "SHO_KAN": {
|
|
766
|
+
var block = parser_1.Block.from(e.block);
|
|
767
|
+
this.hands[e.iam].kan(block);
|
|
756
768
|
if (e.iam != e.wind)
|
|
757
|
-
this.counter.dec(
|
|
769
|
+
this.counter.dec(block.tiles.filter(function (t) { return t.has(core_1.OPERATOR.HORIZONTAL); })[0]);
|
|
758
770
|
break;
|
|
759
|
-
|
|
760
|
-
|
|
771
|
+
}
|
|
772
|
+
case "AN_KAN": {
|
|
773
|
+
var block = parser_1.Block.from(e.block);
|
|
774
|
+
this.hands[e.iam].kan(block);
|
|
761
775
|
if (e.iam != e.wind)
|
|
762
|
-
(_c = this.counter).dec.apply(_c,
|
|
776
|
+
(_c = this.counter).dec.apply(_c, block.tiles.filter(function (t) { return !t.has(core_1.OPERATOR.HORIZONTAL); }));
|
|
763
777
|
break;
|
|
778
|
+
}
|
|
764
779
|
case "REACH":
|
|
765
780
|
var pid = this.placeManager.playerID(e.iam);
|
|
766
781
|
this.hands[e.iam].reach();
|
|
767
782
|
this.scoreManager.reach(pid);
|
|
768
783
|
this.placeManager.incrementReachStick();
|
|
769
784
|
break;
|
|
770
|
-
case "NEW_DORA":
|
|
771
|
-
|
|
772
|
-
this.
|
|
785
|
+
case "NEW_DORA": {
|
|
786
|
+
var doraMarker_1 = parser_1.Tile.from(e.doraMarker);
|
|
787
|
+
this.doraMarkers.push(doraMarker_1);
|
|
788
|
+
this.counter.dec(doraMarker_1);
|
|
773
789
|
break;
|
|
790
|
+
}
|
|
774
791
|
case "TSUMO":
|
|
775
792
|
break;
|
|
776
793
|
case "RON":
|
|
777
794
|
if (e.pushBackReachStick) {
|
|
778
|
-
var w = e.
|
|
795
|
+
var w = e.victimInfo.wind;
|
|
779
796
|
var id = this.placeManager.playerID(w);
|
|
780
797
|
this.scoreManager.restoreReachStick(id);
|
|
781
798
|
this.placeManager.decrementReachStick();
|
|
@@ -827,7 +844,7 @@ var Observer = (function (_super) {
|
|
|
827
844
|
var _this = _super.call(this, "observer", eventHandler) || this;
|
|
828
845
|
_this.applied = {};
|
|
829
846
|
_this.counter.disable = true;
|
|
830
|
-
_this.hands = (0,
|
|
847
|
+
_this.hands = (0, calculator_1.createWindMap)(new ActorHand("_____________"));
|
|
831
848
|
return _this;
|
|
832
849
|
}
|
|
833
850
|
Observer.prototype.setHands = function (e) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Wind, Round } from "../core/constants";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { SerializedBlock } from "../core/parser";
|
|
3
|
+
import { SerializedCandidate, SerializedWinResult } from "../calculator";
|
|
4
4
|
type Event = CallEvent | "DRAW" | "CHOICE_AFTER_DRAWN" | "CHOICE_AFTER_DISCARDED" | "CHOICE_AFTER_CALLED" | "CHOICE_FOR_CHAN_KAN" | "DISTRIBUTE" | "NEW_DORA" | "END_GAME";
|
|
5
5
|
type ChoiceEvent = "PON" | "CHI" | "RON" | "DISCARD" | "TSUMO" | "REACH" | "AN_KAN" | "SHO_KAN" | "DAI_KAN" | "DRAWN_GAME_BY_NINE_TILES";
|
|
6
6
|
export interface DistributeEvent {
|
|
@@ -10,7 +10,7 @@ export interface DistributeEvent {
|
|
|
10
10
|
[key in Wind]: string;
|
|
11
11
|
};
|
|
12
12
|
wind: Wind;
|
|
13
|
-
doraMarker:
|
|
13
|
+
doraMarker: string;
|
|
14
14
|
players: string[];
|
|
15
15
|
places: {
|
|
16
16
|
[key: string]: Wind;
|
|
@@ -49,17 +49,17 @@ export interface CallEvent {
|
|
|
49
49
|
type: Extract<ChoiceEvent, "PON" | "CHI" | "AN_KAN" | "SHO_KAN" | "DAI_KAN">;
|
|
50
50
|
iam: Wind;
|
|
51
51
|
wind: Wind;
|
|
52
|
-
block:
|
|
52
|
+
block: SerializedBlock;
|
|
53
53
|
}
|
|
54
54
|
export interface RonEvent {
|
|
55
55
|
id: string;
|
|
56
56
|
type: Extract<ChoiceEvent, "RON">;
|
|
57
57
|
iam: Wind;
|
|
58
58
|
wind: Wind;
|
|
59
|
-
ret:
|
|
60
|
-
|
|
59
|
+
ret: SerializedWinResult;
|
|
60
|
+
victimInfo: {
|
|
61
61
|
wind: Wind;
|
|
62
|
-
tile:
|
|
62
|
+
tile: string;
|
|
63
63
|
};
|
|
64
64
|
pushBackReachStick: boolean;
|
|
65
65
|
}
|
|
@@ -68,15 +68,15 @@ export interface TsumoEvent {
|
|
|
68
68
|
type: Extract<ChoiceEvent, "TSUMO">;
|
|
69
69
|
iam: Wind;
|
|
70
70
|
wind: Wind;
|
|
71
|
-
lastTile:
|
|
72
|
-
ret:
|
|
71
|
+
lastTile: string;
|
|
72
|
+
ret: SerializedWinResult;
|
|
73
73
|
}
|
|
74
74
|
export interface DiscardEvent {
|
|
75
75
|
id: string;
|
|
76
76
|
type: Extract<ChoiceEvent, "DISCARD">;
|
|
77
77
|
iam: Wind;
|
|
78
78
|
wind: Wind;
|
|
79
|
-
tile:
|
|
79
|
+
tile: string;
|
|
80
80
|
}
|
|
81
81
|
export interface DrawEvent {
|
|
82
82
|
id: string;
|
|
@@ -84,28 +84,28 @@ export interface DrawEvent {
|
|
|
84
84
|
subtype?: "kan";
|
|
85
85
|
iam: Wind;
|
|
86
86
|
wind: Wind;
|
|
87
|
-
tile:
|
|
87
|
+
tile: string;
|
|
88
88
|
}
|
|
89
89
|
export interface ReachEvent {
|
|
90
90
|
id: string;
|
|
91
91
|
type: Extract<ChoiceEvent, "REACH">;
|
|
92
|
-
tile:
|
|
92
|
+
tile: string;
|
|
93
93
|
iam: Wind;
|
|
94
94
|
wind: Wind;
|
|
95
95
|
}
|
|
96
96
|
export interface NewDoraEvent {
|
|
97
97
|
id: string;
|
|
98
98
|
type: Extract<Event, "NEW_DORA">;
|
|
99
|
-
doraMarker:
|
|
99
|
+
doraMarker: string;
|
|
100
100
|
wind: Wind;
|
|
101
101
|
}
|
|
102
102
|
export interface ChoiceAfterDrawnEvent {
|
|
103
103
|
id: string;
|
|
104
104
|
type: Extract<Event, "CHOICE_AFTER_DRAWN">;
|
|
105
105
|
wind: Wind;
|
|
106
|
-
|
|
106
|
+
drawerInfo: {
|
|
107
107
|
wind: Wind;
|
|
108
|
-
tile:
|
|
108
|
+
tile: string;
|
|
109
109
|
};
|
|
110
110
|
choices: DrawnChoice;
|
|
111
111
|
}
|
|
@@ -113,9 +113,9 @@ export interface ChoiceAfterDiscardedEvent {
|
|
|
113
113
|
id: string;
|
|
114
114
|
type: Extract<Event, "CHOICE_AFTER_DISCARDED">;
|
|
115
115
|
wind: Wind;
|
|
116
|
-
|
|
116
|
+
discarterInfo: {
|
|
117
117
|
wind: Wind;
|
|
118
|
-
tile:
|
|
118
|
+
tile: string;
|
|
119
119
|
};
|
|
120
120
|
choices: DiscardedChoice;
|
|
121
121
|
}
|
|
@@ -129,25 +129,25 @@ export interface ChoiceForChanKan {
|
|
|
129
129
|
id: string;
|
|
130
130
|
type: Extract<Event, "CHOICE_FOR_CHAN_KAN">;
|
|
131
131
|
wind: Wind;
|
|
132
|
-
|
|
132
|
+
callerInfo: {
|
|
133
133
|
wind: Wind;
|
|
134
|
-
tile:
|
|
134
|
+
tile: string;
|
|
135
135
|
};
|
|
136
136
|
choices: Pick<DiscardedChoice, "RON">;
|
|
137
137
|
}
|
|
138
138
|
export type PlayerEvent = DistributeEvent | EndEvent | CallEvent | RonEvent | TsumoEvent | DiscardEvent | DrawEvent | ReachEvent | NewDoraEvent | ChoiceAfterDrawnEvent | ChoiceAfterDiscardedEvent | ChoiceAfterCalled | ChoiceForChanKan;
|
|
139
139
|
interface DiscardedChoice {
|
|
140
|
-
RON: false |
|
|
141
|
-
PON: false |
|
|
142
|
-
CHI: false |
|
|
143
|
-
DAI_KAN: false |
|
|
140
|
+
RON: false | SerializedWinResult;
|
|
141
|
+
PON: false | SerializedBlock[];
|
|
142
|
+
CHI: false | SerializedBlock[];
|
|
143
|
+
DAI_KAN: false | SerializedBlock;
|
|
144
144
|
}
|
|
145
145
|
interface DrawnChoice {
|
|
146
|
-
TSUMO: false |
|
|
147
|
-
REACH: false |
|
|
148
|
-
AN_KAN: false |
|
|
149
|
-
SHO_KAN: false |
|
|
150
|
-
DISCARD: false |
|
|
146
|
+
TSUMO: false | SerializedWinResult;
|
|
147
|
+
REACH: false | SerializedCandidate[];
|
|
148
|
+
AN_KAN: false | SerializedBlock[];
|
|
149
|
+
SHO_KAN: false | SerializedBlock[];
|
|
150
|
+
DISCARD: false | string[];
|
|
151
151
|
DRAWN_GAME_BY_NINE_TILES: boolean;
|
|
152
152
|
}
|
|
153
153
|
export declare function prioritizeDiscardedEvents(events: ChoiceAfterDiscardedEvent[]): {
|
|
@@ -55,12 +55,6 @@ export declare const nextRound: (r: Round) => Round;
|
|
|
55
55
|
export declare const prevRound: (r: Round) => "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4";
|
|
56
56
|
export declare const nextWind: (w: Wind) => Wind;
|
|
57
57
|
export declare const prevWind: (w: Wind) => Wind;
|
|
58
|
-
export declare function createWindMap<T>(initial: T, clone?: boolean): {
|
|
59
|
-
"1w": T;
|
|
60
|
-
"2w": T;
|
|
61
|
-
"3w": T;
|
|
62
|
-
"4w": T;
|
|
63
|
-
};
|
|
64
58
|
export declare function shuffle<T>(array: T[]): T[];
|
|
65
59
|
export declare class Counter {
|
|
66
60
|
disable: boolean;
|
|
@@ -4,10 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Counter = exports.prevWind = exports.nextWind = exports.prevRound = exports.nextRound = exports.PlaceManager = exports.ScoreManager = void 0;
|
|
7
|
-
exports.createWindMap = createWindMap;
|
|
8
7
|
exports.shuffle = shuffle;
|
|
9
8
|
var assert_1 = __importDefault(require("assert"));
|
|
10
9
|
var constants_1 = require("../core/constants");
|
|
10
|
+
var calculator_1 = require("../calculator");
|
|
11
|
+
var parser_1 = require("../core/parser");
|
|
11
12
|
var ScoreManager = (function () {
|
|
12
13
|
function ScoreManager(initial) {
|
|
13
14
|
this.reachValue = 1000;
|
|
@@ -40,7 +41,7 @@ var PlaceManager = (function () {
|
|
|
40
41
|
function PlaceManager(initial, params) {
|
|
41
42
|
var _a, _b;
|
|
42
43
|
this.pToW = {};
|
|
43
|
-
this.wToP = createWindMap("");
|
|
44
|
+
this.wToP = (0, calculator_1.createWindMap)("");
|
|
44
45
|
this.round = (_a = params === null || params === void 0 ? void 0 : params.round) !== null && _a !== void 0 ? _a : "1w1";
|
|
45
46
|
this.sticks = (_b = params === null || params === void 0 ? void 0 : params.sticks) !== null && _b !== void 0 ? _b : { reach: 0, dead: 0 };
|
|
46
47
|
this.pToW = initial;
|
|
@@ -123,22 +124,6 @@ var prevWind = function (w) {
|
|
|
123
124
|
return (0, exports.nextWind)((0, exports.nextWind)((0, exports.nextWind)(w)));
|
|
124
125
|
};
|
|
125
126
|
exports.prevWind = prevWind;
|
|
126
|
-
function createWindMap(initial, clone) {
|
|
127
|
-
if (clone === void 0) { clone = false; }
|
|
128
|
-
var m = {
|
|
129
|
-
"1w": initial,
|
|
130
|
-
"2w": initial,
|
|
131
|
-
"3w": initial,
|
|
132
|
-
"4w": initial,
|
|
133
|
-
};
|
|
134
|
-
if (clone) {
|
|
135
|
-
for (var _i = 0, _a = Object.values(constants_1.WIND); _i < _a.length; _i++) {
|
|
136
|
-
var w = _a[_i];
|
|
137
|
-
m[w] = structuredClone(initial);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return m;
|
|
141
|
-
}
|
|
142
127
|
function shuffle(array) {
|
|
143
128
|
var _a;
|
|
144
129
|
for (var i = array.length - 1; i > 0; i--) {
|
|
@@ -158,12 +143,12 @@ var Counter = (function () {
|
|
|
158
143
|
_a[constants_1.TYPE.P] = [1, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
159
144
|
_a[constants_1.TYPE.Z] = [0, 4, 4, 4, 4, 4, 4, 4],
|
|
160
145
|
_a);
|
|
161
|
-
this.safeMap = createWindMap({}, true);
|
|
146
|
+
this.safeMap = (0, calculator_1.createWindMap)({}, true);
|
|
162
147
|
}
|
|
163
148
|
Counter.prototype.get = function (t) {
|
|
164
149
|
if (t.t == constants_1.TYPE.BACK)
|
|
165
150
|
return 0;
|
|
166
|
-
if (
|
|
151
|
+
if ((0, parser_1.isNum0)(t))
|
|
167
152
|
return this.c[t.t][5];
|
|
168
153
|
return this.c[t.t][t.n];
|
|
169
154
|
};
|
|
@@ -181,7 +166,7 @@ var Counter = (function () {
|
|
|
181
166
|
if (this.get(t) <= 0)
|
|
182
167
|
throw new Error("cannot decrease ".concat(t.toString(), " due to zero"));
|
|
183
168
|
this.c[t.t][t.n] -= 1;
|
|
184
|
-
if (
|
|
169
|
+
if ((0, parser_1.isNum0)(t))
|
|
185
170
|
this.c[t.t][5] -= 1;
|
|
186
171
|
}
|
|
187
172
|
};
|
|
@@ -68,8 +68,8 @@ var Player = (function (_super) {
|
|
|
68
68
|
case "CHOICE_AFTER_CALLED":
|
|
69
69
|
case "CHOICE_AFTER_DRAWN":
|
|
70
70
|
if (e.choices.DISCARD) {
|
|
71
|
-
var t = this.handleDiscard(e.choices.DISCARD);
|
|
72
|
-
e.choices.DISCARD = [t];
|
|
71
|
+
var t = this.handleDiscard(e.choices.DISCARD.map(core_1.Tile.from));
|
|
72
|
+
e.choices.DISCARD = [t.toString()];
|
|
73
73
|
}
|
|
74
74
|
this.eventHandler.emit(e);
|
|
75
75
|
break;
|