Skip to content

Commit

Permalink
Add Doomwake Giant
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Oct 20, 2024
1 parent 9b83ec1 commit 2e2da06
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/magic/cards/doomwake_giant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Magic
module Cards
class DoomwakeGiant < Creature
card_name "Doomwake Giant"
cost generic: 4, black: 1
type "Enchantment Creature -- Giant"
power 4
toughness 6

class Trigger < TriggeredAbility
def should_perform?
# Whenever {this} or another enchantment enters under your control...
this? || (actor.type?("Enchantment") && event.permanent.controller?(controller))
end

def call
creatures_opponents_control.each do |creature|
actor.trigger_effect(:modify_power_toughness, power: -1, toughness: -1, target: creature, until_eot: true)
end
end
end

def event_handlers
{
Events::EnteredTheBattlefield => Trigger
}
end
end
end
end
63 changes: 63 additions & 0 deletions spec/cards/doomwake_giant_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'spec_helper'

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

subject(:doomwake_giant) { Card("Doomwake Giant") }
let(:p1_ajanis_pridemate) { ResolvePermanent("Ajani's Pridemate", owner: p1) }
let(:p2_ajanis_pridemate) { ResolvePermanent("Ajani's Pridemate", owner: p2) }

context "when doomwake giant enters" do
before do
p1_ajanis_pridemate
p2_ajanis_pridemate
end

it "gives all creatures opponent controls -1/-1 until end of turn" do
p1.add_mana(black: 5)
p1.cast(card: doomwake_giant) do
_1.pay_mana(generic: { black: 4 }, black: 1)
end

game.tick!

aggregate_failures do
expect(p1_ajanis_pridemate.power).to eq(2)
expect(p1_ajanis_pridemate.toughness).to eq(2)

expect(p2_ajanis_pridemate.power).to eq(1)
expect(p2_ajanis_pridemate.toughness).to eq(1)
end
end
end

context "when another enchantment enters" do
let(:doomwake_giant) { ResolvePermanent("Doomwake Giant") }

before do
doomwake_giant
p1_ajanis_pridemate
p2_ajanis_pridemate
end


let(:griffin_aerie) { Card("Griffin Aerie") }

it "gives all creatures opponent controls -1/-1 until end of turn" do
p1.add_mana(white: 2)
p1.cast(card: griffin_aerie) do
_1.pay_mana(generic: { white: 1 }, white: 1)
end

game.tick!

aggregate_failures do
expect(p1_ajanis_pridemate.power).to eq(2)
expect(p1_ajanis_pridemate.toughness).to eq(2)

expect(p2_ajanis_pridemate.power).to eq(1)
expect(p2_ajanis_pridemate.toughness).to eq(1)
end
end
end
end

0 comments on commit 2e2da06

Please sign in to comment.