Clear Play To Beat when play is passed by all other players

This commit is contained in:
Jesse C. Fisher 2019-10-26 04:28:19 -07:00
parent 00b24af7a2
commit bbfb20a390
4 changed files with 7 additions and 2 deletions

View File

@ -115,7 +115,6 @@ ol#cards-to-beat
margin-left: -21vmin margin-left: -21vmin
// Don't offset first card // Don't offset first card
&:first-of-type &:first-of-type
// margin-left: 0
margin-left: -4vmin margin-left: -4vmin
flex: 1 1 auto flex: 1 1 auto
//flex: 1 1 auto //flex: 1 1 auto

View File

@ -124,6 +124,11 @@ class Game < ActiveRecord::Base
when 'next' when 'next'
self.controlling_player_id = self.next_player_id self.controlling_player_id = self.next_player_id
end 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
end end
def joinable? user def joinable? user

View File

@ -1,4 +1,5 @@
class PlayToBeat < ActiveRecord::Base class PlayToBeat < ActiveRecord::Base
belongs_to :game belongs_to :game
belongs_to :play belongs_to :play
has_one :player, through: :play
end end

View File

@ -1,6 +1,6 @@
#play-to-beat #play-to-beat
%h4 Hand to beat: %h4 Hand to beat:
- if @game.play_to_beat.play == nil - if @game.play_to_beat == nil
None None
- else - else