From 5f450339e18b4258ec6d5df80633bc316577cb1a Mon Sep 17 00:00:00 2001 From: llesterja Date: Sat, 22 Jul 2023 00:31:09 +0800 Subject: [PATCH 1/3] dealing 2 cards per player lol, can be used for blackjack next time --- src/App.js | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index 899cefc..e00a3d4 100644 --- a/src/App.js +++ b/src/App.js @@ -11,20 +11,48 @@ class App extends React.Component { cardDeck: makeShuffledDeck(), // currCards holds the cards from the current round currCards: [], + // comCards holds the cards for the dealer + comCards:[], + // player win, index 0 1 2 , win draw lose + playerWin:[0 ,0, 0] + }; } dealCards = () => { // this.state.cardDeck.pop() modifies this.state.cardDeck array const newCurrCards = [this.state.cardDeck.pop(), this.state.cardDeck.pop()]; + const newComCards = [this.state.cardDeck.pop(), this.state.cardDeck.pop()]; this.setState({ currCards: newCurrCards, + comCards: newComCards }); }; + restartGame = () =>{ + this.setState({ + cardDeck: makeShuffledDeck(), + // currCards holds the cards from the current round + currCards: [], + // comCards holds the cards for the dealer + comCards:[], + // player win, index 0 1 2 , win draw lose + playerWin:[0 ,0, 0] + }); + } +checkWin = () => { + if(this.state.cardDeck.length>=4){ + + } +} render() { // You can write JavaScript here, just don't try and set your state! - + const comCardElems = this.state.comCards.map(({ name, suit }) => ( + // Give each list element a unique key +
+ {name} of {suit} +
+ )); // You can access your current components state here, as indicated below const currCardElems = this.state.currCards.map(({ name, suit }) => ( // Give each list element a unique key @@ -32,14 +60,20 @@ class App extends React.Component { {name} of {suit} )); - + console.log(this.state.cardDeck.length) return (
-

High Card 🚀

+

High Card 🚀

+

Deck Remaining:
{this.state.cardDeck.length}

+ {this.state.cardDeck.length===52?

Press the deal button to start

:this.state.cardDeck.length<=3?

You won/lost

:

Current Score

} +
Dealer's Cards:
+ {comCardElems} +
+
My Cards:
{currCardElems}
- + {this.state.cardDeck.length<=3?:}
); From 4566e473ce77c8c7ea7024b8b774c816598f4a44 Mon Sep 17 00:00:00 2001 From: llesterja Date: Sat, 22 Jul 2023 12:19:35 +0800 Subject: [PATCH 2/3] high card fixed --- package-lock.json | 109 ++++++++++++++++++++++++++++++++++++---------- package.json | 8 +++- src/App.js | 72 +++++++++++++++++++----------- 3 files changed, 137 insertions(+), 52 deletions(-) diff --git a/package-lock.json b/package-lock.json index f8b2902..8270cf7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,10 +8,13 @@ "name": "high-card-bootcamp", "version": "0.1.0", "dependencies": { - "gh-pages": "^3.2.3", "react": "^18.1.0", "react-dom": "^18.1.0", + "react-icons": "^4.10.1", "react-scripts": "5.0.1" + }, + "devDependencies": { + "gh-pages": "^5.0.0" } }, "node_modules/@ampproject/remapping": { @@ -4126,6 +4129,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -5960,9 +5964,10 @@ "integrity": "sha512-oi3YPmaP87hiHn0c4ePB67tXaF+ldGhxvZnT19tW9zX6/Ej+pLN0Afja5rQ6S+TND7I9EuwQTT8JYn1k7R7rrw==" }, "node_modules/email-addresses": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-3.1.0.tgz", - "integrity": "sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg==" + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-5.0.0.tgz", + "integrity": "sha512-4OIPYlA6JXqtVn8zpHpGiI7vE6EQOAg16aGnDMIAlZVinnoZ8208tW1hAbjWydgN/4PLTT9q+O1K6AH/vALJGw==", + "dev": true }, "node_modules/emittery": { "version": "0.8.1", @@ -7091,6 +7096,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz", "integrity": "sha1-q/c9+rc10EVECr/qLZHzieu/oik=", + "dev": true, "engines": { "node": ">=4" } @@ -7099,6 +7105,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-4.3.0.tgz", "integrity": "sha512-hcFKyUG57yWGAzu1CMt/dPzYZuv+jAJUT85bL8mrXvNe6hWj6yEHEc4EdcgiA6Z3oi1/9wXJdZPXF2dZNgwgOg==", + "dev": true, "dependencies": { "filename-reserved-regex": "^2.0.0", "strip-outer": "^1.0.1", @@ -7547,13 +7554,14 @@ } }, "node_modules/gh-pages": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-3.2.3.tgz", - "integrity": "sha512-jA1PbapQ1jqzacECfjUaO9gV8uBgU6XNMV0oXLtfCX3haGLe5Atq8BxlrADhbD6/UdG9j6tZLWAkAybndOXTJg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-5.0.0.tgz", + "integrity": "sha512-Nqp1SjkPIB94Xw/3yYNTUL+G2dxlhjvv1zeN/4kMC1jfViTEqhtVz/Ba1zSXHuvXCN9ADNS1dN4r5/J/nZWEQQ==", + "dev": true, "dependencies": { - "async": "^2.6.1", + "async": "^3.2.4", "commander": "^2.18.0", - "email-addresses": "^3.0.1", + "email-addresses": "^5.0.0", "filenamify": "^4.3.0", "find-cache-dir": "^3.3.1", "fs-extra": "^8.1.0", @@ -7571,6 +7579,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, "dependencies": { "array-uniq": "^1.0.1" }, @@ -7578,15 +7587,23 @@ "node": ">=0.10.0" } }, + "node_modules/gh-pages/node_modules/async": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", + "dev": true + }, "node_modules/gh-pages/node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true }, "node_modules/gh-pages/node_modules/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -7600,6 +7617,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, "dependencies": { "array-union": "^1.0.1", "glob": "^7.0.3", @@ -7615,6 +7633,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -7623,6 +7642,7 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, "engines": { "node": ">= 4.0.0" } @@ -11593,6 +11613,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -11601,6 +11622,7 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -11609,6 +11631,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, "dependencies": { "pinkie": "^2.0.0" }, @@ -13245,6 +13268,14 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, + "node_modules/react-icons": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz", + "integrity": "sha512-/ngzDP/77tlCfqthiiGNZeYFACw85fUjZtLbedmJ5DTlNDIwETxhwBzdOJ21zj4iJdvc0J3y7yOsX3PpxAJzrw==", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -14366,6 +14397,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "dev": true, "dependencies": { "escape-string-regexp": "^1.0.2" }, @@ -14841,6 +14873,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", + "dev": true, "dependencies": { "escape-string-regexp": "^1.0.2" }, @@ -18921,7 +18954,8 @@ "array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=" + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true }, "array.prototype.flat": { "version": "1.3.0", @@ -20254,9 +20288,10 @@ "integrity": "sha512-oi3YPmaP87hiHn0c4ePB67tXaF+ldGhxvZnT19tW9zX6/Ej+pLN0Afja5rQ6S+TND7I9EuwQTT8JYn1k7R7rrw==" }, "email-addresses": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-3.1.0.tgz", - "integrity": "sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg==" + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-5.0.0.tgz", + "integrity": "sha512-4OIPYlA6JXqtVn8zpHpGiI7vE6EQOAg16aGnDMIAlZVinnoZ8208tW1hAbjWydgN/4PLTT9q+O1K6AH/vALJGw==", + "dev": true }, "emittery": { "version": "0.8.1", @@ -21090,12 +21125,14 @@ "filename-reserved-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz", - "integrity": "sha1-q/c9+rc10EVECr/qLZHzieu/oik=" + "integrity": "sha1-q/c9+rc10EVECr/qLZHzieu/oik=", + "dev": true }, "filenamify": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-4.3.0.tgz", "integrity": "sha512-hcFKyUG57yWGAzu1CMt/dPzYZuv+jAJUT85bL8mrXvNe6hWj6yEHEc4EdcgiA6Z3oi1/9wXJdZPXF2dZNgwgOg==", + "dev": true, "requires": { "filename-reserved-regex": "^2.0.0", "strip-outer": "^1.0.1", @@ -21396,13 +21433,14 @@ } }, "gh-pages": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-3.2.3.tgz", - "integrity": "sha512-jA1PbapQ1jqzacECfjUaO9gV8uBgU6XNMV0oXLtfCX3haGLe5Atq8BxlrADhbD6/UdG9j6tZLWAkAybndOXTJg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-5.0.0.tgz", + "integrity": "sha512-Nqp1SjkPIB94Xw/3yYNTUL+G2dxlhjvv1zeN/4kMC1jfViTEqhtVz/Ba1zSXHuvXCN9ADNS1dN4r5/J/nZWEQQ==", + "dev": true, "requires": { - "async": "^2.6.1", + "async": "^3.2.4", "commander": "^2.18.0", - "email-addresses": "^3.0.1", + "email-addresses": "^5.0.0", "filenamify": "^4.3.0", "find-cache-dir": "^3.3.1", "fs-extra": "^8.1.0", @@ -21413,19 +21451,28 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, "requires": { "array-uniq": "^1.0.1" } }, + "async": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", + "dev": true + }, "commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, "requires": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -21436,6 +21483,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, "requires": { "array-union": "^1.0.1", "glob": "^7.0.3", @@ -21448,6 +21496,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, "requires": { "graceful-fs": "^4.1.6" } @@ -21455,7 +21504,8 @@ "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true } } }, @@ -24328,17 +24378,20 @@ "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true }, "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, "requires": { "pinkie": "^2.0.0" } @@ -25384,6 +25437,12 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, + "react-icons": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.10.1.tgz", + "integrity": "sha512-/ngzDP/77tlCfqthiiGNZeYFACw85fUjZtLbedmJ5DTlNDIwETxhwBzdOJ21zj4iJdvc0J3y7yOsX3PpxAJzrw==", + "requires": {} + }, "react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -26219,6 +26278,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "dev": true, "requires": { "escape-string-regexp": "^1.0.2" } @@ -26573,6 +26633,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", + "dev": true, "requires": { "escape-string-regexp": "^1.0.2" } diff --git a/package.json b/package.json index 9e1db91..fcb9d17 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "private": true, "homepage": "https://rocketacademy.github.io/high-card-bootcamp", "dependencies": { - "gh-pages": "^3.2.3", "react": "^18.1.0", "react-dom": "^18.1.0", + "react-icons": "^4.10.1", "react-scripts": "5.0.1" }, "scripts": { @@ -30,6 +30,10 @@ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" - ] + ], + "homepage":"http://llesterja.github.io/high-card-bootcamp/" + }, + "devDependencies": { + "gh-pages": "^5.0.0" } } diff --git a/src/App.js b/src/App.js index e00a3d4..a6b0cf5 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,7 @@ import React from "react"; import "./App.css"; import { makeShuffledDeck } from "./utils.js"; +import {PiSmileyBold,PiSmileyMehBold,PiSmileySadBold} from 'react-icons/fa' class App extends React.Component { constructor(props) { @@ -13,46 +14,65 @@ class App extends React.Component { currCards: [], // comCards holds the cards for the dealer comCards:[], - // player win, index 0 1 2 , win draw lose - playerWin:[0 ,0, 0] - + // player win, index 0 1 2 > win draw lose + playerWin:[0 ,0, 0], + // current win message + currWinMsg:"" , }; } dealCards = () => { // this.state.cardDeck.pop() modifies this.state.cardDeck array const newCurrCards = [this.state.cardDeck.pop(), this.state.cardDeck.pop()]; - const newComCards = [this.state.cardDeck.pop(), this.state.cardDeck.pop()]; this.setState({ currCards: newCurrCards, - comCards: newComCards }); - }; + } restartGame = () =>{ this.setState({ cardDeck: makeShuffledDeck(), // currCards holds the cards from the current round currCards: [], // comCards holds the cards for the dealer - comCards:[], - // player win, index 0 1 2 , win draw lose - playerWin:[0 ,0, 0] + playerWin:[0 ,0, 0], }); } -checkWin = () => { - if(this.state.cardDeck.length>=4){ - - } - +displayScore = () =>{ + return
Wins: {this.state.playerWin[0]} Draws: {this.state.playerWin[1]} Losses: {this.state.playerWin[2]}
+} +checkCurrWin = () => { + const currWin = this.state.playerWin.map((x)=>(x)); + if (this.state.currCards[0].rank>this.state.currCards[1].rank){ + currWin[0] += 1; + this.setState({ + playerWin: currWin, + currWinMsg: "You won this round!" , + }); + } else if(this.state.currCards[0].rank===this.state.currCards[1].rank){ + currWin[1] += 1; + this.setState({ + playerWin: currWin, + currWinMsg: "You drew this round!", + }); + } else { + currWin[2] += 1; + this.setState({ + playerWin: currWin, + currWinMsg: "You lost this round!", + }); + }; + console.log("currwin:",currWin,"playerwin:",this.state.playerWin) +} +checkFinalWin = ()=>{ + if(this.state.playerWin[0] > this.state.playerWin[2]){ + return

You won!

+ }else if (this.state.playerWin[0] < this.state.playerWin[2]){ + return

You won!

+ } else { + return

It's a draw!

+ }; } render() { - // You can write JavaScript here, just don't try and set your state! - const comCardElems = this.state.comCards.map(({ name, suit }) => ( - // Give each list element a unique key -
- {name} of {suit} -
- )); // You can access your current components state here, as indicated below const currCardElems = this.state.currCards.map(({ name, suit }) => ( // Give each list element a unique key @@ -60,20 +80,20 @@ checkWin = () => { {name} of {suit} )); - console.log(this.state.cardDeck.length) + // console.log("playerWin:",this.state.playerWin,"currWin"); return (

High Card 🚀

Deck Remaining:
{this.state.cardDeck.length}

- {this.state.cardDeck.length===52?

Press the deal button to start

:this.state.cardDeck.length<=3?

You won/lost

:

Current Score

} + {this.state.cardDeck.length===52?

Press the deal button to start

:this.state.cardDeck.length<=1?

{this.checkFinalWin()}
Final Score: {this.displayScore()}

:

{this.state.currWinMsg}
Current Score:
{this.displayScore()}

}
Dealer's Cards:
- {comCardElems} + {currCardElems[1]}
My Cards:
- {currCardElems} + {currCardElems[0]}
- {this.state.cardDeck.length<=3?:} + {this.state.cardDeck.length<=1?:}
); From 55e30a922483f73ae74c4086afaba6fdc324520e Mon Sep 17 00:00:00 2001 From: llesterja Date: Tue, 1 Aug 2023 22:25:22 +0800 Subject: [PATCH 3/3] fix gh-pages --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fcb9d17..aa83a27 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "high-card-bootcamp", "version": "0.1.0", "private": true, - "homepage": "https://rocketacademy.github.io/high-card-bootcamp", + "homepage":"http://llesterja.github.io/high-card-bootcamp", "dependencies": { "react": "^18.1.0", "react-dom": "^18.1.0", @@ -30,8 +30,7 @@ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" - ], - "homepage":"http://llesterja.github.io/high-card-bootcamp/" + ] }, "devDependencies": { "gh-pages": "^5.0.0"