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