@konoui/mjimage 0.0.31 → 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.
- package/dist/index.cjs +30 -0
- package/dist/index.d.cts +1386 -0
- package/dist/index.d.ts +1386 -0
- package/dist/index.js +10953 -0
- package/package.json +23 -14
- package/dist/mjs/cmd/index.d.ts +0 -1
- package/dist/mjs/cmd/index.js +0 -49
- package/dist/mjs/index.d.ts +0 -6
- package/dist/mjs/index.js +0 -22
- package/dist/mjs/lib/calculator/calc.d.ts +0 -275
- package/dist/mjs/lib/calculator/calc.js +0 -1397
- package/dist/mjs/lib/calculator/efficiency.d.ts +0 -24
- package/dist/mjs/lib/calculator/efficiency.js +0 -82
- package/dist/mjs/lib/calculator/helper.d.ts +0 -6
- package/dist/mjs/lib/calculator/helper.js +0 -21
- package/dist/mjs/lib/calculator/index.d.ts +0 -3
- package/dist/mjs/lib/calculator/index.js +0 -19
- package/dist/mjs/lib/controller/controller.d.ts +0 -168
- package/dist/mjs/lib/controller/controller.js +0 -897
- package/dist/mjs/lib/controller/events.d.ts +0 -171
- package/dist/mjs/lib/controller/events.js +0 -102
- package/dist/mjs/lib/controller/game.d.ts +0 -5
- package/dist/mjs/lib/controller/game.js +0 -29
- package/dist/mjs/lib/controller/index.d.ts +0 -10
- package/dist/mjs/lib/controller/index.js +0 -26
- package/dist/mjs/lib/controller/managers.d.ts +0 -83
- package/dist/mjs/lib/controller/managers.js +0 -194
- package/dist/mjs/lib/controller/player-efficiency.d.ts +0 -24
- package/dist/mjs/lib/controller/player-efficiency.js +0 -153
- package/dist/mjs/lib/controller/player.d.ts +0 -12
- package/dist/mjs/lib/controller/player.js +0 -85
- package/dist/mjs/lib/controller/replay.d.ts +0 -10
- package/dist/mjs/lib/controller/replay.js +0 -31
- package/dist/mjs/lib/controller/river.d.ts +0 -19
- package/dist/mjs/lib/controller/river.js +0 -52
- package/dist/mjs/lib/controller/state-machine.d.ts +0 -67
- package/dist/mjs/lib/controller/state-machine.js +0 -771
- package/dist/mjs/lib/controller/wall.d.ts +0 -24
- package/dist/mjs/lib/controller/wall.js +0 -117
- package/dist/mjs/lib/core/constants.d.ts +0 -73
- package/dist/mjs/lib/core/constants.js +0 -73
- package/dist/mjs/lib/core/index.d.ts +0 -2
- package/dist/mjs/lib/core/index.js +0 -18
- package/dist/mjs/lib/core/lexer.d.ts +0 -14
- package/dist/mjs/lib/core/lexer.js +0 -53
- package/dist/mjs/lib/core/parser.d.ts +0 -120
- package/dist/mjs/lib/core/parser.js +0 -612
- package/dist/mjs/lib/image/image.d.ts +0 -42
- package/dist/mjs/lib/image/image.js +0 -361
- package/dist/mjs/lib/image/index.d.ts +0 -1
- package/dist/mjs/lib/image/index.js +0 -17
- package/dist/mjs/lib/measure-text/index.d.ts +0 -19
- package/dist/mjs/lib/measure-text/index.js +0 -49
- package/dist/mjs/lib/myassert/index.d.ts +0 -1
- package/dist/mjs/lib/myassert/index.js +0 -8
- package/dist/mjs/lib/table/index.d.ts +0 -2
- package/dist/mjs/lib/table/index.js +0 -18
- package/dist/mjs/lib/table/table-parser.d.ts +0 -127
- package/dist/mjs/lib/table/table-parser.js +0 -105
- package/dist/mjs/lib/table/table.d.ts +0 -12
- package/dist/mjs/lib/table/table.js +0 -248
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.optimizeSVG = exports.drawBlocks = exports.createHand = exports.ImageHelper = void 0;
|
|
30
|
-
var core_1 = require("../core");
|
|
31
|
-
var svg_js_1 = require("@svgdotjs/svg.js");
|
|
32
|
-
var core_2 = require("../core");
|
|
33
|
-
var BaseHelper = (function () {
|
|
34
|
-
function BaseHelper(props) {
|
|
35
|
-
if (props === void 0) { props = {}; }
|
|
36
|
-
var _a, _b, _c, _d, _e;
|
|
37
|
-
this.scale = (_a = props.scale) !== null && _a !== void 0 ? _a : 1;
|
|
38
|
-
this.imageHostPath = (_b = props.imageHostPath) !== null && _b !== void 0 ? _b : "";
|
|
39
|
-
this.imageHostUrl = (_c = props.imageHostUrl) !== null && _c !== void 0 ? _c : "";
|
|
40
|
-
this.imageExt = (_d = props.imageExt) !== null && _d !== void 0 ? _d : "svg";
|
|
41
|
-
this.tileWidth = core_2.TILE_CONTEXT.WIDTH * this.scale;
|
|
42
|
-
this.tileHeight = core_2.TILE_CONTEXT.HEIGHT * this.scale;
|
|
43
|
-
this.svgSprite = (_e = props.svgSprite) !== null && _e !== void 0 ? _e : false;
|
|
44
|
-
}
|
|
45
|
-
BaseHelper.prototype.getDiffTileHeightWidth = function (t) {
|
|
46
|
-
var size = t.imageSize(this.scale);
|
|
47
|
-
return (size.baseHeight - size.baseWidth) / 2;
|
|
48
|
-
};
|
|
49
|
-
BaseHelper.prototype.image = function (tile) {
|
|
50
|
-
var img = new svg_js_1.Image().load(this.buildURL(tile));
|
|
51
|
-
if (this.svgSprite) {
|
|
52
|
-
img = new svg_js_1.Use().use(BaseHelper.buildID(tile));
|
|
53
|
-
}
|
|
54
|
-
if (tile instanceof core_1.Tile && tile.has(core_2.OPERATOR.COLOR_GRAYSCALE)) {
|
|
55
|
-
img.css({ filter: "contrast(65%)" });
|
|
56
|
-
}
|
|
57
|
-
return img;
|
|
58
|
-
};
|
|
59
|
-
BaseHelper.prototype.createImage = function (tile, x, y) {
|
|
60
|
-
var size = tile.imageSize(this.scale);
|
|
61
|
-
var image = this.image(tile)
|
|
62
|
-
.dx(x)
|
|
63
|
-
.dy(y)
|
|
64
|
-
.size(size.baseWidth, size.baseHeight);
|
|
65
|
-
return image;
|
|
66
|
-
};
|
|
67
|
-
BaseHelper.prototype.createTextImage = function (tile, x, y, t) {
|
|
68
|
-
var image = this.createImage(tile, x, y);
|
|
69
|
-
var size = tile.imageSize(this.scale);
|
|
70
|
-
var fontSize = size.baseHeight * 0.2;
|
|
71
|
-
var textX = size.baseWidth;
|
|
72
|
-
var textY = size.baseHeight;
|
|
73
|
-
var text = new svg_js_1.Text().text(t);
|
|
74
|
-
text
|
|
75
|
-
.size(size.baseWidth, size.baseHeight)
|
|
76
|
-
.font({
|
|
77
|
-
family: core_2.FONT_FAMILY,
|
|
78
|
-
size: fontSize,
|
|
79
|
-
})
|
|
80
|
-
.dx(textX)
|
|
81
|
-
.dy(textY);
|
|
82
|
-
var g = new svg_js_1.G();
|
|
83
|
-
g.add(image).add(text).translate(x, y);
|
|
84
|
-
return g;
|
|
85
|
-
};
|
|
86
|
-
BaseHelper.prototype.createRotate90Image = function (tile, x, y, adjustY) {
|
|
87
|
-
if (adjustY === void 0) { adjustY = false; }
|
|
88
|
-
var image = this.createImage(tile, 0, 0);
|
|
89
|
-
var size = tile.imageSize(this.scale);
|
|
90
|
-
var centerX = size.baseWidth / 2;
|
|
91
|
-
var centerY = size.baseHeight / 2;
|
|
92
|
-
var translatedX = x + this.getDiffTileHeightWidth(tile);
|
|
93
|
-
var translatedY = adjustY ? y - this.getDiffTileHeightWidth(tile) : y;
|
|
94
|
-
var g = new svg_js_1.G();
|
|
95
|
-
g.add(image)
|
|
96
|
-
.translate(translatedX, translatedY)
|
|
97
|
-
.rotate(90, centerX, centerY);
|
|
98
|
-
return g;
|
|
99
|
-
};
|
|
100
|
-
BaseHelper.prototype.createStick = function (v) {
|
|
101
|
-
return this.image(v);
|
|
102
|
-
};
|
|
103
|
-
BaseHelper.buildID = function (tile) {
|
|
104
|
-
if (tile == 100 || tile == 1000) {
|
|
105
|
-
return tile == 100 ? "stick100" : "stick1000";
|
|
106
|
-
}
|
|
107
|
-
var n = tile.t == core_2.TYPE.BACK ? 0 : tile.n;
|
|
108
|
-
return "".concat(tile.t).concat(n);
|
|
109
|
-
};
|
|
110
|
-
BaseHelper.prototype.buildURL = function (tile) {
|
|
111
|
-
var filename = "".concat(BaseHelper.buildID(tile), ".").concat(this.imageExt);
|
|
112
|
-
if (this.imageHostUrl != "") {
|
|
113
|
-
return "".concat(this.imageHostUrl).concat(filename);
|
|
114
|
-
}
|
|
115
|
-
return "".concat(this.imageHostPath).concat(filename);
|
|
116
|
-
};
|
|
117
|
-
return BaseHelper;
|
|
118
|
-
}());
|
|
119
|
-
var ImageHelper = (function (_super) {
|
|
120
|
-
__extends(ImageHelper, _super);
|
|
121
|
-
function ImageHelper() {
|
|
122
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
123
|
-
_this.blockMargin = core_2.TILE_CONTEXT.WIDTH * core_2.TILE_CONTEXT.BLOCK_MARGIN_SCALE * _this.scale;
|
|
124
|
-
return _this;
|
|
125
|
-
}
|
|
126
|
-
ImageHelper.prototype.createBlockHandDiscard = function (block) {
|
|
127
|
-
var g = new svg_js_1.G();
|
|
128
|
-
var pos = 0;
|
|
129
|
-
for (var _i = 0, _a = block.tiles; _i < _a.length; _i++) {
|
|
130
|
-
var t = _a[_i];
|
|
131
|
-
var size = t.imageSize(this.scale);
|
|
132
|
-
var f = t.has(core_2.OPERATOR.HORIZONTAL)
|
|
133
|
-
? this.createRotate90Image.bind(this)
|
|
134
|
-
: this.createImage.bind(this);
|
|
135
|
-
var y = t.has(core_2.OPERATOR.HORIZONTAL) ? this.getDiffTileHeightWidth(t) : 0;
|
|
136
|
-
var img = f(t, pos, y);
|
|
137
|
-
g.add(img);
|
|
138
|
-
pos += size.width;
|
|
139
|
-
}
|
|
140
|
-
return g;
|
|
141
|
-
};
|
|
142
|
-
ImageHelper.prototype.createBlockPonChiKan = function (block) {
|
|
143
|
-
var idx = block.tiles.findIndex(function (d) { return d.has(core_2.OPERATOR.HORIZONTAL); });
|
|
144
|
-
var pos = 0;
|
|
145
|
-
var g = new svg_js_1.G();
|
|
146
|
-
if (block.type == core_2.BLOCK.SHO_KAN) {
|
|
147
|
-
var lastIdx = idx;
|
|
148
|
-
for (var i = 0; i < block.tiles.length; i++)
|
|
149
|
-
if (block.tiles[i].has(core_2.OPERATOR.HORIZONTAL))
|
|
150
|
-
lastIdx = i;
|
|
151
|
-
for (var i = 0; i < block.tiles.length; i++) {
|
|
152
|
-
var size = block.tiles[i].imageSize(this.scale);
|
|
153
|
-
if (i == lastIdx)
|
|
154
|
-
continue;
|
|
155
|
-
if (i == idx) {
|
|
156
|
-
var baseTile = block.tiles[idx];
|
|
157
|
-
var upperTile = block.tiles[lastIdx];
|
|
158
|
-
var size_1 = baseTile.imageSize(this.scale);
|
|
159
|
-
var baseImg = this.createRotate90Image(baseTile, 0, 0, true);
|
|
160
|
-
var upImg = this.createRotate90Image(upperTile, 0, size_1.height, true);
|
|
161
|
-
g.add(new svg_js_1.G().translate(pos, 0).add(baseImg).add(upImg));
|
|
162
|
-
pos += size_1.width;
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
var diff = size.width * 2 - size.height;
|
|
166
|
-
var img = this.createImage(block.tiles[i], pos, diff);
|
|
167
|
-
pos += size.width;
|
|
168
|
-
g.add(img);
|
|
169
|
-
}
|
|
170
|
-
return g;
|
|
171
|
-
}
|
|
172
|
-
if (block.type == core_2.BLOCK.CHI) {
|
|
173
|
-
var img = this.createRotate90Image(block.tiles[idx], pos, this.getDiffTileHeightWidth(block.tiles[idx]));
|
|
174
|
-
pos += block.tiles[idx].imageSize(this.scale).width;
|
|
175
|
-
g.add(img);
|
|
176
|
-
for (var i = 0; i < block.tiles.length; i++) {
|
|
177
|
-
if (i == idx)
|
|
178
|
-
continue;
|
|
179
|
-
var size = block.tiles[i].imageSize(this.scale);
|
|
180
|
-
var img_1 = this.createImage(block.tiles[i], pos, 0);
|
|
181
|
-
pos += size.width;
|
|
182
|
-
g.add(img_1);
|
|
183
|
-
}
|
|
184
|
-
return g;
|
|
185
|
-
}
|
|
186
|
-
for (var i = 0; i < block.tiles.length; i++) {
|
|
187
|
-
var f = i == idx
|
|
188
|
-
? this.createRotate90Image.bind(this)
|
|
189
|
-
: this.createImage.bind(this);
|
|
190
|
-
var y = i == idx ? this.getDiffTileHeightWidth(block.tiles[i]) : 0;
|
|
191
|
-
var size = block.tiles[i].imageSize(this.scale);
|
|
192
|
-
var img = f(block.tiles[i], pos, y);
|
|
193
|
-
pos += size.width;
|
|
194
|
-
g.add(img);
|
|
195
|
-
}
|
|
196
|
-
return g;
|
|
197
|
-
};
|
|
198
|
-
return ImageHelper;
|
|
199
|
-
}(BaseHelper));
|
|
200
|
-
exports.ImageHelper = ImageHelper;
|
|
201
|
-
var getBlockCreators = function (h) {
|
|
202
|
-
var _a;
|
|
203
|
-
var scale = h.scale;
|
|
204
|
-
var lookup = (_a = {},
|
|
205
|
-
_a[core_2.BLOCK.CHI] = function (block) {
|
|
206
|
-
var size = block.imageSize(scale);
|
|
207
|
-
var g = h.createBlockPonChiKan(block);
|
|
208
|
-
return __assign(__assign({}, size), { e: g });
|
|
209
|
-
},
|
|
210
|
-
_a[core_2.BLOCK.PON] = function (block) {
|
|
211
|
-
var size = block.imageSize(scale);
|
|
212
|
-
var g = h.createBlockPonChiKan(block);
|
|
213
|
-
return __assign(__assign({}, size), { e: g });
|
|
214
|
-
},
|
|
215
|
-
_a[core_2.BLOCK.DAI_KAN] = function (block) {
|
|
216
|
-
var size = block.imageSize(scale);
|
|
217
|
-
var g = h.createBlockPonChiKan(block);
|
|
218
|
-
return __assign(__assign({}, size), { e: g });
|
|
219
|
-
},
|
|
220
|
-
_a[core_2.BLOCK.SHO_KAN] = function (block) {
|
|
221
|
-
var size = block.imageSize(scale);
|
|
222
|
-
var g = h.createBlockPonChiKan(block);
|
|
223
|
-
return __assign(__assign({}, size), { e: g });
|
|
224
|
-
},
|
|
225
|
-
_a[core_2.BLOCK.AN_KAN] = function (block) {
|
|
226
|
-
if (!(block instanceof core_1.BlockAnKan))
|
|
227
|
-
throw new Error("block type is not ankan: ".concat(block.type));
|
|
228
|
-
var size = block.imageSize(scale);
|
|
229
|
-
var zp = block.tilesWithBack.filter(function (v) {
|
|
230
|
-
return v.t !== core_2.TYPE.BACK;
|
|
231
|
-
});
|
|
232
|
-
if (!(zp != null && zp.length == 2))
|
|
233
|
-
throw new Error("[debug] back tile must be two but ".concat(block));
|
|
234
|
-
var g = h.createBlockHandDiscard(new core_1.BlockAnKan([zp[0], zp[1], zp[0], zp[1]]));
|
|
235
|
-
return __assign(__assign({}, size), { e: g });
|
|
236
|
-
},
|
|
237
|
-
_a[core_2.BLOCK.IMAGE_DORA] = function (block) {
|
|
238
|
-
var size = block.imageSize(scale);
|
|
239
|
-
var g = new svg_js_1.G();
|
|
240
|
-
var img = h.createTextImage(block.tiles[0], 0, 0, "(ドラ)");
|
|
241
|
-
g.add(img);
|
|
242
|
-
return __assign(__assign({}, size), { e: g });
|
|
243
|
-
},
|
|
244
|
-
_a[core_2.BLOCK.TSUMO] = function (block) {
|
|
245
|
-
var size = block.imageSize(scale);
|
|
246
|
-
var g = new svg_js_1.G();
|
|
247
|
-
var img = h.createTextImage(block.tiles[0], 0, 0, "(ツモ)");
|
|
248
|
-
g.add(img);
|
|
249
|
-
return __assign(__assign({}, size), { e: g });
|
|
250
|
-
},
|
|
251
|
-
_a[core_2.BLOCK.HAND] = function (block) {
|
|
252
|
-
var size = block.imageSize(scale);
|
|
253
|
-
var g = h.createBlockHandDiscard(block);
|
|
254
|
-
return __assign(__assign({}, size), { e: g });
|
|
255
|
-
},
|
|
256
|
-
_a[core_2.BLOCK.IMAGE_DISCARD] = function (block) {
|
|
257
|
-
var size = block.imageSize(scale);
|
|
258
|
-
var g = h.createBlockHandDiscard(block);
|
|
259
|
-
return __assign(__assign({}, size), { e: g });
|
|
260
|
-
},
|
|
261
|
-
_a[core_2.BLOCK.THREE] = function (block) {
|
|
262
|
-
throw new Error("found unknown block");
|
|
263
|
-
},
|
|
264
|
-
_a[core_2.BLOCK.RUN] = function (block) {
|
|
265
|
-
throw new Error("found unknown block");
|
|
266
|
-
},
|
|
267
|
-
_a[core_2.BLOCK.UNKNOWN] = function (block) {
|
|
268
|
-
throw new Error("found unknown block");
|
|
269
|
-
},
|
|
270
|
-
_a[core_2.BLOCK.PAIR] = function (block) {
|
|
271
|
-
throw new Error("unsupported");
|
|
272
|
-
},
|
|
273
|
-
_a[core_2.BLOCK.ISOLATED] = function (block) {
|
|
274
|
-
throw new Error("unsupported");
|
|
275
|
-
},
|
|
276
|
-
_a);
|
|
277
|
-
return lookup;
|
|
278
|
-
};
|
|
279
|
-
var createHand = function (helper, blocks) {
|
|
280
|
-
var _a = blocks.reduce(function (acc, b) {
|
|
281
|
-
var size = b.imageSize(helper.scale);
|
|
282
|
-
var v = size.height > acc.maxHeight ? size.height : acc.maxHeight;
|
|
283
|
-
return { maxHeight: v, sumWidth: acc.sumWidth + size.width };
|
|
284
|
-
}, { maxHeight: 0, sumWidth: 0 }), maxHeight = _a.maxHeight, sumWidth = _a.sumWidth;
|
|
285
|
-
var viewBoxHeight = maxHeight;
|
|
286
|
-
var viewBoxWidth = sumWidth + (blocks.length - 1) * helper.blockMargin;
|
|
287
|
-
var creators = getBlockCreators(helper);
|
|
288
|
-
var elms = [];
|
|
289
|
-
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
|
|
290
|
-
var block = blocks_1[_i];
|
|
291
|
-
var fn = creators[block.type];
|
|
292
|
-
var elm = fn(block);
|
|
293
|
-
elms.push(elm);
|
|
294
|
-
}
|
|
295
|
-
var hand = new svg_js_1.G();
|
|
296
|
-
var pos = 0;
|
|
297
|
-
for (var _b = 0, elms_1 = elms; _b < elms_1.length; _b++) {
|
|
298
|
-
var elm = elms_1[_b];
|
|
299
|
-
var diff = viewBoxHeight - elm.height;
|
|
300
|
-
var g = new svg_js_1.G().translate(pos, diff);
|
|
301
|
-
g.add(elm.e);
|
|
302
|
-
hand.add(g);
|
|
303
|
-
pos += elm.width + helper.blockMargin;
|
|
304
|
-
}
|
|
305
|
-
return { e: hand, width: viewBoxWidth, height: viewBoxHeight };
|
|
306
|
-
};
|
|
307
|
-
exports.createHand = createHand;
|
|
308
|
-
var drawBlocks = function (svg, blocks, config, params) {
|
|
309
|
-
if (config === void 0) { config = {}; }
|
|
310
|
-
if (params === void 0) { params = { responsive: false }; }
|
|
311
|
-
var helper = new ImageHelper(config);
|
|
312
|
-
var hand = (0, exports.createHand)(helper, blocks);
|
|
313
|
-
if (!params.responsive)
|
|
314
|
-
svg.size(hand.width, hand.height);
|
|
315
|
-
svg.viewbox(0, 0, hand.width, hand.height);
|
|
316
|
-
svg.add(hand.e);
|
|
317
|
-
};
|
|
318
|
-
exports.drawBlocks = drawBlocks;
|
|
319
|
-
var getValidIDs = function () {
|
|
320
|
-
var values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
321
|
-
var ids = [];
|
|
322
|
-
var _loop_1 = function (kind) {
|
|
323
|
-
if (kind == core_2.TYPE.BACK) {
|
|
324
|
-
ids.push(BaseHelper.buildID(new core_1.Tile(kind, 0)));
|
|
325
|
-
return "continue";
|
|
326
|
-
}
|
|
327
|
-
ids.push.apply(ids, values.map(function (v) { return BaseHelper.buildID(new core_1.Tile(kind, v)); }).flat());
|
|
328
|
-
};
|
|
329
|
-
for (var _i = 0, _a = Object.values(core_2.TYPE); _i < _a.length; _i++) {
|
|
330
|
-
var kind = _a[_i];
|
|
331
|
-
_loop_1(kind);
|
|
332
|
-
}
|
|
333
|
-
return ids;
|
|
334
|
-
};
|
|
335
|
-
var findUsedIDs = function (draw) {
|
|
336
|
-
var validIDs = getValidIDs();
|
|
337
|
-
var usedIDs = [];
|
|
338
|
-
draw.each(function (idx, children) {
|
|
339
|
-
var node = children[idx];
|
|
340
|
-
if (node instanceof svg_js_1.Use) {
|
|
341
|
-
var hrefAttr = node.attr("href");
|
|
342
|
-
var id = hrefAttr.substring(1);
|
|
343
|
-
if (validIDs.includes(id))
|
|
344
|
-
usedIDs.push(id);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
return usedIDs;
|
|
348
|
-
};
|
|
349
|
-
var optimizeSVG = function (draw) {
|
|
350
|
-
var validIDs = getValidIDs();
|
|
351
|
-
var usedIDs = findUsedIDs(draw);
|
|
352
|
-
draw.each(function (idx, children) {
|
|
353
|
-
var node = children[idx];
|
|
354
|
-
if (node instanceof svg_js_1.Symbol) {
|
|
355
|
-
var isUsed = validIDs.includes(node.id()) && usedIDs.includes(node.id());
|
|
356
|
-
if (!isUsed)
|
|
357
|
-
node.remove();
|
|
358
|
-
}
|
|
359
|
-
}, true);
|
|
360
|
-
};
|
|
361
|
-
exports.optimizeSVG = optimizeSVG;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./image";
|
|
@@ -1,17 +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("./image"), exports);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface FontContext {
|
|
2
|
-
font: {
|
|
3
|
-
family: string;
|
|
4
|
-
size: number;
|
|
5
|
-
};
|
|
6
|
-
textWidth: number;
|
|
7
|
-
textHeight: number;
|
|
8
|
-
numWidth: number;
|
|
9
|
-
numHeight: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class MeasureText {
|
|
12
|
-
ctx: CanvasRenderingContext2D | null;
|
|
13
|
-
strText: string;
|
|
14
|
-
numText: string;
|
|
15
|
-
constructor(strText?: string, numText?: string);
|
|
16
|
-
private measure;
|
|
17
|
-
measureFontContext: (fontFamily: string, fontSize: number) => FontContext;
|
|
18
|
-
measureTableFontContext: (tableScale: number) => FontContext;
|
|
19
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MeasureText = void 0;
|
|
4
|
-
var constants_1 = require("../core/constants");
|
|
5
|
-
var myassert_1 = require("../myassert");
|
|
6
|
-
var MeasureText = (function () {
|
|
7
|
-
function MeasureText(strText, numText) {
|
|
8
|
-
if (strText === void 0) { strText = "東"; }
|
|
9
|
-
if (numText === void 0) { numText = "2"; }
|
|
10
|
-
var _this = this;
|
|
11
|
-
this.ctx = null;
|
|
12
|
-
this.measure = function (str, fontStr) {
|
|
13
|
-
if (_this.ctx == null) {
|
|
14
|
-
_this.ctx = document.createElement("canvas").getContext("2d");
|
|
15
|
-
(0, myassert_1.assert)(_this.ctx, "context is null");
|
|
16
|
-
}
|
|
17
|
-
var ctx = _this.ctx;
|
|
18
|
-
ctx.font = fontStr;
|
|
19
|
-
var metrics = ctx.measureText(str);
|
|
20
|
-
var width = metrics.width;
|
|
21
|
-
var height = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
|
|
22
|
-
return [width, height];
|
|
23
|
-
};
|
|
24
|
-
this.measureFontContext = function (fontFamily, fontSize) {
|
|
25
|
-
var font = { family: fontFamily, size: fontSize };
|
|
26
|
-
var fontString = "".concat(font.size, "px ").concat(font.family);
|
|
27
|
-
var _a = _this.measure(_this.strText, fontString), textWidth = _a[0], textHeight = _a[1];
|
|
28
|
-
var _b = _this.measure(_this.numText, fontString), numWidth = _b[0], numHeight = _b[1];
|
|
29
|
-
var ret = {
|
|
30
|
-
font: { family: fontFamily, size: fontSize },
|
|
31
|
-
textWidth: textWidth,
|
|
32
|
-
textHeight: textHeight,
|
|
33
|
-
numWidth: numWidth,
|
|
34
|
-
numHeight: numHeight,
|
|
35
|
-
};
|
|
36
|
-
return ret;
|
|
37
|
-
};
|
|
38
|
-
this.measureTableFontContext = function (tableScale) {
|
|
39
|
-
var fontCtx = _this.measureFontContext(constants_1.FONT_FAMILY, constants_1.TABLE_CONTEXT.BASE * tableScale);
|
|
40
|
-
fontCtx.textHeight = fontCtx.textWidth;
|
|
41
|
-
fontCtx.numHeight = fontCtx.numWidth;
|
|
42
|
-
return fontCtx;
|
|
43
|
-
};
|
|
44
|
-
this.strText = strText;
|
|
45
|
-
this.numText = numText;
|
|
46
|
-
}
|
|
47
|
-
return MeasureText;
|
|
48
|
-
}());
|
|
49
|
-
exports.MeasureText = MeasureText;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function assert(condition: any, message?: string): asserts condition;
|
|
@@ -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("./table"), exports);
|
|
18
|
-
__exportStar(require("./table-parser"), exports);
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { InferOutput } from "valibot";
|
|
2
|
-
import { Tile, Block } from "../core/parser";
|
|
3
|
-
import { WIND_MAP, ROUND_MAP } from "../core/constants";
|
|
4
|
-
declare const tableInputSchema: import("valibot").StrictObjectSchema<{
|
|
5
|
-
readonly board: import("valibot").StrictObjectSchema<{
|
|
6
|
-
readonly round: import("valibot").OptionalSchema<import("valibot").PicklistSchema<("1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4")[], undefined>, "1w1">;
|
|
7
|
-
readonly sticks: import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
8
|
-
readonly reach: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, "">, import("valibot").MaxValueAction<number, 9, "">]>, 0>;
|
|
9
|
-
readonly dead: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, "">, import("valibot").MaxValueAction<number, 9, "">]>, 0>;
|
|
10
|
-
}, undefined>, {
|
|
11
|
-
readonly reach: 0;
|
|
12
|
-
readonly dead: 0;
|
|
13
|
-
}>;
|
|
14
|
-
readonly doras: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, readonly ["3w"]>;
|
|
15
|
-
readonly front: import("valibot").OptionalSchema<import("valibot").PicklistSchema<("1w" | "2w" | "3w" | "4w")[], undefined>, "1w">;
|
|
16
|
-
}, undefined>;
|
|
17
|
-
readonly "1w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
18
|
-
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
19
|
-
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
20
|
-
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
21
|
-
}, undefined>, {
|
|
22
|
-
readonly discard: "";
|
|
23
|
-
readonly hand: "";
|
|
24
|
-
readonly score: 25000;
|
|
25
|
-
}>;
|
|
26
|
-
readonly "2w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
27
|
-
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
28
|
-
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
29
|
-
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
30
|
-
}, undefined>, {
|
|
31
|
-
readonly discard: "";
|
|
32
|
-
readonly hand: "";
|
|
33
|
-
readonly score: 25000;
|
|
34
|
-
}>;
|
|
35
|
-
readonly "3w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
36
|
-
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
37
|
-
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
38
|
-
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
39
|
-
}, undefined>, {
|
|
40
|
-
readonly discard: "";
|
|
41
|
-
readonly hand: "";
|
|
42
|
-
readonly score: 25000;
|
|
43
|
-
}>;
|
|
44
|
-
readonly "4w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
45
|
-
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
46
|
-
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
47
|
-
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
48
|
-
}, undefined>, {
|
|
49
|
-
readonly discard: "";
|
|
50
|
-
readonly hand: "";
|
|
51
|
-
readonly score: 25000;
|
|
52
|
-
}>;
|
|
53
|
-
}, undefined>;
|
|
54
|
-
export type TableInput = InferOutput<typeof tableInputSchema>;
|
|
55
|
-
export interface DiscardsInput {
|
|
56
|
-
front: Tile[];
|
|
57
|
-
right: Tile[];
|
|
58
|
-
opposite: Tile[];
|
|
59
|
-
left: Tile[];
|
|
60
|
-
}
|
|
61
|
-
export interface HandsInput {
|
|
62
|
-
front: Block[];
|
|
63
|
-
right: Block[];
|
|
64
|
-
opposite: Block[];
|
|
65
|
-
left: Block[];
|
|
66
|
-
}
|
|
67
|
-
export interface ScoreBoardInput {
|
|
68
|
-
doras: Tile[];
|
|
69
|
-
round: BoardRound;
|
|
70
|
-
sticks: {
|
|
71
|
-
reach: number;
|
|
72
|
-
dead: number;
|
|
73
|
-
};
|
|
74
|
-
scores: {
|
|
75
|
-
front: number;
|
|
76
|
-
right: number;
|
|
77
|
-
opposite: number;
|
|
78
|
-
left: number;
|
|
79
|
-
};
|
|
80
|
-
frontPlace: BoardWind;
|
|
81
|
-
}
|
|
82
|
-
export type TableWind = keyof typeof WIND_MAP;
|
|
83
|
-
export type TableRound = keyof typeof ROUND_MAP;
|
|
84
|
-
type BoardRound = (typeof ROUND_MAP)[keyof typeof ROUND_MAP];
|
|
85
|
-
type BoardWind = (typeof WIND_MAP)[keyof typeof WIND_MAP];
|
|
86
|
-
export declare const parse: (s: string) => {
|
|
87
|
-
discards: DiscardsInput;
|
|
88
|
-
hands: HandsInput;
|
|
89
|
-
scoreBoard: ScoreBoardInput;
|
|
90
|
-
};
|
|
91
|
-
export declare const parseTableInput: (s: string) => {
|
|
92
|
-
"1w": {
|
|
93
|
-
discard: string;
|
|
94
|
-
hand: string;
|
|
95
|
-
score: number;
|
|
96
|
-
};
|
|
97
|
-
"2w": {
|
|
98
|
-
discard: string;
|
|
99
|
-
hand: string;
|
|
100
|
-
score: number;
|
|
101
|
-
};
|
|
102
|
-
"3w": {
|
|
103
|
-
discard: string;
|
|
104
|
-
hand: string;
|
|
105
|
-
score: number;
|
|
106
|
-
};
|
|
107
|
-
"4w": {
|
|
108
|
-
discard: string;
|
|
109
|
-
hand: string;
|
|
110
|
-
score: number;
|
|
111
|
-
};
|
|
112
|
-
board: {
|
|
113
|
-
round: "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4";
|
|
114
|
-
front: "1w" | "2w" | "3w" | "4w";
|
|
115
|
-
sticks: {
|
|
116
|
-
reach: number;
|
|
117
|
-
dead: number;
|
|
118
|
-
};
|
|
119
|
-
doras: string[];
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
export declare const convertInput: (i: TableInput) => {
|
|
123
|
-
discards: DiscardsInput;
|
|
124
|
-
hands: HandsInput;
|
|
125
|
-
scoreBoard: ScoreBoardInput;
|
|
126
|
-
};
|
|
127
|
-
export {};
|