Module: MatchStartHelper
- Included in:
- MatchStartController
- Defined in:
- app/helpers/match_start_helper.rb
Instance Method Summary collapse
- #hidden_begin_match ⇒ Object
-
#hidden_begin_match_form(match_id) ⇒ Object
Hidden form, within which game parameters may be placed that can be submitted to the
PlayerActionsController
. - #hidden_game_def_file_name ⇒ Object
- #hidden_match_id ⇒ Object
- #hidden_match_name ⇒ Object
- #hidden_match_start_poll_form(match_id) ⇒ Object
- #hidden_num_hands ⇒ Object
- #hidden_poll ⇒ Object
- #hidden_rand_seed ⇒ Object
- #hidden_seat ⇒ Object
- #hidden_start_opponents ⇒ Object
- #hidden_submit ⇒ Object
- #label_for_required(label) ⇒ Object
- #matches_to_join ⇒ Object
- #matches_to_rejoin ⇒ Object
- #num_players(game_def_key) ⇒ Object
- #seats_to_join ⇒ Object
- #seats_to_rejoin ⇒ Object
-
#send_parameters_to_connect_to_dealer ⇒ Object
Renders a
JavaScript
template that sends parameters toPlayerActionsController
so that it can connect to an ACPC dealer instance. - #truncate_opponent_names_if_necessary(match_params) ⇒ Object
- #wait_for_match_to_start ⇒ Object
Instance Method Details
#hidden_begin_match ⇒ Object
10 |
# File 'app/helpers/match_start_helper.rb', line 10 def hidden_begin_match() 'hidden-begin_match' end |
#hidden_begin_match_form(match_id) ⇒ Object
Hidden form, within which game parameters may be placed that can be submitted to the PlayerActionsController
.
22 23 24 25 26 27 28 |
# File 'app/helpers/match_start_helper.rb', line 22 def hidden_begin_match_form(match_id) form_tag match_home_url, :remote => true do form = hidden_field_tag(:match_id, match_id, :id => hidden_match_id) form << submit_tag('', :id => hidden_begin_match, style: 'visibility: hidden') end end |
#hidden_game_def_file_name ⇒ Object
4 |
# File 'app/helpers/match_start_helper.rb', line 4 def hidden_game_def_file_name() 'hidden_game_def_file_name' end |
#hidden_match_id ⇒ Object
2 |
# File 'app/helpers/match_start_helper.rb', line 2 def hidden_match_id() 'hidden_id' end |
#hidden_match_name ⇒ Object
3 |
# File 'app/helpers/match_start_helper.rb', line 3 def hidden_match_name() 'hidden_name' end |
#hidden_match_start_poll_form(match_id) ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/helpers/match_start_helper.rb', line 30 def hidden_match_start_poll_form(match_id) form_tag match_start_poll_url, :remote => true do form = hidden_field_tag(:match_id, match_id, :id => hidden_match_id) form << submit_tag('', :id => hidden_poll, style: 'visibility: hidden') end end |
#hidden_num_hands ⇒ Object
5 |
# File 'app/helpers/match_start_helper.rb', line 5 def hidden_num_hands() 'hidden_num_hands' end |
#hidden_poll ⇒ Object
11 |
# File 'app/helpers/match_start_helper.rb', line 11 def hidden_poll() 'hidden-poll' end |
#hidden_rand_seed ⇒ Object
7 |
# File 'app/helpers/match_start_helper.rb', line 7 def hidden_rand_seed() 'hidden_rand_seed' end |
#hidden_seat ⇒ Object
6 |
# File 'app/helpers/match_start_helper.rb', line 6 def hidden_seat() 'hidden_seat' end |
#hidden_start_opponents ⇒ Object
9 |
# File 'app/helpers/match_start_helper.rb', line 9 def hidden_start_opponents() 'hidden_start_opponents' end |
#hidden_submit ⇒ Object
8 |
# File 'app/helpers/match_start_helper.rb', line 8 def hidden_submit() 'hidden_submit' end |
#label_for_required(label) ⇒ Object
38 39 40 |
# File 'app/helpers/match_start_helper.rb', line 38 def label_for_required(label) "<abbr title='required'>*</abbr> #{label}".html_safe end |
#matches_to_join ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/helpers/match_start_helper.rb', line 63 def matches_to_join @matches_to_join ||= Match.asc(:name).all.select do |m| !m.name_from_user.match(/^_+$/) && m.slices.empty? && !m.human_opponent_seats(user.name).empty? end end |
#matches_to_rejoin ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'app/helpers/match_start_helper.rb', line 77 def matches_to_rejoin @matches_to_rejoin ||= Match.asc(:name).all.select do |m| m.user_name == user_name && !m.name_from_user.match(/^_+$/) && !m.finished? && !m.slices.empty? end end |
#num_players(game_def_key) ⇒ Object
42 43 44 |
# File 'app/helpers/match_start_helper.rb', line 42 def num_players(game_def_key) ApplicationDefs.game_definitions[game_def_key][:num_players] end |
#seats_to_join ⇒ Object
70 71 72 73 74 75 |
# File 'app/helpers/match_start_helper.rb', line 70 def seats_to_join matches_to_join.inject({}) do |hash, lcl_match| hash[lcl_match.name] = lcl_match.rejoinable_seats(user.name).sort hash end end |
#seats_to_rejoin ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'app/helpers/match_start_helper.rb', line 85 def seats_to_rejoin matches_to_rejoin.sort_by{ |m| m.name }.inject({}) do |hash, lcl_match| hash[lcl_match.name] = lcl_match.human_opponent_seats hash[lcl_match.name] << lcl_match.seat unless hash[lcl_match.name].include?(lcl_match.seat) hash[lcl_match.name].sort! hash end end |
#send_parameters_to_connect_to_dealer ⇒ Object
Renders a JavaScript
template that sends parameters to PlayerActionsController
so that it can connect to an ACPC dealer instance.
16 17 18 |
# File 'app/helpers/match_start_helper.rb', line 16 def send_parameters_to_connect_to_dealer render 'match_start/send_parameters_to_connect_to_dealer' end |
#truncate_opponent_names_if_necessary(match_params) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/match_start_helper.rb', line 46 def truncate_opponent_names_if_necessary(match_params) while ( match_params[:opponent_names].length > num_players(match_params[:game_definition_key].to_sym) - 1 ) match_params[:opponent_names].pop end match_params[:opponent_names] end |
#wait_for_match_to_start ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/helpers/match_start_helper.rb', line 55 def wait_for_match_to_start respond_to do |format| format.js do replace_page_contents ApplicationDefs::WAIT_FOR_MATCH_TO_START_PARTIAL end end end |