Skip to content

Commit

Permalink
Add Leafkin Avenger
Browse files Browse the repository at this point in the history
Fixes #231
  • Loading branch information
radar committed Feb 5, 2024
1 parent 7e7698a commit f298e04
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/magic/cards/leafkin_avenger.rb
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
43 changes: 43 additions & 0 deletions spec/cards/leafkin_avenger_spec.rb
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

0 comments on commit f298e04

Please sign in to comment.