Adds top seat, player, controls

This commit is contained in:
Jesse C. Fisher 2019-10-20 16:55:12 -07:00
parent dba4e6e871
commit 0ae22a7a7f
5 changed files with 45 additions and 47 deletions

View File

@ -123,7 +123,7 @@ class GamesController < ApplicationController
@game.errors.messages.each do |key, msg|
flash[key] = msg.join
end
redirect_to(@game)
redirect_to(@game.table)
return
end
flash[:notice] = 'Game started.'

View File

@ -13,7 +13,7 @@
= link_to 'Join', game_join_path(@game)
- if @game.startable? && @game.already_has?(current_user)
= link_to 'Start', game_start_path(@game)
= link_to 'Start', start_game_path(@game)
-#.debug
= button_to 'Debug Start', game_start_path(@game), method: :get
@ -56,7 +56,7 @@
%h1 Open table
.controls
- if @game.control_user == current_user
- if @game.controlling_user == current_user
// Play hand form
= form_for @game, :url => play_hand_game_path(@game), remote: true do |f|
// Provide id of current game

View File

@ -0,0 +1,36 @@
- @game = seat.game
.seat
.seat-controls
- if seat.occupied?
- if seat.occupied_by? current_user
= button_to "Stand",
stand_seat_path(seat)
- else
= button_to "Sit",
sit_seat_path(seat)
- if seat.player
.player
.user-name= seat.player.display_name
- if @game.started?
%h1 hi
.inventory-count= 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, play_hand_game_path do |f|
%ul#inventory
- seat.player.inventory.each do |card|
%li
%label
%input{form: "player_controls_" + card.player_id,
type: "checkbox",
name: "player_card_ids[]",
data: {card_name: card.rank.gsub('11','J') .gsub('12','Q') .gsub('13','K') .gsub('14','A') .gsub('15','2') + ' ' + card.suit}, value: card.id}
%img{src: "/assets/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') }
-# = image_tag("hi")
%input{type: "submit", value: "Play Hand", name: "commit"}
-# %input{type: "submit", value: "Pass", name: "pass"}
= f.submit "Pass"

View File

View File

@ -7,7 +7,7 @@
%h1= @table.title
- if @game.startable? && @game.already_has?(current_user)
= link_to 'Start', game_start_path(@game)
= button_to 'Start', start_game_path(@game)
-#.debug
= button_to 'Debug Start', game_start_path(@game), method: :get
@ -54,8 +54,8 @@
- else
%h1 Open table
.controls
- if @game.control_user == current_user
-# .controls
- if @game.controlling_player.soft_token == current_user.soft_token
// Play hand form
= form_for @game, :url => play_hand_game_path(@game), remote: true do |f|
// Provide id of current game
@ -83,45 +83,7 @@
#playerList
#top
.game-seat.position-1
.seat
.seat-controls
- if @seats[0].occupied?
- if @seats[0].occupied_by? current_user
= button_to "Stand",
stand_seat_path(@seats[0])
- else
= button_to "Sit",
sit_seat_path(@seats[0])
- if @seats[0].player
.player
.user-name= @seats[0].player.display_name
- if @game.started?
.inventory-count= @seats[0].player.inventory.count
-# Show player controls if player is owned by current_user
- if @seats[0].player.soft_token = current_user.soft_token
= form_for @game, play_hand_game_path
%ul#inventory
- @seats[0].player.inventory.each do |card|
%li
%label
%input{form: "player_controls_" + card.player_id,
type: "checkbox",
name: "player_card_ids[]",
data: {card_name: card.rank.gsub('11','J') .gsub('12','Q') .gsub('13','K') .gsub('14','A') .gsub('15','2') + ' ' + card.suit}, value: card.id}
%img{src: "/assets/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') }
-# = image_tag("hi")
%input{type: "submit",
value: "Play Hand",
name: "commit"}
%input{disabled: (@game.controlling_player_id == @seats[0].player.id ? nil : "disabled"),
type: "submit",
value: "Pass",
name: "pass"}
= render "seat", seat: @seats[0]
#mid
= render "seat", seat: @seats[1]