@konoui/mjimage 0.0.31 → 0.0.33

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 (61) hide show
  1. package/dist/index.cjs +30 -0
  2. package/dist/index.d.cts +1389 -0
  3. package/dist/index.d.ts +1389 -0
  4. package/dist/index.js +10971 -0
  5. package/package.json +23 -14
  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 -1397
  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 -897
  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 -194
  28. package/dist/mjs/lib/controller/player-efficiency.d.ts +0 -24
  29. package/dist/mjs/lib/controller/player-efficiency.js +0 -153
  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 -31
  34. package/dist/mjs/lib/controller/river.d.ts +0 -19
  35. package/dist/mjs/lib/controller/river.js +0 -52
  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/myassert/index.d.ts +0 -1
  55. package/dist/mjs/lib/myassert/index.js +0 -8
  56. package/dist/mjs/lib/table/index.d.ts +0 -2
  57. package/dist/mjs/lib/table/index.js +0 -18
  58. package/dist/mjs/lib/table/table-parser.d.ts +0 -127
  59. package/dist/mjs/lib/table/table-parser.js +0 -105
  60. package/dist/mjs/lib/table/table.d.ts +0 -12
  61. package/dist/mjs/lib/table/table.js +0 -248
@@ -1,24 +0,0 @@
1
- import { Tile } from "../core/parser";
2
- export interface WallProps {
3
- drawable: string[];
4
- dead: string[];
5
- replacement: string[];
6
- doraMarkers: string[];
7
- blindDoraMarkers: string[];
8
- }
9
- export declare class Wall {
10
- private walls;
11
- private backup;
12
- private openedDoraCount;
13
- constructor(backup?: WallProps);
14
- kan(): Tile;
15
- draw(): Tile;
16
- openDoraMarker(): Tile;
17
- get doraMarkers(): Tile[];
18
- get blindDoraMarkers(): Tile[];
19
- get canKan(): boolean;
20
- get canDraw(): boolean;
21
- private init;
22
- export(): WallProps;
23
- static clone(walls: WallProps): WallProps;
24
- }
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Wall = void 0;
4
- var constants_1 = require("../core/constants");
5
- var parser_1 = require("../core/parser");
6
- var managers_1 = require("./managers");
7
- var Wall = (function () {
8
- function Wall(backup) {
9
- this.walls = {
10
- replacement: [],
11
- dead: [],
12
- doraMarkers: [],
13
- blindDoraMarkers: [],
14
- drawable: [],
15
- };
16
- this.openedDoraCount = 1;
17
- this.init(backup);
18
- this.backup = Wall.clone(this.walls);
19
- }
20
- Wall.prototype.kan = function () {
21
- if (this.walls.replacement.length == 0)
22
- throw new Error("exceeded maximum kan");
23
- var t = this.walls.replacement.pop();
24
- this.walls.drawable.pop();
25
- return parser_1.Tile.from(t);
26
- };
27
- Wall.prototype.draw = function () {
28
- if (!this.walls.drawable)
29
- throw new Error("cannot draw any more");
30
- return parser_1.Tile.from(this.walls.drawable.pop());
31
- };
32
- Wall.prototype.openDoraMarker = function () {
33
- if (this.openedDoraCount >= 4)
34
- throw new Error("exceeded maximum open dora");
35
- this.openedDoraCount++;
36
- return parser_1.Tile.from(this.walls.doraMarkers[this.openedDoraCount - 1]);
37
- };
38
- Object.defineProperty(Wall.prototype, "doraMarkers", {
39
- get: function () {
40
- return this.walls.doraMarkers.slice(0, this.openedDoraCount).map(parser_1.Tile.from);
41
- },
42
- enumerable: false,
43
- configurable: true
44
- });
45
- Object.defineProperty(Wall.prototype, "blindDoraMarkers", {
46
- get: function () {
47
- return this.walls.blindDoraMarkers
48
- .slice(0, this.openedDoraCount)
49
- .map(parser_1.Tile.from);
50
- },
51
- enumerable: false,
52
- configurable: true
53
- });
54
- Object.defineProperty(Wall.prototype, "canKan", {
55
- get: function () {
56
- return this.walls.replacement.length > 0;
57
- },
58
- enumerable: false,
59
- configurable: true
60
- });
61
- Object.defineProperty(Wall.prototype, "canDraw", {
62
- get: function () {
63
- return this.walls.drawable.length > 0;
64
- },
65
- enumerable: false,
66
- configurable: true
67
- });
68
- Wall.prototype.init = function (backup) {
69
- if (backup != null) {
70
- this.walls = Wall.clone(backup);
71
- return;
72
- }
73
- else {
74
- for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
75
- var t = _a[_i];
76
- if (t == constants_1.TYPE.BACK)
77
- continue;
78
- var values = t == constants_1.TYPE.Z ? [1, 2, 3, 4, 5, 6, 7] : [1, 2, 3, 4, 5, 6, 7, 8, 9];
79
- for (var i = 0; i < 4; i++) {
80
- for (var _b = 0, values_1 = values; _b < values_1.length; _b++) {
81
- var n = values_1[_b];
82
- if (t != constants_1.TYPE.Z && i == 3 && n == 5)
83
- n = 0;
84
- this.walls.drawable.push(new parser_1.Tile(t, n).toString());
85
- }
86
- }
87
- }
88
- (0, managers_1.shuffle)(this.walls.drawable);
89
- }
90
- for (var i = 0; i < 14; i++) {
91
- this.walls.dead.push(this.walls.drawable.pop());
92
- }
93
- for (var i = 0; i < 4; i++) {
94
- this.walls.blindDoraMarkers.push(this.walls.dead.pop());
95
- }
96
- for (var i = 0; i < 4; i++) {
97
- this.walls.doraMarkers.push(this.walls.dead.pop());
98
- }
99
- for (var i = 0; i < 4; i++) {
100
- this.walls.replacement.push(this.walls.dead.pop());
101
- }
102
- };
103
- Wall.prototype.export = function () {
104
- return this.backup;
105
- };
106
- Wall.clone = function (walls) {
107
- return {
108
- drawable: walls.drawable.concat(),
109
- dead: walls.dead.concat(),
110
- doraMarkers: walls.doraMarkers.concat(),
111
- blindDoraMarkers: walls.blindDoraMarkers.concat(),
112
- replacement: walls.replacement.concat(),
113
- };
114
- };
115
- return Wall;
116
- }());
117
- exports.Wall = Wall;
@@ -1,73 +0,0 @@
1
- export declare const FONT_FAMILY = "MS Gothic, sans-serif";
2
- export declare const TILE_CONTEXT: {
3
- WIDTH: number;
4
- HEIGHT: number;
5
- TEXT_SCALE: number;
6
- BLOCK_MARGIN_SCALE: number;
7
- };
8
- export declare const TABLE_CONTEXT: {
9
- BASE: number;
10
- };
11
- export declare const INPUT_SEPARATOR = ",";
12
- export declare const TYPE: {
13
- readonly M: "m";
14
- readonly P: "p";
15
- readonly S: "s";
16
- readonly Z: "z";
17
- readonly BACK: "_";
18
- };
19
- export declare const OPERATOR: {
20
- readonly TSUMO: "t";
21
- readonly RON: "r";
22
- readonly DORA: "d";
23
- readonly HORIZONTAL: "-";
24
- readonly COLOR_GRAYSCALE: "^";
25
- };
26
- export declare const BLOCK: {
27
- readonly PON: "pon";
28
- readonly CHI: "chi";
29
- readonly SHO_KAN: "shokan";
30
- readonly DAI_KAN: "daikan";
31
- readonly AN_KAN: "ankan";
32
- readonly TSUMO: "tsumo";
33
- readonly THREE: "three";
34
- readonly PAIR: "pair";
35
- readonly ISOLATED: "isolated";
36
- readonly RUN: "run";
37
- readonly HAND: "hand";
38
- readonly IMAGE_DORA: "dora";
39
- readonly IMAGE_DISCARD: "simple-discard";
40
- readonly UNKNOWN: "unknown";
41
- };
42
- export declare const WIND: {
43
- readonly EAST: "1w";
44
- readonly SOUTH: "2w";
45
- readonly WEST: "3w";
46
- readonly NORTH: "4w";
47
- };
48
- export declare const ROUND_MAP: {
49
- readonly "1w1": "東1局";
50
- readonly "1w2": "東2局";
51
- readonly "1w3": "東3局";
52
- readonly "1w4": "東4局";
53
- readonly "2w1": "南1局";
54
- readonly "2w2": "南2局";
55
- readonly "2w3": "南3局";
56
- readonly "2w4": "南4局";
57
- readonly "3w1": "西1局";
58
- readonly "3w2": "西2局";
59
- readonly "3w3": "西3局";
60
- readonly "3w4": "西4局";
61
- readonly "4w1": "北1局";
62
- readonly "4w2": "北2局";
63
- readonly "4w3": "北3局";
64
- readonly "4w4": "北4局";
65
- };
66
- export declare const WIND_MAP: {
67
- readonly "1w": "東";
68
- readonly "2w": "南";
69
- readonly "3w": "西";
70
- readonly "4w": "北";
71
- };
72
- export type Wind = keyof typeof WIND_MAP;
73
- export type Round = keyof typeof ROUND_MAP;
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.WIND_MAP = exports.ROUND_MAP = exports.WIND = exports.BLOCK = exports.OPERATOR = exports.TYPE = exports.INPUT_SEPARATOR = exports.TABLE_CONTEXT = exports.TILE_CONTEXT = exports.FONT_FAMILY = void 0;
5
- exports.FONT_FAMILY = "MS Gothic, sans-serif";
6
- exports.TILE_CONTEXT = {
7
- WIDTH: 66,
8
- HEIGHT: 90,
9
- TEXT_SCALE: 0.8,
10
- BLOCK_MARGIN_SCALE: 0.3,
11
- };
12
- exports.TABLE_CONTEXT = { BASE: 40 };
13
- exports.INPUT_SEPARATOR = ",";
14
- exports.TYPE = {
15
- M: "m",
16
- P: "p",
17
- S: "s",
18
- Z: "z",
19
- BACK: "_",
20
- };
21
- exports.OPERATOR = {
22
- TSUMO: "t",
23
- RON: "r",
24
- DORA: "d",
25
- HORIZONTAL: "-",
26
- COLOR_GRAYSCALE: "^",
27
- };
28
- exports.BLOCK = {
29
- PON: "pon",
30
- CHI: "chi",
31
- SHO_KAN: "shokan",
32
- DAI_KAN: "daikan",
33
- AN_KAN: "ankan",
34
- TSUMO: "tsumo",
35
- THREE: "three",
36
- PAIR: "pair",
37
- ISOLATED: "isolated",
38
- RUN: "run",
39
- HAND: "hand",
40
- IMAGE_DORA: "dora",
41
- IMAGE_DISCARD: "simple-discard",
42
- UNKNOWN: "unknown",
43
- };
44
- exports.WIND = {
45
- EAST: "1w",
46
- SOUTH: "2w",
47
- WEST: "3w",
48
- NORTH: "4w",
49
- };
50
- exports.ROUND_MAP = {
51
- "1w1": "東1局",
52
- "1w2": "東2局",
53
- "1w3": "東3局",
54
- "1w4": "東4局",
55
- "2w1": "南1局",
56
- "2w2": "南2局",
57
- "2w3": "南3局",
58
- "2w4": "南4局",
59
- "3w1": "西1局",
60
- "3w2": "西2局",
61
- "3w3": "西3局",
62
- "3w4": "西4局",
63
- "4w1": "北1局",
64
- "4w2": "北2局",
65
- "4w3": "北3局",
66
- "4w4": "北4局",
67
- };
68
- exports.WIND_MAP = (_a = {},
69
- _a[exports.WIND.EAST] = "東",
70
- _a[exports.WIND.SOUTH] = "南",
71
- _a[exports.WIND.WEST] = "西",
72
- _a[exports.WIND.NORTH] = "北",
73
- _a);
@@ -1,2 +0,0 @@
1
- export * from "./constants";
2
- export * from "./parser";
@@ -1,18 +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("./constants"), exports);
18
- __exportStar(require("./parser"), exports);
@@ -1,14 +0,0 @@
1
- export declare class Lexer {
2
- input: string;
3
- position: number;
4
- private nextPosition;
5
- char: string;
6
- readonly eof = "\0";
7
- constructor(input: string);
8
- readChar(): string;
9
- peekChar(): string;
10
- peekCharN(n: number): string;
11
- prevChar(): string;
12
- skipWhitespace(): void;
13
- private isWhitespace;
14
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Lexer = void 0;
4
- var Lexer = (function () {
5
- function Lexer(input) {
6
- this.eof = "\0";
7
- this.input = input;
8
- this.position = 0;
9
- this.nextPosition = 0;
10
- this.char = this.readChar();
11
- }
12
- Lexer.prototype.readChar = function () {
13
- if (this.nextPosition >= this.input.length) {
14
- this.char = this.eof;
15
- return this.char;
16
- }
17
- else {
18
- this.char = this.input[this.nextPosition];
19
- }
20
- this.position = this.nextPosition;
21
- this.nextPosition++;
22
- return this.char;
23
- };
24
- Lexer.prototype.peekChar = function () {
25
- if (this.nextPosition >= this.input.length)
26
- return this.eof;
27
- return this.input[this.nextPosition];
28
- };
29
- Lexer.prototype.peekCharN = function (n) {
30
- if (n < 0)
31
- throw new Error("arg must be positive value");
32
- if (this.position + n >= this.input.length)
33
- return this.eof;
34
- return this.input[this.position + n];
35
- };
36
- Lexer.prototype.prevChar = function () {
37
- if (this.position >= this.input.length)
38
- return this.eof;
39
- if (this.position > 0)
40
- return this.input[this.position - 1];
41
- return this.eof;
42
- };
43
- Lexer.prototype.skipWhitespace = function () {
44
- while (this.isWhitespace(this.char)) {
45
- this.readChar();
46
- }
47
- };
48
- Lexer.prototype.isWhitespace = function (char) {
49
- return /\s/.test(char);
50
- };
51
- return Lexer;
52
- }());
53
- exports.Lexer = Lexer;
@@ -1,120 +0,0 @@
1
- import { BLOCK, OPERATOR, TYPE, INPUT_SEPARATOR } from "./";
2
- type Separator = typeof INPUT_SEPARATOR;
3
- export declare const tileSortFunc: (i: Tile, j: Tile) => number;
4
- export type Type = (typeof TYPE)[keyof typeof TYPE];
5
- type Operator = (typeof OPERATOR)[keyof typeof OPERATOR];
6
- export declare class Tile {
7
- readonly t: Type;
8
- readonly n: number;
9
- readonly ops: Operator[];
10
- constructor(t: Type, n: number, ops?: Operator[]);
11
- static from(s: string): Tile;
12
- toString(): string;
13
- toJSON(): string;
14
- clone(override?: {
15
- t?: Type;
16
- n?: number;
17
- remove?: Operator;
18
- add?: Operator;
19
- }): Tile;
20
- has(op: Operator): boolean;
21
- isNum(): boolean;
22
- equals(t: Tile, ignoreRed?: boolean): boolean;
23
- imageSize(scale: number): {
24
- width: number;
25
- height: number;
26
- baseWidth: number;
27
- baseHeight: number;
28
- };
29
- }
30
- export declare function isNum5or0(t: Tile): boolean;
31
- export declare function isNum5(t: Tile): boolean;
32
- export declare function isNum0(t: Tile): boolean;
33
- type BLOCK = (typeof BLOCK)[keyof typeof BLOCK];
34
- export type SerializedBlock = ReturnType<Block["serialize"]>;
35
- export declare abstract class Block {
36
- private readonly _tiles;
37
- private readonly _type;
38
- constructor(tiles: readonly Tile[], type: BLOCK);
39
- static from(v: SerializedBlock): Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockRun | BlockThree | BlockHand | BlockIsolated | BlockOther;
40
- serialize(): {
41
- tiles: string;
42
- type: "unknown" | "pon" | "chi" | "shokan" | "daikan" | "ankan" | "tsumo" | "three" | "pair" | "isolated" | "run" | "hand" | "dora" | "simple-discard";
43
- };
44
- toJSON(): {
45
- tiles: string;
46
- type: "unknown" | "pon" | "chi" | "shokan" | "daikan" | "ankan" | "tsumo" | "three" | "pair" | "isolated" | "run" | "hand" | "dora" | "simple-discard";
47
- };
48
- get type(): "unknown" | "pon" | "chi" | "shokan" | "daikan" | "ankan" | "tsumo" | "three" | "pair" | "isolated" | "run" | "hand" | "dora" | "simple-discard";
49
- get tiles(): readonly Tile[];
50
- abstract toString(): string;
51
- is(type: BLOCK): boolean;
52
- isCalled(): boolean;
53
- clone(override?: {
54
- replace?: {
55
- idx: number;
56
- tile: Tile;
57
- };
58
- }): Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockRun | BlockThree | BlockHand | BlockIsolated | BlockOther;
59
- imageSize(scale: number): {
60
- width: number;
61
- height: number;
62
- };
63
- }
64
- export declare class BlockChi extends Block {
65
- constructor(tiles: readonly [Tile, Tile, Tile]);
66
- toString(): string;
67
- }
68
- export declare class BlockPon extends Block {
69
- constructor(tiles: readonly [Tile, Tile, Tile]);
70
- toString(): string;
71
- }
72
- export declare class BlockAnKan extends Block {
73
- constructor(tiles: readonly Tile[]);
74
- get tilesWithBack(): Tile[];
75
- static from(v: SerializedBlock): BlockAnKan;
76
- toString(): string;
77
- }
78
- export declare class BlockDaiKan extends Block {
79
- constructor(tiles: readonly Tile[]);
80
- toString(): string;
81
- }
82
- export declare class BlockShoKan extends Block {
83
- constructor(tiles: readonly Tile[]);
84
- toString(): string;
85
- }
86
- export declare class BlockPair extends Block {
87
- constructor(tile1: Tile, tile2: Tile);
88
- toString(): string;
89
- }
90
- export declare class BlockThree extends Block {
91
- constructor(tiles: readonly [Tile, Tile, Tile]);
92
- toString(): string;
93
- }
94
- export declare class BlockRun extends Block {
95
- constructor(tiles: readonly [Tile, Tile, Tile]);
96
- toString(): string;
97
- }
98
- export declare class BlockIsolated extends Block {
99
- constructor(tile: Tile);
100
- toString(): string;
101
- }
102
- export declare class BlockHand extends Block {
103
- constructor(tiles: readonly Tile[]);
104
- toString(): string;
105
- }
106
- export declare class BlockOther extends Block {
107
- constructor(tiles: readonly Tile[], type: BLOCK);
108
- toString(): string;
109
- }
110
- export declare class Parser {
111
- readonly input: string;
112
- readonly maxInputLength = 600;
113
- constructor(input: string);
114
- parse(): (BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockRun | BlockThree | BlockHand | BlockIsolated | BlockOther)[];
115
- tiles(): Tile[];
116
- tileSeparators(): (Tile | Separator)[];
117
- private makeBlocks;
118
- validate(input: string): void;
119
- }
120
- export {};