-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeck.rb
50 lines (40 loc) · 838 Bytes
/
deck.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#require 'card'
class Deck
SUITS = ['♠', '♣', '♥', '♦']
VALUES = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
def initialize
@deck = []
@p_hand = []
@d_hand = []
build_deck
end
def build_deck
SUITS.each do |suit|
VALUES.each do |value|
@deck.push(value + suit)
end
end
@deck.shuffle!
end
def initial_deal
2.times do
@p_hand << @deck.pop
@d_hand << @deck.pop
end
end
def display(gamer)
if gamer == :player
@p_hand.each do |card|
puts "#{gamer} was dealt #{card}"
end
elsif gamer == :dealer
@d_hand.each do |card|
puts "#{gamer} was dealt #{card}"
end
end
end
end
new_deck = Deck.new
new_deck.initial_deal
new_deck.display(:player)
new_deck.display(:dealer)