diff --git a/lib/magic/activated_ability.rb b/lib/magic/activated_ability.rb index ea94aed..afeeee3 100644 --- a/lib/magic/activated_ability.rb +++ b/lib/magic/activated_ability.rb @@ -23,8 +23,12 @@ def battlefield game.battlefield end - def trigger(event, **args) - source.trigger(event, source: self, **args) + def trigger_effect(effect, **args) + source.trigger_effect(effect, source: self, **args) + end + + def add_choice(choice, **args) + source.add_choice(choice, **args) end end end diff --git a/lib/magic/card.rb b/lib/magic/card.rb index 5b4b9cd..e10f3bf 100644 --- a/lib/magic/card.rb +++ b/lib/magic/card.rb @@ -211,14 +211,33 @@ def can_attack? = !defender? def can_block? = true def can_activate_ability?(_) = true - def trigger(effect, source: self, **args) + def add_choice(choice, **args) + case choice + when :discard + game.choices.add(Magic::Choice::Discard.new(player: controller, **args)) + else + raise "Unknown choice: #{choice.inspect}" + end + end + + def trigger_effect(effect, source: self, **args) case effect + when :add_counter + game.add_effect(Effects::AddCounter.new(source: source, **args)) + when :deal_damage + game.add_effect(Effects::DealDamage.new(source: source, **args)) + when :destroy_target + game.add_effect(Effects::DestroyTarget.new(source: source, **args)) when :draw_card game.add_effect(Effects::DrawCards.new(source: source, **args)) - when :discard - game.choices.add(Magic::Choice::Discard.new(player: controller, **args)) + when :gain_life + game.add_effect(Effects::GainLife.new(source: source, target: source.controller, **args)) when :lose_life game.add_effect(Effects::LoseLife.new(source: source, **args)) + when :modify_power_toughness + game.add_effect(Effects::ApplyPowerToughnessModification.new(source: source, **args)) + when :return_to_owners_hand + game.add_effect(Effects::ReturnToOwnersHand.new(source: source, **args)) else raise "Unknown trigger: #{effect.inspect}" end diff --git a/lib/magic/cards/academy_elite.rb b/lib/magic/cards/academy_elite.rb index d5ab0bd..9ac3fc8 100644 --- a/lib/magic/cards/academy_elite.rb +++ b/lib/magic/cards/academy_elite.rb @@ -26,8 +26,8 @@ def costs end def resolve! - trigger(:draw_card, source: source) - trigger(:discard) + trigger_effect(:draw_card, source: source) + add_choice(:discard) end end diff --git a/lib/magic/cards/acidic_slime.rb b/lib/magic/cards/acidic_slime.rb index d19f0ec..a9ede95 100644 --- a/lib/magic/cards/acidic_slime.rb +++ b/lib/magic/cards/acidic_slime.rb @@ -8,17 +8,13 @@ module Cards toughness 2 enters_the_battlefield do - effect = Effects::DestroyTarget.new( - source: permanent, - ) - game.add_effect(effect) + game.choices.add(AcidicSlime::Choice.new(source: self)) end - end class AcidicSlime < Creature - def target_choices(_) - game.battlefield.cards.by_any_type("Artifact", "Enchantment", "Land") + class Choice < Choice::DestroyTarget + def choices = game.battlefield.cards.by_any_type("Artifact", "Enchantment", "Land") end end end diff --git a/lib/magic/cards/animal_sanctuary.rb b/lib/magic/cards/animal_sanctuary.rb index 1cd255b..7e8d925 100644 --- a/lib/magic/cards/animal_sanctuary.rb +++ b/lib/magic/cards/animal_sanctuary.rb @@ -36,7 +36,7 @@ def target_choices end def resolve! - game.add_effect(Effects::AddCounter.new(source: source, counter_type: Counters::Plus1Plus1, choices: target_choices)) + trigger_effect(:add_counter, counter_type: Counters::Plus1Plus1, choices: target_choices) end end diff --git a/lib/magic/cards/barrin_tolarian_archmage.rb b/lib/magic/cards/barrin_tolarian_archmage.rb index 1065b8c..b2ad73c 100644 --- a/lib/magic/cards/barrin_tolarian_archmage.rb +++ b/lib/magic/cards/barrin_tolarian_archmage.rb @@ -22,13 +22,13 @@ def event_handlers } end - class Effect < Effects::ReturnToOwnersHand - end - class ETB < TriggeredAbility::EnterTheBattlefield def perform - effect = Effect.new(source: self, choices: game.battlefield.by_any_type(T::Creature, T::Planeswalker)) - game.add_effect(effect) + permanent.trigger_effect( + :return_to_owners_hand, + source: permanent, + choices: game.battlefield.by_any_type(T::Creature, T::Planeswalker) + ) end end end diff --git a/lib/magic/cards/basris_lieutenant.rb b/lib/magic/cards/basris_lieutenant.rb index de28108..8eee14f 100644 --- a/lib/magic/cards/basris_lieutenant.rb +++ b/lib/magic/cards/basris_lieutenant.rb @@ -12,12 +12,7 @@ module Cards class BasrisLieutenant < Creature class ETB < TriggeredAbility::EnterTheBattlefield def perform - effect = Effects::AddCounter.new( - source: permanent, - counter_type: Counters::Plus1Plus1, - choices: controller.creatures, - ) - game.add_effect(effect) + permanent.trigger_effect(:add_counter, counter_type: Counters::Plus1Plus1, choices: controller.creatures) end end diff --git a/lib/magic/cards/bombard.rb b/lib/magic/cards/bombard.rb index 90e97ba..120a36e 100644 --- a/lib/magic/cards/bombard.rb +++ b/lib/magic/cards/bombard.rb @@ -14,7 +14,7 @@ def target_choices end def resolve!(target:) - game.add_effect(Effects::DealDamage.new(source: self, targets: [target], damage: 4)) + trigger_effect(:deal_damage, targets: [target], damage: 4) end end end diff --git a/lib/magic/cards/cloudkin_seer.rb b/lib/magic/cards/cloudkin_seer.rb index 6140ae5..56c8598 100644 --- a/lib/magic/cards/cloudkin_seer.rb +++ b/lib/magic/cards/cloudkin_seer.rb @@ -11,7 +11,7 @@ module Cards class CloudkinSeer < Creature class ETB < TriggeredAbility::EnterTheBattlefield def perform - permanent.trigger(:draw_card) + permanent.trigger_effect(:draw_card) end end diff --git a/lib/magic/cards/daybreak_charger.rb b/lib/magic/cards/daybreak_charger.rb index b09145a..564037c 100644 --- a/lib/magic/cards/daybreak_charger.rb +++ b/lib/magic/cards/daybreak_charger.rb @@ -10,8 +10,7 @@ module Cards class DaybreakCharger < Creature class ETB < TriggeredAbility::EnterTheBattlefield def perform - effect = Effects::ApplyPowerToughnessModification.new(source: self, power: 2, choices: battlefield.creatures) - game.add_effect(effect) + permanent.trigger_effect(:modify_power_toughness, power: 2, choices: battlefield.creatures) end end diff --git a/lib/magic/cards/defiant_strike.rb b/lib/magic/cards/defiant_strike.rb index 6dd21f6..ff9d527 100644 --- a/lib/magic/cards/defiant_strike.rb +++ b/lib/magic/cards/defiant_strike.rb @@ -15,14 +15,7 @@ def single_target? def resolve!(target:) if target.zone == battlefield - game.add_effect( - Effects::ApplyPowerToughnessModification.new( - source: self, - choices: game.battlefield.creatures, - power: 1, - targets: [target] - ) - ) + target.modify_power_toughness!(source: self, power: 1, toughness: 0) controller.draw! end diff --git a/lib/magic/cards/eliminate.rb b/lib/magic/cards/eliminate.rb index 71076d6..8247134 100644 --- a/lib/magic/cards/eliminate.rb +++ b/lib/magic/cards/eliminate.rb @@ -14,9 +14,7 @@ def target_choices end def resolve!(target:) - game.add_effect( - Effects::DestroyTarget.new(choices: target_choices, source: self, targets: [target]) - ) + trigger_effect(:destroy_target, targets: [target]) end end end diff --git a/lib/magic/cards/epicure_of_blood.rb b/lib/magic/cards/epicure_of_blood.rb index 7739615..77fbe43 100644 --- a/lib/magic/cards/epicure_of_blood.rb +++ b/lib/magic/cards/epicure_of_blood.rb @@ -19,12 +19,12 @@ def event_handlers Events::LifeGain => -> (receiver, event) do return unless event.player == receiver.controller - effect = Effects::LoseLife.new( + trigger_effect( + :lose_life, source: receiver, - targets: game.opponents(receiver.controller), - life: 1 + life: 1, + targets: game.opponents(receiver.controller) ) - game.add_effect(effect) end } end diff --git a/lib/magic/cards/essence_warden.rb b/lib/magic/cards/essence_warden.rb index 2ca84bf..a0bc3a6 100644 --- a/lib/magic/cards/essence_warden.rb +++ b/lib/magic/cards/essence_warden.rb @@ -14,13 +14,7 @@ def event_handlers Events::EnteredTheBattlefield => -> (receiver, event) do return if event.permanent == receiver - game.add_effect( - Effects::GainLife.new( - source: receiver, - target: receiver.controller, - life: 1 - ) - ) + trigger_effect(:gain_life, source: receiver, life: 1) end } end diff --git a/lib/magic/cards/feat_of_resistance.rb b/lib/magic/cards/feat_of_resistance.rb index dad1639..eded4ae 100644 --- a/lib/magic/cards/feat_of_resistance.rb +++ b/lib/magic/cards/feat_of_resistance.rb @@ -13,15 +13,21 @@ def target_choices(controller) controller.creatures end + class Choice < Magic::Choice::Color + attr_reader :target + def initialize(source:, target:) + super(source: source) + @target = target + end + + def resolve!(color:) + target.gains_protection_from_color(color, until_eot: true) + end + end + def resolve!(target:) target.add_counter(Counters::Plus1Plus1) - game.choices.add( - Magic::Choice::Color.new( - callback: -> (choice) { - target.gains_protection_from_color(choice, until_eot: true) - } - ) - ) + game.choices.add(Choice.new(source: self, target: target)) end end end diff --git a/lib/magic/cards/gale_swooper.rb b/lib/magic/cards/gale_swooper.rb index 0e1acdf..b0898e2 100644 --- a/lib/magic/cards/gale_swooper.rb +++ b/lib/magic/cards/gale_swooper.rb @@ -8,20 +8,15 @@ module Cards end class GaleSwooper < Creature - class Effect < Effects::SingleTargetAndResolve - def resolve(target) + class Choice < Magic::Choice + def resolve!(target:) target.grant_keyword(Keywords::FLYING, until_eot: true) end end class ETB < TriggeredAbility::EnterTheBattlefield def perform - game.add_effect( - Effect.new( - source: permanent, - choices: battlefield.creatures, - ) - ) + game.choices.add(Choice.new(source: permanent)) end end diff --git a/lib/magic/cards/ghostly_pilferer.rb b/lib/magic/cards/ghostly_pilferer.rb index 6b8ee59..7fcb65b 100644 --- a/lib/magic/cards/ghostly_pilferer.rb +++ b/lib/magic/cards/ghostly_pilferer.rb @@ -14,7 +14,7 @@ module Cards end class GhostlyPilferer < Creature - class Choice < Magic::Choice::Effect + class Choice < Magic::Choice def costs @costs ||= [Costs::Mana.new(generic: 2)] end diff --git a/lib/magic/cards/grasp_of_darkness.rb b/lib/magic/cards/grasp_of_darkness.rb index 2425eb2..b7f4c74 100644 --- a/lib/magic/cards/grasp_of_darkness.rb +++ b/lib/magic/cards/grasp_of_darkness.rb @@ -14,13 +14,7 @@ def single_target? end def resolve!(target:) - effect = Effects::ApplyPowerToughnessModification.new( - source: self, - power: -4, - toughness: -4, - targets: target - ) - game.add_effect(effect) + target.modify_power_toughness!(source: self, power: -4, toughness: -4) super end diff --git a/lib/magic/cards/lathril_blade_of_the_elves.rb b/lib/magic/cards/lathril_blade_of_the_elves.rb index c0c7d96..e398982 100644 --- a/lib/magic/cards/lathril_blade_of_the_elves.rb +++ b/lib/magic/cards/lathril_blade_of_the_elves.rb @@ -13,19 +13,8 @@ class ActivatedAbility < Magic::ActivatedAbility def costs = [Costs::Tap.new(source), Costs::MultiTap.new(-> (c) { c.type?("Elf") }, 10)] def resolve! - effect = Effects::LoseLife.new( - source: source, - targets: game.opponents(source.controller), - life: 10 - ) - game.add_effect(effect) - - effect = Effects::GainLife.new( - source: source, - target: source.controller, - life: 10 - ) - game.add_effect(effect) + source.trigger_effect(:lose_life, source: source, life: 10, targets: game.opponents(source.controller)) + source.trigger_effect(:gain_life, source: source, life: 10, target: source.controller) end end diff --git a/lib/magic/cards/legions_judgement.rb b/lib/magic/cards/legions_judgement.rb index bd985fe..69ac839 100644 --- a/lib/magic/cards/legions_judgement.rb +++ b/lib/magic/cards/legions_judgement.rb @@ -14,7 +14,7 @@ def single_target? end def resolve!(target:) - game.add_effect(Effects::DestroyTarget.new(source: self, targets: [target], choices: target_choices)) + trigger_effect(:destroy_target, targets: [target], choices: target_choices) super end diff --git a/lib/magic/cards/lightning_bolt.rb b/lib/magic/cards/lightning_bolt.rb index b60b362..3f72349 100644 --- a/lib/magic/cards/lightning_bolt.rb +++ b/lib/magic/cards/lightning_bolt.rb @@ -8,12 +8,8 @@ def target_choices game.any_target end - def single_target? - true - end - def resolve!(target:) - game.add_effect(Effects::DealDamage.new(source: self, targets: [target], damage: 3)) + trigger_effect(:deal_damage, targets: [target], choices: target_choices, damage: 3) end end end diff --git a/lib/magic/cards/lofty_denial.rb b/lib/magic/cards/lofty_denial.rb index aea251c..bfa7104 100644 --- a/lib/magic/cards/lofty_denial.rb +++ b/lib/magic/cards/lofty_denial.rb @@ -5,7 +5,7 @@ module Cards end class LoftyDenial < Instant - class Choice < Magic::Choice::Effect + class Choice < Magic::Choice attr_reader :target def initialize(source:, target:) super(source:) diff --git a/lib/magic/cards/miscast.rb b/lib/magic/cards/miscast.rb index 200773d..439e9e2 100644 --- a/lib/magic/cards/miscast.rb +++ b/lib/magic/cards/miscast.rb @@ -5,7 +5,7 @@ module Cards end class Miscast < Instant - class Choice < Magic::Choice::Effect + class Choice < Magic::Choice attr_reader :source, :target def initialize(source:, target:) super(source:) diff --git a/lib/magic/cards/niambi_esteemed_speaker.rb b/lib/magic/cards/niambi_esteemed_speaker.rb index 145596a..402868e 100644 --- a/lib/magic/cards/niambi_esteemed_speaker.rb +++ b/lib/magic/cards/niambi_esteemed_speaker.rb @@ -14,7 +14,7 @@ module Cards end class NiambiEsteemedSpeaker < Creature - class Choice < Magic::Choice::Effect + class Choice < Magic::Choice attr_reader :source def initialize(source:, choices:) diff --git a/lib/magic/cards/opt.rb b/lib/magic/cards/opt.rb index fe18127..64ee7b1 100644 --- a/lib/magic/cards/opt.rb +++ b/lib/magic/cards/opt.rb @@ -8,7 +8,7 @@ class Opt < Instant def resolve! game.add_effect( Effects::Scry.new(source: self, amount: 1, then_do: -> do - trigger(:draw_card) + trigger_effect(:draw_card) end) ) diff --git a/lib/magic/cards/peer_into_the_abyss.rb b/lib/magic/cards/peer_into_the_abyss.rb index d1e1968..e1e0441 100644 --- a/lib/magic/cards/peer_into_the_abyss.rb +++ b/lib/magic/cards/peer_into_the_abyss.rb @@ -12,8 +12,8 @@ def target_choices end def resolve!(target:) - trigger(:draw_card, player: target, number_to_draw: (target.library.count / 2.0).ceil) - trigger(:lose_life, targets: [target], life: (target.life / 2.0).ceil) + trigger_effect(:draw_card, player: target, number_to_draw: (target.library.count / 2.0).ceil) + trigger_effect(:lose_life, targets: [target], life: (target.life / 2.0).ceil) end end end diff --git a/lib/magic/cards/rambunctious_mutt.rb b/lib/magic/cards/rambunctious_mutt.rb index e669834..bd4ea6b 100644 --- a/lib/magic/cards/rambunctious_mutt.rb +++ b/lib/magic/cards/rambunctious_mutt.rb @@ -6,23 +6,18 @@ module Cards keywords :deathtouch power 2 toughness 2 - end - class RambunctiousMutt < Creature - def target_choices(permanent) - game.battlefield.cards.by_any_type("Artifact", "Enchantment").not_controlled_by(permanent.controller) + enters_the_battlefield do + game.choices.add(RambunctiousMutt::Choice.new(source: permanent)) end + end - class ETB < TriggeredAbility::EnterTheBattlefield - def perform - effect = Effects::DestroyTarget.new( - source: permanent, - ) - game.add_effect(effect) + class RambunctiousMutt < Creature + class Choice < Choice::DestroyTarget + def choices + game.battlefield.cards.by_any_type("Artifact", "Enchantment").not_controlled_by(source.controller) end end - - def etb_triggers = [ETB] end end end diff --git a/lib/magic/cards/rewind.rb b/lib/magic/cards/rewind.rb index 39ee95d..e2edd69 100644 --- a/lib/magic/cards/rewind.rb +++ b/lib/magic/cards/rewind.rb @@ -3,7 +3,7 @@ module Cards Rewind = Instant("Rewind") do cost generic: 2, blue: 2 - class Choice < Magic::Choice::Effect + class Choice < Magic::Choice def target_choices game.battlefield.lands end diff --git a/lib/magic/cards/riddleform.rb b/lib/magic/cards/riddleform.rb index e741eea..17066f5 100644 --- a/lib/magic/cards/riddleform.rb +++ b/lib/magic/cards/riddleform.rb @@ -17,7 +17,7 @@ def event_handlers end class Riddleform < Enchantment - class Choice < Magic::Choice::Effect + class Choice < Magic::Choice def resolve! source.add_types(T::Creature, T::Creatures["Sphinx"]) diff --git a/lib/magic/cards/rousing_read.rb b/lib/magic/cards/rousing_read.rb index 030ae41..4d0c0ff 100644 --- a/lib/magic/cards/rousing_read.rb +++ b/lib/magic/cards/rousing_read.rb @@ -5,8 +5,8 @@ module Cards enters_the_battlefield do - permanent.trigger(:draw_card, number_to_draw: 2) - permanent.trigger(:discard) + permanent.trigger_effect(:draw_card, number_to_draw: 2) + permanent.add_choice(:discard) end def target_choices @@ -24,7 +24,6 @@ def power_modification def toughness_modification 1 end - end end end diff --git a/lib/magic/cards/vito_thorn_of_the_dusk_rose.rb b/lib/magic/cards/vito_thorn_of_the_dusk_rose.rb index 481cfd9..9dd9de0 100644 --- a/lib/magic/cards/vito_thorn_of_the_dusk_rose.rb +++ b/lib/magic/cards/vito_thorn_of_the_dusk_rose.rb @@ -8,7 +8,7 @@ module Cards end class VitoThornOfTheDuskRose < Creature - class LifeLossChoice < Magic::Choice::Effect + class LifeLossChoice < Magic::Choice attr_reader :amount def initialize(amount:) = @amount = amount diff --git a/lib/magic/choice.rb b/lib/magic/choice.rb new file mode 100644 index 0000000..8fc4fc1 --- /dev/null +++ b/lib/magic/choice.rb @@ -0,0 +1,13 @@ +module Magic + class Choice + attr_reader :source + def initialize(source:) + @source = source + end + + def player = source.controller + def game = player.game + + def to_s = inspect + end +end diff --git a/lib/magic/choice/color.rb b/lib/magic/choice/color.rb index c57a8f4..755db03 100644 --- a/lib/magic/choice/color.rb +++ b/lib/magic/choice/color.rb @@ -1,14 +1,6 @@ module Magic - module Choice - class Color - attr_reader :callback - def initialize(callback:) - @callback = callback - end - - def choose(color) - @callback.call(color) - end + class Choice + class Color < Choice end end end diff --git a/lib/magic/choice/destroy_target.rb b/lib/magic/choice/destroy_target.rb new file mode 100644 index 0000000..d57cb69 --- /dev/null +++ b/lib/magic/choice/destroy_target.rb @@ -0,0 +1,19 @@ +module Magic + class Choice + class DestroyTarget < Choice + attr_reader :source + + def initialize(source:) + @source = source + end + + def choices + raise NotImplemented + end + + def resolve!(target:) + source.trigger(:destroy_target, source: source, target: target) + end + end + end +end diff --git a/lib/magic/choice/discard.rb b/lib/magic/choice/discard.rb index b990d92..2480f34 100644 --- a/lib/magic/choice/discard.rb +++ b/lib/magic/choice/discard.rb @@ -1,6 +1,6 @@ module Magic - module Choice - class Discard < Magic::Choice::Effect + class Choice + class Discard < Magic::Choice attr_reader :player, :cards def initialize(player:) diff --git a/lib/magic/choice/effect.rb b/lib/magic/choice/effect.rb deleted file mode 100644 index 9d885e8..0000000 --- a/lib/magic/choice/effect.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Magic - module Choice - class Effect - attr_reader :source - def initialize(source:) - @source = source - end - - def player = source.controller - def game = player.game - - def to_s = inspect - - end - end -end diff --git a/lib/magic/permanent.rb b/lib/magic/permanent.rb index 064e153..a94af75 100644 --- a/lib/magic/permanent.rb +++ b/lib/magic/permanent.rb @@ -310,8 +310,12 @@ def can_untap_during_upkeep? attachments.any?(&:can_untap_during_upkeep?) end - def trigger(effect, source: self, **args) - card.trigger(effect, source: source, **args) + def trigger_effect(effect, source: self, **args) + card.trigger_effect(effect, source: source, **args) + end + + def add_choice(choice, **args) + card.add_choice(choice, **args) end private diff --git a/lib/magic/permanents/creature.rb b/lib/magic/permanents/creature.rb index abf8d4f..bb7ffca 100644 --- a/lib/magic/permanents/creature.rb +++ b/lib/magic/permanents/creature.rb @@ -49,7 +49,8 @@ def toughness def modify_power_toughness!(source:, power: 0, toughness: 0) game.add_effect(Effects::ApplyPowerToughnessModification.new( - choices: self, + choices: [self], + targets: [self], source: source, power: power, toughness: toughness, diff --git a/spec/cards/acidic_slime_spec.rb b/spec/cards/acidic_slime_spec.rb index 78e6d2b..9c7d020 100644 --- a/spec/cards/acidic_slime_spec.rb +++ b/spec/cards/acidic_slime_spec.rb @@ -23,9 +23,9 @@ it "triggers a destroy effect" do cast_and_resolve(card: subject, player: p1) - effect = game.effects.first + effect = game.choices.first - expect(effect).to be_a(Magic::Effects::DestroyTarget) + expect(effect).to be_a(Magic::Choice::DestroyTarget) expect(effect.choices).to match_array([land, enchantment, artifact]) end end diff --git a/spec/cards/feat_of_resistance_spec.rb b/spec/cards/feat_of_resistance_spec.rb index e78f69b..c83cf46 100644 --- a/spec/cards/feat_of_resistance_spec.rb +++ b/spec/cards/feat_of_resistance_spec.rb @@ -23,7 +23,7 @@ expect(wood_elves.toughness).to eq(2) choice = game.choices.last expect(choice).to be_a(Magic::Choice::Color) - choice.choose(:green) + game.resolve_choice!(color: :green) expect(wood_elves.protected_from?(green_card)).to eq(true) end end diff --git a/spec/cards/gale_swooper_spec.rb b/spec/cards/gale_swooper_spec.rb index 8cd6f49..6253967 100644 --- a/spec/cards/gale_swooper_spec.rb +++ b/spec/cards/gale_swooper_spec.rb @@ -9,9 +9,8 @@ it "grants wood elves flying" do cast_and_resolve(card: subject, player: p1) - grant_flying = game.next_effect - expect(grant_flying).to be_a(Magic::Effects::SingleTargetAndResolve) - game.resolve_pending_effect(wood_elves) + game.resolve_choice!(target: wood_elves) + expect(wood_elves).to be_flying expect(wood_elves.keyword_grants.first.until_eot?).to eq(true) end diff --git a/spec/cards/ghostly_pilferer_spec.rb b/spec/cards/ghostly_pilferer_spec.rb index b3de8ab..b7aa0d8 100644 --- a/spec/cards/ghostly_pilferer_spec.rb +++ b/spec/cards/ghostly_pilferer_spec.rb @@ -20,7 +20,7 @@ p1.add_mana(blue: 2) expect(p1).to receive(:draw!) choice = game.choices.last - expect(choice).to be_a(Magic::Choice::Effect) + expect(choice).to be_a(Magic::Choice) choice.pay(p1, generic: { blue: 2 }) choice.resolve! end @@ -34,7 +34,7 @@ p1.add_mana(blue: 2) expect(p1).not_to receive(:draw!) choice = game.choices.last - expect(choice).to be_a(Magic::Choice::Effect) + expect(choice).to be_a(Magic::Choice) game.resolve_choice! expect(game.choices).to be_none end diff --git a/spec/cards/rambunctious_mutt_spec.rb b/spec/cards/rambunctious_mutt_spec.rb index 57678dc..06280a2 100644 --- a/spec/cards/rambunctious_mutt_spec.rb +++ b/spec/cards/rambunctious_mutt_spec.rb @@ -11,10 +11,11 @@ context "when rambunctious mutt enters the battlefield" do it "triggers a destroy effect" do cast_and_resolve(card: subject, player: p1) - effect = game.effects.first + choice = game.choices.first - expect(effect).to be_a(Magic::Effects::DestroyTarget) - expect(effect.choices).to match_array([enchantment, artifact_2]) + expect(choice).to be_a(Magic::Choice::DestroyTarget) + binding.pry + expect(choice.choices).to match_array([enchantment, artifact_2]) end end end