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..747fdd5ba --- /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 -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: 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 -ms-flex-pack: justify;\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 -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: 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 -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: 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 -ms-flex-align: center;\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\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.83f2c579.js b/index.83f2c579.js new file mode 100644 index 000000000..614a7834f --- /dev/null +++ b/index.83f2c579.js @@ -0,0 +1,2 @@ +!function(){function t(t,e,n){if(!e.has(t))throw TypeError("attempted to get private field on non-instance");return n}function e(t,e){!function(t,e){if(e.has(t))throw TypeError("Cannot initialize the same private elements twice on an object")}(t,e),e.add(t)}function n(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n.1?2:4}}function p(t){for(var e=t.filter(function(t){return 0!==t}),n=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:t(this,i,v).call(this);!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,g),e(this,i),e(this,s),e(this,o),e(this,c),e(this,l),e(this,u),e(this,h),e(this,f),e(this,d),this.initialState=n,this.state=this.initialState.map(function(t){return a(t)}),this.score=0,this.status="idle"}return r=[{key:"moveLeft",value:function(){var e=this;if("playing"===this.status){var n=this.state.map(function(n){return t(e,c,p).call(e,n)});t(this,d,k).call(this,n)}}},{key:"moveRight",value:function(){var e=this;if("playing"===this.status){var n=this.state.map(function(n){var r=n.slice().reverse();return t(e,c,p).call(e,r).reverse()});t(this,d,k).call(this,n)}}},{key:"moveUp",value:function(){var e=this;if("playing"===this.status){var n=t(this,l,w).call(this,this.state).map(function(n){return t(e,c,p).call(e,n)});t(this,d,k).call(this,t(this,l,w).call(this,n))}}},{key:"moveDown",value:function(){var e=this;if("playing"===this.status){var n=t(this,l,w).call(this,this.state).map(function(n){var r=n.slice().reverse();return t(e,c,p).call(e,r).reverse()});t(this,d,k).call(this,t(this,l,w).call(this,n))}}},{key:"getScore",value:function(){return this.score}},{key:"getState",value:function(){return this.state}},{key:"getStatus",value:function(){return this.status}},{key:"start",value:function(){this.status="playing",t(this,o,y).call(this),t(this,o,y).call(this)}},{key:"restart",value:function(){this.state=this.initialState.map(function(t){return a(t)}),this.score=0,this.status="idle"}}],n(g.prototype,r),m&&n(g,m),g}()),L=document.querySelector(".button",".start");function x(){var t=A.getState(),e=document.querySelector(".game-field").querySelector("tbody");e.innerHTML="";for(var n=0;n","src/scripts/main.js","src/modules/Game.class.js","node_modules/@swc/helpers/esm/_class_call_check.js","node_modules/@swc/helpers/esm/_class_private_method_get.js","node_modules/@swc/helpers/esm/_class_private_method_init.js","node_modules/@swc/helpers/esm/_check_private_redeclaration.js","node_modules/@swc/helpers/esm/_create_class.js","node_modules/@swc/helpers/esm/_to_consumable_array.js","node_modules/@swc/helpers/esm/_array_without_holes.js","node_modules/@swc/helpers/esm/_array_like_to_array.js","node_modules/@swc/helpers/esm/_iterable_to_array.js","node_modules/@swc/helpers/esm/_non_iterable_spread.js","node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js","node_modules/@swc/helpers/esm/_type_of.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 $ac6739cbe5bf1c84$export$ccedaf978f62b9dd(receiver, privateSet, fn) {\n if (!privateSet.has(receiver)) throw new TypeError(\"attempted to get private field on non-instance\");\n return fn;\n}\n\n\nfunction $f86983e96b0c893e$export$6b10452b5ac97eba(obj, privateCollection) {\n if (privateCollection.has(obj)) throw new TypeError(\"Cannot initialize the same private elements twice on an object\");\n}\n\n\nfunction $ea91727f98d0802f$export$1002c20f28174dbf(obj, privateSet) {\n (0, $f86983e96b0c893e$export$6b10452b5ac97eba)(obj, privateSet);\n privateSet.add(obj);\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 $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 $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 $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 $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\nfunction $0b5c99e6a0876eaa$export$5f0017c582d45a2d(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\n\n\n\"use strict\";\nvar // Add your own methods here\n$3d28d7f1aac198f5$var$_createEmptyState = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_getEmptyCells = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_addRandomTile = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_mergeCells = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_transpose = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_willStateChange = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_isWin = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_isLose = /*#__PURE__*/ new WeakSet(), $3d28d7f1aac198f5$var$_handleMove = /*#__PURE__*/ new WeakSet();\nvar $3d28d7f1aac198f5$var$Game = /*#__PURE__*/ function() {\n function Game() {\n var initialState = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_createEmptyState, $3d28d7f1aac198f5$var$createEmptyState).call(this);\n (0, $8713978b2328d32b$export$2996f80ef42b8419)(this, Game);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_createEmptyState);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_getEmptyCells);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_addRandomTile);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_mergeCells);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_transpose);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_willStateChange);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_isWin);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_isLose);\n (0, $ea91727f98d0802f$export$1002c20f28174dbf)(this, $3d28d7f1aac198f5$var$_handleMove);\n this.initialState = initialState;\n this.state = this.initialState.map(function(row) {\n return (0, $227c6742e0ff6f82$export$1b5e630bc3aea29f)(row);\n });\n this.score = 0;\n this.status = \"idle\";\n }\n (0, $4fc75ccb937ab1df$export$d60067ff2358eee8)(Game, [\n {\n key: \"moveLeft\",\n value: function moveLeft() {\n var _this = this;\n if (this.status === \"playing\") {\n var newState = this.state.map(function(row) {\n return (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(_this, $3d28d7f1aac198f5$var$_mergeCells, $3d28d7f1aac198f5$var$mergeCells).call(_this, row);\n });\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_handleMove, $3d28d7f1aac198f5$var$handleMove).call(this, newState);\n }\n }\n },\n {\n key: \"moveRight\",\n value: function moveRight() {\n var _this = this;\n if (this.status === \"playing\") {\n var newState = this.state.map(function(row) {\n var reversedRow = row.slice().reverse();\n var mergedRow = (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(_this, $3d28d7f1aac198f5$var$_mergeCells, $3d28d7f1aac198f5$var$mergeCells).call(_this, reversedRow);\n return mergedRow.reverse();\n });\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_handleMove, $3d28d7f1aac198f5$var$handleMove).call(this, newState);\n }\n }\n },\n {\n key: \"moveUp\",\n value: function moveUp() {\n var _this = this;\n if (this.status === \"playing\") {\n var transposedState = (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_transpose, $3d28d7f1aac198f5$var$transpose).call(this, this.state);\n var newState = transposedState.map(function(row) {\n return (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(_this, $3d28d7f1aac198f5$var$_mergeCells, $3d28d7f1aac198f5$var$mergeCells).call(_this, row);\n });\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_handleMove, $3d28d7f1aac198f5$var$handleMove).call(this, (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_transpose, $3d28d7f1aac198f5$var$transpose).call(this, newState));\n }\n }\n },\n {\n key: \"moveDown\",\n value: function moveDown() {\n var _this = this;\n if (this.status === \"playing\") {\n var transposedState = (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_transpose, $3d28d7f1aac198f5$var$transpose).call(this, this.state);\n var newState = transposedState.map(function(row) {\n var reversedRow = row.slice().reverse();\n var mergedRow = (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(_this, $3d28d7f1aac198f5$var$_mergeCells, $3d28d7f1aac198f5$var$mergeCells).call(_this, reversedRow);\n return mergedRow.reverse();\n });\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_handleMove, $3d28d7f1aac198f5$var$handleMove).call(this, (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_transpose, $3d28d7f1aac198f5$var$transpose).call(this, newState));\n }\n }\n },\n {\n /**\n * @returns {number}\n */ key: \"getScore\",\n value: function getScore() {\n return this.score;\n }\n },\n {\n /**\n * @returns {number[][]}\n */ key: \"getState\",\n value: function getState() {\n return this.state;\n }\n },\n {\n /**\n * Returns the current game status.\n *\n * @returns {string} One of: 'idle', 'playing', 'win', 'lose'\n *\n * `idle` - the game has not started yet (the initial state);\n * `playing` - the game is in progress;\n * `win` - the game is won;\n * `lose` - the game is lost\n */ key: \"getStatus\",\n value: function getStatus() {\n return this.status;\n }\n },\n {\n /**\n * Starts the game.\n */ key: \"start\",\n value: function start() {\n this.status = \"playing\";\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_addRandomTile, $3d28d7f1aac198f5$var$addRandomTile).call(this);\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_addRandomTile, $3d28d7f1aac198f5$var$addRandomTile).call(this);\n }\n },\n {\n /**\n * Resets the game.\n */ key: \"restart\",\n value: function restart() {\n this.state = this.initialState.map(function(row) {\n return (0, $227c6742e0ff6f82$export$1b5e630bc3aea29f)(row);\n });\n this.score = 0;\n this.status = \"idle\";\n }\n }\n ]);\n return Game;\n}();\nfunction $3d28d7f1aac198f5$var$createEmptyState() {\n return Array.from({\n length: 4\n }, function() {\n return Array(4).fill(0);\n });\n}\nfunction $3d28d7f1aac198f5$var$getEmptyCells() {\n var emptyCells = [];\n this.state.forEach(function(row, rowIndex) {\n row.forEach(function(cell, cellIndex) {\n if (cell === 0) emptyCells.push({\n rowIndex: rowIndex,\n cellIndex: cellIndex\n });\n });\n });\n return emptyCells;\n}\nfunction $3d28d7f1aac198f5$var$addRandomTile() {\n var emptyCells = (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_getEmptyCells, $3d28d7f1aac198f5$var$getEmptyCells).call(this);\n if (emptyCells.length === 0) return;\n var randomCell = emptyCells[Math.floor(Math.random() * emptyCells.length)];\n var value = Math.random() > 0.1 ? 2 : 4;\n this.state[randomCell.rowIndex][randomCell.cellIndex] = value;\n}\nfunction $3d28d7f1aac198f5$var$mergeCells(row) {\n var _newRow;\n var mergedRow = row.filter(function(cell) {\n return cell !== 0;\n });\n var newRow = [];\n var i = 0;\n while(i < mergedRow.length)if (mergedRow[i] === mergedRow[i + 1]) {\n newRow.push(mergedRow[i] * 2);\n this.score += mergedRow[i] * 2;\n i += 2;\n } else {\n newRow.push(mergedRow[i]);\n i += 1;\n }\n (_newRow = newRow).push.apply(_newRow, (0, $227c6742e0ff6f82$export$1b5e630bc3aea29f)(Array(4 - newRow.length).fill(0)));\n return newRow;\n}\nfunction $3d28d7f1aac198f5$var$transpose(matrix) {\n return matrix[0].map(function(_, colIndex) {\n return matrix.map(function(row) {\n return row[colIndex];\n });\n });\n}\nfunction $3d28d7f1aac198f5$var$willStateChange(newState) {\n return JSON.stringify(this.state) !== JSON.stringify(newState);\n}\nfunction $3d28d7f1aac198f5$var$isWin() {\n this.status = this.state.some(function(row) {\n return row.includes(2048);\n }) ? \"win\" : this.status;\n}\nfunction $3d28d7f1aac198f5$var$isLose() {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;\n try {\n var _loop = function() {\n var row = _step.value;\n if (row.some(function(i) {\n return i === 0;\n })) return {\n v: false\n };\n for(var i = 0; i < row.length; i++){\n if (row[i] === row[i + 1]) return {\n v: false\n };\n }\n };\n for(var _iterator = this.state[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){\n var _ret = _loop();\n if ((0, $0b5c99e6a0876eaa$export$5f0017c582d45a2d)(_ret) === \"object\") return _ret.v;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally{\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally{\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n for(var c = 0; c < 4; c++){\n var row = [\n this.state[0][c],\n this.state[1][c],\n this.state[2][c],\n this.state[3][c]\n ];\n for(var i = 0; i < row.length; i++){\n if (row[i] === row[i + 1]) return false;\n }\n }\n return true;\n}\nfunction $3d28d7f1aac198f5$var$handleMove(newState) {\n if ((0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_willStateChange, $3d28d7f1aac198f5$var$willStateChange).call(this, newState)) {\n this.state = newState;\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_addRandomTile, $3d28d7f1aac198f5$var$addRandomTile).call(this);\n (0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_isWin, $3d28d7f1aac198f5$var$isWin).call(this);\n if ((0, $ac6739cbe5bf1c84$export$ccedaf978f62b9dd)(this, $3d28d7f1aac198f5$var$_isLose, $3d28d7f1aac198f5$var$isLose).call(this)) this.status = \"lose\";\n }\n}\n$3d28d7f1aac198f5$exports = $3d28d7f1aac198f5$var$Game;\n\n\nvar $197cd56b15c33885$var$game = new $3d28d7f1aac198f5$exports();\n// Uncomment the next lines to use your game instance in the browser\n// [\n// [2, 0, 2, 2],\n// [0, 2, 2, 2],\n// [2, 2, 0, 2],\n// [2, 2, 2, 0],\n// ]\n// Write your code here\nvar $197cd56b15c33885$var$startButton = document.querySelector(\".button\", \".start\");\nfunction $197cd56b15c33885$var$updateTable() {\n var gameState = $197cd56b15c33885$var$game.getState();\n var table = document.querySelector(\".game-field\");\n var tbody = table.querySelector(\"tbody\");\n tbody.innerHTML = \"\";\n for(var i = 0; i < gameState.length; i++){\n var row = gameState[i];\n var tr = document.createElement(\"tr\");\n tr.className = \"field-row\";\n for(var j = 0; j < row.length; j++){\n var cell = row[j];\n var td = document.createElement(\"td\");\n td.textContent = cell !== 0 ? cell : \"\";\n td.className = cell !== 0 ? \"field-cell field-cell--\".concat(cell) : \"field-cell\";\n tr.appendChild(td);\n }\n tbody.appendChild(tr);\n }\n}\nfunction $197cd56b15c33885$var$updateScore() {\n var gameScore = document.querySelector(\".game-score\");\n gameScore.innerText = $197cd56b15c33885$var$game.getScore();\n}\nfunction $197cd56b15c33885$var$handleMessages(action, type) {\n var startMessage = document.querySelector(\".message-start\");\n var winMessage = document.querySelector(\".message-win\");\n var loseMessage = document.querySelector(\".message-lose\");\n if (action === \"hide\") switch(type){\n case \"start\":\n startMessage.classList.add(\"hidden\");\n break;\n case \"win\":\n winMessage.classList.add(\"hidden\");\n break;\n case \"lose\":\n loseMessage.classList.add(\"hidden\");\n break;\n default:\n break;\n }\n if (action === \"show\") switch(type){\n case \"start\":\n startMessage.classList.remove(\"hidden\");\n break;\n case \"win\":\n winMessage.classList.remove(\"hidden\");\n break;\n case \"lose\":\n loseMessage.classList.remove(\"hidden\");\n break;\n default:\n break;\n }\n}\nfunction $197cd56b15c33885$var$handleGameStatus() {\n switch($197cd56b15c33885$var$game.getStatus()){\n case \"win\":\n $197cd56b15c33885$var$handleMessages(\"show\", \"win\");\n break;\n case \"lose\":\n $197cd56b15c33885$var$handleMessages(\"show\", \"lose\");\n break;\n default:\n break;\n }\n}\nfunction $197cd56b15c33885$var$updateGame() {\n $197cd56b15c33885$var$updateTable();\n $197cd56b15c33885$var$updateScore();\n $197cd56b15c33885$var$handleGameStatus();\n}\n$197cd56b15c33885$var$startButton.addEventListener(\"click\", function() {\n switch($197cd56b15c33885$var$game.getStatus()){\n case \"idle\":\n $197cd56b15c33885$var$game.start();\n $197cd56b15c33885$var$updateTable();\n $197cd56b15c33885$var$startButton.className = \"button restart\";\n $197cd56b15c33885$var$startButton.textContent = \"Restart\";\n $197cd56b15c33885$var$handleMessages(\"hide\", \"start\");\n $197cd56b15c33885$var$updateScore();\n break;\n case \"playing\":\n $197cd56b15c33885$var$game.restart();\n $197cd56b15c33885$var$updateTable();\n $197cd56b15c33885$var$startButton.className = \"button start\";\n $197cd56b15c33885$var$startButton.textContent = \"Start\";\n $197cd56b15c33885$var$handleMessages(\"show\", \"start\");\n $197cd56b15c33885$var$updateScore();\n break;\n case \"win\":\n $197cd56b15c33885$var$game.restart();\n $197cd56b15c33885$var$updateTable();\n $197cd56b15c33885$var$startButton.className = \"button start\";\n $197cd56b15c33885$var$startButton.textContent = \"Start\";\n $197cd56b15c33885$var$handleMessages(\"hide\", \"win\");\n $197cd56b15c33885$var$handleMessages(\"show\", \"start\");\n $197cd56b15c33885$var$updateScore();\n break;\n case \"lose\":\n $197cd56b15c33885$var$game.restart();\n $197cd56b15c33885$var$updateTable();\n $197cd56b15c33885$var$startButton.className = \"button start\";\n $197cd56b15c33885$var$startButton.textContent = \"Start\";\n $197cd56b15c33885$var$handleMessages(\"hide\", \"lose\");\n $197cd56b15c33885$var$handleMessages(\"show\", \"start\");\n $197cd56b15c33885$var$updateScore();\n break;\n default:\n break;\n }\n});\ndocument.addEventListener(\"keydown\", function(e) {\n switch(e.key){\n case \"ArrowLeft\":\n $197cd56b15c33885$var$game.moveLeft();\n $197cd56b15c33885$var$updateGame();\n break;\n case \"ArrowRight\":\n $197cd56b15c33885$var$game.moveRight();\n $197cd56b15c33885$var$updateGame();\n break;\n case \"ArrowUp\":\n $197cd56b15c33885$var$game.moveUp();\n $197cd56b15c33885$var$updateGame();\n break;\n case \"ArrowDown\":\n $197cd56b15c33885$var$game.moveDown();\n $197cd56b15c33885$var$updateGame();\n break;\n default:\n break;\n }\n});\n\n})();\n//# sourceMappingURL=index.83f2c579.js.map\n","'use strict';\n\n// Uncomment the next lines to use your game instance in the browser\nconst Game = require('../modules/Game.class');\nconst game = new Game();\n\n// Uncomment the next lines to use your game instance in the browser\n// [\n// [2, 0, 2, 2],\n// [0, 2, 2, 2],\n// [2, 2, 0, 2],\n// [2, 2, 2, 0],\n// ]\n\n// Write your code here\n\nconst startButton = document.querySelector('.button', '.start');\n\nfunction updateTable() {\n const gameState = game.getState();\n const table = document.querySelector('.game-field');\n const tbody = table.querySelector('tbody');\n\n tbody.innerHTML = '';\n\n for (let i = 0; i < gameState.length; i++) {\n const row = gameState[i];\n const tr = document.createElement('tr');\n\n tr.className = 'field-row';\n\n for (let j = 0; j < row.length; j++) {\n const cell = row[j];\n const td = document.createElement('td');\n\n td.textContent = cell !== 0 ? cell : '';\n\n td.className =\n cell !== 0 ? `field-cell field-cell--${cell}` : 'field-cell';\n tr.appendChild(td);\n }\n tbody.appendChild(tr);\n }\n}\n\nfunction updateScore() {\n const gameScore = document.querySelector('.game-score');\n\n gameScore.innerText = game.getScore();\n}\n\nfunction handleMessages(action, type) {\n const startMessage = document.querySelector('.message-start');\n const winMessage = document.querySelector('.message-win');\n const loseMessage = document.querySelector('.message-lose');\n\n if (action === 'hide') {\n switch (type) {\n case 'start':\n startMessage.classList.add('hidden');\n break;\n case 'win':\n winMessage.classList.add('hidden');\n break;\n case 'lose':\n loseMessage.classList.add('hidden');\n break;\n default:\n break;\n }\n }\n\n if (action === 'show') {\n switch (type) {\n case 'start':\n startMessage.classList.remove('hidden');\n break;\n case 'win':\n winMessage.classList.remove('hidden');\n break;\n case 'lose':\n loseMessage.classList.remove('hidden');\n break;\n default:\n break;\n }\n }\n}\n\nfunction handleGameStatus() {\n switch (game.getStatus()) {\n case 'win':\n handleMessages('show', 'win');\n break;\n case 'lose':\n handleMessages('show', 'lose');\n break;\n default:\n break;\n }\n}\n\nfunction updateGame() {\n updateTable();\n updateScore();\n handleGameStatus();\n}\n\nstartButton.addEventListener('click', () => {\n switch (game.getStatus()) {\n case 'idle':\n game.start();\n updateTable();\n startButton.className = 'button restart';\n startButton.textContent = 'Restart';\n handleMessages('hide', 'start');\n updateScore();\n break;\n case 'playing':\n game.restart();\n updateTable();\n startButton.className = 'button start';\n startButton.textContent = 'Start';\n handleMessages('show', 'start');\n updateScore();\n break;\n case 'win':\n game.restart();\n updateTable();\n startButton.className = 'button start';\n startButton.textContent = 'Start';\n handleMessages('hide', 'win');\n handleMessages('show', 'start');\n updateScore();\n break;\n case 'lose':\n game.restart();\n updateTable();\n startButton.className = 'button start';\n startButton.textContent = 'Start';\n handleMessages('hide', 'lose');\n handleMessages('show', 'start');\n updateScore();\n break;\n default:\n break;\n }\n});\n\ndocument.addEventListener('keydown', (e) => {\n switch (e.key) {\n case 'ArrowLeft':\n game.moveLeft();\n updateGame();\n break;\n case 'ArrowRight':\n game.moveRight();\n updateGame();\n break;\n case 'ArrowUp':\n game.moveUp();\n updateGame();\n break;\n case 'ArrowDown':\n game.moveDown();\n updateGame();\n break;\n default:\n break;\n }\n});\n","'use strict';\nclass Game {\n /**\n * Creates a new game instance.\n *\n * @param {number[][]} initialState\n * The initial state of the board.\n * @default\n * [[0, 0, 0, 0],\n * [0, 0, 0, 0],\n * [0, 0, 0, 0],\n * [0, 0, 0, 0]]\n *\n * If passed, the board will be initialized with the provided\n * initial state.\n */\n constructor(initialState = this.#createEmptyState()) {\n this.initialState = initialState;\n this.state = this.initialState.map((row) => [...row]);\n this.score = 0;\n this.status = 'idle';\n }\n\n moveLeft() {\n if (this.status === 'playing') {\n const newState = this.state.map((row) => this.#mergeCells(row));\n\n this.#handleMove(newState);\n }\n }\n moveRight() {\n if (this.status === 'playing') {\n const newState = this.state.map((row) => {\n const reversedRow = row.slice().reverse();\n const mergedRow = this.#mergeCells(reversedRow);\n\n return mergedRow.reverse();\n });\n\n this.#handleMove(newState);\n }\n }\n moveUp() {\n if (this.status === 'playing') {\n const transposedState = this.#transpose(this.state);\n const newState = transposedState.map((row) => this.#mergeCells(row));\n\n this.#handleMove(this.#transpose(newState));\n }\n }\n moveDown() {\n if (this.status === 'playing') {\n const transposedState = this.#transpose(this.state);\n const newState = transposedState.map((row) => {\n const reversedRow = row.slice().reverse();\n const mergedRow = this.#mergeCells(reversedRow);\n\n return mergedRow.reverse();\n });\n\n this.#handleMove(this.#transpose(newState));\n }\n }\n\n /**\n * @returns {number}\n */\n getScore() {\n return this.score;\n }\n\n /**\n * @returns {number[][]}\n */\n getState() {\n return this.state;\n }\n\n /**\n * Returns the current game status.\n *\n * @returns {string} One of: 'idle', 'playing', 'win', 'lose'\n *\n * `idle` - the game has not started yet (the initial state);\n * `playing` - the game is in progress;\n * `win` - the game is won;\n * `lose` - the game is lost\n */\n getStatus() {\n return this.status;\n }\n\n /**\n * Starts the game.\n */\n start() {\n this.status = 'playing';\n this.#addRandomTile();\n this.#addRandomTile();\n }\n\n /**\n * Resets the game.\n */\n restart() {\n this.state = this.initialState.map((row) => [...row]);\n this.score = 0;\n this.status = 'idle';\n }\n\n // Add your own methods here\n\n #createEmptyState() {\n return Array.from({ length: 4 }, () => Array(4).fill(0));\n }\n\n #getEmptyCells() {\n const emptyCells = [];\n\n this.state.forEach((row, rowIndex) => {\n row.forEach((cell, cellIndex) => {\n if (cell === 0) {\n emptyCells.push({ rowIndex, cellIndex });\n }\n });\n });\n\n return emptyCells;\n }\n\n #addRandomTile() {\n const emptyCells = this.#getEmptyCells();\n\n if (emptyCells.length === 0) {\n return;\n }\n\n const randomCell =\n emptyCells[Math.floor(Math.random() * emptyCells.length)];\n const value = Math.random() > 0.1 ? 2 : 4;\n\n this.state[randomCell.rowIndex][randomCell.cellIndex] = value;\n }\n\n #mergeCells(row) {\n const mergedRow = row.filter((cell) => cell !== 0);\n const newRow = [];\n let i = 0;\n\n while (i < mergedRow.length) {\n if (mergedRow[i] === mergedRow[i + 1]) {\n newRow.push(mergedRow[i] * 2);\n this.score += mergedRow[i] * 2;\n i += 2;\n } else {\n newRow.push(mergedRow[i]);\n i += 1;\n }\n }\n newRow.push(...Array(4 - newRow.length).fill(0));\n\n return newRow;\n }\n\n #transpose(matrix) {\n return matrix[0].map((_, colIndex) => matrix.map((row) => row[colIndex]));\n }\n\n #willStateChange(newState) {\n return JSON.stringify(this.state) !== JSON.stringify(newState);\n }\n\n #isWin() {\n this.status = this.state.some((row) => row.includes(2048))\n ? 'win'\n : this.status;\n }\n\n #isLose() {\n for (const row of this.state) {\n if (row.some((i) => i === 0)) {\n return false;\n }\n\n for (let i = 0; i < row.length; i++) {\n if (row[i] === row[i + 1]) {\n return false;\n }\n }\n }\n\n for (let c = 0; c < 4; c++) {\n const row = [\n this.state[0][c],\n this.state[1][c],\n this.state[2][c],\n this.state[3][c],\n ];\n\n for (let i = 0; i < row.length; i++) {\n if (row[i] === row[i + 1]) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n #handleMove(newState) {\n if (this.#willStateChange(newState)) {\n this.state = newState;\n this.#addRandomTile();\n this.#isWin();\n\n if (this.#isLose()) {\n this.status = 'lose';\n }\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","export function _class_private_method_get(receiver, privateSet, fn) {\n if (!privateSet.has(receiver)) throw new TypeError(\"attempted to get private field on non-instance\");\n\n return fn;\n}\nexport { _class_private_method_get as _ };\n","import { _check_private_redeclaration } from \"./_check_private_redeclaration.js\";\n\nexport function _class_private_method_init(obj, privateSet) {\n _check_private_redeclaration(obj, privateSet);\n privateSet.add(obj);\n}\nexport { _class_private_method_init as _ };\n","export function _check_private_redeclaration(obj, privateCollection) {\n if (privateCollection.has(obj)) {\n throw new TypeError(\"Cannot initialize the same private elements twice on an object\");\n }\n}\nexport { _check_private_redeclaration 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","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 _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","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","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 _type_of(obj) {\n \"@swc/helpers - typeof\";\n\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nexport { _type_of as _ };\n"],"names":["$ac6739cbe5bf1c84$export$ccedaf978f62b9dd","receiver","privateSet","fn","has","TypeError","$ea91727f98d0802f$export$1002c20f28174dbf","obj","privateCollection","add","$4fc75ccb937ab1df$var$_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","$c3b10a83b523f372$export$79e617b1955a2616","arr","len","arr2","Array","$227c6742e0ff6f82$export$1b5e630bc3aea29f","isArray","iter","Symbol","iterator","from","o","minLen","n","prototype","toString","call","slice","constructor","name","test","$3d28d7f1aac198f5$var$_createEmptyState","WeakSet","$3d28d7f1aac198f5$var$_getEmptyCells","$3d28d7f1aac198f5$var$_addRandomTile","$3d28d7f1aac198f5$var$_mergeCells","$3d28d7f1aac198f5$var$_transpose","$3d28d7f1aac198f5$var$_willStateChange","$3d28d7f1aac198f5$var$_isWin","$3d28d7f1aac198f5$var$_isLose","$3d28d7f1aac198f5$var$_handleMove","$3d28d7f1aac198f5$var$createEmptyState","fill","$3d28d7f1aac198f5$var$getEmptyCells","emptyCells","state","forEach","row","rowIndex","cell","cellIndex","push","$3d28d7f1aac198f5$var$addRandomTile","randomCell","Math","floor","random","$3d28d7f1aac198f5$var$mergeCells","mergedRow","filter","newRow","score","apply","$3d28d7f1aac198f5$var$transpose","matrix","map","_","colIndex","$3d28d7f1aac198f5$var$willStateChange","newState","JSON","stringify","$3d28d7f1aac198f5$var$isWin","status","some","includes","$3d28d7f1aac198f5$var$isLose","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","next","done","_ret","_loop","value","v","err","return","c","$3d28d7f1aac198f5$var$handleMove","$197cd56b15c33885$var$game","protoProps","staticProps","Game","initialState","arguments","instance","Constructor","_this","reversedRow","reverse","transposedState","$197cd56b15c33885$var$startButton","document","querySelector","$197cd56b15c33885$var$updateTable","gameState","getState","tbody","table","innerHTML","tr","createElement","className","j","td","textContent","concat","appendChild","$197cd56b15c33885$var$updateScore","gameScore","innerText","getScore","$197cd56b15c33885$var$handleMessages","action","type","startMessage","winMessage","loseMessage","classList","remove","$197cd56b15c33885$var$updateGame","$197cd56b15c33885$var$handleGameStatus","getStatus","addEventListener","start","restart","e","moveLeft","moveRight","moveUp","moveDown"],"version":3,"file":"index.83f2c579.js.map"} \ No newline at end of file diff --git a/index.971c2ea4.css b/index.971c2ea4.css new file mode 100644 index 000000000..3fe31ab5e --- /dev/null +++ b/index.971c2ea4.css @@ -0,0 +1,189 @@ +body { + background: #fbf8ef; + justify-content: center; + align-items: center; + min-height: 100vh; + margin: 0; + font-family: sans-serif; + font-size: 24px; + font-weight: 900; + display: flex; +} + +.field-cell { + color: #776e65; + box-sizing: border-box; + text-align: center; + vertical-align: center; + -webkit-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; + justify-content: space-between; + width: 100%; + margin-bottom: 24px; + padding: 10px; + display: flex; +} + +h1 { + color: #f9f6f2; + box-sizing: border-box; + background: #edc22e; + border-radius: 5px; + justify-content: center; + align-items: center; + width: 75px; + height: 75px; + margin: 0; + font-size: 24px; + display: flex; +} + +.info { + color: #776e65; + box-sizing: border-box; + background: #d6cdc4; + border-radius: 5px; + flex-direction: column; + justify-content: center; + align-items: center; + width: 75px; + height: 75px; + margin: 0 8px 0 0; + font-size: 16px; + display: flex; +} + +.controls { + 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 { + flex-direction: column; + align-items: center; + width: 350px; + display: flex; +} + +.message-win { + color: #f9f6f2; + background: #edc22e; +} + +.message-container { + width: 100%; + height: 150px; +} + +/*# sourceMappingURL=index.971c2ea4.css.map */ diff --git a/index.971c2ea4.css.map b/index.971c2ea4.css.map new file mode 100644 index 000000000..e797e1bb7 --- /dev/null +++ b/index.971c2ea4.css.map @@ -0,0 +1 @@ +{"mappings":"AAAA;;;;;;;;;;;;AAYA;;;;;;;;;;;;;AAWE;;;;AAIA;;;;AAIA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAMF;;;;;;AAMA;;;;;;;;;AASA;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;AAeA;;;;AAIA;;;;;;;;;;;;;AAcA;;;;;AAIE;;;;AAKF;;;;AAGE;;;;AAKF;;;;;;;;;;;AAWA;;;;AAIA;;;;;;;AAOA;;;;;AAKA","sources":["src/styles/main.scss"],"sourcesContent":["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.971c2ea4.css.map","sourceRoot":"/__parcel_source_root/"} \ No newline at end of file diff --git a/index.b8fca702.js b/index.b8fca702.js new file mode 100644 index 000000000..e25bfcb9f --- /dev/null +++ b/index.b8fca702.js @@ -0,0 +1,903 @@ +// modules are defined as an array +// [ module function, map of requires ] +// +// map of requires is short require name -> numeric require +// +// anything defined in a previous bundle is accessed via the +// orig method which is the require for previous bundles + +(function (modules, entry, mainEntry, parcelRequireName, globalName) { + /* eslint-disable no-undef */ + var globalObject = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; + /* eslint-enable no-undef */ + + // Save the require from previous bundle to this closure if any + var previousRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + + var cache = previousRequire.cache || {}; + // Do not use `require` to prevent Webpack from trying to bundle this call + var nodeRequire = + typeof module !== 'undefined' && + typeof module.require === 'function' && + module.require.bind(module); + + function newRequire(name, jumped) { + if (!cache[name]) { + if (!modules[name]) { + // if we cannot find the module within our internal map or + // cache jump to the current global require ie. the last bundle + // that was added to the page. + var currentRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + if (!jumped && currentRequire) { + return currentRequire(name, true); + } + + // If there are other bundles on this page the require from the + // previous one is saved to 'previousRequire'. Repeat this as + // many times as there are bundles until the module is found or + // we exhaust the require chain. + if (previousRequire) { + return previousRequire(name, true); + } + + // Try the node require function if it exists. + if (nodeRequire && typeof name === 'string') { + return nodeRequire(name); + } + + var err = new Error("Cannot find module '" + name + "'"); + err.code = 'MODULE_NOT_FOUND'; + throw err; + } + + localRequire.resolve = resolve; + localRequire.cache = {}; + + var module = (cache[name] = new newRequire.Module(name)); + + modules[name][0].call( + module.exports, + localRequire, + module, + module.exports, + this + ); + } + + return cache[name].exports; + + function localRequire(x) { + var res = localRequire.resolve(x); + return res === false ? {} : newRequire(res); + } + + function resolve(x) { + var id = modules[name][1][x]; + return id != null ? id : x; + } + } + + function Module(moduleName) { + this.id = moduleName; + this.bundle = newRequire; + this.exports = {}; + } + + newRequire.isParcelRequire = true; + newRequire.Module = Module; + newRequire.modules = modules; + newRequire.cache = cache; + newRequire.parent = previousRequire; + newRequire.register = function (id, exports) { + modules[id] = [ + function (require, module) { + module.exports = exports; + }, + {}, + ]; + }; + + Object.defineProperty(newRequire, 'root', { + get: function () { + return globalObject[parcelRequireName]; + }, + }); + + globalObject[parcelRequireName] = newRequire; + + for (var i = 0; i < entry.length; i++) { + newRequire(entry[i]); + } + + if (mainEntry) { + // Expose entry point to Node, AMD or browser globals + // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js + var mainExports = newRequire(mainEntry); + + // CommonJS + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = mainExports; + + // RequireJS + } else if (typeof define === 'function' && define.amd) { + define(function () { + return mainExports; + }); + + // + +