From 8b12e81206bcff46970f00d1c6da8025c7af5487 Mon Sep 17 00:00:00 2001 From: Mizanali Panjwani Date: Wed, 17 Feb 2021 07:04:27 +0530 Subject: [PATCH] Improvements and bug fixes --- src/components/Game.js | 20 ++++++++++++-------- src/components/Homepage.js | 14 +++----------- src/utils/packOfCards.js | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/components/Game.js b/src/components/Game.js index 58c9d2c..a6fcd86 100644 --- a/src/components/Game.js +++ b/src/components/Game.js @@ -483,10 +483,12 @@ const Game = () => { setDrawCardPile([...copiedDrawCardPileArray]) } //else add the drawn card to player1's deck - //set new state - setTurn('Player 2') - setPlayer1Deck([...player1Deck.slice(0, player1Deck.length), drawCard, ...player1Deck.slice(player1Deck.length)]) - setDrawCardPile([...copiedDrawCardPileArray]) + else { + //set new state + setTurn('Player 2') + setPlayer1Deck([...player1Deck.slice(0, player1Deck.length), drawCard, ...player1Deck.slice(player1Deck.length)]) + setDrawCardPile([...copiedDrawCardPileArray]) + } } else { //remove 1 new card from drawCardPile and add it to player2's deck (immutably) @@ -557,10 +559,12 @@ const Game = () => { setDrawCardPile([...copiedDrawCardPileArray]) } //else add the drawn card to player2's deck - //set new state - setTurn('Player 1') - setPlayer2Deck([...player2Deck.slice(0, player2Deck.length), drawCard, ...player2Deck.slice(player2Deck.length)]) - setDrawCardPile([...copiedDrawCardPileArray]) + else { + //set new state + setTurn('Player 1') + setPlayer2Deck([...player2Deck.slice(0, player2Deck.length), drawCard, ...player2Deck.slice(player2Deck.length)]) + setDrawCardPile([...copiedDrawCardPileArray]) + } } } diff --git a/src/components/Homepage.js b/src/components/Homepage.js index 58fe20c..0819410 100644 --- a/src/components/Homepage.js +++ b/src/components/Homepage.js @@ -1,21 +1,13 @@ import React from 'react' import { Link } from 'react-router-dom' -import { START_GAME } from '../store/actions' -import { connect } from 'react-redux' -const Homepage = (props) => { +const Homepage = () => { return (

UNO

- +
) } -const mapDispatchToProps = (dispatch) => { - return { - onStartGame: () => dispatch({type: START_GAME}) - } -} - -export default connect(null, mapDispatchToProps)(Homepage) +export default Homepage diff --git a/src/utils/packOfCards.js b/src/utils/packOfCards.js index 9c45e21..ec3b40c 100644 --- a/src/utils/packOfCards.js +++ b/src/utils/packOfCards.js @@ -1,5 +1,5 @@ //pack of 108 cards (# = reverse) -export default CARDS = [ +export default [ '0R', '1R', '1R', '2R', '2R', '3R', '3R', '4R', '4R', '5R', '5R', '6R', '6R', '7R', '7R', '8R', '8R', '9R', '9R', 'skipR', 'skipR', '#R', '#R', 'D2R', 'D2R', '0G', '1G', '1G', '2G', '2G', '3G', '3G', '4G', '4G', '5G', '5G', '6G', '6G', '7G', '7G', '8G', '8G', '9G', '9G', 'skipG', 'skipG', '#G', '#G', 'D2G', 'D2G', '0B', '1B', '1B', '2B', '2B', '3B', '3B', '4B', '4B', '5B', '5B', '6B', '6B', '7B', '7B', '8B', '8B', '9B', '9B', 'skipB', 'skipB', '#B', '#B', 'D2B', 'D2B',