From 38e4d12b49affc23809de739e5942e05948a388a Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Sat, 9 Nov 2024 21:52:22 +1100 Subject: [PATCH] Add Eternal Witness --- lib/magic/cards/elderfang_ritualist.rb | 2 +- lib/magic/cards/eternal_witness.rb | 26 +++++++++++++++++++++++++ spec/cards/eternal_witness_spec.rb | 27 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 lib/magic/cards/eternal_witness.rb create mode 100644 spec/cards/eternal_witness_spec.rb diff --git a/lib/magic/cards/elderfang_ritualist.rb b/lib/magic/cards/elderfang_ritualist.rb index 44beb8a..b2abc45 100644 --- a/lib/magic/cards/elderfang_ritualist.rb +++ b/lib/magic/cards/elderfang_ritualist.rb @@ -10,7 +10,7 @@ module Cards class ElderfangRitualist < Creature class Choice < Choice::SearchGraveyard def choices - controller.graveyard + controller.graveyard.by_type("Elf") end def choice_amount diff --git a/lib/magic/cards/eternal_witness.rb b/lib/magic/cards/eternal_witness.rb new file mode 100644 index 0000000..d3e6e58 --- /dev/null +++ b/lib/magic/cards/eternal_witness.rb @@ -0,0 +1,26 @@ +module Magic + module Cards + EternalWitness = Creature("Eternal Witness") do + cost green: 1, generic: 2 + power 2 + toughness 1 + creature_type "Human Shaman" + + enters_the_battlefield do + game.add_choice(EternalWitness::Choice.new(actor: actor)) + end + end + + class EternalWitness < Creature + class Choice < Magic::Choice::May + def choices + controller.graveyard + end + + def resolve!(target:) + target.move_to_hand! + end + end + end + end +end diff --git a/spec/cards/eternal_witness_spec.rb b/spec/cards/eternal_witness_spec.rb new file mode 100644 index 0000000..e144d83 --- /dev/null +++ b/spec/cards/eternal_witness_spec.rb @@ -0,0 +1,27 @@ +require "spec_helper" + +RSpec.describe Magic::Cards::EternalWitness do + include_context "two player game" + + context "when it enters" do + subject { Card("Eternal Witness") } + + before do + p1.graveyard.add(Card("Wood Elves")) + end + + it "can choose to return wood elves" do + p1.add_mana(green: 3) + p1.cast(card: subject) do + _1.auto_pay_mana + end + + game.stack.resolve! + + game.resolve_choice!(target: p1.graveyard.first) + + expect(p1.hand.by_name("Wood Elves")).to be_one + expect(p1.graveyard.by_name("Wood Elves")).to be_none + end + end +end