Enable tables and seats
This commit is contained in:
parent
cb38b5ad8a
commit
1faee1d530
@ -266,3 +266,5 @@ textarea
|
||||
@import microposts
|
||||
@import projects
|
||||
@import rooms
|
||||
@import tables
|
||||
@import game
|
||||
|
||||
@ -6,4 +6,8 @@ class VisitorsController < ApplicationController
|
||||
@canisters = authorize Canister.all
|
||||
@feed_items = current_user.feed.paginate(page: params[:page])
|
||||
end
|
||||
|
||||
def games_index
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
class Seat < ActiveRecord::Base
|
||||
belongs_to :table
|
||||
belongs_to :game
|
||||
belongs_to :user
|
||||
belongs_to :player
|
||||
belongs_to :game, optional: true
|
||||
belongs_to :user, optional: true
|
||||
belongs_to :player, optional: true
|
||||
|
||||
def sit(current_user)
|
||||
if self.occupied?
|
||||
@ -13,12 +13,13 @@ class Seat < ActiveRecord::Base
|
||||
|
||||
self.reload
|
||||
if self.player == nil
|
||||
self.player_id = self.table.current_game.add_player_from_user(current_user).id
|
||||
# TODO: Decouple seat from game
|
||||
# self.player_id = self.table.current_game.add_player_from_user(current_user).id
|
||||
end
|
||||
|
||||
self.player.user_id = current_user.id
|
||||
self.player.soft_token = current_user.soft_token
|
||||
self.player.save
|
||||
# self.player.user_id = current_user.id
|
||||
# self.player.soft_token = current_user.soft_token
|
||||
# self.player.save
|
||||
|
||||
self.user_id = current_user.id
|
||||
self.user_soft_token = current_user.soft_token
|
||||
@ -32,9 +33,9 @@ class Seat < ActiveRecord::Base
|
||||
return "Error. Seat not occupied by you."
|
||||
else
|
||||
# self.table.current_game.remove_player_from_user(user)
|
||||
self.player.user = nil
|
||||
self.player.soft_token = nil
|
||||
self.player.save
|
||||
# self.player.user = nil
|
||||
# self.player.soft_token = nil
|
||||
# self.player.save
|
||||
self.user_id = nil
|
||||
self.user_soft_token = nil
|
||||
# self.player_id = nil
|
||||
|
||||
@ -37,11 +37,12 @@ class Table < ActiveRecord::Base
|
||||
self.games.create
|
||||
end
|
||||
|
||||
private
|
||||
# private
|
||||
|
||||
def add_seats
|
||||
return if self.seats.present?
|
||||
1.upto(4) do |i|
|
||||
self.seats.create(position: i)
|
||||
self.seats.create!(position: i)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -7,11 +7,11 @@ class TablePolicy
|
||||
end
|
||||
|
||||
def index?
|
||||
false
|
||||
true
|
||||
end
|
||||
|
||||
def show?
|
||||
@current_user.admin? || @current_user == @user
|
||||
@current_user.admin? || @current_user == @user || true
|
||||
end
|
||||
|
||||
def create?
|
||||
|
||||
@ -12,12 +12,13 @@
|
||||
- "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
|
||||
-# TODO policy check to clear seat
|
||||
-# = 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
|
||||
-# = button_to add_bot_seat_path(seat) do
|
||||
- "+ Bot"
|
||||
|
||||
- if seat.player
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
%h1 Listing tables
|
||||
.contain
|
||||
%h1 Listing tables
|
||||
|
||||
- if policy(:table).new?
|
||||
.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|
|
||||
|
||||
@ -17,9 +17,9 @@
|
||||
-# - if @game.winner_player_id || @game.nil?
|
||||
-# = button_to 'New Game', new_game_table_path(@table)
|
||||
|
||||
-# - if @game && !@game.startable?
|
||||
#table-controls
|
||||
#newgame= button_to 'New Game', new_game_table_path(@table)
|
||||
- if @game && !@game.startable?
|
||||
#table-controls
|
||||
#newgame= button_to 'New Game', new_game_table_path(@table)
|
||||
|
||||
-# #qrcode
|
||||
-# :javascript
|
||||
|
||||
21
app/views/visitors/games_index.html.haml
Normal file
21
app/views/visitors/games_index.html.haml
Normal file
@ -0,0 +1,21 @@
|
||||
#home-headline.home-headline
|
||||
%h1 Web3 Social Gaming <br/>Crypto Rewards
|
||||
|
||||
#main-menu
|
||||
- if policy(:table).play_now?
|
||||
= link_to 'Play 13 Now', play_now_path
|
||||
- else
|
||||
-# Soon
|
||||
= link_to 'Browse Tables', tables_path
|
||||
= link_to 'Tutorial', tutorial_path
|
||||
= link_to 'About', page_path('about')
|
||||
|
||||
-# - Dir.glob("app/assets/images/cards/png/**").each do |card_img|
|
||||
- puts card_img
|
||||
= image_tag
|
||||
|
||||
-# %iframe#videoplayer{:allowfullscreen => "", :frameborder => "0", :height => "480", :mozallowfullscreen => "true", :src => "https://archive.org/embed/my-dinner-with-andre-conspiracy-theory-scene-hd", :webkitallowfullscreen => "true", :width => "640", :autostart => "true"}
|
||||
-# %iframe{:allow => "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share", :allowfullscreen => "", :frameborder => "0", :height => "315", :src => "https://www.youtube.com/embed/kK-1axSGkXc", :title => "YouTube video player", :width => "560"}
|
||||
-# %iframe#videoplayer{:allow => "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share", :allowfullscreen => "", :frameborder => "0", :height => "315", :src => "https://www.youtube.com/embed/PhIM5k_m_hs", :title => "YouTube video player", :width => "560"}
|
||||
-# .video-cover
|
||||
-# = video_tag "video.mp4", autoplay: true, id: "videoplayer", loop: true
|
||||
@ -1,4 +1,5 @@
|
||||
Rails.application.routes.draw do
|
||||
get '/games', to: "visitors#games_index"
|
||||
resources :rooms do
|
||||
resources :messages
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user