Merge pull request #2946 from ingmargoudt/master

various rewrites
This commit is contained in:
ingmargoudt 2017-03-07 22:29:13 +01:00 committed by GitHub
commit 603984c8b0
33 changed files with 156 additions and 166 deletions

View file

@ -55,6 +55,7 @@ import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.countryBox.CountryUtil; import mage.client.util.gui.countryBox.CountryUtil;
import mage.client.util.stats.UpdateMemUsageTask; import mage.client.util.stats.UpdateMemUsageTask;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.constants.PlayerAction; import mage.constants.PlayerAction;
import mage.interfaces.MageClient; import mage.interfaces.MageClient;
import mage.interfaces.callback.CallbackClient; import mage.interfaces.callback.CallbackClient;
@ -426,7 +427,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} else { } else {
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(filename);
BufferedImage background = ImageIO.read(is); BufferedImage background = ImageIO.read(is);
backgroundPane = new ImagePanel(background, ImagePanel.SCALED); backgroundPane = new ImagePanel(background, ImagePanelStyle.SCALED);
} }
backgroundPane.setSize(1024, 768); backgroundPane.setSize(1024, 768);
desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER); desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER);

View file

@ -32,7 +32,6 @@ import javax.swing.BorderFactory;
import javax.swing.border.Border; import javax.swing.border.Border;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public final class Constants { public final class Constants {
@ -116,23 +115,13 @@ public final class Constants {
} }
public static SortBy getByString(String text) { public static SortBy getByString(String text) {
switch (text) { for (SortBy sortBy : values()) {
case "Card Type": if (sortBy.text.equals(text)) {
return CARD_TYPE; return sortBy;
case "Casting Cost": }
return CASTING_COST; }
case "Rarity":
return RARITY;
case "Color":
return COLOR;
case "Color Identity":
return COLOR_IDENTITY;
case "Name":
return NAME;
default:
return UNSORTED; return UNSORTED;
} }
}
} }

View file

@ -31,7 +31,6 @@ import mage.client.constants.Constants.SortBy;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public abstract class SortSetting { public abstract class SortSetting {

View file

@ -44,6 +44,7 @@ import mage.client.util.NaturalOrderCardNumberComparator;
import mage.client.util.audio.AudioManager; import mage.client.util.audio.AudioManager;
import mage.client.util.sets.ConstructedFormats; import mage.client.util.sets.ConstructedFormats;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.view.CardView; import mage.view.CardView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -89,12 +90,12 @@ public class MageBook extends JComponent {
setMinimumSize(new Dimension(conf.WIDTH, conf.HEIGHT)); setMinimumSize(new Dimension(conf.WIDTH, conf.HEIGHT));
//setBorder(BorderFactory.createLineBorder(Color.green)); //setBorder(BorderFactory.createLineBorder(Color.green));
jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanel.TILED); jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanelStyle.TILED);
jPanelLeft.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0)); jPanelLeft.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
jPanelLeft.setLayout(null); jPanelLeft.setLayout(null);
jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanel.SCALED); jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanelStyle.SCALED);
jPanelCenter.setLayout(new BorderLayout()); jPanelCenter.setLayout(new BorderLayout());
jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanel.TILED); jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanelStyle.TILED);
jPanelRight.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0)); jPanelRight.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
jPanelRight.setLayout(null); jPanelRight.setLayout(null);
@ -267,7 +268,7 @@ public class MageBook extends JComponent {
return cards.subList(start, end); return cards.subList(start, end);
} }
private ImagePanel getImagePanel(String filename, int type) { private ImagePanel getImagePanel(String filename, ImagePanelStyle type) {
try { try {
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(filename);

View file

@ -70,6 +70,7 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.BufferedImageBuilder;
import mage.client.util.gui.countryBox.CountryUtil; import mage.client.util.gui.countryBox.CountryUtil;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.constants.CardType; import mage.constants.CardType;
import static mage.constants.Constants.DEFAULT_AVATAR_ID; import static mage.constants.Constants.DEFAULT_AVATAR_ID;
import static mage.constants.Constants.MAX_AVATAR_ID; import static mage.constants.Constants.MAX_AVATAR_ID;
@ -417,7 +418,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
lifeLabel.setToolTipText("Life"); lifeLabel.setToolTipText("Life");
Image imageLife = ImageHelper.getImageFromResources("/info/life.png"); Image imageLife = ImageHelper.getImageFromResources("/info/life.png");
BufferedImage resizedLife = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLife, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resizedLife = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLife, BufferedImage.TYPE_INT_ARGB), r);
life = new ImagePanel(resizedLife, ImagePanel.ACTUAL); life = new ImagePanel(resizedLife, ImagePanelStyle.ACTUAL);
life.setToolTipText("Life"); life.setToolTipText("Life");
life.setOpaque(false); life.setOpaque(false);
// hand area // hand area
@ -425,7 +426,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
handLabel.setToolTipText("Hand"); handLabel.setToolTipText("Hand");
Image imageHand = ImageHelper.getImageFromResources("/info/hand.png"); Image imageHand = ImageHelper.getImageFromResources("/info/hand.png");
BufferedImage resizedHand = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageHand, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resizedHand = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageHand, BufferedImage.TYPE_INT_ARGB), r);
hand = new ImagePanel(resizedHand, ImagePanel.ACTUAL); hand = new ImagePanel(resizedHand, ImagePanelStyle.ACTUAL);
hand.setToolTipText("Hand"); hand.setToolTipText("Hand");
hand.setOpaque(false); hand.setOpaque(false);
@ -435,7 +436,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
poisonLabel.setToolTipText("Poison"); poisonLabel.setToolTipText("Poison");
Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png"); Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png");
BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r);
poison = new ImagePanel(resizedPoison, ImagePanel.ACTUAL); poison = new ImagePanel(resizedPoison, ImagePanelStyle.ACTUAL);
poison.setToolTipText("Poison"); poison.setToolTipText("Poison");
poison.setOpaque(false); poison.setOpaque(false);
@ -512,7 +513,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
energyLabel.setToolTipText("Energy"); energyLabel.setToolTipText("Energy");
Image imageEnergy = ImageHelper.getImageFromResources("/info/energy.png"); Image imageEnergy = ImageHelper.getImageFromResources("/info/energy.png");
BufferedImage resizedEnergy = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageEnergy, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resizedEnergy = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageEnergy, BufferedImage.TYPE_INT_ARGB), r);
energy = new ImagePanel(resizedEnergy, ImagePanel.ACTUAL); energy = new ImagePanel(resizedEnergy, ImagePanelStyle.ACTUAL);
energy.setToolTipText("Energy"); energy.setToolTipText("Energy");
energy.setOpaque(false); energy.setOpaque(false);
@ -522,7 +523,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
experienceLabel.setToolTipText("Experience"); experienceLabel.setToolTipText("Experience");
Image imageExperience = ImageHelper.getImageFromResources("/info/experience.png"); Image imageExperience = ImageHelper.getImageFromResources("/info/experience.png");
BufferedImage resizedExperience = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageExperience, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resizedExperience = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageExperience, BufferedImage.TYPE_INT_ARGB), r);
experience = new ImagePanel(resizedExperience, ImagePanel.ACTUAL); experience = new ImagePanel(resizedExperience, ImagePanelStyle.ACTUAL);
experience.setToolTipText("Experience"); experience.setToolTipText("Experience");
experience.setOpaque(false); experience.setOpaque(false);

View file

@ -7,6 +7,7 @@ import mage.client.dialog.PreferencesDialog;
import mage.client.util.ImageCaches; import mage.client.util.ImageCaches;
import mage.client.util.ImageHelper; import mage.client.util.ImageHelper;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.constants.AbilityType; import mage.constants.AbilityType;
import mage.utils.CardUtil; import mage.utils.CardUtil;
import mage.view.CardView; import mage.view.CardView;
@ -243,7 +244,7 @@ public class CardPanelComponentImpl extends CardPanel {
// Sickness overlay // Sickness overlay
BufferedImage sickness = ImageManagerImpl.getInstance().getSicknessImage(); BufferedImage sickness = ImageManagerImpl.getInstance().getSicknessImage();
overlayPanel = new ImagePanel(sickness, ImagePanel.SCALED); overlayPanel = new ImagePanel(sickness, ImagePanelStyle.SCALED);
overlayPanel.setOpaque(false); overlayPanel.setOpaque(false);
add(overlayPanel); add(overlayPanel);

View file

@ -8,6 +8,7 @@ import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.interfaces.plugin.ThemePlugin; import mage.interfaces.plugin.ThemePlugin;
import net.xeoh.plugins.base.annotations.PluginImplementation; import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.events.Init; import net.xeoh.plugins.base.annotations.events.Init;
@ -82,7 +83,7 @@ public class ThemePluginImpl implements ThemePlugin {
} }
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) { if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
ImagePanel bgPanel = new ImagePanel(backgroundImage, ImagePanel.TILED); ImagePanel bgPanel = new ImagePanel(backgroundImage, ImagePanelStyle.TILED);
unsetOpaque(ui.get("jSplitPane1")); unsetOpaque(ui.get("jSplitPane1"));
unsetOpaque(ui.get("pnlBattlefield")); unsetOpaque(ui.get("pnlBattlefield"));
@ -190,7 +191,7 @@ public class ThemePluginImpl implements ThemePlugin {
} }
} }
} }
return new ImagePanel(background, ImagePanel.SCALED); return new ImagePanel(background, ImagePanelStyle.SCALED);
} }
private void unsetOpaque(JComponent c) { private void unsetOpaque(JComponent c) {

View file

@ -31,7 +31,6 @@ package mage.cards;
import static mage.constants.Constants.*; import static mage.constants.Constants.*;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class CardDimensions { public class CardDimensions {

View file

@ -9,20 +9,18 @@ import javax.swing.JViewport;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ImagePanel extends JPanel { public class ImagePanel extends JPanel {
public static final int TILED = 0;
public static final int SCALED = 1;
public static final int ACTUAL = 2;
private BufferedImage image; private BufferedImage image;
private int style; private ImagePanelStyle style;
private float alignmentX = 0.5f; private float alignmentX = 0.5f;
private float alignmentY = 0.5f; private float alignmentY = 0.5f;
public ImagePanel(BufferedImage image) { public ImagePanel(BufferedImage image) {
this(image, TILED); this(image, ImagePanelStyle.TILED);
} }
public ImagePanel(BufferedImage image, int style) { public ImagePanel(BufferedImage image, ImagePanelStyle style) {
this.image = image; this.image = image;
this.style = style; this.style = style;
setLayout(new BorderLayout()); setLayout(new BorderLayout());
@ -68,12 +66,10 @@ public class ImagePanel extends JPanel {
case TILED: case TILED:
drawTiled(g); drawTiled(g);
break; break;
case SCALED: case SCALED:
Dimension d = getSize(); Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null); g.drawImage(image, 0, 0, d.width, d.height, null);
break; break;
case ACTUAL: case ACTUAL:
drawActual(g); drawActual(g);
break; break;

View file

@ -0,0 +1,8 @@
package mage.components;
/**
* Created by IGOUDT on 7-3-2017.
*/
public enum ImagePanelStyle {
TILED, SCALED, ACTUAL
}

View file

@ -76,10 +76,7 @@ public final class Constants {
*/ */
public static final int PRIORITY_TIME_SEC = 1200; public static final int PRIORITY_TIME_SEC = 1200;
public enum SessionState {
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_STARTING
}
public enum Option { public enum Option {

View file

@ -31,12 +31,13 @@ package mage.interfaces;
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 java.util.stream.Collectors;
import mage.utils.MageVersion; import mage.utils.MageVersion;
import mage.view.GameTypeView; import mage.view.GameTypeView;
import mage.view.TournamentTypeView; import mage.view.TournamentTypeView;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class ServerState implements Serializable { public class ServerState implements Serializable {
@ -71,13 +72,9 @@ public class ServerState implements Serializable {
} }
public List<GameTypeView> getTournamentGameTypes() { public List<GameTypeView> getTournamentGameTypes() {
List<GameTypeView> tournamentGameTypes = new ArrayList<>(); return gameTypes.stream()
for(GameTypeView gameTypeView: gameTypes) { .filter(gameTypeView -> gameTypeView.getMinPlayers() == 2 && gameTypeView.getMaxPlayers() == 2)
if (gameTypeView.getMinPlayers() == 2 && gameTypeView.getMaxPlayers() == 2) { .collect(Collectors.toList());
tournamentGameTypes.add(gameTypeView);
}
}
return tournamentGameTypes;
} }
public List<TournamentTypeView> getTournamentTypes() { public List<TournamentTypeView> getTournamentTypes() {

View file

@ -33,6 +33,7 @@ import java.net.*;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import mage.MageException; import mage.MageException;
import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException; import mage.cards.decks.InvalidDeckException;
@ -40,7 +41,6 @@ import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
import mage.cards.repository.ExpansionInfo; import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository; import mage.cards.repository.ExpansionRepository;
import mage.constants.Constants.SessionState;
import mage.constants.ManaType; import mage.constants.ManaType;
import mage.constants.PlayerAction; import mage.constants.PlayerAction;
import mage.game.GameException; import mage.game.GameException;
@ -63,11 +63,14 @@ import org.jboss.remoting.transport.socket.SocketWrapper;
import org.jboss.remoting.transporter.TransporterClient; import org.jboss.remoting.transporter.TransporterClient;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class SessionImpl implements Session { public class SessionImpl implements Session {
private enum SessionState {
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_STARTING
}
private static final Logger logger = Logger.getLogger(SessionImpl.class); private static final Logger logger = Logger.getLogger(SessionImpl.class);
private final MageClient client; private final MageClient client;
@ -468,7 +471,6 @@ public class SessionImpl implements Session {
} }
/** /**
*
* @param askForReconnect - true = connection was lost because of error and * @param askForReconnect - true = connection was lost because of error and
* ask the user if he want to try to reconnect * ask the user if he want to try to reconnect
*/ */
@ -965,7 +967,6 @@ public class SessionImpl implements Session {
} }
@Override @Override
public boolean joinGame(UUID gameId) { public boolean joinGame(UUID gameId) {
try { try {

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 {

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 {

View file

@ -30,6 +30,7 @@ package mage.cards.g;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -112,7 +113,7 @@ class GhostlyFlickerEffect extends OneShotEffect {
Set<Card> toBattlefield = new HashSet<>(); Set<Card> toBattlefield = new HashSet<>();
for (Card card : toExile) { for (Card card : toExile) {
Zone currentZone = game.getState().getZone(card.getId()); Zone currentZone = game.getState().getZone(card.getId());
if (!(Zone.BATTLEFIELD == currentZone) && Zone.isPublicZone(currentZone)) { if (Zone.BATTLEFIELD != currentZone && currentZone.isPublicZone()) {
toBattlefield.add(game.getCard(card.getId())); toBattlefield.add(game.getCard(card.getId()));
} }
} }

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,7 +34,6 @@ 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 {
@ -47,7 +46,7 @@ public class IsPhaseCondition implements Condition {
@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,13 +85,11 @@ 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
switch (loseType) { switch (loseType) {
case ALL: case ALL:
@ -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()) {
if (!permanent.getCardType().contains(t)) {
permanent.getCardType().add(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

@ -33,7 +33,13 @@ package mage.constants;
*/ */
public enum Zone { public enum Zone {
HAND, GRAVEYARD, LIBRARY, BATTLEFIELD, STACK, EXILED, ALL, OUTSIDE, COMMAND; HAND(false), GRAVEYARD(true), LIBRARY(false), BATTLEFIELD(true), STACK(true), EXILED(true), ALL(false), OUTSIDE(false), COMMAND(false);
private boolean isPublic;
Zone(boolean isPublic){
this.isPublic = isPublic;
}
public boolean match(Zone zone) { public boolean match(Zone zone) {
return (this == zone || this == ALL || zone == ALL); return (this == zone || this == ALL || zone == ALL);
@ -47,7 +53,7 @@ public enum Zone {
return super.toString(); return super.toString();
} }
public static boolean isPublicZone(Zone zone) { public boolean isPublicZone(){
return GRAVEYARD.equals(zone) || BATTLEFIELD.equals(zone) || STACK.equals(zone) || EXILED.equals(zone) || COMMAND.equals(zone); return isPublic;
} }
} }

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;