@konoui/mjimage 0.0.30 → 0.0.32

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 (59) hide show
  1. package/dist/index.cjs +30 -0
  2. package/dist/index.d.cts +1386 -0
  3. package/dist/index.d.ts +1386 -0
  4. package/dist/index.js +10953 -0
  5. package/package.json +23 -18
  6. package/dist/mjs/cmd/index.d.ts +0 -1
  7. package/dist/mjs/cmd/index.js +0 -49
  8. package/dist/mjs/index.d.ts +0 -6
  9. package/dist/mjs/index.js +0 -22
  10. package/dist/mjs/lib/calculator/calc.d.ts +0 -275
  11. package/dist/mjs/lib/calculator/calc.js +0 -1399
  12. package/dist/mjs/lib/calculator/efficiency.d.ts +0 -24
  13. package/dist/mjs/lib/calculator/efficiency.js +0 -82
  14. package/dist/mjs/lib/calculator/helper.d.ts +0 -6
  15. package/dist/mjs/lib/calculator/helper.js +0 -21
  16. package/dist/mjs/lib/calculator/index.d.ts +0 -3
  17. package/dist/mjs/lib/calculator/index.js +0 -19
  18. package/dist/mjs/lib/controller/controller.d.ts +0 -168
  19. package/dist/mjs/lib/controller/controller.js +0 -900
  20. package/dist/mjs/lib/controller/events.d.ts +0 -171
  21. package/dist/mjs/lib/controller/events.js +0 -102
  22. package/dist/mjs/lib/controller/game.d.ts +0 -5
  23. package/dist/mjs/lib/controller/game.js +0 -29
  24. package/dist/mjs/lib/controller/index.d.ts +0 -10
  25. package/dist/mjs/lib/controller/index.js +0 -26
  26. package/dist/mjs/lib/controller/managers.d.ts +0 -83
  27. package/dist/mjs/lib/controller/managers.js +0 -197
  28. package/dist/mjs/lib/controller/player-efficiency.d.ts +0 -24
  29. package/dist/mjs/lib/controller/player-efficiency.js +0 -156
  30. package/dist/mjs/lib/controller/player.d.ts +0 -12
  31. package/dist/mjs/lib/controller/player.js +0 -85
  32. package/dist/mjs/lib/controller/replay.d.ts +0 -10
  33. package/dist/mjs/lib/controller/replay.js +0 -34
  34. package/dist/mjs/lib/controller/river.d.ts +0 -19
  35. package/dist/mjs/lib/controller/river.js +0 -55
  36. package/dist/mjs/lib/controller/state-machine.d.ts +0 -67
  37. package/dist/mjs/lib/controller/state-machine.js +0 -771
  38. package/dist/mjs/lib/controller/wall.d.ts +0 -24
  39. package/dist/mjs/lib/controller/wall.js +0 -117
  40. package/dist/mjs/lib/core/constants.d.ts +0 -73
  41. package/dist/mjs/lib/core/constants.js +0 -73
  42. package/dist/mjs/lib/core/index.d.ts +0 -2
  43. package/dist/mjs/lib/core/index.js +0 -18
  44. package/dist/mjs/lib/core/lexer.d.ts +0 -14
  45. package/dist/mjs/lib/core/lexer.js +0 -53
  46. package/dist/mjs/lib/core/parser.d.ts +0 -120
  47. package/dist/mjs/lib/core/parser.js +0 -612
  48. package/dist/mjs/lib/image/image.d.ts +0 -42
  49. package/dist/mjs/lib/image/image.js +0 -361
  50. package/dist/mjs/lib/image/index.d.ts +0 -1
  51. package/dist/mjs/lib/image/index.js +0 -17
  52. package/dist/mjs/lib/measure-text/index.d.ts +0 -19
  53. package/dist/mjs/lib/measure-text/index.js +0 -49
  54. package/dist/mjs/lib/table/index.d.ts +0 -2
  55. package/dist/mjs/lib/table/index.js +0 -18
  56. package/dist/mjs/lib/table/table-parser.d.ts +0 -127
  57. package/dist/mjs/lib/table/table-parser.js +0 -105
  58. package/dist/mjs/lib/table/table.d.ts +0 -12
  59. package/dist/mjs/lib/table/table.js +0 -248
@@ -0,0 +1,1386 @@
1
+ import { Actor } from 'xstate';
2
+ import { AnyActorRef } from 'xstate';
3
+ import { ArraySchema } from 'valibot';
4
+ import { EventObject } from 'xstate';
5
+ import { G } from '@svgdotjs/svg.js';
6
+ import { Image as Image_2 } from '@svgdotjs/svg.js';
7
+ import { InferOutput } from 'valibot';
8
+ import { MaxValueAction } from 'valibot';
9
+ import { MetaObject } from 'xstate';
10
+ import { MinValueAction } from 'valibot';
11
+ import { NonReducibleUnknown } from 'xstate';
12
+ import { NumberSchema } from 'valibot';
13
+ import { OptionalSchema } from 'valibot';
14
+ import { ParameterizedObject } from 'xstate';
15
+ import { PicklistSchema } from 'valibot';
16
+ import { ProvidedActor } from 'xstate';
17
+ import { SchemaWithPipe } from 'valibot';
18
+ import { StateMachine } from 'xstate';
19
+ import { StateValue } from 'xstate';
20
+ import { StrictObjectSchema } from 'valibot';
21
+ import { StringSchema } from 'valibot';
22
+ import { Svg } from '@svgdotjs/svg.js';
23
+ import { Use } from '@svgdotjs/svg.js';
24
+
25
+ export declare class ActorHand extends Hand {
26
+ isBackHand(): boolean;
27
+ clone(): ActorHand;
28
+ dec(tiles: readonly Tile[]): Tile[];
29
+ }
30
+
31
+ export declare abstract class BaseActor {
32
+ id: string;
33
+ river: River;
34
+ placeManager: PlaceManager;
35
+ scoreManager: ScoreManager;
36
+ hands: {
37
+ "1w": ActorHand;
38
+ "2w": ActorHand;
39
+ "3w": ActorHand;
40
+ "4w": ActorHand;
41
+ };
42
+ counter: Counter;
43
+ doraMarkers: Tile[];
44
+ eventHandler: EventHandler;
45
+ constructor(id: string, eventHandler: EventHandler);
46
+ hand(w: Wind): ActorHand;
47
+ protected abstract setHands(e: DistributeEvent): void;
48
+ handleEvent(e: PlayerEvent): void;
49
+ }
50
+
51
+ declare class BaseHelper {
52
+ readonly tileWidth: number;
53
+ readonly tileHeight: number;
54
+ readonly imageHostPath: string;
55
+ readonly imageHostUrl: string;
56
+ readonly imageExt: string;
57
+ readonly scale: number;
58
+ readonly svgSprite: boolean;
59
+ constructor(props?: ImageHelperConfig);
60
+ protected getDiffTileHeightWidth(t: Tile): number;
61
+ private image;
62
+ createImage(tile: Tile, x: number, y: number): Image_2 | Use;
63
+ createTextImage(tile: Tile, x: number, y: number, t: string): G;
64
+ createRotate90Image(tile: Tile, x: number, y: number, adjustY?: boolean): G;
65
+ createStick(v: 100 | 1000): Image_2 | Use;
66
+ static buildID(tile: Tile | 100 | 1000): string;
67
+ buildURL(tile: Tile | 100 | 1000): string;
68
+ }
69
+
70
+ export declare const BLOCK: {
71
+ readonly PON: "pon";
72
+ readonly CHI: "chi";
73
+ readonly SHO_KAN: "shokan";
74
+ readonly DAI_KAN: "daikan";
75
+ readonly AN_KAN: "ankan";
76
+ readonly TSUMO: "tsumo";
77
+ readonly THREE: "three";
78
+ readonly PAIR: "pair";
79
+ readonly ISOLATED: "isolated";
80
+ readonly RUN: "run";
81
+ readonly HAND: "hand";
82
+ readonly IMAGE_DORA: "dora";
83
+ readonly IMAGE_DISCARD: "simple-discard";
84
+ readonly UNKNOWN: "unknown";
85
+ };
86
+
87
+ export declare abstract class Block {
88
+ private readonly _tiles;
89
+ private readonly _type;
90
+ constructor(tiles: readonly Tile[], type: BLOCK);
91
+ static from(v: SerializedBlock): Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockRun | BlockThree | BlockHand | BlockIsolated | BlockOther;
92
+ serialize(): {
93
+ tiles: string;
94
+ type: "pon" | "chi" | "shokan" | "daikan" | "ankan" | "tsumo" | "three" | "pair" | "isolated" | "run" | "hand" | "dora" | "simple-discard" | "unknown";
95
+ };
96
+ toJSON(): {
97
+ tiles: string;
98
+ type: "pon" | "chi" | "shokan" | "daikan" | "ankan" | "tsumo" | "three" | "pair" | "isolated" | "run" | "hand" | "dora" | "simple-discard" | "unknown";
99
+ };
100
+ get type(): "pon" | "chi" | "shokan" | "daikan" | "ankan" | "tsumo" | "three" | "pair" | "isolated" | "run" | "hand" | "dora" | "simple-discard" | "unknown";
101
+ get tiles(): readonly Tile[];
102
+ abstract toString(): string;
103
+ is(type: BLOCK): boolean;
104
+ isCalled(): boolean;
105
+ clone(override?: {
106
+ replace?: {
107
+ idx: number;
108
+ tile: Tile;
109
+ };
110
+ }): Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockRun | BlockThree | BlockHand | BlockIsolated | BlockOther;
111
+ imageSize(scale: number): {
112
+ width: number;
113
+ height: number;
114
+ };
115
+ }
116
+
117
+ export declare class BlockAnKan extends Block {
118
+ constructor(tiles: readonly Tile[]);
119
+ get tilesWithBack(): Tile[];
120
+ static from(v: SerializedBlock): BlockAnKan;
121
+ toString(): string;
122
+ }
123
+
124
+ export declare class BlockCalculator {
125
+ hand: Hand;
126
+ constructor(hand: Hand);
127
+ calc(lastTile: Tile): Block[][];
128
+ markDrawn(hands: Block[][], lastTile: Tile): Block[][];
129
+ sevenPairs(): Block[][];
130
+ thirteenOrphans(): Block[][];
131
+ nineGates(): Block[][];
132
+ fourSetsOnePair(): Block[][];
133
+ private commonAll;
134
+ private commonByType;
135
+ }
136
+
137
+ export declare class BlockChi extends Block {
138
+ constructor(tiles: readonly [Tile, Tile, Tile]);
139
+ toString(): string;
140
+ }
141
+
142
+ export declare class BlockDaiKan extends Block {
143
+ constructor(tiles: readonly Tile[]);
144
+ toString(): string;
145
+ }
146
+
147
+ export declare class BlockHand extends Block {
148
+ constructor(tiles: readonly Tile[]);
149
+ toString(): string;
150
+ }
151
+
152
+ export declare class BlockIsolated extends Block {
153
+ constructor(tile: Tile);
154
+ toString(): string;
155
+ }
156
+
157
+ export declare class BlockOther extends Block {
158
+ constructor(tiles: readonly Tile[], type: BLOCK);
159
+ toString(): string;
160
+ }
161
+
162
+ export declare class BlockPair extends Block {
163
+ constructor(tile1: Tile, tile2: Tile);
164
+ toString(): string;
165
+ }
166
+
167
+ export declare class BlockPon extends Block {
168
+ constructor(tiles: readonly [Tile, Tile, Tile]);
169
+ toString(): string;
170
+ }
171
+
172
+ export declare class BlockRun extends Block {
173
+ constructor(tiles: readonly [Tile, Tile, Tile]);
174
+ toString(): string;
175
+ }
176
+
177
+ export declare class BlockShoKan extends Block {
178
+ constructor(tiles: readonly Tile[]);
179
+ toString(): string;
180
+ }
181
+
182
+ export declare class BlockThree extends Block {
183
+ constructor(tiles: readonly [Tile, Tile, Tile]);
184
+ toString(): string;
185
+ }
186
+
187
+ export declare interface BoardContext {
188
+ doraMarkers: Tile[];
189
+ blindDoraMarkers?: Tile[];
190
+ round: Round;
191
+ myWind: Wind;
192
+ ronWind?: Wind;
193
+ sticks?: {
194
+ reach: number;
195
+ dead: number;
196
+ };
197
+ reached?: 1 | 2;
198
+ replacementWin?: boolean;
199
+ quadWin?: boolean;
200
+ finalWallWin?: boolean;
201
+ finalDiscardWin?: boolean;
202
+ oneShotWin?: boolean;
203
+ }
204
+
205
+ declare type BoardRound = (typeof ROUND_MAP)[keyof typeof ROUND_MAP];
206
+
207
+ declare type BoardWind = (typeof WIND_MAP)[keyof typeof WIND_MAP];
208
+
209
+ export declare interface CallEvent {
210
+ id: string;
211
+ type: Extract<ChoiceEvent, "PON" | "CHI" | "AN_KAN" | "SHO_KAN" | "DAI_KAN">;
212
+ iam: Wind;
213
+ wind: Wind;
214
+ block: SerializedBlock;
215
+ }
216
+
217
+ export declare interface Candidate {
218
+ tile: Tile;
219
+ candidates: readonly Tile[];
220
+ shanten: number;
221
+ }
222
+
223
+ export declare interface ChoiceAfterCalled {
224
+ id: string;
225
+ type: Extract<Event_2, "CHOICE_AFTER_CALLED">;
226
+ wind: Wind;
227
+ choices: Pick<DrawnChoice, "DISCARD">;
228
+ }
229
+
230
+ export declare interface ChoiceAfterDiscardedEvent {
231
+ id: string;
232
+ type: Extract<Event_2, "CHOICE_AFTER_DISCARDED">;
233
+ wind: Wind;
234
+ discarterInfo: {
235
+ wind: Wind;
236
+ tile: string;
237
+ };
238
+ choices: DiscardedChoice;
239
+ }
240
+
241
+ export declare interface ChoiceAfterDrawnEvent {
242
+ id: string;
243
+ type: Extract<Event_2, "CHOICE_AFTER_DRAWN">;
244
+ wind: Wind;
245
+ drawerInfo: {
246
+ wind: Wind;
247
+ tile: string;
248
+ };
249
+ choices: DrawnChoice;
250
+ }
251
+
252
+ declare type ChoiceEvent = "PON" | "CHI" | "RON" | "DISCARD" | "TSUMO" | "REACH" | "AN_KAN" | "SHO_KAN" | "DAI_KAN" | "DRAWN_GAME_BY_NINE_TILES";
253
+
254
+ export declare interface ChoiceForChanKan {
255
+ id: string;
256
+ type: Extract<Event_2, "CHOICE_FOR_CHAN_KAN">;
257
+ wind: Wind;
258
+ callerInfo: {
259
+ wind: Wind;
260
+ tile: string;
261
+ };
262
+ choices: Pick<DiscardedChoice, "RON">;
263
+ }
264
+
265
+ export declare class Controller {
266
+ wall: Wall;
267
+ playerIDs: string[];
268
+ actor: Actor<StateMachine< {
269
+ currentWind: Wind;
270
+ oneShotMap: { [key in Wind]: boolean; };
271
+ missingMap: { [key in Wind]: boolean; };
272
+ controller: Controller;
273
+ genEventID: ReturnType<incrementalIDGenerator>;
274
+ }, {
275
+ type: "";
276
+ } | {
277
+ type: "NEXT";
278
+ } | {
279
+ type: "CHI";
280
+ block: BlockChi;
281
+ iam: Wind;
282
+ } | {
283
+ type: "PON";
284
+ block: BlockPon;
285
+ iam: Wind;
286
+ } | {
287
+ type: "RON";
288
+ ret: WinResult;
289
+ iam: Wind;
290
+ targetInfo: {
291
+ wind: Wind;
292
+ tile: Tile;
293
+ };
294
+ quadWin?: boolean;
295
+ } | {
296
+ type: "TSUMO";
297
+ ret: WinResult;
298
+ iam: Wind;
299
+ lastTile: Tile;
300
+ } | {
301
+ type: "REACH";
302
+ tile: Tile;
303
+ iam: Wind;
304
+ } | {
305
+ type: "DISCARD";
306
+ tile: Tile;
307
+ iam: Wind;
308
+ } | {
309
+ type: "AN_KAN";
310
+ block: BlockAnKan;
311
+ iam: Wind;
312
+ } | {
313
+ type: "SHO_KAN";
314
+ block: BlockShoKan;
315
+ iam: Wind;
316
+ } | {
317
+ type: "DAI_KAN";
318
+ block: BlockDaiKan;
319
+ iam: Wind;
320
+ } | {
321
+ type: "DRAWN_GAME_BY_NINE_TILES";
322
+ iam: Wind;
323
+ }, Record<string, AnyActorRef>, ProvidedActor, ParameterizedObject, ParameterizedObject, never, StateValue, string, unknown, NonReducibleUnknown, EventObject, MetaObject, any>>;
324
+ observer: Observer;
325
+ handlers: {
326
+ [id: string]: EventHandler;
327
+ };
328
+ mailBox: {
329
+ [id: string]: PlayerEvent[];
330
+ };
331
+ histories: History_2[];
332
+ debugMode: boolean;
333
+ snapshot?: string;
334
+ constructor(players: PlayerProps[], params?: {
335
+ debug?: boolean;
336
+ });
337
+ boardParams(w: Wind): BoardContext;
338
+ hand(w: Wind): ActorHand;
339
+ get placeManager(): PlaceManager;
340
+ get scoreManager(): ScoreManager;
341
+ get river(): River;
342
+ next(force?: boolean): void;
343
+ emit(e: PlayerEvent): void;
344
+ enqueue(event: PlayerEvent): void;
345
+ pollReplies(eventID: string, wind: Wind[]): void;
346
+ export(): History_2[];
347
+ static load(h: History_2): Controller;
348
+ start(): void;
349
+ startGame(): void;
350
+ finalResult(ret: WinResult, iam: Wind): WinResult;
351
+ doWin(w: Wind, t: Tile | null | undefined, params?: {
352
+ quadWin?: boolean;
353
+ replacementWin?: boolean;
354
+ oneShot?: boolean;
355
+ missingRon?: boolean;
356
+ whoDiscarded?: Wind;
357
+ }): WinResult | false;
358
+ doPon(w: Wind, whoDiscarded: Wind, t?: Tile): BlockPon[] | false;
359
+ doChi(w: Wind, whoDiscarded: Wind, t?: Tile): BlockChi[] | false;
360
+ redPattern(blocks: BlockChi[], hasRed: boolean): BlockChi[];
361
+ doReach(w: Wind): Candidate[] | false;
362
+ doDiscard(w: Wind, called?: BlockChi | BlockPon): Tile[];
363
+ cannotDiscardTile(called: BlockChi): Tile[];
364
+ doAnKan(w: Wind): BlockAnKan[] | false;
365
+ doShoKan(w: Wind): BlockShoKan[] | false;
366
+ doDaiKan(w: Wind, whoDiscarded: Wind, t: Tile): BlockDaiKan | false;
367
+ canDrawnGame(w: Wind): boolean;
368
+ initialHands(): {
369
+ "1w": string;
370
+ "2w": string;
371
+ "3w": string;
372
+ "4w": string;
373
+ };
374
+ }
375
+
376
+ declare type ControllerContext = {
377
+ currentWind: Wind;
378
+ oneShotMap: {
379
+ [key in Wind]: boolean;
380
+ };
381
+ missingMap: {
382
+ [key in Wind]: boolean;
383
+ };
384
+ controller: Controller;
385
+ genEventID: ReturnType<typeof incrementalIDGenerator>;
386
+ };
387
+
388
+ export declare const convertInput: (i: TableInput) => {
389
+ discards: DiscardsInput;
390
+ hands: HandsInput;
391
+ scoreBoard: ScoreBoardInput;
392
+ };
393
+
394
+ export declare class Counter {
395
+ disable: boolean;
396
+ private c;
397
+ safeMap: {
398
+ "1w": {
399
+ [name: string]: boolean;
400
+ };
401
+ "2w": {
402
+ [name: string]: boolean;
403
+ };
404
+ "3w": {
405
+ [name: string]: boolean;
406
+ };
407
+ "4w": {
408
+ [name: string]: boolean;
409
+ };
410
+ };
411
+ constructor(disable?: boolean);
412
+ get(t: Tile): number;
413
+ dec(...tiles: Tile[]): void;
414
+ addTileToSafeMap(t: Tile, targetUser: Wind): void;
415
+ isSafeTile(k: Type, n: number, targetUser: Wind): boolean;
416
+ private key;
417
+ reset(): void;
418
+ }
419
+
420
+ export declare const createControllerMachine: (c: Controller) => StateMachine<ControllerContext, {
421
+ type: "";
422
+ } | {
423
+ type: "NEXT";
424
+ } | {
425
+ type: "CHI";
426
+ block: BlockChi;
427
+ iam: Wind;
428
+ } | {
429
+ type: "PON";
430
+ block: BlockPon;
431
+ iam: Wind;
432
+ } | {
433
+ type: "RON";
434
+ ret: WinResult;
435
+ iam: Wind;
436
+ targetInfo: {
437
+ wind: Wind;
438
+ tile: Tile;
439
+ };
440
+ quadWin?: boolean;
441
+ } | {
442
+ type: "TSUMO";
443
+ ret: WinResult;
444
+ iam: Wind;
445
+ lastTile: Tile;
446
+ } | {
447
+ type: "REACH";
448
+ tile: Tile;
449
+ iam: Wind;
450
+ } | {
451
+ type: "DISCARD";
452
+ tile: Tile;
453
+ iam: Wind;
454
+ } | {
455
+ type: "AN_KAN";
456
+ block: BlockAnKan;
457
+ iam: Wind;
458
+ } | {
459
+ type: "SHO_KAN";
460
+ block: BlockShoKan;
461
+ iam: Wind;
462
+ } | {
463
+ type: "DAI_KAN";
464
+ block: BlockDaiKan;
465
+ iam: Wind;
466
+ } | {
467
+ type: "DRAWN_GAME_BY_NINE_TILES";
468
+ iam: Wind;
469
+ }, Record<string, AnyActorRef>, ProvidedActor, ParameterizedObject, ParameterizedObject, never, StateValue, string, unknown, NonReducibleUnknown, EventObject, MetaObject, any>;
470
+
471
+ export declare const createEventEmitter: () => {
472
+ emit: (e: PlayerEvent) => void;
473
+ on: (h: EventHandlerFunc) => void;
474
+ };
475
+
476
+ export declare const createEventPipe: () => [EventHandler, EventHandler];
477
+
478
+ export declare const createHand: (helper: ImageHelper, blocks: Block[]) => {
479
+ e: G;
480
+ width: number;
481
+ height: number;
482
+ };
483
+
484
+ export declare const createLocalGame: (params?: {
485
+ playerIDs?: string[];
486
+ debug?: boolean;
487
+ }) => Controller;
488
+
489
+ export declare const createTable: (helper: ImageHelper, fontCtx: FontContext, handsProps: HandsInput, discardsProps: DiscardsInput, scoreBoardProps: ScoreBoardInput) => {
490
+ e: G;
491
+ width: number;
492
+ height: number;
493
+ };
494
+
495
+ export declare function createWindMap<T>(initial: T, clone?: boolean): {
496
+ "1w": T;
497
+ "2w": T;
498
+ "3w": T;
499
+ "4w": T;
500
+ };
501
+
502
+ export declare const deserializeWinResult: (ret: SerializedWinResult) => WinResult;
503
+
504
+ declare interface DiscardedChoice {
505
+ RON: false | SerializedWinResult;
506
+ PON: false | SerializedBlock[];
507
+ CHI: false | SerializedBlock[];
508
+ DAI_KAN: false | SerializedBlock;
509
+ }
510
+
511
+ export declare interface DiscardEvent {
512
+ id: string;
513
+ type: Extract<ChoiceEvent, "DISCARD">;
514
+ iam: Wind;
515
+ wind: Wind;
516
+ tile: string;
517
+ }
518
+
519
+ export declare interface DiscardsInput {
520
+ front: Tile[];
521
+ right: Tile[];
522
+ opposite: Tile[];
523
+ left: Tile[];
524
+ }
525
+
526
+ export declare interface DistributeEvent {
527
+ id: string;
528
+ type: Extract<Event_2, "DISTRIBUTE">;
529
+ hands: {
530
+ [key in Wind]: string;
531
+ };
532
+ wind: Wind;
533
+ doraMarker: string;
534
+ players: string[];
535
+ places: {
536
+ [key: string]: Wind;
537
+ };
538
+ sticks: {
539
+ reach: number;
540
+ dead: number;
541
+ };
542
+ round: Round;
543
+ scores: {
544
+ [key: string]: number;
545
+ };
546
+ }
547
+
548
+ export declare class DoubleCalculator {
549
+ hand: Hand;
550
+ cfg: {
551
+ doras: Tile[];
552
+ blindDoras: Tile[];
553
+ roundWind: Tile;
554
+ myWind: Tile;
555
+ reached: 0 | 1 | 2;
556
+ sticks: {
557
+ reach: number;
558
+ dead: number;
559
+ };
560
+ replacementWin: boolean;
561
+ quadWin: boolean;
562
+ finalWallWin: boolean;
563
+ finalDiscardWin: boolean;
564
+ oneShotWin: boolean;
565
+ orig: BoardContext;
566
+ };
567
+ constructor(hand: Hand, params: BoardContext);
568
+ calc(hands: Block[][]): WinResult | false;
569
+ calcPatterns(hands: Block[][]): {
570
+ points: {
571
+ name: string;
572
+ double: number;
573
+ }[];
574
+ fu: number;
575
+ hand: Block[];
576
+ }[];
577
+ private minus;
578
+ dA1(h: Block[]): {
579
+ name: string;
580
+ double: number;
581
+ }[];
582
+ dB1(h: Block[]): {
583
+ name: string;
584
+ double: number;
585
+ }[];
586
+ dC1(h: Block[]): {
587
+ name: string;
588
+ double: number;
589
+ }[];
590
+ dD1(h: Block[]): {
591
+ name: string;
592
+ double: number;
593
+ }[];
594
+ dE1(h: Block[]): {
595
+ name: string;
596
+ double: number;
597
+ }[];
598
+ dF1(h: Block[]): {
599
+ name: string;
600
+ double: number;
601
+ }[];
602
+ dG1(h: Block[]): {
603
+ name: string;
604
+ double: number;
605
+ }[];
606
+ dH1(h: Block[]): {
607
+ name: string;
608
+ double: number;
609
+ }[];
610
+ dI1(h: Block[]): {
611
+ name: string;
612
+ double: number;
613
+ }[];
614
+ dJ1(h: Block[]): {
615
+ name: string;
616
+ double: number;
617
+ }[];
618
+ dK1(h: Block[]): {
619
+ name: string;
620
+ double: number;
621
+ }[];
622
+ dX1(h: Block[]): {
623
+ name: string;
624
+ double: number;
625
+ }[];
626
+ dA2(h: Block[]): {
627
+ name: string;
628
+ double: number;
629
+ }[];
630
+ dB2(h: Block[]): {
631
+ name: string;
632
+ double: number;
633
+ }[];
634
+ dC2(h: Block[]): {
635
+ name: string;
636
+ double: number;
637
+ }[];
638
+ dD2(h: Block[]): {
639
+ name: string;
640
+ double: number;
641
+ }[];
642
+ dE2(h: Block[]): {
643
+ name: string;
644
+ double: number;
645
+ }[];
646
+ dF2(h: Block[]): {
647
+ name: string;
648
+ double: number;
649
+ }[];
650
+ dG2(h: Block[]): {
651
+ name: string;
652
+ double: number;
653
+ }[];
654
+ dH2(h: Block[]): {
655
+ name: string;
656
+ double: number;
657
+ }[];
658
+ dI2(h: Block[]): {
659
+ name: string;
660
+ double: number;
661
+ }[];
662
+ dJ2(h: Block[]): {
663
+ name: string;
664
+ double: number;
665
+ }[];
666
+ dA3(h: Block[]): {
667
+ name: string;
668
+ double: number;
669
+ }[];
670
+ dB3(h: Block[]): {
671
+ name: string;
672
+ double: number;
673
+ }[];
674
+ dC3(h: Block[]): {
675
+ name: string;
676
+ double: number;
677
+ }[];
678
+ dA6(h: Block[]): {
679
+ name: string;
680
+ double: number;
681
+ }[];
682
+ dA13(h: Block[]): {
683
+ name: string;
684
+ double: number;
685
+ }[];
686
+ dB13(h: Block[]): {
687
+ name: string;
688
+ double: number;
689
+ }[];
690
+ dC13(h: Block[]): {
691
+ name: string;
692
+ double: number;
693
+ }[];
694
+ dD13(h: Block[]): {
695
+ name: string;
696
+ double: number;
697
+ }[];
698
+ dE13(h: Block[]): {
699
+ name: string;
700
+ double: number;
701
+ }[];
702
+ dF13(h: Block[]): {
703
+ name: string;
704
+ double: number;
705
+ }[];
706
+ dG13(h: Block[]): {
707
+ name: string;
708
+ double: number;
709
+ }[];
710
+ dH13(h: Block[]): {
711
+ name: string;
712
+ double: number;
713
+ }[];
714
+ dI13(h: Block[]): {
715
+ name: string;
716
+ double: number;
717
+ }[];
718
+ dJ13(h: Block[]): never[];
719
+ dK13(h: Block[]): never[];
720
+ calcFu(h: Block[]): number;
721
+ }
722
+
723
+ export declare const drawBlocks: (svg: Svg, blocks: Block[], config?: ImageHelperConfig, params?: {
724
+ responsive: boolean;
725
+ }) => void;
726
+
727
+ export declare interface DrawEvent {
728
+ id: string;
729
+ type: Extract<Event_2, "DRAW">;
730
+ subtype?: "kan";
731
+ iam: Wind;
732
+ wind: Wind;
733
+ tile: string;
734
+ }
735
+
736
+ declare interface DrawnChoice {
737
+ TSUMO: false | SerializedWinResult;
738
+ REACH: false | SerializedCandidate[];
739
+ AN_KAN: false | SerializedBlock[];
740
+ SHO_KAN: false | SerializedBlock[];
741
+ DISCARD: false | string[];
742
+ DRAWN_GAME_BY_NINE_TILES: boolean;
743
+ }
744
+
745
+ export declare const drawTable: (svg: Svg, tableInput: string, config: ImageHelperConfig | undefined, fontCtx: FontContext, params?: {
746
+ responsive: boolean;
747
+ }) => void;
748
+
749
+ export declare class Efficiency {
750
+ static calcCandidates(hand: Hand, choices: Tile[]): Candidate[];
751
+ static candidateTiles(hand: Hand): {
752
+ shanten: number;
753
+ candidates: Tile[];
754
+ };
755
+ static partialCandidateTiles(input: string): {
756
+ shanten: number;
757
+ candidates: Tile[];
758
+ };
759
+ static partialShanten(input: string): number;
760
+ }
761
+
762
+ export declare interface EndEvent {
763
+ id: string;
764
+ type: Extract<Event_2, "END_GAME">;
765
+ subType: "WIN_GAME" | "DRAWN_GAME" | "FOUR_KAN" | "FOUR_WIND" | "NINE_TILES";
766
+ wind: Wind;
767
+ scores: {
768
+ [key: string]: number;
769
+ };
770
+ sticks: {
771
+ reach: number;
772
+ dead: number;
773
+ };
774
+ deltas: {
775
+ [key in Wind]: number;
776
+ };
777
+ hands: {
778
+ [key in Wind]: string;
779
+ };
780
+ shouldContinue: boolean;
781
+ }
782
+
783
+ declare type Event_2 = CallEvent | "DRAW" | "CHOICE_AFTER_DRAWN" | "CHOICE_AFTER_DISCARDED" | "CHOICE_AFTER_CALLED" | "CHOICE_FOR_CHAN_KAN" | "DISTRIBUTE" | "NEW_DORA" | "END_GAME";
784
+
785
+ export declare interface EventHandler {
786
+ emit(e: PlayerEvent): void;
787
+ on(handler: EventHandlerFunc): void;
788
+ }
789
+
790
+ export declare type EventHandlerFunc = (e: PlayerEvent) => void;
791
+
792
+ export declare const FONT_FAMILY = "MS Gothic, sans-serif";
793
+
794
+ export declare interface FontContext {
795
+ font: {
796
+ family: string;
797
+ size: number;
798
+ };
799
+ textWidth: number;
800
+ textHeight: number;
801
+ numWidth: number;
802
+ numHeight: number;
803
+ }
804
+
805
+ export declare class Hand {
806
+ protected data: HandData;
807
+ constructor(input: string, allowBackBlock?: boolean);
808
+ private init;
809
+ get hands(): Tile[];
810
+ toString(): string;
811
+ get called(): readonly (BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan)[];
812
+ get reached(): boolean;
813
+ get drawn(): Tile | null;
814
+ get menzen(): boolean;
815
+ getArrayLen(t: Type): 2 | 8 | 10;
816
+ sum(t: Type): number;
817
+ get(t: Type, n: number): number;
818
+ inc(tiles: readonly Tile[]): Tile[];
819
+ dec(tiles: readonly Tile[]): Tile[];
820
+ draw(t: Tile): void;
821
+ discard(t: Tile): void;
822
+ reach(): void;
823
+ call(b: BlockPon | BlockChi | BlockDaiKan): void;
824
+ kan(b: BlockAnKan | BlockShoKan): void;
825
+ clone(): Hand;
826
+ }
827
+
828
+ export declare interface HandData {
829
+ [TYPE.M]: TupleOfSize<number, 10>;
830
+ [TYPE.S]: TupleOfSize<number, 10>;
831
+ [TYPE.P]: TupleOfSize<number, 10>;
832
+ [TYPE.Z]: TupleOfSize<number, 8>;
833
+ [TYPE.BACK]: [string, number];
834
+ called: readonly (BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan)[];
835
+ tsumo: Tile | null;
836
+ reached: boolean;
837
+ }
838
+
839
+ export declare interface HandsInput {
840
+ front: Block[];
841
+ right: Block[];
842
+ opposite: Block[];
843
+ left: Block[];
844
+ }
845
+
846
+ declare interface History_2 {
847
+ round: Round;
848
+ scores: {
849
+ [key in string]: number;
850
+ };
851
+ players: {
852
+ [key in string]: Wind;
853
+ };
854
+ sticks: {
855
+ reach: number;
856
+ dead: number;
857
+ };
858
+ wall: WallProps;
859
+ choiceEvents: {
860
+ [id: string]: PlayerEvent[];
861
+ };
862
+ }
863
+ export { History_2 as History }
864
+
865
+ export declare class ImageHelper extends BaseHelper {
866
+ readonly blockMargin: number;
867
+ createBlockHandDiscard(block: Block): G;
868
+ createBlockPonChiKan(block: Block): G;
869
+ }
870
+
871
+ export declare interface ImageHelperConfig {
872
+ scale?: number;
873
+ imageHostPath?: string;
874
+ imageHostUrl?: string;
875
+ imageExt?: "svg" | "webp";
876
+ svgSprite?: boolean;
877
+ }
878
+
879
+ export declare function incrementalIDGenerator(start?: number): () => string;
880
+
881
+ export declare const INPUT_SEPARATOR = ",";
882
+
883
+ export declare function isNum0(t: Tile): boolean;
884
+
885
+ export declare function isNum5(t: Tile): boolean;
886
+
887
+ export declare function isNum5or0(t: Tile): boolean;
888
+
889
+ export declare class MeasureText {
890
+ ctx: CanvasRenderingContext2D | null;
891
+ strText: string;
892
+ numText: string;
893
+ constructor(strText?: string, numText?: string);
894
+ private measure;
895
+ measureFontContext: (fontFamily: string, fontSize: number) => FontContext;
896
+ measureTableFontContext: (tableScale: number) => FontContext;
897
+ }
898
+
899
+ export declare const N19: readonly number[];
900
+
901
+ export declare interface NewDoraEvent {
902
+ id: string;
903
+ type: Extract<Event_2, "NEW_DORA">;
904
+ doraMarker: string;
905
+ wind: Wind;
906
+ }
907
+
908
+ export declare const nextRound: (r: Round) => Round;
909
+
910
+ export declare const nextWind: (w: Wind) => Wind;
911
+
912
+ export declare const NZ: readonly number[];
913
+
914
+ export declare class Observer extends BaseActor {
915
+ applied: {
916
+ [id: string]: boolean;
917
+ };
918
+ constructor(eventHandler: EventHandler);
919
+ setHands(e: DistributeEvent): void;
920
+ handleEvent(e: PlayerEvent): void;
921
+ }
922
+
923
+ export declare const OPERATOR: {
924
+ readonly TSUMO: "t";
925
+ readonly RON: "r";
926
+ readonly DORA: "d";
927
+ readonly HORIZONTAL: "-";
928
+ readonly COLOR_GRAYSCALE: "^";
929
+ };
930
+
931
+ declare type Operator = (typeof OPERATOR)[keyof typeof OPERATOR];
932
+
933
+ export declare const optimizeSVG: (draw: Svg) => void;
934
+
935
+ export declare const parse: (s: string) => {
936
+ discards: DiscardsInput;
937
+ hands: HandsInput;
938
+ scoreBoard: ScoreBoardInput;
939
+ };
940
+
941
+ export declare class Parser {
942
+ readonly input: string;
943
+ readonly maxInputLength = 600;
944
+ constructor(input: string);
945
+ parse(): (BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockRun | BlockThree | BlockHand | BlockIsolated | BlockOther)[];
946
+ tiles(): Tile[];
947
+ tileSeparators(): (Tile | Separator)[];
948
+ private makeBlocks;
949
+ validate(input: string): void;
950
+ }
951
+
952
+ export declare const parseTableInput: (s: string) => {
953
+ "1w": {
954
+ hand: string;
955
+ discard: string;
956
+ score: number;
957
+ };
958
+ "2w": {
959
+ hand: string;
960
+ discard: string;
961
+ score: number;
962
+ };
963
+ "3w": {
964
+ hand: string;
965
+ discard: string;
966
+ score: number;
967
+ };
968
+ "4w": {
969
+ hand: string;
970
+ discard: string;
971
+ score: number;
972
+ };
973
+ board: {
974
+ round: "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4";
975
+ sticks: {
976
+ reach: number;
977
+ dead: number;
978
+ };
979
+ doras: string[];
980
+ front: "1w" | "2w" | "3w" | "4w";
981
+ };
982
+ };
983
+
984
+ export declare class PlaceManager {
985
+ private pToW;
986
+ private wToP;
987
+ round: Round;
988
+ sticks: {
989
+ reach: number;
990
+ dead: number;
991
+ };
992
+ constructor(initial: {
993
+ [key: string]: Wind;
994
+ }, params?: {
995
+ round: Round;
996
+ sticks: {
997
+ reach: number;
998
+ dead: number;
999
+ };
1000
+ });
1001
+ private update;
1002
+ incrementDeadStick(): void;
1003
+ incrementReachStick(): void;
1004
+ nextRound(): void;
1005
+ decrementReachStick(): void;
1006
+ resetDeadStick(): void;
1007
+ resetReachStick(): void;
1008
+ is(r: Round): boolean;
1009
+ wind(id: string): "1w" | "2w" | "3w" | "4w";
1010
+ playerID(w: Wind): string;
1011
+ get playerMap(): {
1012
+ [key: string]: "1w" | "2w" | "3w" | "4w";
1013
+ };
1014
+ }
1015
+
1016
+ export declare class Player extends BaseActor {
1017
+ river: River;
1018
+ doras: Tile[];
1019
+ constructor(playerID: string, eventHandler: EventHandler);
1020
+ get myWind(): "1w" | "2w" | "3w" | "4w";
1021
+ setHands(e: DistributeEvent): void;
1022
+ handleDiscard(tiles: Tile[]): Tile;
1023
+ handleEvent(e: PlayerEvent): void;
1024
+ }
1025
+
1026
+ export declare interface PlayerCandidate {
1027
+ tile: Tile;
1028
+ sum: number;
1029
+ candidates: {
1030
+ tile: Tile;
1031
+ n: number;
1032
+ }[];
1033
+ shanten: number;
1034
+ }
1035
+
1036
+ export declare class PlayerEfficiency {
1037
+ static calcPlayerCandidates(counter: Counter, candidates: Candidate[]): PlayerCandidate[];
1038
+ static selectMinPriority(c: Counter, playerCandidates: PlayerCandidate[], doras: Tile[]): PlayerCandidate;
1039
+ private static calcPriority;
1040
+ }
1041
+
1042
+ export declare type PlayerEvent = DistributeEvent | EndEvent | CallEvent | RonEvent | TsumoEvent | DiscardEvent | DrawEvent | ReachEvent | NewDoraEvent | ChoiceAfterDrawnEvent | ChoiceAfterDiscardedEvent | ChoiceAfterCalled | ChoiceForChanKan;
1043
+
1044
+ export declare interface PlayerProps {
1045
+ id: string;
1046
+ handler: EventHandler;
1047
+ }
1048
+
1049
+ export declare const prevRound: (r: Round) => "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4";
1050
+
1051
+ export declare const prevWind: (w: Wind) => Wind;
1052
+
1053
+ export declare function prioritizeDiscardedEvents(events: ChoiceAfterDiscardedEvent[]): {
1054
+ events: ChoiceAfterDiscardedEvent[];
1055
+ type: boolean | keyof DiscardedChoice;
1056
+ };
1057
+
1058
+ export declare function prioritizeDrawnEvents(events: ChoiceAfterDrawnEvent[]): {
1059
+ events: ChoiceAfterDrawnEvent[];
1060
+ type: boolean | keyof DrawnChoice;
1061
+ };
1062
+
1063
+ export declare interface ReachEvent {
1064
+ id: string;
1065
+ type: Extract<ChoiceEvent, "REACH">;
1066
+ tile: string;
1067
+ iam: Wind;
1068
+ wind: Wind;
1069
+ }
1070
+
1071
+ export declare class Replayer {
1072
+ index: number;
1073
+ histories: History_2[];
1074
+ constructor(v: string);
1075
+ next(): void;
1076
+ prev(): void;
1077
+ start(): void;
1078
+ auto(): void;
1079
+ }
1080
+
1081
+ export declare class RiskRank {
1082
+ static selectTile(c: Counter, targetUsers: Wind[], tiles: Tile[]): Tile;
1083
+ static rank(c: Counter, targetUsers: Wind[], t: Tile): number;
1084
+ static rankZ(c: Counter, targetUser: Wind, t: Tile): number;
1085
+ static rankN(c: Counter, targetUser: Wind, t: Tile): 0 | 5 | 3 | 4 | 6 | 8 | 12;
1086
+ }
1087
+
1088
+ export declare class River {
1089
+ private m;
1090
+ constructor();
1091
+ discard(t: Tile, w: Wind): void;
1092
+ get lastTile(): {
1093
+ w: Wind;
1094
+ t: Tile;
1095
+ callMarker?: boolean;
1096
+ };
1097
+ discards(w?: Wind): {
1098
+ w: Wind;
1099
+ t: Tile;
1100
+ callMarker?: boolean;
1101
+ }[];
1102
+ markCalled(): void;
1103
+ cannotContinue(): boolean;
1104
+ }
1105
+
1106
+ export declare interface RonEvent {
1107
+ id: string;
1108
+ type: Extract<ChoiceEvent, "RON">;
1109
+ iam: Wind;
1110
+ wind: Wind;
1111
+ ret: SerializedWinResult;
1112
+ victimInfo: {
1113
+ wind: Wind;
1114
+ tile: string;
1115
+ };
1116
+ pushBackReachStick: boolean;
1117
+ }
1118
+
1119
+ export declare type Round = keyof typeof ROUND_MAP;
1120
+
1121
+ export declare const ROUND_MAP: {
1122
+ readonly "1w1": "東1局";
1123
+ readonly "1w2": "東2局";
1124
+ readonly "1w3": "東3局";
1125
+ readonly "1w4": "東4局";
1126
+ readonly "2w1": "南1局";
1127
+ readonly "2w2": "南2局";
1128
+ readonly "2w3": "南3局";
1129
+ readonly "2w4": "南4局";
1130
+ readonly "3w1": "西1局";
1131
+ readonly "3w2": "西2局";
1132
+ readonly "3w3": "西3局";
1133
+ readonly "3w4": "西4局";
1134
+ readonly "4w1": "北1局";
1135
+ readonly "4w2": "北2局";
1136
+ readonly "4w3": "北3局";
1137
+ readonly "4w4": "北4局";
1138
+ };
1139
+
1140
+ export declare interface ScoreBoardInput {
1141
+ doras: Tile[];
1142
+ round: BoardRound;
1143
+ sticks: {
1144
+ reach: number;
1145
+ dead: number;
1146
+ };
1147
+ scores: {
1148
+ front: number;
1149
+ right: number;
1150
+ opposite: number;
1151
+ left: number;
1152
+ };
1153
+ frontPlace: BoardWind;
1154
+ }
1155
+
1156
+ export declare class ScoreManager {
1157
+ private reachValue;
1158
+ private m;
1159
+ constructor(initial: {
1160
+ [key: string]: number;
1161
+ });
1162
+ get summary(): {
1163
+ [key: string]: number;
1164
+ };
1165
+ reach(id: string): void;
1166
+ /**
1167
+ * 立直後のロンに対する立直棒の戻し
1168
+ */
1169
+ restoreReachStick(id: string): void;
1170
+ update(result: {
1171
+ "1w": number;
1172
+ "2w": number;
1173
+ "3w": number;
1174
+ "4w": number;
1175
+ }, windMap: {
1176
+ [key: string]: Wind;
1177
+ }): void;
1178
+ }
1179
+
1180
+ declare type Separator = typeof INPUT_SEPARATOR;
1181
+
1182
+ export declare type SerializedBlock = ReturnType<Block["serialize"]>;
1183
+
1184
+ declare type SerializedBoardContext = Omit<BoardContext, "doraMarkers" | "blindDoraMarkers"> & {
1185
+ doraMarkers: string[];
1186
+ blindDoraMarkers?: string[];
1187
+ };
1188
+
1189
+ export declare interface SerializedCandidate {
1190
+ tile: string;
1191
+ candidates: readonly string[];
1192
+ shanten: number;
1193
+ }
1194
+
1195
+ export declare type SerializedWinResult = Omit<WinResult, "hand" | "boardContext"> & {
1196
+ hand: SerializedBlock[];
1197
+ boardContext: SerializedBoardContext;
1198
+ };
1199
+
1200
+ export declare class ShantenCalculator {
1201
+ hand: Hand;
1202
+ constructor(hand: Hand);
1203
+ calc(): number;
1204
+ sevenPairs(): number;
1205
+ thirteenOrphans(): number;
1206
+ fourSetsOnePair(): number;
1207
+ private commonByType;
1208
+ private groupRemainingTiles;
1209
+ private calcCommon;
1210
+ }
1211
+
1212
+ export declare function shuffle<T>(array: T[]): T[];
1213
+
1214
+ export declare const TABLE_CONTEXT: {
1215
+ BASE: number;
1216
+ };
1217
+
1218
+ export declare type TableInput = InferOutput<typeof tableInputSchema>;
1219
+
1220
+ declare const tableInputSchema: StrictObjectSchema< {
1221
+ readonly board: StrictObjectSchema< {
1222
+ readonly round: OptionalSchema<PicklistSchema<("1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4")[], undefined>, "1w1">;
1223
+ readonly sticks: OptionalSchema<StrictObjectSchema< {
1224
+ readonly reach: OptionalSchema<SchemaWithPipe<[NumberSchema<undefined>, MinValueAction<number, 0, "">, MaxValueAction<number, 9, "">]>, 0>;
1225
+ readonly dead: OptionalSchema<SchemaWithPipe<[NumberSchema<undefined>, MinValueAction<number, 0, "">, MaxValueAction<number, 9, "">]>, 0>;
1226
+ }, undefined>, {
1227
+ readonly reach: 0;
1228
+ readonly dead: 0;
1229
+ }>;
1230
+ readonly doras: OptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, readonly ["3w"]>;
1231
+ readonly front: OptionalSchema<PicklistSchema<("1w" | "2w" | "3w" | "4w")[], undefined>, "1w">;
1232
+ }, undefined>;
1233
+ readonly "1w": OptionalSchema<StrictObjectSchema< {
1234
+ readonly discard: OptionalSchema<StringSchema<undefined>, "">;
1235
+ readonly hand: OptionalSchema<StringSchema<undefined>, "">;
1236
+ readonly score: OptionalSchema<NumberSchema<undefined>, 25000>;
1237
+ }, undefined>, {
1238
+ readonly discard: "";
1239
+ readonly hand: "";
1240
+ readonly score: 25000;
1241
+ }>;
1242
+ readonly "2w": OptionalSchema<StrictObjectSchema< {
1243
+ readonly discard: OptionalSchema<StringSchema<undefined>, "">;
1244
+ readonly hand: OptionalSchema<StringSchema<undefined>, "">;
1245
+ readonly score: OptionalSchema<NumberSchema<undefined>, 25000>;
1246
+ }, undefined>, {
1247
+ readonly discard: "";
1248
+ readonly hand: "";
1249
+ readonly score: 25000;
1250
+ }>;
1251
+ readonly "3w": OptionalSchema<StrictObjectSchema< {
1252
+ readonly discard: OptionalSchema<StringSchema<undefined>, "">;
1253
+ readonly hand: OptionalSchema<StringSchema<undefined>, "">;
1254
+ readonly score: OptionalSchema<NumberSchema<undefined>, 25000>;
1255
+ }, undefined>, {
1256
+ readonly discard: "";
1257
+ readonly hand: "";
1258
+ readonly score: 25000;
1259
+ }>;
1260
+ readonly "4w": OptionalSchema<StrictObjectSchema< {
1261
+ readonly discard: OptionalSchema<StringSchema<undefined>, "">;
1262
+ readonly hand: OptionalSchema<StringSchema<undefined>, "">;
1263
+ readonly score: OptionalSchema<NumberSchema<undefined>, 25000>;
1264
+ }, undefined>, {
1265
+ readonly discard: "";
1266
+ readonly hand: "";
1267
+ readonly score: 25000;
1268
+ }>;
1269
+ }, undefined>;
1270
+
1271
+ export declare type TableRound = keyof typeof ROUND_MAP;
1272
+
1273
+ export declare type TableWind = keyof typeof WIND_MAP;
1274
+
1275
+ export declare class Tile {
1276
+ readonly t: Type;
1277
+ readonly n: number;
1278
+ readonly ops: Operator[];
1279
+ constructor(t: Type, n: number, ops?: Operator[]);
1280
+ static from(s: string): Tile;
1281
+ toString(): string;
1282
+ toJSON(): string;
1283
+ clone(override?: {
1284
+ t?: Type;
1285
+ n?: number;
1286
+ remove?: Operator;
1287
+ add?: Operator;
1288
+ }): Tile;
1289
+ has(op: Operator): boolean;
1290
+ isNum(): boolean;
1291
+ equals(t: Tile, ignoreRed?: boolean): boolean;
1292
+ imageSize(scale: number): {
1293
+ width: number;
1294
+ height: number;
1295
+ baseWidth: number;
1296
+ baseHeight: number;
1297
+ };
1298
+ }
1299
+
1300
+ export declare const TILE_CONTEXT: {
1301
+ WIDTH: number;
1302
+ HEIGHT: number;
1303
+ TEXT_SCALE: number;
1304
+ BLOCK_MARGIN_SCALE: number;
1305
+ };
1306
+
1307
+ export declare const tileSortFunc: (i: Tile, j: Tile) => number;
1308
+
1309
+ export declare interface TsumoEvent {
1310
+ id: string;
1311
+ type: Extract<ChoiceEvent, "TSUMO">;
1312
+ iam: Wind;
1313
+ wind: Wind;
1314
+ lastTile: string;
1315
+ ret: SerializedWinResult;
1316
+ }
1317
+
1318
+ export declare type TupleOfSize<T, N extends number, R extends unknown[] = []> = R["length"] extends N ? R : TupleOfSize<T, N, [T, ...R]>;
1319
+
1320
+ export declare const TYPE: {
1321
+ readonly M: "m";
1322
+ readonly P: "p";
1323
+ readonly S: "s";
1324
+ readonly Z: "z";
1325
+ readonly BACK: "_";
1326
+ };
1327
+
1328
+ export declare type Type = (typeof TYPE)[keyof typeof TYPE];
1329
+
1330
+ export declare class Wall {
1331
+ private walls;
1332
+ private backup;
1333
+ private openedDoraCount;
1334
+ constructor(backup?: WallProps);
1335
+ kan(): Tile;
1336
+ draw(): Tile;
1337
+ openDoraMarker(): Tile;
1338
+ get doraMarkers(): Tile[];
1339
+ get blindDoraMarkers(): Tile[];
1340
+ get canKan(): boolean;
1341
+ get canDraw(): boolean;
1342
+ private init;
1343
+ export(): WallProps;
1344
+ static clone(walls: WallProps): WallProps;
1345
+ }
1346
+
1347
+ export declare interface WallProps {
1348
+ drawable: string[];
1349
+ dead: string[];
1350
+ replacement: string[];
1351
+ doraMarkers: string[];
1352
+ blindDoraMarkers: string[];
1353
+ }
1354
+
1355
+ export declare const WIND: {
1356
+ readonly EAST: "1w";
1357
+ readonly SOUTH: "2w";
1358
+ readonly WEST: "3w";
1359
+ readonly NORTH: "4w";
1360
+ };
1361
+
1362
+ export declare type Wind = keyof typeof WIND_MAP;
1363
+
1364
+ export declare const WIND_MAP: {
1365
+ readonly "1w": "東";
1366
+ readonly "2w": "南";
1367
+ readonly "3w": "西";
1368
+ readonly "4w": "北";
1369
+ };
1370
+
1371
+ export declare interface WinResult {
1372
+ deltas: {
1373
+ [w in Wind]: number;
1374
+ };
1375
+ sum: number;
1376
+ fu: number;
1377
+ points: {
1378
+ name: string;
1379
+ double: number;
1380
+ }[];
1381
+ point: number;
1382
+ hand: Block[];
1383
+ boardContext: BoardContext;
1384
+ }
1385
+
1386
+ export { }