lib/twenty_one/game.rb in twenty_one-0.1.0 vs lib/twenty_one/game.rb in twenty_one-0.1.1
- old
+ new
@@ -12,93 +12,109 @@
@@SHOE_DECKS_COUNT = 4
def self.play
@playing = true
@phase = :bet
- @player = Player.new "Alex"
shoe = []
@@SHOE_DECKS_COUNT.times do
shoe.concat Deck.new.shuffle
end
@dealer = Dealer.new "Harold", shoe
- puts "Welcome to the twenty_one table! Today's dealer is #{@dealer.name}"
- puts "Press any key to begin the game..."
- gets
+ puts <<-EOS
+ You went into the Wolf's Den
+ After they made you sign with that pen.
+ You said were there to settle a bet.
+ The Dealer shuffled his deck.
+ “What was your name again?”
+ EOS
+ puts "Type your name:"
+ name = gets
+ @player = Player.new name
+ puts
while @playing
case @phase
when :bet
- puts "How much would you like to bet? (minimum of $1)"
+ puts '"How much would you like to bet?" (minimum of $1)'
amount = gets.chomp.to_i
if Chip.get_amount(@player.chips) == 0
- puts "Oh man! You're completely out of money! It's time you see a specialist..."
+ puts '"You\'re completely out of money, friend. The game is over."'
@pahse = :gameover
elsif Chip.get_amount(@player.chips) <= amount
- puts "Woah! You don't have enough money to bet that amount."
+ puts' "You don\'t have enough money to make that bet."'
elsif amount > 0
@phase = :deal
end
when :deal
@player.make_bet amount
- puts "Deal!"
+ puts
+ puts "The Dealer dealt the cards"
+ puts
# Deal cards
2.times do @dealer.hit(@player) end
2.times do @dealer.hit(@dealer) end
- puts "You have:"
+ puts "You received:"
+ puts
@player.hand.cards.each { |card| puts card }
- puts "The dealer has a #{@dealer.hand.cards.first.to_s} and one card face-down"
+ puts "The Dealer received a #{@dealer.hand.cards.first.to_s}. He kept the his second card face-down."
+ puts
@phase = :player_turn
when :side_rules
#TODO: Side Rules
when :player_turn
- puts "What would you like to do? hit, stand"
+ puts '"What would you like to do?" (type hit or stand)'
choice = gets.chomp
case choice
when "hit"
@dealer.hit @player
- puts "You got a #{@player.hand.cards.last.to_s}"
+ puts "You received a #{@player.hand.cards.last.to_s}"
+ puts
if @player.hand.cards.last.is_a?(AceCard) && @player.hand.cards.last.name == :ace
- puts "You got an #{@player.hand.cards.last.to_s}!"
- puts "Would you like it to value 1 or 11?"
- new_ace_value = gets
+ puts "You received an #{@player.hand.cards.last.to_s}."
+ puts '"Would you like it to value 1 or 11?" (type 1 or 11)'
+ new_ace_value = gets.chomp
case new_ace_value
when "1"
@player.hand.cards.last.use_lower
when "11"
@player.hand.cards.last.use_upper
end
puts "Your ace's new value is #{@player.hand.cards.last.value}"
+ puts
end
if @player.hand.value > @@BLACKJACK
- puts "Aaaaah shucks! You have more than 21 which means you lose."
+ puts "You received more than 21, which meant you lost."
+ puts
@phase = :results
end
when "stand"
- puts "Alright! It's the dealer's turn."
+ puts "Then it was The Dealer's turn."
+ puts
@phase = :showdown
end
when :dealer_turn
when :showdown
puts "The dealer reveals his card!"
puts "It's a #{@dealer.hand.cards.last.to_s}"
+ puts
while @dealer.hand.value < @@DEALER_MIN && @dealer.hand.value != @@BLACKJACK
@dealer.hit(@dealer)
puts "The dealer drew a #{@dealer.hand.cards.last.to_s}"
@@ -106,29 +122,30 @@
result = @dealer.showdown(@player)
case result
when :twenty_one
- puts "TwentyOne!"
+ puts "21!"
when :win
puts "You won!"
when :bust
puts "You lost!"
when :push
puts "Tie!"
end
@phase = :results
when :results
- puts "Here are your game stats:"
+ puts "Here were your game stats:"
+ puts
puts "Chips: #{@player.chips.size}"
puts "Total value: $#{Chip.get_amount(@player.chips)}"
puts "TwentyOnes: #{@player.twenty_ones}"
puts "Wins: #{@player.wins}"
puts "Busts: #{@player.busts}"
puts "Pushes: #{@player.pushes}"
-
- puts "Play again?"
+ puts
+ puts '"Play again?"'
answer = gets.chomp
case answer
when "no"
@playing = false