Imorove turn logic regress new end of game bugs
This commit is contained in:
parent
8970379e57
commit
b665999104
@ -36,15 +36,12 @@ class GamesController < ApplicationController
|
||||
# Player action: pass
|
||||
# TODO: wtf do we need game params for? And why nest hand_type in it?
|
||||
# if params[:game]
|
||||
if params[:hand_type] == 'Pass'
|
||||
@game.set_controlling_player 'next'
|
||||
flash[:notice] = 'Successfully passed.'
|
||||
@game.save
|
||||
end
|
||||
# end
|
||||
|
||||
if params[:hand_type] == 'Pass'
|
||||
@game.set_controlling_player 'next'
|
||||
flash[:notice] = 'Successfully passed.'
|
||||
@game.save
|
||||
# Player action: play_hand
|
||||
if params[:player_card_ids]
|
||||
elsif params[:player_card_ids]
|
||||
@cards_to_play = @game.controlling_player.try(:player_cards).order(:value).find(params[:player_card_ids])
|
||||
# Instantiate the play
|
||||
@play = @game.controlling_player.plays.new
|
||||
|
||||
@ -30,6 +30,12 @@ class TablesController < ApplicationController
|
||||
# GET /tables/1
|
||||
# GET /tables/1.json
|
||||
def show
|
||||
# TODO move this to the game.rb model
|
||||
# Clear play to beat if play returns to owner
|
||||
if @game.play_to_beat.try(:player).try(:id) == @game.controlling_player_id
|
||||
@game.play_to_beat_id = nil
|
||||
@game.save
|
||||
end
|
||||
end
|
||||
|
||||
# GET /tables/new
|
||||
|
||||
@ -126,9 +126,9 @@ class Game < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# Clear play to beat if play returns to owner
|
||||
if self.play_to_beat.try(:player).try(:id) == self.controlling_player_id
|
||||
self.play_to_beat_id = nil
|
||||
end
|
||||
# if self.play_to_beat.try(:player).try(:id) == self.controlling_player_id
|
||||
# self.play_to_beat_id = nil
|
||||
# end
|
||||
end
|
||||
|
||||
def joinable? user
|
||||
@ -141,6 +141,7 @@ class Game < ActiveRecord::Base
|
||||
|
||||
def next_player_id
|
||||
@controlling_player_index = self.player_ids_by_seat_order.index(controlling_player_id)
|
||||
@controlling_player_index ||= 0
|
||||
player_ids_by_seat_order[(@controlling_player_index + 1) % self.player_ids_by_seat_order.length]
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user