Adds top seat, player, controls

This commit is contained in:
Jesse C. Fisher 2019-10-20 05:06:22 -07:00 committed by Jesse C. Fisher
parent 7183d91d7c
commit aab6008279
3 changed files with 54 additions and 69 deletions

View File

@ -100,3 +100,28 @@
- 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"}

View File

@ -26,7 +26,7 @@ Rails.application.routes.draw do
get 'my-inventory'
post 'start'
post 'join'
patch 'play_hand'
post 'play_hand'
end
resources :seats do
member do

View File

@ -1,44 +1,4 @@
{/* Show player controls if player is owned by current_user */}
{(this.props.soft_token == this.props.game.current_user_soft_token) && (this.props.game.is_started == true)
? (<PlayerControls
key={this.props.id}
onPlayHandSubmit={this.props.onPlayHandSubmit}
game_id={this.props.game.id}
player_id={this.props.id}
inventory={this.props.inventory}
controlling_player_id={this.props.game.controlling_player_id} /> )
:
<div className='inventory'>
{[...Array(this.props.inventory_count)].map((card, index) => <img key={index} src='/assets/cards/png/back-pink.png' />)}
</div>
}
</div>
<Player
game={this.props.game}
onPlayHandSubmit={this.props.onPlayHandSubmit}
{...this.props.player} />
: "Empty" }
</div>
<Seat
{...this.props.game.seats[0]}
game={this.props.game}
onPlayHandSubmit={this.props.onPlayHandSubmit}
current_user={this.props.current_user}
onSeatSubmit={this.props.onSeatSubmit} />
</div>
</div>
<div id="mid">
<div className="game-seat position-2">
<div className="game-seat position-2">
<Seat
{...this.props.game.seats[1]}
game={this.props.game}