Class: Ankit::Challenge::Progress
Instance Attribute Summary collapse
Instance Method Summary
collapse
#make_happen
#card_wildcard_for, #to_card_name, #to_card_path
find_latest_event_for, find_latest_event_named, #latest_event_for
#format_as_score
#last_round, #latest_round, #next_round, #round_proceeded
Constructor Details
#initialize(session, slots) ⇒ Progress
Returns a new instance of Progress.
140
141
142
143
|
# File 'lib/ankit/challenge.rb', line 140
def initialize(session, slots)
@session, @slots, @index = session, slots, 0
@this_round = latest_round
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
138
139
140
|
# File 'lib/ankit/challenge.rb', line 138
def index
@index
end
|
#session ⇒ Object
Returns the value of attribute session.
138
139
140
|
# File 'lib/ankit/challenge.rb', line 138
def session
@session
end
|
#slots ⇒ Object
Returns the value of attribute slots.
138
139
140
|
# File 'lib/ankit/challenge.rb', line 138
def slots
@slots
end
|
#this_round ⇒ Object
Returns the value of attribute this_round.
138
139
140
|
# File 'lib/ankit/challenge.rb', line 138
def this_round
@this_round
end
|
Instance Method Details
#already_failed? ⇒ Boolean
161
|
# File 'lib/ankit/challenge.rb', line 161
def already_failed?; current_slot.rating == :failed; end
|
#attack ⇒ Object
163
164
165
166
|
# File 'lib/ankit/challenge.rb', line 163
def attack
current_slot.rating = :attacking unless current_slot.rating
self
end
|
#current_card ⇒ Object
155
|
# File 'lib/ankit/challenge.rb', line 155
def current_card; card_at(current_path); end
|
#current_path ⇒ Object
154
|
# File 'lib/ankit/challenge.rb', line 154
def current_path; current_slot.path; end
|
#current_slot ⇒ Object
153
|
# File 'lib/ankit/challenge.rb', line 153
def current_slot; @slots[@index]; end
|
#fail ⇒ Object
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/ankit/challenge.rb', line 168
def fail
unless already_failed?
last_slot = current_slot
last_slot.rating = :failed
last_slot.event = make_happen(FailCommand::EVENT_HAPPENING, to_card_name(current_path), this_round)
session.failed_on(last_slot.event)
end
self
end
|
#indicator ⇒ Object
191
192
193
194
195
196
197
198
199
200
|
# File 'lib/ankit/challenge.rb', line 191
def indicator
@slots.inject("") do |a, i|
a += case i.rating
when :failed; "x"
when :passed; "o"
when :attacking; "*"
else; "-"
end
end
end
|
#last_card ⇒ Object
152
|
# File 'lib/ankit/challenge.rb', line 152
def last_card; card_at(last_path); end
|
#last_path ⇒ Object
151
|
# File 'lib/ankit/challenge.rb', line 151
def last_path; last_slot.path; end
|
#last_slot ⇒ Object
150
|
# File 'lib/ankit/challenge.rb', line 150
def last_slot; @slots[@index-1]; end
|
#maturities ⇒ Object
213
|
# File 'lib/ankit/challenge.rb', line 213
def maturities; slots.map(&:maturity); end
|
#nfailed ⇒ Object
159
|
# File 'lib/ankit/challenge.rb', line 159
def nfailed; @slots.count { |c| c.rating == :failed }; end
|
#npassed ⇒ Object
158
|
# File 'lib/ankit/challenge.rb', line 158
def npassed; @slots.count { |c| c.rating == :passed }; end
|
#over? ⇒ Boolean
157
|
# File 'lib/ankit/challenge.rb', line 157
def over?; @slots.size <= @index; end
|
#pass ⇒ Object
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/ankit/challenge.rb', line 179
def pass
unless already_failed?
last_slot = current_slot
last_slot.rating = :passed
last_slot.event = make_happen(PassCommand::EVENT_HAPPENING, to_card_name(current_path), this_round)
session.passed_on(last_slot.event)
end
@index += 1
self
end
|
#round_delta ⇒ Object
145
146
147
|
# File 'lib/ankit/challenge.rb', line 145
def round_delta
latest_round - this_round
end
|
#runtime ⇒ Object
149
|
# File 'lib/ankit/challenge.rb', line 149
def runtime; @session.runtime; end
|
#size ⇒ Object
156
|
# File 'lib/ankit/challenge.rb', line 156
def size; @slots.size; end
|
#styled_indicator ⇒ Object