This repository has been archived on 2021-10-15. You can view files and clone it, but cannot push or open issues or pull requests.
2020-coding-projects/uno/client/CardDeck.js
2020-05-05 22:35:48 +02:00

30 lines
620 B
JavaScript

import {
Card
} from "./Card.js";
export class CardDeck {
constructor() {
this.cards = [];
}
/**
* Returns a random card of this deck
* @returns {Card}
*/
getRandomCard() {
return this.cards[Math.floor(Math.random() * this.cards.length)];
}
}
export const cardDecks = [];
// Default card deck
const defaultDeck = new CardDeck();
const colors = ['RED', 'GREEN', 'BLUE', 'YELLOW'];
colors.forEach(color => {
for (let i = 0; i < 10; i++) {
defaultDeck.cards.push(new Card(color, i));
}
});
cardDecks.push(defaultDeck);