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

View file

@ -32,7 +32,6 @@ import javax.swing.BorderFactory;
import javax.swing.border.Border;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public final class Constants {
@ -116,23 +115,13 @@ public final class Constants {
}
public static SortBy getByString(String text) {
switch (text) {
case "Card Type":
return CARD_TYPE;
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:
for (SortBy sortBy : values()) {
if (sortBy.text.equals(text)) {
return sortBy;
}
}
return UNSORTED;
}
}
}

View file

@ -31,7 +31,6 @@ import mage.client.constants.Constants.SortBy;
import mage.client.dialog.PreferencesDialog;
/**
*
* @author LevelX2
*/
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.sets.ConstructedFormats;
import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.constants.Rarity;
import mage.view.CardView;
import org.apache.log4j.Logger;
@ -89,12 +90,12 @@ public class MageBook extends JComponent {
setMinimumSize(new Dimension(conf.WIDTH, conf.HEIGHT));
//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.setLayout(null);
jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanel.SCALED);
jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanelStyle.SCALED);
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.setLayout(null);
@ -267,7 +268,7 @@ public class MageBook extends JComponent {
return cards.subList(start, end);
}
private ImagePanel getImagePanel(String filename, int type) {
private ImagePanel getImagePanel(String filename, ImagePanelStyle type) {
try {
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.countryBox.CountryUtil;
import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.constants.CardType;
import static mage.constants.Constants.DEFAULT_AVATAR_ID;
import static mage.constants.Constants.MAX_AVATAR_ID;
@ -417,7 +418,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
lifeLabel.setToolTipText("Life");
Image imageLife = ImageHelper.getImageFromResources("/info/life.png");
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.setOpaque(false);
// hand area
@ -425,7 +426,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
handLabel.setToolTipText("Hand");
Image imageHand = ImageHelper.getImageFromResources("/info/hand.png");
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.setOpaque(false);
@ -435,7 +436,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
poisonLabel.setToolTipText("Poison");
Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png");
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.setOpaque(false);
@ -512,7 +513,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
energyLabel.setToolTipText("Energy");
Image imageEnergy = ImageHelper.getImageFromResources("/info/energy.png");
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.setOpaque(false);
@ -522,7 +523,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
experienceLabel.setToolTipText("Experience");
Image imageExperience = ImageHelper.getImageFromResources("/info/experience.png");
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.setOpaque(false);

View file

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

View file

@ -8,6 +8,7 @@ import javax.imageio.ImageIO;
import javax.swing.*;
import mage.client.dialog.PreferencesDialog;
import mage.components.ImagePanel;
import mage.components.ImagePanelStyle;
import mage.interfaces.plugin.ThemePlugin;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.events.Init;
@ -82,7 +83,7 @@ public class ThemePluginImpl implements ThemePlugin {
}
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("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) {

View file

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

View file

@ -9,20 +9,18 @@ import javax.swing.JViewport;
@SuppressWarnings("serial")
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 int style;
private ImagePanelStyle style;
private float alignmentX = 0.5f;
private float alignmentY = 0.5f;
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.style = style;
setLayout(new BorderLayout());
@ -68,12 +66,10 @@ public class ImagePanel extends JPanel {
case TILED:
drawTiled(g);
break;
case SCALED:
Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null);
break;
case ACTUAL:
drawActual(g);
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 enum SessionState {
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_STARTING
}
public enum Option {

View file

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

View file

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

View file

@ -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 {

View file

@ -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 {

View file

@ -30,6 +30,7 @@ package mage.cards.g;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -112,7 +113,7 @@ class GhostlyFlickerEffect extends OneShotEffect {
Set<Card> toBattlefield = new HashSet<>();
for (Card card : toExile) {
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()));
}
}

View file

@ -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

View file

@ -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) {

View file

@ -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

View file

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

View file

@ -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());

View file

@ -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();
}
}

View file

@ -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();

View file

@ -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) {

View file

@ -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();

View file

@ -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();

View file

@ -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;

View file

@ -40,7 +40,6 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
/**
*
* @author jeff
*/
public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
@ -86,13 +85,11 @@ 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);
}
}
}
// card type
switch (loseType) {
case ALL:
@ -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);
}
}
}
// 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);
}
}
}
}
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);
}
}
}
break;
case PTChangingEffects_7:

View file

@ -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();
}
}

View file

@ -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;

View file

@ -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;
}

View file

@ -33,7 +33,13 @@ package mage.constants;
*/
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) {
return (this == zone || this == ALL || zone == ALL);
@ -47,7 +53,7 @@ public enum Zone {
return super.toString();
}
public static boolean isPublicZone(Zone zone) {
return GRAVEYARD.equals(zone) || BATTLEFIELD.equals(zone) || STACK.equals(zone) || EXILED.equals(zone) || COMMAND.equals(zone);
public boolean isPublicZone(){
return isPublic;
}
}

View file

@ -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;