[ALL] fixed implementation of Gift of the Woods
-
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 {
@@ -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.";
+ }
+}
