Commit 879e6e8f authored by cc201010's avatar cc201010
Browse files

writing better JS "Clean code"

parent 73dbe4fa
......@@ -8,8 +8,9 @@
"name": "poke-app",
"version": "0.0.0",
"dependencies": {
"vue": "^3.2.16",
"vue-router": "^4.0.12"
"vue": "^3.2.23",
"vue-router": "^4.0.12",
"vuex": "^4.0.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.3",
......@@ -17,9 +18,9 @@
}
},
"node_modules/@babel/parser": {
"version": "7.16.3",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.3.tgz",
"integrity": "sha512-dcNwU1O4sx57ClvLBVFbEgx0UZWfd0JQX5X6fxFRCLHelFBGXFfSz6Y0FAq2PEwUqlqLkdVjVr4VASEOuUnLJw==",
"version": "7.16.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.4.tgz",
"integrity": "sha512-6V0qdPUaiVHH3RtZeLIsc+6pDhbYzHR8ogA8w+f+Wc77DuXto19g2QUwveINoS34Uw+W8/hQDGJCx+i4n7xcng==",
"bin": {
"parser": "bin/babel-parser.js"
},
......@@ -40,36 +41,36 @@
}
},
"node_modules/@vue/compiler-core": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.22.tgz",
"integrity": "sha512-uAkovrVeTcjzpiM4ECmVaMrv/bjdgAaLzvjcGqQPBEyUrcqsCgccT9fHJ/+hWVGhyMahmBwLqcn4guULNx7sdw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.23.tgz",
"integrity": "sha512-4ZhiI/orx+7EJ1B+0zjgvXMV2uRN+XBfG06UN2sJfND9rH5gtEQT3QmO4erum1o6Irl7y754W8/KSaDJh4EUQg==",
"dependencies": {
"@babel/parser": "^7.15.0",
"@vue/shared": "3.2.22",
"@vue/shared": "3.2.23",
"estree-walker": "^2.0.2",
"source-map": "^0.6.1"
}
},
"node_modules/@vue/compiler-dom": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.22.tgz",
"integrity": "sha512-VZdsw/VuO1ODs8K7NQwnMQzKITDkIFlYYC03SVnunuf6eNRxBPEonSyqbWNoo6qNaHAEBTG6VVcZC5xC9bAx1g==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.23.tgz",
"integrity": "sha512-X2Nw8QFc5lgoK3kio5ktM95nqmLUH+q+N/PbV4kCHzF1avqv/EGLnAhaaF0Iu4bewNvHJAAhhwPZFeoV/22nbw==",
"dependencies": {
"@vue/compiler-core": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-core": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"node_modules/@vue/compiler-sfc": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.22.tgz",
"integrity": "sha512-tWRQ5ge1tsTDhUwHgueicKJ8rYm6WUVAPTaIpFW3GSwZKcOEJ2rXdfkHFShNVGupeRALz2ET2H84OL0GeRxY0A==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.23.tgz",
"integrity": "sha512-Aw+pb50Q5zTjyvWod8mNKmYZDRGHJBptmNNWE+84ZxrzEztPgMz8cNYIzWGbwcFVkmJlhvioAMvKnB+LM/sjSA==",
"dependencies": {
"@babel/parser": "^7.15.0",
"@vue/compiler-core": "3.2.22",
"@vue/compiler-dom": "3.2.22",
"@vue/compiler-ssr": "3.2.22",
"@vue/ref-transform": "3.2.22",
"@vue/shared": "3.2.22",
"@vue/compiler-core": "3.2.23",
"@vue/compiler-dom": "3.2.23",
"@vue/compiler-ssr": "3.2.23",
"@vue/ref-transform": "3.2.23",
"@vue/shared": "3.2.23",
"estree-walker": "^2.0.2",
"magic-string": "^0.25.7",
"postcss": "^8.1.10",
......@@ -77,12 +78,12 @@
}
},
"node_modules/@vue/compiler-ssr": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.22.tgz",
"integrity": "sha512-Cl6aoLJtXzzBkk1sKod8S0WBJLts3+ugVC91d22gGpbkw/64WnF12tOZi7Rg54PPLi1NovqyNWPsLH/SAFcu+w==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.23.tgz",
"integrity": "sha512-Bqzn4jFyXPK1Ehqiq7e/czS8n62gtYF1Zfeu0DrR5uv+SBllh7LIvZjZU6+c8qbocAd3/T3I3gn2cZGmnDb6zg==",
"dependencies": {
"@vue/compiler-dom": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-dom": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"node_modules/@vue/devtools-api": {
......@@ -91,65 +92,65 @@
"integrity": "sha512-R2rfiRY+kZugzWh9ZyITaovx+jpU4vgivAEAiz80kvh3yviiTU3CBuGuyWpSwGz9/C7TkSWVM/FtQRGlZ16n8Q=="
},
"node_modules/@vue/reactivity": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.2.22.tgz",
"integrity": "sha512-xNkLAItjI0xB+lFeDgKCrSItmrHTaAzSnt8LmdSCPQnDyarmzbi/u4ESQnckWvlL7lSRKiEaOvblaNyqAa7OnQ==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.2.23.tgz",
"integrity": "sha512-8RGVr/5Kpgb/EkCjgHXqttgA5IMc6n0lIXFY4TVbMkzdXrvaIhzBd7Te44oIDsTSYVKZLpfHd6/wEnuDqE8vFw==",
"dependencies": {
"@vue/shared": "3.2.22"
"@vue/shared": "3.2.23"
}
},
"node_modules/@vue/ref-transform": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/ref-transform/-/ref-transform-3.2.22.tgz",
"integrity": "sha512-qalVWbq5xWWxLZ0L9OroBg/JZhzavQuCcDXblfErxyDEH6Xc5gIJ4feo1SVCICFzhAUgLgQTdSFLpgjBawbFpw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/ref-transform/-/ref-transform-3.2.23.tgz",
"integrity": "sha512-gW0GD2PSAs/th7mC7tPB/UwpIQxclbApVtsDtscDmOJXb2+cdu60ny+SuHNgfrlUT/JqWKQHq7jFKO4woxLNaA==",
"dependencies": {
"@babel/parser": "^7.15.0",
"@vue/compiler-core": "3.2.22",
"@vue/shared": "3.2.22",
"@vue/compiler-core": "3.2.23",
"@vue/shared": "3.2.23",
"estree-walker": "^2.0.2",
"magic-string": "^0.25.7"
}
},
"node_modules/@vue/runtime-core": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.2.22.tgz",
"integrity": "sha512-e7WOC55wmHPvmoVUk9VBe/Z9k5bJfWJfVIlkUkiADJn0bOgQD29oh/GS14Kb3aEJXIHLI17Em6+HxNut1sIh7Q==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.2.23.tgz",
"integrity": "sha512-wSI5lmY2kCGLf89iiygqxVh6/5bsawz78Me9n1x4U2bHnN0yf3PWyuhN0WgIE8VfEaF7e75E333uboNEIFjgkg==",
"dependencies": {
"@vue/reactivity": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/reactivity": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"node_modules/@vue/runtime-dom": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.2.22.tgz",
"integrity": "sha512-w7VHYJoliLRTLc5beN77wxuOjla4v9wr2FF22xpZFYBmH4U1V7HkYhoHc1BTuNghI15CXT1tNIMhibI1nrQgdw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.2.23.tgz",
"integrity": "sha512-z6lp0888NkLmxD9j2sGoll8Kb7J743s8s6w7GbiyUc4WZwm0KJ35B4qTFDMoIU0G7CatS6Z+yRTpPHc6srtByg==",
"dependencies": {
"@vue/runtime-core": "3.2.22",
"@vue/shared": "3.2.22",
"@vue/runtime-core": "3.2.23",
"@vue/shared": "3.2.23",
"csstype": "^2.6.8"
}
},
"node_modules/@vue/server-renderer": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.2.22.tgz",
"integrity": "sha512-jCwbQgKPXiXoH9VS9F7K+gyEvEMrjutannwEZD1R8fQ9szmOTqC+RRbIY3Uf2ibQjZtZ8DV9a4FjxICvd9zZlQ==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.2.23.tgz",
"integrity": "sha512-mgQ2VAE5WjeZELJKNbwE69uiBNpN+3LyL0ZDki1bJWVwHD2fhPfx7pwyYuiucE81xz2LxVsyGxhKKUL997g8vw==",
"dependencies": {
"@vue/compiler-ssr": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-ssr": "3.2.23",
"@vue/shared": "3.2.23"
},
"peerDependencies": {
"vue": "3.2.22"
"vue": "3.2.23"
}
},
"node_modules/@vue/shared": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.22.tgz",
"integrity": "sha512-qWVav014mpjEtbWbEgl0q9pEyrrIySKum8UVYjwhC6njrKzknLZPvfuYdQyVbApsqr94tf/3dP4pCuZmmjdCWQ=="
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.23.tgz",
"integrity": "sha512-U+/Jefa0QfXUF2qVy9Dqlrb6HKJSr9/wJcM66wXmWcTOoqg7hOWzF4qruDle51pyF4x3wMn6TSH54UdjKjCKMA=="
},
"node_modules/csstype": {
"version": "2.6.18",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.18.tgz",
"integrity": "sha512-RSU6Hyeg14am3Ah4VZEmeX8H7kLwEEirXe6aU2IPfKNvhXwTflK5HQRDNI0ypQXoqmm+QPyG2IaPuQE5zMwSIQ=="
"version": "2.6.19",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.19.tgz",
"integrity": "sha512-ZVxXaNy28/k3kJg0Fou5MiYpp88j7H9hLZp8PDC3jV0WFjfH5E9xHb56L0W59cPbKbcHXeP4qyT8PrHp8t6LcQ=="
},
"node_modules/esbuild": {
"version": "0.13.13",
......@@ -584,15 +585,15 @@
}
},
"node_modules/vue": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.2.22.tgz",
"integrity": "sha512-KD5nZpXVZquOC6926Xnp3zOvswrUyO9Rya7ZUoxWFQEjFDW4iACtwzubRB4Um2Om9kj6CaJOqAVRDSFlqLpdgw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.2.23.tgz",
"integrity": "sha512-MGp9JZC37lzGhwSu6c1tQxrQbXbw7XKFqtYh7SFwNrNK899FPxGAHwSHMZijMChTSC3uZrD2BGO/3EHOgMJ0cw==",
"dependencies": {
"@vue/compiler-dom": "3.2.22",
"@vue/compiler-sfc": "3.2.22",
"@vue/runtime-dom": "3.2.22",
"@vue/server-renderer": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-dom": "3.2.23",
"@vue/compiler-sfc": "3.2.23",
"@vue/runtime-dom": "3.2.23",
"@vue/server-renderer": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"node_modules/vue-router": {
......@@ -605,13 +606,24 @@
"peerDependencies": {
"vue": "^3.0.0"
}
},
"node_modules/vuex": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-4.0.2.tgz",
"integrity": "sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==",
"dependencies": {
"@vue/devtools-api": "^6.0.0-beta.11"
},
"peerDependencies": {
"vue": "^3.0.2"
}
}
},
"dependencies": {
"@babel/parser": {
"version": "7.16.3",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.3.tgz",
"integrity": "sha512-dcNwU1O4sx57ClvLBVFbEgx0UZWfd0JQX5X6fxFRCLHelFBGXFfSz6Y0FAq2PEwUqlqLkdVjVr4VASEOuUnLJw=="
"version": "7.16.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.4.tgz",
"integrity": "sha512-6V0qdPUaiVHH3RtZeLIsc+6pDhbYzHR8ogA8w+f+Wc77DuXto19g2QUwveINoS34Uw+W8/hQDGJCx+i4n7xcng=="
},
"@vitejs/plugin-vue": {
"version": "1.9.4",
......@@ -621,36 +633,36 @@
"requires": {}
},
"@vue/compiler-core": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.22.tgz",
"integrity": "sha512-uAkovrVeTcjzpiM4ECmVaMrv/bjdgAaLzvjcGqQPBEyUrcqsCgccT9fHJ/+hWVGhyMahmBwLqcn4guULNx7sdw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.23.tgz",
"integrity": "sha512-4ZhiI/orx+7EJ1B+0zjgvXMV2uRN+XBfG06UN2sJfND9rH5gtEQT3QmO4erum1o6Irl7y754W8/KSaDJh4EUQg==",
"requires": {
"@babel/parser": "^7.15.0",
"@vue/shared": "3.2.22",
"@vue/shared": "3.2.23",
"estree-walker": "^2.0.2",
"source-map": "^0.6.1"
}
},
"@vue/compiler-dom": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.22.tgz",
"integrity": "sha512-VZdsw/VuO1ODs8K7NQwnMQzKITDkIFlYYC03SVnunuf6eNRxBPEonSyqbWNoo6qNaHAEBTG6VVcZC5xC9bAx1g==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.23.tgz",
"integrity": "sha512-X2Nw8QFc5lgoK3kio5ktM95nqmLUH+q+N/PbV4kCHzF1avqv/EGLnAhaaF0Iu4bewNvHJAAhhwPZFeoV/22nbw==",
"requires": {
"@vue/compiler-core": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-core": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"@vue/compiler-sfc": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.22.tgz",
"integrity": "sha512-tWRQ5ge1tsTDhUwHgueicKJ8rYm6WUVAPTaIpFW3GSwZKcOEJ2rXdfkHFShNVGupeRALz2ET2H84OL0GeRxY0A==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.23.tgz",
"integrity": "sha512-Aw+pb50Q5zTjyvWod8mNKmYZDRGHJBptmNNWE+84ZxrzEztPgMz8cNYIzWGbwcFVkmJlhvioAMvKnB+LM/sjSA==",
"requires": {
"@babel/parser": "^7.15.0",
"@vue/compiler-core": "3.2.22",
"@vue/compiler-dom": "3.2.22",
"@vue/compiler-ssr": "3.2.22",
"@vue/ref-transform": "3.2.22",
"@vue/shared": "3.2.22",
"@vue/compiler-core": "3.2.23",
"@vue/compiler-dom": "3.2.23",
"@vue/compiler-ssr": "3.2.23",
"@vue/ref-transform": "3.2.23",
"@vue/shared": "3.2.23",
"estree-walker": "^2.0.2",
"magic-string": "^0.25.7",
"postcss": "^8.1.10",
......@@ -658,12 +670,12 @@
}
},
"@vue/compiler-ssr": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.22.tgz",
"integrity": "sha512-Cl6aoLJtXzzBkk1sKod8S0WBJLts3+ugVC91d22gGpbkw/64WnF12tOZi7Rg54PPLi1NovqyNWPsLH/SAFcu+w==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.23.tgz",
"integrity": "sha512-Bqzn4jFyXPK1Ehqiq7e/czS8n62gtYF1Zfeu0DrR5uv+SBllh7LIvZjZU6+c8qbocAd3/T3I3gn2cZGmnDb6zg==",
"requires": {
"@vue/compiler-dom": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-dom": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"@vue/devtools-api": {
......@@ -672,62 +684,62 @@
"integrity": "sha512-R2rfiRY+kZugzWh9ZyITaovx+jpU4vgivAEAiz80kvh3yviiTU3CBuGuyWpSwGz9/C7TkSWVM/FtQRGlZ16n8Q=="
},
"@vue/reactivity": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.2.22.tgz",
"integrity": "sha512-xNkLAItjI0xB+lFeDgKCrSItmrHTaAzSnt8LmdSCPQnDyarmzbi/u4ESQnckWvlL7lSRKiEaOvblaNyqAa7OnQ==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.2.23.tgz",
"integrity": "sha512-8RGVr/5Kpgb/EkCjgHXqttgA5IMc6n0lIXFY4TVbMkzdXrvaIhzBd7Te44oIDsTSYVKZLpfHd6/wEnuDqE8vFw==",
"requires": {
"@vue/shared": "3.2.22"
"@vue/shared": "3.2.23"
}
},
"@vue/ref-transform": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/ref-transform/-/ref-transform-3.2.22.tgz",
"integrity": "sha512-qalVWbq5xWWxLZ0L9OroBg/JZhzavQuCcDXblfErxyDEH6Xc5gIJ4feo1SVCICFzhAUgLgQTdSFLpgjBawbFpw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/ref-transform/-/ref-transform-3.2.23.tgz",
"integrity": "sha512-gW0GD2PSAs/th7mC7tPB/UwpIQxclbApVtsDtscDmOJXb2+cdu60ny+SuHNgfrlUT/JqWKQHq7jFKO4woxLNaA==",
"requires": {
"@babel/parser": "^7.15.0",
"@vue/compiler-core": "3.2.22",
"@vue/shared": "3.2.22",
"@vue/compiler-core": "3.2.23",
"@vue/shared": "3.2.23",
"estree-walker": "^2.0.2",
"magic-string": "^0.25.7"
}
},
"@vue/runtime-core": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.2.22.tgz",
"integrity": "sha512-e7WOC55wmHPvmoVUk9VBe/Z9k5bJfWJfVIlkUkiADJn0bOgQD29oh/GS14Kb3aEJXIHLI17Em6+HxNut1sIh7Q==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.2.23.tgz",
"integrity": "sha512-wSI5lmY2kCGLf89iiygqxVh6/5bsawz78Me9n1x4U2bHnN0yf3PWyuhN0WgIE8VfEaF7e75E333uboNEIFjgkg==",
"requires": {
"@vue/reactivity": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/reactivity": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"@vue/runtime-dom": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.2.22.tgz",
"integrity": "sha512-w7VHYJoliLRTLc5beN77wxuOjla4v9wr2FF22xpZFYBmH4U1V7HkYhoHc1BTuNghI15CXT1tNIMhibI1nrQgdw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.2.23.tgz",
"integrity": "sha512-z6lp0888NkLmxD9j2sGoll8Kb7J743s8s6w7GbiyUc4WZwm0KJ35B4qTFDMoIU0G7CatS6Z+yRTpPHc6srtByg==",
"requires": {
"@vue/runtime-core": "3.2.22",
"@vue/shared": "3.2.22",
"@vue/runtime-core": "3.2.23",
"@vue/shared": "3.2.23",
"csstype": "^2.6.8"
}
},
"@vue/server-renderer": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.2.22.tgz",
"integrity": "sha512-jCwbQgKPXiXoH9VS9F7K+gyEvEMrjutannwEZD1R8fQ9szmOTqC+RRbIY3Uf2ibQjZtZ8DV9a4FjxICvd9zZlQ==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.2.23.tgz",
"integrity": "sha512-mgQ2VAE5WjeZELJKNbwE69uiBNpN+3LyL0ZDki1bJWVwHD2fhPfx7pwyYuiucE81xz2LxVsyGxhKKUL997g8vw==",
"requires": {
"@vue/compiler-ssr": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-ssr": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"@vue/shared": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.22.tgz",
"integrity": "sha512-qWVav014mpjEtbWbEgl0q9pEyrrIySKum8UVYjwhC6njrKzknLZPvfuYdQyVbApsqr94tf/3dP4pCuZmmjdCWQ=="
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.23.tgz",
"integrity": "sha512-U+/Jefa0QfXUF2qVy9Dqlrb6HKJSr9/wJcM66wXmWcTOoqg7hOWzF4qruDle51pyF4x3wMn6TSH54UdjKjCKMA=="
},
"csstype": {
"version": "2.6.18",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.18.tgz",
"integrity": "sha512-RSU6Hyeg14am3Ah4VZEmeX8H7kLwEEirXe6aU2IPfKNvhXwTflK5HQRDNI0ypQXoqmm+QPyG2IaPuQE5zMwSIQ=="
"version": "2.6.19",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.19.tgz",
"integrity": "sha512-ZVxXaNy28/k3kJg0Fou5MiYpp88j7H9hLZp8PDC3jV0WFjfH5E9xHb56L0W59cPbKbcHXeP4qyT8PrHp8t6LcQ=="
},
"esbuild": {
"version": "0.13.13",
......@@ -991,15 +1003,15 @@
}
},
"vue": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.2.22.tgz",
"integrity": "sha512-KD5nZpXVZquOC6926Xnp3zOvswrUyO9Rya7ZUoxWFQEjFDW4iACtwzubRB4Um2Om9kj6CaJOqAVRDSFlqLpdgw==",
"version": "3.2.23",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.2.23.tgz",
"integrity": "sha512-MGp9JZC37lzGhwSu6c1tQxrQbXbw7XKFqtYh7SFwNrNK899FPxGAHwSHMZijMChTSC3uZrD2BGO/3EHOgMJ0cw==",
"requires": {
"@vue/compiler-dom": "3.2.22",
"@vue/compiler-sfc": "3.2.22",
"@vue/runtime-dom": "3.2.22",
"@vue/server-renderer": "3.2.22",
"@vue/shared": "3.2.22"
"@vue/compiler-dom": "3.2.23",
"@vue/compiler-sfc": "3.2.23",
"@vue/runtime-dom": "3.2.23",
"@vue/server-renderer": "3.2.23",
"@vue/shared": "3.2.23"
}
},
"vue-router": {
......@@ -1009,6 +1021,14 @@
"requires": {
"@vue/devtools-api": "^6.0.0-beta.18"
}
},
"vuex": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-4.0.2.tgz",
"integrity": "sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==",
"requires": {
"@vue/devtools-api": "^6.0.0-beta.11"
}
}
}
}
......@@ -7,8 +7,9 @@
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.2.16",
"vue-router": "^4.0.12"
"vue": "^3.2.23",
"vue-router": "^4.0.12",
"vuex": "^4.0.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.3",
......
function cardSymbol(suit) {
switch (suit) {
case 'CLUBS':
return '♣️';
case 'SPADES':
return '♠️';
case 'DIAMONDS':
return '♦️';
case 'HEARTS':
return '♥️';
default:
break;
}
}
export function createCleanCard({ value, suit, image }) {
// Here's a clean card object that has a nice symbol
return {
value,
image,
symbol: cardSymbol(suit),
};
}
export function validateGuess(card, nextGuess) {
const colors = {
SPADES: 'black',
HEARTS: 'red',
CLUBS: 'black',
DIAMONDS: 'red',
};
const cardColor = colors[card.suit];
return cardColor == nextGuess;
}
const API = 'https://deckofcardsapi.com/api/deck/new/shuffle/';
export function getDeckAPI() {
return API;
}
export function getCardAPI(deckId) {
return `https://deckofcardsapi.com/api/deck/${deckId}/draw/?count=1`;
}
import { createRouter, createWebHistory } from 'vue-router';
import Home from '@/pages/Home.vue';
import Pokedex from '@/pages/Pokedex.vue';
import Calculator from '@/pages/Calculator.vue'
import Guesser from '@/pages/Guesser.vue';
const routes = [
{ path: '/', component: Home },
{ path: '/pokedex', component: Pokedex },
{ path: '/calculator', component: Calculator },
{ path: '/guesser', component: Guesser },
];
// Here we create our own Vue Router Instance
// and define the paths we can then use.
const router = createRouter({
history: createWebHistory(),
routes,
});
export default router;
import {
validateGuess,
createCleanCard,
getCardAPI,
getDeckAPI,
} from '@/lib/game';
export default {
setNextGuess({ commit }, color) {
commit('setNextGuess', color);
},
async getDeck({ commit }) {
const { deck_id } = await fetch(getDeckAPI()).then((r) => r.json());
commit('setDeckId', deck_id);
},
async drawCard({ state, commit, getters }) {
const { cards } = await fetch(getCardAPI(state.guesser.deckId)).then((r) =>
r.json()
);
const card = cards[0];
// +1 the guess counter
commit('incrementGuesses');
// +1 the point counter if you guessed correctly
if (validateGuess(card, state.guesser.nextGuess)) {
commit('incrementPoints');
}
commit('pushNewCard', createCleanCard(card));
},
};
import { createStore } from 'vuex';
import mutations from './mutations';
import actions from './actions';
const store = createStore({
state() {
return {
guesser: {
deckId: undefined,
cards: [],
points: 0,
guesses: 0,
nextGuess: undefined,
},
};
},
mutations,
actions,
});
export default store;
export default {
incrementPoints(state) {
state.guesser.points++;
},
incrementGuesses(state) {
state.guesser.guesses++;
},
setDeckId(state, deckId) {
state.guesser.deckId = deckId;
},
setNextGuess(state, color) {
state.guesser.nextGuess = color;