diff --git a/package.json b/package.json index 9e1db91..1856b8f 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": "https://ignatiusgabrieltan.github.io/high-card-bootcamp", "dependencies": { "gh-pages": "^3.2.3", "react": "^18.1.0", @@ -12,7 +12,7 @@ "scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d build", - "start": "react-scripts start", + "start": "WATCHPACK_POLLING=true react-scripts start", "build": "react-scripts build" }, "eslintConfig": { diff --git a/src/App.css b/src/App.css index 97b7c57..2f34581 100644 --- a/src/App.css +++ b/src/App.css @@ -1,5 +1,13 @@ .App { text-align: center; + background-color: rgb(153, 153, 211); + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: rgba(15, 15, 122, 0.622); } .App-logo { @@ -7,7 +15,26 @@ pointer-events: none; } -.App-header { +button { + width: 100px; + height: 30px; + background-color: rgba(15, 15, 122, 0.622); + color: rgb(215, 242, 152); + border-radius: 5px; +} + +.table-container { + border-radius: 20px; + padding: 0 50px; + color: rgba(15, 15, 122, 0.622); +} +h5 { + border: rgb(194, 138, 40) solid 1.5px; + background-color: rgb(215, 242, 152); + margin: 0; + padding: 5px 35px; +} +/* .App-header { background-color: #282c34; min-height: 100vh; display: flex; @@ -16,4 +43,4 @@ justify-content: center; font-size: calc(10px + 2vmin); color: white; -} +} */ diff --git a/src/App.js b/src/App.js index 899cefc..569d9ec 100644 --- a/src/App.js +++ b/src/App.js @@ -11,36 +11,166 @@ class App extends React.Component { cardDeck: makeShuffledDeck(), // currCards holds the cards from the current round currCards: [], + playerOneRoundScore: 0, + playerTwoRoundScore: 0, + tieRoundScore: 0, + playerOneGameScore: 0, + playerTwoGameScore: 0, + tieGameScore: 0, + winner: 0, + gameState: "START", }; } + //restart the game function.. + restartGame = () => { + this.setState({ + cardDeck: makeShuffledDeck(), + currCards: [], + playerOneRoundScore: 0, + playerTwoRoundScore: 0, + tieRoundScore: 0, + winner: 0, + gameState: "START", + }); + }; + dealCards = () => { // this.state.cardDeck.pop() modifies this.state.cardDeck array const newCurrCards = [this.state.cardDeck.pop(), this.state.cardDeck.pop()]; + let roundWinner = 0; + if (newCurrCards[0].rank > newCurrCards[1].rank) { + roundWinner = 1; + } else if (newCurrCards[0].rank < newCurrCards[1].rank) { + roundWinner = 2; + } else if (newCurrCards[0].rank === newCurrCards[1].rank) { + roundWinner = 3; + } this.setState({ currCards: newCurrCards, + gameState: "PLAY", + playerOneRoundScore: + roundWinner === 1 + ? this.state.playerOneRoundScore + 1 + : this.state.playerOneRoundScore, + playerTwoRoundScore: + roundWinner === 2 + ? this.state.playerTwoRoundScore + 1 + : this.state.playerTwoRoundScore, + tieRoundScore: + roundWinner === 3 + ? this.state.tieRoundScore + 1 + : this.state.tieRoundScore, + winner: roundWinner, }); }; - render() { - // You can write JavaScript here, just don't try and set your state! + //start of game + gameTitle = () => { + if (this.state.gameState === "START") { + return ( +