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