Exploratory dev custom host. Prep reintro of thirteen tien len
This commit is contained in:
parent
ffceb89c50
commit
c45487404f
@ -31,15 +31,17 @@ class TablesController < ApplicationController
|
||||
# GET /tables/1
|
||||
# GET /tables/1.json
|
||||
def show
|
||||
authorize @game
|
||||
# TODO refactor to ensure play for 2nd and 3rd place
|
||||
authorize @table
|
||||
if @game
|
||||
authorize @game
|
||||
# TODO refactor to ensure play for 2nd and 3rd place
|
||||
|
||||
if @game.controlling_player.try("is_bot?")
|
||||
@game.controlling_player.auto_play
|
||||
@game.save
|
||||
@game.reload
|
||||
if @game.controlling_player.try("is_bot?")
|
||||
@game.controlling_player.auto_play
|
||||
@game.save
|
||||
@game.reload
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def new_game
|
||||
|
||||
@ -13,7 +13,7 @@ class Table < ActiveRecord::Base
|
||||
|
||||
#TODO: Should these be part of Game initialize instead of callback?
|
||||
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
|
||||
# scope :play_now, lambda { |user|
|
||||
|
||||
@ -26,6 +26,10 @@ class SeatPolicy
|
||||
true
|
||||
end
|
||||
|
||||
def stand?
|
||||
true
|
||||
end
|
||||
|
||||
def sit?
|
||||
true
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ class TablePolicy
|
||||
end
|
||||
|
||||
def index?
|
||||
@current_user.admin?
|
||||
false
|
||||
end
|
||||
|
||||
def show?
|
||||
|
||||
@ -30,7 +30,7 @@ class UserPolicy
|
||||
end
|
||||
|
||||
def show?
|
||||
@current_user.admin? || @current_user == @user || @user.admin?
|
||||
@current_user.admin? || @current_user == @user
|
||||
end
|
||||
|
||||
def update?
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
<nav>
|
||||
<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 'Tokens', tokens_path %></li>
|
||||
<li><%= link_to 'Profiles', profiles_path %></li>
|
||||
<li><%= link_to 'Projects', projects_path %></li>
|
||||
<li><%= link_to 'Doodads', doodads_path, data: { turbo: false } %></li>
|
||||
<% if !request.base_url.match(/pin|my|fireside/) %>
|
||||
<% if policy(:table).index? %>
|
||||
<li><%= link_to 'Tables', tables_path %></li>
|
||||
<% end %>
|
||||
<% if policy(:table).index? %>
|
||||
<li><%= link_to 'Tables', tables_path %></li>
|
||||
<% end %>
|
||||
<% if current_user.signed_in? %>
|
||||
<% if current_user.admin? %>
|
||||
<%# <li><%= link_to 'Admin', '/admin' %1></li> %>
|
||||
<li><%= link_to 'Users', users_path %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
#play-to-beat
|
||||
%h4 Hand to beat:
|
||||
- if @game.play_to_beat == nil
|
||||
None
|
||||
- else
|
||||
- if @game
|
||||
#play-to-beat
|
||||
%h4 Hand to beat:
|
||||
- if @game.play_to_beat == nil
|
||||
None
|
||||
- else
|
||||
|
||||
%div.hand-type= @game.play_to_beat.play.hand_type.capitalize
|
||||
%span= @game.play_to_beat.play.to_s
|
||||
|
||||
@ -1,65 +1,66 @@
|
||||
- @game = seat.game
|
||||
.seat{class: "position-#{@seats.index(seat) + 1}"}
|
||||
.seat-controls
|
||||
- if seat.occupied?
|
||||
- if seat.player.is_bot?
|
||||
-# = button_to remove_bot_seat_path(seat) do
|
||||
- "- Bot"
|
||||
- if seat.occupied_by? current_user
|
||||
-# = button_to stand_seat_path(seat), :data => { :confirm => 'Are you sure you want to leave this seat?' } do
|
||||
= button_to stand_seat_path(seat) do
|
||||
- "Leave"
|
||||
- else
|
||||
-# = 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}
|
||||
|
||||
- if seat
|
||||
- @game = seat.game
|
||||
.seat{class: "position-#{@seats.index(seat) + 1}"}
|
||||
.seat-controls
|
||||
- if seat.occupied?
|
||||
- if seat.player.try("is_bot?")
|
||||
-# = button_to remove_bot_seat_path(seat) do
|
||||
- "- Bot"
|
||||
- if seat.occupied_by? current_user
|
||||
-# = button_to stand_seat_path(seat), :data => { :confirm => 'Are you sure you want to leave this seat?' } do
|
||||
= button_to stand_seat_path(seat) do
|
||||
- "Leave"
|
||||
- else
|
||||
.inventory
|
||||
- seat.player.inventory.count.times do |index|
|
||||
= image_tag('cards/png/back-pink.png')
|
||||
-# = 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
|
||||
.inventory
|
||||
- seat.player.inventory.count.times do |index|
|
||||
= image_tag('cards/png/back-pink.png')
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
%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.each do |table|
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
= button_to 'Rename', edit_table_path(@table), class: "smallbtn", method: :get
|
||||
= 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?
|
||||
= button_to 'Start', start_game_path(@game)
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
});
|
||||
|
||||
#game-component
|
||||
- if @game.winner_player_id
|
||||
- if @game && @game.winner_player_id
|
||||
%h1= @game.status
|
||||
|
||||
#playerList
|
||||
|
||||
@ -74,4 +74,5 @@ Rails.application.configure do
|
||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||
# config.action_cable.disable_request_forgery_protection = true
|
||||
config.hosts << "pineapple.punked.us"
|
||||
config.hosts << "theneedfuldo.tendy.zone"
|
||||
end
|
||||
|
||||
@ -58,6 +58,12 @@ Rails.application.routes.draw do
|
||||
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'
|
||||
get '/play-now', to: 'tables#play_now', as: 'play_now'
|
||||
get '/tutorial', to: 'tables#tutorial', as: 'tutorial'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user