-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeck.rb
More file actions
executable file
·97 lines (70 loc) · 2.38 KB
/
deck.rb
File metadata and controls
executable file
·97 lines (70 loc) · 2.38 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require './card'
class Deck
attr_accessor :cards, :playeroneTotalMatches, :playertwoTotalMatches, :deck_size
def initialize(deck_size = 12)
if deck_size > 12
raise "Max size for deck is 12"
end
@deck_size = deck_size
#@cardValues = ["🦊","🦔","🦄","🦧","🐁","🐄"]
@cardValues = ["🦊","🦔","🦄","🦥","🦦","🐄"]
#@cardValues = ["☢","🦔","🦄","😈","🐧","🐄"]
@faceValueDown = "💎"
i = 0;
iterations = deck_size / 2
@cards = Array.new
until i >= iterations do
@cards.append(Card.new(@cardValues[i - 1],@faceValueDown))
@cards.append(Card.new(@cardValues[i - 1],@faceValueDown))
i += 1
end
cards.shuffle!
end
def display(rows = 4, cols = 3 )
gridSpace = " "
left_margin = " "
i = 0
outText = ""
row_start = 0
rCount = rows - 1
for z in 0...cols do
for i in 0...rows
print (i == 0 ? left_margin : "") + @cards[row_start + i].cardTop + gridSpace
end
print "\n"
for i in 0...rows
print (i == 0 ? left_margin : "") + @cards[row_start + i].cardFillLine + gridSpace
end
print "\n"
for i in 0...rows
print (i == 0 ? left_margin : "") + @cards[row_start + i].currentCardFace + gridSpace
end
print "\n"
for i in 0...rows
print (i == 0 ? left_margin : "") + @cards[row_start + i].cardFillLine + gridSpace
end
print "\n"
for i in 0...rows
print (i == 0 ? left_margin : "") + @cards[row_start + i].cardBottom + gridSpace
end
print "\n"
for i in 0...rows
card_number = row_start + i + 1
print (i == 0 ? left_margin : "") + card_number.to_s + " "
end
print "\n"
row_start = row_start + rows
end
end
def all_flipped
retval = true
cardLength = @cards.length - 1
for i in 0..cardLength
if !@cards[i].faceUp
retval = false;
break
end
end
return retval
end
end