Advertisement
erielrj

Untitled

Dec 16th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Deck of Cards - Portuguese
  2.  
  3. class Card{
  4.     constructor(suit, value){
  5.         this.suit = suit
  6.         this.value = value
  7.     }
  8. }
  9.  
  10. class Deck{
  11.     constructor(){
  12.         this.deck = []
  13.     }
  14.  
  15.     createDeck(suits, values){
  16.         for(let suit of suits){
  17.             for(let value of values){
  18.                 this.deck.push(new Card(suit, value))
  19.             }
  20.         }
  21.        
  22.         this.deck.push(new Card('Curinga', 'Curinga'))
  23.         this.deck.push(new Card('Curinga', 'Curinga'))
  24.        
  25.         return this.deck
  26.        
  27.     }
  28.  
  29.     shuffle(){
  30.        
  31.     }
  32.  
  33.     deal(){
  34.         let hand = [];
  35.         while(hand.length<2){
  36.             hand.push(this.deck.pop());
  37.         }
  38.         return hand
  39.     }
  40.  
  41.  
  42.  
  43. }
  44.  
  45. let suits = ['Copas', 'Ouros', 'Paus', 'Espadas']
  46. let values = [2,3,4,5,6,7,8,9,10,'Valete', 'Dama', 'Rei', 'Ás']
  47. let deck = new Deck();
  48.  
  49. deck.createDeck(suits, values)
  50. console.log(deck)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement