-
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 #231
- Loading branch information
Showing
2 changed files
with
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Magic | ||
module Cards | ||
class LeafkinAvenger < Creature | ||
card_name "Leafkin Avenger" | ||
cost "{2}{R}{G}" | ||
creature_type "Elemental Druid" | ||
power 4 | ||
toughness 3 | ||
|
||
class Ability < ActivatedAbility | ||
costs "{T}" | ||
|
||
def resolve! | ||
count = creatures_you_control.with_power { |power| power >= 4 }.count | ||
controller.add_mana(green: count) | ||
end | ||
end | ||
|
||
class Ability2 < ActivatedAbility | ||
costs "{7}{R}" | ||
|
||
def target_choices | ||
game.players + game.battlefield.planeswalkers | ||
end | ||
|
||
def resolve!(target:) | ||
trigger_effect(:deal_damage, damage: source.power, target: target) | ||
end | ||
end | ||
|
||
def activated_abilities | ||
[Ability, Ability2] | ||
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,43 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Magic::Cards::LeafkinAvenger do | ||
include_context "two player game" | ||
|
||
subject(:leafkin_avenger) { ResolvePermanent("Leafkin Avenger") } | ||
|
||
before do | ||
ResolvePermanent("Epicure Of Blood") # has 4 Power | ||
ResolvePermanent("Wood Elves") # has 1 Power | ||
end | ||
|
||
context "first activated ability" do | ||
it "taps and adds 2 green" do | ||
# Counts itself (Leafkin Avenger) and Epicure of Blood | ||
ability = leafkin_avenger.activated_abilities.first | ||
p1.activate_ability(ability: ability) | ||
|
||
expect(leafkin_avenger).to be_tapped | ||
expect(p1.mana_pool[:green]).to eq(2) | ||
end | ||
end | ||
|
||
context "second activated ability" do | ||
let!(:basri_ket) { ResolvePermanent("Basri Ket", owner: p2) } | ||
|
||
it "deals damage to target player or planeswalker" do | ||
ability = leafkin_avenger.activated_abilities.last | ||
expect(ability.target_choices).to include(p1) | ||
expect(ability.target_choices).to include(p2) | ||
expect(ability.target_choices).to include(basri_ket) | ||
|
||
p1.add_mana(red: 8) | ||
p1.activate_ability(ability: ability) do | ||
_1.pay_mana(generic: { red: 7 }, red: 1) | ||
_1.targeting(p2) | ||
end | ||
|
||
expect(p2.life).to eq(16) | ||
end | ||
end | ||
|
||
end |