Skip to content

Commit

Permalink
shreyansh added a shuffle algo to the deck
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyansh200528 committed Jun 1, 2024
1 parent f05595c commit 848730b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/uno-game-engine/deck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,11 @@ export function makeCard(
*/
export function shuffle(deck: Array<any>) {

Check failure on line 77 in backend/uno-game-engine/deck.ts

View workflow job for this annotation

GitHub Actions / eslint-backend

Unexpected any. Specify a different type
//todo: Implement a generic shuffling algorithm
[deck[0], deck[1]] = [deck[1], deck[0]];
//[deck[0], deck[1]] = [deck[1], deck[0]];
for (var i = deck.length - 1; i > 0; i--) {

Check failure on line 80 in backend/uno-game-engine/deck.ts

View workflow job for this annotation

GitHub Actions / eslint-backend

Unexpected var, use let or const instead
var j = Math.floor(Math.random() * (i + 1));

Check failure on line 81 in backend/uno-game-engine/deck.ts

View workflow job for this annotation

GitHub Actions / eslint-backend

Unexpected var, use let or const instead
var temp = deck[i];

Check failure on line 82 in backend/uno-game-engine/deck.ts

View workflow job for this annotation

GitHub Actions / eslint-backend

Unexpected var, use let or const instead
deck[i] = deck[j];
deck[j] = temp;
}
}

0 comments on commit 848730b

Please sign in to comment.