Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Commit

Permalink
Panda and Tiger level complete, mulling over Eagle
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbCSO committed Aug 5, 2012
1 parent 49605e5 commit a385171
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions blackjack.rb
Expand Up @@ -14,7 +14,7 @@ def value
end

def to_s
"#{@value}-#{suit}"
"#{suit.to_s[0].capitalize}#{@value}"
end

end
Expand Down Expand Up @@ -75,6 +75,9 @@ def initialize

def hit
@player_hand.hit!(@deck)
if status[:player_value] > 21 then
stand
end
end

def stand
Expand Down Expand Up @@ -135,7 +138,7 @@ def inspect

it "should be formatted nicely" do
card = Card.new(:diamonds, "A")
card.to_s.should eq("A-diamonds")
card.to_s.should eq("DA")
end
end

Expand Down Expand Up @@ -225,6 +228,14 @@ def inspect
game.status[:winner].should_not be_nil
end

it "should #stand for the player if they bust" do
game = Game.new
while game.status[:player_value] < 21
game.hit
end
game.status[:winner].should_not be_nil
end

describe "#determine_winner" do
it "should have dealer win when player busts" do
Game.new.determine_winner(22, 15).should eq(:dealer)
Expand Down

0 comments on commit a385171

Please sign in to comment.