Skip to content

Commit

Permalink
Add Tormod's Crypt
Browse files Browse the repository at this point in the history
Fixes #252
  • Loading branch information
radar committed Jan 28, 2024
1 parent 028a894 commit 3fbccc4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
30 changes: 30 additions & 0 deletions lib/magic/cards/tormods_crypt.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Magic
module Cards
TormodsCrypt = Artifact("Tormod's Crypt") do
cost generic: 0
end

class TormodsCrypt < Artifact
class ActivatedAbility < Magic::ActivatedAbility
def costs
[
Costs::Tap.new(source),
Costs::Sacrifice.new(source: source),
]
end

def target_choices
game.players
end

def resolve!(target:)
target.graveyard.each do |card|
trigger_effect(:exile, target: card)
end
end
end

def activated_abilities = [ActivatedAbility]
end
end
end
2 changes: 1 addition & 1 deletion lib/magic/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Zone
extend Forwardable
include Enumerable

def_delegators :@cards, :each, :last, :shift, :unshift, :push, :<<, :by_name, :creatures, :by_any_type, :basic_lands, :controlled_by, :cmc_lte, :by_card
def_delegators :@cards, :each, :last, :shift, :unshift, :push, :empty?, :<<, :by_name, :creatures, :by_any_type, :basic_lands, :controlled_by, :cmc_lte, :by_card

attr_reader :owner, :cards

Expand Down
24 changes: 24 additions & 0 deletions spec/cards/tormods_crypt_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'

RSpec.describe Magic::Cards::TormodsCrypt do
include_context "two player game"
subject(:permanent) { ResolvePermanent("Tormod's Crypt") }

let(:wood_elves) { Card("Wood Elves", owner: p2) }

before do
wood_elves.move_to_graveyard!
end

it "taps and sacrifices to exile a player's graveyard" do
p1.activate_ability(ability: permanent.activated_abilities.first) do
_1.pay_sacrifice(permanent)
_1.targeting(p2)
end

game.tick!

expect(p2.graveyard).to be_empty
expect(wood_elves.zone).to be_exile
end
end

0 comments on commit 3fbccc4

Please sign in to comment.