From 1de2d531444a6356e822c3ddfdd3f5cbb8e8c039 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Tue, 27 Feb 2024 06:49:06 +1100 Subject: [PATCH] Rename TriggeredAbility::Base -> TriggeredAbility Fixes #507 --- lib/magic/cards/barrin_tolarian_archmage.rb | 2 +- lib/magic/cards/light_of_promise.rb | 2 +- lib/magic/cards/profane_memento.rb | 2 +- lib/magic/cards/spined_megalodon.rb | 2 +- lib/magic/stack.rb | 2 +- lib/magic/triggered_ability.rb | 16 ++++++++++++++++ lib/magic/triggered_ability/base.rb | 18 ------------------ lib/magic/triggered_ability/death.rb | 4 ++-- .../triggered_ability/enter_the_battlefield.rb | 4 ++-- .../triggered_ability/leave_the_battlefield.rb | 4 ++-- 10 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 lib/magic/triggered_ability.rb delete mode 100644 lib/magic/triggered_ability/base.rb diff --git a/lib/magic/cards/barrin_tolarian_archmage.rb b/lib/magic/cards/barrin_tolarian_archmage.rb index 5ce86df..e8b4c2c 100644 --- a/lib/magic/cards/barrin_tolarian_archmage.rb +++ b/lib/magic/cards/barrin_tolarian_archmage.rb @@ -31,7 +31,7 @@ def perform end end - class BeginningOfEndStepTrigger < TriggeredAbility::Base + class BeginningOfEndStepTrigger < TriggeredAbility def should_perform? cards_returned_to_hand = game.current_turn.events.select do |event| next unless event.is_a?(Events::PermanentEnteredZone) diff --git a/lib/magic/cards/light_of_promise.rb b/lib/magic/cards/light_of_promise.rb index 69d64d4..8a319e1 100644 --- a/lib/magic/cards/light_of_promise.rb +++ b/lib/magic/cards/light_of_promise.rb @@ -10,7 +10,7 @@ def target_choices battlefield.creatures end - class LifeGain < TriggeredAbility::Base + class LifeGain < TriggeredAbility def should_perform? event.player == controller end diff --git a/lib/magic/cards/profane_memento.rb b/lib/magic/cards/profane_memento.rb index d106940..9570628 100644 --- a/lib/magic/cards/profane_memento.rb +++ b/lib/magic/cards/profane_memento.rb @@ -5,7 +5,7 @@ class ProfaneMemento < Card COST = { any: 1 } TYPE_LINE = "Artifact" - class PermanentEnteredZoneTrigger < TriggeredAbility::Base + class PermanentEnteredZoneTrigger < TriggeredAbility def should_perform? event.to.graveyard? && event.card.creature? && event.card.controller != controller end diff --git a/lib/magic/cards/spined_megalodon.rb b/lib/magic/cards/spined_megalodon.rb index 9a0902d..99161eb 100644 --- a/lib/magic/cards/spined_megalodon.rb +++ b/lib/magic/cards/spined_megalodon.rb @@ -9,7 +9,7 @@ class SpinedMegalodon < Creature keywords :hexproof - class ScryTrigger < TriggeredAbility::Base + class ScryTrigger < TriggeredAbility def should_perform? return false if event.attacks.none? { |attack| attack.attacker == actor } true diff --git a/lib/magic/stack.rb b/lib/magic/stack.rb index 517afc4..07addc3 100644 --- a/lib/magic/stack.rb +++ b/lib/magic/stack.rb @@ -56,7 +56,7 @@ def spells end def abilities - @stack.select { |item| item.is_a?(Magic::Actions::ActivateAbility) || item.is_a?(TriggeredAbility::Base) } + @stack.select { |item| item.is_a?(Magic::Actions::ActivateAbility) || item.is_a?(TriggeredAbility) } end def cards diff --git a/lib/magic/triggered_ability.rb b/lib/magic/triggered_ability.rb new file mode 100644 index 0000000..fdca5e7 --- /dev/null +++ b/lib/magic/triggered_ability.rb @@ -0,0 +1,16 @@ +module Magic + class TriggeredAbility + include BattlefieldFilters + attr_reader :event, :actor + + def initialize(event:, actor:) + @event = event + @actor = actor + end + + def perform! + return unless should_perform? + call + end + end +end diff --git a/lib/magic/triggered_ability/base.rb b/lib/magic/triggered_ability/base.rb deleted file mode 100644 index c53dc3a..0000000 --- a/lib/magic/triggered_ability/base.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Magic - module TriggeredAbility - class Base - include BattlefieldFilters - attr_reader :event, :actor - - def initialize(event:, actor:) - @event = event - @actor = actor - end - - def perform! - return unless should_perform? - call - end - end - end -end diff --git a/lib/magic/triggered_ability/death.rb b/lib/magic/triggered_ability/death.rb index d546fba..d5ad364 100644 --- a/lib/magic/triggered_ability/death.rb +++ b/lib/magic/triggered_ability/death.rb @@ -1,6 +1,6 @@ module Magic - module TriggeredAbility - class Death < Base + class TriggeredAbility + class Death < TriggeredAbility end end end diff --git a/lib/magic/triggered_ability/enter_the_battlefield.rb b/lib/magic/triggered_ability/enter_the_battlefield.rb index a011c56..c8356eb 100644 --- a/lib/magic/triggered_ability/enter_the_battlefield.rb +++ b/lib/magic/triggered_ability/enter_the_battlefield.rb @@ -1,6 +1,6 @@ module Magic - module TriggeredAbility - class EnterTheBattlefield < Base + class TriggeredAbility + class EnterTheBattlefield < TriggeredAbility end end end diff --git a/lib/magic/triggered_ability/leave_the_battlefield.rb b/lib/magic/triggered_ability/leave_the_battlefield.rb index a4b5dcd..2813b36 100644 --- a/lib/magic/triggered_ability/leave_the_battlefield.rb +++ b/lib/magic/triggered_ability/leave_the_battlefield.rb @@ -1,6 +1,6 @@ module Magic - module TriggeredAbility - class LeaveTheBattlefield < Base + class TriggeredAbility + class LeaveTheBattlefield < TriggeredAbility end end end