From 972d36147b3890a343309ccee57f8cdc43214773 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Fri, 4 Apr 2025 08:35:04 +0200 Subject: [PATCH] remis build/ pour le ssh de l'ens qui ne peut riuen compiler tout seul --- build/dp0.js | 33 ++++++++++ build/dp1.js | 126 +++++++++++++++++++++++++++++++++++ build/dp2.js | 126 +++++++++++++++++++++++++++++++++++ build/dp3.js | 126 +++++++++++++++++++++++++++++++++++ build/dp4.js | 156 ++++++++++++++++++++++++++++++++++++++++++++ build/dp5.js | 66 +++++++++++++++++++ build/test_yakus.js | 136 ++++++++++++++++++++++++++++++++++++++ build/txt0.js | 96 +++++++++++++++++++++++++++ build/txt1.js | 96 +++++++++++++++++++++++++++ build/txt2.js | 96 +++++++++++++++++++++++++++ build/txt3.js | 96 +++++++++++++++++++++++++++ build/txt4.js | 96 +++++++++++++++++++++++++++ build/txt5.js | 96 +++++++++++++++++++++++++++ src/yakus/yaku.ts | 29 +++++++- 14 files changed, 1373 insertions(+), 1 deletion(-) create mode 100644 build/dp0.js create mode 100644 build/dp1.js create mode 100644 build/dp2.js create mode 100644 build/dp3.js create mode 100644 build/dp4.js create mode 100644 build/dp5.js create mode 100644 build/test_yakus.js create mode 100644 build/txt0.js create mode 100644 build/txt1.js create mode 100644 build/txt2.js create mode 100644 build/txt3.js create mode 100644 build/txt4.js create mode 100644 build/txt5.js diff --git a/build/dp0.js b/build/dp0.js new file mode 100644 index 0000000..f8ff324 --- /dev/null +++ b/build/dp0.js @@ -0,0 +1,33 @@ +/* + * 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/display/dp0.ts": +/*!****************************!*\ + !*** ./src/display/dp0.ts ***! + \****************************/ +/***/ (() => { + +eval("\n\n\n//# sourceURL=webpack:///./src/display/dp0.ts?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module can't be inlined because the eval devtool is used. +/******/ var __webpack_exports__ = {}; +/******/ __webpack_modules__["./src/display/dp0.ts"](); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/dp1.js b/build/dp1.js new file mode 100644 index 0000000..2161dde --- /dev/null +++ b/build/dp1.js @@ -0,0 +1,126 @@ +/* + * 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/deck.ts": +/*!*********************!*\ + !*** ./src/deck.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 */ Deck: () => (/* binding */ Deck)\n/* harmony export */ });\n/* harmony import */ var _tile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tile */ \"./src/tile.ts\");\n/* harmony import */ var _hand__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hand */ \"./src/hand.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 Deck = /** @class */ (function () {\n function Deck(allowRed) {\n this.tiles = [];\n this.initTiles(allowRed);\n }\n Deck.prototype.displayFamilies = function (ctx, x, y, size, xOffset, yOffset) {\n if (xOffset === void 0) { xOffset = 0; }\n if (yOffset === void 0) { yOffset = 0; }\n var posX = x;\n var posY = y;\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size, false, 0, false);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 4) { //vent\n for (var j = 1; j < 5; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 5) { //vent\n for (var j = 1; j < 4; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n }\n }\n };\n Deck.prototype.length = function () {\n return this.tiles.length;\n };\n Deck.prototype.pop = function () {\n if (this.tiles.length === 0) {\n }\n return this.tiles.pop();\n };\n Deck.prototype.push = function (tile) {\n this.tiles.push(tile);\n };\n Deck.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 &&\n this.tiles[i].getValue() === value) {\n n = i;\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 return this.tiles.shift();\n }\n else {\n return undefined;\n }\n };\n Deck.prototype.count = function (family, value) {\n var n = 0;\n for (var i = 0; i < this.tiles.length; i++) {\n if (this.tiles[i].getFamily() === family &&\n this.tiles[i].getValue() === value) {\n n++;\n }\n }\n return n;\n };\n Deck.prototype.shuffle = function () {\n var _a;\n var newArray = [];\n while (this.tiles.length > 0) {\n var n = Math.floor(Math.random() * this.tiles.length);\n _a = [this.tiles[0], this.tiles[n]], this.tiles[n] = _a[0], this.tiles[0] = _a[1];\n newArray.push(this.tiles.shift());\n }\n this.tiles = newArray;\n };\n Deck.prototype.getRandomHand = function () {\n var hand = new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand();\n this.shuffle();\n for (var i = 0; i < 13; i++) {\n hand.push(this.pop());\n }\n return hand;\n };\n Deck.prototype.cleanup = function () {\n this.tiles.forEach(function (tile) { return tile.cleanup(); });\n this.tiles = [];\n };\n Deck.prototype.preload = function () {\n return __awaiter(this, void 0, void 0, function () {\n var i;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < this.tiles.length)) return [3 /*break*/, 4];\n return [4 /*yield*/, this.tiles[i].preloadImg()];\n case 2:\n _a.sent();\n _a.label = 3;\n case 3:\n i++;\n return [3 /*break*/, 1];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n Deck.prototype.initTiles = function (allowRed) {\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n if (j === 5 && allowRed) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, true));\n }\n else {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 4) { // vent\n for (var j = 1; j < 5; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 5) { // dragon\n for (var j = 1; j < 4; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n }\n };\n return Deck;\n}());\n\n\n\n//# sourceURL=webpack:///./src/deck.ts?"); + +/***/ }), + +/***/ "./src/display/dp1.ts": +/*!****************************!*\ + !*** ./src/display/dp1.ts ***! + \****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _deck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../deck */ \"./src/deck.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\nfunction preloadDeck(deck) {\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*/, deck.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction display() {\n return __awaiter(this, void 0, void 0, function () {\n var canvas, ctx, x, y, size, xos, yos, deck_1, delta, eps, i, j;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n canvas = document.getElementById(\"myCanvas\");\n if (!canvas) return [3 /*break*/, 4];\n ctx = canvas.getContext(\"2d\");\n if (!ctx) return [3 /*break*/, 2];\n // tapis\n ctx.fillStyle = \"#007730\";\n ctx.fillRect(50, 50, 1000, 1000);\n x = 180;\n y = 80;\n size = 0.75;\n xos = 40;\n yos = 100;\n deck_1 = new _deck__WEBPACK_IMPORTED_MODULE_0__.Deck(false);\n return [4 /*yield*/, preloadDeck(deck_1)];\n case 1:\n _a.sent();\n deck_1.displayFamilies(ctx, x, y, size, xos, yos);\n // texte\n ctx.fillStyle = \"#DFDFFF\";\n ctx.font = \"30px serif\";\n delta = 50 * size;\n eps = 30 * size;\n ctx.fillText(\"Caractère:\", 55, y + delta + eps);\n ctx.fillText(\"Rond:\", 55, y + 3 * delta + yos * size + eps);\n ctx.fillText(\"Bambou:\", 55, y + 5 * delta + 2 * yos * size + eps);\n ctx.fillText(\"Vent:\", 55, y + 7 * delta + 3 * yos * size + eps);\n ctx.fillText(\"Dragon:\", 55, y + 9 * delta + 4 * yos * size + eps);\n // familles\n for (i = 0; i < 3; i++) {\n for (j = 0; j < 9; j++) {\n ctx.fillText(String(j + 1), x + j * (xos + 75) * size + 30 * size, y + i * (yos + 100) * size + 150 * size);\n }\n }\n // vent\n ctx.fillText(\"Est\", x + 0 * (xos + 75) * size, y + 3 * (yos + 100) * size + 150 * size);\n ctx.fillText(\"Sud\", x + 1 * (xos + 75) * size, y + 3 * (yos + 100) * size + 150 * size);\n ctx.fillText(\"Ouest\", x + 2 * (xos + 75) * size, y + 3 * (yos + 100) * size + 150 * size);\n ctx.fillText(\"Nord\", x + 3 * (xos + 75) * size, y + 3 * (yos + 100) * size + 150 * size);\n // dragon\n ctx.fillText(\"Rouge\", x + 0 * (xos + 75) * size, y + 4 * (yos + 100) * size + 150 * size);\n ctx.fillText(\"Vert\", x + 1 * (xos + 75) * size, y + 4 * (yos + 100) * size + 150 * size);\n ctx.fillText(\"Blanc\", x + 2 * (xos + 75) * size, y + 4 * (yos + 100) * size + 150 * size);\n window.cleanup = function () {\n deck_1.cleanup();\n };\n return [3 /*break*/, 3];\n case 2:\n console.error(\"Impossible d'obtenir le contexte du canvas.\");\n _a.label = 3;\n case 3: return [3 /*break*/, 5];\n case 4:\n console.error(\"Canvas introuvable dans le DOM.\");\n _a.label = 5;\n case 5: return [2 /*return*/];\n }\n });\n });\n}\ndisplay();\n\n\n//# sourceURL=webpack:///./src/display/dp1.ts?"); + +/***/ }), + +/***/ "./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; 2 * i + 1 < stiles.length; i++) {\n var ss = stiles.substring(2 * i, 2 * (i + 1));\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 }\n else {\n return [];\n }\n return undefined;\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/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 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?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // 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/display/dp1.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/dp2.js b/build/dp2.js new file mode 100644 index 0000000..f52357d --- /dev/null +++ b/build/dp2.js @@ -0,0 +1,126 @@ +/* + * 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/deck.ts": +/*!*********************!*\ + !*** ./src/deck.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 */ Deck: () => (/* binding */ Deck)\n/* harmony export */ });\n/* harmony import */ var _tile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tile */ \"./src/tile.ts\");\n/* harmony import */ var _hand__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hand */ \"./src/hand.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 Deck = /** @class */ (function () {\n function Deck(allowRed) {\n this.tiles = [];\n this.initTiles(allowRed);\n }\n Deck.prototype.displayFamilies = function (ctx, x, y, size, xOffset, yOffset) {\n if (xOffset === void 0) { xOffset = 0; }\n if (yOffset === void 0) { yOffset = 0; }\n var posX = x;\n var posY = y;\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size, false, 0, false);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 4) { //vent\n for (var j = 1; j < 5; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 5) { //vent\n for (var j = 1; j < 4; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n }\n }\n };\n Deck.prototype.length = function () {\n return this.tiles.length;\n };\n Deck.prototype.pop = function () {\n if (this.tiles.length === 0) {\n }\n return this.tiles.pop();\n };\n Deck.prototype.push = function (tile) {\n this.tiles.push(tile);\n };\n Deck.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 &&\n this.tiles[i].getValue() === value) {\n n = i;\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 return this.tiles.shift();\n }\n else {\n return undefined;\n }\n };\n Deck.prototype.count = function (family, value) {\n var n = 0;\n for (var i = 0; i < this.tiles.length; i++) {\n if (this.tiles[i].getFamily() === family &&\n this.tiles[i].getValue() === value) {\n n++;\n }\n }\n return n;\n };\n Deck.prototype.shuffle = function () {\n var _a;\n var newArray = [];\n while (this.tiles.length > 0) {\n var n = Math.floor(Math.random() * this.tiles.length);\n _a = [this.tiles[0], this.tiles[n]], this.tiles[n] = _a[0], this.tiles[0] = _a[1];\n newArray.push(this.tiles.shift());\n }\n this.tiles = newArray;\n };\n Deck.prototype.getRandomHand = function () {\n var hand = new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand();\n this.shuffle();\n for (var i = 0; i < 13; i++) {\n hand.push(this.pop());\n }\n return hand;\n };\n Deck.prototype.cleanup = function () {\n this.tiles.forEach(function (tile) { return tile.cleanup(); });\n this.tiles = [];\n };\n Deck.prototype.preload = function () {\n return __awaiter(this, void 0, void 0, function () {\n var i;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < this.tiles.length)) return [3 /*break*/, 4];\n return [4 /*yield*/, this.tiles[i].preloadImg()];\n case 2:\n _a.sent();\n _a.label = 3;\n case 3:\n i++;\n return [3 /*break*/, 1];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n Deck.prototype.initTiles = function (allowRed) {\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n if (j === 5 && allowRed) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, true));\n }\n else {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 4) { // vent\n for (var j = 1; j < 5; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 5) { // dragon\n for (var j = 1; j < 4; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n }\n };\n return Deck;\n}());\n\n\n\n//# sourceURL=webpack:///./src/deck.ts?"); + +/***/ }), + +/***/ "./src/display/dp2.ts": +/*!****************************!*\ + !*** ./src/display/dp2.ts ***! + \****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _deck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../deck */ \"./src/deck.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\nvar canvas = document.getElementById(\"myCanvas\");\nfunction preloadDeck(deck) {\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*/, deck.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction display() {\n return __awaiter(this, void 0, void 0, function () {\n var ctx_1, offScreenCanvas_1, offScreenCtx_1, lastTime_1, FPS, interval_1, x_1, y_1, os_1, size_1, deck_1, hands_1, i, hand, edeck_1, ehand_1, selectedTile_1, drawCanvas_1, animationLoop_1;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!canvas) return [3 /*break*/, 5];\n ctx_1 = canvas.getContext(\"2d\");\n if (!ctx_1) return [3 /*break*/, 3];\n offScreenCanvas_1 = document.createElement('canvas');\n offScreenCanvas_1.width = canvas.width;\n offScreenCanvas_1.height = canvas.height;\n offScreenCtx_1 = offScreenCanvas_1.getContext('2d');\n lastTime_1 = 0;\n FPS = 30;\n interval_1 = 1000 / FPS;\n x_1 = 100;\n y_1 = 150;\n os_1 = 75;\n size_1 = 0.75;\n deck_1 = new _deck__WEBPACK_IMPORTED_MODULE_0__.Deck(false);\n return [4 /*yield*/, preloadDeck(deck_1)];\n case 1:\n _a.sent();\n hands_1 = [];\n for (i = 0; i < 4; i++) {\n hand = deck_1.getRandomHand();\n hand.sort();\n hands_1.push(hand);\n }\n edeck_1 = new _deck__WEBPACK_IMPORTED_MODULE_0__.Deck(false);\n return [4 /*yield*/, edeck_1.preload()];\n case 2:\n _a.sent();\n ehand_1 = edeck_1.getRandomHand();\n ehand_1.push(edeck_1.pop());\n ehand_1.sort();\n selectedTile_1 = undefined;\n drawCanvas_1 = function () { return __awaiter(_this, void 0, void 0, function () {\n var i;\n return __generator(this, function (_a) {\n // clean screeen\n offScreenCtx_1.clearRect(0, 0, canvas.width, canvas.height);\n // tapis\n offScreenCtx_1.fillStyle = \"#007730\";\n offScreenCtx_1.fillRect(50, 50, 1000, 1000);\n // texte\n offScreenCtx_1.fillStyle = \"#DFDFFF\";\n offScreenCtx_1.font = \"50px serif\";\n offScreenCtx_1.fillText(\"Exemples de main:\", 65, 100);\n // example hands\n for (i = 0; i < hands_1.length; i++) {\n hands_1[i].drawHand(offScreenCtx_1, x_1, y_1 + i * size_1 * (100 + os_1), 5, size_1);\n }\n // dynamic hand\n ehand_1.isolate = true;\n ehand_1.drawHand(offScreenCtx_1, x_1, 800, 5, size_1, selectedTile_1);\n ctx_1.clearRect(0, 0, canvas.width, canvas.height);\n ctx_1.drawImage(offScreenCanvas_1, 0, 0);\n return [2 /*return*/];\n });\n }); };\n animationLoop_1 = function (currentTime) {\n var deltaTime = currentTime - lastTime_1;\n if (deltaTime >= interval_1) {\n lastTime_1 = currentTime;\n drawCanvas_1();\n }\n requestAnimationFrame(animationLoop_1);\n };\n // mouse event\n canvas.addEventListener(\"mousemove\", function (event) {\n var rect = canvas.getBoundingClientRect();\n var mouseX = event.clientX - rect.left - x_1;\n var mouseY = event.clientY - rect.top;\n var q = Math.floor(mouseX / (80 * size_1));\n var r = mouseX - q * 80 * size_1;\n if (r <= 75 && q >= 0 && q < 14 && mouseY >= 800 && mouseY <= 800 + 100 * size_1) {\n selectedTile_1 = q;\n }\n else {\n selectedTile_1 = undefined;\n }\n });\n canvas.addEventListener(\"mousedown\", function (event) {\n if (selectedTile_1 !== undefined) {\n edeck_1.push(ehand_1.eject(selectedTile_1));\n edeck_1.shuffle();\n ehand_1.sort();\n ehand_1.push(edeck_1.pop());\n }\n });\n requestAnimationFrame(animationLoop_1);\n window.cleanup = function () {\n deck_1.cleanup();\n hands_1.forEach(function (hand) { return hand.cleanup(); });\n hands_1 = [];\n edeck_1.cleanup();\n ehand_1.cleanup();\n ctx_1.clearRect(0, 0, canvas.width, canvas.height);\n offScreenCtx_1.clearRect(0, 0, offScreenCanvas_1.width, offScreenCanvas_1.height);\n selectedTile_1 = undefined;\n };\n return [3 /*break*/, 4];\n case 3:\n console.error(\"Impossible d'obtenir le contexte du canvas.\");\n _a.label = 4;\n case 4: return [3 /*break*/, 6];\n case 5:\n console.error(\"Canvas introuvable dans le DOM.\");\n _a.label = 6;\n case 6: return [2 /*return*/];\n }\n });\n });\n}\ndisplay();\n\n\n//# sourceURL=webpack:///./src/display/dp2.ts?"); + +/***/ }), + +/***/ "./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; 2 * i + 1 < stiles.length; i++) {\n var ss = stiles.substring(2 * i, 2 * (i + 1));\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 }\n else {\n return [];\n }\n return undefined;\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/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 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?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // 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/display/dp2.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/dp3.js b/build/dp3.js new file mode 100644 index 0000000..c1097d7 --- /dev/null +++ b/build/dp3.js @@ -0,0 +1,126 @@ +/* + * 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/deck.ts": +/*!*********************!*\ + !*** ./src/deck.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 */ Deck: () => (/* binding */ Deck)\n/* harmony export */ });\n/* harmony import */ var _tile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tile */ \"./src/tile.ts\");\n/* harmony import */ var _hand__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hand */ \"./src/hand.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 Deck = /** @class */ (function () {\n function Deck(allowRed) {\n this.tiles = [];\n this.initTiles(allowRed);\n }\n Deck.prototype.displayFamilies = function (ctx, x, y, size, xOffset, yOffset) {\n if (xOffset === void 0) { xOffset = 0; }\n if (yOffset === void 0) { yOffset = 0; }\n var posX = x;\n var posY = y;\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size, false, 0, false);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 4) { //vent\n for (var j = 1; j < 5; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 5) { //vent\n for (var j = 1; j < 4; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n }\n }\n };\n Deck.prototype.length = function () {\n return this.tiles.length;\n };\n Deck.prototype.pop = function () {\n if (this.tiles.length === 0) {\n }\n return this.tiles.pop();\n };\n Deck.prototype.push = function (tile) {\n this.tiles.push(tile);\n };\n Deck.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 &&\n this.tiles[i].getValue() === value) {\n n = i;\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 return this.tiles.shift();\n }\n else {\n return undefined;\n }\n };\n Deck.prototype.count = function (family, value) {\n var n = 0;\n for (var i = 0; i < this.tiles.length; i++) {\n if (this.tiles[i].getFamily() === family &&\n this.tiles[i].getValue() === value) {\n n++;\n }\n }\n return n;\n };\n Deck.prototype.shuffle = function () {\n var _a;\n var newArray = [];\n while (this.tiles.length > 0) {\n var n = Math.floor(Math.random() * this.tiles.length);\n _a = [this.tiles[0], this.tiles[n]], this.tiles[n] = _a[0], this.tiles[0] = _a[1];\n newArray.push(this.tiles.shift());\n }\n this.tiles = newArray;\n };\n Deck.prototype.getRandomHand = function () {\n var hand = new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand();\n this.shuffle();\n for (var i = 0; i < 13; i++) {\n hand.push(this.pop());\n }\n return hand;\n };\n Deck.prototype.cleanup = function () {\n this.tiles.forEach(function (tile) { return tile.cleanup(); });\n this.tiles = [];\n };\n Deck.prototype.preload = function () {\n return __awaiter(this, void 0, void 0, function () {\n var i;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < this.tiles.length)) return [3 /*break*/, 4];\n return [4 /*yield*/, this.tiles[i].preloadImg()];\n case 2:\n _a.sent();\n _a.label = 3;\n case 3:\n i++;\n return [3 /*break*/, 1];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n Deck.prototype.initTiles = function (allowRed) {\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n if (j === 5 && allowRed) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, true));\n }\n else {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 4) { // vent\n for (var j = 1; j < 5; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 5) { // dragon\n for (var j = 1; j < 4; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n }\n };\n return Deck;\n}());\n\n\n\n//# sourceURL=webpack:///./src/deck.ts?"); + +/***/ }), + +/***/ "./src/display/dp3.ts": +/*!****************************!*\ + !*** ./src/display/dp3.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 */ cleanup: () => (/* binding */ cleanup),\n/* harmony export */ initDisplay: () => (/* binding */ initDisplay)\n/* harmony export */ });\n/* harmony import */ var _deck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../deck */ \"./src/deck.ts\");\n/* harmony import */ var _hand__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../hand */ \"./src/hand.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\n// Configuration globale\nvar CANVAS_ID = \"myCanvas\";\nvar BG_COLOR = \"#007730\";\nvar BG_RECT = { x: 50, y: 50, w: 1000, h: 1000 };\nvar FPS = 30;\nvar FRAME_INTERVAL = 1000 / FPS;\n// variables globales\nvar DECKS = [];\nvar HANDS = [];\nvar selectedTile = undefined;\n// Optimisation des références\nvar animationFrameId;\nvar lastFrameTime = 0;\nvar callbacks = [];\n// Pré-calcul des dimensions\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\n// Cache statique\nvar staticCanvas = document.createElement('canvas');\nvar staticCtx = staticCanvas.getContext(\"2d\");\nstaticCanvas.width = canvas.width;\nstaticCanvas.height = canvas.height;\n// Pré-rendu du fond\nfunction prerenderBackground() {\n staticCtx.clearRect(0, 0, canvas.width, canvas.height);\n staticCtx.fillStyle = BG_COLOR;\n staticCtx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);\n}\n;\nfunction drawFrame() {\n if (!ctx)\n return;\n // Effacement intelligent (uniquement la zone nécessaire)\n prerenderBackground();\n // Ici viendrait le dessin des éléments dynamiques\n // Par exemple:\n // drawDeck();\n // drawHands();\n var x = 300;\n var y = 150;\n var xos = 250;\n var yos = 100;\n var size = 0.75;\n staticCtx.fillStyle = \"#DFDFFF\";\n staticCtx.font = \"50px serif\";\n staticCtx.fillText(\"Chii:\", 75, y + 100 * size - 5);\n HANDS[0].drawHand(staticCtx, x, y, 5, 0.75); // chii\n HANDS[1].drawHand(staticCtx, x + (75 + xos) * size, y, 5, 0.75);\n staticCtx.fillText(\"Pon:\", 75, y + (100 + yos) * size + 100 * size - 5);\n HANDS[2].drawHand(staticCtx, x, y + (100 + yos) * size, 5, 0.75); // pon\n HANDS[3].drawHand(staticCtx, x + (75 + xos) * size, y + (100 + yos) * size, 5, 0.75);\n HANDS[4].drawHand(staticCtx, x + 2 * (75 + xos) * size, y + 2 * (100 + yos) * size, 5, 0.75);\n staticCtx.fillText(\"Invalide:\", 75, y + 2 * (100 + yos) * size + 100 * size - 5);\n HANDS[5].drawHand(staticCtx, x, y + 2 * (100 + yos) * size, 5, 0.75); // wrong\n HANDS[6].drawHand(staticCtx, x + (75 + xos) * size, y + 2 * (100 + yos) * size, 5, 0.75);\n HANDS[7].drawHand(staticCtx, x + 2 * (75 + xos) * size, y + 2 * (100 + yos) * size, 5, 0.75);\n HANDS[8].isolate = true;\n HANDS[8].drawHand(staticCtx, 100, 800, 5, size, selectedTile);\n var groups = HANDS[8].toGroup();\n if (groups !== undefined) {\n staticCtx.fillStyle = \"#FF0000\";\n staticCtx.font = \"50px serif\";\n staticCtx.fillText(\"Tous les groupes sont formés !\", 100, 750);\n }\n groups = [];\n // Dessin du cache statique\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.drawImage(staticCanvas, 0, 0);\n}\nfunction animationLoop(currentTime) {\n animationFrameId = requestAnimationFrame(animationLoop);\n var deltaTime = currentTime - lastFrameTime;\n if (deltaTime < FRAME_INTERVAL)\n return;\n lastFrameTime = currentTime - (deltaTime % FRAME_INTERVAL);\n drawFrame();\n}\nfunction initEventListeners() {\n var handlers = {\n mousemove: function (e) {\n var size = 0.75;\n var x = 100;\n // Logique de gestion du mouvement de la souris\n var rect = canvas.getBoundingClientRect();\n var mouseX = e.clientX - rect.left - x;\n var mouseY = e.clientY - rect.top;\n var q = Math.floor(mouseX / (80 * size));\n var r = mouseX - q * 80 * size;\n if (r <= 75 && q >= 0 && q < 14 && mouseY >= 800 && mouseY <= 800 + 100 * size) {\n selectedTile = q;\n }\n else {\n selectedTile = undefined;\n }\n },\n mousedown: function (e) {\n // Logique de gestion du clic de souris\n if (selectedTile !== undefined) {\n DECKS[0].push(HANDS[8].eject(selectedTile));\n DECKS[0].shuffle();\n HANDS[8].sort();\n HANDS[8].push(DECKS[0].pop());\n }\n }\n };\n callbacks.push(function () {\n canvas.removeEventListener('mousemove', handlers.mousemove);\n canvas.removeEventListener('mousedown', handlers.mousedown);\n });\n canvas.addEventListener('mousemove', handlers.mousemove);\n canvas.addEventListener('mousedown', handlers.mousedown);\n}\nfunction preloadDeck(deck) {\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*/, deck.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction preloadHand(hand) {\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*/, hand.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction cleanup() {\n cancelAnimationFrame(animationFrameId);\n callbacks.forEach(function (fn) { return fn(); });\n}\nfunction initDisplay() {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!ctx) {\n console.error(\"Context canvas indisponible\");\n return [2 /*return*/];\n }\n // Préchargement des ressources si nécessaire\n // const deck = new Deck();\n // await preloadDeck(deck);\n DECKS.push(new _deck__WEBPACK_IMPORTED_MODULE_0__.Deck(false));\n HANDS.push(new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"s1s2s3\"), new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"m2m3m4\"), new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"p5p5p5\"), new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"w2w2w2\"), new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"d3d3d3\"), new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"s4p5m6\"), new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"m9s9p9\"), new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand(\"d1d2d3\"), DECKS[0].getRandomHand());\n return [4 /*yield*/, Promise.all(DECKS.map(function (d) { return preloadDeck(d); }))];\n case 1:\n _a.sent();\n return [4 /*yield*/, Promise.all(HANDS.map(function (h) { return preloadHand(h); }))];\n case 2:\n _a.sent();\n HANDS[8].push(DECKS[0].pop());\n HANDS[8].sort();\n initEventListeners();\n requestAnimationFrame(animationLoop);\n window.cleanup = cleanup;\n return [2 /*return*/];\n }\n });\n });\n}\n// Initialisation automatique si le script est chargé directement\nif (typeof window !== 'undefined') {\n initDisplay().catch(console.error);\n}\n\n\n//# sourceURL=webpack:///./src/display/dp3.ts?"); + +/***/ }), + +/***/ "./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; 2 * i + 1 < stiles.length; i++) {\n var ss = stiles.substring(2 * i, 2 * (i + 1));\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 }\n else {\n return [];\n }\n return undefined;\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/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 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?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // 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/display/dp3.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/dp4.js b/build/dp4.js new file mode 100644 index 0000000..42400ec --- /dev/null +++ b/build/dp4.js @@ -0,0 +1,156 @@ +/* + * 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/button.ts": +/*!***********************!*\ + !*** ./src/button.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 */ clickAction: () => (/* binding */ clickAction),\n/* harmony export */ clickChii: () => (/* binding */ clickChii),\n/* harmony export */ drawButtons: () => (/* binding */ drawButtons),\n/* harmony export */ drawChiis: () => (/* binding */ drawChiis)\n/* harmony export */ });\nfunction clickAction(x, y, chii, pon, kan, ron, tsumo) {\n var buttons = [\n [tsumo, 5],\n [ron, 4],\n [kan, 3],\n [pon, 2],\n [chii, 1]\n ];\n if (buttons.some(function (c) { return c[0]; })) {\n buttons.push([true, 0]);\n }\n else {\n return -1;\n }\n var xmin = 960 - buttons.filter(function (c) { return c[0]; }).length * 120;\n var inside = 838 < y && y < 888;\n var q = Math.floor((x - xmin) / 120);\n var r = (x - xmin) - 120 * q;\n if (q >= 0 &&\n q < buttons.filter(function (c) { return c[0]; }).length &&\n r > 10 &&\n inside) {\n return buttons.filter(function (c) { return c[0]; })[q][1];\n }\n return -1;\n}\nfunction drawButtons(ctx, chii, pon, kan, ron, tsumo) {\n var buttons = [\n [chii, buttonChii],\n [pon, buttonPon],\n [kan, buttonKan],\n [ron, buttonRon],\n [tsumo, buttonTsumo]\n ];\n if (buttons.some(function (c) { return c[0]; })) {\n buttons.unshift([true, buttonPass]);\n }\n var dx = 0;\n for (var i = 0; i < buttons.length; i++) {\n if (buttons[i][0]) {\n buttons[i][1](ctx, 850 - dx * 120, 835);\n dx++;\n }\n }\n}\nfunction clickChii(x, y, chiis) {\n var xmin = 960 - (chiis.length + 1) * 120;\n var inside = 838 < y && y < 888;\n var q = Math.floor((x - xmin) / 120);\n var r = (x - xmin) - 120 * q;\n if (q >= 0 &&\n q < (chiis.length + 1) &&\n r > 10 &&\n inside) {\n return q === chiis.length ? 0 : chiis[q][0].getValue();\n }\n return -1;\n}\nfunction drawChiis(ctx, chiis) {\n chiis.reverse();\n var r = 8;\n var w = 110;\n var h = 50;\n button(ctx, 850, 835, r, w, h, \"#FF9030\");\n ctx.fillStyle = \"black\";\n ctx.font = \"30px garamond\";\n ctx.fillText(\"Retour\", 850 + w * 0.1, 835 + h / 2 * 1.3);\n var dx = 1;\n for (var i = 0; i < chiis.length; i++) {\n drawOneChii(ctx, 850 - dx * 120, 835, chiis[i]);\n dx++;\n }\n}\nfunction drawOneChii(ctx, x, y, tiles) {\n var r = 8;\n var w = 110;\n var h = 50;\n var dx = 32;\n var x0 = x + 7;\n var y0 = y + 5;\n button(ctx, x, y, r, w, h, \"#FFCC33\");\n tiles[0].drawTile(ctx, x0, y0, 0.4, false, 0, false, false);\n tiles[1].drawTile(ctx, x0 + dx, y0, 0.4, false, 0, false, false);\n tiles[2].drawTile(ctx, x0 + 2 * dx, y0, 0.4, false, 0, false, false);\n}\nfunction button(ctx, x, y, r, w, h, color) {\n ctx.fillStyle = color;\n ctx.beginPath();\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.quadraticCurveTo(x + w, y, x + w, y + r);\n ctx.lineTo(x + w, y + h - r);\n ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);\n ctx.lineTo(x + r, y + h);\n ctx.quadraticCurveTo(x, y + h, x, y + h - r);\n ctx.lineTo(x, y + r);\n ctx.quadraticCurveTo(x, y, x + r, y);\n ctx.fill();\n ctx.fillStyle = \"#606060\";\n ctx.stroke();\n}\nfunction buttonPass(ctx, x, y) {\n var r = 8;\n var w = 110;\n var h = 50;\n // button(ctx, x, y, r, w, h, \"#FFAC4D\");\n button(ctx, x, y, r, w, h, \"#FF9030\");\n ctx.fillStyle = \"black\";\n ctx.font = \"30px garamond\";\n ctx.fillText(\"Ignorer\", x + w * 0.1, y + h / 2 * 1.3);\n}\nfunction buttonPon(ctx, x, y) {\n var r = 8;\n var w = 110;\n var h = 50;\n button(ctx, x, y, r, w, h, \"#FFCC33\");\n ctx.fillStyle = \"black\";\n ctx.font = \"30px garamond\";\n ctx.fillText(\"Pon\", x + w * 0.28, y + h / 2 * 1.3);\n}\nfunction buttonChii(ctx, x, y) {\n var r = 8;\n var w = 110;\n var h = 50;\n button(ctx, x, y, r, w, h, \"#FFCC33\");\n ctx.fillStyle = \"black\";\n ctx.font = \"30px garamond\";\n ctx.fillText(\"Chii\", x + w * 0.25, y + h / 2 * 1.3);\n}\nfunction buttonKan(ctx, x, y) {\n var r = 8;\n var w = 110;\n var h = 50;\n button(ctx, x, y, r, w, h, \"#FFCC33\");\n ctx.fillStyle = \"black\";\n ctx.font = \"30px garamond\";\n ctx.fillText(\"Kan\", x + w * 0.28, y + h / 2 * 1.3);\n}\nfunction buttonRon(ctx, x, y) {\n var r = 8;\n var w = 110;\n var h = 50;\n button(ctx, x, y, r, w, h, \"#FF3060\");\n ctx.fillStyle = \"black\";\n ctx.font = \"30px garamond\";\n ctx.fillText(\"Ron\", x + w * 0.28, y + h / 2 * 1.3);\n}\nfunction buttonTsumo(ctx, x, y) {\n var r = 8;\n var w = 110;\n var h = 50;\n button(ctx, x, y, r, w, h, \"#FF3060\");\n ctx.fillStyle = \"black\";\n ctx.font = \"30px garamond\";\n ctx.fillText(\"Tsumo\", x + w * 0.13, y + h / 2 * 1.3);\n}\n\n\n//# sourceURL=webpack:///./src/button.ts?"); + +/***/ }), + +/***/ "./src/deck.ts": +/*!*********************!*\ + !*** ./src/deck.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 */ Deck: () => (/* binding */ Deck)\n/* harmony export */ });\n/* harmony import */ var _tile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tile */ \"./src/tile.ts\");\n/* harmony import */ var _hand__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hand */ \"./src/hand.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 Deck = /** @class */ (function () {\n function Deck(allowRed) {\n this.tiles = [];\n this.initTiles(allowRed);\n }\n Deck.prototype.displayFamilies = function (ctx, x, y, size, xOffset, yOffset) {\n if (xOffset === void 0) { xOffset = 0; }\n if (yOffset === void 0) { yOffset = 0; }\n var posX = x;\n var posY = y;\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size, false, 0, false);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 4) { //vent\n for (var j = 1; j < 5; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n posX = x;\n posY += (100 + yOffset) * size;\n }\n else if (i === 5) { //vent\n for (var j = 1; j < 4; j++) {\n var tile = this.find(i, j);\n tile.drawTile(ctx, posX, posY, size);\n posX += (75 + xOffset) * size;\n }\n }\n }\n };\n Deck.prototype.length = function () {\n return this.tiles.length;\n };\n Deck.prototype.pop = function () {\n if (this.tiles.length === 0) {\n }\n return this.tiles.pop();\n };\n Deck.prototype.push = function (tile) {\n this.tiles.push(tile);\n };\n Deck.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 &&\n this.tiles[i].getValue() === value) {\n n = i;\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 return this.tiles.shift();\n }\n else {\n return undefined;\n }\n };\n Deck.prototype.count = function (family, value) {\n var n = 0;\n for (var i = 0; i < this.tiles.length; i++) {\n if (this.tiles[i].getFamily() === family &&\n this.tiles[i].getValue() === value) {\n n++;\n }\n }\n return n;\n };\n Deck.prototype.shuffle = function () {\n var _a;\n var newArray = [];\n while (this.tiles.length > 0) {\n var n = Math.floor(Math.random() * this.tiles.length);\n _a = [this.tiles[0], this.tiles[n]], this.tiles[n] = _a[0], this.tiles[0] = _a[1];\n newArray.push(this.tiles.shift());\n }\n this.tiles = newArray;\n };\n Deck.prototype.getRandomHand = function () {\n var hand = new _hand__WEBPACK_IMPORTED_MODULE_1__.Hand();\n this.shuffle();\n for (var i = 0; i < 13; i++) {\n hand.push(this.pop());\n }\n return hand;\n };\n Deck.prototype.cleanup = function () {\n this.tiles.forEach(function (tile) { return tile.cleanup(); });\n this.tiles = [];\n };\n Deck.prototype.preload = function () {\n return __awaiter(this, void 0, void 0, function () {\n var i;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < this.tiles.length)) return [3 /*break*/, 4];\n return [4 /*yield*/, this.tiles[i].preloadImg()];\n case 2:\n _a.sent();\n _a.label = 3;\n case 3:\n i++;\n return [3 /*break*/, 1];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n Deck.prototype.initTiles = function (allowRed) {\n for (var i = 1; i < 6; i++) {\n if (i < 4) { // famille\n for (var j = 1; j < 10; j++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n if (j === 5 && allowRed) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, true));\n }\n else {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 4) { // vent\n for (var j = 1; j < 5; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n else if (i === 5) { // dragon\n for (var j = 1; j < 4; j++) {\n for (var k = 0; k < 4; k++) {\n this.tiles.push(new _tile__WEBPACK_IMPORTED_MODULE_0__.Tile(i, j, false));\n }\n }\n }\n }\n };\n return Deck;\n}());\n\n\n\n//# sourceURL=webpack:///./src/deck.ts?"); + +/***/ }), + +/***/ "./src/display/dp4.ts": +/*!****************************!*\ + !*** ./src/display/dp4.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 */ cleanup: () => (/* binding */ cleanup),\n/* harmony export */ initDisplay: () => (/* binding */ initDisplay)\n/* harmony export */ });\n/* harmony import */ var _game__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../game */ \"./src/game.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// Configuration globale\nvar CANVAS_ID = \"myCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 1050, h: 1050 };\nvar MOUSE = { x: 0, y: 0 };\nvar FPS = 30;\nvar FRAME_INTERVAL = 1000 / FPS;\n// variables globales\nvar DECKS = [];\nvar HANDS = [];\nvar GAME;\n// Optimisation des références\nvar animationFrameId;\nvar lastFrameTime = 0;\nvar callbacks = [];\n// Pré-calcul des dimensions\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\n// Cache statique\nvar staticCanvas = document.createElement('canvas');\nvar staticCtx = staticCanvas.getContext(\"2d\");\nstaticCanvas.width = canvas.width;\nstaticCanvas.height = canvas.height;\nfunction drawFrame() {\n if (!ctx)\n return;\n GAME === null || GAME === void 0 ? void 0 : GAME.draw(MOUSE);\n}\nfunction animationLoop(currentTime) {\n animationFrameId = requestAnimationFrame(animationLoop);\n var deltaTime = currentTime - lastFrameTime;\n if (deltaTime < FRAME_INTERVAL)\n return;\n lastFrameTime = currentTime - (deltaTime % FRAME_INTERVAL);\n drawFrame();\n}\nfunction initEventListeners() {\n var handlers = {\n mousedown: function (e) {\n GAME === null || GAME === void 0 ? void 0 : GAME.click(e);\n },\n mousemove: function (e) {\n MOUSE.x = e.x;\n MOUSE.y = e.y;\n }\n };\n callbacks.push(function () {\n canvas.removeEventListener('mousemove', handlers.mousemove);\n canvas.removeEventListener('mousedown', handlers.mousedown);\n });\n canvas.addEventListener('mousemove', handlers.mousemove);\n canvas.addEventListener('mousedown', handlers.mousedown);\n}\nfunction preloadDeck(deck) {\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*/, deck.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction preloadHand(hand) {\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*/, hand.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction cleanup() {\n cancelAnimationFrame(animationFrameId);\n callbacks.forEach(function (fn) { return fn(); });\n}\nfunction initDisplay() {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!ctx) {\n console.error(\"Context canvas indisponible\");\n return [2 /*return*/];\n }\n console.log(\"Load begining\\n\");\n // Préchargement des ressources si nécessaire\n // const deck = new Deck();\n // await preloadDeck(deck);\n DECKS.push();\n HANDS.push();\n GAME = new _game__WEBPACK_IMPORTED_MODULE_0__.Game(ctx, canvas, staticCtx, staticCanvas);\n return [4 /*yield*/, Promise.all(DECKS.map(function (d) { return preloadDeck(d); }))];\n case 1:\n _a.sent();\n return [4 /*yield*/, Promise.all(HANDS.map(function (h) { return preloadHand(h); }))];\n case 2:\n _a.sent();\n return [4 /*yield*/, (GAME === null || GAME === void 0 ? void 0 : GAME.preload())];\n case 3:\n _a.sent();\n console.log(\"Loaded completed\\n\");\n initEventListeners();\n requestAnimationFrame(animationLoop);\n window.cleanup = cleanup;\n return [2 /*return*/];\n }\n });\n });\n}\n// Initialisation automatique si le script est chargé directement\nif (typeof window !== 'undefined') {\n initDisplay().catch(console.error);\n}\n\n\n//# sourceURL=webpack:///./src/display/dp4.ts?"); + +/***/ }), + +/***/ "./src/game.ts": +/*!*********************!*\ + !*** ./src/game.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 */ Game: () => (/* binding */ Game)\n/* harmony export */ });\n/* harmony import */ var _deck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./deck */ \"./src/deck.ts\");\n/* harmony import */ var _group__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./group */ \"./src/group.ts\");\n/* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./button */ \"./src/button.ts\");\n/* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./state */ \"./src/state.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\n\n\nvar Game = /** @class */ (function () {\n function Game(ctx, cv, staticCtx, staticCv, red, level) {\n if (red === void 0) { red = false; }\n if (level === void 0) { level = 0; }\n this.deadWall = [];\n this.hands = [];\n this.turn = 0;\n this.minWaitingTime = 500;\n this.maxWaitingTime = 2000;\n this.waitingTime = 700;\n this.selectedTile = undefined;\n this.canCall = false;\n this.hasPicked = false;\n this.hasPlayed = false;\n this.lastPlayed = Date.now();\n this.chooseChii = false;\n this.end = false;\n this.result = -1;\n // display parameter\n this.BG_RECT = { color: \"#007730\", x: 0, y: 0, w: 1050, h: 1050 };\n this.sizeHand = 0.7;\n this.sizeHiddenHand = 0.6;\n this.sizeDiscard = 0.6;\n this.ctx = ctx;\n this.cv = cv;\n this.staticCtx = staticCtx;\n this.staticCv = staticCv;\n this.level = level;\n this.deck = new _deck__WEBPACK_IMPORTED_MODULE_0__.Deck(red);\n this.deck.shuffle();\n for (var i = 0; i < 14; i++) {\n this.deadWall.push(this.deck.pop());\n }\n for (var i = 0; i < 4; i++) {\n this.hands.push(this.deck.getRandomHand());\n }\n this.discards = [[], [], [], []];\n this.lastDiscard = undefined;\n this.groups = [[], [], [], []];\n this.hands[0].sort();\n this.pick(0);\n }\n Game.prototype.draw = function (mp) {\n // background\n this.staticCtx.clearRect(0, 0, this.cv.width, this.cv.height);\n this.staticCtx.fillStyle = this.BG_RECT.color;\n this.staticCtx.fillRect(this.BG_RECT.x, this.BG_RECT.y, this.BG_RECT.w, this.BG_RECT.h);\n this.getSelected(mp);\n this.drawGame();\n this.ctx.clearRect(0, 0, this.cv.width, this.cv.height);\n this.ctx.drawImage(this.staticCv, 0, 0);\n };\n Game.prototype.getDeck = function () {\n return this.deck;\n };\n Game.prototype.getHands = function () {\n return this.hands;\n };\n Game.prototype.isFinished = function () {\n return this.end;\n };\n Game.prototype.click = function (// player is playing\n mp) {\n var rect = this.cv.getBoundingClientRect();\n if (this.hasWin(0)) {\n this.end = true;\n this.result = 1;\n }\n else if (this.chooseChii) { // is choosing\n var allChii = this.getChii(0);\n var c = (0,_button__WEBPACK_IMPORTED_MODULE_2__.clickChii)(mp.x - rect.x, mp.y - rect.y, allChii);\n if (c === 0) {\n this.chooseChii = false;\n }\n else {\n this.chooseChii = false;\n this.chii(c, 0);\n }\n }\n else {\n var action = (0,_button__WEBPACK_IMPORTED_MODULE_2__.clickAction)(mp.x - rect.left, mp.y - rect.top, this.canDoAChii().length > 0, this.canDoAPon(), false && 0, false && 0, false && 0);\n if (this.canCall && action !== -1) { // can call\n if (action === 0) { // pass\n this.canCall = false;\n if (this.turn === 3) {\n this.turn = 0;\n this.pick(0);\n }\n else {\n this.turn++;\n }\n this.updateWaitingTime();\n this.hasPicked = false;\n this.hasPlayed = false;\n }\n else if (action === 1) { // chii\n var chiis = this.canDoAChii();\n if (chiis.length === 1) { // only one possible\n this.chii(chiis[0], 0);\n }\n else {\n this.chooseChii = true;\n this.drawGame();\n }\n }\n else if (action == 2) { // pon\n this.pon(this.turn);\n }\n }\n else { // nothing unusual\n if (this.turn === 0 && this.selectedTile !== undefined) {\n this.discard(0, this.selectedTile);\n if (!this.checkPon()) {\n var chiis = this.canDoAChii(1);\n if (chiis.length > 0) {\n var i = Math.floor(Math.random() * chiis.length);\n this.chii(chiis[i], 1);\n }\n else {\n this.updateWaitingTime();\n this.turn = (this.turn + 1) % 4;\n }\n }\n }\n }\n }\n };\n Game.prototype.getSelected = function (mp) {\n var rect = this.cv.getBoundingClientRect();\n var x = 2.5 * 75 * 0.75;\n var y = 1050 - 250 * 0.6;\n var mouseX = mp.x - rect.left - x;\n var mouseY = mp.y - rect.top;\n var s = 83.9;\n var q = Math.floor(mouseX / (s * this.sizeHand));\n var r = mouseX - q * s * this.sizeHand;\n if (r <= (s - 3) * this.sizeHand &&\n q >= 0 &&\n q < this.hands[0].length() &&\n mouseY >= y &&\n mouseY <= y + 100 * this.sizeHand) {\n this.selectedTile = q;\n }\n else {\n this.selectedTile = undefined;\n }\n };\n ;\n Game.prototype.updateWaitingTime = function () {\n this.waitingTime =\n Math.floor(Math.random() *\n (this.maxWaitingTime - this.minWaitingTime) +\n this.minWaitingTime);\n };\n Game.prototype.play = function () {\n if (this.turn !== 0 && !this.end) { // bot playing\n if (!this.hasPicked) { // begin of his turn\n this.lastPlayed = Date.now();\n this.pick(this.turn);\n this.hasPicked = true;\n }\n else if (!this.hasPlayed) { // middle of his turn\n if (this.hasWin(this.turn)) {\n this.end = true;\n this.result = 2;\n }\n else if (Date.now() - this.lastPlayed > this.waitingTime) {\n this.lastPlayed = Date.now();\n var n = Math.floor(this.hands[this.turn].length() * Math.random());\n this.discard(this.turn, n);\n this.hasPlayed = true;\n if (this.deck.length() <= 0) {\n this.result = 0;\n this.end = true;\n }\n if (!this.end) {\n this.checkPon();\n if (this.turn !== 3 && this.canDoAChii(this.turn + 1).length > 0) {\n var chiis = this.canDoAChii(this.turn + 1);\n var i = Math.floor(Math.random() * chiis.length);\n this.chii(chiis[i], this.turn + 1);\n }\n this.canCall = this.canDoAChii().length > 0 || this.canDoAPon();\n }\n }\n }\n else if (!this.canCall) { // end of his turn\n if (this.turn === 3) {\n this.turn = 0;\n this.pick(0);\n if (this.hasWin(0)) {\n this.end = true;\n this.result = 1;\n }\n }\n else {\n this.turn++;\n }\n this.updateWaitingTime();\n this.hasPicked = false;\n this.hasPlayed = false;\n }\n }\n };\n Game.prototype.pick = function (player) {\n this.hands[player].push(this.deck.pop());\n this.hands[player].isolate = true;\n };\n Game.prototype.discard = function (player, n) {\n var tile = this.hands[player].eject(n);\n this.hands[player].sort();\n tile.setTilt();\n this.discards[player].push(tile);\n this.hands[player].isolate = false;\n this.hands[player].sort();\n this.lastDiscard = player;\n this.lastPlayed = Date.now();\n };\n Game.prototype.canDoAChii = function (p) {\n if (p === void 0) { p = 0; }\n var chii = [];\n if (this.lastDiscard !== undefined &&\n (this.lastDiscard + 1) % 4 === p &&\n (this.turn + 1) % 4 === p &&\n this.discards[this.lastDiscard][this.discards[this.lastDiscard].length - 1].getFamily() < 4) {\n var t = this.discards[this.lastDiscard][this.discards[this.lastDiscard].length - 1];\n var h = this.hands[p];\n if (h.count(t.getFamily(), t.getValue() - 2) > 0 &&\n h.count(t.getFamily(), t.getValue() - 1) > 0) {\n chii.push(t.getValue() - 2);\n }\n if (h.count(t.getFamily(), t.getValue() - 1) > 0 &&\n h.count(t.getFamily(), t.getValue() + 1) > 0) {\n chii.push(t.getValue() - 1);\n }\n if (h.count(t.getFamily(), t.getValue() + 1) > 0 &&\n h.count(t.getFamily(), t.getValue() + 2) > 0) {\n chii.push(t.getValue());\n }\n }\n return chii;\n };\n Game.prototype.chii = function (minValue, p) {\n var t = this.discards[p === 0 ? 3 : p - 1].pop();\n this.lastDiscard = undefined;\n var tn = 0;\n var v = minValue;\n var tt = [];\n while (tn < 2) {\n if (v === t.getValue()) {\n v++;\n }\n else {\n tt[tn] = this.hands[p].find(t.getFamily(), v);\n tn++;\n v++;\n }\n }\n [t, tt[0], tt[1]].forEach(function (t) { return t.setTilt(); });\n this.groups[p].push(new _group__WEBPACK_IMPORTED_MODULE_1__.Group([t, tt[0], tt[1]], p === 0 ? 3 : p - 1, p));\n if (this.hasWin(p)) {\n this.end = true;\n this.result = p === 0 ? 1 : 2;\n }\n this.updateWaitingTime();\n this.turn = p;\n this.hasPicked = true;\n this.hasPlayed = false;\n };\n Game.prototype.getChii = function (p) {\n var chiis = [];\n var numChii = this.canDoAChii();\n var d = this.discards[p === 0 ? 3 : p - 1];\n var t = d[d.length - 1];\n for (var i = 0; i < numChii.length; i++) {\n var v = numChii[i];\n var chii = [];\n for (var dv = 0; dv < 3; dv++) {\n if (v + dv === t.getValue()) {\n chii.push(t);\n }\n else {\n var tt = this.hands[p].find(t.getFamily(), v + dv);\n chii.push(tt);\n this.hands[p].push(tt);\n this.hands[p].sort();\n }\n }\n chiis.push(chii);\n }\n return chiis;\n };\n Game.prototype.checkPon = function () {\n for (var p = 1; p < 4; p++) {\n if (this.canDoAPon(p)) {\n this.pon(this.lastDiscard, p);\n return true;\n }\n }\n return false;\n };\n Game.prototype.canDoAPon = function (player) {\n if (player === void 0) { player = 0; }\n if (this.lastDiscard !== undefined && // il y a une défausse\n this.lastDiscard !== player && // pas sa propre défausse\n this.turn !== player && // pas son propre tour\n !(this.hasPicked && !this.hasPlayed) // pas un joueur en train de jouer\n ) {\n var t = this.discards[this.lastDiscard][this.discards[this.lastDiscard].length - 1];\n return this.hands[player].count(t.getFamily(), t.getValue()) >= 2;\n }\n else {\n return false;\n }\n };\n Game.prototype.pon = function (p, thief) {\n if (thief === void 0) { thief = 0; }\n var t = this.discards[p].pop();\n this.lastDiscard = undefined;\n var t2 = this.hands[thief].find(t.getFamily(), t.getValue());\n var t3 = this.hands[thief].find(t.getFamily(), t.getValue());\n [t, t2, t3].forEach(function (t) { return t.setTilt(); });\n this.groups[thief].push(new _group__WEBPACK_IMPORTED_MODULE_1__.Group([t, t2, t3], p, thief));\n if (this.hasWin(thief)) {\n this.end = true;\n this.result = thief === 0 ? 1 : 2;\n }\n this.updateWaitingTime();\n this.turn = thief;\n this.hasPicked = true;\n this.hasPlayed = false;\n };\n Game.prototype.hasWin = function (p) {\n return this.hands[p].toGroup() !== undefined;\n };\n Game.prototype.drawGame = function () {\n // update game\n this.play();\n // draw winds, discard, riichi etc...\n (0,_state__WEBPACK_IMPORTED_MODULE_3__.drawState)(this.staticCtx, this.turn);\n this.drawDiscardSize();\n // draw result\n this.drawResult();\n // hands\n this.drawHands();\n // groups\n this.drawGroups(0.6);\n // discards\n for (var i = 0; i < 4; i++) {\n this.drawDiscard(i, this.hands[0].get(this.selectedTile));\n }\n // called\n if (this.chooseChii) {\n (0,_button__WEBPACK_IMPORTED_MODULE_2__.drawChiis)(this.staticCtx, this.getChii(0));\n }\n else {\n (0,_button__WEBPACK_IMPORTED_MODULE_2__.drawButtons)(this.staticCtx, this.canDoAChii().length > 0, this.canDoAPon(), false && 0, false && 0, false && 0);\n }\n };\n Game.prototype.drawHands = function () {\n var pi = 3.141592;\n var showHands = false;\n this.hands[0].drawHand(this.staticCtx, 2.5 * 75 * 0.75, 1000 - 150 * this.sizeHand, 5 * this.sizeHand, 0.75, this.selectedTile, false, 0);\n this.hands[1].drawHand(this.staticCtx, 1000 - 150 * this.sizeHiddenHand, 1000 - 75 * 5 * this.sizeHiddenHand, 5 * this.sizeHiddenHand, this.sizeHiddenHand, undefined, !showHands, -pi / 2);\n this.hands[2].drawHand(this.staticCtx, 1000 - 75 * 5 * this.sizeHiddenHand, 150 * this.sizeHiddenHand, 5 * this.sizeHiddenHand, this.sizeHiddenHand, undefined, !showHands, -pi);\n this.hands[3].drawHand(this.staticCtx, 150 * this.sizeHiddenHand, 75 * 5 * this.sizeHiddenHand, 5 * this.sizeHiddenHand, this.sizeHiddenHand, undefined, !showHands, pi / 2);\n };\n Game.prototype.drawGroups = function (size) {\n var os = 25;\n var pi = 3.141592;\n for (var p = 0; p < 4; p++) {\n var rotation = [0, -pi / 2, -pi, pi / 2][p];\n if (this.groups[p].length > 0) {\n for (var i = this.groups[p].length - 1; i >= 0; i--) {\n this.groups[p][i].drawGroup(this.staticCtx, 1050 - 240 - (260 + os) * size * i, 1050 - 62, 5, 0.6, rotation, this.hands[0].get(this.selectedTile));\n }\n }\n }\n };\n Game.prototype.drawDiscard = function (p, highlitedTile) {\n var pi = 3.141592;\n this.staticCtx.save();\n this.staticCtx.translate(525, 525);\n this.staticCtx.rotate([0, -pi / 2, -pi, pi / 2][p]);\n var x = -this.sizeDiscard * 475 / 2;\n var y = this.sizeDiscard * (475 / 2 + 5);\n for (var i = 0; i < this.discards[p].length; i++) {\n var tile = this.discards[p][i];\n if (i < 12) {\n tile.drawTile(this.staticCtx, x + (i % 6) * 80 * this.sizeDiscard, y + Math.floor(i / 6) * 105 * this.sizeDiscard, this.sizeDiscard, false, 0, highlitedTile === null || highlitedTile === void 0 ? void 0 : highlitedTile.isEqual(tile.getFamily(), tile.getValue()));\n }\n else {\n tile.drawTile(this.staticCtx, x + (i - 12) * 80 * this.sizeDiscard, y + 2 * 105 * this.sizeDiscard, this.sizeDiscard, false, 0, highlitedTile === null || highlitedTile === void 0 ? void 0 : highlitedTile.isEqual(tile.getFamily(), tile.getValue()));\n }\n }\n if (this.lastDiscard === p) {\n var j = this.discards[p].length - 1;\n var tx = j < 12 ?\n x + (j % 6) * 80 * this.sizeDiscard :\n x + (j - 12) * 80 * this.sizeDiscard;\n var ty = j < 12 ?\n y + Math.floor(j / 6) * 105 * this.sizeDiscard :\n y + 2 * 105 * this.sizeDiscard;\n tx += 75 / 2 * this.sizeDiscard;\n ty += 115 * this.sizeDiscard;\n var ts = 10;\n this.staticCtx.fillStyle = \"#ff0000\";\n this.staticCtx.beginPath();\n this.staticCtx.moveTo(tx, ty);\n this.staticCtx.lineTo(tx + ts / 2, ty + 0.866 * ts);\n this.staticCtx.lineTo(tx - ts / 2, ty + 0.866 * ts);\n this.staticCtx.lineTo(tx, ty);\n this.staticCtx.fill();\n this.staticCtx.stroke();\n }\n this.staticCtx.restore();\n };\n Game.prototype.drawDiscardSize = function () {\n this.staticCtx.fillStyle = \"#f070f0\";\n this.staticCtx.font = \"40px garamond\";\n var l = this.deck.length();\n if (l < 10) {\n this.staticCtx.fillText(l.toString(), 517, 537);\n }\n else {\n this.staticCtx.fillText(l.toString(), 507, 537);\n }\n };\n Game.prototype.drawResult = function () {\n if (this.result !== -1) {\n this.staticCtx.fillStyle = \"#e0e0f0\";\n this.staticCtx.fillRect(450, 430, 150, 190);\n this.staticCtx.fillRect(430, 450, 190, 150);\n this.staticCtx.fillStyle = \"#ff0000\";\n this.staticCtx.font = \"45px garamond\";\n }\n if (this.result === 0) { // Égalité\n this.staticCtx.fillText(\"Égalité\", 450, 535);\n }\n else if (this.result === 1) { // victoire\n this.staticCtx.fillText(\"Victoire !\", 440, 535);\n }\n else if (this.result === 2) { // Défaite\n this.staticCtx.fillText(\"Défaite...\", 440, 535);\n }\n };\n Game.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*/, this.deck.preload()];\n case 1:\n _a.sent();\n return [4 /*yield*/, Promise.all(this.hands.map(function (h) { return h.preload(); }))];\n case 2:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n return Game;\n}());\n\n\n\n//# sourceURL=webpack:///./src/game.ts?"); + +/***/ }), + +/***/ "./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; 2 * i + 1 < stiles.length; i++) {\n var ss = stiles.substring(2 * i, 2 * (i + 1));\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 }\n else {\n return [];\n }\n return undefined;\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/state.ts": +/*!**********************!*\ + !*** ./src/state.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 */ drawState: () => (/* binding */ drawState)\n/* harmony export */ });\nfunction drawState(ctx, turn, rotation) {\n if (turn === void 0) { turn = 0; }\n if (rotation === void 0) { rotation = 0; }\n var color = \"#e0e0f0\";\n var r = 30;\n var s = 100;\n var c = 525;\n var pi = Math.PI;\n // turn\n var w = 150;\n var h = 4;\n var rd = 2;\n var y = 525 + s + 5;\n ctx.save();\n ctx.translate(525, 525);\n ctx.rotate([0, -pi / 2, pi, pi / 2][turn]);\n ctx.translate(-525, -525);\n ctx.fillStyle = \"#ffcc33\";\n ctx.beginPath();\n ctx.moveTo(c, y);\n ctx.lineTo(c - w / 2 + rd, y);\n ctx.quadraticCurveTo(c - w / 2, y, c - w / 2, y + rd);\n ctx.lineTo(c - w / 2, y + h - rd);\n ctx.quadraticCurveTo(c - w / 2, y + h, c - w / 2 + rd, y + h);\n ctx.lineTo(c + w / 2 - rd, y + h);\n ctx.quadraticCurveTo(c + w / 2, y + h, c + w / 2, y + h - rd);\n ctx.lineTo(c + w / 2, y + rd);\n ctx.quadraticCurveTo(c + w / 2, y, c + w / 2 - rd, y);\n ctx.lineTo(c, y);\n ctx.fill();\n ctx.stroke();\n ctx.restore();\n // big rectangle\n ctx.save();\n ctx.translate(525, 525);\n ctx.rotate(rotation);\n ctx.translate(-525, -525);\n ctx.fillStyle = color;\n ctx.beginPath();\n ctx.moveTo(c - s, c);\n ctx.lineTo(c - s, c + s - r);\n ctx.quadraticCurveTo(c - s, c + s, c - s + r, c + s);\n ctx.lineTo(c + s - r, c + s);\n ctx.quadraticCurveTo(c + s, c + s, c + s, c + s - r);\n ctx.lineTo(c + s, c - s + r);\n ctx.quadraticCurveTo(c + s, c - s, c + s - r, c - s);\n ctx.lineTo(c - s + r, c - s);\n ctx.quadraticCurveTo(c - s, c - s, c - s, c - s + r);\n ctx.lineTo(c - s, c);\n ctx.fill();\n ctx.stroke();\n // winds\n ctx.fillStyle = \"#000000\";\n ctx.font = \"40px garamond\";\n ctx.fillText(\"Est\", 505, 515 + s);\n ctx.save();\n ctx.translate(525, 525);\n ctx.rotate(-3.141592 / 2);\n ctx.translate(-525, -525);\n ctx.fillText(\"Sud\", 500, 515 + s);\n ctx.restore();\n ctx.save();\n ctx.translate(525, 525);\n ctx.rotate(3.141592);\n ctx.translate(-525, -525);\n ctx.fillText(\"Ouest\", 480, 515 + s);\n ctx.restore();\n ctx.save();\n ctx.translate(525, 525);\n ctx.rotate(3.141592 / 2);\n ctx.translate(-525, -525);\n ctx.fillText(\"Nord\", 485, 515 + s);\n ctx.restore();\n ctx.restore();\n}\n\n\n//# sourceURL=webpack:///./src/state.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 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?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // 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/display/dp4.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/dp5.js b/build/dp5.js new file mode 100644 index 0000000..8f5051e --- /dev/null +++ b/build/dp5.js @@ -0,0 +1,66 @@ +/* + * 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/display/dp5.ts": +/*!****************************!*\ + !*** ./src/display/dp5.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 */ cleanup: () => (/* binding */ cleanup),\n/* harmony export */ initDisplay: () => (/* binding */ initDisplay)\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};\n// Configuration globale\nvar CANVAS_ID = \"myCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 1050, h: 1050 };\nvar MOUSE = { x: 0, y: 0 };\nvar FPS = 30;\nvar FRAME_INTERVAL = 1000 / FPS;\n// variables globales\nvar DECKS = [];\nvar HANDS = [];\nvar GAME;\n// Optimisation des références\nvar animationFrameId;\nvar lastFrameTime = 0;\nvar callbacks = [];\n// Pré-calcul des dimensions\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\n// Cache statique\nvar staticCanvas = document.createElement('canvas');\nvar staticCtx = staticCanvas.getContext(\"2d\");\nstaticCanvas.width = canvas.width;\nstaticCanvas.height = canvas.height;\nfunction drawFrame() {\n if (!ctx)\n return;\n GAME === null || GAME === void 0 ? void 0 : GAME.draw(MOUSE);\n}\nfunction animationLoop(currentTime) {\n animationFrameId = requestAnimationFrame(animationLoop);\n var deltaTime = currentTime - lastFrameTime;\n if (deltaTime < FRAME_INTERVAL)\n return;\n lastFrameTime = currentTime - (deltaTime % FRAME_INTERVAL);\n drawFrame();\n}\nfunction initEventListeners() {\n var handlers = {\n mousedown: function (e) {\n GAME === null || GAME === void 0 ? void 0 : GAME.click(e);\n },\n mousemove: function (e) {\n MOUSE.x = e.x;\n MOUSE.y = e.y;\n }\n };\n callbacks.push(function () {\n canvas.removeEventListener('mousemove', handlers.mousemove);\n });\n canvas.addEventListener('mousedown', handlers.mousedown);\n}\nfunction preloadDeck(deck) {\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*/, deck.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction preloadHand(hand) {\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*/, hand.preload()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n}\nfunction cleanup() {\n cancelAnimationFrame(animationFrameId);\n callbacks.forEach(function (fn) { return fn(); });\n}\nfunction initDisplay() {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n if (!ctx) {\n console.error(\"Context canvas indisponible\");\n return [2 /*return*/];\n }\n console.log(\"Load begining\\n\");\n return [2 /*return*/];\n });\n });\n}\n// Initialisation automatique si le script est chargé directement\nif (typeof window !== 'undefined') {\n initDisplay().catch(console.error);\n}\n\n\n//# sourceURL=webpack:///./src/display/dp5.ts?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The require scope +/******/ var __webpack_require__ = {}; +/******/ +/************************************************************************/ +/******/ /* 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_modules__["./src/display/dp5.ts"](0, __webpack_exports__, __webpack_require__); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/test_yakus.js b/build/test_yakus.js new file mode 100644 index 0000000..e389533 --- /dev/null +++ b/build/test_yakus.js @@ -0,0 +1,136 @@ +/* + * 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; 2 * i + 1 < stiles.length; i++) {\n var ss = stiles.substring(2 * i, 2 * (i + 1));\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 }\n else {\n return [];\n }\n return undefined;\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 p1p2p3 p5p5\");\nvar h2 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m1m1 m4m4m4 m7m7m7 p1p1p1 p5p5\");\nvar h3 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m1m1p9p9p9s1s1s1w2w2w2d1d1\");\nvar h4 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m2m3m4 p3p3p3 p4p5p6 s4s4 s6s7s8\");\nvar h5 = new _hand__WEBPACK_IMPORTED_MODULE_2__.Hand(\"m1m2m3m1m2m3p7p8p9p7p8p9w3w3\");\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 m9m9m9 p9p9\");\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 m999 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// chanta\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.chanta(h3, [], 0) === 2, \"m111 p999 s111 w222 d11 is Chanta\");\ncount += (0,_assert__WEBPACK_IMPORTED_MODULE_0__.assert)(_yakus_yaku__WEBPACK_IMPORTED_MODULE_1__.yakus.chanta(h1, [], 0) === 0, \"m123 m456 m789 m123 p55 is not Chanta\");\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 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 (// TODO\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 return 1;\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.sort(function (g1, g2) { return g1.compare(g2); });\n gr.filter(function (g) { return chii(g); });\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 return 0; //TODO\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 // TODO multiplicité !\n hand, groups, wind) {\n return 0;\n },\n shousangen: function (//TODO\n /**\n * trois petits dragons\n * 2/2\n */\n hand, groups, wind) {\n return 0;\n },\n daisangen: function (//TODO\n /**\n * trois grands dragons\n * 13/13\n */\n hand, groups, wind) {\n return 0;\n },\n shousuushii: function (//TODO\n /**\n * quatre petits vents\n * 13/13\n */\n hand, groups, wind) {\n return 0;\n },\n daisuushi: function (//TODO\n /**\n * quatre grands vents\n * 13/13\n */\n hand, groups, wind) {\n return 0;\n },\n chanta: function (//TODO\n /**\n * terminales et honneurs partout\n * 1/2\n */\n hand, groups, wind) {\n return 0;\n },\n junchan: function (//TODO\n /**\n * terminales partout\n * 2/3\n */\n hand, groups, wind) {\n return 0;\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"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/txt0.js b/build/txt0.js new file mode 100644 index 0000000..9c56147 --- /dev/null +++ b/build/txt0.js @@ -0,0 +1,96 @@ +/* + * 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/text/parse.ts": +/*!***************************!*\ + !*** ./src/text/parse.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 */ drawText: () => (/* binding */ drawText)\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};\nfunction drawText(filePath, ctx) {\n return __awaiter(this, void 0, void 0, function () {\n var fileContent, size, dl, ll, xx, defaultColor, readingColor, color, gras, italic, line, x, _i, fileContent_1, c;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(filePath, \"\\n\");\n return [4 /*yield*/, fetch(filePath)\n .then(function (response) { return response.text(); })];\n case 1:\n fileContent = _a.sent();\n size = 30;\n dl = 5;\n ll = 50;\n xx = 10;\n defaultColor = \"#ffffff\";\n ctx.fillStyle = defaultColor;\n ctx.font = size + \"px Garamond\";\n readingColor = false;\n color = \"\";\n gras = \"\";\n italic = \"\";\n line = 1;\n x = 0;\n for (_i = 0, fileContent_1 = fileContent; _i < fileContent_1.length; _i++) {\n c = fileContent_1[_i];\n if (c === '*') {\n if (gras === \"\") {\n gras = \"bold \";\n }\n else {\n gras = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '~') {\n if (italic === \"\") {\n italic = \"italic \";\n }\n else {\n italic = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '#') {\n color = \"#\";\n readingColor = true;\n }\n else if (c === '{') {\n readingColor = false;\n ctx.fillStyle = color;\n }\n else if (c === '}') {\n color = \"\";\n ctx.fillStyle = defaultColor;\n }\n else if (readingColor) {\n color += c;\n }\n else if (c === '\\n') {\n line++;\n x = 0;\n }\n else {\n ctx.fillText(c, xx + x, ll + line * (size + dl));\n x += ctx.measureText(c).width;\n }\n }\n return [2 /*return*/];\n }\n });\n });\n}\n\n\n//# sourceURL=webpack:///./src/text/parse.ts?"); + +/***/ }), + +/***/ "./src/text/txt0.ts": +/*!**************************!*\ + !*** ./src/text/txt0.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _parse__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse */ \"./src/text/parse.ts\");\n\nvar CANVAS_ID = \"myTextCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: \"#007733\" };\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\nvar path = \"../src/text/\";\nctx.fillStyle = BG_RECT.color;\nctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);\n(0,_parse__WEBPACK_IMPORTED_MODULE_0__.drawText)(path + \"txt0.txt\", ctx).catch(function (error) { return console.error(error); });\n\n\n//# sourceURL=webpack:///./src/text/txt0.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/text/txt0.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/txt1.js b/build/txt1.js new file mode 100644 index 0000000..cb4cbae --- /dev/null +++ b/build/txt1.js @@ -0,0 +1,96 @@ +/* + * 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/text/parse.ts": +/*!***************************!*\ + !*** ./src/text/parse.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 */ drawText: () => (/* binding */ drawText)\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};\nfunction drawText(filePath, ctx) {\n return __awaiter(this, void 0, void 0, function () {\n var fileContent, size, dl, ll, xx, defaultColor, readingColor, color, gras, italic, line, x, _i, fileContent_1, c;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(filePath, \"\\n\");\n return [4 /*yield*/, fetch(filePath)\n .then(function (response) { return response.text(); })];\n case 1:\n fileContent = _a.sent();\n size = 30;\n dl = 5;\n ll = 50;\n xx = 10;\n defaultColor = \"#ffffff\";\n ctx.fillStyle = defaultColor;\n ctx.font = size + \"px Garamond\";\n readingColor = false;\n color = \"\";\n gras = \"\";\n italic = \"\";\n line = 1;\n x = 0;\n for (_i = 0, fileContent_1 = fileContent; _i < fileContent_1.length; _i++) {\n c = fileContent_1[_i];\n if (c === '*') {\n if (gras === \"\") {\n gras = \"bold \";\n }\n else {\n gras = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '~') {\n if (italic === \"\") {\n italic = \"italic \";\n }\n else {\n italic = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '#') {\n color = \"#\";\n readingColor = true;\n }\n else if (c === '{') {\n readingColor = false;\n ctx.fillStyle = color;\n }\n else if (c === '}') {\n color = \"\";\n ctx.fillStyle = defaultColor;\n }\n else if (readingColor) {\n color += c;\n }\n else if (c === '\\n') {\n line++;\n x = 0;\n }\n else {\n ctx.fillText(c, xx + x, ll + line * (size + dl));\n x += ctx.measureText(c).width;\n }\n }\n return [2 /*return*/];\n }\n });\n });\n}\n\n\n//# sourceURL=webpack:///./src/text/parse.ts?"); + +/***/ }), + +/***/ "./src/text/txt1.ts": +/*!**************************!*\ + !*** ./src/text/txt1.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _parse__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse */ \"./src/text/parse.ts\");\n\nvar CANVAS_ID = \"myTextCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: \"#007733\" };\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\nvar path = \"../src/text/\";\nctx.fillStyle = BG_RECT.color;\nctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);\n(0,_parse__WEBPACK_IMPORTED_MODULE_0__.drawText)(path + \"txt1.txt\", ctx).catch(function (error) { return console.error(error); });\n\n\n//# sourceURL=webpack:///./src/text/txt1.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/text/txt1.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/txt2.js b/build/txt2.js new file mode 100644 index 0000000..bdd66ff --- /dev/null +++ b/build/txt2.js @@ -0,0 +1,96 @@ +/* + * 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/text/parse.ts": +/*!***************************!*\ + !*** ./src/text/parse.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 */ drawText: () => (/* binding */ drawText)\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};\nfunction drawText(filePath, ctx) {\n return __awaiter(this, void 0, void 0, function () {\n var fileContent, size, dl, ll, xx, defaultColor, readingColor, color, gras, italic, line, x, _i, fileContent_1, c;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(filePath, \"\\n\");\n return [4 /*yield*/, fetch(filePath)\n .then(function (response) { return response.text(); })];\n case 1:\n fileContent = _a.sent();\n size = 30;\n dl = 5;\n ll = 50;\n xx = 10;\n defaultColor = \"#ffffff\";\n ctx.fillStyle = defaultColor;\n ctx.font = size + \"px Garamond\";\n readingColor = false;\n color = \"\";\n gras = \"\";\n italic = \"\";\n line = 1;\n x = 0;\n for (_i = 0, fileContent_1 = fileContent; _i < fileContent_1.length; _i++) {\n c = fileContent_1[_i];\n if (c === '*') {\n if (gras === \"\") {\n gras = \"bold \";\n }\n else {\n gras = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '~') {\n if (italic === \"\") {\n italic = \"italic \";\n }\n else {\n italic = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '#') {\n color = \"#\";\n readingColor = true;\n }\n else if (c === '{') {\n readingColor = false;\n ctx.fillStyle = color;\n }\n else if (c === '}') {\n color = \"\";\n ctx.fillStyle = defaultColor;\n }\n else if (readingColor) {\n color += c;\n }\n else if (c === '\\n') {\n line++;\n x = 0;\n }\n else {\n ctx.fillText(c, xx + x, ll + line * (size + dl));\n x += ctx.measureText(c).width;\n }\n }\n return [2 /*return*/];\n }\n });\n });\n}\n\n\n//# sourceURL=webpack:///./src/text/parse.ts?"); + +/***/ }), + +/***/ "./src/text/txt2.ts": +/*!**************************!*\ + !*** ./src/text/txt2.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _parse__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse */ \"./src/text/parse.ts\");\n\nvar CANVAS_ID = \"myTextCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: \"#007733\" };\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\nvar path = \"../src/text/\";\nctx.fillStyle = BG_RECT.color;\nctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);\n(0,_parse__WEBPACK_IMPORTED_MODULE_0__.drawText)(path + \"txt2.txt\", ctx).catch(function (error) { return console.error(error); });\n\n\n//# sourceURL=webpack:///./src/text/txt2.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/text/txt2.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/txt3.js b/build/txt3.js new file mode 100644 index 0000000..19726af --- /dev/null +++ b/build/txt3.js @@ -0,0 +1,96 @@ +/* + * 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/text/parse.ts": +/*!***************************!*\ + !*** ./src/text/parse.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 */ drawText: () => (/* binding */ drawText)\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};\nfunction drawText(filePath, ctx) {\n return __awaiter(this, void 0, void 0, function () {\n var fileContent, size, dl, ll, xx, defaultColor, readingColor, color, gras, italic, line, x, _i, fileContent_1, c;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(filePath, \"\\n\");\n return [4 /*yield*/, fetch(filePath)\n .then(function (response) { return response.text(); })];\n case 1:\n fileContent = _a.sent();\n size = 30;\n dl = 5;\n ll = 50;\n xx = 10;\n defaultColor = \"#ffffff\";\n ctx.fillStyle = defaultColor;\n ctx.font = size + \"px Garamond\";\n readingColor = false;\n color = \"\";\n gras = \"\";\n italic = \"\";\n line = 1;\n x = 0;\n for (_i = 0, fileContent_1 = fileContent; _i < fileContent_1.length; _i++) {\n c = fileContent_1[_i];\n if (c === '*') {\n if (gras === \"\") {\n gras = \"bold \";\n }\n else {\n gras = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '~') {\n if (italic === \"\") {\n italic = \"italic \";\n }\n else {\n italic = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '#') {\n color = \"#\";\n readingColor = true;\n }\n else if (c === '{') {\n readingColor = false;\n ctx.fillStyle = color;\n }\n else if (c === '}') {\n color = \"\";\n ctx.fillStyle = defaultColor;\n }\n else if (readingColor) {\n color += c;\n }\n else if (c === '\\n') {\n line++;\n x = 0;\n }\n else {\n ctx.fillText(c, xx + x, ll + line * (size + dl));\n x += ctx.measureText(c).width;\n }\n }\n return [2 /*return*/];\n }\n });\n });\n}\n\n\n//# sourceURL=webpack:///./src/text/parse.ts?"); + +/***/ }), + +/***/ "./src/text/txt3.ts": +/*!**************************!*\ + !*** ./src/text/txt3.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _parse__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse */ \"./src/text/parse.ts\");\n\nvar CANVAS_ID = \"myTextCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: \"#007733\" };\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\nvar path = \"../src/text/\";\nctx.fillStyle = BG_RECT.color;\nctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);\n(0,_parse__WEBPACK_IMPORTED_MODULE_0__.drawText)(path + \"txt3.txt\", ctx).catch(function (error) { return console.error(error); });\n\n\n//# sourceURL=webpack:///./src/text/txt3.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/text/txt3.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/txt4.js b/build/txt4.js new file mode 100644 index 0000000..04c07b0 --- /dev/null +++ b/build/txt4.js @@ -0,0 +1,96 @@ +/* + * 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/text/parse.ts": +/*!***************************!*\ + !*** ./src/text/parse.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 */ drawText: () => (/* binding */ drawText)\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};\nfunction drawText(filePath, ctx) {\n return __awaiter(this, void 0, void 0, function () {\n var fileContent, size, dl, ll, xx, defaultColor, readingColor, color, gras, italic, line, x, _i, fileContent_1, c;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(filePath, \"\\n\");\n return [4 /*yield*/, fetch(filePath)\n .then(function (response) { return response.text(); })];\n case 1:\n fileContent = _a.sent();\n size = 30;\n dl = 5;\n ll = 50;\n xx = 10;\n defaultColor = \"#ffffff\";\n ctx.fillStyle = defaultColor;\n ctx.font = size + \"px Garamond\";\n readingColor = false;\n color = \"\";\n gras = \"\";\n italic = \"\";\n line = 1;\n x = 0;\n for (_i = 0, fileContent_1 = fileContent; _i < fileContent_1.length; _i++) {\n c = fileContent_1[_i];\n if (c === '*') {\n if (gras === \"\") {\n gras = \"bold \";\n }\n else {\n gras = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '~') {\n if (italic === \"\") {\n italic = \"italic \";\n }\n else {\n italic = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '#') {\n color = \"#\";\n readingColor = true;\n }\n else if (c === '{') {\n readingColor = false;\n ctx.fillStyle = color;\n }\n else if (c === '}') {\n color = \"\";\n ctx.fillStyle = defaultColor;\n }\n else if (readingColor) {\n color += c;\n }\n else if (c === '\\n') {\n line++;\n x = 0;\n }\n else {\n ctx.fillText(c, xx + x, ll + line * (size + dl));\n x += ctx.measureText(c).width;\n }\n }\n return [2 /*return*/];\n }\n });\n });\n}\n\n\n//# sourceURL=webpack:///./src/text/parse.ts?"); + +/***/ }), + +/***/ "./src/text/txt4.ts": +/*!**************************!*\ + !*** ./src/text/txt4.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _parse__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse */ \"./src/text/parse.ts\");\n\nvar CANVAS_ID = \"myTextCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: \"#007733\" };\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\nvar path = \"../src/text/\";\nctx.fillStyle = BG_RECT.color;\nctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);\n(0,_parse__WEBPACK_IMPORTED_MODULE_0__.drawText)(path + \"txt4.txt\", ctx).catch(function (error) { return console.error(error); });\n\n\n//# sourceURL=webpack:///./src/text/txt4.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/text/txt4.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/build/txt5.js b/build/txt5.js new file mode 100644 index 0000000..9850937 --- /dev/null +++ b/build/txt5.js @@ -0,0 +1,96 @@ +/* + * 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/text/parse.ts": +/*!***************************!*\ + !*** ./src/text/parse.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 */ drawText: () => (/* binding */ drawText)\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};\nfunction drawText(filePath, ctx) {\n return __awaiter(this, void 0, void 0, function () {\n var fileContent, size, dl, ll, xx, defaultColor, readingColor, color, gras, italic, line, x, _i, fileContent_1, c;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(filePath, \"\\n\");\n return [4 /*yield*/, fetch(filePath)\n .then(function (response) { return response.text(); })];\n case 1:\n fileContent = _a.sent();\n size = 30;\n dl = 5;\n ll = 50;\n xx = 10;\n defaultColor = \"#ffffff\";\n ctx.fillStyle = defaultColor;\n ctx.font = size + \"px Garamond\";\n readingColor = false;\n color = \"\";\n gras = \"\";\n italic = \"\";\n line = 1;\n x = 0;\n for (_i = 0, fileContent_1 = fileContent; _i < fileContent_1.length; _i++) {\n c = fileContent_1[_i];\n if (c === '*') {\n if (gras === \"\") {\n gras = \"bold \";\n }\n else {\n gras = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '~') {\n if (italic === \"\") {\n italic = \"italic \";\n }\n else {\n italic = \"\";\n }\n ctx.font = italic + gras + size + \"px Garamond\";\n }\n else if (c === '#') {\n color = \"#\";\n readingColor = true;\n }\n else if (c === '{') {\n readingColor = false;\n ctx.fillStyle = color;\n }\n else if (c === '}') {\n color = \"\";\n ctx.fillStyle = defaultColor;\n }\n else if (readingColor) {\n color += c;\n }\n else if (c === '\\n') {\n line++;\n x = 0;\n }\n else {\n ctx.fillText(c, xx + x, ll + line * (size + dl));\n x += ctx.measureText(c).width;\n }\n }\n return [2 /*return*/];\n }\n });\n });\n}\n\n\n//# sourceURL=webpack:///./src/text/parse.ts?"); + +/***/ }), + +/***/ "./src/text/txt5.ts": +/*!**************************!*\ + !*** ./src/text/txt5.ts ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _parse__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parse */ \"./src/text/parse.ts\");\n\nvar CANVAS_ID = \"myTextCanvas\";\nvar BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: \"#007733\" };\nvar canvas = document.getElementById(CANVAS_ID);\nvar ctx = canvas.getContext(\"2d\");\ncanvas.width = BG_RECT.w;\ncanvas.height = BG_RECT.h;\nvar path = \"../src/text/\";\nctx.fillStyle = BG_RECT.color;\nctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);\n(0,_parse__WEBPACK_IMPORTED_MODULE_0__.drawText)(path + \"txt5.txt\", ctx).catch(function (error) { return console.error(error); });\n\n\n//# sourceURL=webpack:///./src/text/txt5.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/text/txt5.ts"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/src/yakus/yaku.ts b/src/yakus/yaku.ts index ed06927..ef0134a 100644 --- a/src/yakus/yaku.ts +++ b/src/yakus/yaku.ts @@ -135,7 +135,34 @@ sanshokuDoujun: function( // TODO groups: Array, wind: number ): number { - return 0; + let h = hand.toGroup(); + let gr; + if (h !== undefined) { + gr = groups.concat(h); + } else { + gr = groups; + } + gr = gr.filter(g => chii(g)); + gr.sort((g1, g2) => g1.compare(g2)) + if (gr.length < 3) { // pas assez de chii + return 0; + } else if(gr.length === 3) { + let t0 = gr[0].getTiles(); + let t1 = gr[1].getTiles(); + let t2 = gr[2].getTiles(); + if ( + t0[0].getValue() === t1[0].getValue() && + t0[0].getValue() === t2[0].getValue() && + t0[0].getFamily() !== t1[0].getFamily() && + t0[0].getFamily() !== t2[0].getFamily() && + t1[0].getFamily() !== t2[0].getFamily() + ) { + return groups.length > 0 ? 1 : 2; + } + return 0; + } else {// il y a un intrus + return 1 + } }, ittsuu: function(