Exploratory dev custom host. Prep reintro of thirteen tien len
This commit is contained in:
parent
d3481526a2
commit
e8599242ee
@ -31,15 +31,17 @@ class TablesController < ApplicationController
|
|||||||
# GET /tables/1
|
# GET /tables/1
|
||||||
# GET /tables/1.json
|
# GET /tables/1.json
|
||||||
def show
|
def show
|
||||||
authorize @game
|
authorize @table
|
||||||
# TODO refactor to ensure play for 2nd and 3rd place
|
if @game
|
||||||
|
authorize @game
|
||||||
|
# TODO refactor to ensure play for 2nd and 3rd place
|
||||||
|
|
||||||
if @game.controlling_player.try("is_bot?")
|
if @game.controlling_player.try("is_bot?")
|
||||||
@game.controlling_player.auto_play
|
@game.controlling_player.auto_play
|
||||||
@game.save
|
@game.save
|
||||||
@game.reload
|
@game.reload
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_game
|
def new_game
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class Table < ActiveRecord::Base
|
|||||||
|
|
||||||
#TODO: Should these be part of Game initialize instead of callback?
|
#TODO: Should these be part of Game initialize instead of callback?
|
||||||
after_create :add_seats
|
after_create :add_seats
|
||||||
after_create :add_game
|
# after_create :add_game
|
||||||
|
|
||||||
# Returns the newest joinable table or creates a new table if none are found
|
# Returns the newest joinable table or creates a new table if none are found
|
||||||
# scope :play_now, lambda { |user|
|
# scope :play_now, lambda { |user|
|
||||||
|
|||||||
@ -26,6 +26,10 @@ class SeatPolicy
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stand?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def sit?
|
def sit?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,7 +7,7 @@ class TablePolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index?
|
def index?
|
||||||
@current_user.admin?
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class UserPolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
@current_user.admin? || @current_user == @user || @user.admin?
|
@current_user.admin? || @current_user == @user
|
||||||
end
|
end
|
||||||
|
|
||||||
def update?
|
def update?
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
|
<%# <% if current_user.signed_in? %1> %>
|
||||||
|
<%# <li><%= link_to 'My Zone', user_path(current_user), data: { turbo: false } %1></li> %>
|
||||||
|
<%# <% end %1> %>
|
||||||
<li><%= link_to 'Public', root_path, data: { turbo: false } %></li>
|
<li><%= link_to 'Public', root_path, data: { turbo: false } %></li>
|
||||||
<li><%= link_to 'Tokens', tokens_path %></li>
|
<li><%= link_to 'Tokens', tokens_path %></li>
|
||||||
<li><%= link_to 'Profiles', profiles_path %></li>
|
<li><%= link_to 'Profiles', profiles_path %></li>
|
||||||
<li><%= link_to 'Projects', projects_path %></li>
|
<li><%= link_to 'Projects', projects_path %></li>
|
||||||
<li><%= link_to 'Doodads', doodads_path, data: { turbo: false } %></li>
|
<li><%= link_to 'Doodads', doodads_path, data: { turbo: false } %></li>
|
||||||
<% if !request.base_url.match(/pin|my|fireside/) %>
|
<% if policy(:table).index? %>
|
||||||
<% if policy(:table).index? %>
|
<li><%= link_to 'Tables', tables_path %></li>
|
||||||
<li><%= link_to 'Tables', tables_path %></li>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if current_user.signed_in? %>
|
<% if current_user.signed_in? %>
|
||||||
<% if current_user.admin? %>
|
<% if current_user.admin? %>
|
||||||
<%# <li><%= link_to 'Admin', '/admin' %1></li> %>
|
|
||||||
<li><%= link_to 'Users', users_path %></li>
|
<li><%= link_to 'Users', users_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
#play-to-beat
|
- if @game
|
||||||
%h4 Hand to beat:
|
#play-to-beat
|
||||||
- if @game.play_to_beat == nil
|
%h4 Hand to beat:
|
||||||
None
|
- if @game.play_to_beat == nil
|
||||||
- else
|
None
|
||||||
|
- else
|
||||||
|
|
||||||
%div.hand-type= @game.play_to_beat.play.hand_type.capitalize
|
%div.hand-type= @game.play_to_beat.play.hand_type.capitalize
|
||||||
%span= @game.play_to_beat.play.to_s
|
%span= @game.play_to_beat.play.to_s
|
||||||
|
|||||||
@ -1,65 +1,66 @@
|
|||||||
- @game = seat.game
|
- if seat
|
||||||
.seat{class: "position-#{@seats.index(seat) + 1}"}
|
- @game = seat.game
|
||||||
.seat-controls
|
.seat{class: "position-#{@seats.index(seat) + 1}"}
|
||||||
- if seat.occupied?
|
.seat-controls
|
||||||
- if seat.player.is_bot?
|
- if seat.occupied?
|
||||||
-# = button_to remove_bot_seat_path(seat) do
|
- if seat.player.try("is_bot?")
|
||||||
- "- Bot"
|
-# = button_to remove_bot_seat_path(seat) do
|
||||||
- if seat.occupied_by? current_user
|
- "- Bot"
|
||||||
-# = button_to stand_seat_path(seat), :data => { :confirm => 'Are you sure you want to leave this seat?' } do
|
- if seat.occupied_by? current_user
|
||||||
= button_to stand_seat_path(seat) do
|
-# = button_to stand_seat_path(seat), :data => { :confirm => 'Are you sure you want to leave this seat?' } do
|
||||||
- "Leave"
|
= button_to stand_seat_path(seat) do
|
||||||
- else
|
- "Leave"
|
||||||
-# = button_to empty_seat_path(seat), :data => { :confirm => 'Are you sure you want to empty this seat?' } do
|
|
||||||
= button_to empty_seat_path(seat) do
|
|
||||||
- "Clear Seat"
|
|
||||||
- else
|
|
||||||
= button_to sit_seat_path(seat) do
|
|
||||||
- "Sit"
|
|
||||||
= button_to add_bot_seat_path(seat) do
|
|
||||||
- "+ Bot"
|
|
||||||
|
|
||||||
- if seat.player
|
|
||||||
-# = button_to remove_player_seat_path(seat), :data => { :confirm => 'Are you sure you want to remove this player?' } do
|
|
||||||
= button_to remove_player_seat_path(seat) do
|
|
||||||
- "Remove Player"
|
|
||||||
.player{id: "player-#{seat.player.id}", class: @game.controlling_player == seat.player ? "taking-turn" : "",
|
|
||||||
data: {soft_token: seat.player.soft_token} }
|
|
||||||
.user-name= seat.player.display_name
|
|
||||||
-# .user-soft-token= seat.player.soft_token
|
|
||||||
.user-principal= seat.player.principal
|
|
||||||
- if @game.started?
|
|
||||||
.inventory-count
|
|
||||||
Cards:
|
|
||||||
= seat.player.inventory.count
|
|
||||||
|
|
||||||
-# Show player controls if player is owned by current_user
|
|
||||||
- if seat.player.soft_token == current_user.soft_token
|
|
||||||
= form_for(@game,
|
|
||||||
url: play_hand_game_path(@game),
|
|
||||||
method: "post",
|
|
||||||
name: "player_controls_" + seat.player_id.to_s,
|
|
||||||
id: "player_controls_" + seat.player_id.to_s) do |f|
|
|
||||||
%ul#inventory
|
|
||||||
- seat.player.inventory.each do |card|
|
|
||||||
%li
|
|
||||||
%label
|
|
||||||
= check_box_tag 'player_card_ids[]',
|
|
||||||
card.id,
|
|
||||||
false,
|
|
||||||
data: {value: card.id, card_name: card.rank.gsub('11','J') .gsub('12','Q') .gsub('13','K') .gsub('14','A') .gsub('15','2') + ' ' + card.suit}
|
|
||||||
|
|
||||||
-# %input{form: "player_controls_" + card.player_id.to_s,
|
|
||||||
type: "checkbox",
|
|
||||||
name: "player_card_ids[]",
|
|
||||||
data: {value: card.id, card_name: card.rank.gsub('11','J') .gsub('12','Q') .gsub('13','K') .gsub('14','A') .gsub('15','2') + ' ' + card.suit}}
|
|
||||||
= image_tag('cards/png/' + (card.rank.gsub('J','jack').gsub('Q','queen').gsub('K','king').gsub('A','ace') + '_of_' + card.suit.downcase + 's.png').gsub('11','jack') .gsub('12','queen') .gsub('13','king') .gsub('14','ace') .gsub('15','2'))
|
|
||||||
- disabled = @game.controlling_player != seat.player
|
|
||||||
#play-buttons
|
|
||||||
%input{type: "submit", value: "Play Hand", name: "hand_type", disabled: disabled}
|
|
||||||
%input{type: "submit", value: "Pass", name: "hand_type", disabled: disabled}
|
|
||||||
|
|
||||||
- else
|
- else
|
||||||
.inventory
|
-# = button_to empty_seat_path(seat), :data => { :confirm => 'Are you sure you want to empty this seat?' } do
|
||||||
- seat.player.inventory.count.times do |index|
|
= button_to empty_seat_path(seat) do
|
||||||
= image_tag('cards/png/back-pink.png')
|
- "Clear Seat"
|
||||||
|
- else
|
||||||
|
= button_to sit_seat_path(seat) do
|
||||||
|
- "Sit"
|
||||||
|
= button_to add_bot_seat_path(seat) do
|
||||||
|
- "+ Bot"
|
||||||
|
|
||||||
|
- if seat.player
|
||||||
|
-# = button_to remove_player_seat_path(seat), :data => { :confirm => 'Are you sure you want to remove this player?' } do
|
||||||
|
= button_to remove_player_seat_path(seat) do
|
||||||
|
- "Remove Player"
|
||||||
|
.player{id: "player-#{seat.player.id}", class: @game.controlling_player == seat.player ? "taking-turn" : "",
|
||||||
|
data: {soft_token: seat.player.soft_token} }
|
||||||
|
.user-name= seat.player.display_name
|
||||||
|
-# .user-soft-token= seat.player.soft_token
|
||||||
|
.user-principal= seat.player.principal
|
||||||
|
- if @game.started?
|
||||||
|
.inventory-count
|
||||||
|
Cards:
|
||||||
|
= seat.player.inventory.count
|
||||||
|
|
||||||
|
-# Show player controls if player is owned by current_user
|
||||||
|
- if seat.player.soft_token == current_user.soft_token
|
||||||
|
= form_for(@game,
|
||||||
|
url: play_hand_game_path(@game),
|
||||||
|
method: "post",
|
||||||
|
name: "player_controls_" + seat.player_id.to_s,
|
||||||
|
id: "player_controls_" + seat.player_id.to_s) do |f|
|
||||||
|
%ul#inventory
|
||||||
|
- seat.player.inventory.each do |card|
|
||||||
|
%li
|
||||||
|
%label
|
||||||
|
= check_box_tag 'player_card_ids[]',
|
||||||
|
card.id,
|
||||||
|
false,
|
||||||
|
data: {value: card.id, card_name: card.rank.gsub('11','J') .gsub('12','Q') .gsub('13','K') .gsub('14','A') .gsub('15','2') + ' ' + card.suit}
|
||||||
|
|
||||||
|
-# %input{form: "player_controls_" + card.player_id.to_s,
|
||||||
|
type: "checkbox",
|
||||||
|
name: "player_card_ids[]",
|
||||||
|
data: {value: card.id, card_name: card.rank.gsub('11','J') .gsub('12','Q') .gsub('13','K') .gsub('14','A') .gsub('15','2') + ' ' + card.suit}}
|
||||||
|
= image_tag('cards/png/' + (card.rank.gsub('J','jack').gsub('Q','queen').gsub('K','king').gsub('A','ace') + '_of_' + card.suit.downcase + 's.png').gsub('11','jack') .gsub('12','queen') .gsub('13','king') .gsub('14','ace') .gsub('15','2'))
|
||||||
|
- disabled = @game.controlling_player != seat.player
|
||||||
|
#play-buttons
|
||||||
|
%input{type: "submit", value: "Play Hand", name: "hand_type", disabled: disabled}
|
||||||
|
%input{type: "submit", value: "Pass", name: "hand_type", disabled: disabled}
|
||||||
|
|
||||||
|
- else
|
||||||
|
.inventory
|
||||||
|
- seat.player.inventory.count.times do |index|
|
||||||
|
= image_tag('cards/png/back-pink.png')
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
%h1 Listing tables
|
%h1 Listing tables
|
||||||
|
|
||||||
.button= link_to 'New Table', new_table_path
|
- if policy(:table).new?
|
||||||
|
.button= link_to 'New Table', new_table_path
|
||||||
|
|
||||||
.tables-container
|
.tables-container
|
||||||
- @tables.each do |table|
|
- @tables.each do |table|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
= button_to 'Rename', edit_table_path(@table), class: "smallbtn", method: :get
|
= button_to 'Rename', edit_table_path(@table), class: "smallbtn", method: :get
|
||||||
= button_to 'Delete', @game, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: "smallbtn"
|
= button_to 'Delete', @game, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: "smallbtn"
|
||||||
|
|
||||||
- if @game.already_has?(current_user)
|
- if @game && @game.already_has?(current_user)
|
||||||
- if @game.startable?
|
- if @game.startable?
|
||||||
= button_to 'Start', start_game_path(@game)
|
= button_to 'Start', start_game_path(@game)
|
||||||
|
|
||||||
@ -40,7 +40,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
#game-component
|
#game-component
|
||||||
- if @game.winner_player_id
|
- if @game && @game.winner_player_id
|
||||||
%h1= @game.status
|
%h1= @game.status
|
||||||
|
|
||||||
#playerList
|
#playerList
|
||||||
|
|||||||
@ -74,4 +74,5 @@ Rails.application.configure do
|
|||||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||||
# config.action_cable.disable_request_forgery_protection = true
|
# config.action_cable.disable_request_forgery_protection = true
|
||||||
config.hosts << "pineapple.punked.us"
|
config.hosts << "pineapple.punked.us"
|
||||||
|
config.hosts << "theneedfuldo.tendy.zone"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -58,6 +58,12 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
constraints query_string: /website=theneedfuldo/ do
|
||||||
|
root to: 'doodads#index', as: :needful_root
|
||||||
|
end
|
||||||
|
constraints host: 'theneedfuldo.tendy.zone' do
|
||||||
|
root to: 'projects#show', id: 2, as: :needful_host_root
|
||||||
|
end
|
||||||
root to: 'visitors#index'
|
root to: 'visitors#index'
|
||||||
get '/play-now', to: 'tables#play_now', as: 'play_now'
|
get '/play-now', to: 'tables#play_now', as: 'play_now'
|
||||||
get '/tutorial', to: 'tables#tutorial', as: 'tutorial'
|
get '/tutorial', to: 'tables#tutorial', as: 'tutorial'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user