From f7622d3c4a2d366d90c7459a9bf914105f5a1d0f Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Tue, 30 Apr 2019 14:40:19 +0400 Subject: [PATCH] * Awakening of Vitu-Ghazi - fixed that it creates non legendary tokens --- .../continuous/BecomesCreatureAllEffect.java | 59 +++++++++++++------ .../BecomesCreatureTargetEffect.java | 27 +++++---- 2 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java index 54d96c75d15..07892612d65 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAllEffect.java @@ -1,19 +1,13 @@ - package mage.abilities.effects.common.continuous; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.effects.ContinuousEffectImpl; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; +import mage.constants.*; import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; -import mage.game.permanent.token.TokenImpl; import mage.game.permanent.token.Token; import java.util.HashSet; @@ -21,7 +15,6 @@ import java.util.Set; /** * @author LevelX2 - * */ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { @@ -29,13 +22,19 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { protected String theyAreStillType; private final FilterPermanent filter; private boolean loseColor = true; + protected boolean loseName = false; public BecomesCreatureAllEffect(Token token, String theyAreStillType, FilterPermanent filter, Duration duration, boolean loseColor) { + this(token, theyAreStillType, filter, duration, loseColor, false); + } + + public BecomesCreatureAllEffect(Token token, String theyAreStillType, FilterPermanent filter, Duration duration, boolean loseColor, boolean loseName) { super(duration, Outcome.BecomeCreature); this.token = token; this.theyAreStillType = theyAreStillType; this.filter = filter; this.loseColor = loseColor; + this.loseName = loseName; } public BecomesCreatureAllEffect(final BecomesCreatureAllEffect effect) { @@ -44,6 +43,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { this.theyAreStillType = effect.theyAreStillType; this.filter = effect.filter.copy(); this.loseColor = effect.loseColor; + this.loseName = effect.loseName; } @Override @@ -65,30 +65,47 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Set affectedPermanents = new HashSet<>(); if (this.affectedObjectsSet) { - for(MageObjectReference ref : affectedObjectList) { + for (MageObjectReference ref : affectedObjectList) { affectedPermanents.add(ref.getPermanent(game)); } } else { affectedPermanents = new HashSet<>(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)); } - for(Permanent permanent : affectedPermanents) { + for (Permanent permanent : affectedPermanents) { if (permanent != null) { switch (layer) { + case TextChangingEffects_3: + if (sublayer == SubLayer.NA) { + if (loseName) { + permanent.setName(token.getName()); + } + } + break; + case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { - if (!token.getCardType().isEmpty()) { - for (CardType t : token.getCardType()) { - if (!permanent.getCardType().contains(t)) { - permanent.addCardType(t); + if (theyAreStillType != null) { + permanent.getSubtype(game).retainAll(SubType.getLandTypes()); + permanent.getSubtype(game).addAll(token.getSubtype(game)); + } else { + for (SubType t : token.getSubtype(game)) { + if (!permanent.hasSubtype(t, game)) { + permanent.getSubtype(game).add(t); } } } - if (theyAreStillType == null) { - permanent.getSubtype(game).clear(); + + for (SuperType t : token.getSuperType()) { + if (!permanent.getSuperType().contains(t)) { + permanent.addSuperType(t); + } } - if (!token.getSubtype(game).isEmpty()) { - permanent.getSubtype(game).addAll(token.getSubtype(game)); + + for (CardType t : token.getCardType()) { + if (!permanent.getCardType().contains(t)) { + permanent.addCardType(t); + } } } break; @@ -141,7 +158,11 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl { @Override public boolean hasLayer(Layer layer) { - return layer == Layer.PTChangingEffects_7 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4; + return layer == Layer.PTChangingEffects_7 + || layer == Layer.AbilityAddingRemovingEffects_6 + || layer == Layer.ColorChangingEffects_5 + || layer == Layer.TypeChangingEffects_4 + || layer == Layer.TextChangingEffects_3; } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureTargetEffect.java index 97d55d1aa0b..ae2f629c6c0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureTargetEffect.java @@ -69,30 +69,34 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl { } } break; + case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { if (loseAllAbilities) { permanent.getSubtype(game).retainAll(SubType.getLandTypes()); permanent.getSubtype(game).addAll(token.getSubtype(game)); } else { - if (!token.getSubtype(game).isEmpty()) { - for (SubType subtype : token.getSubtype(game)) { - if (!permanent.hasSubtype(subtype, game)) { - permanent.getSubtype(game).add(subtype); - } + for (SubType t : token.getSubtype(game)) { + if (!permanent.hasSubtype(t, game)) { + permanent.getSubtype(game).add(t); } - } } - if (!token.getCardType().isEmpty()) { - for (CardType t : token.getCardType()) { - if (!permanent.getCardType().contains(t)) { - permanent.addCardType(t); - } + + for (SuperType t : token.getSuperType()) { + if (!permanent.getSuperType().contains(t)) { + permanent.addSuperType(t); + } + } + + for (CardType t : token.getCardType()) { + if (!permanent.getCardType().contains(t)) { + permanent.addCardType(t); } } } break; + case ColorChangingEffects_5: if (sublayer == SubLayer.NA) { if (loseAllAbilities) { @@ -107,6 +111,7 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl { } } break; + case AbilityAddingRemovingEffects_6: if (loseAllAbilities) { permanent.removeAllAbilities(source.getSourceId(), game);