@konoui/mjimage 0.0.1 → 0.0.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.
Files changed (91) hide show
  1. package/README.md +2 -2
  2. package/dist/mjs/cmd/index.d.ts +1 -0
  3. package/dist/mjs/cmd/index.js +49 -0
  4. package/dist/mjs/index.d.ts +1 -1
  5. package/dist/mjs/index.js +1 -1
  6. package/dist/mjs/lib/calculator/index.d.ts +284 -0
  7. package/dist/mjs/lib/calculator/index.js +1390 -0
  8. package/dist/mjs/lib/constants.d.ts +22 -2
  9. package/dist/mjs/lib/constants.js +28 -9
  10. package/dist/mjs/lib/controller/controller.d.ts +223 -0
  11. package/dist/mjs/lib/controller/controller.js +862 -0
  12. package/dist/mjs/lib/controller/efficiency.d.ts +36 -0
  13. package/dist/mjs/lib/controller/efficiency.js +217 -0
  14. package/dist/mjs/lib/controller/events.d.ts +172 -0
  15. package/dist/mjs/lib/controller/events.js +102 -0
  16. package/dist/mjs/lib/controller/game.d.ts +5 -0
  17. package/dist/mjs/lib/controller/game.js +29 -0
  18. package/dist/mjs/lib/controller/index.d.ts +10 -0
  19. package/dist/mjs/lib/controller/index.js +26 -0
  20. package/dist/mjs/lib/controller/managers.d.ts +89 -0
  21. package/dist/mjs/lib/controller/managers.js +212 -0
  22. package/dist/mjs/lib/controller/player.d.ts +12 -0
  23. package/dist/mjs/lib/controller/player.js +88 -0
  24. package/dist/mjs/lib/controller/replay.d.ts +10 -0
  25. package/dist/mjs/lib/controller/replay.js +34 -0
  26. package/dist/mjs/lib/controller/river.d.ts +19 -0
  27. package/dist/mjs/lib/controller/river.js +55 -0
  28. package/dist/mjs/lib/controller/state-machine.d.ts +116 -0
  29. package/dist/mjs/lib/controller/state-machine.js +733 -0
  30. package/dist/mjs/lib/controller/wall.d.ts +30 -0
  31. package/dist/mjs/lib/controller/wall.js +115 -0
  32. package/dist/mjs/lib/image.d.ts +3 -2
  33. package/dist/mjs/lib/image.js +78 -17
  34. package/dist/mjs/lib/lexer.d.ts +2 -1
  35. package/dist/mjs/lib/lexer.js +7 -0
  36. package/dist/mjs/lib/measure-text.d.ts +19 -0
  37. package/dist/mjs/lib/measure-text.js +52 -0
  38. package/dist/mjs/lib/mjai/event.d.ts +117 -0
  39. package/dist/mjs/lib/mjai/event.js +348 -0
  40. package/dist/mjs/lib/mjimage.d.ts +0 -1
  41. package/dist/mjs/lib/mjimage.js +3 -12
  42. package/dist/mjs/lib/parser.d.ts +51 -7
  43. package/dist/mjs/lib/parser.js +276 -42
  44. package/dist/mjs/lib/table-parser.d.ts +8 -6
  45. package/dist/mjs/lib/table-parser.js +12 -11
  46. package/dist/mjs/lib/table.d.ts +1 -1
  47. package/package.json +16 -8
  48. package/dist/index.html +0 -17763
  49. package/dist/mjs/lib/context.d.ts +0 -12
  50. package/dist/mjs/lib/context.js +0 -33
  51. package/dist/svg/_0.svg +0 -1
  52. package/dist/svg/m0.svg +0 -1
  53. package/dist/svg/m1.svg +0 -1
  54. package/dist/svg/m2.svg +0 -1
  55. package/dist/svg/m3.svg +0 -1
  56. package/dist/svg/m4.svg +0 -1
  57. package/dist/svg/m5.svg +0 -1
  58. package/dist/svg/m6.svg +0 -1
  59. package/dist/svg/m7.svg +0 -1
  60. package/dist/svg/m8.svg +0 -1
  61. package/dist/svg/m9.svg +0 -1
  62. package/dist/svg/p0.svg +0 -1
  63. package/dist/svg/p1.svg +0 -1
  64. package/dist/svg/p2.svg +0 -1
  65. package/dist/svg/p3.svg +0 -1
  66. package/dist/svg/p4.svg +0 -1
  67. package/dist/svg/p5.svg +0 -1
  68. package/dist/svg/p6.svg +0 -1
  69. package/dist/svg/p7.svg +0 -1
  70. package/dist/svg/p8.svg +0 -1
  71. package/dist/svg/p9.svg +0 -1
  72. package/dist/svg/s0.svg +0 -1
  73. package/dist/svg/s1.svg +0 -1
  74. package/dist/svg/s2.svg +0 -1
  75. package/dist/svg/s3.svg +0 -1
  76. package/dist/svg/s4.svg +0 -1
  77. package/dist/svg/s5.svg +0 -1
  78. package/dist/svg/s6.svg +0 -1
  79. package/dist/svg/s7.svg +0 -1
  80. package/dist/svg/s8.svg +0 -1
  81. package/dist/svg/s9.svg +0 -1
  82. package/dist/svg/stick100.svg +0 -1
  83. package/dist/svg/stick1000.svg +0 -1
  84. package/dist/svg/z1.svg +0 -1
  85. package/dist/svg/z2.svg +0 -1
  86. package/dist/svg/z3.svg +0 -1
  87. package/dist/svg/z4.svg +0 -1
  88. package/dist/svg/z5.svg +0 -1
  89. package/dist/svg/z6.svg +0 -1
  90. package/dist/svg/z7.svg +0 -1
  91. package/dist/tiles.1417fc37.svg +0 -1
@@ -0,0 +1,348 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MJAIPlayer = void 0;
13
+ var constants_1 = require("../constants");
14
+ var parser_1 = require("../parser");
15
+ var controller_1 = require("./../controller");
16
+ var M = ["5mr", "1m", "2m", "3m", "4m", "5m", "6m", "7m", "8m", "9m"];
17
+ var S = ["5sr", "1s", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s"];
18
+ var P = ["5pr", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p"];
19
+ var Z = ["ERROR-WIND", "E", "S", "W", "N", "P", "F", "C"];
20
+ var UNSCREEN = "?";
21
+ var MJAIPlayer = (function () {
22
+ function MJAIPlayer() {
23
+ var _this = this;
24
+ this.genID = (0, controller_1.incrementalIDGenerator)();
25
+ this.reachEventRecorder = {};
26
+ this.toPlayerEvent = function (myWind, pm, e) {
27
+ var _a, _b;
28
+ var kyoku = toKyoku(pm.round);
29
+ switch (e.type) {
30
+ case "start_kyoku": {
31
+ var pe = {
32
+ id: _this.genID(),
33
+ type: "DISTRIBUTE",
34
+ hands: toHands(e.tehais, e.kyoku),
35
+ wind: myWind,
36
+ doraMarker: toTile(e.dora_marker),
37
+ sticks: { reach: e.kyotaku, dead: e.honba },
38
+ scores: toScores(e.scores),
39
+ round: toRound(e.bakaze, e.kyotaku),
40
+ places: toPlaces(e.kyoku),
41
+ players: ["0", "1", "2", "3"],
42
+ };
43
+ return pe;
44
+ }
45
+ case "tsumo": {
46
+ var pe = {
47
+ id: _this.genID(),
48
+ type: "DRAW",
49
+ iam: toPlayerWind(e.actor, kyoku),
50
+ wind: myWind,
51
+ tile: toTile(e.pai),
52
+ };
53
+ return pe;
54
+ }
55
+ case "dahai": {
56
+ if (_this.reachEventRecorder[e.actor]) {
57
+ _this.reachEventRecorder[e.actor] = false;
58
+ var pe_1 = {
59
+ id: _this.genID(),
60
+ type: "REACH",
61
+ wind: myWind,
62
+ iam: toPlayerWind(e.actor, kyoku),
63
+ tile: toTile(e.pai),
64
+ };
65
+ return pe_1;
66
+ }
67
+ var pe = {
68
+ id: _this.genID(),
69
+ type: "DISCARD",
70
+ iam: toPlayerWind(e.actor, kyoku),
71
+ wind: myWind,
72
+ tile: toTile(e.pai),
73
+ };
74
+ return pe;
75
+ }
76
+ case "dora": {
77
+ var pe = {
78
+ id: _this.genID(),
79
+ type: "NEW_DORA",
80
+ doraMarker: toTile(e.dora_marker),
81
+ wind: myWind,
82
+ };
83
+ return pe;
84
+ }
85
+ case "ankan": {
86
+ var tiles = __spreadArray([toTile(e.pai)], toTiles(e.consumed), true);
87
+ var pe = {
88
+ id: _this.genID(),
89
+ type: "AN_KAN",
90
+ wind: myWind,
91
+ iam: toPlayerWind(e.actor, kyoku),
92
+ block: new parser_1.BlockAnKan(tiles),
93
+ };
94
+ return pe;
95
+ }
96
+ case "chi": {
97
+ var block = new parser_1.BlockChi([
98
+ toTile(e.pai).add(constants_1.OPERATOR.HORIZONTAL),
99
+ toTile(e.consumed[0]),
100
+ toTile(e.consumed[1]),
101
+ ]);
102
+ var pe = {
103
+ id: _this.genID(),
104
+ type: "CHI",
105
+ wind: myWind,
106
+ iam: toPlayerWind(e.actor, kyoku),
107
+ block: block,
108
+ };
109
+ return pe;
110
+ }
111
+ case "pon": {
112
+ var idx = Math.abs(e.actor - e.target);
113
+ if (idx == 3)
114
+ idx = 0;
115
+ if (idx == 2)
116
+ idx = 1;
117
+ if (idx == 1)
118
+ idx = 2;
119
+ var block = new parser_1.BlockPon([
120
+ toTile(e.pai).add(constants_1.OPERATOR.HORIZONTAL),
121
+ toTile(e.consumed[0]),
122
+ toTile(e.consumed[1]),
123
+ ]);
124
+ _a = [block.tiles[idx], block.tiles[0]], block.tiles[0] = _a[0], block.tiles[idx] = _a[1];
125
+ var pe = {
126
+ id: _this.genID(),
127
+ type: "CHI",
128
+ wind: myWind,
129
+ iam: toPlayerWind(e.actor, kyoku),
130
+ block: block,
131
+ };
132
+ return pe;
133
+ }
134
+ case "daiminkan": {
135
+ var idx = Math.abs(e.actor - e.target);
136
+ if (idx == 3)
137
+ idx = 0;
138
+ if (idx == 2)
139
+ idx = 1;
140
+ if (idx == 1)
141
+ idx = 2;
142
+ var block = new parser_1.BlockDaiKan([
143
+ toTile(e.pai).add(constants_1.OPERATOR.HORIZONTAL),
144
+ toTile(e.consumed[0]),
145
+ toTile(e.consumed[1]),
146
+ toTile(e.consumed[2]),
147
+ ]);
148
+ _b = [block.tiles[idx], block.tiles[0]], block.tiles[0] = _b[0], block.tiles[idx] = _b[1];
149
+ var pe = {
150
+ id: _this.genID(),
151
+ type: "CHI",
152
+ wind: myWind,
153
+ iam: toPlayerWind(e.actor, kyoku),
154
+ block: block,
155
+ };
156
+ return pe;
157
+ }
158
+ case "kakan": {
159
+ var block = new parser_1.BlockAnKan([
160
+ toTile(e.pai).add(constants_1.OPERATOR.HORIZONTAL),
161
+ toTile(e.consumed[0]).add(constants_1.OPERATOR.HORIZONTAL),
162
+ toTile(e.consumed[1]),
163
+ toTile(e.consumed[2]),
164
+ ]);
165
+ var pe = {
166
+ id: _this.genID(),
167
+ type: "CHI",
168
+ wind: myWind,
169
+ iam: toPlayerWind(e.actor, kyoku),
170
+ block: block,
171
+ };
172
+ return pe;
173
+ }
174
+ case "hora": {
175
+ if (e.actor != e.target) {
176
+ var pe = {
177
+ id: _this.genID(),
178
+ wind: myWind,
179
+ type: "RON",
180
+ iam: toPlayerWind(e.actor, kyoku),
181
+ targetInfo: {
182
+ wind: toPlayerWind(e.target, kyoku),
183
+ tile: toTile(e.pai),
184
+ },
185
+ pushBackReachStick: false,
186
+ ret: toWinResult(e.hora_tehais, e.fan, e.fu, e.yakus, e.hora_points, e.deltas, toKyoku(pm.round)),
187
+ };
188
+ return pe;
189
+ }
190
+ else {
191
+ var pe = {
192
+ id: _this.genID(),
193
+ wind: myWind,
194
+ type: "TSUMO",
195
+ iam: toPlayerWind(e.actor, kyoku),
196
+ lastTile: toTile(e.pai),
197
+ ret: toWinResult(e.hora_tehais, e.fan, e.fu, e.yakus, e.hora_points, e.deltas, toKyoku(pm.round)),
198
+ };
199
+ return pe;
200
+ }
201
+ }
202
+ default:
203
+ throw new Error("unexpected MJAI event ".concat(e));
204
+ }
205
+ };
206
+ var _a = (0, controller_1.createEventPipe)(), ce = _a[0], pe = _a[1];
207
+ this.from = ce;
208
+ this.to = pe;
209
+ this.player = new controller_1.Player("-1", this.to);
210
+ this.from.on(function (e) {
211
+ });
212
+ }
213
+ MJAIPlayer.prototype.react = function (e) {
214
+ var _this = this;
215
+ var events = JSON.parse(e);
216
+ events.forEach(function (e) {
217
+ _this.handle(e);
218
+ });
219
+ };
220
+ MJAIPlayer.prototype.handle = function (e) {
221
+ switch (e.type) {
222
+ case "start_game": {
223
+ this.player.id = e.id.toString();
224
+ break;
225
+ }
226
+ case "reach": {
227
+ this.reachEventRecorder[e.actor] = true;
228
+ break;
229
+ }
230
+ case "end_game":
231
+ break;
232
+ default:
233
+ var pe = this.toPlayerEvent(this.player.myWind, this.player.placeManager, e);
234
+ this.from.emit(pe);
235
+ }
236
+ };
237
+ return MJAIPlayer;
238
+ }());
239
+ exports.MJAIPlayer = MJAIPlayer;
240
+ var toWinResult = function (tehais, fan, fu, yaku, hora_points, deltas, kyoku) {
241
+ var d = (0, controller_1.createWindMap)(0);
242
+ d[toPlayerWind(0, kyoku)] = deltas[0];
243
+ d[toPlayerWind(1, kyoku)] = deltas[1];
244
+ d[toPlayerWind(2, kyoku)] = deltas[2];
245
+ d[toPlayerWind(3, kyoku)] = deltas[3];
246
+ var points = yaku.map(function (v) {
247
+ return { double: v[1], name: v[0] };
248
+ });
249
+ var ret = {
250
+ deltas: d,
251
+ fu: fu,
252
+ sum: fan,
253
+ points: points,
254
+ point: hora_points,
255
+ hand: [],
256
+ params: {
257
+ doraMarkers: [new parser_1.Tile(constants_1.KIND.BACK, 0)],
258
+ round: "1w1",
259
+ myWind: "1w",
260
+ },
261
+ };
262
+ return ret;
263
+ };
264
+ var toPlaces = function (kyoku) {
265
+ return {
266
+ "0": toPlayerWind(0, kyoku),
267
+ "1": toPlayerWind(1, kyoku),
268
+ "2": toPlayerWind(2, kyoku),
269
+ "3": toPlayerWind(3, kyoku),
270
+ };
271
+ };
272
+ var toScores = function (scores) {
273
+ return {
274
+ "0": scores[0],
275
+ "1": scores[1],
276
+ "2": scores[2],
277
+ "3": scores[3],
278
+ };
279
+ };
280
+ var toHands = function (tehais, kyoku) {
281
+ var hands = (0, controller_1.createWindMap)("");
282
+ for (var actor = 0; actor < tehais.length; actor++) {
283
+ var w = toPlayerWind(actor, kyoku);
284
+ var tehai = tehais[actor];
285
+ hands[w] = toTiles(tehai).toString();
286
+ }
287
+ return hands;
288
+ };
289
+ var toPlayerWind = function (actor, kyoku) {
290
+ var idx = Math.abs(actor + 1 - kyoku) + 1;
291
+ return toWind(Z[idx]);
292
+ };
293
+ var toRound = function (b, kyoku) {
294
+ return "".concat(toWind(b)).concat(kyoku);
295
+ };
296
+ var toKyoku = function (round) {
297
+ return Number(round[2]);
298
+ };
299
+ var toWind = function (b) {
300
+ var idx = Z.findIndex(function (v) { return v == b; });
301
+ return "".concat(idx, "w");
302
+ };
303
+ var toBakaze = function (b) {
304
+ var idx = b[0];
305
+ return Z[Number(idx)];
306
+ };
307
+ var toTile = function (hai) {
308
+ var idx = Z.findIndex(function (v) { return v == hai; });
309
+ if (idx >= 0)
310
+ return new parser_1.Tile(constants_1.KIND.Z, idx);
311
+ idx = M.findIndex(function (v) { return v == hai; });
312
+ if (idx >= 0)
313
+ return new parser_1.Tile(constants_1.KIND.M, idx);
314
+ idx = S.findIndex(function (v) { return v == hai; });
315
+ if (idx >= 0)
316
+ return new parser_1.Tile(constants_1.KIND.S, idx);
317
+ idx = P.findIndex(function (v) { return v == hai; });
318
+ if (idx >= 0)
319
+ return new parser_1.Tile(constants_1.KIND.P, idx);
320
+ return new parser_1.Tile(constants_1.KIND.BACK, 0);
321
+ };
322
+ var toTiles = function (hais) {
323
+ var tiles = [];
324
+ for (var _i = 0, hais_1 = hais; _i < hais_1.length; _i++) {
325
+ var hai = hais_1[_i];
326
+ tiles.push(toTile(hai));
327
+ }
328
+ return tiles;
329
+ };
330
+ var toHais = function (tiles) {
331
+ var hais = [];
332
+ for (var _i = 0, tiles_1 = tiles; _i < tiles_1.length; _i++) {
333
+ var tile = tiles_1[_i];
334
+ var n = tile.n;
335
+ var k = tile.k;
336
+ if (k == constants_1.KIND.Z)
337
+ hais.push(Z[n]);
338
+ if (k == constants_1.KIND.M)
339
+ hais.push(M[n]);
340
+ if (k == constants_1.KIND.S)
341
+ hais.push(S[n]);
342
+ if (k == constants_1.KIND.P)
343
+ hais.push(P[n]);
344
+ if (k == constants_1.KIND.BACK)
345
+ hais.push(UNSCREEN);
346
+ }
347
+ return hais;
348
+ };
@@ -5,7 +5,6 @@ interface InitializeConfig extends Omit<ImageHelperConfig, "scale"> {
5
5
  tableScale?: number;
6
6
  }
7
7
  export declare class mjimage {
8
- static svgURL: () => string;
9
8
  static initialize: (props?: InitializeConfig) => void;
10
9
  }
11
10
  export {};
@@ -10,19 +10,14 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
13
  Object.defineProperty(exports, "__esModule", { value: true });
17
14
  exports.mjimage = void 0;
18
- var assert_1 = __importDefault(require("assert"));
19
15
  var parser_1 = require("./parser");
20
16
  var image_1 = require("./image");
21
- var context_1 = require("./context");
17
+ var measure_text_1 = require("./measure-text");
22
18
  var table_1 = require("./table");
23
19
  var constants_1 = require("./constants");
24
20
  var svg_js_1 = require("@svgdotjs/svg.js");
25
- var tiles_svg_1 = __importDefault(require("./tiles.svg"));
26
21
  var defaultQuerySelector = ".mjimage";
27
22
  var defaultScale = 1.6;
28
23
  var defaultSvgSprite = false;
@@ -34,9 +29,6 @@ var calculateScale = function (scale, textHeight) {
34
29
  var mjimage = (function () {
35
30
  function mjimage() {
36
31
  }
37
- mjimage.svgURL = function () {
38
- return tiles_svg_1.default;
39
- };
40
32
  mjimage.initialize = function (props) {
41
33
  var _a, _b, _c, _d;
42
34
  if (props === void 0) { props = {}; }
@@ -47,8 +39,7 @@ var mjimage = (function () {
47
39
  var svgSprite = (_d = props.svgSprite) !== null && _d !== void 0 ? _d : defaultSvgSprite;
48
40
  if (typeof querySelector === "string")
49
41
  querySelector = [querySelector];
50
- var ctx = document.createElement("canvas").getContext("2d");
51
- (0, assert_1.default)(ctx != null);
42
+ var mtext = new measure_text_1.MeasureText();
52
43
  querySelector.forEach(function (qs) {
53
44
  console.debug("try to find", qs);
54
45
  var targets = document.querySelectorAll(qs);
@@ -68,7 +59,7 @@ var mjimage = (function () {
68
59
  try {
69
60
  if (tableRegex.test(input)) {
70
61
  var scale = calculateScale(tableScale, textHeight);
71
- var fontCtx = (0, context_1.getTableFontContext)(ctx, scale);
62
+ var fontCtx = mtext.measureTableFontContext(scale);
72
63
  (0, table_1.drawTable)(svg, input, __assign(__assign({}, props), { svgSprite: svgSprite, scale: scale }), fontCtx);
73
64
  }
74
65
  else {
@@ -1,14 +1,20 @@
1
- import { BLOCK, OPERATOR, KIND } from "./constants";
1
+ import { BLOCK, OPERATOR, KIND, INPUT_SEPARATOR } from "./constants";
2
+ type Separator = typeof INPUT_SEPARATOR;
2
3
  export declare const tileSortFunc: (i: Tile, j: Tile) => number;
3
- type Kind = (typeof KIND)[keyof typeof KIND];
4
+ export type Kind = (typeof KIND)[keyof typeof KIND];
4
5
  export declare function isKind(v: string): [Kind, boolean];
5
6
  type Operator = (typeof OPERATOR)[keyof typeof OPERATOR];
6
7
  export declare class Tile {
7
8
  k: Kind;
8
9
  n: number;
9
- op?: Operator | undefined;
10
- constructor(k: Kind, n: number, op?: Operator | undefined);
10
+ ops: Operator[];
11
+ constructor(k: Kind, n: number, ops?: Operator[]);
11
12
  toString(): string;
13
+ clone(): Tile;
14
+ has(op: Operator): boolean;
15
+ add(op: Operator): Tile;
16
+ remove(op: Operator): Tile;
17
+ isNum(): boolean;
12
18
  equals(t: Tile, ignoreRed?: boolean): boolean;
13
19
  }
14
20
  type BLOCK = (typeof BLOCK)[keyof typeof BLOCK];
@@ -17,13 +23,51 @@ export declare class Block {
17
23
  type: BLOCK;
18
24
  constructor(tiles: Tile[], type: BLOCK);
19
25
  toString(): string;
26
+ is(type: BLOCK): boolean;
27
+ isCalled(): boolean;
28
+ equals(b: Block): boolean;
29
+ minTile(): Tile;
30
+ clone(): Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockSet | BlockIsolated;
20
31
  }
32
+ export declare class BlockChi extends Block {
33
+ constructor(tiles: [Tile, Tile, Tile]);
34
+ }
35
+ export declare class BlockPon extends Block {
36
+ constructor(tiles: [Tile, Tile, Tile]);
37
+ }
38
+ export declare class BlockAnKan extends Block {
39
+ constructor(tiles: Tile[]);
40
+ toString(): string;
41
+ }
42
+ export declare class BlockDaiKan extends Block {
43
+ constructor(tiles: Tile[]);
44
+ }
45
+ export declare class BlockShoKan extends Block {
46
+ constructor(tiles: Tile[]);
47
+ }
48
+ export declare class BlockPair extends Block {
49
+ constructor(tile1: Tile, tile2: Tile);
50
+ }
51
+ declare class BlockSet extends Block {
52
+ constructor(tiles: [Tile, Tile, Tile]);
53
+ }
54
+ export declare class BlockThree extends BlockSet {
55
+ constructor(tiles: [Tile, Tile, Tile]);
56
+ }
57
+ export declare class BlockRun extends BlockSet {
58
+ constructor(tiles: [Tile, Tile, Tile]);
59
+ }
60
+ export declare class BlockIsolated extends Block {
61
+ constructor(tile: Tile);
62
+ }
63
+ export declare const blockWrapper: (tiles: Tile[], type: BLOCK) => Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockSet | BlockIsolated;
21
64
  export declare class Parser {
22
65
  readonly input: string;
23
- readonly maxInputLength = 128;
66
+ readonly maxInputLength = 600;
24
67
  constructor(input: string);
25
- parse(): Block[];
26
- parseInput(): Tile[];
68
+ parse(): (Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan)[];
69
+ tiles(): Tile[];
70
+ tileSeparators(): (Tile | Separator)[];
27
71
  private makeBlocks;
28
72
  validate(input: string): void;
29
73
  }