Fix logic for next players turn
This commit is contained in:
parent
4c52336fd4
commit
57f8aaa938
@ -131,12 +131,12 @@ class Game < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def player_ids_by_seat_order
|
def player_ids_by_seat_order
|
||||||
player_ids = self.seats.order(:position).select {|s| s.player_id}.map {|s| s.player_id}
|
player_ids = self.seats.order(:position).select {|s| ( s.player.inventory.count > 0) ? s.player_id : nil}.compact.map {|s| s.player_id}
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_player_id
|
def next_player_id
|
||||||
@controlling_player_index = self.player_ids_by_seat_order.index(controlling_player_id)
|
@controlling_player_index = self.player_ids_by_seat_order.index(controlling_player_id)
|
||||||
player_ids_by_seat_order[(@controlling_player_index + 1) % self.player_ids.length]
|
player_ids_by_seat_order[(@controlling_player_index + 1) % self.player_ids_by_seat_order.length]
|
||||||
end
|
end
|
||||||
|
|
||||||
# The player whose turn it is
|
# The player whose turn it is
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user