Module: PlayerActionsHelper
Overview
Helpers for PlayerActions
controller and views.
Instance Method Summary
collapse
#error?, #help_link, #link_with_glyph, #log_error, #match, #replace_page_contents, #reset_to_match_entry_view, #user, #user_initialized?, #user_name
Instance Method Details
#acting_player_id(player_seat) ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'app/helpers/player_actions_helper.rb', line 25
def acting_player_id(player_seat)
if (
!match_view.hand_ended? &&
match_view.slice.seat_next_to_act == player_seat
)
'acting_player'
else
'not_acting_player'
end
end
|
#custom_hotkey_amount_field_tag ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'app/helpers/player_actions_helper.rb', line 59
def custom_hotkey_amount_field_tag
number_field_tag(
"custom_amount",
'',
maxlength: 4,
size: 4,
name: "#{custom_hotkeys_amount_param_key}[]",
min: 0,
max: 9999,
step: 0.01
)
end
|
#custom_hotkey_key_field_tag ⇒ Object
Assumes that it will be called right after the corresponding custom_hotkey_amount_field_tag call
55
56
57
|
# File 'app/helpers/player_actions_helper.rb', line 55
def custom_hotkey_key_field_tag
text_field_tag "custom_key", '', maxlength: 1, size: 1, name: "#{custom_hotkeys_keys_param_key}[]"
end
|
#custom_hotkeys_amount_param_key ⇒ Object
95
96
97
|
# File 'app/helpers/player_actions_helper.rb', line 95
def custom_hotkeys_amount_param_key
'custom_hotkeys_amount'
end
|
#custom_hotkeys_keys_param_key ⇒ Object
98
99
100
|
# File 'app/helpers/player_actions_helper.rb', line 98
def custom_hotkeys_keys_param_key
'custom_hotkeys_key'
end
|
#customize_hotkeys_html_id ⇒ Object
92
93
94
|
# File 'app/helpers/player_actions_helper.rb', line 92
def customize_hotkeys_html_id
'customize_hotkeys'
end
|
#fold_disabled_when ⇒ Object
118
119
120
121
122
123
|
# File 'app/helpers/player_actions_helper.rb', line 118
def fold_disabled_when
!(
user_must_act? &&
match_view.legal_actions.include?(AcpcPokerTypes::PokerAction::FOLD)
)
end
|
#fold_html_class ⇒ Object
TODO:
Do not require state, remove from this module
73
|
# File 'app/helpers/player_actions_helper.rb', line 73
def fold_html_class() 'fold' end
|
#hotkey_field_tag(name, initial_value = '', options = {}) ⇒ Object
50
51
52
|
# File 'app/helpers/player_actions_helper.rb', line 50
def hotkey_field_tag(name, initial_value='', options={})
text_field_tag name, initial_value, options.merge(maxlength: 1, size: 1, name: "#{hotkeys_param_key}[#{name}]")
end
|
#hotkeys_param_key ⇒ Object
89
90
91
|
# File 'app/helpers/player_actions_helper.rb', line 89
def hotkeys_param_key
'hotkeys'
end
|
#html_character(suit_symbol) ⇒ Object
86
87
88
|
# File 'app/helpers/player_actions_helper.rb', line 86
def html_character(suit_symbol)
Suit::DOMAIN[suit_symbol][:html_character]
end
|
80
|
# File 'app/helpers/player_actions_helper.rb', line 80
def leave_match_button_html_class() 'leave-btn' end
|
#leave_match_confirmation_message ⇒ Object
82
83
84
|
# File 'app/helpers/player_actions_helper.rb', line 82
def leave_match_confirmation_message
"Are you sure you want to leave this match?"
end
|
#leave_match_label ⇒ Object
85
|
# File 'app/helpers/player_actions_helper.rb', line 85
def leave_match_label() "Leave Match" end
|
138
139
140
141
142
143
144
145
146
|
# File 'app/helpers/player_actions_helper.rb', line 138
def make_wager_button_label
label = if match_view.legal_actions.include?('b')
'Bet'
else
'Raise'
end
label += ' to' if match_view.no_limit?
label
end
|
#match_view ⇒ Object
49
|
# File 'app/helpers/player_actions_helper.rb', line 49
def match_view() @match_view end
|
#nav_leave_html_class ⇒ Object
81
|
# File 'app/helpers/player_actions_helper.rb', line 81
def nav_leave_html_class() 'leave' end
|
46
47
48
|
# File 'app/helpers/player_actions_helper.rb', line 46
def next_hand_button_visible?
!@match_view.match_ended? && @match_view.hand_ended?
end
|
#next_hand_id ⇒ Object
76
|
# File 'app/helpers/player_actions_helper.rb', line 76
def next_hand_id() 'next_state' end
|
#no_change?(action_label, new_key) ⇒ Boolean
101
102
103
104
|
# File 'app/helpers/player_actions_helper.rb', line 101
def no_change?(action_label, new_key)
old_hotkey = user.hotkeys.where(action: action_label).first
old_hotkey && old_hotkey.key == new_key
end
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'app/helpers/player_actions_helper.rb', line 124
def pass_action_button_label
if (
match_view.legal_actions.include?(AcpcPokerTypes::PokerAction::CALL) &&
match_view.amount_for_next_player_to_call > 0
)
if match_view.no_limit?
"Call (#{match_view.amount_for_next_player_to_call.to_i})"
else
'Call'
end
else
'Check'
end
end
|
#pass_html_class ⇒ Object
74
|
# File 'app/helpers/player_actions_helper.rb', line 74
def pass_html_class() 'pass' end
|
#replace_page_contents_with_updated_game_view(match_id) ⇒ Object
Replaces the page contents with an updated game view
15
16
17
18
19
20
21
22
23
24
|
# File 'app/helpers/player_actions_helper.rb', line 15
def replace_page_contents_with_updated_game_view(match_id)
@match_view ||= MatchView.new(match_id)
@partial ||= 'player_actions/index'
@update_state_periodically = false unless @update_state_periodically
replace_page_contents(
@partial,
nil,
"#{ApplicationDefs::HTML_CLASS_PREFIX}#{ApplicationDefs::POKER_VIEW_HTML_CLASS}"
)
end
|
#update_hotkeys_html_class ⇒ Object
79
|
# File 'app/helpers/player_actions_helper.rb', line 79
def update_hotkeys_html_class() 'update_hotkeys' end
|
#update_id ⇒ Object
77
|
# File 'app/helpers/player_actions_helper.rb', line 77
def update_id() 'update' end
|
#update_state_html_class ⇒ Object
78
|
# File 'app/helpers/player_actions_helper.rb', line 78
def update_state_html_class() 'update_state' end
|
#user_must_act? ⇒ Boolean
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/helpers/player_actions_helper.rb', line 35
def user_must_act?
(
!waiting_for_response && (
(
@match_view.users_turn_to_act? &&
@match_view.match.slices.length == 1
) ||
@match_view.hand_ended?
)
)
end
|
#wager_disabled_when ⇒ Object
109
110
111
112
113
114
115
116
117
|
# File 'app/helpers/player_actions_helper.rb', line 109
def wager_disabled_when
!(
user_must_act? &&
(
match_view.legal_actions.include?(AcpcPokerTypes::PokerAction::RAISE) ||
match_view.legal_actions.include?(AcpcPokerTypes::PokerAction::BET)
)
)
end
|
#wager_html_class ⇒ Object
75
|
# File 'app/helpers/player_actions_helper.rb', line 75
def wager_html_class() 'wager' end
|
#waiting_for_response ⇒ Object
105
106
107
|
# File 'app/helpers/player_actions_helper.rb', line 105
def waiting_for_response
session['waiting_for_response']
end
|