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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 097ec3f9595fb36938715267bb2fdb70cf8027c8
4
- data.tar.gz: 73f084d40fbe6660fe8bbf4922fbe93706f8c3f8
3
+ metadata.gz: c9cfee5231e54857206d116d44c444d2d10006bd
4
+ data.tar.gz: b81401a825b54688a9f6c91b61497610d517cfd0
5
5
  SHA512:
6
- metadata.gz: 1993da48eb109d1b4c398836ae1c327f915f1cf8cac619d90b90c417e205b8f0c59f9ef5bb49727ab55ccc45f7e91ce7837893d64f372fd5b8facf421628602a
7
- data.tar.gz: 5ef4b0b47e205911b1dc0cea8e6e4fb4cac033a700767c660385395e419da2a69ffb8d17ec266717c6c1c72add04eaf29d355867f52ad6604f4e54aaf766959f
6
+ metadata.gz: 54f500d48ab47fa41d67285ee66e4f3623abe1b339cdcb348d1672ff977df47283e316ede278734421527016e5b27c74cc43434fe012fe0a3e3db8931d390650
7
+ data.tar.gz: 0e14fabb5823a5e767e0b21cd331a56763d3a929b06b6104610e6b5e015d4dd32a43d4dac371dbc73d51863a8532c3ec6b00afec9c055226a7bf52e593ba47ad
data/.gitignore CHANGED
@@ -20,3 +20,7 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+
24
+ *~
25
+ *.swp
26
+ *.swo
data/README.md CHANGED
@@ -97,6 +97,7 @@ The goal of the game is to draw a hand with a value greater than the dealer's as
97
97
 
98
98
  ## Planned Features
99
99
 
100
+ * Side rules
100
101
  * Multiple players
101
102
  * An option to play as the dealer
102
103
  * Saving player stats to a local SQLite database
@@ -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 "Welcome to the twenty_one table! Today's dealer is #{@dealer.name}"
28
- puts "Press any key to begin the game..."
29
- gets
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 "Oh man! You're completely out of money! It's time you see a specialist..."
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 "Woah! You don't have enough money to bet that amount."
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 "Deal!"
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 have:"
63
+ puts "You received:"
64
+ puts
55
65
 
56
66
  @player.hand.cards.each { |card| puts card }
57
67
 
58
- puts "The dealer has a #{@dealer.hand.cards.first.to_s} and one card face-down"
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, stand"
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 got a #{@player.hand.cards.last.to_s}"
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 got an #{@player.hand.cards.last.to_s}!"
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 "Aaaaah shucks! You have more than 21 which means you lose."
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 "Alright! It's the dealer's turn."
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 "TwentyOne!"
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 are your game stats:"
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
@@ -1,3 +1,3 @@
1
1
  module TwentyOne
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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
Binary file
Binary file