mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
changed enum equals to ==, removed contains check for set
This commit is contained in:
parent
46ab7daf55
commit
1bc8e2248b
18 changed files with 42 additions and 50 deletions
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<Integer> surgeActivations = (ArrayList) game.getState().getValue(SurgeAbility.SURGE_ACTIVATION_VALUE_KEY + source.getSourceId());
|
||||
if (surgeActivations != null) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue