136 lines
No EOL
48 KiB
JavaScript
136 lines
No EOL
48 KiB
JavaScript
/*
|
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
* This devtool is neither made for production nor for readable output files.
|
|
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
* or disable the default devtool with "devtool: false".
|
|
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
*/
|
|
/******/ (() => { // webpackBootstrap
|
|
/******/ "use strict";
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
/***/ "./src/group.ts":
|
|
/*!**********************!*\
|
|
!*** ./src/group.ts ***!
|
|
\**********************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Group: () => (/* binding */ Group)\n/* harmony export */ });\nvar Group = /** @class */ (function () {\n function Group(tiles, stolenFrom, belongsTo) {\n this.tiles = tiles;\n this.stolenFrom = stolenFrom;\n this.belongsTo = belongsTo;\n }\n Group.prototype.push = function (tile) {\n this.tiles.push(tile);\n };\n Group.prototype.pop = function () {\n return this.tiles.pop();\n };\n Group.prototype.getTiles = function () {\n return this.tiles;\n };\n Group.prototype.compare = function (g) {\n var c = this.tiles[0].compare(g.tiles[0]);\n if (c !== 0) {\n return c;\n }\n return this.tiles[1].compare(g.tiles[1]);\n };\n Group.prototype.drawGroup = function (ctx, x, y, os, size, rotation, selectedTile) {\n ctx.save();\n ctx.translate(525, 525);\n ctx.rotate(rotation);\n ctx.translate(-525, -525);\n rotation = 0;\n var v = 75 * size;\n var w = 90 * size;\n var osy = 25 * size / 2;\n var p = (this.belongsTo - this.stolenFrom - 1 + 4) % 4;\n var sf = selectedTile === undefined ? -1 : selectedTile.getFamily();\n var sv = selectedTile === undefined ? 0 : selectedTile.getValue();\n if (p === 0) {\n this.tiles[0].drawTile(ctx, x, y + osy, size, false, 3.141592 / 2, this.tiles[0].isEqual(sf, sv));\n this.tiles[1].drawTile(ctx, x + w, y, size, false, 0, this.tiles[1].isEqual(sf, sv));\n this.tiles[2].drawTile(ctx, x + w + v + os * size, y, size, false, 0, this.tiles[2].isEqual(sf, sv));\n }\n else if (p === 1) {\n this.tiles[0].drawTile(ctx, x, y, size, false, 0, this.tiles[0].isEqual(sf, sv));\n this.tiles[1].drawTile(ctx, x + w, y + osy, size, false, 0 - 3.141592 / 2, this.tiles[1].isEqual(sf, sv));\n this.tiles[2].drawTile(ctx, x + w + v + 3 * os * size, y, size, false, 0, this.tiles[2].isEqual(sf, sv));\n }\n else if (p === 2) {\n this.tiles[0].drawTile(ctx, x, y, size, false, 0, this.tiles[0].isEqual(sf, sv));\n this.tiles[1].drawTile(ctx, x + v + os * size, y, size, false, 0, this.tiles[1].isEqual(sf, sv));\n this.tiles[2].drawTile(ctx, x + w + v + os * size, y + osy, size, false, 0 - 3.141592 / 2, this.tiles[2].isEqual(sf, sv));\n }\n else {\n //TODO error\n }\n ctx.restore();\n };\n return Group;\n}());\n\n\n\n//# sourceURL=webpack:///./src/group.ts?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/hand.ts":
|
|
/*!*********************!*\
|
|
!*** ./src/hand.ts ***!
|
|
\*********************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Hand: () => (/* binding */ Hand)\n/* harmony export */ });\n/* harmony import */ var _tile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tile */ \"./src/tile.ts\");\n/* harmony import */ var _group__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./group */ \"./src/group.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n\n\nvar Hand = /** @class */ (function () {\n function Hand(stiles) {\n if (stiles === void 0) { stiles = \"\"; }\n this.isolate = false;\n this.tiles = [];\n for (var i = 0; i < stiles.length - 1; i++) {\n var ss = stiles.substring(i, i + 2);\n if (ss[0] === \"m\") {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(1, Number(ss[1]), false));\n }\n else if (ss[0] === \"p\") {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(2, Number(ss[1]), false));\n }\n else if (ss[0] === \"s\") {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(3, Number(ss[1]), false));\n }\n else if (ss[0] === \"w\") {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(4, Number(ss[1]), false));\n }\n else if (ss[0] === \"d\") {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(5, Number(ss[1]), false));\n }\n else { }\n }\n }\n Hand.prototype.getTiles = function () {\n return this.tiles;\n };\n Hand.prototype.length = function () {\n return this.tiles.length;\n };\n Hand.prototype.push = function (tile) {\n this.tiles.push(tile);\n };\n Hand.prototype.pop = function () {\n return this.tiles.pop();\n };\n Hand.prototype.find = function (family, value) {\n var _a;\n var n = undefined;\n for (var i = 0; i < this.tiles.length; i++) {\n if (this.tiles[i].getFamily() === family && this.tiles[i].getValue() === value) {\n n = i;\n break;\n }\n }\n if (n !== undefined) {\n _a = [this.tiles[0], this.tiles[n]], this.tiles[n] = _a[0], this.tiles[0] = _a[1];\n var t = this.tiles.shift();\n this.sort();\n return t;\n }\n else {\n return undefined;\n }\n };\n Hand.prototype.eject = function (idTile) {\n var _a;\n _a = [this.tiles[idTile], this.tiles[0]], this.tiles[0] = _a[0], this.tiles[idTile] = _a[1];\n var tile = this.tiles.shift();\n this.sort();\n return tile;\n };\n Hand.prototype.get = function (idTile) {\n if (idTile !== undefined) {\n return this.tiles[idTile];\n }\n else {\n return undefined;\n }\n };\n Hand.prototype.sort = function () {\n this.tiles.sort(function (a, b) { return a.isLessThan(b) ? -1 : 1; });\n };\n Hand.prototype.count = function (family, value) {\n var c = 0;\n this.tiles.forEach(function (t) {\n if (t.getFamily() === family && t.getValue() === value) {\n c++;\n }\n });\n return c;\n };\n Hand.prototype.toGroup = function (pair) {\n if (pair === void 0) { pair = false; }\n if (this.tiles.length > 0) {\n var t1 = this.tiles.pop();\n var c = this.count(t1.getFamily(), t1.getValue());\n if (c >= 1 && !pair) { //can do a pair\n var t2 = this.find(t1.getFamily(), t1.getValue());\n var groups = this.toGroup(true);\n this.tiles.push(t2);\n this.sort();\n if (groups !== undefined) {\n this.tiles.push(t1);\n this.sort();\n groups.push(new _group__WEBPACK_IMPORTED_MODULE_1__.Group([t1, t2], 0, 0));\n return groups;\n }\n }\n if (c >= 2) { //can do a pon\n var t2 = this.find(t1.getFamily(), t1.getValue());\n var t3 = this.find(t1.getFamily(), t1.getValue());\n var groups = this.toGroup(pair);\n this.tiles.push(t2);\n this.tiles.push(t3);\n this.sort();\n if (groups !== undefined) {\n groups.push(new _group__WEBPACK_IMPORTED_MODULE_1__.Group([t1, t2, t3], 0, 0));\n this.tiles.push(t1);\n this.sort();\n return groups;\n }\n }\n var c2 = this.count(t1.getFamily(), t1.getValue() - 1);\n var c3 = this.count(t1.getFamily(), t1.getValue() - 2);\n if (c2 * c3 > 0) { //can do a chii\n var t2 = this.find(t1.getFamily(), t1.getValue() - 1);\n var t3 = this.find(t1.getFamily(), t1.getValue() - 2);\n var groups = this.toGroup(pair);\n this.tiles.push(t2);\n this.tiles.push(t3);\n this.sort();\n if (groups !== undefined) {\n groups.push(new _group__WEBPACK_IMPORTED_MODULE_1__.Group([t3, t2, t1], 0, 0));\n this.tiles.push(t1);\n this.sort();\n return groups;\n }\n }\n this.tiles.push(t1);\n this.tiles.sort();\n return undefined;\n }\n else {\n return [];\n }\n };\n Hand.prototype.drawHand = function (ctx, x, y, offset, size, focusedTiled, hidden, rotation) {\n if (focusedTiled === void 0) { focusedTiled = undefined; }\n if (hidden === void 0) { hidden = false; }\n if (rotation === void 0) { rotation = 0; }\n var v = (75 + offset) * size;\n var vx = Math.cos(rotation) * v;\n var vy = Math.sin(rotation) * v;\n for (var i = 0; i < this.tiles.length; i++) {\n var e = (i === this.tiles.length - 1 && this.isolate) ? 10 : 0;\n if (i === focusedTiled) {\n this.tiles[i].drawTile(ctx, x +\n i * vx +\n 25 * size * Math.sin(rotation) +\n e * size * Math.cos(rotation), y +\n i * vy -\n 25 * size * Math.cos(rotation) +\n e * size * Math.sin(rotation), size, hidden, rotation);\n }\n else {\n this.tiles[i].drawTile(ctx, x + i * vx + e * size * Math.cos(rotation), y + i * vy + e * size * Math.sin(rotation), size, hidden, rotation);\n }\n }\n };\n Hand.prototype.preload = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all(this.tiles.map(function (t) { return t.preloadImg(); }))];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n Hand.prototype.cleanup = function () {\n this.tiles.forEach(function (tile) { return tile.cleanup(); });\n this.tiles = [];\n };\n return Hand;\n}());\n\n\n\n//# sourceURL=webpack:///./src/hand.ts?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/tests/assert.ts":
|
|
/*!*****************************!*\
|
|
!*** ./src/tests/assert.ts ***!
|
|
\*****************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assert: () => (/* binding */ assert)\n/* harmony export */ });\nfunction assert(b, msg) {\n if (b) {\n console.log(\"%c[SUCCES] \" + msg, \"color: green\");\n return 1;\n }\n else {\n console.log(\"%c[ECHEC] \" + msg, \"color: red\");\n return 0;\n }\n}\n\n\n//# sourceURL=webpack:///./src/tests/assert.ts?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/tests/test_yakus.ts":
|
|
/*!*********************************!*\
|
|
!*** ./src/tests/test_yakus.ts ***!
|
|
\*********************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _assert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assert */ \"./src/tests/assert.ts\");\n/* harmony import */ var _yakus_yaku__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../yakus/yaku */ \"./src/yakus/yaku.ts\");\n/* harmony import */ var _hand__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../hand */ \"./src/hand.ts\");\n\n\n\nvar count = 0;\nvar total = 0;\nvar h1 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 m4m5m6 m7m8m9 m1m2m3 m5m5\");\nvar h2 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5\");\nvar h3 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m1m1 p9p9p9 s1s1s1 w2w2w2 d1d1\");\nvar h4 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8\");\nvar h5 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 m1m2m3 p7p8p9 p7p8p9 w3w3\");\nvar h6 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 m1m2m3 p6p7p8 p7p8p9 w3w3\");\nvar h7 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 p1p2p3 s1s2s3 m7m8m9 p9p9\");\nvar h8 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 m1m2m3 p6p6 w0w0w0 w3w3w3\");\nvar h9 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 m1m2m3 d1d1d1 d2d2d2 d3d3\");\nvar h10 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 p6p6 d1d1d1 d2d2d2 d3d3d3\");\nvar h11 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3 w1w1w1 w2w2w2 w3w3w3 w4w4\");\nvar h12 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m1 w1w1w1 w2w2w2 w3w3w3 w4w4w4\");\nvar h13 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"d1d1 w1w1w1 w2w2w2 w3w3w3 w4w4w4\");\n// lipeikou\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.lipekou(h5, [], 0) === 1, \"m123 m123 p789 p789 w33 is Lipeikou\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.lipekou(h3, [], 0) === 0, \"m111 p999 s111 w222 d11 is not Lipeikou\");\ntotal += 2;\n// ryanpeikou\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.ryanpeikou(h5, [], 0) === 3, \"m123 m123 p789 p789 w33 is Ryanpeikou\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.ryanpeikou(h6, [], 0) === 0, \"m1123 m123 p678 p789 w33 is not Ryanpeikou\");\ntotal += 2;\n// pinfu\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.pinfu(h1, [], 0) === 1, \"m123 m456 m789 m123 p55 is Pinfu\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.pinfu(h2, [], 0) === 0, \"m111 m444 m777 p111 p55 is not Pinfu\");\ntotal += 2;\n// sanshoku doujun\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.sanshokuDoujun(h7, [], 0) === 2, \"m123 p123 s123 m789 p99 is Shanshokou Doujun\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.sanshokuDoujun(h2, [], 0) === 0, \"m111 m444 m777 p111 p55 is not Shanshokou Doujun\");\ntotal += 2;\n// ittsuu\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.ittsuu(h1, [], 0) === 2, \"m123 m456 m789 m123 m55 is Ittsuu\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.ittsuu(h2, [], 0) === 0, \"m111 m444 m777 p111 p55 is not Ittsu\");\ntotal += 2;\n// tanyao\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.tanyao(h4, [], 0) === 1, \"m234 p333 p456 s44 s678 is Tanyao\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.tanyao(h1, [], 0) === 0, \"m123 m456 m789 m123 p55 is not Tanyao\");\ntotal += 2;\n// yakuhai\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.yakuhai(h3, [], 2) === 1, \"m111 p999 s111 w222 d11 West is Yakuhai\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.yakuhai(h8, [], 3) === 2, \"m123 m123 p66 w000 w333 North is double Yakuhai\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.yakuhai(h3, [], 0) === 0, \"m111 p999 s111 w222 d11 Est is not Yakuhai\");\ntotal += 3;\n// shousangen\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.shousangen(h9, [], 0) === 2, \"m123 m123 d111 d222 d33 is Shousangen\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.shousangen(h10, [], 0) === 0, \"m123 p66 d111 d222 d333 is not Shousangen\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.shousangen(h3, [], 0) === 0, \"m111 p999 s111 w222 d11 is not Shousangen\");\ntotal += 3;\n// daisangen\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.daisangen(h10, [], 0) === 13, \"m123 p66 d111 d222 d333 is Daisangen\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.daisangen(h9, [], 0) === 0, \"m123 m123 d111 d222 d33 is not Daisangen\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.daisangen(h3, [], 0) === 0, \"m111 p999 s111 w222 d11 is not Daisangen\");\ntotal += 3;\n// shousuushi\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.shousuushii(h11, [], 0) === 13, \"m123 w111 w222 w333 w44 is Shousuushi\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.shousuushii(h12, [], 0) === 0, \"m11 w111 w222 w333 w444 is not Shousuushi\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.shousuushii(h3, [], 0) === 0, \"m111 p999 s111 w222 d11 is not Shousuushi\");\ntotal += 3;\n// daisuushi\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.daisuushi(h12, [], 0) === 13, \"m11 w111 w222 w333 w444 is Daisuushi\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.daisuushi(h11, [], 0) === 0, \"m123 w111 w222 w333 w44 is not Daisuushi\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.daisuushi(h3, [], 0) === 0, \"m111 p999 s111 w222 d11 is not Daisuushi\");\ntotal += 3;\n// chanta\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.chanta(h13, [], 0) === 2, \"d11 w111 w222 w333 w444 is Chanta\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.chanta(h12, [], 0) === 2, \"m11 w111 w222 w333 w444 is Chanta\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.chanta(h10, [], 0) === 0, \"m123 p66 d111 d222 d333 is not Chanta\");\ntotal += 3;\n// junchan\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.junchan(h7, [], 0) === 3, \"m123 p123 s123 m789 p99 is Junchan\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.junchan(h10, [], 0) === 0, \"m123 p66 d111 d222 d333 is not Junchan\");\ntotal += 2;\n// total\nconsole.log(\"Succès: \" + count.toString() + \"/\" + total.toString());\n\n\n//# sourceURL=webpack:///./src/tests/test_yakus.ts?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/tile.ts":
|
|
/*!*********************!*\
|
|
!*** ./src/tile.ts ***!
|
|
\*********************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Tile: () => (/* binding */ Tile)\n/* harmony export */ });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar Tile = /** @class */ (function () {\n function Tile(family, value, red) {\n this.family = family;\n this.value = value;\n this.red = red;\n this.imgSrc = \"\";\n this.imgFront = new Image();\n this.imgBack = new Image();\n this.imgGray = new Image();\n this.img = new Image();\n this.tilt = 0;\n this.setImgSrc();\n }\n Tile.prototype.getFamily = function () {\n return this.family;\n };\n Tile.prototype.getValue = function () {\n return this.value;\n };\n Tile.prototype.isEqual = function (family, value) {\n return this.family === family && this.value === value;\n };\n Tile.prototype.isRed = function () {\n return this.red;\n };\n Tile.prototype.compare = function (t) {\n if (this.family < t.family) {\n return -1;\n }\n else if (this.family > t.family) {\n return 1;\n }\n if (this.value < t.value) {\n return -1;\n }\n else if (this.value > t.value) {\n return 1;\n }\n return 0;\n };\n Tile.prototype.setTilt = function () {\n this.tilt = (1 - 2 * Math.random()) * 0.04;\n };\n Tile.prototype.drawTile = function (ctx, x, y, size, hidden, rotation, gray, tilted) {\n if (hidden === void 0) { hidden = false; }\n if (rotation === void 0) { rotation = 0; }\n if (gray === void 0) { gray = false; }\n if (tilted === void 0) { tilted = true; }\n ctx.save();\n ctx.translate(x + (75 * size) / 2, y + (100 * size) / 2);\n if (tilted) {\n ctx.rotate(rotation + this.tilt);\n }\n else {\n ctx.rotate(rotation);\n }\n if (hidden) {\n ctx.drawImage(// ombre\n this.imgGray, -(75 * size * 0.92) / 2, -(100 * size * 0.91) / 2, 75 * size, 100 * size);\n ctx.drawImage(// le dos des tuiles\n this.imgBack, -(75 * size) / 2, -(100 * size) / 2, 75 * size, 100 * size);\n }\n else {\n ctx.drawImage(// ombre\n this.imgGray, -(75 * size * 0.92) / 2, -(100 * size * 0.91) / 2, 75 * size, 100 * size);\n ctx.drawImage(// tuile à vide\n this.imgFront, -(75 * size) / 2, -(100 * size) / 2, 75 * size, 100 * size);\n ctx.drawImage(// le dessin sur la tuile\n this.img, -((75 - 7) * size) / 2, -((100 - 10) * size) / 2, 75 * size * 0.9, 100 * size * 0.9);\n if (gray) { // grisé\n ctx.drawImage(this.imgGray, -(75 * size) / 2, -(100 * size) / 2, 75 * size, 100 * size);\n }\n }\n ctx.restore();\n };\n Tile.prototype.isLessThan = function (t) {\n if (this.family < t.family) {\n return true;\n }\n else if (this.family === t.family && this.value <= t.value) {\n return true;\n }\n else {\n return false;\n }\n };\n Tile.prototype.cleanup = function () {\n this.imgFront.onload = null;\n this.imgFront.onerror = null;\n this.imgBack.onload = null;\n this.imgBack.onerror = null;\n this.imgGray.onload = null;\n this.imgGray.onerror = null;\n this.img.onload = null;\n this.img.onerror = null;\n };\n Tile.prototype.setImgSrc = function () {\n this.imgSrc = \"img/Regular/\";\n if (this.family <= 3) {\n this.imgSrc += [\"\", \"Man\", \"Pin\", \"Sou\"][this.family];\n this.imgSrc += String(this.value);\n if (this.red) {\n this.imgSrc += \"-Dora\";\n }\n this.imgSrc += \".svg\";\n }\n else if (this.family === 4) {\n this.imgSrc += [\"\", \"Ton\", \"Nan\", \"Shaa\", \"Pei\"][this.value] + \".svg\";\n }\n else if (this.family === 5) {\n this.imgSrc += [\"\", \"Chun\", \"Hatsu\", \"Haku\"][this.value] + \".svg\";\n }\n };\n Tile.prototype.preloadImg = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, Promise.all([\n this.loadImg(this.imgFront, \"img/Regular/Front.svg\"),\n // this.loadImg(this.imgFront, \"/~img/Export/Regular/Front.png\"),\n this.loadImg(this.imgBack, \"img/Regular/Back.svg\"),\n this.loadImg(this.imgGray, \"img/Regular/Gray.svg\"),\n this.loadImg(this.img, this.imgSrc)\n ])];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n Tile.prototype.loadImg = function (img, src) {\n return new Promise(function (resolve, reject) {\n img.onload = function () { return resolve(); };\n img.onerror = function () { return reject(); };\n img.src = src;\n });\n };\n return Tile;\n}());\n\n\n\n//# sourceURL=webpack:///./src/tile.ts?");
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/yakus/yaku.ts":
|
|
/*!***************************!*\
|
|
!*** ./src/yakus/yaku.ts ***!
|
|
\***************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ yakus: () => (/* binding */ yakus)\n/* harmony export */ });\nfunction ord(g) {\n return g.getTiles().every(function (t) { return t.getFamily() < 4 &&\n t.getValue() > 1 &&\n t.getValue() < 9; });\n}\nfunction term(g) {\n return g.getTiles().every(function (t) {\n return t.getFamily() < 4 &&\n (t.getValue() === 0 ||\n t.getValue() === 9);\n });\n}\nfunction honn(g) {\n return g.getTiles().every(function (t) {\n return t.getFamily() >= 4;\n });\n}\nfunction chii(g) {\n var t = g.getTiles();\n return t[0].getValue() !== t[1].getValue();\n}\nfunction pon(g) {\n var t = g.getTiles();\n return t[0].getValue() === t[1].getValue();\n}\nvar yakus = {\n lipekou: function (\n /**\n * double suite pure\n * 0/1\n */\n hand, groups, wind) {\n if (groups.length > 0 && !yakus.ryanpeikou(hand, groups, wind)) { // ouvert\n return 0;\n }\n var gr = hand.toGroup();\n gr.sort(function (g1, g2) { return g1.compare(g2); });\n for (var i = 0; i < 3; i++) {\n var g1 = gr[i].getTiles();\n var g2 = gr[i + 1].getTiles();\n if (g1[0].isEqual(g2[0].getFamily(), g2[0].getValue()) &&\n chii(gr[i]) && chii(gr[i + 1])) {\n return 1;\n }\n }\n return 0;\n },\n ryanpeikou: function (\n /**\n * deux doubles suites pures\n * 0/3\n */\n hand, groups, wind) {\n if (groups.length > 0) {\n return 0;\n }\n var gr = hand.toGroup();\n gr.filter(function (g) { return chii(g); });\n if (gr.length < 4) { // pas assez de suite\n return 0;\n }\n gr.sort(function (g1, g2) { return g1.compare(g2); });\n var t1 = gr[0].getTiles()[0];\n var t2 = gr[1].getTiles()[0];\n var t3 = gr[2].getTiles()[0];\n var t4 = gr[3].getTiles()[0];\n if (t1.compare(t2) === 0 &&\n t3.compare(t4) === 0) {\n return 3;\n }\n return 0;\n },\n pinfu: function (\n /**\n * tout suite\n * 0/1\n */\n hand, groups, wind) {\n if (groups.length > 0) {\n return 0;\n }\n var h = hand.toGroup();\n if (h !== undefined &&\n h.every(function (g) {\n var tiles = g.getTiles();\n return (chii(g) || tiles.length === 2);\n })) {\n return 1;\n }\n return 0;\n },\n sanshokuDoujun: function (\n /**\n * triple suite\n * 1/2\n */\n hand, groups, wind) {\n var h = hand.toGroup();\n var gr = [];\n if (h !== undefined) {\n gr = groups.concat(h);\n }\n else {\n gr = groups;\n }\n gr = gr.filter(function (g) { return chii(g); });\n gr.sort(function (g1, g2) { return g1.compare(g2); });\n if (gr.length < 3) { // pas assez de chii\n return 0;\n }\n else if (gr.length === 3) {\n var t0 = gr[0].getTiles();\n var t1 = gr[1].getTiles();\n var t2 = gr[2].getTiles();\n if (t0[0].getValue() === t1[0].getValue() &&\n t0[0].getValue() === t2[0].getValue() &&\n t0[0].getFamily() !== t1[0].getFamily() &&\n t0[0].getFamily() !== t2[0].getFamily() &&\n t1[0].getFamily() !== t2[0].getFamily()) {\n return groups.length > 0 ? 1 : 2;\n }\n return 0;\n }\n else { // il y a un intrus\n for (var i = 0; i < 4; i++) {\n var index = [];\n for (var j = 0; j < 4; j++) {\n if (j !== i) {\n index.push(j);\n }\n }\n var t0 = gr[index[0]].getTiles();\n var t1 = gr[index[1]].getTiles();\n var t2 = gr[index[2]].getTiles();\n if (t0[0].getValue() === t1[0].getValue() &&\n t0[0].getValue() === t2[0].getValue() &&\n t0[0].getFamily() !== t1[0].getFamily() &&\n t0[0].getFamily() !== t2[0].getFamily() &&\n t1[0].getFamily() !== t2[0].getFamily()) {\n return groups.length > 0 ? 1 : 2;\n }\n }\n return 0;\n }\n },\n ittsuu: function (\n /**\n * grande suite pure\n * 1/2\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) { return chii(g); });\n gr.sort(function (g1, g2) { return g1.compare(g2); });\n if (gr.length < 3) { // trop peu de suite\n return 0;\n }\n else if (gr.length === 3) { // pile le bon nombre\n var g1 = gr[0].getTiles();\n var g2 = gr[1].getTiles();\n var g3 = gr[2].getTiles();\n if (g1[0].getFamily() === g2[0].getFamily() &&\n g2[0].getFamily() === g3[0].getFamily() &&\n g1[0].getValue() === 1 &&\n g2[0].getValue() === 4 &&\n g3[0].getValue() === 7) {\n return groups.length > 0 ? 1 : 2;\n }\n }\n else { // il y a un intrus\n for (var i = 0; i < 4; i++) {\n var index = [];\n for (var j = 0; j < 4; j++) {\n if (j !== i) {\n index.push(j);\n }\n }\n var t0 = gr[index[0]].getTiles();\n var t1 = gr[index[1]].getTiles();\n var t2 = gr[index[2]].getTiles();\n if (t0[0].getValue() === 1 &&\n t1[0].getValue() === 4 &&\n t2[0].getValue() === 7 &&\n t0[0].getFamily() === t1[0].getFamily() &&\n t0[0].getFamily() === t2[0].getFamily()) {\n return groups.length > 0 ? 1 : 2;\n }\n }\n return 0;\n }\n return 0;\n },\n tanyao: function (\n /**\n * tout ordinaire\n * 1/1\n */\n hand, groups, wind) {\n var h = hand.toGroup();\n if (h === undefined) {\n return 0;\n }\n if (groups.every(function (g) { return ord(g); }) &&\n h.every(function (g) { return ord(g); })) {\n return 1;\n }\n return 0;\n },\n yakuhai: function (\n /**\n * brelan de valeur\n * 1/1\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) { return pon(g) && g.getTiles().length === 3; });\n var han = 0;\n gr.forEach(function (g) {\n var t = g.getTiles();\n var f = t[0].getFamily();\n var v = t[0].getValue();\n if (f === 5) { // brelan de dragon\n han++;\n }\n if (f === 4 && v === 0) { // vent d'est\n han++;\n }\n if (f === 4 && v === wind) { // vent du joueur\n han++;\n }\n });\n return han;\n },\n shousangen: function (\n /**\n * trois petits dragons\n * 2/2\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) { return pon(g); });\n var nbPon = 0;\n var nbPair = 0;\n gr.forEach(function (g) {\n var t = g.getTiles();\n if (t[0].getFamily() === 5) {\n if (t.length === 3) {\n nbPon++;\n }\n else {\n nbPair++;\n }\n }\n });\n if (nbPon == 2 && nbPair == 1) {\n return 2;\n }\n return 0;\n },\n daisangen: function (\n /**\n * trois grands dragons\n * 13/13\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) { return pon(g) &&\n g.getTiles().length === 3 &&\n g.getTiles()[0].getFamily() === 5; });\n if (gr.length === 3) {\n return 13;\n }\n return 0;\n },\n shousuushii: function (\n /**\n * quatre petits vents\n * 13/13\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) { return pon(g); });\n var nbPon = 0;\n var nbPair = 0;\n gr.forEach(function (g) {\n var t = g.getTiles();\n if (t[0].getFamily() === 4) {\n if (t.length === 3) {\n nbPon++;\n }\n else {\n nbPair++;\n }\n }\n });\n if (nbPon == 3 && nbPair == 1) {\n return 13;\n }\n return 0;\n },\n daisuushi: function (\n /**\n * quatre grands vents\n * 13/13\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) { return pon(g); });\n var nbPon = 0;\n var nbPair = 0;\n gr.forEach(function (g) {\n var t = g.getTiles();\n if (t[0].getFamily() === 4) {\n if (t.length === 3) {\n nbPon++;\n }\n else {\n nbPair++;\n }\n }\n });\n if (nbPon == 4 && nbPair == 0) {\n return 13;\n }\n return 0;\n },\n chanta: function (\n /**\n * terminales et honneurs partout\n * 1/2\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) {\n var tiles = g.getTiles();\n var f = tiles[0].getFamily();\n var v = tiles[0].getValue();\n var vd = tiles[tiles.length - 1].getValue();\n return f < 4 && v !== 1 && vd !== 9;\n });\n if (gr.length > 0) {\n return 0;\n }\n return groups.length > 0 ? 1 : 2;\n },\n junchan: function (\n /**\n * terminales partout\n * 2/3\n */\n hand, groups, wind) {\n var gr = groups.concat(hand.toGroup());\n gr = gr.filter(function (g) {\n var tiles = g.getTiles();\n var f = tiles[0].getFamily();\n var v = tiles[0].getValue();\n var vd = tiles[tiles.length - 1].getValue();\n return f > 3 || (v !== 1 && vd !== 9);\n });\n if (gr.length > 0) {\n return 0;\n }\n return groups.length > 0 ? 2 : 3;\n },\n honroutou: function (//TODO\n /**\n * tout terminale et honneur\n * 2/2\n */\n hand, groups, wind) {\n return 0;\n },\n chinroutou: function (\n /**\n * tout terminale\n * 13/13\n */\n hand, groups, wind) {\n var h = hand.toGroup();\n if (h === undefined) {\n return 0;\n }\n if (groups.every(function (g) { return term(g); }) &&\n h.every(function (g) { return term(g); })) {\n return 13;\n }\n return 0;\n },\n tsuuiisou: function (\n /**\n * tout honneur\n * 13/13\n */\n hand, groups, wind) {\n var h = hand.toGroup();\n if (h === undefined) {\n return 0;\n }\n if (groups.every(function (g) { return honn(g); }) &&\n h.every(function (g) { return honn(g); })) {\n return 13;\n }\n return 0;\n },\n kokushiMusou: function (\n /**\n * treize orphelins\n * 0/13\n */\n hand, groups, wind) {\n if (groups.length > 0) {\n return 0;\n }\n if (yakus.honroutou(hand, groups, wind) === 0) {\n return 0;\n }\n var h = hand.getTiles();\n var count = 0;\n for (var i = 0; i < h.length - 1; i++) {\n if (h[i].isEqual(h[i + 1].getFamily(), h[i + 1].getValue())) {\n count++;\n }\n if (count > 1) {\n break;\n }\n }\n if (count === 1) {\n return 13;\n }\n return 0;\n },\n chiitoitsu: function (\n /**\n * sept paires\n * 0/2\n */\n hand, groups, wind) {\n return 0;\n if (groups.length > 0) {\n return 0;\n }\n //TODO\n },\n toitoi: function (\n /**\n * tout brelans\n * 2/2\n */\n hand, groups, wind) {\n var h = hand.toGroup();\n if (groups.every(function (g) { return pon(g); }) &&\n (h === null || h === void 0 ? void 0 : h.every(function (g) { return pon(g); }))) {\n return 2;\n }\n return 0;\n },\n sanankou: function (\n /**\n * trois brelan cachés\n * 2/2\n */\n hand, groups, wind) {\n var h = hand.toGroup();\n var count = 0;\n h === null || h === void 0 ? void 0 : h.forEach(function (g) {\n if (pon(g) && g.getTiles().length === 3) {\n count++;\n }\n });\n if (count === 3) {\n return 2;\n }\n return 0;\n },\n suuankou: function (\n /**\n * quatre brelans cachés\n * 0/13\n */\n hand, groups, wind) {\n var h = hand.toGroup();\n var count = 0;\n h === null || h === void 0 ? void 0 : h.forEach(function (g) {\n if (pon(g) && g.getTiles().length === 3) {\n count++;\n }\n });\n if (count === 4) {\n return 13;\n }\n return 0;\n },\n sanshokuDoukou: function (//TODO\n /**\n * triple brelan\n * 2/2\n */\n hand, groups, wind) {\n return 0;\n },\n sankantsu: function (//TODO\n /**\n * trois carrés\n * 2/2\n */\n hand, groups, wind) {\n return 0;\n },\n suukantsu: function (//TODO\n /**\n * quatre carrés\n * 13/13\n */\n hand, groups, wind) {\n return 0;\n },\n honitsu: function (//TODO\n /**\n * semie pure\n * 2/3\n */\n hand, groups, wind) {\n return 0;\n },\n chinitsu: function (\n /**\n * main pure\n * 5/6\n */\n hand, groups, wind) {\n var h = hand.getTiles();\n var t0 = h[0];\n if (h.every(function (t) { return t.getFamily() === t0.getFamily(); }) &&\n groups.every(function (g) { return g.getTiles().every(function (t) { return t.getFamily() === t0.getFamily(); }); })) {\n return groups.length > 0 ? 5 : 6;\n }\n return 0;\n },\n ryuuisou: function (//TODO\n /**\n * main verte\n * 13/13\n */\n hand, groups, wind) {\n if (yakus.chinitsu(hand, groups, wind) === 0) {\n return 0;\n }\n return 0;\n },\n chuurenPoutou: function (//TODO\n /**\n * neuf portes\n * 0/13\n */\n hand, groups, wind) {\n if (groups.length > 0 || yakus.chinitsu(hand, groups, wind) === 0) {\n return 0;\n }\n return 0;\n }\n};\n\n\n//# sourceURL=webpack:///./src/yakus/yaku.ts?");
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
/************************************************************************/
|
|
/******/ // The module cache
|
|
/******/ var __webpack_module_cache__ = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/ // Check if module is in cache
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
/******/ if (cachedModule !== undefined) {
|
|
/******/ return cachedModule.exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
/******/ // no module.id needed
|
|
/******/ // no module.loaded needed
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/************************************************************************/
|
|
/******/ /* webpack/runtime/define property getters */
|
|
/******/ (() => {
|
|
/******/ // define getter functions for harmony exports
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
|
/******/ for(var key in definition) {
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
/******/ }
|
|
/******/ }
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
/******/ (() => {
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
/******/ (() => {
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = (exports) => {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/************************************************************************/
|
|
/******/
|
|
/******/ // startup
|
|
/******/ // Load entry module and return exports
|
|
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
/******/ var __webpack_exports__ = __webpack_require__("./src/tests/test_yakus.ts");
|
|
/******/
|
|
/******/ })()
|
|
; |