Added card images
BIN
client/src/assets/card-back.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
client/src/assets/cards-front/0B.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
client/src/assets/cards-front/0G.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
client/src/assets/cards-front/0R.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
client/src/assets/cards-front/0Y.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/1B.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
client/src/assets/cards-front/1G.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
client/src/assets/cards-front/1R.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
client/src/assets/cards-front/1Y.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
client/src/assets/cards-front/2B.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/2G.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
client/src/assets/cards-front/2R.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/2Y.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
client/src/assets/cards-front/3B.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/3G.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/3R.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/3Y.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
client/src/assets/cards-front/4B.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
client/src/assets/cards-front/4G.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/4R.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/4Y.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
client/src/assets/cards-front/5B.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/5G.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
client/src/assets/cards-front/5R.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/5Y.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
client/src/assets/cards-front/6B.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/6G.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/6R.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/6Y.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
client/src/assets/cards-front/7B.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
client/src/assets/cards-front/7G.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/7R.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/7Y.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
client/src/assets/cards-front/8B.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/8G.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
client/src/assets/cards-front/8R.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
client/src/assets/cards-front/8Y.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
client/src/assets/cards-front/9B.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/9G.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
client/src/assets/cards-front/9R.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/src/assets/cards-front/9Y.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
client/src/assets/cards-front/D2B.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
client/src/assets/cards-front/D2G.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
client/src/assets/cards-front/D2R.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
client/src/assets/cards-front/D2Y.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
client/src/assets/cards-front/D4W.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
client/src/assets/cards-front/W.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
client/src/assets/cards-front/revB.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
client/src/assets/cards-front/revG.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
client/src/assets/cards-front/revR.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
client/src/assets/cards-front/revY.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
client/src/assets/cards-front/skipB.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
client/src/assets/cards-front/skipG.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
client/src/assets/cards-front/skipR.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
client/src/assets/cards-front/skipY.png
Normal file
After Width: | Height: | Size: 22 KiB |
@ -71,10 +71,10 @@ const Game = (props) => {
|
|||||||
let startingCardIndex
|
let startingCardIndex
|
||||||
while(true) {
|
while(true) {
|
||||||
startingCardIndex = Math.floor(Math.random() * 94)
|
startingCardIndex = Math.floor(Math.random() * 94)
|
||||||
if(shuffledCards[startingCardIndex]==='skipR' || shuffledCards[startingCardIndex]==='#R' || shuffledCards[startingCardIndex]==='D2R' ||
|
if(shuffledCards[startingCardIndex]==='skipR' || shuffledCards[startingCardIndex]==='revR' || shuffledCards[startingCardIndex]==='D2R' ||
|
||||||
shuffledCards[startingCardIndex]==='skipG' || shuffledCards[startingCardIndex]==='#G' || shuffledCards[startingCardIndex]==='D2G' ||
|
shuffledCards[startingCardIndex]==='skipG' || shuffledCards[startingCardIndex]==='revG' || shuffledCards[startingCardIndex]==='D2G' ||
|
||||||
shuffledCards[startingCardIndex]==='skipB' || shuffledCards[startingCardIndex]==='#B' || shuffledCards[startingCardIndex]==='D2B' ||
|
shuffledCards[startingCardIndex]==='skipB' || shuffledCards[startingCardIndex]==='revB' || shuffledCards[startingCardIndex]==='D2B' ||
|
||||||
shuffledCards[startingCardIndex]==='skipY' || shuffledCards[startingCardIndex]==='#Y' || shuffledCards[startingCardIndex]==='D2Y' ||
|
shuffledCards[startingCardIndex]==='skipY' || shuffledCards[startingCardIndex]==='revY' || shuffledCards[startingCardIndex]==='D2Y' ||
|
||||||
shuffledCards[startingCardIndex]==='W' || shuffledCards[startingCardIndex]==='D4W') {
|
shuffledCards[startingCardIndex]==='W' || shuffledCards[startingCardIndex]==='D4W') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ const Game = (props) => {
|
|||||||
const cardPlayedBy = turn
|
const cardPlayedBy = turn
|
||||||
switch(played_card) {
|
switch(played_card) {
|
||||||
//if card played was a number card
|
//if card played was a number card
|
||||||
case '0R': case '1R': case '2R': case '3R': case '4R': case '5R': case '6R': case '7R': case '8R': case '9R': case '#R': case '0G': case '1G': case '2G': case '3G': case '4G': case '5G': case '6G': case '7G': case '8G': case '9G': case '#G': case '0B': case '1B': case '2B': case '3B': case '4B': case '5B': case '6B': case '7B': case '8B': case '9B': case '#B': case '0Y': case '1Y': case '2Y': case '3Y': case '4Y': case '5Y': case '6Y': case '7Y': case '8Y': case '9Y': case '#Y': {
|
case '0R': case '1R': case '2R': case '3R': case '4R': case '5R': case '6R': case '7R': case '8R': case '9R': case 'revR': case '0G': case '1G': case '2G': case '3G': case '4G': case '5G': case '6G': case '7G': case '8G': case '9G': case 'revG': case '0B': case '1B': case '2B': case '3B': case '4B': case '5B': case '6B': case '7B': case '8B': case '9B': case 'revB': case '0Y': case '1Y': case '2Y': case '3Y': case '4Y': case '5Y': case '6Y': case '7Y': case '8Y': case '9Y': case 'revY': {
|
||||||
//extract number and color of played card
|
//extract number and color of played card
|
||||||
const numberOfPlayedCard = played_card.charAt(0)
|
const numberOfPlayedCard = played_card.charAt(0)
|
||||||
const colorOfPlayedCard = played_card.charAt(1)
|
const colorOfPlayedCard = played_card.charAt(1)
|
||||||
@ -708,35 +708,69 @@ const Game = (props) => {
|
|||||||
{gameOver ? <div>{winner !== '' && <><h1>GAME OVER</h1><h2>{winner} wins!</h2></>}<a href='/'>Home</a></div> :
|
{gameOver ? <div>{winner !== '' && <><h1>GAME OVER</h1><h2>{winner} wins!</h2></>}<a href='/'>Home</a></div> :
|
||||||
<div className='Game'>
|
<div className='Game'>
|
||||||
<h1>Turn: {turn}</h1>
|
<h1>Turn: {turn}</h1>
|
||||||
{currentUser === 'Player 1' &&
|
|
||||||
|
{currentUser === 'Player 1' && <>
|
||||||
<div className='player1Deck' style={turn === 'Player 1' ? null : {pointerEvents: 'none'}}>
|
<div className='player1Deck' style={turn === 'Player 1' ? null : {pointerEvents: 'none'}}>
|
||||||
{player1Deck.map((item) => (
|
{player1Deck.map((item) => (
|
||||||
<span
|
<img
|
||||||
onClick={() => onCardPlayedHandler(item)}
|
onClick={() => onCardPlayedHandler(item)}
|
||||||
className='card'>
|
src={require(`../assets/cards-front/${item}.png`).default}
|
||||||
{item}
|
width='100px'
|
||||||
</span>
|
/>
|
||||||
))}
|
))}
|
||||||
<button onClick={onCardDrawnHandler}>DRAW CARD</button>
|
<button onClick={onCardDrawnHandler}>DRAW CARD</button>
|
||||||
</div> }
|
|
||||||
<hr />
|
|
||||||
<div>
|
|
||||||
<h1>Current Card: {playedCardsPile[playedCardsPile.length-1]}</h1>
|
|
||||||
<h2>Current Color: {currentColor}</h2>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
{currentUser === 'Player 2' &&
|
<div>
|
||||||
|
{playedCardsPile && playedCardsPile.length>0 &&
|
||||||
|
<img
|
||||||
|
src={require(`../assets/cards-front/${playedCardsPile[playedCardsPile.length-1]}.png`).default}
|
||||||
|
width='100px'
|
||||||
|
/> }
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
<div className='player2Deck' style={turn === 'Player 1' ? {pointerEvents: 'none'} : null}>
|
<div className='player2Deck' style={turn === 'Player 1' ? {pointerEvents: 'none'} : null}>
|
||||||
{player2Deck.map((item) => (
|
{player2Deck.map((item) => (
|
||||||
<span
|
<img
|
||||||
onClick={() => onCardPlayedHandler(item)}
|
onClick={() => onCardPlayedHandler(item)}
|
||||||
className='card'>
|
src={require(`../assets/card-back.png`).default}
|
||||||
{item}
|
width='100px'
|
||||||
</span>
|
/>
|
||||||
))}
|
))}
|
||||||
<button onClick={onCardDrawnHandler}>DRAW CARD</button>
|
<button onClick={onCardDrawnHandler}>DRAW CARD</button>
|
||||||
</div> }
|
</div> </> }
|
||||||
|
|
||||||
|
{currentUser === 'Player 2' && <>
|
||||||
|
<div className='player1Deck' style={turn === 'Player 1' ? null : {pointerEvents: 'none'}}>
|
||||||
|
{player1Deck.map((item) => (
|
||||||
|
<img
|
||||||
|
onClick={() => onCardPlayedHandler(item)}
|
||||||
|
src={require(`../assets/card-back.png`).default}
|
||||||
|
width='100px'
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
<button onClick={onCardDrawnHandler}>DRAW CARD</button>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div>
|
||||||
|
{playedCardsPile && playedCardsPile.length>0 &&
|
||||||
|
<img
|
||||||
|
src={require(`../assets/cards-front/${playedCardsPile[playedCardsPile.length-1]}.png`).default}
|
||||||
|
width='100px'
|
||||||
|
/> }
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div className='player2Deck' style={turn === 'Player 1' ? {pointerEvents: 'none'} : null}>
|
||||||
|
{player2Deck.map((item) => (
|
||||||
|
<img
|
||||||
|
onClick={() => onCardPlayedHandler(item)}
|
||||||
|
src={require(`../assets/cards-front/${item}.png`).default}
|
||||||
|
width='100px'
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
<button onClick={onCardDrawnHandler}>DRAW CARD</button>
|
||||||
|
</div> </> }
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
<a href='/'>Home</a>
|
<a href='/'>Home</a>
|
||||||
</div> }
|
</div> }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//pack of 108 cards (# = reverse)
|
//pack of 108 cards
|
||||||
export default [
|
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',
|
'0R', '1R', '1R', '2R', '2R', '3R', '3R', '4R', '4R', '5R', '5R', '6R', '6R', '7R', '7R', '8R', '8R', '9R', '9R', 'skipR', 'skipR', 'revR', 'revR', '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',
|
'0G', '1G', '1G', '2G', '2G', '3G', '3G', '4G', '4G', '5G', '5G', '6G', '6G', '7G', '7G', '8G', '8G', '9G', '9G', 'skipG', 'skipG', 'revG', 'revG', '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',
|
'0B', '1B', '1B', '2B', '2B', '3B', '3B', '4B', '4B', '5B', '5B', '6B', '6B', '7B', '7B', '8B', '8B', '9B', '9B', 'skipB', 'skipB', 'revB', 'revB', 'D2B', 'D2B',
|
||||||
'0Y', '1Y', '1Y', '2Y', '2Y', '3Y', '3Y', '4Y', '4Y', '5Y', '5Y', '6Y', '6Y', '7Y', '7Y', '8Y', '8Y', '9Y', '9Y', 'skipY', 'skipY', '#Y', '#Y', 'D2Y', 'D2Y',
|
'0Y', '1Y', '1Y', '2Y', '2Y', '3Y', '3Y', '4Y', '4Y', '5Y', '5Y', '6Y', '6Y', '7Y', '7Y', '8Y', '8Y', '9Y', '9Y', 'skipY', 'skipY', 'revY', 'revY', 'D2Y', 'D2Y',
|
||||||
'W', 'W', 'W', 'W', 'D4W', 'D4W', 'D4W', 'D4W'
|
'W', 'W', 'W', 'W', 'D4W', 'D4W', 'D4W', 'D4W'
|
||||||
]
|
]
|