twenty_one 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/README.md +1 -0
- data/lib/twenty_one/game.rb +38 -21
- data/lib/twenty_one/version.rb +1 -1
- data/twenty_one.gemspec +1 -1
- metadata +2 -8
- data/spec/lib/.ace_card_spec.rb.swp +0 -0
- data/spec/lib/.card_spec.rb.swp +0 -0
- data/spec/lib/.dealer_spec.rb.swp +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9cfee5231e54857206d116d44c444d2d10006bd
|
4
|
+
data.tar.gz: b81401a825b54688a9f6c91b61497610d517cfd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f500d48ab47fa41d67285ee66e4f3623abe1b339cdcb348d1672ff977df47283e316ede278734421527016e5b27c74cc43434fe012fe0a3e3db8931d390650
|
7
|
+
data.tar.gz: 0e14fabb5823a5e767e0b21cd331a56763d3a929b06b6104610e6b5e015d4dd32a43d4dac371dbc73d51863a8532c3ec6b00afec9c055226a7bf52e593ba47ad
|
data/.gitignore
CHANGED
data/README.md
CHANGED
data/lib/twenty_one/game.rb
CHANGED
@@ -14,7 +14,6 @@ module TwentyOne
|
|
14
14
|
def self.play
|
15
15
|
@playing = true
|
16
16
|
@phase = :bet
|
17
|
-
@player = Player.new "Alex"
|
18
17
|
|
19
18
|
shoe = []
|
20
19
|
|
@@ -24,56 +23,69 @@ module TwentyOne
|
|
24
23
|
|
25
24
|
@dealer = Dealer.new "Harold", shoe
|
26
25
|
|
27
|
-
puts
|
28
|
-
|
29
|
-
|
26
|
+
puts <<-EOS
|
27
|
+
You went into the Wolf's Den
|
28
|
+
After they made you sign with that pen.
|
29
|
+
You said were there to settle a bet.
|
30
|
+
The Dealer shuffled his deck.
|
31
|
+
“What was your name again?”
|
32
|
+
EOS
|
33
|
+
puts "Type your name:"
|
34
|
+
name = gets
|
35
|
+
@player = Player.new name
|
36
|
+
puts
|
30
37
|
|
31
38
|
while @playing
|
32
39
|
case @phase
|
33
40
|
when :bet
|
34
|
-
puts "How much would you like to bet? (minimum of $1)
|
41
|
+
puts '"How much would you like to bet?" (minimum of $1)'
|
35
42
|
amount = gets.chomp.to_i
|
36
43
|
|
37
44
|
if Chip.get_amount(@player.chips) == 0
|
38
|
-
puts "
|
45
|
+
puts '"You\'re completely out of money, friend. The game is over."'
|
39
46
|
@pahse = :gameover
|
40
47
|
elsif Chip.get_amount(@player.chips) <= amount
|
41
|
-
puts "
|
48
|
+
puts' "You don\'t have enough money to make that bet."'
|
42
49
|
elsif amount > 0
|
43
50
|
@phase = :deal
|
44
51
|
end
|
45
52
|
when :deal
|
46
53
|
@player.make_bet amount
|
47
54
|
|
48
|
-
puts
|
55
|
+
puts
|
56
|
+
puts "The Dealer dealt the cards"
|
57
|
+
puts
|
49
58
|
|
50
59
|
# Deal cards
|
51
60
|
2.times do @dealer.hit(@player) end
|
52
61
|
2.times do @dealer.hit(@dealer) end
|
53
62
|
|
54
|
-
puts "You
|
63
|
+
puts "You received:"
|
64
|
+
puts
|
55
65
|
|
56
66
|
@player.hand.cards.each { |card| puts card }
|
57
67
|
|
58
|
-
puts "The
|
68
|
+
puts "The Dealer received a #{@dealer.hand.cards.first.to_s}. He kept the his second card face-down."
|
69
|
+
puts
|
59
70
|
|
60
71
|
@phase = :player_turn
|
61
72
|
when :side_rules
|
62
73
|
#TODO: Side Rules
|
63
74
|
when :player_turn
|
64
|
-
puts "What would you like to do? hit
|
75
|
+
puts '"What would you like to do?" (type hit or stand)'
|
65
76
|
choice = gets.chomp
|
66
77
|
|
67
78
|
case choice
|
68
79
|
when "hit"
|
69
80
|
@dealer.hit @player
|
70
81
|
|
71
|
-
puts "You
|
82
|
+
puts "You received a #{@player.hand.cards.last.to_s}"
|
83
|
+
puts
|
72
84
|
|
73
85
|
if @player.hand.cards.last.is_a?(AceCard) && @player.hand.cards.last.name == :ace
|
74
|
-
puts "You
|
75
|
-
puts "Would you like it to value 1 or 11?"
|
76
|
-
new_ace_value = gets
|
86
|
+
puts "You received an #{@player.hand.cards.last.to_s}."
|
87
|
+
puts '"Would you like it to value 1 or 11?" (type 1 or 11)'
|
88
|
+
new_ace_value = gets.chomp
|
77
89
|
|
78
90
|
case new_ace_value
|
79
91
|
when "1"
|
@@ -83,20 +95,24 @@ module TwentyOne
|
|
83
95
|
end
|
84
96
|
|
85
97
|
puts "Your ace's new value is #{@player.hand.cards.last.value}"
|
98
|
+
puts
|
86
99
|
end
|
87
100
|
|
88
101
|
if @player.hand.value > @@BLACKJACK
|
89
|
-
puts "
|
102
|
+
puts "You received more than 21, which meant you lost."
|
103
|
+
puts
|
90
104
|
@phase = :results
|
91
105
|
end
|
92
106
|
when "stand"
|
93
|
-
puts "
|
107
|
+
puts "Then it was The Dealer's turn."
|
108
|
+
puts
|
94
109
|
@phase = :showdown
|
95
110
|
end
|
96
111
|
when :dealer_turn
|
97
112
|
when :showdown
|
98
113
|
puts "The dealer reveals his card!"
|
99
114
|
puts "It's a #{@dealer.hand.cards.last.to_s}"
|
115
|
+
puts
|
100
116
|
|
101
117
|
while @dealer.hand.value < @@DEALER_MIN && @dealer.hand.value != @@BLACKJACK
|
102
118
|
@dealer.hit(@dealer)
|
@@ -108,7 +124,7 @@ module TwentyOne
|
|
108
124
|
|
109
125
|
case result
|
110
126
|
when :twenty_one
|
111
|
-
puts "
|
127
|
+
puts "21!"
|
112
128
|
when :win
|
113
129
|
puts "You won!"
|
114
130
|
when :bust
|
@@ -119,15 +135,16 @@ module TwentyOne
|
|
119
135
|
|
120
136
|
@phase = :results
|
121
137
|
when :results
|
122
|
-
puts "Here
|
138
|
+
puts "Here were your game stats:"
|
139
|
+
puts
|
123
140
|
puts "Chips: #{@player.chips.size}"
|
124
141
|
puts "Total value: $#{Chip.get_amount(@player.chips)}"
|
125
142
|
puts "TwentyOnes: #{@player.twenty_ones}"
|
126
143
|
puts "Wins: #{@player.wins}"
|
127
144
|
puts "Busts: #{@player.busts}"
|
128
145
|
puts "Pushes: #{@player.pushes}"
|
129
|
-
|
130
|
-
puts "Play again?"
|
146
|
+
puts
|
147
|
+
puts '"Play again?"'
|
131
148
|
answer = gets.chomp
|
132
149
|
|
133
150
|
case answer
|
data/lib/twenty_one/version.rb
CHANGED
data/twenty_one.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["pori"]
|
10
10
|
spec.email = ["porialex@gmail.com"]
|
11
11
|
spec.summary = %q{A simple command-line implementation of 21, better known as blackjack.}
|
12
|
-
spec.description = %q{}
|
12
|
+
spec.description = %q{Run 21 to execute the application.}
|
13
13
|
spec.homepage = "https://github.com/pori/twenty_one"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twenty_one
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pori
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: Run 21 to execute the application.
|
56
56
|
email:
|
57
57
|
- porialex@gmail.com
|
58
58
|
executables:
|
@@ -78,9 +78,6 @@ files:
|
|
78
78
|
- lib/twenty_one/hand.rb
|
79
79
|
- lib/twenty_one/player.rb
|
80
80
|
- lib/twenty_one/version.rb
|
81
|
-
- spec/lib/.ace_card_spec.rb.swp
|
82
|
-
- spec/lib/.card_spec.rb.swp
|
83
|
-
- spec/lib/.dealer_spec.rb.swp
|
84
81
|
- spec/lib/ace_card_spec.rb
|
85
82
|
- spec/lib/bet_spec.rb
|
86
83
|
- spec/lib/card_spec.rb
|
@@ -116,9 +113,6 @@ signing_key:
|
|
116
113
|
specification_version: 4
|
117
114
|
summary: A simple command-line implementation of 21, better known as blackjack.
|
118
115
|
test_files:
|
119
|
-
- spec/lib/.ace_card_spec.rb.swp
|
120
|
-
- spec/lib/.card_spec.rb.swp
|
121
|
-
- spec/lib/.dealer_spec.rb.swp
|
122
116
|
- spec/lib/ace_card_spec.rb
|
123
117
|
- spec/lib/bet_spec.rb
|
124
118
|
- spec/lib/card_spec.rb
|
Binary file
|
data/spec/lib/.card_spec.rb.swp
DELETED
Binary file
|
Binary file
|