-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #247
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module Magic | ||
module Cards | ||
class Equipment < Card | ||
TYPE_LINE = "Artifact -- Equipment" | ||
|
||
|
||
def self.equip(cost) | ||
equip = Class.new(ActivatedAbility) do | ||
def costs | ||
[Costs::Mana.new(generic: 1)] | ||
end | ||
|
||
def target_choices | ||
game.battlefield.creatures.controlled_by(controller) | ||
end | ||
|
||
def resolve!(target:) | ||
target.attachments << source | ||
end | ||
end | ||
|
||
define_method(:activated_abilities) do | ||
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Magic | ||
module Cards | ||
ShortSword = Equipment("Short Sword") do | ||
cost generic: 1 | ||
|
||
equip 1 | ||
|
||
def power_modification | ||
1 | ||
end | ||
|
||
def toughness_modification | ||
1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Magic::Cards::ShortSword do | ||
include_context "two player game" | ||
|
||
subject(:permanent) { ResolvePermanent("Short Sword") } | ||
|
||
context "equips, gives a +1/+1" do | ||
let!(:wood_elves) { ResolvePermanent("Wood Elves", owner: p1) } | ||
|
||
it "buffs wood elves" do | ||
p1.add_mana(white: 1) | ||
p1.activate_ability(ability: permanent.activated_abilities.first) do | ||
_1.targeting(wood_elves) | ||
_1.pay_mana(generic: { white: 1 }) | ||
end | ||
|
||
expect(wood_elves.attachments.count).to eq(1) | ||
expect(wood_elves.attachments.first.name).to eq("Short Sword") | ||
expect(wood_elves.power).to eq(2) | ||
expect(wood_elves.toughness).to eq(2) | ||
end | ||
end | ||
end |