Adds top seat, player, controls
This commit is contained in:
parent
e5145206f8
commit
dba4e6e871
@ -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"}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,69 +1,29 @@
|
||||
{/* 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 className="game-seat position-2">
|
||||
<Seat
|
||||
{...this.props.game.seats[1]}
|
||||
game={this.props.game}
|
||||
onPlayHandSubmit={this.props.onPlayHandSubmit}
|
||||
current_user={this.props.current_user}
|
||||
onSeatSubmit={this.props.onSeatSubmit} />
|
||||
</div>
|
||||
<HandToBeat cards={this.props.game.cards_to_beat} />
|
||||
<div className="game-seat position-3">
|
||||
<Seat
|
||||
{...this.props.game.seats[2]}
|
||||
game={this.props.game}
|
||||
onPlayHandSubmit={this.props.onPlayHandSubmit}
|
||||
current_user={this.props.current_user}
|
||||
onSeatSubmit={this.props.onSeatSubmit} />
|
||||
</div>
|
||||
</div>
|
||||
<div id="bot">
|
||||
<div className="game-seat position-4">
|
||||
<Seat
|
||||
{...this.props.game.seats[3]}
|
||||
game={this.props.game}
|
||||
onPlayHandSubmit={this.props.onPlayHandSubmit}
|
||||
current_user={this.props.current_user}
|
||||
onSeatSubmit={this.props.onSeatSubmit} />
|
||||
</div>
|
||||
</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">
|
||||
<Seat
|
||||
{...this.props.game.seats[1]}
|
||||
game={this.props.game}
|
||||
onPlayHandSubmit={this.props.onPlayHandSubmit}
|
||||
current_user={this.props.current_user}
|
||||
onSeatSubmit={this.props.onSeatSubmit} />
|
||||
</div>
|
||||
<HandToBeat cards={this.props.game.cards_to_beat} />
|
||||
<div className="game-seat position-3">
|
||||
<Seat
|
||||
{...this.props.game.seats[2]}
|
||||
game={this.props.game}
|
||||
onPlayHandSubmit={this.props.onPlayHandSubmit}
|
||||
current_user={this.props.current_user}
|
||||
onSeatSubmit={this.props.onSeatSubmit} />
|
||||
</div>
|
||||
</div>
|
||||
<div id="bot">
|
||||
<div className="game-seat position-4">
|
||||
<Seat
|
||||
{...this.props.game.seats[3]}
|
||||
game={this.props.game}
|
||||
onPlayHandSubmit={this.props.onPlayHandSubmit}
|
||||
current_user={this.props.current_user}
|
||||
onSeatSubmit={this.props.onSeatSubmit} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user