Add play hand and pass function. 2 player game capable
This commit is contained in:
parent
918fd8f81e
commit
72726117cd
@ -35,13 +35,13 @@ class GamesController < ApplicationController
|
||||
|
||||
# Player action: pass
|
||||
# TODO: wtf do we need game params for? And why nest hand_type in it?
|
||||
if params[:game]
|
||||
if params[:game][:hand_type] == 'pass'
|
||||
# if params[:game]
|
||||
if params[:hand_type] == 'Pass'
|
||||
@game.set_controlling_player 'next'
|
||||
flash[:notice] = 'Successfully passed.'
|
||||
@game.save
|
||||
end
|
||||
end
|
||||
# end
|
||||
|
||||
# Player action: play_hand
|
||||
if params[:player_card_ids]
|
||||
@ -74,8 +74,9 @@ class GamesController < ApplicationController
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(@game) }
|
||||
## TODO: Return status message of attempt to play_hand
|
||||
# flash[:notice] = 'I hi'
|
||||
format.html { redirect_to(@game.table) }
|
||||
format.json { render json: @game }
|
||||
end
|
||||
|
||||
|
||||
@ -17,18 +17,22 @@
|
||||
|
||||
-# 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) do |f|
|
||||
= form_for(@game,
|
||||
url: play_hand_game_path,
|
||||
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
|
||||
%input{form: "player_controls_" + card.player_id.to_s,
|
||||
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') }
|
||||
= check_box_tag 'player_card_ids[]', card.id
|
||||
-# %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}}
|
||||
%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') }
|
||||
|
||||
%input{type: "submit", value: "Play Hand", name: "commit"}
|
||||
-# %input{type: "submit", value: "Pass", name: "pass"}
|
||||
= f.submit "Pass"
|
||||
%input{type: "submit", value: "Play Hand", name: "hand_type"}
|
||||
%input{type: "submit", value: "Pass", name: "hand_type"}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user