Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Deck of Cards - Portuguese
- class Card{
- constructor(suit, value){
- this.suit = suit
- this.value = value
- }
- }
- class Deck{
- constructor(){
- this.deck = []
- }
- createDeck(suits, values){
- for(let suit of suits){
- for(let value of values){
- this.deck.push(new Card(suit, value))
- }
- }
- this.deck.push(new Card('Curinga', 'Curinga'))
- this.deck.push(new Card('Curinga', 'Curinga'))
- return this.deck
- }
- shuffle(){
- }
- deal(){
- let hand = [];
- while(hand.length<2){
- hand.push(this.deck.pop());
- }
- return hand
- }
- }
- let suits = ['Copas', 'Ouros', 'Paus', 'Espadas']
- let values = [2,3,4,5,6,7,8,9,10,'Valete', 'Dama', 'Rei', 'Ás']
- let deck = new Deck();
- deck.createDeck(suits, values)
- console.log(deck)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement