diff --git a/backend/uno-game-engine/deck.ts b/backend/uno-game-engine/deck.ts index 068916b..0567ba5 100644 --- a/backend/uno-game-engine/deck.ts +++ b/backend/uno-game-engine/deck.ts @@ -1,5 +1,5 @@ const colors: Array = ['red', 'yellow', 'green', 'blue']; -const values = [ +const numValues: Array = [ '0', '1', '2', @@ -10,12 +10,10 @@ const values = [ '7', '8', '9', - 'skip', - 'reverse', - 'draw2', ]; -const specialCards = ['wild', 'draw4']; -const deck = []; +const specialValues: Array = ['skip', 'reverse', 'draw2']; +const wildCardValue: Array = ['colchange', 'draw4']; +const deck: Array = []; /** * In a standard UNO deck, there are 108 cards. Here's the breakdown: @@ -41,11 +39,27 @@ const deck = []; @returns {Array} deck - An array of 108 UNO cards. */ export function getShuffledCardDeck(): Array { - const deck = []; - // todo: Implement the card generation logic - // dummy code: - // deck.push(makeCard('special', 'wild', 'wild')) - // deck.push(makeCard('number', 'red', '0')) + const deck: Array = []; + + colors.forEach((color) => { + numValues.forEach((value) => { + deck.push(makeCard('number', color, value)); + if (value !== '0') { + deck.push(makeCard('number', color, value)); + } + }); + specialValues.forEach((value) => { + deck.push(makeCard('special', color, value)); + deck.push(makeCard('special', color, value)); + }); + if (color === 'black') { + wildCardValue.forEach((value) => { + for (let i = 0; i < 4; i++) { + deck.push(makeCard('wild', color, value)); + } + }); + } + }); shuffle(deck); return deck; diff --git a/backend/uno-game-engine/types.d.ts b/backend/uno-game-engine/types.d.ts index 7c281f2..30fc8c0 100644 --- a/backend/uno-game-engine/types.d.ts +++ b/backend/uno-game-engine/types.d.ts @@ -1,6 +1,6 @@ type CardType = 'number' | 'special' | 'wild'; -type CardColor = 'red' | 'blue' | 'green' | 'yellow'; +type CardColor = 'red' | 'blue' | 'green' | 'yellow' | 'black'; type SpecialCardNames = 'skip' | 'reverse' | 'draw2' | 'draw4' | 'colchange'; type CardNumbers = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';