From 173c197c5e8dc5e69e251d0c8b89a55f4268b2b0 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 18 Feb 2022 23:01:47 -0500 Subject: [PATCH] [ALL] fixed implementation of Gift of the Woods --- .../src/mage/cards/g/GiftOfTheWoods.java | 67 +++++++++++++------ 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java b/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java index c6518ace39d..2dd91bd49d2 100644 --- a/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java +++ b/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java @@ -1,30 +1,28 @@ - package mage.cards.g; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.common.BlocksOrBecomesBlockedSourceTriggeredAbility; +import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.SubType; -import mage.constants.Outcome; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * - * @author Ketsuban + * @author TheElk801 */ public final class GiftOfTheWoods extends CardImpl { public GiftOfTheWoods(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[] { CardType.ENCHANTMENT }, "{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}"); this.subtype.add(SubType.AURA); @@ -32,15 +30,10 @@ public final class GiftOfTheWoods extends CardImpl { TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit)); this.getSpellAbility().addTarget(auraTarget); - Ability ability = new EnchantAbility(auraTarget.getTargetName()); - this.addAbility(ability); + this.addAbility(new EnchantAbility(auraTarget.getTargetName())); - // Whenever enchanted creature blocks or becomes blocked, it gets +0/+3 until - // end of turn and you gain 1 life. - Ability ability2 = new BlocksOrBecomesBlockedSourceTriggeredAbility( - new BoostEnchantedEffect(0, 3, Duration.EndOfTurn), false); - ability2.addEffect(new GainLifeEffect(1).concatBy("and")); - this.addAbility(ability2); + // Whenever enchanted creature blocks or becomes blocked, it gets +0/+3 until end of turn and you gain 1 life. + this.addAbility(new GiftOfTheWoodsTriggeredAbility()); } private GiftOfTheWoods(final GiftOfTheWoods card) { @@ -52,3 +45,39 @@ public final class GiftOfTheWoods extends CardImpl { return new GiftOfTheWoods(this); } } + +class GiftOfTheWoodsTriggeredAbility extends TriggeredAbilityImpl { + + GiftOfTheWoodsTriggeredAbility() { + super(Zone.BATTLEFIELD, new BoostEnchantedEffect(0, 3, Duration.EndOfTurn)); + this.addEffect(new GainLifeEffect(1)); + } + + private GiftOfTheWoodsTriggeredAbility(final GiftOfTheWoodsTriggeredAbility ability) { + super(ability); + } + + @Override + public GiftOfTheWoodsTriggeredAbility copy() { + return new GiftOfTheWoodsTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.BLOCKER_DECLARED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent permanent = getSourcePermanentIfItStillExists(game); + return permanent != null && permanent.getAttachedTo() != null + && (event.getSourceId().equals(permanent.getAttachedTo()) + || event.getTargetId().equals(permanent.getAttachedTo())); + } + + @Override + public String getRule() { + return "Whenever enchanted creature blocks or becomes blocked, " + + "it gets +0/+3 until end of turn and you gain 1 life."; + } +}