From 1bc8e2248bc32cf71bd4c340a951830ed1a69019 Mon Sep 17 00:00:00 2001 From: ingmargoudt Date: Tue, 7 Mar 2017 21:47:11 +0100 Subject: [PATCH] changed enum equals to ==, removed contains check for set --- Mage.Common/src/mage/view/RevealedView.java | 4 +-- Mage.Common/src/mage/view/RoundView.java | 8 ++--- Mage/src/main/java/mage/ConditionalMana.java | 6 ++-- .../abilities/abilityword/KinshipAbility.java | 2 +- .../AfterBlockersAreDeclaredCondition.java | 5 +-- .../condition/common/IsPhaseCondition.java | 5 ++- .../common/ManaWasSpentCondition.java | 2 +- ...yTurnBeforeAttackersDeclaredCondition.java | 4 +-- .../SourceTappedBeforeUntapStepCondition.java | 4 +-- .../condition/common/SurgedCondition.java | 2 +- ...nControllersNextUntapStepSourceEffect.java | 2 +- .../continuous/AddCardTypeSourceEffect.java | 2 +- .../continuous/BecomesColorTargetEffect.java | 2 +- .../BecomesCreatureAttachedEffect.java | 36 ++++++++----------- .../continuous/SetToughnessSourceEffect.java | 2 +- .../mage/abilities/keyword/EchoAbility.java | 2 +- .../abilities/keyword/SuspendAbility.java | 2 +- Mage/src/main/java/mage/game/Table.java | 2 +- 18 files changed, 42 insertions(+), 50 deletions(-) diff --git a/Mage.Common/src/mage/view/RevealedView.java b/Mage.Common/src/mage/view/RevealedView.java index d5f086e410..b2f79d67fa 100644 --- a/Mage.Common/src/mage/view/RevealedView.java +++ b/Mage.Common/src/mage/view/RevealedView.java @@ -29,12 +29,12 @@ package mage.view; import java.io.Serializable; + import mage.cards.Card; import mage.cards.Cards; import mage.game.Game; /** - * * @author BetaSteward_at_googlemail.com */ public class RevealedView implements Serializable { @@ -44,7 +44,7 @@ public class RevealedView implements Serializable { public RevealedView(String name, Cards cards, Game game) { this.name = name; - for (Card card: cards.getCards(game)) { + for (Card card : cards.getCards(game)) { this.cards.put(card.getId(), new CardView(card, game, card.getId())); } } diff --git a/Mage.Common/src/mage/view/RoundView.java b/Mage.Common/src/mage/view/RoundView.java index b34b5b89ee..fc8297b9c3 100644 --- a/Mage.Common/src/mage/view/RoundView.java +++ b/Mage.Common/src/mage/view/RoundView.java @@ -31,13 +31,13 @@ package mage.view; import java.io.Serializable; import java.util.ArrayList; import java.util.List; + import mage.game.Game; import mage.game.GameInfo; import mage.game.tournament.Round; import mage.game.tournament.TournamentPairing; /** - * * @author BetaSteward_at_googlemail.com */ public class RoundView implements Serializable { @@ -47,17 +47,17 @@ public class RoundView implements Serializable { public RoundView(Round round) { try { - for (TournamentPairing pair: round.getPairs()) { + for (TournamentPairing pair : round.getPairs()) { // get info of finished games from match if (pair.getMatch() != null) { - for (GameInfo gameInfo: pair.getMatch().getGamesInfo()) { + for (GameInfo gameInfo : pair.getMatch().getGamesInfo()) { games.add(new TournamentGameView(round.getRoundNumber(), gameInfo.getMatchId(), gameInfo.getGameId(), gameInfo.getState(), gameInfo.getResult(), gameInfo.getPlayers(), gameInfo.getTableId())); } if (!pair.getMatch().hasEnded()) { int numberSavedGames = pair.getMatch().getGamesInfo().size(); if (pair.getMatch() != null) { int gameCount = 0; - for (Game game: pair.getMatch().getGames()) { + for (Game game : pair.getMatch().getGames()) { gameCount++; if (gameCount > numberSavedGames) { // only unfinished game info directly from game diff --git a/Mage/src/main/java/mage/ConditionalMana.java b/Mage/src/main/java/mage/ConditionalMana.java index 3dcfec39f6..825ec5d541 100644 --- a/Mage/src/main/java/mage/ConditionalMana.java +++ b/Mage/src/main/java/mage/ConditionalMana.java @@ -104,13 +104,13 @@ public class ConditionalMana extends Mana implements Serializable { if (!applied) { // if one condition fails, return false only if All conditions should be met // otherwise it may happen that Any other condition will be ok - if (scope.equals(Filter.ComparisonScope.All)) { + if (scope == Filter.ComparisonScope.All) { return false; } } else { // if one condition succeeded, return true only if Any conditions should be met // otherwise it may happen that any other condition will fail - if (scope.equals(Filter.ComparisonScope.Any)) { + if (scope == Filter.ComparisonScope.Any) { return true; } } @@ -118,7 +118,7 @@ public class ConditionalMana extends Mana implements Serializable { // we are here // if All conditions should be met, then it's Ok (return true) // if Any, then it should have already returned true, so returning false here - return scope.equals(Filter.ComparisonScope.All); + return scope == Filter.ComparisonScope.All; } @Override diff --git a/Mage/src/main/java/mage/abilities/abilityword/KinshipAbility.java b/Mage/src/main/java/mage/abilities/abilityword/KinshipAbility.java index 6670a61c99..ccf9cffce7 100644 --- a/Mage/src/main/java/mage/abilities/abilityword/KinshipAbility.java +++ b/Mage/src/main/java/mage/abilities/abilityword/KinshipAbility.java @@ -131,7 +131,7 @@ class KinshipBaseEffect extends OneShotEffect { controller.revealCards(sourcePermanent.getName(), cards, game); for (Effect effect: kinshipEffects) { effect.setTargetPointer(new FixedTarget(card.getId())); - if (effect.getEffectType().equals(EffectType.ONESHOT)) { + if (effect.getEffectType() == EffectType.ONESHOT) { effect.apply(game, source); } else { if (effect instanceof ContinuousEffect) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/AfterBlockersAreDeclaredCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AfterBlockersAreDeclaredCondition.java index 84086f7a4a..46118efa63 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AfterBlockersAreDeclaredCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AfterBlockersAreDeclaredCondition.java @@ -26,8 +26,9 @@ public class AfterBlockersAreDeclaredCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - return !(game.getStep().getType().equals(PhaseStep.BEGIN_COMBAT) - || game.getStep().getType().equals(PhaseStep.DECLARE_ATTACKERS)); + + return !(game.getStep().getType() == PhaseStep.BEGIN_COMBAT + || game.getStep().getType() == PhaseStep.DECLARE_ATTACKERS); } @Override diff --git a/Mage/src/main/java/mage/abilities/condition/common/IsPhaseCondition.java b/Mage/src/main/java/mage/abilities/condition/common/IsPhaseCondition.java index 7c133182f7..93fb6632dd 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/IsPhaseCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/IsPhaseCondition.java @@ -34,20 +34,19 @@ import mage.constants.TurnPhase; import mage.game.Game; /** - * * @author LevelX2 */ public class IsPhaseCondition implements Condition { protected TurnPhase turnPhase; - public IsPhaseCondition(TurnPhase turnPhase) { + public IsPhaseCondition(TurnPhase turnPhase) { this.turnPhase = turnPhase; } @Override public boolean apply(Game game, Ability source) { - return turnPhase.equals(game.getTurn().getPhaseType()); + return turnPhase == game.getTurn().getPhaseType(); } @Override diff --git a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java index 93244ebb33..be0984f282 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java @@ -53,7 +53,7 @@ public class ManaWasSpentCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - if (source.getAbilityType().equals(AbilityType.SPELL)) { + if (source.getAbilityType() == AbilityType.SPELL) { return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0); } ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get("ManaSpentToCast", source.getSourceId()); diff --git a/Mage/src/main/java/mage/abilities/condition/common/MyTurnBeforeAttackersDeclaredCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MyTurnBeforeAttackersDeclaredCondition.java index 8b531ad885..cb5d6b37f8 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MyTurnBeforeAttackersDeclaredCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MyTurnBeforeAttackersDeclaredCondition.java @@ -48,10 +48,10 @@ public class MyTurnBeforeAttackersDeclaredCondition implements Condition { public boolean apply(Game game, Ability source) { if (game.getActivePlayerId().equals(source.getControllerId())) { TurnPhase turnPhase = game.getTurn().getPhase().getType(); - if (turnPhase.equals(TurnPhase.BEGINNING) || turnPhase.equals(TurnPhase.PRECOMBAT_MAIN)) { + if (turnPhase == TurnPhase.BEGINNING || turnPhase == TurnPhase.PRECOMBAT_MAIN) { return true; } - if (turnPhase.equals(TurnPhase.COMBAT)) { + if (turnPhase == TurnPhase.COMBAT) { return !game.getTurn().isDeclareAttackersStepStarted(); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/SourceTappedBeforeUntapStepCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SourceTappedBeforeUntapStepCondition.java index 0f64617d05..6a6f28bfe5 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SourceTappedBeforeUntapStepCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SourceTappedBeforeUntapStepCondition.java @@ -65,12 +65,12 @@ public class SourceTappedBeforeUntapStepCondition implements Condition { Permanent permanent = game.getBattlefield().getPermanent(permanentId); if (permanent != null) { - if (lastTurnNum != game.getTurnNum() && turnPhase.equals(TurnPhase.BEGINNING)) { + if (lastTurnNum != game.getTurnNum() && turnPhase == TurnPhase.BEGINNING) { lastTurnNum = game.getTurnNum(); permanentWasTappedBeforeUntapStep = permanent.isTapped(); } - if (step.getType().equals(PhaseStep.UNTAP)) { + if (step.getType() == PhaseStep.UNTAP) { return permanentWasTappedBeforeUntapStep; } else { return permanent.isTapped(); diff --git a/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java index 76d3d3a4b1..609b14dd82 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SurgedCondition.java @@ -54,7 +54,7 @@ public class SurgedCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - if (source.getAbilityType().equals(AbilityType.TRIGGERED)) { + if (source.getAbilityType() == AbilityType.TRIGGERED) { @SuppressWarnings("unchecked") ArrayList surgeActivations = (ArrayList) game.getState().getValue(SurgeAbility.SURGE_ACTIVATION_VALUE_KEY + source.getSourceId()); if (surgeActivations != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java index 666aa0a08b..7ce2f8b92a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DontUntapInControllersNextUntapStepSourceEffect.java @@ -59,7 +59,7 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR 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() == GameEvent.EventType.UNTAP_STEP && game.getActivePlayerId().equals(source.getControllerId())) { 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/continuous/AddCardTypeSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AddCardTypeSourceEffect.java index 0fa2451938..35ee7f03fd 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 @@ -63,7 +63,7 @@ public class AddCardTypeSourceEffect extends ContinuousEffectImpl { @Override public void init(Ability source, Game game) { super.init(source, game); - if (Duration.Custom.equals(this.duration) || this.duration.toString().startsWith("End")) { + if (this.duration == Duration.Custom || this.duration.toString().startsWith("End")) { affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()), game)); if (affectedObjectList.isEmpty()) { this.discard(); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java index 12675f6798..abf36d2d3a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesColorTargetEffect.java @@ -116,7 +116,7 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl { targetObject.getColor(game).setColor(setColor); } } - if (!objectFound && this.getDuration().equals(Duration.Custom)) { + if (!objectFound && this.getDuration() == Duration.Custom) { this.discard(); } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java index d946b6869f..5386d56ed5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java @@ -40,7 +40,6 @@ import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; /** - * * @author jeff */ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { @@ -86,11 +85,9 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { - if (!token.getSupertype().isEmpty()) { - for (String t : token.getSupertype()) { - if (!permanent.getSupertype().contains(t)) { - permanent.getSupertype().add(t); - } + for (String t : token.getSupertype()) { + if (!permanent.getSupertype().contains(t)) { + permanent.getSupertype().add(t); } } // card type @@ -100,13 +97,10 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { permanent.getCardType().clear(); break; } - if (!token.getCardType().isEmpty()) { - for (CardType t : token.getCardType()) { - if (!permanent.getCardType().contains(t)) { - permanent.getCardType().add(t); - } - } + for (CardType t : token.getCardType()) { + permanent.getCardType().add(t); } + // sub type switch (loseType) { case ALL: @@ -115,18 +109,17 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { permanent.getSubtype(game).retainAll(CardRepository.instance.getLandTypes()); break; } - if (!token.getSubtype(game).isEmpty()) { - for (String t : token.getSubtype(game)) { - if (!permanent.getSubtype(game).contains(t)) { - permanent.getSubtype(game).add(t); - } + for (String t : token.getSubtype(game)) { + if (!permanent.getSubtype(game).contains(t)) { + permanent.getSubtype(game).add(t); } } + } break; case ColorChangingEffects_5: if (sublayer == SubLayer.NA) { - if (loseType.equals(LoseType.ALL)) { + if (loseType == LoseType.ALL) { permanent.getColor(game).setBlack(false); permanent.getColor(game).setGreen(false); permanent.getColor(game).setBlue(false); @@ -148,11 +141,10 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { permanent.removeAllAbilities(source.getSourceId(), game); break; } - if (!token.getAbilities().isEmpty()) { - for (Ability ability : token.getAbilities()) { - permanent.addAbility(ability, source.getSourceId(), game); - } + for (Ability ability : token.getAbilities()) { + permanent.addAbility(ability, source.getSourceId(), game); } + } break; case PTChangingEffects_7: diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java index 09e4b0febf..af48b2b92c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetToughnessSourceEffect.java @@ -69,7 +69,7 @@ public class SetToughnessSourceEffect extends ContinuousEffectImpl { mageObject.getToughness().setValue(value); return true; } else { - if (Duration.Custom.equals(duration)) { + if (duration == Duration.Custom) { discard(); } } diff --git a/Mage/src/main/java/mage/abilities/keyword/EchoAbility.java b/Mage/src/main/java/mage/abilities/keyword/EchoAbility.java index 8b28bb0e00..a98f93567f 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EchoAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EchoAbility.java @@ -91,7 +91,7 @@ public class EchoAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { // reset the echo paid state back, if creature enteres the battlefield - if (event.getType().equals(GameEvent.EventType.ENTERS_THE_BATTLEFIELD) + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId())) { this.echoPaid = false; diff --git a/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java b/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java index da004d5b75..a273bd123f 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java @@ -236,7 +236,7 @@ public class SuspendAbility extends SpecialAction { @Override public boolean canActivate(UUID playerId, Game game) { - if (!game.getState().getZone(getSourceId()).equals(Zone.HAND)) { + if (game.getState().getZone(getSourceId()) != Zone.HAND) { // Supend can only be activated from hand return false; } diff --git a/Mage/src/main/java/mage/game/Table.java b/Mage/src/main/java/mage/game/Table.java index 44b04c1205..aa779be8fa 100644 --- a/Mage/src/main/java/mage/game/Table.java +++ b/Mage/src/main/java/mage/game/Table.java @@ -148,7 +148,7 @@ public class Table implements Serializable { * */ public void closeTable() { - if (!getState().equals(TableState.WAITING) && !getState().equals(TableState.READY_TO_START)) { + if (getState() != TableState.WAITING && getState() != TableState.READY_TO_START) { setState(TableState.FINISHED); // otherwise the table can be removed completely } this.validator = null;