Autoload game updates if not taking turn
This commit is contained in:
parent
d163fa2eaa
commit
d5ef4d6481
@ -1,5 +1,7 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
$('#table-component').load(window.location.pathname +" #table-component");
|
if ( $('.taking-turn.player[data-soft-token=' + soft_token + ']').length < 1 ) {
|
||||||
|
$('#table-component').load(window.location.pathname +" #table-component");
|
||||||
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
sit_seat_path(seat)
|
sit_seat_path(seat)
|
||||||
|
|
||||||
- if seat.player
|
- if seat.player
|
||||||
.player{class: @game.controlling_player == seat.player ? "taking-turn" : ""}
|
.player{class: @game.controlling_player == seat.player ? "taking-turn" : "",
|
||||||
|
data: {soft_token: seat.player.soft_token} }
|
||||||
.user-name= seat.player.display_name
|
.user-name= seat.player.display_name
|
||||||
- if @game.started?
|
- if @game.started?
|
||||||
.inventory-count= seat.player.inventory.count
|
.inventory-count= seat.player.inventory.count
|
||||||
|
|||||||
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
-# #table-component-container-container= react_component 'Table', props = {url: "#{table_path @table}"}, html_options = {id: "table-component-container"}
|
-# #table-component-container-container= react_component 'Table', props = {url: "#{table_path @table}"}, html_options = {id: "table-component-container"}
|
||||||
#table-component
|
#table-component
|
||||||
- unless current_user.soft_token == @game.controlling_player.try("soft_token")
|
|
||||||
= javascript_include_tag 'table-loader'
|
|
||||||
|
|
||||||
%p= @table.title
|
%p= @table.title
|
||||||
|
|
||||||
@ -17,37 +15,6 @@
|
|||||||
- if @game.winner_player_id || @game.nil?
|
- if @game.winner_player_id || @game.nil?
|
||||||
= button_to 'New Game', new_game_table_path(@table)
|
= button_to 'New Game', new_game_table_path(@table)
|
||||||
|
|
||||||
-# .players
|
|
||||||
%b Players:
|
|
||||||
%ol
|
|
||||||
- @game.players.each do |player|
|
|
||||||
%li
|
|
||||||
= player.display_name
|
|
||||||
// Show the user which player they are
|
|
||||||
= "Me" if player.soft_token == current_user.soft_token
|
|
||||||
// Show whose turn it is
|
|
||||||
- if @game.controlling_player_id
|
|
||||||
%strong= "Taking Turn " if @game.controlling_player == player
|
|
||||||
// Show the players' cards
|
|
||||||
- if player.user == current_user && player.inventory.empty? == false
|
|
||||||
-##inventory
|
|
||||||
|
|
||||||
-# TODO better logic, not in view
|
|
||||||
- unless @game.status == nil
|
|
||||||
.table
|
|
||||||
-# TODO better logic, not in view. Set play to beat = nil; instead of view logic
|
|
||||||
-# - if @game.play_to_beat && @game.player_to_beat != @game.controlling_player
|
|
||||||
- if @game.play_to_beat.play
|
|
||||||
%h1
|
|
||||||
Hand to beat
|
|
||||||
%span.hand-type= @game.play_to_beat.play.hand_type
|
|
||||||
%div= @game.play_to_beat.play.to_s
|
|
||||||
- @game.play_to_beat.play.player_cards.each do |card|
|
|
||||||
= card.to_s
|
|
||||||
%span.player= @game.play_to_beat.play.player.display_name
|
|
||||||
-# - else
|
|
||||||
%h1 Open table
|
|
||||||
|
|
||||||
#game-component
|
#game-component
|
||||||
- if @game.winner_player_id
|
- if @game.winner_player_id
|
||||||
%h1= @game.status
|
%h1= @game.status
|
||||||
@ -64,3 +31,7 @@
|
|||||||
|
|
||||||
#bot
|
#bot
|
||||||
= render "seat", seat: @seats[3]
|
= render "seat", seat: @seats[3]
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
var soft_token = "#{current_user.soft_token}";
|
||||||
|
= javascript_include_tag 'table-loader'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user