From 9b83ec147ac4f46e59e68bed8e400c879ef10694 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Sun, 20 Oct 2024 14:39:58 +1100 Subject: [PATCH] Add Satyr Enchanter --- lib/magic/cards/satyr_enchanter.rb | 26 ++++++++++++++++++++++++++ spec/cards/satyr_enchanter_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 lib/magic/cards/satyr_enchanter.rb create mode 100644 spec/cards/satyr_enchanter_spec.rb diff --git a/lib/magic/cards/satyr_enchanter.rb b/lib/magic/cards/satyr_enchanter.rb new file mode 100644 index 0000000..ab71670 --- /dev/null +++ b/lib/magic/cards/satyr_enchanter.rb @@ -0,0 +1,26 @@ +module Magic + module Cards + SatyrEnchanter = Creature("Satyr Enchanter") do + cost generic: 1, green: 1, white: 1 + power 2 + toughness 2 + creature_type "Satyr Druid" + + class SpellCastTrigger < TriggeredAbility + def should_perform? + you? && event.type?("Enchantment") + end + + def call + actor.trigger_effect(:draw_cards, source: actor) + end + end + + def event_handlers + { + Events::SpellCast => SpellCastTrigger + } + end + end + end +end diff --git a/spec/cards/satyr_enchanter_spec.rb b/spec/cards/satyr_enchanter_spec.rb new file mode 100644 index 0000000..3f57327 --- /dev/null +++ b/spec/cards/satyr_enchanter_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +RSpec.describe Magic::Cards::SatyrEnchanter do + include_context "two player game" + + subject! { ResolvePermanent("Satyr Enchanter", owner: p1) } + + context "when enchantment is cast" do + let(:doubling_season) { Card("Doubling Season") } + + it "draws a card" do + p1.add_mana(green: 5) + expect(p1).to receive(:draw!) + p1.cast(card: doubling_season) do + _1.pay_mana(green: 1, generic: { green: 4 }) + end + + game.tick! + end + end +end