diff --git a/index.0e0517f7.js b/index.0e0517f7.js new file mode 100644 index 000000000..d4e6b9eaf --- /dev/null +++ b/index.0e0517f7.js @@ -0,0 +1,2 @@ +!function(){var t,e,r={};function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,a=Array(e);r0&&void 0!==arguments[0]?arguments[0]:[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,e),this.state=t.map(function(t){return s(t)}),this.status=e.Status.idle,this.initialState=t,this.score=0}return t=[{key:"filterZero",value:function(t){return t.filter(function(t){return 0!==t})}},{key:"slide",value:function(t){for(var e=this.filterZero(t),r=0;r0){var a,s=function(t){if(Array.isArray(t))return t}(a=t[Math.floor(Math.random()*t.length)])||function(t,e){var r,a,n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var s=[],i=!0,o=!1;try{for(n=n.call(t);!(i=(r=n.next()).done)&&(s.push(r.value),2!==s.length);i=!0);}catch(t){o=!0,a=t}finally{try{i||null==n.return||n.return()}finally{if(o)throw a}}return s}}(a,2)||n(a,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=s[0],o=s[1];this.state[i][o]=.9>Math.random()?2:4}}},{key:"checkGameStatus",value:function(){for(var t=!1,r=!1,a=0;a<4;a++)for(var n=0;n<4;n++){if(2048===this.state[a][n]){this.status=e.Status.win;return}0===this.state[a][n]&&(r=!0),(a<3&&this.state[a][n]===this.state[a+1][n]||n<3&&this.state[a][n]===this.state[a][n+1])&&(t=!0)}t||r||(this.status=e.Status.lose)}}],function(t,e){for(var r=0;r","src/scripts/main.js","src/modules/Game.class.js","node_modules/@swc/helpers/esm/_class_call_check.js","node_modules/@swc/helpers/esm/_create_class.js","node_modules/@swc/helpers/esm/_define_property.js","node_modules/@swc/helpers/esm/_sliced_to_array.js","node_modules/@swc/helpers/esm/_array_with_holes.js","node_modules/@swc/helpers/esm/_iterable_to_array_limit.js","node_modules/@swc/helpers/esm/_non_iterable_rest.js","node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js","node_modules/@swc/helpers/esm/_array_like_to_array.js","node_modules/@swc/helpers/esm/_to_consumable_array.js","node_modules/@swc/helpers/esm/_array_without_holes.js","node_modules/@swc/helpers/esm/_iterable_to_array.js","node_modules/@swc/helpers/esm/_non_iterable_spread.js"],"sourcesContent":["(function () {\n\"use strict\";\nvar $3d28d7f1aac198f5$exports = {};\nfunction $8713978b2328d32b$export$2996f80ef42b8419(instance, Constructor) {\n if (!(instance instanceof Constructor)) throw new TypeError(\"Cannot call a class as a function\");\n}\n\n\nfunction $4fc75ccb937ab1df$var$_defineProperties(target, props) {\n for(var i = 0; i < props.length; i++){\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nfunction $4fc75ccb937ab1df$export$d60067ff2358eee8(Constructor, protoProps, staticProps) {\n if (protoProps) $4fc75ccb937ab1df$var$_defineProperties(Constructor.prototype, protoProps);\n if (staticProps) $4fc75ccb937ab1df$var$_defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\n\nfunction $cd5a47cf8ef6d766$export$1e71eb4bef00f6b0(obj, key, value) {\n if (key in obj) Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n else obj[key] = value;\n return obj;\n}\n\n\nfunction $09cbfe85151ea6c6$export$e6256bf45c68d561(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\n\nfunction $8ca2848f896a6803$export$2fd15edff6687200(arr, i) {\n var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"];\n if (_i == null) return;\n var _arr = [];\n var _n = true;\n var _d = false;\n var _s, _e;\n try {\n for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){\n _arr.push(_s.value);\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally{\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally{\n if (_d) throw _e;\n }\n }\n return _arr;\n}\n\n\nfunction $a0bc1859061deae1$export$60dbc22abd7da546() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\n\nfunction $c3b10a83b523f372$export$79e617b1955a2616(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];\n return arr2;\n}\n\n\nfunction $d4f69c5c6c4654b1$export$a5be06335b3a083c(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return (0, $c3b10a83b523f372$export$79e617b1955a2616)(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return (0, $c3b10a83b523f372$export$79e617b1955a2616)(o, minLen);\n}\n\n\nfunction $efec029548ccee7f$export$fdf2a89c76341bbf(arr, i) {\n return (0, $09cbfe85151ea6c6$export$e6256bf45c68d561)(arr) || (0, $8ca2848f896a6803$export$2fd15edff6687200)(arr, i) || (0, $d4f69c5c6c4654b1$export$a5be06335b3a083c)(arr, i) || (0, $a0bc1859061deae1$export$60dbc22abd7da546)();\n}\n\n\n\nfunction $c50969dc1df61e8b$export$7e0947b5ad3404e2(arr) {\n if (Array.isArray(arr)) return (0, $c3b10a83b523f372$export$79e617b1955a2616)(arr);\n}\n\n\nfunction $09c9f293d010c0e1$export$1eb58a6e75231000(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n}\n\n\nfunction $38c2d4931cb7a7c4$export$e6f3c4780d19eb2b() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\n\n\nfunction $227c6742e0ff6f82$export$1b5e630bc3aea29f(arr) {\n return (0, $c50969dc1df61e8b$export$7e0947b5ad3404e2)(arr) || (0, $09c9f293d010c0e1$export$1eb58a6e75231000)(arr) || (0, $d4f69c5c6c4654b1$export$a5be06335b3a083c)(arr) || (0, $38c2d4931cb7a7c4$export$e6f3c4780d19eb2b)();\n}\n\n\n\"use strict\";\nvar $3d28d7f1aac198f5$var$Game = /*#__PURE__*/ function() {\n function Game() {\n var initialState = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ]\n ];\n (0, $8713978b2328d32b$export$2996f80ef42b8419)(this, Game);\n this.state = initialState.map(function(row) {\n return (0, $227c6742e0ff6f82$export$1b5e630bc3aea29f)(row);\n });\n this.status = Game.Status.idle;\n this.initialState = initialState;\n this.score = 0;\n }\n (0, $4fc75ccb937ab1df$export$d60067ff2358eee8)(Game, [\n {\n key: \"filterZero\",\n value: function filterZero(row) {\n return row.filter(function(num) {\n return num !== 0;\n });\n }\n },\n {\n key: \"slide\",\n value: function slide(row) {\n var updRow = this.filterZero(row);\n for(var i = 0; i < updRow.length - 1; i++)if (updRow[i] === updRow[i + 1]) {\n updRow[i] *= 2;\n updRow[i + 1] = 0;\n this.score += updRow[i];\n }\n updRow = this.filterZero(updRow);\n while(updRow.length < 4)updRow.push(0);\n return updRow;\n }\n },\n {\n key: \"moveLeft\",\n value: function moveLeft() {\n var _this = this;\n if (this.status === Game.Status.playing) {\n var isMovable = false;\n var updatedCells = this.state.map(function(row) {\n return _this.slide(row);\n });\n this.state = updatedCells;\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n },\n {\n key: \"moveRight\",\n value: function moveRight() {\n var _this = this;\n if (this.status === Game.Status.playing) {\n var isMovable = false;\n var reversedSlide = function(row) {\n return _this.slide(row.reverse()).reverse();\n };\n var updatedCells = this.state.map(function(row) {\n return reversedSlide;\n });\n this.state = updatedCells;\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n },\n {\n key: \"transposeArray\",\n value: function transposeArray(array) {\n return array[0].map(function(col, i) {\n return array.map(function(row) {\n return row[i];\n });\n });\n }\n },\n {\n key: \"moveUp\",\n value: function moveUp() {\n var _this = this;\n if (this.status === Game.Status.playing) {\n var isMovable = false;\n var slide = function(row) {\n return _this.slide(row);\n };\n var updatedCells = this.transposeArray(this.state).map(function(row) {\n return slide;\n });\n this.state = this.transposeArray(updatedCells);\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n },\n {\n key: \"moveDown\",\n value: function moveDown() {\n var _this = this;\n if (this.status === Game.Status.playing) {\n var isMovable = false;\n var reversedSlide = function(row) {\n return _this.slide(row.reverse()).reverse();\n };\n var updatedCells = this.transposeArray(this.state).map(function(row) {\n return reversedSlide;\n });\n this.state = this.transposeArray(updatedCells);\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n },\n {\n key: \"getScore\",\n value: function getScore() {\n return this.score;\n }\n },\n {\n key: \"getState\",\n value: function getState() {\n return this.state;\n }\n },\n {\n key: \"getStatus\",\n value: function getStatus() {\n return this.status;\n }\n },\n {\n key: \"start\",\n value: function start() {\n this.status = Game.Status.playing;\n this.getRandomCells();\n this.getRandomCells();\n }\n },\n {\n key: \"restart\",\n value: function restart() {\n this.status = Game.Status.idle;\n this.state = this.initialState.map(function(row) {\n return (0, $227c6742e0ff6f82$export$1b5e630bc3aea29f)(row);\n });\n this.score = 0;\n }\n },\n {\n key: \"getRandomCells\",\n value: function getRandomCells() {\n var emptyCells = [];\n for(var r = 0; r < 4; r++){\n for(var c = 0; c < 4; c++)if (this.state[r][c] === 0) emptyCells.push([\n r,\n c\n ]);\n }\n if (emptyCells.length > 0) {\n var _emptyCells_Math_floor = (0, $efec029548ccee7f$export$fdf2a89c76341bbf)(emptyCells[Math.floor(Math.random() * emptyCells.length)], 2), randomR = _emptyCells_Math_floor[0], randomC = _emptyCells_Math_floor[1];\n this.state[randomR][randomC] = Math.random() < 0.9 ? 2 : 4;\n }\n }\n },\n {\n key: \"checkGameStatus\",\n value: function checkGameStatus() {\n var isMovable = false;\n var hasEmptyCells = false;\n for(var r = 0; r < 4; r++)for(var c = 0; c < 4; c++){\n if (this.state[r][c] === 2048) {\n this.status = Game.Status.win;\n return;\n }\n if (this.state[r][c] === 0) hasEmptyCells = true;\n if (r < 3 && this.state[r][c] === this.state[r + 1][c] || c < 3 && this.state[r][c] === this.state[r][c + 1]) isMovable = true;\n }\n if (!isMovable && !hasEmptyCells) this.status = Game.Status.lose;\n }\n }\n ]);\n return Game;\n}();\n(0, $cd5a47cf8ef6d766$export$1e71eb4bef00f6b0)($3d28d7f1aac198f5$var$Game, \"Status\", {\n idle: \"idle\",\n playing: \"playing\",\n win: \"win\",\n lose: \"lose\"\n});\n$3d28d7f1aac198f5$exports = $3d28d7f1aac198f5$var$Game;\n\n\nvar $197cd56b15c33885$var$game = new $3d28d7f1aac198f5$exports();\nvar $197cd56b15c33885$var$button = document.querySelector(\".start\");\nvar $197cd56b15c33885$var$gameField = document.querySelector(\".game-field\");\nvar $197cd56b15c33885$var$gameScore = document.querySelector(\".game-score\");\nvar $197cd56b15c33885$var$messageStart = document.querySelector(\".message-start\");\nvar $197cd56b15c33885$var$messageLose = document.querySelector(\".message-lose\");\nvar $197cd56b15c33885$var$messageWin = document.querySelector(\".message-win\");\n$197cd56b15c33885$var$button.addEventListener(\"click\", function() {\n if ($197cd56b15c33885$var$button.classList.contains(\"start\")) {\n $197cd56b15c33885$var$game.start();\n $197cd56b15c33885$var$button.classList.remove(\"start\");\n $197cd56b15c33885$var$button.classList.add(\"restart\");\n $197cd56b15c33885$var$button.textContent = \"Restart\";\n $197cd56b15c33885$var$messageStart.classList.add(\"hidden\");\n $197cd56b15c33885$var$messageLose.classList.add(\"hidden\");\n $197cd56b15c33885$var$messageWin.classList.add(\"hidden\");\n } else if ($197cd56b15c33885$var$button.classList.contains(\"restart\")) {\n $197cd56b15c33885$var$game.restart();\n $197cd56b15c33885$var$button.classList.remove(\"restart\");\n $197cd56b15c33885$var$button.classList.add(\"start\");\n $197cd56b15c33885$var$button.textContent = \"Start\";\n $197cd56b15c33885$var$messageStart.classList.add(\"hidden\");\n $197cd56b15c33885$var$messageLose.classList.add(\"hidden\");\n $197cd56b15c33885$var$messageWin.classList.add(\"hidden\");\n }\n $197cd56b15c33885$var$manageGameField();\n $197cd56b15c33885$var$manageGameScore();\n});\ndocument.addEventListener(\"keyup\", function(e) {\n switch(e.key){\n case \"ArrowRight\":\n $197cd56b15c33885$var$game.moveRight();\n break;\n case \"ArrowLeft\":\n $197cd56b15c33885$var$game.moveLeft();\n break;\n case \"ArrowUp\":\n $197cd56b15c33885$var$game.moveUp();\n break;\n case \"ArrowDown\":\n $197cd56b15c33885$var$game.moveDown();\n break;\n }\n $197cd56b15c33885$var$manageGameField();\n $197cd56b15c33885$var$manageGameScore();\n $197cd56b15c33885$var$manageMessages();\n});\nfunction $197cd56b15c33885$var$manageGameField() {\n $197cd56b15c33885$var$gameField.innerHTML = \"\";\n var currState = $197cd56b15c33885$var$game.getState();\n for(var r = 0; r < 4; r++){\n var tr = document.createElement(\"tr\");\n for(var c = 0; c < 4; c++){\n var td = document.createElement(\"td\");\n var value = currState[r][c];\n td.textContent = value !== 0 ? value : \"\";\n td.classList.add(\"field-cell\");\n if (value !== 0) td.classList.add(\"field-cell--\".concat(value));\n tr.appendChild(td);\n }\n $197cd56b15c33885$var$gameField.appendChild(tr);\n }\n}\nfunction $197cd56b15c33885$var$manageGameScore() {\n $197cd56b15c33885$var$gameScore.textContent = $197cd56b15c33885$var$game.getScore();\n}\nfunction $197cd56b15c33885$var$manageMessages() {\n if ($197cd56b15c33885$var$game.getStatus() === $3d28d7f1aac198f5$exports.Status.win) $197cd56b15c33885$var$messageWin.classList.remove(\"hidden\");\n else if ($197cd56b15c33885$var$game.getStatus() === $3d28d7f1aac198f5$exports.Status.lose) $197cd56b15c33885$var$messageLose.classList.remove(\"hidden\");\n}\n$197cd56b15c33885$var$manageGameField();\n$197cd56b15c33885$var$manageGameScore();\n$197cd56b15c33885$var$manageMessages();\n\n})();\n//# sourceMappingURL=index.0e0517f7.js.map\n","'use strict';\n\nconst Game = require('../modules/Game.class');\n\nconst game = new Game();\n\nconst button = document.querySelector('.start');\n\nconst gameField = document.querySelector('.game-field');\nconst gameScore = document.querySelector('.game-score');\n\nconst messageStart = document.querySelector('.message-start');\nconst messageLose = document.querySelector('.message-lose');\nconst messageWin = document.querySelector('.message-win');\n\nbutton.addEventListener('click', () => {\n if (button.classList.contains('start')) {\n game.start();\n\n button.classList.remove('start');\n button.classList.add('restart');\n button.textContent = 'Restart';\n\n messageStart.classList.add('hidden');\n messageLose.classList.add('hidden');\n messageWin.classList.add('hidden');\n } else if (button.classList.contains('restart')) {\n game.restart();\n\n button.classList.remove('restart');\n button.classList.add('start');\n button.textContent = 'Start';\n\n messageStart.classList.add('hidden');\n messageLose.classList.add('hidden');\n messageWin.classList.add('hidden');\n }\n\n manageGameField();\n manageGameScore();\n});\n\ndocument.addEventListener('keyup', (e) => {\n switch (e.key) {\n case 'ArrowRight':\n game.moveRight();\n break;\n case 'ArrowLeft':\n game.moveLeft();\n break;\n case 'ArrowUp':\n game.moveUp();\n break;\n case 'ArrowDown':\n game.moveDown();\n break;\n }\n\n manageGameField();\n manageGameScore();\n manageMessages();\n});\n\nfunction manageGameField() {\n gameField.innerHTML = '';\n\n const currState = game.getState();\n\n for (let r = 0; r < 4; r++) {\n const tr = document.createElement('tr');\n\n for (let c = 0; c < 4; c++) {\n const td = document.createElement('td');\n const value = currState[r][c];\n\n td.textContent = value !== 0 ? value : '';\n td.classList.add('field-cell');\n\n if (value !== 0) {\n td.classList.add(`field-cell--${value}`);\n }\n\n tr.appendChild(td);\n }\n\n gameField.appendChild(tr);\n }\n}\n\nfunction manageGameScore() {\n gameScore.textContent = game.getScore();\n}\n\nfunction manageMessages() {\n if (game.getStatus() === Game.Status.win) {\n messageWin.classList.remove('hidden');\n } else if (game.getStatus() === Game.Status.lose) {\n messageLose.classList.remove('hidden');\n }\n}\n\nmanageGameField();\nmanageGameScore();\nmanageMessages();\n","'use strict';\n\nclass Game {\n static Status = {\n idle: 'idle',\n playing: 'playing',\n win: 'win',\n lose: 'lose',\n };\n\n constructor(\n initialState = [\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n ],\n ) {\n this.state = initialState.map((row) => [...row]);\n this.status = Game.Status.idle;\n this.initialState = initialState;\n this.score = 0;\n }\n\n filterZero(row) {\n return row.filter((num) => num !== 0);\n }\n slide(row) {\n let updRow = this.filterZero(row);\n\n for (let i = 0; i < updRow.length - 1; i++) {\n if (updRow[i] === updRow[i + 1]) {\n updRow[i] *= 2;\n updRow[i + 1] = 0;\n this.score += updRow[i];\n }\n }\n updRow = this.filterZero(updRow);\n\n while (updRow.length < 4) {\n updRow.push(0);\n }\n\n return updRow;\n }\n moveLeft() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n\n const updatedCells = this.state.map((row) => this.slide(row));\n\n this.state = updatedCells;\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n\n moveRight() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n const reversedSlide = (row) => this.slide(row.reverse()).reverse();\n\n const updatedCells = this.state.map((row) => reversedSlide);\n\n this.state = updatedCells;\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n\n transposeArray(array) {\n return array[0].map((col, i) => array.map((row) => row[i]));\n }\n moveUp() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n const slide = (row) => this.slide(row);\n\n const updatedCells = this.transposeArray(this.state).map((row) => slide);\n\n this.state = this.transposeArray(updatedCells);\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n moveDown() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n const reversedSlide = (row) => this.slide(row.reverse()).reverse();\n\n const updatedCells = this.transposeArray(this.state).map(\n (row) => reversedSlide,\n );\n\n this.state = this.transposeArray(updatedCells);\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n\n getScore() {\n return this.score;\n }\n getState() {\n return this.state;\n }\n getStatus() {\n return this.status;\n }\n\n start() {\n this.status = Game.Status.playing;\n this.getRandomCells();\n this.getRandomCells();\n }\n\n restart() {\n this.status = Game.Status.idle;\n this.state = this.initialState.map((row) => [...row]);\n this.score = 0;\n }\n\n getRandomCells() {\n const emptyCells = [];\n\n for (let r = 0; r < 4; r++) {\n for (let c = 0; c < 4; c++) {\n if (this.state[r][c] === 0) {\n emptyCells.push([r, c]);\n }\n }\n }\n\n if (emptyCells.length > 0) {\n const [randomR, randomC] =\n emptyCells[Math.floor(Math.random() * emptyCells.length)];\n\n this.state[randomR][randomC] = Math.random() < 0.9 ? 2 : 4;\n }\n }\n checkGameStatus() {\n let isMovable = false;\n let hasEmptyCells = false;\n\n for (let r = 0; r < 4; r++) {\n for (let c = 0; c < 4; c++) {\n if (this.state[r][c] === 2048) {\n this.status = Game.Status.win;\n\n return;\n }\n\n if (this.state[r][c] === 0) {\n hasEmptyCells = true;\n }\n\n if (\n (r < 3 && this.state[r][c] === this.state[r + 1][c]) ||\n (c < 3 && this.state[r][c] === this.state[r][c + 1])\n ) {\n isMovable = true;\n }\n }\n }\n\n if (!isMovable && !hasEmptyCells) {\n this.status = Game.Status.lose;\n }\n }\n}\n\nmodule.exports = Game;\n","export function _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) throw new TypeError(\"Cannot call a class as a function\");\n}\nexport { _class_call_check as _ };\n","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n\n if (\"value\" in descriptor) descriptor.writable = true;\n\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nexport function _create_class(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n\n return Constructor;\n}\nexport { _create_class as _ };\n","export function _define_property(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });\n } else obj[key] = value;\n\n return obj;\n}\nexport { _define_property as _ };\n","import { _array_with_holes } from \"./_array_with_holes.js\";\nimport { _iterable_to_array_limit } from \"./_iterable_to_array_limit.js\";\nimport { _non_iterable_rest } from \"./_non_iterable_rest.js\";\nimport { _unsupported_iterable_to_array } from \"./_unsupported_iterable_to_array.js\";\n\nexport function _sliced_to_array(arr, i) {\n return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();\n}\nexport { _sliced_to_array as _ };\n","export function _array_with_holes(arr) {\n if (Array.isArray(arr)) return arr;\n}\nexport { _array_with_holes as _ };\n","export function _iterable_to_array_limit(arr, i) {\n var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"];\n\n if (_i == null) return;\n\n var _arr = [];\n var _n = true;\n var _d = false;\n var _s, _e;\n\n try {\n for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\nexport { _iterable_to_array_limit as _ };\n","export function _non_iterable_rest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _non_iterable_rest as _ };\n","import { _array_like_to_array } from \"./_array_like_to_array.js\";\n\nexport function _unsupported_iterable_to_array(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _array_like_to_array(o, minLen);\n\n var n = Object.prototype.toString.call(o).slice(8, -1);\n\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);\n}\nexport { _unsupported_iterable_to_array as _ };\n","export function _array_like_to_array(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\nexport { _array_like_to_array as _ };\n","import { _array_without_holes } from \"./_array_without_holes.js\";\nimport { _iterable_to_array } from \"./_iterable_to_array.js\";\nimport { _non_iterable_spread } from \"./_non_iterable_spread.js\";\nimport { _unsupported_iterable_to_array } from \"./_unsupported_iterable_to_array.js\";\n\nexport function _to_consumable_array(arr) {\n return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();\n}\nexport { _to_consumable_array as _ };\n","import { _array_like_to_array } from \"./_array_like_to_array.js\";\n\nexport function _array_without_holes(arr) {\n if (Array.isArray(arr)) return _array_like_to_array(arr);\n}\nexport { _array_without_holes as _ };\n","export function _iterable_to_array(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) {\n return Array.from(iter);\n }\n}\nexport { _iterable_to_array as _ };\n","export function _non_iterable_spread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _non_iterable_spread as _ };\n"],"names":["key","value","$3d28d7f1aac198f5$exports","$c3b10a83b523f372$export$79e617b1955a2616","arr","len","length","i","arr2","Array","$d4f69c5c6c4654b1$export$a5be06335b3a083c","o","minLen","n","Object","prototype","toString","call","slice","constructor","name","from","test","$227c6742e0ff6f82$export$1b5e630bc3aea29f","isArray","iter","Symbol","iterator","TypeError","$3d28d7f1aac198f5$var$Game","protoProps","Game","initialState","arguments","instance","Constructor","state","map","row","status","Status","idle","score","filter","num","updRow","filterZero","push","_this","playing","updatedCells","slide","getRandomCells","checkGameStatus","reversedSlide","reverse","array","col","transposeArray","emptyCells","r","c","_emptyCells_Math_floor","Math","floor","random","_s","_e","_i","_arr","_n","_d","next","done","err","randomR","randomC","isMovable","hasEmptyCells","win","lose","$4fc75ccb937ab1df$var$_defineProperties","target","props","descriptor","enumerable","configurable","writable","defineProperty","obj","$197cd56b15c33885$var$game","$197cd56b15c33885$var$button","document","querySelector","$197cd56b15c33885$var$gameField","$197cd56b15c33885$var$gameScore","$197cd56b15c33885$var$messageStart","$197cd56b15c33885$var$messageLose","$197cd56b15c33885$var$messageWin","$197cd56b15c33885$var$manageGameField","innerHTML","currState","getState","tr","createElement","td","textContent","classList","add","concat","appendChild","$197cd56b15c33885$var$manageGameScore","getScore","$197cd56b15c33885$var$manageMessages","getStatus","remove","addEventListener","contains","start","restart","e","moveRight","moveLeft","moveUp","moveDown"],"version":3,"file":"index.0e0517f7.js.map"} \ No newline at end of file diff --git a/index.6910ad39.css b/index.6910ad39.css new file mode 100644 index 000000000..3cd0f3b4d --- /dev/null +++ b/index.6910ad39.css @@ -0,0 +1,2 @@ +body{background:#fbf8ef;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;min-height:100vh;margin:0;font-family:sans-serif;font-size:24px;font-weight:900;display:-ms-flexbox;display:flex}.field-cell{color:#776e65;box-sizing:border-box;text-align:center;vertical-align:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;background:#d6cdc4;border-radius:5px;width:75px;height:75px}.field-cell--2{background:#eee4da}.field-cell--4{background:#ede0c8}.field-cell--8{color:#f9f6f2;background:#f2b179}.field-cell--16{color:#f9f6f2;background:#f59563}.field-cell--32{color:#f9f6f2;background:#f67c5f}.field-cell--64{color:#f9f6f2;background:#f65e3b}.field-cell--128{color:#f9f6f2;background:#edcf72}.field-cell--256{color:#f9f6f2;background:#edcc61}.field-cell--512{color:#f9f6f2;background:#edc850}.field-cell--1024{color:#f9f6f2;background:#edc53f}.field-cell--2048{color:#f9f6f2;background:#edc22e}.game-field{border-spacing:10px;background:#bbada0;border-radius:5px}.game-header{box-sizing:border-box;-ms-flex-pack:justify;justify-content:space-between;width:100%;margin-bottom:24px;padding:10px;display:-ms-flexbox;display:flex}h1{color:#f9f6f2;box-sizing:border-box;background:#edc22e;border-radius:5px;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:75px;height:75px;margin:0;font-size:24px;display:-ms-flexbox;display:flex}.info{color:#776e65;box-sizing:border-box;background:#d6cdc4;border-radius:5px;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:75px;height:75px;margin:0 8px 0 0;font-size:16px;display:-ms-flexbox;display:flex}.controls{display:-ms-flexbox;display:flex}.button{cursor:pointer;color:#f9f6f2;border:none;border-radius:5px;width:75px;height:75px;font-family:sans-serif;font-size:16px;font-weight:700;transition:background .25s}.start{background:#1dae28;font-size:20px}.start:hover{background:#179921}.restart{background:#f1b2b2}.restart:hover{background:#f87474}.message{box-sizing:border-box;color:#776e65;text-align:center;background:#d6cdc4;border-radius:5px;width:100%;padding:10px;font-size:20px}.hidden{display:none}.container{-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;width:350px;display:-ms-flexbox;display:flex}.message-win{color:#f9f6f2;background:#edc22e}.message-container{width:100%;height:150px} +/*# sourceMappingURL=index.6910ad39.css.map */ diff --git a/index.6910ad39.css.map b/index.6910ad39.css.map new file mode 100644 index 000000000..a33c78270 --- /dev/null +++ b/index.6910ad39.css.map @@ -0,0 +1 @@ +{"mappings":"ACAA,8NAYA,mNAWE,kCAIA,kCAIA,gDAKA,iDAKA,iDAKA,iDAKA,kDAKA,kDAKA,kDAKA,mDAKA,mDAMF,qEAMA,mKASA,iPAcA,4SAeA,2CAIA,2KAcA,yCAIE,gCAKF,4BAGE,kCAKF,2IAWA,qBAIA,iJAOA,8CAKA","sources":["index.6910ad39.css","src/styles/main.scss"],"sourcesContent":["body {\n background: #fbf8ef;\n justify-content: center;\n align-items: center;\n min-height: 100vh;\n margin: 0;\n font-family: sans-serif;\n font-size: 24px;\n font-weight: 900;\n display: -ms-flexbox;\n display: flex;\n}\n\n.field-cell {\n color: #776e65;\n box-sizing: border-box;\n text-align: center;\n vertical-align: center;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background: #d6cdc4;\n border-radius: 5px;\n width: 75px;\n height: 75px;\n}\n\n.field-cell--2 {\n background: #eee4da;\n}\n\n.field-cell--4 {\n background: #ede0c8;\n}\n\n.field-cell--8 {\n color: #f9f6f2;\n background: #f2b179;\n}\n\n.field-cell--16 {\n color: #f9f6f2;\n background: #f59563;\n}\n\n.field-cell--32 {\n color: #f9f6f2;\n background: #f67c5f;\n}\n\n.field-cell--64 {\n color: #f9f6f2;\n background: #f65e3b;\n}\n\n.field-cell--128 {\n color: #f9f6f2;\n background: #edcf72;\n}\n\n.field-cell--256 {\n color: #f9f6f2;\n background: #edcc61;\n}\n\n.field-cell--512 {\n color: #f9f6f2;\n background: #edc850;\n}\n\n.field-cell--1024 {\n color: #f9f6f2;\n background: #edc53f;\n}\n\n.field-cell--2048 {\n color: #f9f6f2;\n background: #edc22e;\n}\n\n.game-field {\n border-spacing: 10px;\n background: #bbada0;\n border-radius: 5px;\n}\n\n.game-header {\n box-sizing: border-box;\n justify-content: space-between;\n width: 100%;\n margin-bottom: 24px;\n padding: 10px;\n display: -ms-flexbox;\n display: flex;\n}\n\nh1 {\n color: #f9f6f2;\n box-sizing: border-box;\n background: #edc22e;\n border-radius: 5px;\n justify-content: center;\n align-items: center;\n width: 75px;\n height: 75px;\n margin: 0;\n font-size: 24px;\n display: -ms-flexbox;\n display: flex;\n}\n\n.info {\n color: #776e65;\n box-sizing: border-box;\n background: #d6cdc4;\n border-radius: 5px;\n -ms-flex-direction: column;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n width: 75px;\n height: 75px;\n margin: 0 8px 0 0;\n font-size: 16px;\n display: -ms-flexbox;\n display: flex;\n}\n\n.controls {\n display: -ms-flexbox;\n display: flex;\n}\n\n.button {\n cursor: pointer;\n color: #f9f6f2;\n border: none;\n border-radius: 5px;\n width: 75px;\n height: 75px;\n font-family: sans-serif;\n font-size: 16px;\n font-weight: 700;\n transition: background .25s;\n}\n\n.start {\n background: #1dae28;\n font-size: 20px;\n}\n\n.start:hover {\n background: #179921;\n}\n\n.restart {\n background: #f1b2b2;\n}\n\n.restart:hover {\n background: #f87474;\n}\n\n.message {\n box-sizing: border-box;\n color: #776e65;\n text-align: center;\n background: #d6cdc4;\n border-radius: 5px;\n width: 100%;\n padding: 10px;\n font-size: 20px;\n}\n\n.hidden {\n display: none;\n}\n\n.container {\n -ms-flex-direction: column;\n flex-direction: column;\n align-items: center;\n width: 350px;\n display: -ms-flexbox;\n display: flex;\n}\n\n.message-win {\n color: #f9f6f2;\n background: #edc22e;\n}\n\n.message-container {\n width: 100%;\n height: 150px;\n}\n/*# sourceMappingURL=index.6910ad39.css.map */\n","body {\n margin: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n background: #fbf8ef;\n font-family: sans-serif;\n font-size: 24px;\n font-weight: 900;\n}\n\n.field-cell {\n background: #d6cdc4;\n width: 75px;\n height: 75px;\n border-radius: 5px;\n color: #776e65;\n box-sizing: border-box;\n text-align: center;\n vertical-align: center;\n user-select: none;\n\n &--2 {\n background: #eee4da;\n }\n\n &--4 {\n background: #ede0c8;\n }\n\n &--8 {\n background: #f2b179;\n color: #f9f6f2;\n }\n\n &--16 {\n background: #f59563;\n color: #f9f6f2;\n }\n\n &--32 {\n background: #f67c5f;\n color: #f9f6f2;\n }\n\n &--64 {\n background: #f65e3b;\n color: #f9f6f2;\n }\n\n &--128 {\n background: #edcf72;\n color: #f9f6f2;\n }\n\n &--256 {\n background: #edcc61;\n color: #f9f6f2;\n }\n\n &--512 {\n background: #edc850;\n color: #f9f6f2;\n }\n\n &--1024 {\n background: #edc53f;\n color: #f9f6f2;\n }\n\n &--2048 {\n background: #edc22e;\n color: #f9f6f2;\n }\n}\n\n.game-field {\n background: #bbada0;\n border-spacing: 10px;\n border-radius: 5px;\n}\n\n.game-header {\n display: flex;\n width: 100%;\n justify-content: space-between;\n margin-bottom: 24px;\n padding: 10px;\n box-sizing: border-box;\n}\n\nh1 {\n background: #edc22e;\n color: #f9f6f2;\n width: 75px;\n height: 75px;\n font-size: 24px;\n border-radius: 5px;\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n margin: 0;\n}\n\n.info {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background: #d6cdc4;\n width: 75px;\n height: 75px;\n border-radius: 5px;\n color: #776e65;\n box-sizing: border-box;\n font-size: 16px;\n margin: 0 8px 0 0;\n}\n\n.controls {\n display: flex;\n}\n\n.button {\n border: none;\n border-radius: 5px;\n cursor: pointer;\n color: #f9f6f2;\n font-family: sans-serif;\n font-weight: 700;\n font-size: 16px;\n width: 75px;\n height: 75px;\n\n transition: 0.25s ease background;\n}\n\n.start {\n background: #1dae28;\n font-size: 20px;\n\n &:hover {\n background: #179921;\n }\n}\n\n.restart {\n background: #f1b2b2;\n\n &:hover {\n background: #f87474;\n }\n}\n\n.message {\n box-sizing: border-box;\n width: 100%;\n background: #d6cdc4;\n color: #776e65;\n padding: 10px;\n text-align: center;\n border-radius: 5px;\n font-size: 20px;\n}\n\n.hidden {\n display: none;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 350px;\n}\n\n.message-win {\n background: #edc22e;\n color: #f9f6f2;\n}\n\n.message-container {\n width: 100%;\n height: 150px;\n}\n"],"names":[],"version":3,"file":"index.6910ad39.css.map"} \ No newline at end of file diff --git a/index.f45556b2.js b/index.f45556b2.js new file mode 100644 index 000000000..3e3d2197f --- /dev/null +++ b/index.f45556b2.js @@ -0,0 +1,2 @@ +var t={};class e{static Status={idle:"idle",playing:"playing",win:"win",lose:"lose"};constructor(t=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]){this.state=t.map(t=>[...t]),this.status=e.Status.idle,this.initialState=t,this.score=0}filterZero(t){return t.filter(t=>0!==t)}slide(t){let e=this.filterZero(t);for(let t=0;tthis.slide(t));this.state=t,this.getRandomCells(),this.checkGameStatus()}}moveRight(){if(this.status===e.Status.playing){let t=t=>this.slide(t.reverse()).reverse(),e=this.state.map(e=>t);this.state=e,this.getRandomCells(),this.checkGameStatus()}}transposeArray(t){return t[0].map((e,s)=>t.map(t=>t[s]))}moveUp(){if(this.status===e.Status.playing){let t=t=>this.slide(t),e=this.transposeArray(this.state).map(e=>t);this.state=this.transposeArray(e),this.getRandomCells(),this.checkGameStatus()}}moveDown(){if(this.status===e.Status.playing){let t=t=>this.slide(t.reverse()).reverse(),e=this.transposeArray(this.state).map(e=>t);this.state=this.transposeArray(e),this.getRandomCells(),this.checkGameStatus()}}getScore(){return this.score}getState(){return this.state}getStatus(){return this.status}start(){this.status=e.Status.playing,this.getRandomCells(),this.getRandomCells()}restart(){this.status=e.Status.idle,this.state=this.initialState.map(t=>[...t]),this.score=0}getRandomCells(){let t=[];for(let e=0;e<4;e++)for(let s=0;s<4;s++)0===this.state[e][s]&&t.push([e,s]);if(t.length>0){let[e,s]=t[Math.floor(Math.random()*t.length)];this.state[e][s]=.9>Math.random()?2:4}}checkGameStatus(){let t=!1,s=!1;for(let a=0;a<4;a++)for(let i=0;i<4;i++){if(2048===this.state[a][i]){this.status=e.Status.win;return}0===this.state[a][i]&&(s=!0),(a<3&&this.state[a][i]===this.state[a+1][i]||i<3&&this.state[a][i]===this.state[a][i+1])&&(t=!0)}t||s||(this.status=e.Status.lose)}}const s=new(t=e),a=document.querySelector(".start"),i=document.querySelector(".game-field"),r=document.querySelector(".game-score"),l=document.querySelector(".message-start"),n=document.querySelector(".message-lose"),o=document.querySelector(".message-win");function h(){i.innerHTML="";let t=s.getState();for(let e=0;e<4;e++){let s=document.createElement("tr");for(let a=0;a<4;a++){let i=document.createElement("td"),r=t[e][a];i.textContent=0!==r?r:"",i.classList.add("field-cell"),0!==r&&i.classList.add(`field-cell--${r}`),s.appendChild(i)}i.appendChild(s)}}function d(){r.textContent=s.getScore()}function c(){s.getStatus()===t.Status.win?o.classList.remove("hidden"):s.getStatus()===t.Status.lose&&n.classList.remove("hidden")}a.addEventListener("click",()=>{a.classList.contains("start")?(s.start(),a.classList.remove("start"),a.classList.add("restart"),a.textContent="Restart",l.classList.add("hidden"),n.classList.add("hidden"),o.classList.add("hidden")):a.classList.contains("restart")&&(s.restart(),a.classList.remove("restart"),a.classList.add("start"),a.textContent="Start",l.classList.add("hidden"),n.classList.add("hidden"),o.classList.add("hidden")),h(),d()}),document.addEventListener("keyup",t=>{switch(t.key){case"ArrowRight":s.moveRight();break;case"ArrowLeft":s.moveLeft();break;case"ArrowUp":s.moveUp();break;case"ArrowDown":s.moveDown()}h(),d(),c()}),h(),d(),c(); +//# sourceMappingURL=index.f45556b2.js.map diff --git a/index.f45556b2.js.map b/index.f45556b2.js.map new file mode 100644 index 000000000..a3cc2e220 --- /dev/null +++ b/index.f45556b2.js.map @@ -0,0 +1 @@ +{"mappings":"A,I,E,C,CEEA,OAAM,EACJ,OAAO,OAAS,CACd,KAAM,OACN,QAAS,UACT,IAAK,MACL,KAAM,MACR,CAAE,AAEF,aACE,EAAe,CACb,CAAC,EAAG,EAAG,EAAG,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CAAC,QAAS,KAC3B,EAAO,SAAS,CAAC,QAAQ,CAAC,UAC5B,EAAK,KAAK,GAEV,EAAO,SAAS,CAAC,MAAM,CAAC,SACxB,EAAO,SAAS,CAAC,GAAG,CAAC,WACrB,EAAO,WAAW,CAAG,UAErB,EAAa,SAAS,CAAC,GAAG,CAAC,UAC3B,EAAY,SAAS,CAAC,GAAG,CAAC,UAC1B,EAAW,SAAS,CAAC,GAAG,CAAC,WAChB,EAAO,SAAS,CAAC,QAAQ,CAAC,aACnC,EAAK,OAAO,GAEZ,EAAO,SAAS,CAAC,MAAM,CAAC,WACxB,EAAO,SAAS,CAAC,GAAG,CAAC,SACrB,EAAO,WAAW,CAAG,QAErB,EAAa,SAAS,CAAC,GAAG,CAAC,UAC3B,EAAY,SAAS,CAAC,GAAG,CAAC,UAC1B,EAAW,SAAS,CAAC,GAAG,CAAC,WAG3B,IACA,GACF,GAEA,SAAS,gBAAgB,CAAC,QAAS,AAAC,IAClC,OAAQ,EAAE,GAAG,EACX,IAAK,aACH,EAAK,SAAS,GACd,KACF,KAAK,YACH,EAAK,QAAQ,GACb,KACF,KAAK,UACH,EAAK,MAAM,GACX,KACF,KAAK,YACH,EAAK,QAAQ,EAEjB,CAEA,IACA,IACA,GACF,GAwCA,IACA,IACA","sources":["","src/scripts/main.js","src/modules/Game.class.js"],"sourcesContent":["\"use strict\";\nvar $a5fd07fa01589658$exports = {};\n\"use strict\";\nclass $a5fd07fa01589658$var$Game {\n static Status = {\n idle: \"idle\",\n playing: \"playing\",\n win: \"win\",\n lose: \"lose\"\n };\n constructor(initialState = [\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ],\n [\n 0,\n 0,\n 0,\n 0\n ]\n ]){\n this.state = initialState.map((row)=>[\n ...row\n ]);\n this.status = $a5fd07fa01589658$var$Game.Status.idle;\n this.initialState = initialState;\n this.score = 0;\n }\n filterZero(row) {\n return row.filter((num)=>num !== 0);\n }\n slide(row) {\n let updRow = this.filterZero(row);\n for(let i = 0; i < updRow.length - 1; i++)if (updRow[i] === updRow[i + 1]) {\n updRow[i] *= 2;\n updRow[i + 1] = 0;\n this.score += updRow[i];\n }\n updRow = this.filterZero(updRow);\n while(updRow.length < 4)updRow.push(0);\n return updRow;\n }\n moveLeft() {\n if (this.status === $a5fd07fa01589658$var$Game.Status.playing) {\n let isMovable = false;\n const updatedCells = this.state.map((row)=>this.slide(row));\n this.state = updatedCells;\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n moveRight() {\n if (this.status === $a5fd07fa01589658$var$Game.Status.playing) {\n let isMovable = false;\n const reversedSlide = (row)=>this.slide(row.reverse()).reverse();\n const updatedCells = this.state.map((row)=>reversedSlide);\n this.state = updatedCells;\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n transposeArray(array) {\n return array[0].map((col, i)=>array.map((row)=>row[i]));\n }\n moveUp() {\n if (this.status === $a5fd07fa01589658$var$Game.Status.playing) {\n let isMovable = false;\n const slide = (row)=>this.slide(row);\n const updatedCells = this.transposeArray(this.state).map((row)=>slide);\n this.state = this.transposeArray(updatedCells);\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n moveDown() {\n if (this.status === $a5fd07fa01589658$var$Game.Status.playing) {\n let isMovable = false;\n const reversedSlide = (row)=>this.slide(row.reverse()).reverse();\n const updatedCells = this.transposeArray(this.state).map((row)=>reversedSlide);\n this.state = this.transposeArray(updatedCells);\n isMovable = true;\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n getScore() {\n return this.score;\n }\n getState() {\n return this.state;\n }\n getStatus() {\n return this.status;\n }\n start() {\n this.status = $a5fd07fa01589658$var$Game.Status.playing;\n this.getRandomCells();\n this.getRandomCells();\n }\n restart() {\n this.status = $a5fd07fa01589658$var$Game.Status.idle;\n this.state = this.initialState.map((row)=>[\n ...row\n ]);\n this.score = 0;\n }\n getRandomCells() {\n const emptyCells = [];\n for(let r = 0; r < 4; r++){\n for(let c = 0; c < 4; c++)if (this.state[r][c] === 0) emptyCells.push([\n r,\n c\n ]);\n }\n if (emptyCells.length > 0) {\n const [randomR, randomC] = emptyCells[Math.floor(Math.random() * emptyCells.length)];\n this.state[randomR][randomC] = Math.random() < 0.9 ? 2 : 4;\n }\n }\n checkGameStatus() {\n let isMovable = false;\n let hasEmptyCells = false;\n for(let r = 0; r < 4; r++)for(let c = 0; c < 4; c++){\n if (this.state[r][c] === 2048) {\n this.status = $a5fd07fa01589658$var$Game.Status.win;\n return;\n }\n if (this.state[r][c] === 0) hasEmptyCells = true;\n if (r < 3 && this.state[r][c] === this.state[r + 1][c] || c < 3 && this.state[r][c] === this.state[r][c + 1]) isMovable = true;\n }\n if (!isMovable && !hasEmptyCells) this.status = $a5fd07fa01589658$var$Game.Status.lose;\n }\n}\n$a5fd07fa01589658$exports = $a5fd07fa01589658$var$Game;\n\n\nconst $09e991522ca7e64e$var$game = new $a5fd07fa01589658$exports();\nconst $09e991522ca7e64e$var$button = document.querySelector(\".start\");\nconst $09e991522ca7e64e$var$gameField = document.querySelector(\".game-field\");\nconst $09e991522ca7e64e$var$gameScore = document.querySelector(\".game-score\");\nconst $09e991522ca7e64e$var$messageStart = document.querySelector(\".message-start\");\nconst $09e991522ca7e64e$var$messageLose = document.querySelector(\".message-lose\");\nconst $09e991522ca7e64e$var$messageWin = document.querySelector(\".message-win\");\n$09e991522ca7e64e$var$button.addEventListener(\"click\", ()=>{\n if ($09e991522ca7e64e$var$button.classList.contains(\"start\")) {\n $09e991522ca7e64e$var$game.start();\n $09e991522ca7e64e$var$button.classList.remove(\"start\");\n $09e991522ca7e64e$var$button.classList.add(\"restart\");\n $09e991522ca7e64e$var$button.textContent = \"Restart\";\n $09e991522ca7e64e$var$messageStart.classList.add(\"hidden\");\n $09e991522ca7e64e$var$messageLose.classList.add(\"hidden\");\n $09e991522ca7e64e$var$messageWin.classList.add(\"hidden\");\n } else if ($09e991522ca7e64e$var$button.classList.contains(\"restart\")) {\n $09e991522ca7e64e$var$game.restart();\n $09e991522ca7e64e$var$button.classList.remove(\"restart\");\n $09e991522ca7e64e$var$button.classList.add(\"start\");\n $09e991522ca7e64e$var$button.textContent = \"Start\";\n $09e991522ca7e64e$var$messageStart.classList.add(\"hidden\");\n $09e991522ca7e64e$var$messageLose.classList.add(\"hidden\");\n $09e991522ca7e64e$var$messageWin.classList.add(\"hidden\");\n }\n $09e991522ca7e64e$var$manageGameField();\n $09e991522ca7e64e$var$manageGameScore();\n});\ndocument.addEventListener(\"keyup\", (e)=>{\n switch(e.key){\n case \"ArrowRight\":\n $09e991522ca7e64e$var$game.moveRight();\n break;\n case \"ArrowLeft\":\n $09e991522ca7e64e$var$game.moveLeft();\n break;\n case \"ArrowUp\":\n $09e991522ca7e64e$var$game.moveUp();\n break;\n case \"ArrowDown\":\n $09e991522ca7e64e$var$game.moveDown();\n break;\n }\n $09e991522ca7e64e$var$manageGameField();\n $09e991522ca7e64e$var$manageGameScore();\n $09e991522ca7e64e$var$manageMessages();\n});\nfunction $09e991522ca7e64e$var$manageGameField() {\n $09e991522ca7e64e$var$gameField.innerHTML = \"\";\n const currState = $09e991522ca7e64e$var$game.getState();\n for(let r = 0; r < 4; r++){\n const tr = document.createElement(\"tr\");\n for(let c = 0; c < 4; c++){\n const td = document.createElement(\"td\");\n const value = currState[r][c];\n td.textContent = value !== 0 ? value : \"\";\n td.classList.add(\"field-cell\");\n if (value !== 0) td.classList.add(`field-cell--${value}`);\n tr.appendChild(td);\n }\n $09e991522ca7e64e$var$gameField.appendChild(tr);\n }\n}\nfunction $09e991522ca7e64e$var$manageGameScore() {\n $09e991522ca7e64e$var$gameScore.textContent = $09e991522ca7e64e$var$game.getScore();\n}\nfunction $09e991522ca7e64e$var$manageMessages() {\n if ($09e991522ca7e64e$var$game.getStatus() === $a5fd07fa01589658$exports.Status.win) $09e991522ca7e64e$var$messageWin.classList.remove(\"hidden\");\n else if ($09e991522ca7e64e$var$game.getStatus() === $a5fd07fa01589658$exports.Status.lose) $09e991522ca7e64e$var$messageLose.classList.remove(\"hidden\");\n}\n$09e991522ca7e64e$var$manageGameField();\n$09e991522ca7e64e$var$manageGameScore();\n$09e991522ca7e64e$var$manageMessages();\n\n\n//# sourceMappingURL=index.f45556b2.js.map\n","'use strict';\n\nconst Game = require('../modules/Game.class');\n\nconst game = new Game();\n\nconst button = document.querySelector('.start');\n\nconst gameField = document.querySelector('.game-field');\nconst gameScore = document.querySelector('.game-score');\n\nconst messageStart = document.querySelector('.message-start');\nconst messageLose = document.querySelector('.message-lose');\nconst messageWin = document.querySelector('.message-win');\n\nbutton.addEventListener('click', () => {\n if (button.classList.contains('start')) {\n game.start();\n\n button.classList.remove('start');\n button.classList.add('restart');\n button.textContent = 'Restart';\n\n messageStart.classList.add('hidden');\n messageLose.classList.add('hidden');\n messageWin.classList.add('hidden');\n } else if (button.classList.contains('restart')) {\n game.restart();\n\n button.classList.remove('restart');\n button.classList.add('start');\n button.textContent = 'Start';\n\n messageStart.classList.add('hidden');\n messageLose.classList.add('hidden');\n messageWin.classList.add('hidden');\n }\n\n manageGameField();\n manageGameScore();\n});\n\ndocument.addEventListener('keyup', (e) => {\n switch (e.key) {\n case 'ArrowRight':\n game.moveRight();\n break;\n case 'ArrowLeft':\n game.moveLeft();\n break;\n case 'ArrowUp':\n game.moveUp();\n break;\n case 'ArrowDown':\n game.moveDown();\n break;\n }\n\n manageGameField();\n manageGameScore();\n manageMessages();\n});\n\nfunction manageGameField() {\n gameField.innerHTML = '';\n\n const currState = game.getState();\n\n for (let r = 0; r < 4; r++) {\n const tr = document.createElement('tr');\n\n for (let c = 0; c < 4; c++) {\n const td = document.createElement('td');\n const value = currState[r][c];\n\n td.textContent = value !== 0 ? value : '';\n td.classList.add('field-cell');\n\n if (value !== 0) {\n td.classList.add(`field-cell--${value}`);\n }\n\n tr.appendChild(td);\n }\n\n gameField.appendChild(tr);\n }\n}\n\nfunction manageGameScore() {\n gameScore.textContent = game.getScore();\n}\n\nfunction manageMessages() {\n if (game.getStatus() === Game.Status.win) {\n messageWin.classList.remove('hidden');\n } else if (game.getStatus() === Game.Status.lose) {\n messageLose.classList.remove('hidden');\n }\n}\n\nmanageGameField();\nmanageGameScore();\nmanageMessages();\n","'use strict';\n\nclass Game {\n static Status = {\n idle: 'idle',\n playing: 'playing',\n win: 'win',\n lose: 'lose',\n };\n\n constructor(\n initialState = [\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n ],\n ) {\n this.state = initialState.map((row) => [...row]);\n this.status = Game.Status.idle;\n this.initialState = initialState;\n this.score = 0;\n }\n\n filterZero(row) {\n return row.filter((num) => num !== 0);\n }\n slide(row) {\n let updRow = this.filterZero(row);\n\n for (let i = 0; i < updRow.length - 1; i++) {\n if (updRow[i] === updRow[i + 1]) {\n updRow[i] *= 2;\n updRow[i + 1] = 0;\n this.score += updRow[i];\n }\n }\n updRow = this.filterZero(updRow);\n\n while (updRow.length < 4) {\n updRow.push(0);\n }\n\n return updRow;\n }\n moveLeft() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n\n const updatedCells = this.state.map((row) => this.slide(row));\n\n this.state = updatedCells;\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n\n moveRight() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n const reversedSlide = (row) => this.slide(row.reverse()).reverse();\n\n const updatedCells = this.state.map((row) => reversedSlide);\n\n this.state = updatedCells;\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n\n transposeArray(array) {\n return array[0].map((col, i) => array.map((row) => row[i]));\n }\n moveUp() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n const slide = (row) => this.slide(row);\n\n const updatedCells = this.transposeArray(this.state).map((row) => slide);\n\n this.state = this.transposeArray(updatedCells);\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n moveDown() {\n if (this.status === Game.Status.playing) {\n let isMovable = false;\n const reversedSlide = (row) => this.slide(row.reverse()).reverse();\n\n const updatedCells = this.transposeArray(this.state).map(\n (row) => reversedSlide,\n );\n\n this.state = this.transposeArray(updatedCells);\n\n isMovable = true;\n\n if (isMovable) {\n this.getRandomCells();\n this.checkGameStatus();\n }\n }\n }\n\n getScore() {\n return this.score;\n }\n getState() {\n return this.state;\n }\n getStatus() {\n return this.status;\n }\n\n start() {\n this.status = Game.Status.playing;\n this.getRandomCells();\n this.getRandomCells();\n }\n\n restart() {\n this.status = Game.Status.idle;\n this.state = this.initialState.map((row) => [...row]);\n this.score = 0;\n }\n\n getRandomCells() {\n const emptyCells = [];\n\n for (let r = 0; r < 4; r++) {\n for (let c = 0; c < 4; c++) {\n if (this.state[r][c] === 0) {\n emptyCells.push([r, c]);\n }\n }\n }\n\n if (emptyCells.length > 0) {\n const [randomR, randomC] =\n emptyCells[Math.floor(Math.random() * emptyCells.length)];\n\n this.state[randomR][randomC] = Math.random() < 0.9 ? 2 : 4;\n }\n }\n checkGameStatus() {\n let isMovable = false;\n let hasEmptyCells = false;\n\n for (let r = 0; r < 4; r++) {\n for (let c = 0; c < 4; c++) {\n if (this.state[r][c] === 2048) {\n this.status = Game.Status.win;\n\n return;\n }\n\n if (this.state[r][c] === 0) {\n hasEmptyCells = true;\n }\n\n if (\n (r < 3 && this.state[r][c] === this.state[r + 1][c]) ||\n (c < 3 && this.state[r][c] === this.state[r][c + 1])\n ) {\n isMovable = true;\n }\n }\n }\n\n if (!isMovable && !hasEmptyCells) {\n this.status = Game.Status.lose;\n }\n }\n}\n\nmodule.exports = Game;\n"],"names":["$a5fd07fa01589658$exports","$a5fd07fa01589658$var$Game","Status","idle","playing","win","lose","constructor","initialState","state","map","row","status","score","filterZero","filter","num","slide","updRow","i","length","push","moveLeft","updatedCells","getRandomCells","checkGameStatus","moveRight","reversedSlide","reverse","transposeArray","array","col","moveUp","moveDown","getScore","getState","getStatus","start","restart","emptyCells","r","c","randomR","randomC","Math","floor","random","isMovable","hasEmptyCells","$09e991522ca7e64e$var$game","$09e991522ca7e64e$var$button","document","querySelector","$09e991522ca7e64e$var$gameField","$09e991522ca7e64e$var$gameScore","$09e991522ca7e64e$var$messageStart","$09e991522ca7e64e$var$messageLose","$09e991522ca7e64e$var$messageWin","$09e991522ca7e64e$var$manageGameField","innerHTML","currState","tr","createElement","td","value","textContent","classList","add","appendChild","$09e991522ca7e64e$var$manageGameScore","$09e991522ca7e64e$var$manageMessages","remove","addEventListener","contains","e","key"],"version":3,"file":"index.f45556b2.js.map"} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 000000000..a1d1a3dbb --- /dev/null +++ b/index.html @@ -0,0 +1 @@ +2048

2048

Score: 0

Press "Start" to begin game. Good luck!

\ No newline at end of file