changed enum equals to ==, removed contains check for set

This commit is contained in:
ingmargoudt 2017-03-07 21:47:11 +01:00
parent 46ab7daf55
commit 1bc8e2248b
18 changed files with 42 additions and 50 deletions

View file

@ -29,12 +29,12 @@
package mage.view; package mage.view;
import java.io.Serializable; import java.io.Serializable;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.game.Game; import mage.game.Game;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class RevealedView implements Serializable { public class RevealedView implements Serializable {
@ -44,7 +44,7 @@ public class RevealedView implements Serializable {
public RevealedView(String name, Cards cards, Game game) { public RevealedView(String name, Cards cards, Game game) {
this.name = name; 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())); this.cards.put(card.getId(), new CardView(card, game, card.getId()));
} }
} }

View file

@ -31,13 +31,13 @@ package mage.view;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mage.game.Game; import mage.game.Game;
import mage.game.GameInfo; import mage.game.GameInfo;
import mage.game.tournament.Round; import mage.game.tournament.Round;
import mage.game.tournament.TournamentPairing; import mage.game.tournament.TournamentPairing;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class RoundView implements Serializable { public class RoundView implements Serializable {
@ -47,17 +47,17 @@ public class RoundView implements Serializable {
public RoundView(Round round) { public RoundView(Round round) {
try { try {
for (TournamentPairing pair: round.getPairs()) { for (TournamentPairing pair : round.getPairs()) {
// get info of finished games from match // get info of finished games from match
if (pair.getMatch() != null) { 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())); games.add(new TournamentGameView(round.getRoundNumber(), gameInfo.getMatchId(), gameInfo.getGameId(), gameInfo.getState(), gameInfo.getResult(), gameInfo.getPlayers(), gameInfo.getTableId()));
} }
if (!pair.getMatch().hasEnded()) { if (!pair.getMatch().hasEnded()) {
int numberSavedGames = pair.getMatch().getGamesInfo().size(); int numberSavedGames = pair.getMatch().getGamesInfo().size();
if (pair.getMatch() != null) { if (pair.getMatch() != null) {
int gameCount = 0; int gameCount = 0;
for (Game game: pair.getMatch().getGames()) { for (Game game : pair.getMatch().getGames()) {
gameCount++; gameCount++;
if (gameCount > numberSavedGames) { if (gameCount > numberSavedGames) {
// only unfinished game info directly from game // only unfinished game info directly from game

View file

@ -104,13 +104,13 @@ public class ConditionalMana extends Mana implements Serializable {
if (!applied) { if (!applied) {
// if one condition fails, return false only if All conditions should be met // if one condition fails, return false only if All conditions should be met
// otherwise it may happen that Any other condition will be ok // otherwise it may happen that Any other condition will be ok
if (scope.equals(Filter.ComparisonScope.All)) { if (scope == Filter.ComparisonScope.All) {
return false; return false;
} }
} else { } else {
// if one condition succeeded, return true only if Any conditions should be met // if one condition succeeded, return true only if Any conditions should be met
// otherwise it may happen that any other condition will fail // otherwise it may happen that any other condition will fail
if (scope.equals(Filter.ComparisonScope.Any)) { if (scope == Filter.ComparisonScope.Any) {
return true; return true;
} }
} }
@ -118,7 +118,7 @@ public class ConditionalMana extends Mana implements Serializable {
// we are here // we are here
// if All conditions should be met, then it's Ok (return true) // 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 // 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 @Override

View file

@ -131,7 +131,7 @@ class KinshipBaseEffect extends OneShotEffect {
controller.revealCards(sourcePermanent.getName(), cards, game); controller.revealCards(sourcePermanent.getName(), cards, game);
for (Effect effect: kinshipEffects) { for (Effect effect: kinshipEffects) {
effect.setTargetPointer(new FixedTarget(card.getId())); effect.setTargetPointer(new FixedTarget(card.getId()));
if (effect.getEffectType().equals(EffectType.ONESHOT)) { if (effect.getEffectType() == EffectType.ONESHOT) {
effect.apply(game, source); effect.apply(game, source);
} else { } else {
if (effect instanceof ContinuousEffect) { if (effect instanceof ContinuousEffect) {

View file

@ -26,8 +26,9 @@ public class AfterBlockersAreDeclaredCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { 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 @Override

View file

@ -34,20 +34,19 @@ import mage.constants.TurnPhase;
import mage.game.Game; import mage.game.Game;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class IsPhaseCondition implements Condition { public class IsPhaseCondition implements Condition {
protected TurnPhase turnPhase; protected TurnPhase turnPhase;
public IsPhaseCondition(TurnPhase turnPhase) { public IsPhaseCondition(TurnPhase turnPhase) {
this.turnPhase = turnPhase; this.turnPhase = turnPhase;
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return turnPhase.equals(game.getTurn().getPhaseType()); return turnPhase == game.getTurn().getPhaseType();
} }
@Override @Override

View file

@ -53,7 +53,7 @@ public class ManaWasSpentCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { 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); return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0);
} }
ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get("ManaSpentToCast", source.getSourceId()); ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get("ManaSpentToCast", source.getSourceId());

View file

@ -48,10 +48,10 @@ public class MyTurnBeforeAttackersDeclaredCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
if (game.getActivePlayerId().equals(source.getControllerId())) { if (game.getActivePlayerId().equals(source.getControllerId())) {
TurnPhase turnPhase = game.getTurn().getPhase().getType(); 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; return true;
} }
if (turnPhase.equals(TurnPhase.COMBAT)) { if (turnPhase == TurnPhase.COMBAT) {
return !game.getTurn().isDeclareAttackersStepStarted(); return !game.getTurn().isDeclareAttackersStepStarted();
} }
} }

View file

@ -65,12 +65,12 @@ public class SourceTappedBeforeUntapStepCondition implements Condition {
Permanent permanent = game.getBattlefield().getPermanent(permanentId); Permanent permanent = game.getBattlefield().getPermanent(permanentId);
if (permanent != null) { if (permanent != null) {
if (lastTurnNum != game.getTurnNum() && turnPhase.equals(TurnPhase.BEGINNING)) { if (lastTurnNum != game.getTurnNum() && turnPhase == TurnPhase.BEGINNING) {
lastTurnNum = game.getTurnNum(); lastTurnNum = game.getTurnNum();
permanentWasTappedBeforeUntapStep = permanent.isTapped(); permanentWasTappedBeforeUntapStep = permanent.isTapped();
} }
if (step.getType().equals(PhaseStep.UNTAP)) { if (step.getType() == PhaseStep.UNTAP) {
return permanentWasTappedBeforeUntapStep; return permanentWasTappedBeforeUntapStep;
} else { } else {
return permanent.isTapped(); return permanent.isTapped();

View file

@ -54,7 +54,7 @@ public class SurgedCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
if (source.getAbilityType().equals(AbilityType.TRIGGERED)) { if (source.getAbilityType() == AbilityType.TRIGGERED) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ArrayList<Integer> surgeActivations = (ArrayList) game.getState().getValue(SurgeAbility.SURGE_ACTIVATION_VALUE_KEY + source.getSourceId()); ArrayList<Integer> surgeActivations = (ArrayList) game.getState().getValue(SurgeAbility.SURGE_ACTIVATION_VALUE_KEY + source.getSourceId());
if (surgeActivations != null) { if (surgeActivations != null) {

View file

@ -59,7 +59,7 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR
return false; return false;
} }
// remember the turn of the untap step the effect has to be applied // 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())) { && 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 if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step
discard(); discard();

View file

@ -63,7 +63,7 @@ public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
@Override @Override
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, 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)); affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()), game));
if (affectedObjectList.isEmpty()) { if (affectedObjectList.isEmpty()) {
this.discard(); this.discard();

View file

@ -116,7 +116,7 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl {
targetObject.getColor(game).setColor(setColor); targetObject.getColor(game).setColor(setColor);
} }
} }
if (!objectFound && this.getDuration().equals(Duration.Custom)) { if (!objectFound && this.getDuration() == Duration.Custom) {
this.discard(); this.discard();
} }
return true; return true;

View file

@ -40,7 +40,6 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token; import mage.game.permanent.token.Token;
/** /**
*
* @author jeff * @author jeff
*/ */
public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
@ -86,11 +85,9 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) { if (sublayer == SubLayer.NA) {
if (!token.getSupertype().isEmpty()) { for (String t : token.getSupertype()) {
for (String t : token.getSupertype()) { if (!permanent.getSupertype().contains(t)) {
if (!permanent.getSupertype().contains(t)) { permanent.getSupertype().add(t);
permanent.getSupertype().add(t);
}
} }
} }
// card type // card type
@ -100,13 +97,10 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
permanent.getCardType().clear(); permanent.getCardType().clear();
break; break;
} }
if (!token.getCardType().isEmpty()) { for (CardType t : token.getCardType()) {
for (CardType t : token.getCardType()) { permanent.getCardType().add(t);
if (!permanent.getCardType().contains(t)) {
permanent.getCardType().add(t);
}
}
} }
// sub type // sub type
switch (loseType) { switch (loseType) {
case ALL: case ALL:
@ -115,18 +109,17 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
permanent.getSubtype(game).retainAll(CardRepository.instance.getLandTypes()); permanent.getSubtype(game).retainAll(CardRepository.instance.getLandTypes());
break; break;
} }
if (!token.getSubtype(game).isEmpty()) { for (String t : token.getSubtype(game)) {
for (String t : token.getSubtype(game)) { if (!permanent.getSubtype(game).contains(t)) {
if (!permanent.getSubtype(game).contains(t)) { permanent.getSubtype(game).add(t);
permanent.getSubtype(game).add(t);
}
} }
} }
} }
break; break;
case ColorChangingEffects_5: case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) { if (sublayer == SubLayer.NA) {
if (loseType.equals(LoseType.ALL)) { if (loseType == LoseType.ALL) {
permanent.getColor(game).setBlack(false); permanent.getColor(game).setBlack(false);
permanent.getColor(game).setGreen(false); permanent.getColor(game).setGreen(false);
permanent.getColor(game).setBlue(false); permanent.getColor(game).setBlue(false);
@ -148,11 +141,10 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
permanent.removeAllAbilities(source.getSourceId(), game); permanent.removeAllAbilities(source.getSourceId(), game);
break; break;
} }
if (!token.getAbilities().isEmpty()) { for (Ability ability : token.getAbilities()) {
for (Ability ability : token.getAbilities()) { permanent.addAbility(ability, source.getSourceId(), game);
permanent.addAbility(ability, source.getSourceId(), game);
}
} }
} }
break; break;
case PTChangingEffects_7: case PTChangingEffects_7:

View file

@ -69,7 +69,7 @@ public class SetToughnessSourceEffect extends ContinuousEffectImpl {
mageObject.getToughness().setValue(value); mageObject.getToughness().setValue(value);
return true; return true;
} else { } else {
if (Duration.Custom.equals(duration)) { if (duration == Duration.Custom) {
discard(); discard();
} }
} }

View file

@ -91,7 +91,7 @@ public class EchoAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
// reset the echo paid state back, if creature enteres the battlefield // 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())) { && event.getTargetId().equals(this.getSourceId())) {
this.echoPaid = false; this.echoPaid = false;

View file

@ -236,7 +236,7 @@ public class SuspendAbility extends SpecialAction {
@Override @Override
public boolean canActivate(UUID playerId, Game game) { 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 // Supend can only be activated from hand
return false; return false;
} }

View file

@ -148,7 +148,7 @@ public class Table implements Serializable {
* *
*/ */
public void closeTable() { 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 setState(TableState.FINISHED); // otherwise the table can be removed completely
} }
this.validator = null; this.validator = null;