This commit is contained in:
dragonfyre23 2020-01-26 15:42:03 -05:00
commit 4ab8f506fc
56 changed files with 381 additions and 419 deletions

View file

@ -1,18 +0,0 @@
server-name=localhost
port=17171
remote-server=mage-server
cards-resource-path=/home/loki/.wine/drive_c/Program Files/Wizards of the Coast/Magic Online/Graphics/Cards/
symbols-resource-path=/home/loki/.wine/drive_c/Program Files/Wizards of the Coast/Magic Online/Graphics/Chat/chat_graphic_typingicon_
resource-path=/home/loki/.wine/drive_c/Program Files/Wizards of the Coast/Magic Online/Graphics/Cards/Pics/
#cards-resource-path=resources/images/cards/
#symbols-resource-path=resources/images/symbols/
#resource-path=resources/images/
card-scaling-factor=0.4
card-scaling-factor-enlarged=0.5
hand-scaling-factor=1.3
# parameters for debugging and testing faster
default-deck-path=C:\\Users\\836D~1\\AppData\\Local\\Temp\\tempDeck1577fd51-f098-420e-8794-c22d2c0602d99142449166006085381.dck
# 0: Human,1: Computer - mad, 2: Computer - Draft Bot
default-other-player-index=1
default-computer-name=computer

View file

@ -0,0 +1,3 @@
Xmage load default logs settings from resources.
If you want to run app with different log configs then copy files from release/config folder and add it to command line.

View file

@ -1,14 +0,0 @@
#default levels
log4j.rootLogger=info, console, logfile
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.console.Threshold=info
#file log
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=mageserver.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n

View file

@ -1,3 +0,0 @@
grant {
permission java.security.AllPermission;
};

View file

@ -1,14 +0,0 @@
server-name=localhost
port=17171
remote-server=mage-server
cards-resource-path=resources/images/cards/
symbols-resource-path=resources/images/symbols/
resource-path=resources/images/
card-scaling-factor=0.4
card-scaling-factor-enlarged=0.5
hand-scaling-factor=1.3
# 0: Human,1: Computer - mad, 2: Computer - Draft Bot
default-other-player-index=1
default-computer-name=computer

View file

@ -1,5 +1,11 @@
#default levels
log4j.rootLogger=info, console, logfile
#SAMPLE CLIENT CONFIG (you must enable it by command line)
#default log level and active appenders (dest for logs)
log4j.rootLogger=info, console, logfileByIndex
#custom log level for java classes
#log4j.logger.com.j256.ormlite=warn
#log4j.logger.mage.player.ai=warn
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
@ -7,8 +13,24 @@ log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.console.Threshold=info
#file log
#file log - without rolling
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=mageserver.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfile.File=mageclient.log
#file log - rolling by index
log4j.appender.logfileByIndex=org.apache.log4j.RollingFileAppender
log4j.appender.logfileByIndex.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByIndex.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByIndex.File=mageclient.log
log4j.appender.logfileByIndex.MaxFileSize=10MB
log4j.appender.logfileByIndex.MaxBackupIndex=5
log4j.appender.logfileByIndex.append=true
#file log - rolling by dayly
log4j.appender.logfileByDayly=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfileByDayly.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByDayly.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByDayly.File=mageclient.log
log4j.appender.logfileByDayly.DatePattern='.'yyyy-MM-dd

View file

@ -0,0 +1,3 @@
It's a sample config files. If you want to use it then run app with that extra commands (add it in launcher settings or in run script):
-Dlog4j.configuration=file:./config/log4j.properties
-Djava.security.policy=./config/security.policy

View file

@ -17,7 +17,7 @@ Extact the client and the server to separate folders.
To play a game you can either connect to a server or start your own server. To
connect to a server you will need to know the server name or IP address and the port.
To start a server run the startServer.bat command. If you want to use a different
port or change the timeout setting then modify the config.properties file in the
port or change the timeout setting then modify the config.xml file in the
config folder.
To launch the client run the startClient.bat command. Click on the connect button on

View file

@ -1315,7 +1315,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (startPort > 0) {
instance.currentConnection.setPort(startPort);
} else {
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port));
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(ClientDefaultSettings.port));
}
PreferencesDialog.setProxyInformation(instance.currentConnection);
instance.currentConnection.setPassword(startPassword);

View file

@ -7,7 +7,7 @@ import mage.cards.TextPopup;
import mage.cards.action.ActionCallback;
import mage.client.MageFrame;
import mage.client.game.PlayAreaPanel;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.DefaultActionCallback;
import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
@ -68,7 +68,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
this.gameId = gameId;
this.card = card;
this.bigCard = bigCard;
small = new BufferedImage(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight(), BufferedImage.TYPE_INT_RGB);
small = new BufferedImage(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight(), BufferedImage.TYPE_INT_RGB);
backgroundName = getBackgroundName();
background = ImageHelper.getBackground(card, backgroundName);
@ -120,7 +120,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gSmall.setColor(Color.BLACK);
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()), 0, 0, this);
gSmall.drawImage(ImageHelper.scaleImage(image, ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight()), 0, 0, this);
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
gImage.drawString(card.getName() + "TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
@ -136,16 +136,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.dispose();
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.getNameFontSize()));
gSmall.drawString(card.getName() + "TEST2", Config.dimensions.getContentXOffset(), Config.dimensions.getNameYOffset());
gSmall.setFont(new Font("Arial", Font.PLAIN, ClientDefaultSettings.dimensions.getNameFontSize()));
gSmall.drawString(card.getName() + "TEST2", ClientDefaultSettings.dimensions.getContentXOffset(), ClientDefaultSettings.dimensions.getNameYOffset());
if (card.isCreature()) {
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), ClientDefaultSettings.dimensions.getPowBoxTextLeft(), ClientDefaultSettings.dimensions.getPowBoxTextTop());
} else if (card.isPlanesWalker()) {
gSmall.drawString(card.getLoyalty(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
gSmall.drawString(card.getLoyalty(), ClientDefaultSettings.dimensions.getPowBoxTextLeft(), ClientDefaultSettings.dimensions.getPowBoxTextTop());
}
if (!card.getCardTypes().isEmpty()) {
gSmall.drawString(cardType, Config.dimensions.getContentXOffset(), Config.dimensions.getTypeYOffset());
gSmall.drawString(cardType, ClientDefaultSettings.dimensions.getContentXOffset(), ClientDefaultSettings.dimensions.getTypeYOffset());
}
drawText();
@ -346,11 +346,11 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
tooltipPopup.hide();
}
PopupFactory factory = PopupFactory.getSharedInstance();
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + ClientDefaultSettings.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup.show();
//hack to get tooltipPopup to resize to fit text
tooltipPopup.hide();
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + ClientDefaultSettings.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup.show();
tooltipShowing = true;

View file

@ -11,7 +11,7 @@
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.view.*;
import org.apache.log4j.Logger;
@ -212,7 +212,7 @@
private Dimension getCardDimension() {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
return cardDimension;
}

View file

@ -11,7 +11,7 @@ package mage.client.cards;
import mage.cards.CardDimensions;
import mage.cards.MagePermanent;
import mage.cards.Sets;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.TransformedImageCache;
import mage.view.CounterView;
import mage.view.PermanentView;
@ -49,7 +49,7 @@ public class Permanent extends Card {
super(permanent, bigCard, dimensions, gameId);
this.setSize(this.getPreferredSize());
this.permanent = permanent;
tappedImage = new BufferedImage(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth(), BufferedImage.TYPE_INT_RGB);
tappedImage = new BufferedImage(ClientDefaultSettings.dimensions.getFrameHeight(), ClientDefaultSettings.dimensions.getFrameWidth(), BufferedImage.TYPE_INT_RGB);
}
public UUID getPermanentId() {
@ -173,10 +173,10 @@ public class Permanent extends Card {
g2.setColor(Color.BLACK);
}
if (permanent.isTapped()) {
g2.drawRect(0, 0, Config.dimensions.getFrameHeight() - 1, Config.dimensions.getFrameWidth() - 1);
g2.drawRect(0, 0, ClientDefaultSettings.dimensions.getFrameHeight() - 1, ClientDefaultSettings.dimensions.getFrameWidth() - 1);
}
else {
g2.drawRect(0, 0, Config.dimensions.getFrameWidth() - 1, Config.dimensions.getFrameHeight() - 1);
g2.drawRect(0, 0, ClientDefaultSettings.dimensions.getFrameWidth() - 1, ClientDefaultSettings.dimensions.getFrameHeight() - 1);
}
}
@ -206,10 +206,10 @@ public class Permanent extends Card {
@Override
public Dimension getPreferredSize() {
if (permanent != null && permanent.isTapped()) {
return new Dimension(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth());
return new Dimension(ClientDefaultSettings.dimensions.getFrameHeight(), ClientDefaultSettings.dimensions.getFrameWidth());
}
else {
return new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
return new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
}
@ -229,7 +229,7 @@ public class Permanent extends Card {
tooltipPopup.hide();
}
PopupFactory factory = PopupFactory.getSharedInstance();
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()? Config.dimensions.getFrameHeight() : Config.dimensions.getFrameWidth());
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()? ClientDefaultSettings.dimensions.getFrameHeight() : ClientDefaultSettings.dimensions.getFrameWidth());
int y = (int) this.getLocationOnScreen().getY() + 40;
tooltipPopup = factory.getPopup(this, tooltipText, x, y);
tooltipPopup.show();

View file

@ -1,7 +1,7 @@
package mage.client.components.ext.dlg;
import mage.client.components.ImageButton;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import org.jdesktop.swingx.JXPanel;
import javax.swing.*;
@ -71,7 +71,7 @@ public abstract class IDialogPanel extends JXPanel {
protected Dimension getCardDimension() {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
return cardDimension;
}

View file

@ -10,7 +10,7 @@ import mage.client.cards.BigCard;
import mage.client.components.HoverButton;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.ImageHelper;
import mage.client.util.NaturalOrderCardNumberComparator;
import mage.client.util.audio.AudioManager;
@ -405,7 +405,7 @@ public class MageBook extends JComponent {
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true, PreferencesDialog.getRenderMode(), true);
cardImg.setBounds(rectangle);
@ -442,7 +442,7 @@ public class MageBook extends JComponent {
private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null);
newToken.removeSummoningSickness();

View file

@ -7,7 +7,7 @@ import mage.client.cards.ICardGrid;
import mage.client.deckeditor.SortSetting;
import mage.client.plugins.impl.Plugins;
import mage.client.util.ClientEventType;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.client.util.gui.GuiDisplayUtil;
@ -249,8 +249,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(),
Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(),
ClientDefaultSettings.dimensions.getFrameHeight());
}
cards.put(card.getId(), card);

View file

@ -6,7 +6,7 @@ import mage.choices.ChoiceImpl;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.preference.MagePreferences;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.gui.countryBox.CountryItemEditor;
import mage.client.util.sets.ConstructedFormats;
import mage.remote.Connection;
@ -59,9 +59,9 @@ public class ConnectDialog extends MageDialog {
}
public void showDialog() {
String serverAddress = MagePreferences.getServerAddressWithDefault(Config.serverName);
String serverAddress = MagePreferences.getServerAddressWithDefault(ClientDefaultSettings.serverName);
this.txtServer.setText(serverAddress);
this.txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(Config.port)));
this.txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(ClientDefaultSettings.port)));
this.txtUserName.setText(MagePreferences.getUserName(serverAddress));
this.txtPassword.setText(MagePreferences.getPassword(serverAddress));
this.chkAutoConnect.setSelected(Boolean.parseBoolean(MageFrame.getPreferences().get(KEY_CONNECT_AUTO_CONNECT, "false")));
@ -512,9 +512,9 @@ public class ConnectDialog extends MageDialog {
return;
}
// txtPassword is not checked here, because authentication might be disabled by the server config.
if (Integer.valueOf(txtPort.getText()) < 1 || Integer.valueOf(txtPort.getText()) > 65535) {
if (Integer.parseInt(txtPort.getText()) < 1 || Integer.parseInt(txtPort.getText()) > 65535) {
JOptionPane.showMessageDialog(rootPane, "Invalid port number");
txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(Config.port)));
txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(ClientDefaultSettings.port)));
return;
}
@ -522,7 +522,7 @@ public class ConnectDialog extends MageDialog {
try {
connection = new Connection();
connection.setHost(this.txtServer.getText().trim());
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
connection.setPort(Integer.parseInt(this.txtPort.getText().trim()));
connection.setUsername(this.txtUserName.getText().trim());
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected() || RepositoryUtil.isDatabaseEmpty());

View file

@ -11,7 +11,6 @@ import java.awt.event.InvocationEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
/**
* @author BetaSteward_at_googlemail.com, JayDi85
@ -215,7 +214,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
try {
this.setClosed(true);
} catch (PropertyVetoException ex) {
java.util.logging.Logger.getLogger(MageDialog.class.getName()).log(Level.SEVERE, "setClosed(false) failed", ex);
LOGGER.error("setClosed(false) failed", ex);
}
MageFrame.getDesktop().remove(this);
}

View file

@ -4,7 +4,7 @@ import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.components.KeyBindButton;
import mage.client.util.CardLanguage;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
@ -3475,8 +3475,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
private static void loadProxySettings(Preferences prefs) {
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase(Locale.ENGLISH)));
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, Config.serverName);
load(prefs, dialog.txtProxyPort, KEY_PROXY_PORT, Integer.toString(Config.port));
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, ClientDefaultSettings.serverName);
load(prefs, dialog.txtProxyPort, KEY_PROXY_PORT, Integer.toString(ClientDefaultSettings.port));
load(prefs, dialog.txtProxyUserName, KEY_PROXY_USERNAME, "");
load(prefs, dialog.rememberPswd, KEY_PROXY_REMEMBER, "true", "false");
if (dialog.rememberPswd.isSelected()) {

View file

@ -12,7 +12,7 @@
import mage.client.cards.Permanent;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.client.util.audio.AudioManager;
import mage.client.util.layout.CardLayoutStrategy;
@ -226,7 +226,7 @@
private void addPermanent(PermanentView permanent, final int count) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true, PreferencesDialog.getRenderMode(), true);

View file

@ -10,7 +10,7 @@ import mage.client.cards.Permanent;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.MagePlugins;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.interfaces.PluginException;
import mage.interfaces.plugin.CardPlugin;
import mage.interfaces.plugin.CounterPlugin;
@ -99,7 +99,7 @@ public enum Plugins implements MagePlugins {
mageActionCallback.setCardPreviewComponent(bigCard);
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode, needFullPermanentRender);
} else {
return new Permanent(card, bigCard, Config.dimensions, gameId);
return new Permanent(card, bigCard, ClientDefaultSettings.dimensions, gameId);
}
}
@ -112,7 +112,7 @@ public enum Plugins implements MagePlugins {
}
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode, needFullPermanentRender);
} else {
return new Card(card, bigCard, Config.dimensions, gameId);
return new Card(card, bigCard, ClientDefaultSettings.dimensions, gameId);
}
}

View file

@ -2,7 +2,7 @@ package mage.client.preference;
import com.google.common.collect.Sets;
import mage.client.MageFrame;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import java.util.Set;
import java.util.prefs.BackingStoreException;
@ -144,8 +144,8 @@ public final class MagePreferences {
}
public static void saveLastServer() {
lastServerAddress = getServerAddressWithDefault(Config.serverName);
lastServerPort = getServerPortWithDefault(Config.port);
lastServerAddress = getServerAddressWithDefault(ClientDefaultSettings.serverName);
lastServerPort = getServerPortWithDefault(ClientDefaultSettings.port);
lastServerUser = getUserName(lastServerAddress);
lastServerPassword = getPassword(lastServerAddress);
}

View file

@ -9,14 +9,12 @@ package mage.client.table;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import mage.cards.decks.DeckFileFilter;
import mage.client.MageFrame;
import mage.client.deck.generator.DeckGenerator;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
/**
*
@ -36,14 +34,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
fcSelectDeck.addChoosableFileFilter(new DeckFileFilter("dck", "XMage's deck files (*.dck)"));
String deckPath = MageFrame.getPreferences().get("defaultDeckPath", "");
if (deckPath.isEmpty()) {
if (Config.defaultDeckPath != null) {
deckPath = Config.defaultDeckPath;
}
deckPath = ClientDefaultSettings.deckPath;
}
this.txtPlayerDeck.setText(deckPath);
if (Config.defaultComputerName != null) {
this.txtPlayerName.setText(Config.defaultComputerName);
}
this.txtPlayerName.setText(ClientDefaultSettings.computerName);
}
public void setPlayerName(String playerName) {

View file

@ -10,7 +10,7 @@ package mage.client.table;
import mage.cards.decks.importer.DeckImporter;
import mage.client.SessionHandler;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.players.PlayerType;
@ -38,11 +38,11 @@ public class TablePlayerPanel extends javax.swing.JPanel {
public void init(int playerNum, PlayerType playerType) {
cbPlayerType.setModel(new DefaultComboBoxModel(SessionHandler.getPlayerTypes()));
this.lblPlayerNum.setText("Player " + playerNum);
if (Config.defaultOtherPlayerIndex != null) {
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
if (ClientDefaultSettings.otherPlayerIndex != null) {
Integer index = Integer.parseInt(ClientDefaultSettings.otherPlayerIndex);
if (index >= cbPlayerType.getItemCount()) {
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
} else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
cbPlayerType.setSelectedIndex(index);
}
}

View file

@ -10,7 +10,7 @@ package mage.client.unusedFiles;
//package mage.client.game;
import java.util.UUID;
import mage.client.cards.BigCard;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.view.CombatGroupView;
@ -61,9 +61,9 @@ public class CombatGroup extends javax.swing.JPanel {
attackers = new mage.client.cards.Cards();
lblDefender = new javax.swing.JLabel();
blockers.setPreferredSize(new java.awt.Dimension(Config.dimensions.getFrameWidth() + 8, Config.dimensions.getFrameHeight() + 25));
blockers.setPreferredSize(new java.awt.Dimension(ClientDefaultSettings.dimensions.getFrameWidth() + 8, ClientDefaultSettings.dimensions.getFrameHeight() + 25));
attackers.setPreferredSize(new java.awt.Dimension(Config.dimensions.getFrameWidth() + 8, Config.dimensions.getFrameHeight() + 25));
attackers.setPreferredSize(new java.awt.Dimension(ClientDefaultSettings.dimensions.getFrameWidth() + 8, ClientDefaultSettings.dimensions.getFrameHeight() + 25));
lblDefender.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblDefender.setText("Defender");

View file

@ -0,0 +1,35 @@
package mage.client.util;
import mage.cards.CardDimensions;
/**
* @author JayDi85
*/
public final class ClientDefaultSettings {
public static final String serverName;
public static final int port;
public static final double cardScalingFactor;
public static final double cardScalingFactorEnlarged;
public static final double handScalingFactor;
public static final CardDimensions dimensions;
public static final CardDimensions dimensionsEnlarged;
public static final String deckPath;
public static final String otherPlayerIndex;
public static final String computerName;
static {
// default values
serverName = "localhost";
port = 17171;
cardScalingFactor = 0.4;
cardScalingFactorEnlarged = 0.5;
handScalingFactor = 1.3;
deckPath = "";
otherPlayerIndex = "1"; // combobox default, example: 0: Human, 1: Computer - mad, 2: Computer - Draft Bot
computerName = "computer";
dimensions = new CardDimensions(cardScalingFactor);
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
}
}

View file

@ -1,73 +0,0 @@
package mage.client.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import mage.cards.CardDimensions;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public final class Config {
// TODO: Remove this class completely
private static final Logger logger = Logger.getLogger(Config.class);
public static final String remoteServer;
public static final String serverName;
public static final int port;
public static final double cardScalingFactor;
public static final double cardScalingFactorEnlarged;
public static final double handScalingFactor;
public static final CardDimensions dimensions;
public static final CardDimensions dimensionsEnlarged;
public static final String defaultGameType;
public static final String defaultDeckPath;
public static final String defaultOtherPlayerIndex;
public static final String defaultComputerName;
static {
Properties p = new Properties();
boolean fileFound = true;
try (FileInputStream fis = new FileInputStream(new File("config/config.properties"))) {
p.load(fis);
} catch (IOException ex) {
fileFound = false;
}
if (fileFound) {
serverName = p.getProperty("server-name");
port = Integer.parseInt(p.getProperty("port"));
remoteServer = p.getProperty("remote-server");
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
cardScalingFactorEnlarged = Double.valueOf(p.getProperty("card-scaling-factor-enlarged"));
handScalingFactor = Double.valueOf(p.getProperty("hand-scaling-factor"));
defaultGameType = p.getProperty("default-game-type", "Human");
defaultDeckPath = p.getProperty("default-deck-path");
defaultOtherPlayerIndex = p.getProperty("default-other-player-index");
defaultComputerName = p.getProperty("default-computer-name");
dimensions = new CardDimensions(cardScalingFactor);
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
} else { // Take some default valies for netbeans design view
serverName = "localhost";
port = 17171;
remoteServer = "mage-server";
cardScalingFactor = 0.4;
cardScalingFactorEnlarged = 0.5;
handScalingFactor = 1.3;
defaultGameType = p.getProperty("default-game-type", "Human");
defaultDeckPath = "";
defaultOtherPlayerIndex = "1";
defaultComputerName = "AI Computer";
dimensions = new CardDimensions(cardScalingFactor);
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
}
}
}

View file

@ -1,7 +0,0 @@
server-name=localhost
port=17171
remote-server=mage-server
cards-resource-path=resources/images/cards/
symbols-resource-path=resources/images/symbols/
resource-path=resources/images/
card-scaling-factor=0.4

View file

@ -7,7 +7,6 @@ import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
/**
* @author spjspj
@ -15,7 +14,7 @@ import java.util.logging.Level;
public enum GrabbagImageSource implements CardImageSource {
instance;
private static final Logger logger = Logger.getLogger(GrabbagImageSource.class);
private static final Logger LOGGER = Logger.getLogger(GrabbagImageSource.class);
private static final Set<String> supportedSets = new LinkedHashSet<String>() {
{
@ -454,7 +453,7 @@ public enum GrabbagImageSource implements CardImageSource {
try {
return generateCardUrl(card);
} catch (Exception ex) {
java.util.logging.Logger.getLogger(GrabbagImageSource.class.getName()).log(Level.SEVERE, null, ex);
LOGGER.error(ex.getMessage(), ex);
}
return null;
}

View file

@ -15,7 +15,6 @@ import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
import java.util.logging.Level;
/**
* @author Quercitron
@ -23,7 +22,7 @@ import java.util.logging.Level;
public enum TokensMtgImageSource implements CardImageSource {
instance;
private static final Logger logger = Logger.getLogger(TokensMtgImageSource.class);
private static final Logger LOGGER = Logger.getLogger(TokensMtgImageSource.class);
// [[EXP/Name, TokenData>
private HashMap<String, List<TokenData>> tokensData;
@ -99,14 +98,14 @@ public enum TokensMtgImageSource implements CardImageSource {
// We don't know these numbers, but we can take them from a file
// with tokens information that can be downloaded from the site.
if (tokensData.isEmpty()) {
logger.info("Source " + getSourceName() + " provides no token data.");
LOGGER.info("Source " + getSourceName() + " provides no token data.");
return null;
}
String key = set + "/" + name;
List<TokenData> list = tokensData.get(key);
if (list == null) {
logger.warn("Could not find data for token " + name + ", set " + set + ".");
LOGGER.warn("Could not find data for token " + name + ", set " + set + ".");
return null;
}
@ -115,7 +114,7 @@ public enum TokensMtgImageSource implements CardImageSource {
tokenData = list.get(0);
} else {
if (type > list.size()) {
logger.warn("Not enough images variants for token with type number " + type + ", name " + name + ", set " + set + '.');
LOGGER.warn("Not enough images variants for token with type number " + type + ", name " + name + ", set " + set + '.');
return null;
}
tokenData = list.get(card.getType() - 1);
@ -137,7 +136,7 @@ public enum TokensMtgImageSource implements CardImageSource {
try {
getTokensData();
} catch (IOException ex) {
logger.error(getSourceName() + ": Loading available data failed. " + ex.getMessage());
LOGGER.error(getSourceName() + ": Loading available data failed. " + ex.getMessage());
}
return tokensData.size();
}
@ -172,7 +171,7 @@ public enum TokensMtgImageSource implements CardImageSource {
try {
getTokensData();
} catch (IOException ex) {
java.util.logging.Logger.getLogger(TokensMtgImageSource.class.getName()).log(Level.SEVERE, null, ex);
LOGGER.error(ex.getMessage(), ex);
}
String key = setCode + "/" + searchName;
return (tokensData.containsKey(key));
@ -199,12 +198,12 @@ public enum TokensMtgImageSource implements CardImageSource {
list = new ArrayList<>();
tokensData.put(key, list);
supportedSets.add(tokenData.getExpansionSetCode());
logger.debug("Added key: " + key);
LOGGER.debug("Added key: " + key);
}
list.add(tokenData);
}
} catch (Exception exception) {
logger.warn("Failed to get tokens description from resource file tokens-mtg-onl-list.csv", exception);
LOGGER.warn("Failed to get tokens description from resource file tokens-mtg-onl-list.csv", exception);
}
String urlString = "http://tokens.mtg.onl/data/SetsWithTokens.csv";
@ -240,7 +239,7 @@ public enum TokensMtgImageSource implements CardImageSource {
DownloadPicturesService.getInstance().updateMessage("");
DownloadPicturesService.getInstance().showDownloadControls(true);
} catch (Exception ex) {
logger.warn("Failed to get tokens description from tokens.mtg.onl", ex);
LOGGER.warn("Failed to get tokens description from tokens.mtg.onl", ex);
DownloadPicturesService.getInstance().updateMessage(ex.getMessage());
}
}

View file

@ -1,17 +1,11 @@
#This configuration file is used for the client started from the IDE
#default levels
log4j.rootLogger=info, console, logfile
# Suppress SQL info messages
log4j.logger.com.j256.ormlite=warn
#default settings (uses for CLIENT run)
#log4j.logger.org.jboss.remoting=debug
#log4j.logger.org.jboss.logging=debug
#log4j.logger.mage.player.ai.ComputerPlayer6=debug
#log4j.logger.mage.client.remote.CallbackClientImpl=debug
#log4j.logger.mage.client.remote.CallbackClientImpl=debug
#log4j.logger.mage.client.game.FeedbackPanel=debug
#log4j.logger.mage.client.game.FeedbackPanel=warn
#log4j.logger.mage.client.util.audio=debug
#default log level and active appenders (dest for logs)
log4j.rootLogger=info, console, logfileByIndex
#custom log level for java classes
#log4j.logger.com.j256.ormlite=warn
#log4j.logger.mage.player.ai=warn
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
@ -19,8 +13,24 @@ log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.console.Threshold=info
#file log
#file log - without rolling
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=mageclient.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfile.File=mageclient.log
#file log - rolling by index
log4j.appender.logfileByIndex=org.apache.log4j.RollingFileAppender
log4j.appender.logfileByIndex.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByIndex.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByIndex.File=mageclient.log
log4j.appender.logfileByIndex.MaxFileSize=10MB
log4j.appender.logfileByIndex.MaxBackupIndex=5
log4j.appender.logfileByIndex.append=true
#file log - rolling by dayly
log4j.appender.logfileByDayly=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfileByDayly.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByDayly.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByDayly.File=mageclient.log
log4j.appender.logfileByDayly.DatePattern='.'yyyy-MM-dd

View file

@ -1,8 +0,0 @@
#default levels
log4j.rootLogger=debug, console
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.console.Threshold=debug

View file

@ -1,14 +1,20 @@
#default levels
#default settings (uses for ADMIN run)
#default log level and active appenders (dest for logs)
log4j.rootLogger=info, console, logfile
#custom log level for java classes
#log4j.logger.com.j256.ormlite=warn
#log4j.logger.mage.player.ai=warn
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.console.Threshold=DEBUG
log4j.appender.console.Threshold=debug
#file log
#file log - without rolling
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=mageadmin.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfile.File=mageadmin.log

View file

@ -0,0 +1,3 @@
Xmage load default logs settings from resources.
If you want to run app with different log configs then copy files from release/config folder and add it to command line.

View file

@ -1,45 +0,0 @@
#default levels
#log4j.rootLogger=info, console, logfile
log4j.rootLogger=info, RollingAppender
log4j.logger.com.j256.ormlite=warn
log4j.logger.mage.game=debug
log4j.logger.mage.game.GameImpl=debug
#log4j.logger.mage.players.PlayerImpl=debug
log4j.logger.mage.server=debug
#log4j.logger.mage.server.UserManager=debug
log4j.logger.mage.server.User=trace
#log4j.logger.mage.server.ChatSession=debug
#log4j.logger.mage.server.ChatManager=debug
#log4j.logger.mage.server.TableController=debug
#log4j.logger.mage.server.TableManager=debug
#log4j.logger.mage.server.tournament.TournamentManager=debug
#log4j.logger.mage.server.game.GameSession=debug
log4j.logger.mage.abilities.AbilityImpl=debug
log4j.logger.mage.cards.decks=debug
log4j.logger.mage.abilities.effects.common.continious.CommanderManaReplacementEffect=debug
#console log
#log4j.appender.console=org.apache.log4j.ConsoleAppender
#log4j.appender.console.layout=org.apache.log4j.PatternLayout
#log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%
#log4j.appender.console.Threshold=info
#file log
#log4j.appender.logfile=org.apache.log4j.FileAppender
#log4j.appender.logfile.File=mageserver.log
#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.logfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.RollingAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RollingAppender.File=mageserver.log
log4j.appender.RollingAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingAppender.layout.ConversionPattern=[%p] %d %c %M - %m%n
log4j.appender.RollingAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n
#diagnostic log for game core classes
#log4j.category.mage.server.game = INFO, diagfile
#log4j.additivity.mage.server.game = false
#log4j.appender.diagfile=org.apache.log4j.FileAppender
#log4j.appender.diagfile.File=magediag.log
#log4j.appender.diagfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.diagfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n

View file

@ -1,5 +0,0 @@
# Default global logging level.
.level=FINER
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level = ALL

View file

@ -1,3 +0,0 @@
grant {
permission java.security.AllPermission;
};

View file

@ -1,15 +1,46 @@
#default levels
#SAMPLE SERVER CONFIG (you must enable it by command line)
#default log level and active appenders (dest for logs)
log4j.rootLogger=info, console, logfile
log4j.logger.com.j256.ormlite=warn
log4j.logger.mage.player.ai=warn
#custom log level for java classes
#log4j.logger.com.j256.ormlite=warn
#log4j.logger.mage.player.ai=warn
#custom log file with diag info (only from special classes)
#log4j.category.mage.server.game = INFO, diagfile
#log4j.category.mage.server.tournament = INFO, diagfile
#log4j.additivity.mage.server.game = false
#log4j.additivity.mage.server.tournament = false
#log4j.appender.diagfile=org.apache.log4j.FileAppender
#log4j.appender.diagfile.File=magediag.log
#log4j.appender.diagfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.diagfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.console.Threshold=info
#file log
#file log - without rolling
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=mageserver.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfile.File=mageserver.log
#file log - rolling by index
log4j.appender.logfileByIndex=org.apache.log4j.RollingFileAppender
log4j.appender.logfileByIndex.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByIndex.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByIndex.File=mageserver.log
log4j.appender.logfileByIndex.MaxFileSize=10MB
log4j.appender.logfileByIndex.MaxBackupIndex=5
log4j.appender.logfileByIndex.append=true
#file log - rolling by dayly
log4j.appender.logfileByDayly=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfileByDayly.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByDayly.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByDayly.File=mageserver.log
log4j.appender.logfileByDayly.DatePattern='.'yyyy-MM-dd

View file

@ -1,5 +0,0 @@
# Default global logging level.
.level=FINE
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level = ALL

View file

@ -0,0 +1,3 @@
It's a sample config files. If you want to use it then run app with that extra commands (add it in launcher settings or in run script):
-Dlog4j.configuration=file:./config/log4j.properties
-Djava.security.policy=./config/security.policy

View file

@ -17,7 +17,7 @@ Extact the client and the server to separate folders.
To play a game you can either connect to a server or start your own server. To
connect to a server you will need to know the server name or IP address and the port.
To start a server run the startServer.bat command. If you want to use a different
port or change the timeout setting then modify the config.properties file in the
port or change the timeout setting then modify the config.xml file in the
config folder.
To launch the client run the startClient.bat command. Click on the connect button on

View file

@ -4,5 +4,5 @@ set JAVA_HOME="C:\Program Files\Java\jre7\"
set CLASSPATH=%JAVA_HOME%/bin;%CLASSPATH%
set PATH=%JAVA_HOME%/bin;%PATH%
:NOJAVADIR
java -Xms256m -Xmx512m -XX:MaxPermSize=384m -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar
java -Xms256m -Xmx512m -XX:MaxPermSize=384m -Djava.security.policy=./config/security.policy -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar
pause

View file

@ -2,4 +2,4 @@
cd "`dirname "$0"`"
java -Xms256M -Xmx512M -XX:MaxPermSize=256m -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar
java -Xms256M -Xmx512M -XX:MaxPermSize=256m -Djava.security.policy=./config/security.policy -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar

View file

@ -1,3 +1,3 @@
#!/bin/sh
java -Xms256M -Xmx512M -XX:MaxPermSize=256m -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar
java -Xms256M -Xmx512M -XX:MaxPermSize=256m -Djava.security.policy=./config/security.policy -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar

View file

@ -4,4 +4,4 @@ set JAVA_HOME="C:\Program Files (x86)\Java\jre7\"
set CLASSPATH=%JAVA_HOME%/bin;%CLASSPATH%
set PATH=%JAVA_HOME%/bin;%PATH%
:NOJAVADIR
java -Xms256M -Xmx512M -XX:MaxPermSize=384m -Djava.security.policy=./config/security.policy -Djava.util.logging.config.file=./config/logging.config -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar
java -Xms256M -Xmx512M -XX:MaxPermSize=384m -Djava.security.policy=./config/security.policy -Dlog4j.configuration=file:./config/log4j.properties -jar ./lib/mage-server-${project.version}.jar

View file

@ -1,56 +0,0 @@
package mage.server.util;
import java.io.IOException;
import java.util.Properties;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public final class Config {
private Config(){}
private static final Logger logger = Logger.getLogger(Config.class);
static {
Properties p = new Properties();
try {
p.load(Config.class.getResourceAsStream("resources/config.properties"));
} catch (IOException ex) {
logger.fatal("Config error", ex);
}
port = Integer.parseInt(p.getProperty("port"));
secondaryBindPort = Integer.parseInt(p.getProperty("secondaryBindPort"));
backlogSize = Integer.parseInt(p.getProperty("backlogSize"));
numAcceptThreads = Integer.parseInt(p.getProperty("numAcceptThreads"));
maxPoolSize = Integer.parseInt(p.getProperty("numPoolSize"));
leasePeriod = Integer.parseInt(p.getProperty("leasePeriod"));
remoteServer = p.getProperty("remote-server");
maxGameThreads = Integer.parseInt(p.getProperty("max-game-threads"));
maxSecondsIdle = Integer.parseInt(p.getProperty("max-seconds-idle"));
minUserNameLength = Integer.parseInt(p.getProperty("minUserNameLength"));
maxUserNameLength = Integer.parseInt(p.getProperty("maxUserNameLength"));
userNamePattern = p.getProperty("userNamePattern");
saveGameActivated = Boolean.parseBoolean(p.getProperty("saveGameActivated"));
}
public static final String remoteServer;
public static final int port;
public static final int secondaryBindPort;
public static final int backlogSize;
public static final int numAcceptThreads;
public static final int maxPoolSize;
public static final int leasePeriod;
public static final int maxGameThreads;
public static final int maxSecondsIdle;
public static final int minUserNameLength;
public static final int maxUserNameLength;
public static final String userNamePattern;
public static final boolean saveGameActivated;
}

View file

@ -1,29 +1,13 @@
#default levels
#default settings (uses for SERVER run)
#default log level and active appenders (dest for logs)
log4j.rootLogger=info, console, logfile
#custom log level for java classes
log4j.logger.com.j256.ormlite=warn
#log4j.logger.mage.player.ai=TRACE
log4j.logger.mage.player.ai=warn
#log4j.logger.mage.player.ai.ComputerPlayer6=debug
#log4j.logger.mage.player.ai.ComputerPlayer7=debug
#log4j.logger.mage.player.ai.GameStateEvaluator2=debug
#log4j.logger.mage.player.human=DEBUG, console, logfile
#log4j.additivity.mage.player.human=false
log4j.logger.mage.server=debug
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
#log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n
log4j.appender.console.Threshold=DEBUG
#file log
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=mageserver.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M%n
#diagnostic log for game core classes
#custom log file with diag info (only from special classes)
log4j.category.mage.server.game = INFO, diagfile
log4j.category.mage.server.tournament = INFO, diagfile
log4j.additivity.mage.server.game = false
@ -32,3 +16,31 @@ log4j.appender.diagfile=org.apache.log4j.FileAppender
log4j.appender.diagfile.File=magediag.log
log4j.appender.diagfile.layout=org.apache.log4j.PatternLayout
log4j.appender.diagfile.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.console.Threshold=debug
#file log - without rolling
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfile.File=mageserver.log
#file log - rolling by index
log4j.appender.logfileByIndex=org.apache.log4j.RollingFileAppender
log4j.appender.logfileByIndex.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByIndex.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByIndex.File=mageserver.log
log4j.appender.logfileByIndex.MaxFileSize=10MB
log4j.appender.logfileByIndex.MaxBackupIndex=5
log4j.appender.logfileByIndex.append=true
#file log - rolling by dayly
log4j.appender.logfileByDayly=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfileByDayly.layout=org.apache.log4j.PatternLayout
log4j.appender.logfileByDayly.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfileByDayly.File=mageserver.log
log4j.appender.logfileByDayly.DatePattern='.'yyyy-MM-dd

View file

@ -74,7 +74,8 @@ enum GadwickTheWizenedValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
GadwickTheWizenedWatcher watcher = game.getState().getWatcher(GadwickTheWizenedWatcher.class);
// watcher in card's scope
GadwickTheWizenedWatcher watcher = game.getState().getWatcher(GadwickTheWizenedWatcher.class, sourceAbility.getSourceId());
if (watcher == null) {
return 0;
}

View file

@ -49,7 +49,7 @@ class ThassasOracleEffect extends OneShotEffect {
ThassasOracleEffect() {
super(Outcome.Benefit);
staticText = "look at the top X cards of your library, where X is your devotion to blue. " +
"Put one of them on top of your library and the rest on the bottom of your library in a random order. " +
"Put up to one of them on top of your library and the rest on the bottom of your library in a random order. " +
"If X is greater than or equal to the number of cards in your library, you win the game";
}

View file

@ -14,7 +14,7 @@ import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
@ -77,7 +77,7 @@ class ViviensArkbowEffect extends OneShotEffect {
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost " + xValue + " or less");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
TargetCard target = new TargetCardInHand(0, 1, filter);
TargetCard target = new TargetCardInLibrary(0, 1, filter);
if (player.choose(outcome, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());

View file

@ -1,5 +0,0 @@
# Default global logging level.
.level=ALL
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level = ALL

View file

@ -19,8 +19,6 @@ import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Date;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Base for starting Mage server. Controls interactions between MageAPI and Mage

View file

@ -9,6 +9,12 @@ import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author JayDi85
*/
@ -93,6 +99,45 @@ public class EssenceOfTheWildCopyTest extends CardTestPlayerBase {
Assert.assertEquals("copy 2 must have 6 p/t", 6, copy2.getToughness().getValue());
}
@Test
@Ignore // TODO: enable and fix random failes with replace effects
public void test_CopyManyTokens() {
// https://github.com/magefree/mage/issues/6222
addCard(Zone.BATTLEFIELD, playerA, "Essence of the Wild", 1);
//
// Create X 1/1 white Soldier creature tokens with lifelink.
addCard(Zone.HAND, playerA, "March of the Multitudes", 1); // {X}{G}{W}{W}
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5 + 1);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
// create multiple tokens
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "March of the Multitudes");
setChoice(playerA, "X=5");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Soldier", 0);
assertPermanentCount(playerA, "Essence of the Wild", 1 + 5);
List<Permanent> list = new ArrayList<>();
list.add(findCopyPermanent(currentGame, 1));
list.add(findCopyPermanent(currentGame, 2));
list.add(findCopyPermanent(currentGame, 3));
list.add(findCopyPermanent(currentGame, 4));
list.add(findCopyPermanent(currentGame, 5));
Set<UUID> uniq = list.stream().map(Permanent::getId).collect(Collectors.toSet());
Assert.assertEquals("All tokens must be copied", list.size(), uniq.size());
list.stream().forEach(permanent -> {
Assert.assertEquals("copy must have 6 p/t", 6, permanent.getPower().getValue());
Assert.assertEquals("copy must have 6 p/t", 6, permanent.getToughness().getValue());
});
}
@Test
public void test_CopyCreatureWithContinuousEffect() {
// essence with -1/-1 must copy creature with normal p/t

View file

@ -0,0 +1,53 @@
package org.mage.test.serverside.performance;
import mage.abilities.keyword.InfectAbility;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.counters.CounterType;
import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentImpl;
import mage.remote.traffic.ZippedObjectImpl;
import mage.utils.CompressUtil;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class SerializationTest extends CardTestPlayerBase {
@Test
public void test_PermanentImpl_Simple() {
CardInfo cardInfo = CardRepository.instance.findCard("Balduvian Bears");
PermanentImpl permanent = new PermanentCard(cardInfo.getCard(), playerA.getId(), currentGame);
currentGame.addPermanent(permanent);
Object compressed = CompressUtil.compress(permanent);
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
PermanentImpl uncompressed = (PermanentImpl) CompressUtil.decompress(compressed);
Assert.assertEquals("Must be same", permanent.getName(), uncompressed.getName());
}
@Test
public void test_PermanentImpl_MarkedDamageInfo() {
CardInfo cardInfo = CardRepository.instance.findCard("Balduvian Bears");
PermanentImpl permanent = new PermanentCard(cardInfo.getCard(), playerA.getId(), currentGame);
currentGame.addPermanent(permanent);
// mark damage from infected ability
permanent.addAbility(InfectAbility.getInstance(), currentGame);
permanent.markDamage(1, permanent.getId(), currentGame, false, false);
// test compress (it uses default java serialization)
Object compressed = CompressUtil.compress(permanent);
Assert.assertTrue("Must be zip", compressed instanceof ZippedObjectImpl);
PermanentImpl uncompressed = (PermanentImpl) CompressUtil.decompress(compressed);
Assert.assertEquals("Must be same", permanent.getName(), uncompressed.getName());
// ensure that it was marked damage
permanent.applyDamage(currentGame);
Assert.assertEquals("Must get infected counter", 1, permanent.getCounters(currentGame).getCount(CounterType.M1M1));
}
}

View file

@ -1,25 +1,29 @@
#default levels
log4j.rootLogger=debug, console, file, watchdog
#default settings (uses for TESTS run)
#default log level and active appenders (dest for logs)
log4j.rootLogger=info, console, logfile, watchdog
log4j.logger.com.j256.ormlite=warn
#custom log level for java classes
#log4j.logger.com.j256.ormlite=warn
#log4j.logger.mage.player.ai=warn
#console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.console.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.console.Threshold=info
#log4j.appender.console.Threshold=debug
#file log - without rolling
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %-90m =>[%t] %C{1}.%M %n
log4j.appender.logfile.File=magetest.log
log4j.appender.logfile.Threshold=info
#file log
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.file=Mage.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.file.Threshold=INFO
#errors
#file log - errors only
log4j.appender.watchdog=org.apache.log4j.FileAppender
log4j.appender.watchdog.file=watchdog.log
log4j.appender.watchdog.layout=org.apache.log4j.PatternLayout
log4j.appender.watchdog.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.watchdog.Threshold=ERROR
log4j.appender.watchdog.file=magetestErrors.log
log4j.appender.watchdog.Threshold=error

View file

@ -1,7 +1,6 @@
package mage.abilities.effects.common;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import mage.MageObject;
import mage.abilities.Ability;
@ -25,8 +24,6 @@ import mage.target.targetpointer.FixedTarget;
*/
public class RollPlanarDieEffect extends OneShotEffect {
private static final Logger log = Logger.getLogger("Roll Planar Die");
protected List<Effect> chaosEffects = null;
protected List<Target> chaosTargets = null;

View file

@ -37,6 +37,7 @@ import mage.util.GameLog;
import mage.util.ThreadLocalStringBuilder;
import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
/**
@ -46,7 +47,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
private static final Logger logger = Logger.getLogger(PermanentImpl.class);
static class MarkedDamageInfo {
static class MarkedDamageInfo implements Serializable {
public MarkedDamageInfo(Counter counter, MageObject sourceObject) {
this.counter = counter;