@konoui/mjimage 0.5.2 → 0.6.0
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.cjs +10 -10
- package/dist/index.d.cts +112 -90
- package/dist/index.d.ts +112 -90
- package/dist/index.js +2006 -1921
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -59,7 +59,7 @@ declare class BaseHelper {
|
|
|
59
59
|
readonly scale: number;
|
|
60
60
|
readonly svgSprite: boolean;
|
|
61
61
|
constructor(props?: ImageHelperConfig);
|
|
62
|
-
protected
|
|
62
|
+
protected getHorizontalTileYOffset(t: Tile): number;
|
|
63
63
|
private image;
|
|
64
64
|
createImage(tile: Tile, x: number, y: number): Image_2 | Use;
|
|
65
65
|
createTextImage(tile: Tile, x: number, y: number, t: string): G;
|
|
@@ -125,15 +125,17 @@ export declare class BlockCalculator {
|
|
|
125
125
|
hand: Hand;
|
|
126
126
|
constructor(hand: Hand);
|
|
127
127
|
calc(lastTile: Tile): readonly Block[][];
|
|
128
|
-
|
|
128
|
+
markedHands(hands: readonly Block[][], lastTile: Tile): readonly Block[][];
|
|
129
|
+
markedHand(hand: readonly Block[], lastTile: Tile): readonly Block[][];
|
|
129
130
|
sevenPairs(): readonly Block[][];
|
|
130
131
|
thirteenOrphans(): readonly Block[][];
|
|
131
132
|
nineGates(): readonly Block[][];
|
|
132
|
-
|
|
133
|
-
private
|
|
133
|
+
standardType(): readonly Block[][];
|
|
134
|
+
private calcAllBlockCombinations;
|
|
134
135
|
private handleBack;
|
|
135
136
|
private handleZ;
|
|
136
137
|
private addRedPattern;
|
|
138
|
+
private addRedPatterns;
|
|
137
139
|
private handleNumType;
|
|
138
140
|
}
|
|
139
141
|
|
|
@@ -215,9 +217,9 @@ export declare interface BoardContext {
|
|
|
215
217
|
finalWallWin?: boolean;
|
|
216
218
|
finalDiscardWin?: boolean;
|
|
217
219
|
oneShotWin?: boolean;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
220
|
+
enableRoundUpMangan?: boolean;
|
|
221
|
+
disableCountableYakuman?: boolean;
|
|
222
|
+
disableDoubleYakuman?: boolean;
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
declare type BoardRound = (typeof ROUND_MAP)[keyof typeof ROUND_MAP];
|
|
@@ -232,12 +234,6 @@ export declare interface CallEvent {
|
|
|
232
234
|
block: SerializedBlock;
|
|
233
235
|
}
|
|
234
236
|
|
|
235
|
-
export declare interface Candidate {
|
|
236
|
-
tile: Tile;
|
|
237
|
-
candidates: readonly Tile[];
|
|
238
|
-
shanten: number;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
237
|
export declare interface ChoiceAfterCalled {
|
|
242
238
|
id: string;
|
|
243
239
|
type: Extract<Event_2, "CHOICE_AFTER_CALLED">;
|
|
@@ -291,6 +287,8 @@ export declare interface ChoiceForReachAcceptance {
|
|
|
291
287
|
choices: Pick<DiscardedChoice, "RON">;
|
|
292
288
|
}
|
|
293
289
|
|
|
290
|
+
export declare const compareTiles: (i: Tile, j: Tile) => number;
|
|
291
|
+
|
|
294
292
|
export declare class Controller {
|
|
295
293
|
wall: IWall;
|
|
296
294
|
playerIDs: string[];
|
|
@@ -363,9 +361,9 @@ export declare class Controller {
|
|
|
363
361
|
mailBox: {
|
|
364
362
|
[id: string]: PlayerEvent[];
|
|
365
363
|
};
|
|
366
|
-
histories:
|
|
364
|
+
histories: GameHistory[];
|
|
367
365
|
debugMode: boolean;
|
|
368
|
-
constructor(players:
|
|
366
|
+
constructor(players: PlayerSession[], params?: {
|
|
369
367
|
debug?: boolean;
|
|
370
368
|
shuffle?: boolean;
|
|
371
369
|
});
|
|
@@ -378,8 +376,8 @@ export declare class Controller {
|
|
|
378
376
|
emit(e: PlayerEvent): void;
|
|
379
377
|
enqueue(event: PlayerEvent): void;
|
|
380
378
|
pollReplies(eventID: string, wind: Wind[]): void;
|
|
381
|
-
export():
|
|
382
|
-
static load(h:
|
|
379
|
+
export(): GameHistory[];
|
|
380
|
+
static load(h: GameHistory): Controller;
|
|
383
381
|
start(): void;
|
|
384
382
|
startGame(): void;
|
|
385
383
|
finalResult(ret: WinResult, iam: Wind): WinResult;
|
|
@@ -393,7 +391,7 @@ export declare class Controller {
|
|
|
393
391
|
doPon(w: Wind, discardedBy: Wind, t?: Tile): BlockPon[] | false;
|
|
394
392
|
doChi(w: Wind, discardedBy: Wind, t?: Tile): BlockChi[] | false;
|
|
395
393
|
redPattern(blocks: BlockChi[]): BlockChi[];
|
|
396
|
-
doReach(w: Wind):
|
|
394
|
+
doReach(w: Wind): TileAnalysis[] | false;
|
|
397
395
|
doDiscard(w: Wind, called?: BlockChi | BlockPon): Tile[];
|
|
398
396
|
cannotDiscardTile(b: BlockChi): Tile[];
|
|
399
397
|
doAnKan(w: Wind): BlockAnKan[] | false;
|
|
@@ -429,7 +427,7 @@ export declare const convertInput: (i: TableInput) => {
|
|
|
429
427
|
export declare class Counter {
|
|
430
428
|
disable: boolean;
|
|
431
429
|
private c;
|
|
432
|
-
|
|
430
|
+
safeTileMap: {
|
|
433
431
|
"1z": {
|
|
434
432
|
[name: string]: boolean;
|
|
435
433
|
};
|
|
@@ -614,7 +612,7 @@ export declare interface DrawEvent {
|
|
|
614
612
|
|
|
615
613
|
declare interface DrawnChoice {
|
|
616
614
|
TSUMO: false | SerializedWinResult;
|
|
617
|
-
REACH: false |
|
|
615
|
+
REACH: false | SerializedTileAnalysis[];
|
|
618
616
|
AN_KAN: false | SerializedBlock[];
|
|
619
617
|
SHO_KAN: false | SerializedBlock[];
|
|
620
618
|
DISCARD: false | string[];
|
|
@@ -631,16 +629,16 @@ export declare const drawTable: (svg: Svg, tableInput: string, config: ImageHelp
|
|
|
631
629
|
}) => void;
|
|
632
630
|
|
|
633
631
|
export declare class Efficiency {
|
|
634
|
-
static
|
|
632
|
+
static calcEffectiveTiles(hand: Hand, choices: Tile[], options?: {
|
|
635
633
|
arrangeRed?: boolean;
|
|
636
|
-
|
|
637
|
-
}):
|
|
638
|
-
static
|
|
639
|
-
|
|
634
|
+
standardTypeOnly?: boolean;
|
|
635
|
+
}): TileAnalysis[];
|
|
636
|
+
static getEffectiveTiles(hand: Hand, options?: {
|
|
637
|
+
standardTypeOnly?: boolean;
|
|
640
638
|
typeFilter?: Type[];
|
|
641
639
|
}): {
|
|
642
640
|
shanten: number;
|
|
643
|
-
|
|
641
|
+
effectiveTiles: Tile[];
|
|
644
642
|
};
|
|
645
643
|
}
|
|
646
644
|
|
|
@@ -705,7 +703,35 @@ export declare class G extends Mark {
|
|
|
705
703
|
each(block: (idx: number, children: Mark[]) => void, deep: boolean): void;
|
|
706
704
|
}
|
|
707
705
|
|
|
708
|
-
export declare
|
|
706
|
+
export declare interface GameHistory {
|
|
707
|
+
round: Round;
|
|
708
|
+
scores: {
|
|
709
|
+
[wind in string]: number;
|
|
710
|
+
};
|
|
711
|
+
players: {
|
|
712
|
+
[id in string]: Wind;
|
|
713
|
+
};
|
|
714
|
+
sticks: {
|
|
715
|
+
reach: number;
|
|
716
|
+
dead: number;
|
|
717
|
+
};
|
|
718
|
+
wall: WallProps;
|
|
719
|
+
choiceEvents: {
|
|
720
|
+
[id: string]: PlayerEvent[];
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
export declare const getCallBlockIndex: (caller: Wind, discardedBy: Wind, type: typeof BLOCK.PON | typeof BLOCK.DAI_KAN) => 0 | 1 | 3 | 2;
|
|
725
|
+
|
|
726
|
+
export declare function getPointDescription(params: {
|
|
727
|
+
base: number;
|
|
728
|
+
fu: number;
|
|
729
|
+
han: number;
|
|
730
|
+
isTsumo: boolean;
|
|
731
|
+
isParent: boolean;
|
|
732
|
+
isYakuman?: boolean;
|
|
733
|
+
isCountableYakuman?: boolean;
|
|
734
|
+
}): string;
|
|
709
735
|
|
|
710
736
|
export declare class Hand {
|
|
711
737
|
protected data: HandData;
|
|
@@ -747,25 +773,6 @@ export declare interface HandsInput {
|
|
|
747
773
|
left: Block[];
|
|
748
774
|
}
|
|
749
775
|
|
|
750
|
-
declare interface History_2 {
|
|
751
|
-
round: Round;
|
|
752
|
-
scores: {
|
|
753
|
-
[key in string]: number;
|
|
754
|
-
};
|
|
755
|
-
players: {
|
|
756
|
-
[key in string]: Wind;
|
|
757
|
-
};
|
|
758
|
-
sticks: {
|
|
759
|
-
reach: number;
|
|
760
|
-
dead: number;
|
|
761
|
-
};
|
|
762
|
-
wall: WallProps;
|
|
763
|
-
choiceEvents: {
|
|
764
|
-
[id: string]: PlayerEvent[];
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
export { History_2 as History }
|
|
768
|
-
|
|
769
776
|
declare class Image_2 extends Mark {
|
|
770
777
|
attrs: Attrs & {
|
|
771
778
|
href?: string;
|
|
@@ -808,7 +815,7 @@ export declare interface IRiver {
|
|
|
808
815
|
cannotContinue(): boolean;
|
|
809
816
|
}
|
|
810
817
|
|
|
811
|
-
export declare function
|
|
818
|
+
export declare function is5Tile(t: Tile): boolean;
|
|
812
819
|
|
|
813
820
|
export declare interface IWall {
|
|
814
821
|
kan(): Tile;
|
|
@@ -904,7 +911,7 @@ export declare const OP: {
|
|
|
904
911
|
readonly COLOR_GRAYSCALE: "^";
|
|
905
912
|
};
|
|
906
913
|
|
|
907
|
-
declare type Operator = (typeof OP)[keyof typeof OP];
|
|
914
|
+
export declare type Operator = (typeof OP)[keyof typeof OP];
|
|
908
915
|
|
|
909
916
|
export declare const optimizeSVG: (draw: Svg) => void;
|
|
910
917
|
|
|
@@ -958,8 +965,8 @@ export declare const parseTableInput: (s: string) => {
|
|
|
958
965
|
};
|
|
959
966
|
|
|
960
967
|
export declare class PlaceManager {
|
|
961
|
-
private
|
|
962
|
-
private
|
|
968
|
+
private playerToWind;
|
|
969
|
+
private windToPlayer;
|
|
963
970
|
round: Round;
|
|
964
971
|
sticks: {
|
|
965
972
|
reach: number;
|
|
@@ -984,7 +991,7 @@ export declare class PlaceManager {
|
|
|
984
991
|
wind(id: string): Wind;
|
|
985
992
|
playerID(w: Wind): string;
|
|
986
993
|
get playerMap(): {
|
|
987
|
-
[
|
|
994
|
+
[id: string]: Wind;
|
|
988
995
|
};
|
|
989
996
|
}
|
|
990
997
|
|
|
@@ -998,34 +1005,34 @@ export declare class Player extends BaseActor {
|
|
|
998
1005
|
handleEvent(e: PlayerEvent): void;
|
|
999
1006
|
}
|
|
1000
1007
|
|
|
1001
|
-
export declare
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
tile: Tile;
|
|
1006
|
-
n: number;
|
|
1007
|
-
}[];
|
|
1008
|
-
shanten: number;
|
|
1008
|
+
export declare class PlayerEfficiency {
|
|
1009
|
+
static analyzePlayerEfficiency(counter: Counter, analyses: TileAnalysis[]): PlayerTileAnalysis[];
|
|
1010
|
+
static selectMinPriority(c: Counter, playerAnalyses: PlayerTileAnalysis[], doras: Tile[]): PlayerTileAnalysis;
|
|
1011
|
+
private static calcPriority;
|
|
1009
1012
|
}
|
|
1010
1013
|
|
|
1011
|
-
export declare
|
|
1014
|
+
export declare type PlayerEvent = DistributeEvent | EndEvent | CallEvent | RonEvent | TsumoEvent | DiscardEvent | DrawEvent | ReachEvent | ReachAcceptedEvent | NewDoraEvent | ChoiceAfterDrawnEvent | ChoiceAfterDiscardedEvent | ChoiceAfterCalled | ChoiceForReachAcceptance | ChoiceForChanKan;
|
|
1015
|
+
|
|
1016
|
+
export declare interface PlayerSession {
|
|
1012
1017
|
id: string;
|
|
1013
1018
|
handler: EventHandler;
|
|
1014
1019
|
}
|
|
1015
1020
|
|
|
1016
|
-
export declare
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1021
|
+
export declare interface PlayerTileAnalysis {
|
|
1022
|
+
tile: Tile;
|
|
1023
|
+
sum: number;
|
|
1024
|
+
effectiveTiles: {
|
|
1025
|
+
tile: Tile;
|
|
1026
|
+
count: number;
|
|
1027
|
+
}[];
|
|
1028
|
+
shanten: number;
|
|
1020
1029
|
}
|
|
1021
1030
|
|
|
1022
|
-
export declare type PlayerEvent = DistributeEvent | EndEvent | CallEvent | RonEvent | TsumoEvent | DiscardEvent | DrawEvent | ReachEvent | ReachAcceptedEvent | NewDoraEvent | ChoiceAfterDrawnEvent | ChoiceAfterDiscardedEvent | ChoiceAfterCalled | ChoiceForReachAcceptance | ChoiceForChanKan;
|
|
1023
|
-
|
|
1024
1031
|
export declare class PointCalculator {
|
|
1025
1032
|
hand: Hand;
|
|
1026
1033
|
cfg: {
|
|
1027
1034
|
doras: readonly Tile[];
|
|
1028
|
-
|
|
1035
|
+
hiddenDoras: readonly Tile[];
|
|
1029
1036
|
roundWind: Tile;
|
|
1030
1037
|
myWind: Tile;
|
|
1031
1038
|
reached: 0 | 1 | 2;
|
|
@@ -1038,19 +1045,26 @@ export declare class PointCalculator {
|
|
|
1038
1045
|
finalWallWin: boolean;
|
|
1039
1046
|
finalDiscardWin: boolean;
|
|
1040
1047
|
oneShotWin: boolean;
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1048
|
+
enableRoundUpMangan: boolean;
|
|
1049
|
+
disableCountableYakuman: boolean;
|
|
1050
|
+
disableDoubleYakuman: boolean;
|
|
1044
1051
|
orig: BoardContext;
|
|
1045
1052
|
};
|
|
1046
1053
|
constructor(hand: Hand, params: BoardContext);
|
|
1047
1054
|
calc(...hands: readonly Block[][]): WinResult | false;
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1055
|
+
getWinningHands(hands: readonly Block[][]): WinningHand[];
|
|
1056
|
+
private selectBestHand;
|
|
1057
|
+
private calculateScore;
|
|
1058
|
+
private hasYakuman;
|
|
1059
|
+
private isRoundUpMangan;
|
|
1060
|
+
private isTsumoWin;
|
|
1061
|
+
private calculateDeltas;
|
|
1062
|
+
private calculateRonDeltas;
|
|
1063
|
+
private calculateTsumoDeltas;
|
|
1064
|
+
private calculateParentTsumoDeltas;
|
|
1065
|
+
private calculateChildTsumoDeltas;
|
|
1066
|
+
private addStickPoints;
|
|
1067
|
+
private getBasePoints;
|
|
1054
1068
|
private minus;
|
|
1055
1069
|
dA1(h: readonly Block[]): Yaku[];
|
|
1056
1070
|
dB1(h: readonly Block[]): Yaku[];
|
|
@@ -1136,7 +1150,7 @@ export declare class Rect extends Mark {
|
|
|
1136
1150
|
|
|
1137
1151
|
export declare class Replayer {
|
|
1138
1152
|
index: number;
|
|
1139
|
-
histories:
|
|
1153
|
+
histories: GameHistory[];
|
|
1140
1154
|
constructor(v: string);
|
|
1141
1155
|
next(): void;
|
|
1142
1156
|
prev(): void;
|
|
@@ -1263,9 +1277,9 @@ declare type SerializedBoardContext = Omit<BoardContext, "doraIndicators" | "hid
|
|
|
1263
1277
|
hiddenDoraIndicators?: readonly string[];
|
|
1264
1278
|
};
|
|
1265
1279
|
|
|
1266
|
-
export declare interface
|
|
1280
|
+
export declare interface SerializedTileAnalysis {
|
|
1267
1281
|
tile: string;
|
|
1268
|
-
|
|
1282
|
+
effectiveTiles: readonly string[];
|
|
1269
1283
|
shanten: number;
|
|
1270
1284
|
}
|
|
1271
1285
|
|
|
@@ -1282,10 +1296,10 @@ export declare class ShantenCalculator {
|
|
|
1282
1296
|
calc(): number;
|
|
1283
1297
|
sevenPairs(): number;
|
|
1284
1298
|
thirteenOrphans(): number;
|
|
1285
|
-
|
|
1286
|
-
private
|
|
1299
|
+
standardType(): number;
|
|
1300
|
+
private calcNumberTilePatterns;
|
|
1287
1301
|
private groupRemainingTiles;
|
|
1288
|
-
private
|
|
1302
|
+
private calcStandardType;
|
|
1289
1303
|
}
|
|
1290
1304
|
|
|
1291
1305
|
export declare function shuffle<T>(array: T[]): T[];
|
|
@@ -1435,7 +1449,11 @@ export declare const TILE_CONTEXT: {
|
|
|
1435
1449
|
readonly BLOCK_MARGIN_SCALE: 0.3;
|
|
1436
1450
|
};
|
|
1437
1451
|
|
|
1438
|
-
export declare
|
|
1452
|
+
export declare interface TileAnalysis {
|
|
1453
|
+
tile: Tile;
|
|
1454
|
+
effectiveTiles: readonly Tile[];
|
|
1455
|
+
shanten: number;
|
|
1456
|
+
}
|
|
1439
1457
|
|
|
1440
1458
|
export declare const toDora: (doraIndicator: Tile) => Tile;
|
|
1441
1459
|
|
|
@@ -1516,16 +1534,20 @@ export declare const WIND_MAP: {
|
|
|
1516
1534
|
readonly "4z": "北";
|
|
1517
1535
|
};
|
|
1518
1536
|
|
|
1519
|
-
|
|
1537
|
+
declare interface WinningHand {
|
|
1538
|
+
hand: Block[];
|
|
1539
|
+
fu: number;
|
|
1540
|
+
yakus: readonly Yaku[];
|
|
1541
|
+
han: number;
|
|
1542
|
+
isYakuman?: boolean;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
export declare interface WinResult extends WinningHand {
|
|
1520
1546
|
deltas: {
|
|
1521
1547
|
readonly [w in Wind]: number;
|
|
1522
1548
|
};
|
|
1523
|
-
han: number;
|
|
1524
|
-
fu: number;
|
|
1525
|
-
yakus: readonly Yaku[];
|
|
1526
1549
|
points: number;
|
|
1527
|
-
|
|
1528
|
-
hand: Block[];
|
|
1550
|
+
basePoints: number;
|
|
1529
1551
|
boardContext: BoardContext;
|
|
1530
1552
|
description: string;
|
|
1531
1553
|
}
|
|
@@ -1533,7 +1555,7 @@ export declare interface WinResult {
|
|
|
1533
1555
|
export declare interface Yaku {
|
|
1534
1556
|
name: string;
|
|
1535
1557
|
han: number;
|
|
1536
|
-
|
|
1558
|
+
isYakuman?: boolean;
|
|
1537
1559
|
}
|
|
1538
1560
|
|
|
1539
1561
|
export { }
|