diff --git a/Mage.Sets/src/mage/cards/n/NecroticOoze.java b/Mage.Sets/src/mage/cards/n/NecroticOoze.java index 3cc535023f..f27bfff6ca 100644 --- a/Mage.Sets/src/mage/cards/n/NecroticOoze.java +++ b/Mage.Sets/src/mage/cards/n/NecroticOoze.java @@ -31,12 +31,15 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; + import mage.MageInt; import mage.abilities.Ability; import mage.abilities.ActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.Effect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -119,17 +122,11 @@ public class NecroticOoze extends CardImpl { @Override public Set isDependentTo(List allEffectsInLayer) { // the dependent classes needs to be an enclosed class for dependent check of continuous effects - Set dependentTo = null; - for (ContinuousEffect effect : allEffectsInLayer) { - // http://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/285211-yixlid-jailer-vs-necrotic-ooze - if (YixlidJailer.class.equals(effect.getClass().getEnclosingClass())) { - if (dependentTo == null) { - dependentTo = new HashSet<>(); - } - dependentTo.add(effect.getId()); - } - } - return dependentTo; + return allEffectsInLayer.stream() + .filter(effect -> YixlidJailer.class.equals(effect.getClass().getEnclosingClass())) + .map(Effect::getId) + .collect(Collectors.toSet()); + } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AfterUpkeepStepCondtion.java b/Mage/src/main/java/mage/abilities/condition/common/AfterUpkeepStepCondtion.java index c0ef7381d1..b3c60a479e 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AfterUpkeepStepCondtion.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AfterUpkeepStepCondtion.java @@ -23,8 +23,7 @@ public class AfterUpkeepStepCondtion implements Condition { @Override public boolean apply(Game game, Ability source) { - return !(game.getStep().getType() == PhaseStep.UNTAP - || game.getStep().getType() == PhaseStep.UPKEEP); + return game.getStep().getType().isAfter(PhaseStep.UPKEEP); } @Override diff --git a/Mage/src/main/java/mage/abilities/condition/common/BeforeBlockersAreDeclaredCondition.java b/Mage/src/main/java/mage/abilities/condition/common/BeforeBlockersAreDeclaredCondition.java index c0326e5bb4..c7f30b3fea 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/BeforeBlockersAreDeclaredCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/BeforeBlockersAreDeclaredCondition.java @@ -26,10 +26,7 @@ public class BeforeBlockersAreDeclaredCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return !(game.getStep().getType().equals(PhaseStep.DECLARE_BLOCKERS) - || game.getStep().getType().equals(PhaseStep.FIRST_COMBAT_DAMAGE) - || game.getStep().getType().equals(PhaseStep.COMBAT_DAMAGE) - || game.getStep().getType().equals(PhaseStep.END_COMBAT)); + return game.getStep().getType().isBefore(PhaseStep.DECLARE_BLOCKERS); } @Override diff --git a/Mage/src/main/java/mage/abilities/decorator/ConditionalAsThoughEffect.java b/Mage/src/main/java/mage/abilities/decorator/ConditionalAsThoughEffect.java index 2538b583cf..94c2caf4ad 100644 --- a/Mage/src/main/java/mage/abilities/decorator/ConditionalAsThoughEffect.java +++ b/Mage/src/main/java/mage/abilities/decorator/ConditionalAsThoughEffect.java @@ -28,6 +28,7 @@ package mage.abilities.decorator; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.abilities.effects.AsThoughEffect; @@ -36,10 +37,9 @@ import mage.constants.Duration; import mage.game.Game; /** - * * @author LevelX2 */ -public class ConditionalAsThoughEffect extends AsThoughEffectImpl { +public class ConditionalAsThoughEffect extends AsThoughEffectImpl { protected AsThoughEffect effect; protected AsThoughEffect otherwiseEffect; @@ -59,9 +59,9 @@ public class ConditionalAsThoughEffect extends AsThoughEffectImpl { public ConditionalAsThoughEffect(final ConditionalAsThoughEffect effect) { super(effect); - this.effect = (AsThoughEffect) effect.effect.copy(); + this.effect = effect.effect.copy(); if (effect.otherwiseEffect != null) { - this.otherwiseEffect = (AsThoughEffect) effect.otherwiseEffect.copy(); + this.otherwiseEffect = effect.otherwiseEffect.copy(); } this.condition = effect.condition; this.conditionState = effect.conditionState; diff --git a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java index d0382e571c..0916c4f730 100644 --- a/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/AuraReplacementEffect.java @@ -28,6 +28,7 @@ package mage.abilities.effects; import java.util.UUID; + import mage.MageObject; import mage.abilities.Ability; import mage.abilities.SpellAbility; @@ -55,10 +56,10 @@ import mage.target.common.TargetCardInGraveyard; * was not cast (so from Zone != Hand), this effect gets the target to whitch to * attach it and adds the Aura the the battlefield and attachs it to the target. * The "attachTo:" value in game state has to be set therefore. - * + *

* If no "attachTo:" value is defined, the controlling player has to chose the * aura target. - * + *

* This effect is automatically added to ContinuousEffects at the start of a * game * @@ -204,15 +205,15 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (((ZoneChangeEvent) event).getToZone().equals(Zone.BATTLEFIELD) - && !(((ZoneChangeEvent) event).getFromZone().equals(Zone.STACK))) { + if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD + && (((ZoneChangeEvent) event).getFromZone() != Zone.STACK)) { Card card = game.getCard(event.getTargetId()); if (card != null && (card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura", game) || // in case of transformable enchantments (game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null - && card.getSecondCardFace() != null - && card.getSecondCardFace().getCardType().contains(CardType.ENCHANTMENT) - && card.getSecondCardFace().hasSubtype("Aura", game)))) { + && card.getSecondCardFace() != null + && card.getSecondCardFace().getCardType().contains(CardType.ENCHANTMENT) + && card.getSecondCardFace().hasSubtype("Aura", game)))) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java index c3027ce821..52cb239bd2 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java @@ -33,6 +33,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; + import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.MageSingleton; @@ -51,7 +53,6 @@ import mage.game.Game; import mage.players.Player; /** - * * @author BetaSteward_at_googlemail.com */ public abstract class ContinuousEffectImpl extends EffectImpl implements ContinuousEffect { @@ -171,9 +172,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu public void init(Ability source, Game game) { targetPointer.init(game, source); //20100716 - 611.2c - if (AbilityType.ACTIVATED.equals(source.getAbilityType()) - || AbilityType.SPELL.equals(source.getAbilityType()) - || AbilityType.TRIGGERED.equals(source.getAbilityType())) { + if (AbilityType.ACTIVATED == source.getAbilityType() + || AbilityType.SPELL == source.getAbilityType() + || AbilityType.TRIGGERED == source.getAbilityType()) { if (layer != null) { switch (layer) { case CopyEffects_1: @@ -197,7 +198,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu @Override public boolean isInactive(Ability source, Game game) { - if (duration.equals(Duration.UntilYourNextTurn)) { + if (duration == Duration.UntilYourNextTurn) { Player player = game.getPlayer(startingControllerId); if (player != null) { if (player.isInGame()) { @@ -271,19 +272,13 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu @Override public Set isDependentTo(List allEffectsInLayer) { if (dependendToType != null) { - // the dependent classes needs to be an enclosed class for dependent check of continuous effects - Set dependentTo = null; - for (ContinuousEffect effect : allEffectsInLayer) { - if (effect.getDependencyTypes().contains(dependendToType)) { - if (dependentTo == null) { - dependentTo = new HashSet<>(); - } - dependentTo.add(effect.getId()); - } - } - return dependentTo; + return allEffectsInLayer.stream() + .filter(effect -> effect.getDependencyTypes().contains(dependendToType)) + .map(Effect::getId) + .collect(Collectors.toSet()); + } - return null; + return new HashSet<>(); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java index c5da9a1849..cd041b6d59 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java @@ -27,40 +27,12 @@ */ package mage.abilities.effects; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.UUID; import mage.MageObject; -import mage.abilities.Ability; -import mage.abilities.ActivatedAbility; -import mage.abilities.MageSingleton; -import mage.abilities.SpellAbility; -import mage.abilities.StaticAbility; +import mage.abilities.*; import mage.abilities.keyword.SpliceOntoArcaneAbility; import mage.cards.Cards; import mage.cards.CardsImpl; -import mage.constants.AbilityType; -import mage.constants.AsThoughEffectType; -import mage.constants.CostModificationType; -import mage.constants.Duration; -import mage.constants.EffectType; -import mage.constants.Layer; -import mage.constants.ManaType; -import mage.constants.Outcome; -import mage.constants.SpellAbilityType; -import mage.constants.SubLayer; -import mage.constants.Zone; +import mage.constants.*; import mage.filter.FilterCard; import mage.filter.predicate.Predicate; import mage.filter.predicate.Predicates; @@ -77,8 +49,11 @@ import mage.players.Player; import mage.target.common.TargetCardInHand; import org.apache.log4j.Logger; +import java.io.Serializable; +import java.util.*; +import java.util.Map.Entry; + /** - * * @author BetaSteward_at_googlemail.com */ public class ContinuousEffects implements Serializable { @@ -218,7 +193,7 @@ public class ContinuousEffects implements Serializable { case WhileOnStack: case WhileInGraveyard: HashSet abilities = layeredEffects.getAbility(effect.getId()); - if (abilities != null) { + if (!abilities.isEmpty()) { for (Ability ability : abilities) { // If e.g. triggerd abilities (non static) created the effect, the ability must not be in usable zone (e.g. Unearth giving Haste effect) if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) { @@ -358,7 +333,6 @@ public class ContinuousEffects implements Serializable { } /** - * * @param event * @param game * @return a list of all {@link ReplacementEffect} that apply to the current @@ -717,7 +691,8 @@ public class ContinuousEffects implements Serializable { spliceAbilities.remove(selectedAbility); } } - } while (!spliceAbilities.isEmpty() && controller.chooseUse(Outcome.Benefit, "Splice another card?", abilityToModify, game)); + } + while (!spliceAbilities.isEmpty() && controller.chooseUse(Outcome.Benefit, "Splice another card?", abilityToModify, game)); controller.revealCards("Spliced cards", cardsToReveal, game); } } @@ -727,10 +702,10 @@ public class ContinuousEffects implements Serializable { * Checks if an event won't happen because of an rule modifying effect * * @param event - * @param targetAbility ability the event is attached to. can be null. + * @param targetAbility ability the event is attached to. can be null. * @param game * @param checkPlayableMode true if the event does not really happen but - * it's checked if the event would be replaced + * it's checked if the event would be replaced * @return */ public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean checkPlayableMode) { @@ -777,7 +752,7 @@ public class ContinuousEffects implements Serializable { do { HashMap> rEffects = getApplicableReplacementEffects(event, game); // Remove all consumed effects (ability dependant) - for (Iterator it1 = rEffects.keySet().iterator(); it1.hasNext();) { + for (Iterator it1 = rEffects.keySet().iterator(); it1.hasNext(); ) { ReplacementEffect entry = it1.next(); if (consumed.containsKey(entry.getId())) { HashSet consumedAbilitiesIds = consumed.get(entry.getId()); @@ -865,9 +840,8 @@ public class ContinuousEffects implements Serializable { if (consumed.containsKey(rEffect.getId())) { HashSet set = consumed.get(rEffect.getId()); if (rAbility != null) { - if (!set.contains(rAbility.getId())) { - set.add(rAbility.getId()); - } + set.add(rAbility.getId()); + } } else { HashSet set = new HashSet<>(); @@ -936,7 +910,7 @@ public class ContinuousEffects implements Serializable { for (ContinuousEffect effect : layer) { if (activeLayerEffects.contains(effect) && !appliedEffects.contains(effect.getId())) { // Effect does still exist and was not applied yet Set dependentTo = effect.isDependentTo(layer); - if (dependentTo != null && !appliedEffects.containsAll(dependentTo)) { + if (!appliedEffects.containsAll(dependentTo)) { waitingEffects.put(effect, dependentTo); continue; } @@ -959,7 +933,7 @@ public class ContinuousEffects implements Serializable { if (!waitingEffects.isEmpty()) { // check if waiting effects can be applied now - for (Iterator>> iterator = waitingEffects.entrySet().iterator(); iterator.hasNext();) { + for (Iterator>> iterator = waitingEffects.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry> entry = iterator.next(); if (appliedEffects.containsAll(entry.getValue())) { // all dependent to effects are applied now so apply the effect itself appliedAbilities = appliedEffectAbilities.get(entry.getKey()); @@ -1039,7 +1013,7 @@ public class ContinuousEffects implements Serializable { for (ContinuousEffect effect : layer) { if (numberOfEffects > 1) { // If an effect is dependent to not applied effects yet of this layer, so wait to apply this effect Set dependentTo = effect.isDependentTo(layer); - if (dependentTo != null && !appliedEffects.containsAll(dependentTo)) { + if (!appliedEffects.containsAll(dependentTo)) { waitingEffects.put(effect, dependentTo); continue; } @@ -1162,17 +1136,16 @@ public class ContinuousEffects implements Serializable { private void setControllerForEffect(ContinuousEffectsList effects, UUID sourceId, UUID controllerId) { for (Effect effect : effects) { HashSet abilities = effects.getAbility(effect.getId()); - if (abilities != null) { - for (Ability ability : abilities) { - if (ability.getSourceId() != null) { - if (ability.getSourceId().equals(sourceId)) { - ability.setControllerId(controllerId); - } - } else if (!ability.getZone().equals(Zone.COMMAND)) { - logger.fatal("Continuous effect for ability with no sourceId Ability: " + ability); + for (Ability ability : abilities) { + if (ability.getSourceId() != null) { + if (ability.getSourceId().equals(sourceId)) { + ability.setControllerId(controllerId); } + } else if (ability.getZone() != Zone.COMMAND) { + logger.fatal("Continuous effect for ability with no sourceId Ability: " + ability); } } + } } diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java index 234a30e456..0fad03c7bc 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectsList.java @@ -34,6 +34,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.MageSingleton; import mage.constants.Duration; @@ -41,9 +42,8 @@ import mage.game.Game; import org.apache.log4j.Logger; /** - * - * @author BetaSteward_at_googlemail.com * @param + * @author BetaSteward_at_googlemail.com */ public class ContinuousEffectsList extends ArrayList { @@ -74,7 +74,7 @@ public class ContinuousEffectsList extends ArrayList } public void removeEndOfTurnEffects() { - for (Iterator i = this.iterator(); i.hasNext();) { + for (Iterator i = this.iterator(); i.hasNext(); ) { T entry = i.next(); if (entry.getDuration() == Duration.EndOfTurn) { i.remove(); @@ -84,7 +84,7 @@ public class ContinuousEffectsList extends ArrayList } public void removeEndOfCombatEffects() { - for (Iterator i = this.iterator(); i.hasNext();) { + for (Iterator i = this.iterator(); i.hasNext(); ) { T entry = i.next(); if (entry.getDuration() == Duration.EndOfCombat) { i.remove(); @@ -94,7 +94,7 @@ public class ContinuousEffectsList extends ArrayList } public void removeInactiveEffects(Game game) { - for (Iterator i = this.iterator(); i.hasNext();) { + for (Iterator i = this.iterator(); i.hasNext(); ) { T entry = i.next(); if (isInactive(entry, game)) { i.remove(); @@ -169,7 +169,7 @@ public class ContinuousEffectsList extends ArrayList } public HashSet getAbility(UUID effectId) { - return effectAbilityMap.get(effectId); + return effectAbilityMap.getOrDefault(effectId, new HashSet<>()); } public void removeEffects(UUID effectIdToRemove, Set abilitiesToRemove) { @@ -178,7 +178,7 @@ public class ContinuousEffectsList extends ArrayList abilities.removeAll(abilitiesToRemove); } if (abilities == null || abilities.isEmpty()) { - for (Iterator iterator = this.iterator(); iterator.hasNext();) { + for (Iterator iterator = this.iterator(); iterator.hasNext(); ) { ContinuousEffect effect = iterator.next(); if (effect.getId().equals(effectIdToRemove)) { iterator.remove(); diff --git a/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java b/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java index 320ddaa08b..ef78e432bb 100644 --- a/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/EntersBattlefieldEffect.java @@ -97,13 +97,13 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl { public boolean checksEventType(GameEvent event, Game game) { switch (enterEventType) { case OTHER: - return EventType.ENTERS_THE_BATTLEFIELD.equals(event.getType()); + return EventType.ENTERS_THE_BATTLEFIELD == event.getType(); case SELF: - return EventType.ENTERS_THE_BATTLEFIELD_SELF.equals(event.getType()); + return EventType.ENTERS_THE_BATTLEFIELD_SELF == event.getType(); case CONTROL: - return EventType.ENTERS_THE_BATTLEFIELD_CONTROL.equals(event.getType()); + return EventType.ENTERS_THE_BATTLEFIELD_CONTROL == event.getType(); case COPY: - return EventType.ENTERS_THE_BATTLEFIELD_COPY.equals(event.getType()); + return EventType.ENTERS_THE_BATTLEFIELD_COPY == event.getType(); } return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/PayCostToAttackBlockEffectImpl.java b/Mage/src/main/java/mage/abilities/effects/PayCostToAttackBlockEffectImpl.java index f1440fb6c6..6b3c56b6fe 100644 --- a/Mage/src/main/java/mage/abilities/effects/PayCostToAttackBlockEffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/PayCostToAttackBlockEffectImpl.java @@ -44,7 +44,7 @@ import mage.players.Player; */ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectImpl implements PayCostToAttackBlockEffect { - public static enum RestrictType { + public enum RestrictType { ATTACK("attack"), ATTACK_AND_BLOCK("attack or block"), @@ -111,7 +111,7 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm case BLOCK: return event.getType().equals(GameEvent.EventType.DECLARE_BLOCKER); case ATTACK_AND_BLOCK: - return event.getType() == GameEvent.EventType.DECLARE_ATTACKER || event.getType().equals(GameEvent.EventType.DECLARE_BLOCKER); + return event.getType() == GameEvent.EventType.DECLARE_ATTACKER || event.getType() == EventType.DECLARE_BLOCKER; } return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/AddCombatAndMainPhaseEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AddCombatAndMainPhaseEffect.java index c2fee30b9c..4cc5a71ce6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AddCombatAndMainPhaseEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AddCombatAndMainPhaseEffect.java @@ -61,8 +61,8 @@ public class AddCombatAndMainPhaseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { // 15.07.2006 If it's somehow not a main phase when Fury of the Horde resolves, all it does is untap all creatures that attacked that turn. No new phases are created. - if (TurnPhase.PRECOMBAT_MAIN.equals(game.getTurn().getPhaseType()) - || TurnPhase.POSTCOMBAT_MAIN.equals(game.getTurn().getPhaseType())) { + if (game.getTurn().getPhaseType() == TurnPhase.PRECOMBAT_MAIN + || game.getTurn().getPhaseType() == TurnPhase.POSTCOMBAT_MAIN) { // we can't add two turn modes at once, will add additional post combat on delayed trigger resolution TurnMod combat = new TurnMod(source.getControllerId(), TurnPhase.COMBAT, TurnPhase.POSTCOMBAT_MAIN, false); game.getState().getTurnMods().add(combat); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java index 9cda89ce6b..8f0989f7cb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepTargetEffect.java @@ -114,7 +114,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR public boolean applies(GameEvent event, Ability source, Game game) { // the check if a permanent untap pahse is already handled is needed if multiple effects are added to prevent untap in next untap step of controller // if we don't check it for every untap step of a turn only one effect would be consumed instead of all be valid for the next untap step - if (GameEvent.EventType.UNTAP_STEP.equals(event.getType())) { + if (event.getType() == EventType.UNTAP_STEP) { boolean allHandled = true; for (UUID targetId : getTargetPointer().getTargets(game, source)) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepEnchantedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepEnchantedEffect.java index f259f9568d..541bdd908e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepEnchantedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepEnchantedEffect.java @@ -56,7 +56,7 @@ public class DontUntapInControllersUntapStepEnchantedEffect extends ContinuousRu @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (PhaseStep.UNTAP.equals(game.getTurn().getStepType())) { + if (game.getTurn().getStepType() == PhaseStep.UNTAP) { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) { Permanent permanent = game.getPermanent(enchantment.getAttachedTo()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepTargetEffect.java index 69118f2ac1..b4e0b50bd2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersUntapStepTargetEffect.java @@ -81,7 +81,7 @@ public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleM @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (PhaseStep.UNTAP.equals(game.getTurn().getStepType())) { + if (game.getTurn().getStepType() == PhaseStep.UNTAP) { for (UUID targetId : targetPointer.getTargets(game, source)) { if (event.getTargetId().equals(targetId)) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInOpponentsNextUntapStepAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInOpponentsNextUntapStepAllEffect.java index 53a627a1d9..81d25066c5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInOpponentsNextUntapStepAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInOpponentsNextUntapStepAllEffect.java @@ -107,7 +107,7 @@ public class DontUntapInOpponentsNextUntapStepAllEffect extends ContinuousRuleMo return false; } // remember the turn of the untap step the effect has to be applied - if (GameEvent.EventType.UNTAP_STEP.equals(event.getType())) { + if (event.getType() == EventType.UNTAP_STEP) { if (game.getActivePlayerId().equals(getTargetPointer().getFirst(game, source))) { if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step discard(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java index 0d1c9dda85..20ab7c5e7b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java @@ -190,7 +190,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff if (player.choose(Outcome.DrawCard, cards, target, game)) { Cards pickedCards = new CardsImpl(target.getTargets()); cards.removeAll(pickedCards); - if (targetPickedCards.equals(Zone.LIBRARY) && !putOnTopSelected) { + if (targetPickedCards == Zone.LIBRARY && !putOnTopSelected) { player.putCardsOnBottomOfLibrary(pickedCards, game, source, true); } else { player.moveCards(pickedCards.getCards(game), targetPickedCards, source, game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAttachedEffect.java index 19432669b3..db8b62ba53 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAttachedEffect.java @@ -44,7 +44,7 @@ public class AttacksIfAbleAttachedEffect extends RequirementEffect { public AttacksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) { super(duration); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature attacks each turn if able"; } else { this.staticText = "Equipped creature attacks each turn if able"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java index c4421d7951..c8b8f140f2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAllEffect.java @@ -51,7 +51,7 @@ public class BlocksIfAbleAllEffect extends RequirementEffect { super(duration); staticText = new StringBuilder(filter.getMessage()) .append(" block ") - .append(duration.equals(Duration.EndOfTurn) ? "this":"each") + .append(duration == Duration.EndOfTurn ? "this":"each") .append(" turn if able").toString(); this.filter = filter; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAttachedEffect.java index 0c00164f6a..b6dcc75a19 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/BlocksIfAbleAttachedEffect.java @@ -44,7 +44,7 @@ public class BlocksIfAbleAttachedEffect extends RequirementEffect { public BlocksIfAbleAttachedEffect(Duration duration, AttachmentType attachmentType) { super(duration); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature blocks each turn if able"; } else { this.staticText = "Equipped creature blocks each turn if able"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java index 1acbd8bba1..8bd2142df4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderAllEffect.java @@ -27,7 +27,6 @@ */ package mage.abilities.effects.common.combat; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.AsThoughEffectImpl; import mage.constants.AsThoughEffectType; @@ -38,18 +37,19 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author Quercitron */ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffectImpl { private final FilterPermanent filter; - + public CanAttackAsThoughItDidntHaveDefenderAllEffect(Duration duration) { this(duration, new FilterCreaturePermanent()); } - + public CanAttackAsThoughItDidntHaveDefenderAllEffect(Duration duration, FilterPermanent filter) { super(AsThoughEffectType.ATTACK, duration, Outcome.Benefit); this.filter = filter; @@ -76,12 +76,12 @@ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffec Permanent permanent = game.getPermanent(objectId); return permanent != null && filter.match(permanent, game); } - + private String getText() { StringBuilder sb = new StringBuilder(filter.getMessage()); sb.append(" can attack "); - if (!duration.toString().isEmpty()) { - if(Duration.EndOfTurn.equals(duration)) { + if (!duration.toString().isEmpty()) { + if (Duration.EndOfTurn == duration) { sb.append("this turn"); } else { sb.append(duration.toString()); @@ -89,6 +89,6 @@ public class CanAttackAsThoughItDidntHaveDefenderAllEffect extends AsThoughEffec sb.append(' '); } sb.append("as though they didn't have defender"); - return sb.toString(); + return sb.toString(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderSourceEffect.java index cda6bf1b3f..8e8837ae69 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CanAttackAsThoughItDidntHaveDefenderSourceEffect.java @@ -44,7 +44,7 @@ public class CanAttackAsThoughItDidntHaveDefenderSourceEffect extends AsThoughEf public CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration duration) { super(AsThoughEffectType.ATTACK, duration, Outcome.Benefit); staticText = "{this} can attack " - + (duration.equals(Duration.EndOfTurn) ? "this turn " : "") + + (duration == Duration.EndOfTurn ? "this turn " : "") + "as though it didn't have defender"; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java index 9053f62776..889acb03ea 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CanBlockOnlyFlyingAttachedEffect.java @@ -45,7 +45,7 @@ public class CanBlockOnlyFlyingAttachedEffect extends RestrictionEffect { public CanBlockOnlyFlyingAttachedEffect(AttachmentType attachmentType) { super(Duration.WhileOnBattlefield); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature can block only creatures with flying"; } else { this.staticText = "Equipped creature can block only creatures with flying"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java index 79a28e2703..55a030d9e4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java @@ -20,7 +20,7 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect { public CantAttackAloneAttachedEffect(AttachmentType attachmentType) { super(Duration.WhileOnBattlefield); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature can't attack alone"; } else { this.staticText = "Equipped creature can't attack alone"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAttachedEffect.java index ebea8a1e29..1bb4ce7527 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAttachedEffect.java @@ -44,7 +44,7 @@ public class CantAttackAttachedEffect extends RestrictionEffect { public CantAttackAttachedEffect(AttachmentType attachmentType) { super(Duration.WhileOnBattlefield); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature can't attack"; } else { this.staticText = "Equipped creature can't attack"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java index 96a726b457..af046779ac 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAllEffect.java @@ -48,7 +48,7 @@ public class CantAttackBlockAllEffect extends RestrictionEffect { StringBuilder sb = new StringBuilder(filter.getMessage()).append(" can't attack or block"); if (!duration.toString().isEmpty()) { sb.append(' '); - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { sb.append(" this turn"); } else { sb.append(' ').append(duration.toString()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java index 5904f32957..4f1e9be277 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java @@ -42,7 +42,7 @@ public class CantAttackBlockAttachedEffect extends RestrictionEffect { public CantAttackBlockAttachedEffect(AttachmentType attachmentType) { super(Duration.WhileOnBattlefield); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature can't attack or block"; } else { this.staticText = "Equipped creature can't attack or block"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysAttachedEffect.java index 6d7a9c54d9..df1f936cc1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysAttachedEffect.java @@ -46,7 +46,7 @@ public class CantAttackBlockUnlessPaysAttachedEffect extends PayCostToAttackBloc public CantAttackBlockUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) { super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK_AND_BLOCK, manaCosts); - staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted " : "Equipped ") + staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ") + "creature can't attack or block unless its controller pays " + (manaCosts == null ? "" : manaCosts.getText()); } @@ -59,10 +59,10 @@ public class CantAttackBlockUnlessPaysAttachedEffect extends PayCostToAttackBloc public boolean applies(GameEvent event, Ability source, Game game) { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) { - if (event.getType().equals(EventType.DECLARE_ATTACKER)) { + if (event.getType() == EventType.DECLARE_ATTACKER) { return event.getSourceId().equals(enchantment.getAttachedTo()); } - if (event.getType().equals(EventType.DECLARE_BLOCKER)) { + if (event.getType() == EventType.DECLARE_BLOCKER) { return event.getSourceId().equals(enchantment.getAttachedTo()); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysSourceEffect.java index b7969dc5b4..c7408d5897 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockUnlessPaysSourceEffect.java @@ -47,7 +47,7 @@ public class CantAttackBlockUnlessPaysSourceEffect extends PayCostToAttackBlockE super(Duration.WhileOnBattlefield, Outcome.Detriment, restrictType, cost); staticText = "{this} can't " + restrictType.toString() + " unless you " + cost == null ? "" : cost.getText() - + (restrictType.equals(RestrictType.ATTACK) ? " (This cost is paid as attackers are declared.)" : ""); + + (restrictType == RestrictType.ATTACK ? " (This cost is paid as attackers are declared.)" : ""); } public CantAttackBlockUnlessPaysSourceEffect(ManaCosts manaCosts, RestrictType restrictType) { @@ -62,10 +62,10 @@ public class CantAttackBlockUnlessPaysSourceEffect extends PayCostToAttackBlockE @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (!restrictType.equals(RestrictType.BLOCK) && event.getType().equals(EventType.DECLARE_ATTACKER)) { + if (!(restrictType == RestrictType.BLOCK) && event.getType() == EventType.DECLARE_ATTACKER) { return event.getSourceId().equals(source.getSourceId()); } - if (!restrictType.equals(RestrictType.ATTACK) && event.getType().equals(EventType.DECLARE_BLOCKER)) { + if (!(restrictType == RestrictType.ATTACK) && event.getType() == EventType.DECLARE_BLOCKER) { return event.getSourceId().equals(source.getSourceId()); } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java index 69c5101f3f..df49c730d0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackControllerAttachedEffect.java @@ -46,7 +46,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect { public CantAttackControllerAttachedEffect(AttachmentType attachmentType) { super(Duration.WhileOnBattlefield); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature can't attack you or a planeswalker you control"; } else { this.staticText = "Equipped creature can't attack you or a planeswalker you control"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackUnlessPaysAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackUnlessPaysAttachedEffect.java index 5dee2cc0b1..4bfb764f58 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackUnlessPaysAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackUnlessPaysAttachedEffect.java @@ -46,7 +46,7 @@ public class CantAttackUnlessPaysAttachedEffect extends PayCostToAttackBlockEffe public CantAttackUnlessPaysAttachedEffect(ManaCosts manaCosts, AttachmentType attachmentType) { super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK, manaCosts); - staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted " : "Equipped ") + staticText = (attachmentType == AttachmentType.AURA ? "Enchanted " : "Equipped ") + "creature can't attack unless its controller pays " + (manaCosts == null ? "" : manaCosts.getText()); } @@ -59,7 +59,7 @@ public class CantAttackUnlessPaysAttachedEffect extends PayCostToAttackBlockEffe public boolean applies(GameEvent event, Ability source, Game game) { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) { - if (event.getType().equals(EventType.DECLARE_ATTACKER)) { + if (event.getType() == EventType.DECLARE_ATTACKER) { return event.getSourceId().equals(enchantment.getAttachedTo()); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java index 82410c702b..7dc4efa76c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackYouAllEffect.java @@ -59,7 +59,7 @@ public class CantAttackYouAllEffect extends RestrictionEffect { this.alsoPlaneswalker = alsoPlaneswalker; staticText = filterAttacker.getMessage() + " can't attack you" + (alsoPlaneswalker ? " or a planeswalker you control" : "") - + (duration.equals(Duration.UntilYourNextTurn) ? " until your next turn" : ""); + + (duration == Duration.UntilYourNextTurn ? " until your next turn" : ""); } CantAttackYouAllEffect(final CantAttackYouAllEffect effect) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java index 0a4ca0c1b8..d87d9978ff 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAllEffect.java @@ -47,7 +47,7 @@ public class CantBeBlockedAllEffect extends RestrictionEffect { this.filter = filter; this.staticText = filter.getMessage() + " can't be blocked"; - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { this.staticText += " this turn"; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAttachedEffect.java index d995a52417..a975bc89f3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedAttachedEffect.java @@ -42,7 +42,7 @@ public class CantBeBlockedAttachedEffect extends RestrictionEffect { public CantBeBlockedAttachedEffect(AttachmentType attachmentType) { super(Duration.WhileOnBattlefield); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { this.staticText = "Enchanted creature can't be blocked"; } else { this.staticText = "Equipped creature can't be blocked"; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java index 603ade5201..c6c5c62472 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java @@ -47,7 +47,7 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect { super(duration); this.filter = filter; StringBuilder sb = new StringBuilder(); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { sb.append("Enchanted "); } else { sb.append("Equipped "); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java index 2762140573..6fd2ee2115 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java @@ -56,7 +56,7 @@ public class CantBeBlockedByOneAllEffect extends ContinuousEffectImpl { this.amount = amount; this.filter = filter; StringBuilder sb = new StringBuilder("each ").append(filter.getMessage()).append(" can't be blocked "); - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { sb.append("this turn "); } sb.append("except by ").append(CardUtil.numberToText(amount)).append(" or more creatures"); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAttachedEffect.java index b28abb1b23..76437b0e84 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByOneAttachedEffect.java @@ -54,7 +54,7 @@ public class CantBeBlockedByOneAttachedEffect extends ContinuousEffectImpl { super(duration, Outcome.Benefit); this.amount = amount; this.attachmentType = attachmentType; - staticText = (attachmentType.equals(AttachmentType.AURA) ? "Enchanted" : "Equipped") + " creature can't be blocked except by " + amount + " or more creatures"; + staticText = (attachmentType == AttachmentType.AURA ? "Enchanted" : "Equipped") + " creature can't be blocked except by " + amount + " or more creatures"; } public CantBeBlockedByOneAttachedEffect(final CantBeBlockedByOneAttachedEffect effect) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java index 1acc83c3b3..20317444d8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java @@ -93,7 +93,7 @@ public class CantBeBlockedByTargetSourceEffect extends RestrictionEffect { sb.append("Target "); } sb.append(target.getTargetName()).append(" can't block {this}"); - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { sb.append(" this turn"); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedSourceEffect.java index 65397f268d..3e7a3c2df5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedSourceEffect.java @@ -45,7 +45,7 @@ public class CantBeBlockedSourceEffect extends RestrictionEffect { public CantBeBlockedSourceEffect(Duration duration) { super(duration); this.staticText = "{this} can't be blocked"; - if (Duration.EndOfTurn.equals(this.duration)) { + if (this.duration == Duration.EndOfTurn) { this.staticText += " this turn"; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java index 6b2206a436..11fcccee32 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAllEffect.java @@ -72,7 +72,7 @@ public class CantBlockAllEffect extends RestrictionEffect { public String getText(Mode mode) { StringBuilder sb = new StringBuilder(); sb.append(filter.getMessage()).append(" can't block"); - if (Duration.EndOfTurn.equals(this.duration)) { + if (this.duration == Duration.EndOfTurn) { sb.append(" this turn"); } return sb.toString(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java index 50927b66ab..017cf8991b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockAttachedEffect.java @@ -56,7 +56,7 @@ public class CantBlockAttachedEffect extends RestrictionEffect { super(duration); this.filter = filter; StringBuilder sb = new StringBuilder(); - if (attachmentType.equals(AttachmentType.AURA)) { + if (attachmentType == AttachmentType.AURA) { sb.append("Enchanted creature can't block"); } else { sb.append("Equipped creature can't block"); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java index f36ec2805c..ca99b4bcd8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java @@ -43,7 +43,7 @@ public class CantBlockSourceEffect extends RestrictionEffect { public CantBlockSourceEffect(Duration duration) { super(duration); this.staticText = "{this} can't block"; - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { this.staticText += " this turn"; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockTargetEffect.java index 5e61b12edd..1cb92d7535 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockTargetEffect.java @@ -89,7 +89,7 @@ public class CantBlockTargetEffect extends RestrictionEffect { } sb.append(" can't block"); - if (Duration.EndOfTurn.equals(this.duration)) { + if (this.duration == Duration.EndOfTurn) { sb.append(" this turn"); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java index 7f8dd5e81f..f242fd2cf5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java @@ -46,7 +46,7 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect { public MustBeBlockedByAllTargetEffect(Duration duration) { super(duration); staticText = new StringBuilder("All creatures able to block target creature ") - .append(this.getDuration().equals(Duration.EndOfTurn) ? "this turn ":"") + .append(this.getDuration() == Duration.EndOfTurn ? "this turn ":"") .append("do so").toString(); } @@ -58,7 +58,7 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect { public boolean applies(Permanent permanent, Ability source, Game game) { Permanent attackingCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (attackingCreature != null && attackingCreature.isAttacking()) { - if (!source.getAbilityType().equals(AbilityType.STATIC)) { + if (source.getAbilityType() != AbilityType.STATIC) { BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher"); if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attackingCreature, permanent, game)) { // has already blocked this turn, so no need to do again diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubTypeTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubTypeTargetEffect.java index f58836f257..a32141d8c7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubTypeTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardSubTypeTargetEffect.java @@ -62,7 +62,7 @@ public class AddCardSubTypeTargetEffect extends ContinuousEffectImpl { target.getSubtype(game).add(addedSubType); } } else { - if (Duration.Custom.equals(duration)) { + if (duration == Duration.Custom) { discard(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeSourceEffect.java index fa695f368f..a3c0db0e11 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeSourceEffect.java @@ -49,7 +49,7 @@ public class AddCardTypeSourceEffect extends ContinuousEffectImpl { public AddCardTypeSourceEffect(CardType addedCardType, Duration duration) { super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); this.addedCardType = addedCardType; - if (addedCardType.equals(CardType.ENCHANTMENT)) { + if (addedCardType == CardType.ENCHANTMENT) { dependencyTypes.add(DependencyType.EnchantmentAddingRemoving); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeTargetEffect.java index 665f4b28cc..56981a038f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeTargetEffect.java @@ -50,9 +50,9 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl { public AddCardTypeTargetEffect(CardType addedCardType, Duration duration) { super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit); this.addedCardType = addedCardType; - if (addedCardType.equals(CardType.ENCHANTMENT)) { + if (addedCardType == CardType.ENCHANTMENT) { dependencyTypes.add(DependencyType.EnchantmentAddingRemoving); - } else if (addedCardType.equals(CardType.ARTIFACT)) { + } else if (addedCardType == CardType.ARTIFACT) { dependencyTypes.add(DependencyType.ArtifactAddingRemoving); } } @@ -75,7 +75,7 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl { } } if (!result) { - if (this.getDuration().equals(Duration.Custom)) { + if (this.getDuration() == Duration.Custom) { this.discard(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java index 1e32816cce..12d8955d1d 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java @@ -130,7 +130,7 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl { sb.append(" can't gain life"); if (!this.duration.toString().isEmpty()) { sb.append(' '); - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { sb.append("this turn"); } else { sb.append(duration.toString()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeTargetEffect.java index 7ac097963a..18af3f8478 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeTargetEffect.java @@ -48,7 +48,7 @@ public class CantGainLifeTargetEffect extends ContinuousEffectImpl { super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit); StringBuilder sb = new StringBuilder("If that player would gain life"); if (!this.duration.toString().isEmpty()) { - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { sb.append("this turn, "); } else { sb.append(' ').append(duration.toString()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java index ab7967dc1d..b1b2623be4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CastAsThoughItHadFlashAllEffect.java @@ -94,7 +94,7 @@ public class CastAsThoughItHadFlashAllEffect extends AsThoughEffectImpl { sb.append(" may cast "); sb.append(filter.getMessage()); if (!duration.toString().isEmpty()) { - if (duration.equals(Duration.EndOfTurn)) { + if (duration == Duration.EndOfTurn) { sb.append(" this turn"); } else { sb.append(' '); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/DamageCantBePreventedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/DamageCantBePreventedEffect.java index 08b432f31b..56d08fdbab 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/DamageCantBePreventedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/DamageCantBePreventedEffect.java @@ -29,7 +29,7 @@ public class DamageCantBePreventedEffect extends ContinuousRuleModifyingEffectIm @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType().equals(GameEvent.EventType.PREVENT_DAMAGE); + return event.getType() == GameEvent.EventType.PREVENT_DAMAGE; } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java index 8ea40207d6..e81642e823 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java @@ -46,7 +46,7 @@ import mage.util.CardUtil; */ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { - public static enum HandSizeModification { + public enum HandSizeModification { SET, INCREASE, REDUCE } @@ -90,8 +90,8 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { protected static Outcome defineOutcome(HandSizeModification handSizeModification, TargetController targetController) { Outcome newOutcome = Outcome.Benefit; - if ((targetController.equals(TargetController.YOU) || targetController.equals(TargetController.ANY)) - && handSizeModification.equals(HandSizeModification.REDUCE)) { + if ((targetController == TargetController.YOU || targetController == TargetController.ANY) + && handSizeModification == HandSizeModification.REDUCE) { newOutcome = Outcome.Detriment; } return newOutcome; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayAdditionalLandsControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayAdditionalLandsControllerEffect.java index 8d84b19e7c..c7395e98b9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayAdditionalLandsControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayAdditionalLandsControllerEffect.java @@ -38,7 +38,6 @@ import mage.game.Game; import mage.players.Player; /** - * * @author Viserion */ public class PlayAdditionalLandsControllerEffect extends ContinuousEffectImpl { @@ -65,10 +64,9 @@ public class PlayAdditionalLandsControllerEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - if(player.getLandsPerTurn() == Integer.MAX_VALUE || this.additionalCards == Integer.MAX_VALUE){ + if (player.getLandsPerTurn() == Integer.MAX_VALUE || this.additionalCards == Integer.MAX_VALUE) { player.setLandsPerTurn(Integer.MAX_VALUE); - } - else{ + } else { player.setLandsPerTurn(player.getLandsPerTurn() + this.additionalCards); } return true; @@ -79,15 +77,13 @@ public class PlayAdditionalLandsControllerEffect extends ContinuousEffectImpl { private void setText() { StringBuilder sb = new StringBuilder(); sb.append("You may play "); - if(additionalCards == Integer.MAX_VALUE){ + if (additionalCards == Integer.MAX_VALUE) { sb.append("any number of"); + } else { + sb.append(Integer.toString(additionalCards)); } - else - { - sb.append(Integer.toString(additionalCards)); - } - sb.append(" additional land").append((additionalCards == 1 ? "" : "s")) - .append(duration == Duration.EndOfTurn ? " this turn" : " on each of your turns"); + sb.append(" additional land").append((additionalCards == 1 ? "" : "s")) + .append(duration == Duration.EndOfTurn ? " this turn" : " on each of your turns"); staticText = sb.toString(); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java index 4ae3e82e0d..7a3ba37830 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java @@ -71,7 +71,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl { affectedPlayers = game.getOpponents(source.getControllerId()); break; case YOU: - ArrayList tmp = new ArrayList<>(); + ArrayList tmp = new ArrayList<>(); tmp.add(source.getControllerId()); affectedPlayers = tmp; break; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java index 5947dbdb31..8182274c24 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerToughnessSourceEffect.java @@ -85,7 +85,7 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { MageObject mageObject = game.getPermanentEntering(source.getSourceId()); if (mageObject == null) { - if (duration.equals(Duration.Custom) || isTemporary()) { + if (duration == Duration.Custom || isTemporary()) { mageObject = game.getPermanent(source.getSourceId()); } else { mageObject = game.getObject(source.getSourceId()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessSourceEffect.java index f14ea6a4ce..a13e3178d6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessSourceEffect.java @@ -37,7 +37,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; /** - * * @author North */ public class SwitchPowerToughnessSourceEffect extends ContinuousEffectImpl { @@ -58,7 +57,7 @@ public class SwitchPowerToughnessSourceEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - Permanent target = (Permanent) game.getPermanent(source.getSourceId()); + Permanent target = game.getPermanent(source.getSourceId()); if (target != null) { int power = target.getPower().getValue(); target.getPower().setValue(target.getToughness().getValue()); @@ -68,4 +67,4 @@ public class SwitchPowerToughnessSourceEffect extends ContinuousEffectImpl { return false; } - } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessTargetEffect.java index 759ae59865..316e5cd36a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SwitchPowerToughnessTargetEffect.java @@ -39,7 +39,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; /** - * * @author ayratn */ public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl { @@ -59,7 +58,7 @@ public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - Permanent target = (Permanent) game.getPermanent(source.getFirstTarget()); + Permanent target = game.getPermanent(source.getFirstTarget()); if (target != null) { int power = target.getPower().getValue(); target.getPower().setValue(target.getToughness().getValue()); @@ -73,7 +72,7 @@ public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl { public String getText(Mode mode) { StringBuilder sb = new StringBuilder(); sb.append("Switch target ").append(mode.getTargets().get(0).getTargetName()).append("'s power and toughness") - .append(' ').append(duration.toString()); + .append(' ').append(duration.toString()); return sb.toString(); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java index 2b74dc176a..9fb4fabaef 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapAllDuringEachOtherPlayersUntapStepEffect.java @@ -69,7 +69,7 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff if (applied == null) { applied = Boolean.FALSE; } - if (!applied && layer.equals(Layer.RulesEffects)) { + if (!applied && layer == Layer.RulesEffects) { if (!source.getControllerId().equals(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) { game.getState().setValue(source.getSourceId() + "applied", true); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapSourceDuringEachOtherPlayersUntapStepEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapSourceDuringEachOtherPlayersUntapStepEffect.java index 4d7010102b..b0eaa7ed3c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapSourceDuringEachOtherPlayersUntapStepEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/UntapSourceDuringEachOtherPlayersUntapStepEffect.java @@ -64,7 +64,7 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous if (applied == null) { applied = Boolean.FALSE; } - if (!applied && layer.equals(Layer.RulesEffects)) { + if (!applied && layer == Layer.RulesEffects) { if (!source.getControllerId().equals(game.getActivePlayerId()) && game.getStep() != null && game.getStep().getType() == PhaseStep.UNTAP) { @@ -80,7 +80,7 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous } } } - } else if (applied && layer.equals(Layer.RulesEffects)) { + } else if (applied && layer == Layer.RulesEffects) { if (game.getStep() != null && game.getStep().getType() == PhaseStep.END_TURN) { game.getState().setValue(source.getSourceId() + "applied", false); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java index c18d4030f0..b50b5adbbb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java @@ -71,8 +71,7 @@ public class ProliferateEffect extends OneShotEffect { options.put("UI.right.btn.text", "Done"); controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options); - for (int idx = 0; idx < target.getTargets().size(); idx++) { - UUID chosen = (UUID) target.getTargets().get(idx); + for (UUID chosen : target.getTargets()) { Permanent permanent = game.getPermanent(chosen); if (permanent != null) { if (!permanent.getCounters(game).isEmpty()) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyDuringPhaseStepSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyDuringPhaseStepSourceEffect.java index c20202dfc9..ccd8fcfbe1 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyDuringPhaseStepSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyDuringPhaseStepSourceEffect.java @@ -16,7 +16,6 @@ import mage.game.Game; import mage.game.events.GameEvent; /** - * * @author LevelX2 */ public class CastOnlyDuringPhaseStepSourceEffect extends ContinuousRuleModifyingEffectImpl { @@ -49,8 +48,8 @@ public class CastOnlyDuringPhaseStepSourceEffect extends ContinuousRuleModifying public boolean applies(GameEvent event, Ability source, Game game) { // has to return true, if the spell cannot be cast in the current phase / step if (event.getSourceId().equals(source.getSourceId())) { - if ((turnPhase != null && !game.getPhase().getType().equals(turnPhase)) - || (phaseStep != null && !game.getTurn().getStepType().equals(phaseStep)) + if ((turnPhase != null && game.getPhase().getType() != turnPhase) + || (phaseStep != null && (game.getTurn().getStepType() != phaseStep)) || (condition != null && !condition.apply(game, source))) { return true; } diff --git a/Mage/src/main/java/mage/constants/PhaseStep.java b/Mage/src/main/java/mage/constants/PhaseStep.java index 06bd7427df..f6bb690515 100644 --- a/Mage/src/main/java/mage/constants/PhaseStep.java +++ b/Mage/src/main/java/mage/constants/PhaseStep.java @@ -1,5 +1,7 @@ package mage.constants; +import mage.game.turn.Phase; + /** * * @author North @@ -33,6 +35,14 @@ public enum PhaseStep { this.stepText = stepText; } + public boolean isBefore(PhaseStep other){ + return this.getIndex()other.getIndex(); + } + public int getIndex() { return index; }