@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
@@ -1,24 +0,0 @@
1
- import { Tile } from "../core";
2
- import { Hand } from "./calc";
3
- export interface SerializedCandidate {
4
- tile: string;
5
- candidates: readonly string[];
6
- shanten: number;
7
- }
8
- export interface Candidate {
9
- tile: Tile;
10
- candidates: readonly Tile[];
11
- shanten: number;
12
- }
13
- export declare class Efficiency {
14
- static calcCandidates(hand: Hand, choices: Tile[]): Candidate[];
15
- static candidateTiles(hand: Hand): {
16
- shanten: number;
17
- candidates: Tile[];
18
- };
19
- static partialCandidateTiles(input: string): {
20
- shanten: number;
21
- candidates: Tile[];
22
- };
23
- static partialShanten(input: string): number;
24
- }
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Efficiency = void 0;
4
- var core_1 = require("../core");
5
- var calc_1 = require("./calc");
6
- var Efficiency = (function () {
7
- function Efficiency() {
8
- }
9
- Efficiency.calcCandidates = function (hand, choices) {
10
- if (choices.length == 0)
11
- throw new Error("[debug] choices to discard is zero");
12
- var ret = [];
13
- for (var _i = 0, choices_1 = choices; _i < choices_1.length; _i++) {
14
- var t = choices_1[_i];
15
- var tiles = hand.dec([t]);
16
- var c = Efficiency.candidateTiles(hand);
17
- hand.inc(tiles);
18
- if (ret.length == 0 || c.shanten < ret[0].shanten) {
19
- ret = [
20
- {
21
- shanten: c.shanten,
22
- candidates: c.candidates,
23
- tile: t,
24
- },
25
- ];
26
- }
27
- else if (c.shanten == ret[0].shanten) {
28
- ret.push({
29
- candidates: c.candidates,
30
- shanten: c.shanten,
31
- tile: t,
32
- });
33
- }
34
- }
35
- return ret;
36
- };
37
- Efficiency.candidateTiles = function (hand) {
38
- var r = Number.POSITIVE_INFINITY;
39
- var candidates = [];
40
- var sc = new calc_1.ShantenCalculator(hand);
41
- for (var _i = 0, _a = Object.values(core_1.TYPE); _i < _a.length; _i++) {
42
- var t = _a[_i];
43
- if (t == core_1.TYPE.BACK)
44
- continue;
45
- for (var n = 1; n < hand.getArrayLen(t); n++) {
46
- if (hand.get(t, n) >= 4)
47
- continue;
48
- var tile = new core_1.Tile(t, n);
49
- var tiles = hand.inc([tile]);
50
- var s = sc.calc();
51
- hand.dec(tiles);
52
- if (s < r) {
53
- r = s;
54
- candidates = [tile];
55
- }
56
- else if (s == r)
57
- candidates.push(tile);
58
- }
59
- }
60
- return {
61
- shanten: r,
62
- candidates: candidates,
63
- };
64
- };
65
- Efficiency.partialCandidateTiles = function (input) {
66
- var h = new calc_1.Hand(input, true);
67
- Array(13 - h.hands.length)
68
- .fill(undefined)
69
- .map(function () { return h.inc([new core_1.Tile(core_1.TYPE.BACK, 0)]); });
70
- return Efficiency.candidateTiles(h);
71
- };
72
- Efficiency.partialShanten = function (input) {
73
- var h = new calc_1.Hand(input, true);
74
- Array(13 - h.hands.length)
75
- .fill(undefined)
76
- .map(function () { return h.inc([new core_1.Tile(core_1.TYPE.BACK, 0)]); });
77
- var sc = new calc_1.ShantenCalculator(h);
78
- return sc.calc();
79
- };
80
- return Efficiency;
81
- }());
82
- exports.Efficiency = Efficiency;
@@ -1,6 +0,0 @@
1
- export declare function createWindMap<T>(initial: T, clone?: boolean): {
2
- "1w": T;
3
- "2w": T;
4
- "3w": T;
5
- "4w": T;
6
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWindMap = createWindMap;
4
- var constants_1 = require("../core/constants");
5
- function createWindMap(initial, clone) {
6
- var _a;
7
- if (clone === void 0) { clone = false; }
8
- var m = (_a = {},
9
- _a[constants_1.WIND.EAST] = initial,
10
- _a[constants_1.WIND.SOUTH] = initial,
11
- _a[constants_1.WIND.WEST] = initial,
12
- _a[constants_1.WIND.NORTH] = initial,
13
- _a);
14
- if (clone) {
15
- for (var _i = 0, _b = Object.values(constants_1.WIND); _i < _b.length; _i++) {
16
- var w = _b[_i];
17
- m[w] = structuredClone(initial);
18
- }
19
- }
20
- return m;
21
- }
@@ -1,3 +0,0 @@
1
- export * from "./calc";
2
- export * from "./efficiency";
3
- export * from "./helper";
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./calc"), exports);
18
- __exportStar(require("./efficiency"), exports);
19
- __exportStar(require("./helper"), exports);
@@ -1,168 +0,0 @@
1
- import { Wind, Round } from "../core/";
2
- import { BoardContext, Hand, WinResult, Candidate } from "../calculator";
3
- import { BlockAnKan, BlockChi, BlockDaiKan, BlockPon, BlockShoKan, Tile } from "../core/parser";
4
- import { PlayerEvent, EventHandler, DistributeEvent } from "./events";
5
- import { Wall, WallProps, River, PlaceManager, ScoreManager, Counter } from ".";
6
- export interface History {
7
- round: Round;
8
- scores: {
9
- [key in string]: number;
10
- };
11
- players: {
12
- [key in string]: Wind;
13
- };
14
- sticks: {
15
- reach: number;
16
- dead: number;
17
- };
18
- wall: WallProps;
19
- choiceEvents: {
20
- [id: string]: PlayerEvent[];
21
- };
22
- }
23
- export interface PlayerProps {
24
- id: string;
25
- handler: EventHandler;
26
- }
27
- export declare class Controller {
28
- wall: Wall;
29
- playerIDs: string[];
30
- actor: import("xstate").Actor<import("xstate").StateMachine<{
31
- currentWind: Wind;
32
- oneShotMap: { [key in Wind]: boolean; };
33
- missingMap: { [key in Wind]: boolean; };
34
- controller: Controller;
35
- genEventID: ReturnType<typeof import("./state-machine").incrementalIDGenerator>;
36
- }, {
37
- type: "";
38
- } | {
39
- type: "NEXT";
40
- } | {
41
- type: "CHI";
42
- block: BlockChi;
43
- iam: Wind;
44
- } | {
45
- type: "PON";
46
- block: BlockPon;
47
- iam: Wind;
48
- } | {
49
- type: "RON";
50
- ret: WinResult;
51
- iam: Wind;
52
- targetInfo: {
53
- wind: Wind;
54
- tile: Tile;
55
- };
56
- quadWin?: boolean;
57
- } | {
58
- type: "TSUMO";
59
- ret: WinResult;
60
- iam: Wind;
61
- lastTile: Tile;
62
- } | {
63
- type: "REACH";
64
- tile: Tile;
65
- iam: Wind;
66
- } | {
67
- type: "DISCARD";
68
- tile: Tile;
69
- iam: Wind;
70
- } | {
71
- type: "AN_KAN";
72
- block: BlockAnKan;
73
- iam: Wind;
74
- } | {
75
- type: "SHO_KAN";
76
- block: BlockShoKan;
77
- iam: Wind;
78
- } | {
79
- type: "DAI_KAN";
80
- block: BlockDaiKan;
81
- iam: Wind;
82
- } | {
83
- type: "DRAWN_GAME_BY_NINE_TILES";
84
- iam: Wind;
85
- }, Record<string, import("xstate").AnyActorRef>, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, never, import("xstate").StateValue, string, unknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, any>>;
86
- observer: Observer;
87
- handlers: {
88
- [id: string]: EventHandler;
89
- };
90
- mailBox: {
91
- [id: string]: PlayerEvent[];
92
- };
93
- histories: History[];
94
- debugMode: boolean;
95
- snapshot?: string;
96
- constructor(players: PlayerProps[], params?: {
97
- debug?: boolean;
98
- });
99
- boardParams(w: Wind): BoardContext;
100
- hand(w: Wind): ActorHand;
101
- get placeManager(): PlaceManager;
102
- get scoreManager(): ScoreManager;
103
- get river(): River;
104
- next(force?: boolean): void;
105
- emit(e: PlayerEvent): void;
106
- enqueue(event: PlayerEvent): void;
107
- pollReplies(eventID: string, wind: Wind[]): void;
108
- export(): History[];
109
- static load(h: History): Controller;
110
- start(): void;
111
- startGame(): void;
112
- finalResult(ret: WinResult, iam: Wind): WinResult;
113
- doWin(w: Wind, t: Tile | null | undefined, params?: {
114
- quadWin?: boolean;
115
- replacementWin?: boolean;
116
- oneShot?: boolean;
117
- missingRon?: boolean;
118
- whoDiscarded?: Wind;
119
- }): WinResult | false;
120
- doPon(w: Wind, whoDiscarded: Wind, t?: Tile): BlockPon[] | false;
121
- doChi(w: Wind, whoDiscarded: Wind, t?: Tile): BlockChi[] | false;
122
- redPattern(blocks: BlockChi[], hasRed: boolean): BlockChi[];
123
- doReach(w: Wind): Candidate[] | false;
124
- doDiscard(w: Wind, called?: BlockChi | BlockPon): Tile[];
125
- cannotDiscardTile(called: BlockChi): Tile[];
126
- doAnKan(w: Wind): BlockAnKan[] | false;
127
- doShoKan(w: Wind): BlockShoKan[] | false;
128
- doDaiKan(w: Wind, whoDiscarded: Wind, t: Tile): BlockDaiKan | false;
129
- canDrawnGame(w: Wind): boolean;
130
- initialHands(): {
131
- "1w": string;
132
- "2w": string;
133
- "3w": string;
134
- "4w": string;
135
- };
136
- }
137
- export declare class ActorHand extends Hand {
138
- isBackHand(): boolean;
139
- clone(): ActorHand;
140
- dec(tiles: readonly Tile[]): Tile[];
141
- }
142
- export declare abstract class BaseActor {
143
- id: string;
144
- river: River;
145
- placeManager: PlaceManager;
146
- scoreManager: ScoreManager;
147
- hands: {
148
- "1w": ActorHand;
149
- "2w": ActorHand;
150
- "3w": ActorHand;
151
- "4w": ActorHand;
152
- };
153
- counter: Counter;
154
- doraMarkers: Tile[];
155
- eventHandler: EventHandler;
156
- constructor(id: string, eventHandler: EventHandler);
157
- hand(w: Wind): ActorHand;
158
- protected abstract setHands(e: DistributeEvent): void;
159
- handleEvent(e: PlayerEvent): void;
160
- }
161
- export declare class Observer extends BaseActor {
162
- applied: {
163
- [id: string]: boolean;
164
- };
165
- constructor(eventHandler: EventHandler);
166
- setHands(e: DistributeEvent): void;
167
- handleEvent(e: PlayerEvent): void;
168
- }