Skip to content

Commit

Permalink
Refactor shared Aura + Equipment methods into Attachment class
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Jan 31, 2024
1 parent f9c0682 commit 58696bc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 65 deletions.
30 changes: 30 additions & 0 deletions lib/magic/cards/attachment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Magic
module Cards
class Attachment < Card
def resolve!(target:)
permanent = super()
permanent.attach_to!(target)
end

def power_modification
0
end

def toughness_modification
0
end

def keyword_grants
[]
end

def type_grants
[]
end

def can_activate_ability?(_)
true
end
end
end
end
31 changes: 1 addition & 30 deletions lib/magic/cards/aura.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
module Magic
module Cards
class Aura < Card
class Aura < Attachment
TYPE_LINE = "Enchantment -- Aura"

def single_target?
true
end

def resolve!(target:)
permanent = super()
permanent.attach_to!(target)
end

def power_modification
0
end

def toughness_modification
0
end

def keyword_grants
[]
end

def type_grants
[]
end

def can_activate_ability?(_)
true
end
end
end
end
36 changes: 1 addition & 35 deletions lib/magic/cards/equipment.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Magic
module Cards
class Equipment < Card
class Equipment < Attachment
TYPE_LINE = "Artifact -- Equipment"

def self.equip(equip_cost)
Expand All @@ -20,40 +20,6 @@ def resolve!(target:)
[equip]
end
end

def resolve!(target:)
permanent = super()
permanent.attach_to!(target)
end

def single_target?
true
end

def resolve!(target:)
permanent = super()
permanent.attach_to!(target)
end

def power_modification
0
end

def toughness_modification
0
end

def keyword_grants
[]
end

def type_grants
[]
end

def can_activate_ability?(_)
true
end
end
end
end

0 comments on commit 58696bc

Please sign in to comment.