Skip to content

Commit

Permalink
Fixes unseating and hand cycling.
Browse files Browse the repository at this point in the history
  • Loading branch information
rnubel committed Feb 24, 2012
1 parent 0156423 commit 670f66e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions models/game_table.rb
Expand Up @@ -13,13 +13,13 @@ def active

def play!
while self.players.count > 1
begin_hand
begin_hand.play!
end
end

def begin_hand
assign_dealer!
return hands.find_or_create_by_active(true)
hands.create # TODO: incorporate dealer position
end

def small_blind
Expand Down
3 changes: 1 addition & 2 deletions models/round.rb
Expand Up @@ -141,8 +141,7 @@ def call_blinds(small_blind)
action = Action.create(:player => action_to, :round => self, :action_name => action_hash[:action].to_s, :amount => action_hash[:amount].to_i)
accept_bet(action)
else
# TODO: unseat player
raise "player did not post blinds"
unseat_player!(action_to)
end

next_player!
Expand Down
6 changes: 3 additions & 3 deletions spec/models/game_table_spec.rb
Expand Up @@ -79,11 +79,11 @@
players = mock('association')
game_table.stubs(:players).returns(players)
players.expects(:count).in_sequence(seq).returns(3)
game_table.expects(:begin_hand).in_sequence(seq).returns(nil)
game_table.expects(:begin_hand).in_sequence(seq).returns(mock('hand', :play! => nil))
players.expects(:count).in_sequence(seq).returns(3)
game_table.expects(:begin_hand).in_sequence(seq).returns(nil)
game_table.expects(:begin_hand).in_sequence(seq).returns(mock('hand', :play! => nil))
players.expects(:count).in_sequence(seq).returns(2)
game_table.expects(:begin_hand).in_sequence(seq).returns(nil)
game_table.expects(:begin_hand).in_sequence(seq).returns(mock('hand', :play! => nil))
players.expects(:count).in_sequence(seq).returns(1)

game_table.play!
Expand Down

0 comments on commit 670f66e

Please sign in to comment.