diff --git a/.gitignore b/.gitignore index 8e27764..953dc60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules frontend/node_modules -.env +.env \ No newline at end of file diff --git a/backend/uno-game-engine/deck.js b/backend/uno-game-engine/deck.js index e094a7d..3f32bf2 100644 --- a/backend/uno-game-engine/deck.js +++ b/backend/uno-game-engine/deck.js @@ -70,5 +70,10 @@ function makeCard(type, color, value) { */ function shuffle(deck) { //todo: Implement a generic shuffling algorithm - [deck[0], deck[1]] = [deck[1], deck[0]]; + + // Fisher-Yates shuffle algorithm + for (let i = deck.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * i); + [deck[i], deck[j]] = [deck[j], deck[i]]; + } } \ No newline at end of file