Skip to content

Commit

Permalink
Add Elvish Archdruid
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Oct 18, 2024
1 parent 438573e commit f092afa
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/magic/cards/elvish_archdruid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module Magic
module Cards
ElvishArchdruid = Creature("Elvish Archdruid") do
power 2
toughness 2
cost generic: 1, green: 2
creature_type "Elf Druid"

class PowerAndToughnessModification < Abilities::Static::PowerAndToughnessModification
def initialize(source:)
@source = source
end

def power
1
end

def toughness
1
end

def applicable_targets
source.controller.creatures.by_type("Elf") - [source]
end
end

class ManaAbility < Magic::TapManaAbility
def resolve!
source.controller.add_mana(green: source.controller.creatures.by_type("Elf").count)
end
end

def activated_abilities = [ManaAbility]

def static_abilities = [PowerAndToughnessModification]
end
end
end
32 changes: 32 additions & 0 deletions spec/cards/elvish_archdruid_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'

RSpec.describe Magic::Cards::ElvishArchdruid do
include_context "two player game"

subject! { ResolvePermanent("Elvish Archdruid", 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(2)
expect(subject.toughness).to eq(2)
end
end

context "mana ability" do
def activate_ability
p1.activate_ability(ability: subject.activated_abilities.first)
end

it "adds green mana" do
activate_ability
# 1 mana from the Archdruid, 1 from Lathril
expect(p1.mana_pool[:green]).to eq(2)
end
end
end

0 comments on commit f092afa

Please sign in to comment.