@konoui/mjimage 0.0.12 → 0.0.14

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 (55) hide show
  1. package/dist/mjs/lib/calculator/index.d.ts +7 -19
  2. package/dist/mjs/lib/calculator/index.js +86 -90
  3. package/dist/mjs/lib/constants.d.ts +2 -0
  4. package/dist/mjs/lib/constants.js +6 -1
  5. package/dist/mjs/lib/controller/efficiency.d.ts +1 -0
  6. package/dist/mjs/lib/controller/efficiency.js +16 -8
  7. package/dist/mjs/lib/image.d.ts +5 -5
  8. package/dist/mjs/lib/image.js +109 -111
  9. package/dist/mjs/lib/mjimage.d.ts +1 -0
  10. package/dist/mjs/lib/mjimage.js +6 -4
  11. package/dist/mjs/lib/parser.d.ts +10 -1
  12. package/dist/mjs/lib/parser.js +41 -26
  13. package/dist/mjs/lib/table.d.ts +3 -1
  14. package/dist/mjs/lib/table.js +10 -3
  15. package/dist/mjs/svg/_0.svg +1 -1
  16. package/dist/mjs/svg/m0.svg +1 -1
  17. package/dist/mjs/svg/m1.svg +1 -1
  18. package/dist/mjs/svg/m2.svg +1 -1
  19. package/dist/mjs/svg/m3.svg +1 -1
  20. package/dist/mjs/svg/m4.svg +1 -1
  21. package/dist/mjs/svg/m5.svg +1 -1
  22. package/dist/mjs/svg/m6.svg +1 -1
  23. package/dist/mjs/svg/m7.svg +1 -1
  24. package/dist/mjs/svg/m8.svg +1 -1
  25. package/dist/mjs/svg/m9.svg +1 -1
  26. package/dist/mjs/svg/p0.svg +1 -1
  27. package/dist/mjs/svg/p1.svg +1 -1
  28. package/dist/mjs/svg/p2.svg +1 -1
  29. package/dist/mjs/svg/p3.svg +1 -1
  30. package/dist/mjs/svg/p4.svg +1 -1
  31. package/dist/mjs/svg/p5.svg +1 -1
  32. package/dist/mjs/svg/p6.svg +1 -1
  33. package/dist/mjs/svg/p7.svg +1 -1
  34. package/dist/mjs/svg/p8.svg +1 -1
  35. package/dist/mjs/svg/p9.svg +1 -1
  36. package/dist/mjs/svg/s0.svg +1 -1
  37. package/dist/mjs/svg/s1.svg +1 -1
  38. package/dist/mjs/svg/s2.svg +1 -1
  39. package/dist/mjs/svg/s3.svg +1 -1
  40. package/dist/mjs/svg/s4.svg +1 -1
  41. package/dist/mjs/svg/s5.svg +1 -1
  42. package/dist/mjs/svg/s6.svg +1 -1
  43. package/dist/mjs/svg/s7.svg +1 -1
  44. package/dist/mjs/svg/s8.svg +1 -1
  45. package/dist/mjs/svg/s9.svg +1 -1
  46. package/dist/mjs/svg/stick100.svg +1 -1
  47. package/dist/mjs/svg/stick1000.svg +1 -1
  48. package/dist/mjs/svg/z1.svg +1 -1
  49. package/dist/mjs/svg/z2.svg +1 -1
  50. package/dist/mjs/svg/z3.svg +1 -1
  51. package/dist/mjs/svg/z4.svg +1 -1
  52. package/dist/mjs/svg/z5.svg +1 -1
  53. package/dist/mjs/svg/z6.svg +1 -1
  54. package/dist/mjs/svg/z7.svg +1 -1
  55. package/package.json +2 -2
@@ -1,22 +1,11 @@
1
1
  import { TYPE, Round, Wind } from "../constants";
2
2
  import { Tile, BlockPon, BlockChi, BlockShoKan, BlockAnKan, BlockDaiKan, Type, Block } from "../parser";
3
- type FixedNumber = [
4
- number,
5
- number,
6
- number,
7
- number,
8
- number,
9
- number,
10
- number,
11
- number,
12
- number,
13
- number
14
- ];
3
+ export type TupleOfSize<T, N extends number, R extends unknown[] = []> = R["length"] extends N ? R : TupleOfSize<T, N, [T, ...R]>;
15
4
  export interface HandData {
16
- [TYPE.M]: FixedNumber;
17
- [TYPE.S]: FixedNumber;
18
- [TYPE.P]: FixedNumber;
19
- [TYPE.Z]: [number, number, number, number, number, number, number, number];
5
+ [TYPE.M]: TupleOfSize<number, 10>;
6
+ [TYPE.S]: TupleOfSize<number, 10>;
7
+ [TYPE.P]: TupleOfSize<number, 10>;
8
+ [TYPE.Z]: TupleOfSize<number, 8>;
20
9
  [TYPE.BACK]: [string, number];
21
10
  called: (BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan)[];
22
11
  tsumo: Tile | null;
@@ -32,8 +21,8 @@ export declare class Hand {
32
21
  get reached(): boolean;
33
22
  get drawn(): Tile | null;
34
23
  get menzen(): boolean;
35
- getArrayLen(k: Type): 2 | 8 | 10;
36
- sum(k: Type): number;
24
+ getArrayLen(t: Type): 2 | 8 | 10;
25
+ sum(t: Type): number;
37
26
  get(t: Type, n: number): number;
38
27
  inc(tiles: Tile[]): Tile[];
39
28
  dec(tiles: Tile[]): Tile[];
@@ -272,4 +261,3 @@ export declare class DoubleCalculator {
272
261
  dK13(h: Block[]): never[];
273
262
  calcFu(h: Block[]): number;
274
263
  }
275
- export {};
@@ -65,15 +65,15 @@ var Hand = (function () {
65
65
  get: function () {
66
66
  var tiles = [];
67
67
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
68
- var k = _a[_i];
69
- for (var n = 1; n < this.getArrayLen(k); n++) {
70
- var count = this.get(k, n);
71
- if (k != constants_1.TYPE.Z && n == 5 && this.get(k, 0) > 0) {
72
- count -= this.get(k, 0);
73
- tiles.push(new parser_1.Tile(k, 0));
68
+ var t = _a[_i];
69
+ for (var n = 1; n < this.getArrayLen(t); n++) {
70
+ var count = this.get(t, n);
71
+ if (t != constants_1.TYPE.Z && n == 5 && this.get(t, 0) > 0) {
72
+ count -= this.get(t, 0);
73
+ tiles.push(new parser_1.Tile(t, 0));
74
74
  }
75
75
  for (var i = 0; i < count; i++) {
76
- tiles.push(new parser_1.Tile(k, n));
76
+ tiles.push(new parser_1.Tile(t, n));
77
77
  }
78
78
  }
79
79
  }
@@ -126,13 +126,13 @@ var Hand = (function () {
126
126
  enumerable: false,
127
127
  configurable: true
128
128
  });
129
- Hand.prototype.getArrayLen = function (k) {
130
- return this.data[k].length;
129
+ Hand.prototype.getArrayLen = function (t) {
130
+ return this.data[t].length;
131
131
  };
132
- Hand.prototype.sum = function (k) {
132
+ Hand.prototype.sum = function (t) {
133
133
  var sum = 0;
134
- for (var n = 1; n < this.getArrayLen(k); n++)
135
- sum += this.get(k, n);
134
+ for (var n = 1; n < this.getArrayLen(t); n++)
135
+ sum += this.get(t, n);
136
136
  return sum;
137
137
  };
138
138
  Hand.prototype.get = function (t, n) {
@@ -144,7 +144,7 @@ var Hand = (function () {
144
144
  var backup = [];
145
145
  for (var _i = 0, tiles_1 = tiles; _i < tiles_1.length; _i++) {
146
146
  var t = tiles_1[_i];
147
- if (t.t != constants_1.TYPE.BACK && this.get(t.t, t.n) > 4) {
147
+ if (t.t != constants_1.TYPE.BACK && this.get(t.t, t.n) >= 4) {
148
148
  this.dec(backup);
149
149
  throw new Error("unable to increase ".concat(t, " in ").concat(this.toString()));
150
150
  }
@@ -301,15 +301,15 @@ var ShantenCalculator = (function () {
301
301
  var nOrphans = 0;
302
302
  var nPairs = 0;
303
303
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
304
- var k = _a[_i];
305
- if (k == constants_1.TYPE.BACK)
304
+ var t = _a[_i];
305
+ if (t == constants_1.TYPE.BACK)
306
306
  continue;
307
- var nn = k == constants_1.TYPE.Z ? [1, 2, 3, 4, 5, 6, 7] : [1, 9];
307
+ var nn = t == constants_1.TYPE.Z ? [1, 2, 3, 4, 5, 6, 7] : [1, 9];
308
308
  for (var _b = 0, nn_1 = nn; _b < nn_1.length; _b++) {
309
309
  var n = nn_1[_b];
310
- if (this.hand.get(k, n) >= 1)
310
+ if (this.hand.get(t, n) >= 1)
311
311
  nOrphans++;
312
- if (this.hand.get(k, n) >= 2)
312
+ if (this.hand.get(t, n) >= 2)
313
313
  nPairs++;
314
314
  }
315
315
  }
@@ -361,12 +361,10 @@ var ShantenCalculator = (function () {
361
361
  };
362
362
  var min = calc(false);
363
363
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
364
- var k = _a[_i];
365
- for (var n = 1; n < this.hand.getArrayLen(k); n++) {
366
- if (k == constants_1.TYPE.BACK && this.hand.get(k, n) % 3 != 2)
367
- continue;
368
- if (this.hand.get(k, n) >= 2) {
369
- var tiles = this.hand.dec([new parser_1.Tile(k, n), new parser_1.Tile(k, n)]);
364
+ var t = _a[_i];
365
+ for (var n = 1; n < this.hand.getArrayLen(t); n++) {
366
+ if (this.hand.get(t, n) >= 2) {
367
+ var tiles = this.hand.dec([new parser_1.Tile(t, n), new parser_1.Tile(t, n)]);
370
368
  var r = calc(true);
371
369
  this.hand.inc(tiles);
372
370
  if (r < min) {
@@ -377,23 +375,23 @@ var ShantenCalculator = (function () {
377
375
  }
378
376
  return min;
379
377
  };
380
- ShantenCalculator.prototype.commonByType = function (k, n) {
378
+ ShantenCalculator.prototype.commonByType = function (t, n) {
381
379
  if (n === void 0) { n = 1; }
382
- if (k == constants_1.TYPE.BACK || k == constants_1.TYPE.Z)
383
- throw new Error("expect number type but ".concat(k));
380
+ if (t == constants_1.TYPE.BACK || t == constants_1.TYPE.Z)
381
+ throw new Error("expect number type but ".concat(t));
384
382
  if (n > 9)
385
- return this.groupRemainingTiles(k);
386
- var max = this.commonByType(k, n + 1);
383
+ return this.groupRemainingTiles(t);
384
+ var max = this.commonByType(t, n + 1);
387
385
  if (n <= 7 &&
388
- this.hand.get(k, n) > 0 &&
389
- this.hand.get(k, n + 1) > 0 &&
390
- this.hand.get(k, n + 2) > 0) {
386
+ this.hand.get(t, n) > 0 &&
387
+ this.hand.get(t, n + 1) > 0 &&
388
+ this.hand.get(t, n + 2) > 0) {
391
389
  var tiles = this.hand.dec([
392
- new parser_1.Tile(k, n),
393
- new parser_1.Tile(k, n + 1),
394
- new parser_1.Tile(k, n + 2),
390
+ new parser_1.Tile(t, n),
391
+ new parser_1.Tile(t, n + 1),
392
+ new parser_1.Tile(t, n + 2),
395
393
  ]);
396
- var r = this.commonByType(k, n);
394
+ var r = this.commonByType(t, n);
397
395
  this.hand.inc(tiles);
398
396
  r.patternA[0]++, r.patternB[0]++;
399
397
  if (r.patternA[2] < max.patternA[2] ||
@@ -405,13 +403,13 @@ var ShantenCalculator = (function () {
405
403
  max.patternB = r.patternB;
406
404
  }
407
405
  }
408
- if (this.hand.get(k, n) >= 3) {
406
+ if (this.hand.get(t, n) >= 3) {
409
407
  var tiles = this.hand.dec([
410
- new parser_1.Tile(k, n),
411
- new parser_1.Tile(k, n),
412
- new parser_1.Tile(k, n),
408
+ new parser_1.Tile(t, n),
409
+ new parser_1.Tile(t, n),
410
+ new parser_1.Tile(t, n),
413
411
  ]);
414
- var r = this.commonByType(k, n);
412
+ var r = this.commonByType(t, n);
415
413
  this.hand.inc(tiles);
416
414
  r.patternA[0]++, r.patternB[0]++;
417
415
  if (r.patternA[2] < max.patternA[2] ||
@@ -425,15 +423,15 @@ var ShantenCalculator = (function () {
425
423
  }
426
424
  return max;
427
425
  };
428
- ShantenCalculator.prototype.groupRemainingTiles = function (k) {
426
+ ShantenCalculator.prototype.groupRemainingTiles = function (t) {
429
427
  var nSerialPairs = 0;
430
428
  var nIsolated = 0;
431
429
  var nTiles = 0;
432
- for (var n = 1; n < this.hand.getArrayLen(k); n++) {
433
- nTiles += this.hand.get(k, n);
430
+ for (var n = 1; n < this.hand.getArrayLen(t); n++) {
431
+ nTiles += this.hand.get(t, n);
434
432
  if (n <= 7 &&
435
- this.hand.get(k, n + 1) == 0 &&
436
- this.hand.get(k, n + 2) == 0) {
433
+ this.hand.get(t, n + 1) == 0 &&
434
+ this.hand.get(t, n + 2) == 0) {
437
435
  nSerialPairs += nTiles >> 1;
438
436
  nIsolated += nTiles % 2;
439
437
  nTiles = 0;
@@ -518,13 +516,13 @@ var BlockCalculator = (function () {
518
516
  return [];
519
517
  var ret = [];
520
518
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
521
- var k = _a[_i];
522
- if (k == constants_1.TYPE.BACK)
519
+ var t = _a[_i];
520
+ if (t == constants_1.TYPE.BACK)
523
521
  continue;
524
- for (var n = 1; n < this.hand.getArrayLen(k); n++) {
525
- var v = this.hand.get(k, n);
522
+ for (var n = 1; n < this.hand.getArrayLen(t); n++) {
523
+ var v = this.hand.get(t, n);
526
524
  if (v == 2)
527
- ret.push(new parser_1.BlockPair(new parser_1.Tile(k, n), new parser_1.Tile(k, n)));
525
+ ret.push(new parser_1.BlockPair(new parser_1.Tile(t, n), new parser_1.Tile(t, n)));
528
526
  else if (v == 0)
529
527
  continue;
530
528
  else
@@ -537,16 +535,16 @@ var BlockCalculator = (function () {
537
535
  var ret = [];
538
536
  var pairs = "";
539
537
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
540
- var k = _a[_i];
541
- if (k == constants_1.TYPE.BACK)
538
+ var t = _a[_i];
539
+ if (t == constants_1.TYPE.BACK)
542
540
  continue;
543
- var nn = k == constants_1.TYPE.Z ? [1, 2, 3, 4, 5, 6, 7] : [1, 9];
541
+ var nn = t == constants_1.TYPE.Z ? [1, 2, 3, 4, 5, 6, 7] : [1, 9];
544
542
  for (var _b = 0, nn_2 = nn; _b < nn_2.length; _b++) {
545
543
  var n = nn_2[_b];
546
- if (this.hand.get(k, n) == 1)
547
- ret.push(new parser_1.BlockIsolated(new parser_1.Tile(k, n)));
548
- else if (this.hand.get(k, n) == 2 && pairs == "")
549
- ret.unshift(new parser_1.BlockPair(new parser_1.Tile(k, n), new parser_1.Tile(k, n)));
544
+ if (this.hand.get(t, n) == 1)
545
+ ret.push(new parser_1.BlockIsolated(new parser_1.Tile(t, n)));
546
+ else if (this.hand.get(t, n) == 2 && pairs == "")
547
+ ret.unshift(new parser_1.BlockPair(new parser_1.Tile(t, n), new parser_1.Tile(t, n)));
550
548
  else
551
549
  return [];
552
550
  }
@@ -555,25 +553,25 @@ var BlockCalculator = (function () {
555
553
  };
556
554
  BlockCalculator.prototype.nineGates = function () {
557
555
  var _this = this;
558
- var cond = function (k, n, want) {
559
- return want.includes(_this.hand.get(k, n));
556
+ var cond = function (t, n, want) {
557
+ return want.includes(_this.hand.get(t, n));
560
558
  };
561
559
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
562
- var k = _a[_i];
563
- if (k == constants_1.TYPE.BACK)
560
+ var t = _a[_i];
561
+ if (t == constants_1.TYPE.BACK)
564
562
  continue;
565
- if (k == constants_1.TYPE.Z)
563
+ if (t == constants_1.TYPE.Z)
566
564
  continue;
567
- var cond1 = cond(k, 1, [3, 4]) &&
568
- cond(k, 9, [3, 4]) &&
569
- cond(k, 2, [1, 2]) &&
570
- cond(k, 3, [1, 2]) &&
571
- cond(k, 4, [1, 2]) &&
572
- cond(k, 5, [1, 2]) &&
573
- cond(k, 6, [1, 2]) &&
574
- cond(k, 7, [1, 2]) &&
575
- cond(k, 8, [1, 2]);
576
- var cond2 = this.hand.sum(k) == 14;
565
+ var cond1 = cond(t, 1, [3, 4]) &&
566
+ cond(t, 9, [3, 4]) &&
567
+ cond(t, 2, [1, 2]) &&
568
+ cond(t, 3, [1, 2]) &&
569
+ cond(t, 4, [1, 2]) &&
570
+ cond(t, 5, [1, 2]) &&
571
+ cond(t, 6, [1, 2]) &&
572
+ cond(t, 7, [1, 2]) &&
573
+ cond(t, 8, [1, 2]);
574
+ var cond2 = this.hand.sum(t) == 14;
577
575
  if (cond1 && cond2) {
578
576
  return [[new parser_1.Block(this.hand.hands, constants_1.BLOCK.HAND)]];
579
577
  }
@@ -583,12 +581,10 @@ var BlockCalculator = (function () {
583
581
  BlockCalculator.prototype.fourSetsOnePair = function () {
584
582
  var ret = [];
585
583
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
586
- var k = _a[_i];
584
+ var t = _a[_i];
587
585
  var _loop_1 = function (n) {
588
- if (k == constants_1.TYPE.BACK && this_1.hand.get(k, n) % 3 != 2)
589
- return "continue";
590
- if (this_1.hand.get(k, n) >= 2) {
591
- var tiles_3 = this_1.hand.dec([new parser_1.Tile(k, n), new parser_1.Tile(k, n)]);
586
+ if (this_1.hand.get(t, n) >= 2) {
587
+ var tiles_3 = this_1.hand.dec([new parser_1.Tile(t, n), new parser_1.Tile(t, n)]);
592
588
  var v = this_1.commonAll()
593
589
  .filter(function (arr) { return arr.length == 4; })
594
590
  .map(function (arr) {
@@ -600,7 +596,7 @@ var BlockCalculator = (function () {
600
596
  }
601
597
  };
602
598
  var this_1 = this;
603
- for (var n = 1; n < this.hand.getArrayLen(k); n++) {
599
+ for (var n = 1; n < this.hand.getArrayLen(t); n++) {
604
600
  _loop_1(n);
605
601
  }
606
602
  }
@@ -1130,15 +1126,15 @@ var DoubleCalculator = (function () {
1130
1126
  var cond = !h.some(function (block) { return block.tiles[0].t == constants_1.TYPE.Z; });
1131
1127
  if (cond)
1132
1128
  return [];
1133
- var _loop_4 = function (k) {
1134
- var ok = h.every(function (b) { return b.tiles[0].t == constants_1.TYPE.Z || b.tiles[0].t == k; });
1129
+ var _loop_4 = function (t) {
1130
+ var ok = h.every(function (b) { return b.tiles[0].t == constants_1.TYPE.Z || b.tiles[0].t == t; });
1135
1131
  if (ok)
1136
1132
  return { value: [{ name: "混一色", double: 3 - this_3.minus() }] };
1137
1133
  };
1138
1134
  var this_3 = this;
1139
1135
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
1140
- var k = _a[_i];
1141
- var state_3 = _loop_4(k);
1136
+ var t = _a[_i];
1137
+ var state_3 = _loop_4(t);
1142
1138
  if (typeof state_3 === "object")
1143
1139
  return state_3.value;
1144
1140
  }
@@ -1165,17 +1161,17 @@ var DoubleCalculator = (function () {
1165
1161
  DoubleCalculator.prototype.dA6 = function (h) {
1166
1162
  if (h.some(function (block) { return block.tiles[0].t == constants_1.TYPE.Z; }))
1167
1163
  return [];
1168
- var _loop_5 = function (k) {
1169
- if (k == constants_1.TYPE.Z)
1164
+ var _loop_5 = function (t) {
1165
+ if (t == constants_1.TYPE.Z)
1170
1166
  return "continue";
1171
- var ok = h.every(function (v) { return v.tiles[0].t == k; });
1167
+ var ok = h.every(function (v) { return v.tiles[0].t == t; });
1172
1168
  if (ok)
1173
1169
  return { value: [{ name: "清一色", double: 6 - this_4.minus() }] };
1174
1170
  };
1175
1171
  var this_4 = this;
1176
1172
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
1177
- var k = _a[_i];
1178
- var state_4 = _loop_5(k);
1173
+ var t = _a[_i];
1174
+ var state_4 = _loop_5(t);
1179
1175
  if (typeof state_4 === "object")
1180
1176
  return state_4.value;
1181
1177
  }
@@ -1385,6 +1381,6 @@ var countSameBlocks = function (h) {
1385
1381
  };
1386
1382
  var toDora = function (doraMarker) {
1387
1383
  var n = doraMarker.isNum() && doraMarker.n == 0 ? 5 : doraMarker.n;
1388
- var k = doraMarker.t;
1389
- return new parser_1.Tile(k, (n % 9) + 1);
1384
+ var t = doraMarker.t;
1385
+ return new parser_1.Tile(t, (n % 9) + 1);
1390
1386
  };
@@ -2,6 +2,8 @@ export declare const FONT_FAMILY = "MS Gothic, sans-serif";
2
2
  export declare const TILE_CONTEXT: {
3
3
  WIDTH: number;
4
4
  HEIGHT: number;
5
+ TEXT_SCALE: number;
6
+ BLOCK_MARGIN_SCALE: number;
5
7
  };
6
8
  export declare const TABLE_CONTEXT: {
7
9
  BASE: number;
@@ -3,7 +3,12 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
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
5
  exports.FONT_FAMILY = "MS Gothic, sans-serif";
6
- exports.TILE_CONTEXT = { WIDTH: 66, HEIGHT: 90 };
6
+ exports.TILE_CONTEXT = {
7
+ WIDTH: 66,
8
+ HEIGHT: 90,
9
+ TEXT_SCALE: 0.8,
10
+ BLOCK_MARGIN_SCALE: 0.3,
11
+ };
7
12
  exports.TABLE_CONTEXT = { BASE: 40 };
8
13
  exports.INPUT_SEPARATOR = ",";
9
14
  exports.TYPE = {
@@ -17,6 +17,7 @@ export declare class Efficiency {
17
17
  shanten: number;
18
18
  candidates: Tile[];
19
19
  };
20
+ static partialShanten(input: string): number;
20
21
  }
21
22
  export interface PlayerCandidate {
22
23
  tile: Tile;
@@ -43,22 +43,22 @@ var Efficiency = (function () {
43
43
  var candidates = [];
44
44
  var sc = new calculator_1.ShantenCalculator(hand);
45
45
  for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
46
- var k = _a[_i];
47
- if (k == constants_1.TYPE.BACK)
46
+ var t = _a[_i];
47
+ if (t == constants_1.TYPE.BACK)
48
48
  continue;
49
- for (var n = 1; n < hand.getArrayLen(k); n++) {
50
- if (hand.get(k, n) >= 4)
49
+ for (var n = 1; n < hand.getArrayLen(t); n++) {
50
+ if (hand.get(t, n) >= 4)
51
51
  continue;
52
- var t = new parser_1.Tile(k, n);
53
- var tiles = hand.inc([t]);
52
+ var tile = new parser_1.Tile(t, n);
53
+ var tiles = hand.inc([tile]);
54
54
  var s = sc.calc();
55
55
  hand.dec(tiles);
56
56
  if (s < r) {
57
57
  r = s;
58
- candidates = [t];
58
+ candidates = [tile];
59
59
  }
60
60
  else if (s == r)
61
- candidates.push(t);
61
+ candidates.push(tile);
62
62
  }
63
63
  }
64
64
  return {
@@ -73,6 +73,14 @@ var Efficiency = (function () {
73
73
  .map(function () { return h.inc([new parser_1.Tile(constants_1.TYPE.BACK, 0)]); });
74
74
  return Efficiency.candidateTiles(h);
75
75
  };
76
+ Efficiency.partialShanten = function (input) {
77
+ var h = new calculator_1.Hand(input, true);
78
+ Array(13 - h.hands.length)
79
+ .fill(undefined)
80
+ .map(function () { return h.inc([new parser_1.Tile(constants_1.TYPE.BACK, 0)]); });
81
+ var sc = new calculator_1.ShantenCalculator(h);
82
+ return sc.calc();
83
+ };
76
84
  return Efficiency;
77
85
  }());
78
86
  exports.Efficiency = Efficiency;
@@ -9,17 +9,15 @@ export interface ImageHelperConfig {
9
9
  declare class BaseHelper {
10
10
  readonly tileWidth: number;
11
11
  readonly tileHeight: number;
12
- readonly diffTileHeightWidth: number;
13
- readonly textWidth: number;
14
12
  readonly image_host_path: string;
15
13
  readonly image_host_url: string;
16
14
  readonly scale: number;
17
15
  readonly svgSprite: boolean;
18
16
  constructor(props?: ImageHelperConfig);
17
+ protected getDiffTileHeightWidth(t: Tile): number;
19
18
  private image;
20
19
  createImage(tile: Tile, x: number, y: number): Image | Use;
21
20
  createTextImage(tile: Tile, x: number, y: number, t: string): G;
22
- createStackImage(baseTile: Tile, upTile: Tile, x: number, y: number): G;
23
21
  createRotate90Image(tile: Tile, x: number, y: number, adjustY?: boolean): G;
24
22
  createStick(v: 100 | 1000): Image | Use;
25
23
  static buildID(tile: Tile | 100 | 1000): string;
@@ -27,7 +25,7 @@ declare class BaseHelper {
27
25
  }
28
26
  export declare class ImageHelper extends BaseHelper {
29
27
  readonly blockMargin: number;
30
- createBlockHandDiscard(tiles: Tile[]): G;
28
+ createBlockHandDiscard(block: Block): G;
31
29
  createBlockPonChiKan(block: Block): G;
32
30
  }
33
31
  export declare const createHand: (helper: ImageHelper, blocks: Block[]) => {
@@ -35,6 +33,8 @@ export declare const createHand: (helper: ImageHelper, blocks: Block[]) => {
35
33
  width: number;
36
34
  height: number;
37
35
  };
38
- export declare const drawBlocks: (svg: Svg, blocks: Block[], config?: ImageHelperConfig) => void;
36
+ export declare const drawBlocks: (svg: Svg, blocks: Block[], config?: ImageHelperConfig, params?: {
37
+ responsive: boolean;
38
+ }) => void;
39
39
  export declare const optimizeSVG: (draw: Svg) => void;
40
40
  export {};