diff --git a/Mage.Sets/src/mage/cards/a/AerialModification.java b/Mage.Sets/src/mage/cards/a/AerialModification.java index 1720c2c87bd..b68f29e0dc8 100644 --- a/Mage.Sets/src/mage/cards/a/AerialModification.java +++ b/Mage.Sets/src/mage/cards/a/AerialModification.java @@ -29,22 +29,23 @@ package mage.cards.a; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.BecomesCreatureIfVehicleEffect; import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import java.util.UUID; @@ -96,35 +97,3 @@ public class AerialModification extends CardImpl { return new AerialModification(this); } } - -class BecomesCreatureIfVehicleEffect extends ContinuousEffectImpl { - - private CardType addedType = CardType.CREATURE; - - public BecomesCreatureIfVehicleEffect() { - super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); - this.staticText = "As long as enchanted permanent is a Vehicle, it's a creature in addition to its other types"; - } - - public BecomesCreatureIfVehicleEffect(final BecomesCreatureIfVehicleEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent aura = game.getPermanent(source.getSourceId()); - if (aura != null && aura.getAttachedTo() != null) { - Permanent enchanted = game.getPermanent(aura.getAttachedTo()); - if (enchanted != null && enchanted.getSubtype(game).contains("Vehicle")) { - enchanted.getCardType().add(addedType); - } - } - - return true; - } - - @Override - public BecomesCreatureIfVehicleEffect copy() { - return new BecomesCreatureIfVehicleEffect(this); - } -} diff --git a/Mage.Sets/src/mage/cards/s/SiegeModification.java b/Mage.Sets/src/mage/cards/s/SiegeModification.java index df945c792ac..874b878ad90 100644 --- a/Mage.Sets/src/mage/cards/s/SiegeModification.java +++ b/Mage.Sets/src/mage/cards/s/SiegeModification.java @@ -29,22 +29,23 @@ package mage.cards.s; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.BecomesCreatureIfVehicleEffect; import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.FirstStrikeAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import java.util.UUID; @@ -95,35 +96,5 @@ public class SiegeModification extends CardImpl { return new SiegeModification(this); } - private static class BecomesCreatureIfVehicleEffect extends ContinuousEffectImpl { - private CardType addedType = CardType.CREATURE; - - public BecomesCreatureIfVehicleEffect() { - super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); - this.staticText = "As long as enchanted permanent is a Vehicle, it's a creature in addition to its other types"; - } - - public BecomesCreatureIfVehicleEffect(final BecomesCreatureIfVehicleEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent aura = game.getPermanent(source.getSourceId()); - if (aura != null && aura.getAttachedTo() != null) { - Permanent enchanted = game.getPermanent(aura.getAttachedTo()); - if (enchanted != null && enchanted.getSubtype(game).contains("Vehicle")) { - enchanted.getCardType().add(addedType); - } - } - - return true; - } - - @Override - public BecomesCreatureIfVehicleEffect copy() { - return new BecomesCreatureIfVehicleEffect(this); - } - } } diff --git a/Mage/src/main/java/mage/MageObject.java b/Mage/src/main/java/mage/MageObject.java index 7ec8ec053c0..3ee4a3e2d0d 100644 --- a/Mage/src/main/java/mage/MageObject.java +++ b/Mage/src/main/java/mage/MageObject.java @@ -125,21 +125,25 @@ public interface MageObject extends MageItem, Serializable { return getSuperType().contains(SuperType.SNOW); } - default void addSuperType(SuperType superType){ + default void addSuperType(SuperType superType) { getSuperType().add(superType); } - default boolean isBasic() { return getSuperType().contains(SuperType.BASIC);} + default boolean isBasic() { + return getSuperType().contains(SuperType.BASIC); + } default boolean isWorld() { return getSuperType().contains(SuperType.WORLD); } + default void addCardType(CardType cardType) { + getCardType().add(cardType); + } /** * Checks whether two cards share card types. * - * * @param otherCard * @return */ diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureIfVehicleEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureIfVehicleEffect.java new file mode 100644 index 00000000000..2fc8214a365 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureIfVehicleEffect.java @@ -0,0 +1,42 @@ +package mage.abilities.effects.common.continuous; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * Created by IGOUDT on 5-4-2017. + */ +public class BecomesCreatureIfVehicleEffect extends ContinuousEffectImpl { + + private CardType addedType = CardType.CREATURE; + + public BecomesCreatureIfVehicleEffect() { + super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); + this.staticText = "As long as enchanted permanent is a Vehicle, it's a creature in addition to its other types"; + } + + public BecomesCreatureIfVehicleEffect(final BecomesCreatureIfVehicleEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent aura = game.getPermanent(source.getSourceId()); + if (aura != null && aura.getAttachedTo() != null) { + Permanent enchanted = game.getPermanent(aura.getAttachedTo()); + if (enchanted != null && enchanted.getSubtype(game).contains("Vehicle")) { + enchanted.addCardType(addedType); + } + } + + return true; + } + + @Override + public BecomesCreatureIfVehicleEffect copy() { + return new BecomesCreatureIfVehicleEffect(this); + } +} \ No newline at end of file