module Card::Set::Event::SkipAndTrigger
opt into (trigger) or out of (skip) events
Public Instance Methods
Source
# File lib/card/set/event/skip_and_trigger.rb, line 17 def skip= skip_val @skip_hash = @full_skip_hash = nil @skip = skip_val end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 38 def skip_event! *events @full_skip_hash = nil force_events events, act_skip_hash end
force skipping this event for all cards in act
Source
# File lib/card/set/event/skip_and_trigger.rb, line 68 def skip_event? event full_skip_hash.key? event.to_s end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 44 def skip_event_in_action! *events force_events events, full_skip_hash end
force skipping this event for this card only
Source
# File lib/card/set/event/skip_and_trigger.rb, line 60 def skip_hash @skip_hash ||= hash_with_value skip, true end
hash form of raw skip setting, eg { “my_event” => true }
Source
# File lib/card/set/event/skip_and_trigger.rb, line 22 def skip_in_action= skip_val @skip_hash = @full_skip_hash = nil @skip_in_action = skip_val end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 27 def trigger= trigger_val @trigger_hash = @full_trigger_hash = nil @trigger = trigger_val end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 49 def trigger_event! *events @full_trigger_hash = nil force_events events, act_trigger_hash end
force triggering this event (when it comes up) for all cards in act
Source
# File lib/card/set/event/skip_and_trigger.rb, line 72 def trigger_event? event full_trigger_hash.key? event.to_s end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 55 def trigger_event_in_action! *events force_events events, full_trigger_hash end
force triggering this event (when it comes up) for this card only
Source
# File lib/card/set/event/skip_and_trigger.rb, line 64 def trigger_hash @trigger_hash ||= hash_with_value trigger, true end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 32 def trigger_in_action= trigger_val @trigger_hash = @full_trigger_hash = nil @trigger_in_action = trigger_val end
Private Instance Methods
Source
# File lib/card/set/event/skip_and_trigger.rb, line 96 def act_skip_hash (act_card || self).skip_hash end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 105 def act_trigger_hash (act_card || self).trigger_hash end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 115 def force_events events, hash events.each { |e| hash[e.to_s] = :force } end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 92 def full_skip_hash @full_skip_hash ||= act_skip_hash.merge hash_with_value(skip_in_action, true) end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 100 def full_trigger_hash @full_trigger_hash ||= act_trigger_hash.merge hash_with_value(trigger_in_action, true) end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 109 def hash_with_value array, value Array.wrap(array).each_with_object({}) do |event, hash| hash[event.to_s] = value end end
Source
# File lib/card/set/event/skip_and_trigger.rb, line 80 def skip_condition_applies? event, allowed return true unless (val = full_skip_hash[event.name.to_s]) allowed ? val.blank? : (val != :force) end
“applies always means event can run so if skip_condition_applies?, we do NOT skip
Source
# File lib/card/set/event/skip_and_trigger.rb, line 86 def trigger_condition_applies? event, required return true unless required full_trigger_hash[event.name.to_s].present? end