Skip to content

Commit

Permalink
Rename TriggeredAbility::Base -> TriggeredAbility
Browse files Browse the repository at this point in the history
Fixes #507
  • Loading branch information
radar committed Feb 26, 2024
1 parent 6e2347b commit 1de2d53
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/magic/cards/barrin_tolarian_archmage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/magic/cards/light_of_promise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def target_choices
battlefield.creatures
end

class LifeGain < TriggeredAbility::Base
class LifeGain < TriggeredAbility
def should_perform?
event.player == controller
end
Expand Down
2 changes: 1 addition & 1 deletion lib/magic/cards/profane_memento.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/magic/cards/spined_megalodon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/magic/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions lib/magic/triggered_ability.rb
Original file line number Diff line number Diff line change
@@ -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
18 changes: 0 additions & 18 deletions lib/magic/triggered_ability/base.rb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/magic/triggered_ability/death.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Magic
module TriggeredAbility
class Death < Base
class TriggeredAbility
class Death < TriggeredAbility
end
end
end
4 changes: 2 additions & 2 deletions lib/magic/triggered_ability/enter_the_battlefield.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Magic
module TriggeredAbility
class EnterTheBattlefield < Base
class TriggeredAbility
class EnterTheBattlefield < TriggeredAbility
end
end
end
4 changes: 2 additions & 2 deletions lib/magic/triggered_ability/leave_the_battlefield.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Magic
module TriggeredAbility
class LeaveTheBattlefield < Base
class TriggeredAbility
class LeaveTheBattlefield < TriggeredAbility
end
end
end

0 comments on commit 1de2d53

Please sign in to comment.