-
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.
- Loading branch information
Showing
6 changed files
with
167 additions
and
20 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,27 @@ | ||
module Magic | ||
module Cards | ||
CanopyTactician = Creature("Canopy Tactician") do | ||
cost generic: 3, green: 1 | ||
creature_type "Elf Warrior" | ||
power 3 | ||
toughness 3 | ||
end | ||
|
||
class CanopyTactician < Creature | ||
class PowerAndToughnessModification < Abilities::Static::PowerAndToughnessModification | ||
modify power: 1, toughness: 1 | ||
other_creatures "Elf" | ||
end | ||
|
||
def static_abilities = [PowerAndToughnessModification] | ||
|
||
class ManaAbility < Magic::TapManaAbility | ||
def resolve! | ||
source.controller.add_mana(green: 3) | ||
end | ||
end | ||
|
||
def activated_abilities = [ManaAbility] | ||
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,49 @@ | ||
module Magic | ||
module Cards | ||
class CrownOfSkemfar < Aura | ||
card_name "Crown of Skemfar" | ||
cost "{2}{G}{G}" | ||
|
||
def target_choices | ||
battlefield.creatures | ||
end | ||
|
||
def elves | ||
battlefield.controlled_by(owner).by_type("Elf").count | ||
end | ||
|
||
def power_modification | ||
elves | ||
end | ||
|
||
def toughness_modification | ||
elves | ||
end | ||
|
||
def keyword_grants | ||
[Keywords::REACH] | ||
end | ||
|
||
class ReturnFromGraveyard < Magic::ActivatedAbility | ||
def costs = [Costs::Mana.new(generic: 2, green: 1)] | ||
|
||
def resolve! | ||
source.controller.graveyard.remove(source) | ||
source.controller.hand.add(source) | ||
end | ||
end | ||
|
||
def can_activate_ability?(ability) | ||
return true unless ability.is_a?(ReturnFromGraveyard) | ||
|
||
return true if self.zone == controller.graveyard | ||
|
||
false | ||
end | ||
|
||
def activated_abilities | ||
[ReturnFromGraveyard.new(source: self)] | ||
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
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,31 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Magic::Cards::CanopyTactician do | ||
include_context "two player game" | ||
|
||
subject! { ResolvePermanent("Canopy Tactician", owner: p1) } | ||
let!(:lathril) { ResolvePermanent("Lathril, Blade Of The Elves", owner: p1) } | ||
|
||
context "static ability" do | ||
it "gives lathril +1/+1" do | ||
expect(lathril.power).to eq(3) | ||
expect(lathril.toughness).to eq(4) | ||
end | ||
|
||
it "does not give itself the boost" do | ||
expect(subject.power).to eq(3) | ||
expect(subject.toughness).to eq(3) | ||
end | ||
end | ||
|
||
context "mana ability" do | ||
def activate_ability | ||
p1.activate_ability(ability: subject.activated_abilities.first) | ||
end | ||
|
||
it "adds 3 green mana" do | ||
activate_ability | ||
expect(p1.mana_pool[:green]).to eq(3) | ||
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,43 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Magic::Cards::CrownOfSkemfar do | ||
include_context "two player game" | ||
|
||
subject(:crown_of_skemfar) { Card("Crown Of Skemfar") } | ||
|
||
let!(:wood_elves) { ResolvePermanent("Wood Elves") } | ||
|
||
it "attaches to a creature" do | ||
p1.add_mana(green: 4) | ||
action = cast_action(player: p1, card: subject) | ||
.pay_mana(green: 2, generic: { green: 2 }) | ||
.targeting(wood_elves) | ||
game.take_action(action) | ||
game.stack.resolve! | ||
expect(wood_elves.power).to eq(2) | ||
expect(wood_elves.toughness).to eq(2) | ||
expect(wood_elves.has_keyword?(Magic::Cards::Keywords::REACH)).to eq(true) | ||
|
||
expect(p1.permanents.by_name("Crown of Skemfar").count).to eq(1) | ||
end | ||
|
||
context "return from graveyard to hand" do | ||
let(:crown_of_skemfar) { Card("Crown Of Skemfar") } | ||
|
||
before do | ||
p1.graveyard.add(crown_of_skemfar) | ||
end | ||
|
||
it "returns to hand" do | ||
ability = crown_of_skemfar.activated_abilities.first | ||
p1.add_mana(green: 3) | ||
p1.activate_ability(ability: ability) do | ||
_1.pay_mana(generic: { green: 2 }, green: 1) | ||
end | ||
|
||
game.tick! | ||
|
||
expect(p1.hand).to include(crown_of_skemfar) | ||
end | ||
end | ||
end |