mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
commit
603984c8b0
33 changed files with 156 additions and 166 deletions
|
@ -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);
|
||||
|
|
|
@ -32,7 +32,6 @@ import javax.swing.BorderFactory;
|
|||
import javax.swing.border.Border;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public final class Constants {
|
||||
|
@ -116,22 +115,12 @@ 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:
|
||||
return UNSORTED;
|
||||
for (SortBy sortBy : values()) {
|
||||
if (sortBy.text.equals(text)) {
|
||||
return sortBy;
|
||||
}
|
||||
}
|
||||
return UNSORTED;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,16 +31,15 @@ import mage.client.constants.Constants.SortBy;
|
|||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public abstract class SortSetting {
|
||||
|
||||
|
||||
SortBy sortBy;
|
||||
int sortIndex;
|
||||
boolean ascending;
|
||||
boolean pilesToggle;
|
||||
|
||||
|
||||
final String prefSortBy;
|
||||
final String prefSortIndex;
|
||||
final String prefSortAscending;
|
||||
|
@ -60,7 +59,7 @@ public abstract class SortSetting {
|
|||
this.ascending = PreferencesDialog.getCachedValue(this.prefSortAscending, "1").equals("1");
|
||||
this.pilesToggle = PreferencesDialog.getCachedValue(this.prefPilesToggle, "true").equals("true");
|
||||
}
|
||||
|
||||
|
||||
public void setSortBy(SortBy sortBy) {
|
||||
this.sortBy = sortBy;
|
||||
PreferencesDialog.saveValue(prefSortBy, sortBy.toString());
|
||||
|
@ -73,12 +72,12 @@ public abstract class SortSetting {
|
|||
|
||||
public void setAscending(boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
PreferencesDialog.saveValue(this.prefSortAscending, this.ascending ? "1":"0");
|
||||
PreferencesDialog.saveValue(this.prefSortAscending, this.ascending ? "1" : "0");
|
||||
}
|
||||
|
||||
public void setPilesToggle(boolean pileToggle) {
|
||||
this.pilesToggle = pileToggle;
|
||||
PreferencesDialog.saveValue(this.prefSortAscending, this.pilesToggle ? "true":"false");
|
||||
PreferencesDialog.saveValue(this.prefSortAscending, this.pilesToggle ? "true" : "false");
|
||||
}
|
||||
|
||||
public SortBy getSortBy() {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -31,7 +31,6 @@ package mage.cards;
|
|||
import static mage.constants.Constants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardDimensions {
|
||||
|
@ -51,19 +50,19 @@ public class CardDimensions {
|
|||
public int nameFontSize;
|
||||
|
||||
public CardDimensions(double scaleFactor) {
|
||||
frameHeight = (int)(FRAME_MAX_HEIGHT * scaleFactor);
|
||||
frameWidth = (int)(FRAME_MAX_WIDTH * scaleFactor);
|
||||
symbolHeight = (int)(SYMBOL_MAX_HEIGHT * scaleFactor);
|
||||
symbolWidth = (int)(SYMBOL_MAX_WIDTH * scaleFactor);
|
||||
contentXOffset = (int)(CONTENT_MAX_XOFFSET * scaleFactor);
|
||||
nameYOffset = (int)(NAME_MAX_YOFFSET * scaleFactor);
|
||||
typeYOffset = (int)(TYPE_MAX_YOFFSET * scaleFactor);
|
||||
textYOffset = (int)(TEXT_MAX_YOFFSET * scaleFactor);
|
||||
textWidth = (int)(TEXT_MAX_WIDTH * scaleFactor);
|
||||
textHeight = (int)(TEXT_MAX_HEIGHT * scaleFactor);
|
||||
powBoxTextTop = (int)(POWBOX_TEXT_MAX_TOP * scaleFactor);
|
||||
powBoxTextLeft = (int)(POWBOX_TEXT_MAX_LEFT * scaleFactor);
|
||||
nameFontSize = Math.max(9, (int)(NAME_FONT_MAX_SIZE * scaleFactor));
|
||||
frameHeight = (int) (FRAME_MAX_HEIGHT * scaleFactor);
|
||||
frameWidth = (int) (FRAME_MAX_WIDTH * scaleFactor);
|
||||
symbolHeight = (int) (SYMBOL_MAX_HEIGHT * scaleFactor);
|
||||
symbolWidth = (int) (SYMBOL_MAX_WIDTH * scaleFactor);
|
||||
contentXOffset = (int) (CONTENT_MAX_XOFFSET * scaleFactor);
|
||||
nameYOffset = (int) (NAME_MAX_YOFFSET * scaleFactor);
|
||||
typeYOffset = (int) (TYPE_MAX_YOFFSET * scaleFactor);
|
||||
textYOffset = (int) (TEXT_MAX_YOFFSET * scaleFactor);
|
||||
textWidth = (int) (TEXT_MAX_WIDTH * scaleFactor);
|
||||
textHeight = (int) (TEXT_MAX_HEIGHT * scaleFactor);
|
||||
powBoxTextTop = (int) (POWBOX_TEXT_MAX_TOP * scaleFactor);
|
||||
powBoxTextLeft = (int) (POWBOX_TEXT_MAX_LEFT * scaleFactor);
|
||||
nameFontSize = Math.max(9, (int) (NAME_FONT_MAX_SIZE * scaleFactor));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
@ -65,18 +63,16 @@ public class ImagePanel extends JPanel {
|
|||
return;
|
||||
|
||||
switch (style) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
8
Mage.Common/src/mage/components/ImagePanelStyle.java
Normal file
8
Mage.Common/src/mage/components/ImagePanelStyle.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package mage.components;
|
||||
|
||||
/**
|
||||
* Created by IGOUDT on 7-3-2017.
|
||||
*/
|
||||
public enum ImagePanelStyle {
|
||||
TILED, SCALED, ACTUAL
|
||||
}
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
@ -52,8 +53,8 @@ public class ServerState implements Serializable {
|
|||
private final long expansionsContentVersion;
|
||||
|
||||
public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes,
|
||||
String[] playerTypes, String[] deckTypes, String[] draftCubes, boolean testMode,
|
||||
MageVersion version, long cardsContentVersion, long expansionsContentVersion) {
|
||||
String[] playerTypes, String[] deckTypes, String[] draftCubes, boolean testMode,
|
||||
MageVersion version, long cardsContentVersion, long expansionsContentVersion) {
|
||||
this.gameTypes = gameTypes;
|
||||
this.tournamentTypes = tournamentTypes;
|
||||
this.playerTypes = playerTypes;
|
||||
|
@ -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() {
|
||||
|
@ -111,5 +108,5 @@ public class ServerState implements Serializable {
|
|||
public long getExpansionsContentVersion() {
|
||||
return expansionsContentVersion;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -216,32 +219,32 @@ public class SessionImpl implements Session {
|
|||
public synchronized boolean connect(final Connection connection) {
|
||||
return establishJBossRemotingConnection(connection)
|
||||
&& handleRemotingTaskExceptions(new RemotingTask() {
|
||||
@Override
|
||||
public boolean run() throws Throwable {
|
||||
logger.info("Trying to log-in as " + getUserName() + " to XMAGE server at " + connection.getHost() + ':' + connection.getPort());
|
||||
boolean registerResult;
|
||||
if (connection.getAdminPassword() == null) {
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion(), connection.getUserIdStr());
|
||||
if (registerResult) {
|
||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString(), connection.getUserIdStr());
|
||||
}
|
||||
} else {
|
||||
registerResult = server.connectAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
|
||||
}
|
||||
if (registerResult) {
|
||||
serverState = server.getServerState();
|
||||
if (!connection.getUsername().equals("Admin")) {
|
||||
updateDatabase(connection.isForceDBComparison(), serverState);
|
||||
}
|
||||
logger.info("Logged-in as " + getUserName() + " to MAGE server at " + connection.getHost() + ':' + connection.getPort());
|
||||
client.connected(getUserName() + '@' + connection.getHost() + ':' + connection.getPort() + ' ');
|
||||
return true;
|
||||
}
|
||||
disconnect(false);
|
||||
return false;
|
||||
@Override
|
||||
public boolean run() throws Throwable {
|
||||
logger.info("Trying to log-in as " + getUserName() + " to XMAGE server at " + connection.getHost() + ':' + connection.getPort());
|
||||
boolean registerResult;
|
||||
if (connection.getAdminPassword() == null) {
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion(), connection.getUserIdStr());
|
||||
if (registerResult) {
|
||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString(), connection.getUserIdStr());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
registerResult = server.connectAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
|
||||
}
|
||||
if (registerResult) {
|
||||
serverState = server.getServerState();
|
||||
if (!connection.getUsername().equals("Admin")) {
|
||||
updateDatabase(connection.isForceDBComparison(), serverState);
|
||||
}
|
||||
logger.info("Logged-in as " + getUserName() + " to MAGE server at " + connection.getHost() + ':' + connection.getPort());
|
||||
client.connected(getUserName() + '@' + connection.getHost() + ':' + connection.getPort() + ' ');
|
||||
return true;
|
||||
}
|
||||
disconnect(false);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Optional<String> getServerHostname() {
|
||||
|
@ -468,9 +471,8 @@ 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
|
||||
* ask the user if he want to try to reconnect
|
||||
*/
|
||||
@Override
|
||||
public synchronized void disconnect(boolean askForReconnect) {
|
||||
|
@ -965,7 +967,6 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean joinGame(UUID gameId) {
|
||||
try {
|
||||
|
@ -1175,7 +1176,7 @@ public class SessionImpl implements Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Override
|
||||
// public boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId) {
|
||||
// try {
|
||||
// if (isConnected()) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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