Merge remote-tracking branch 'upstream/master' into CMH-GuiltyConscienceAndBackfire

This commit is contained in:
Clint Herron 2017-04-18 11:00:24 -04:00
commit d1c8796a49
7431 changed files with 56515 additions and 21681 deletions

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<groupId>org.mage</groupId>

File diff suppressed because one or more lines are too long

View file

@ -27,6 +27,21 @@
*/
package mage.client;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import mage.cards.decks.Deck;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
@ -77,25 +92,6 @@ import org.mage.plugins.card.images.DownloadPictures;
import org.mage.plugins.card.info.CardInfoPaneImpl;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -253,13 +249,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
updateMemUsageTask = new UpdateMemUsageTask(jMemUsageLabel);
try {
tablesPane = new TablesPane();
desktopPane.add(tablesPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
tablesPane.setMaximum(true);
} catch (PropertyVetoException ex) {
LOGGER.fatal(null, ex);
}
tablesPane = new TablesPane();
desktopPane.add(tablesPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
addTooltipContainer();
setBackground();
@ -279,6 +270,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
backgroundPane.setSize(width, height);
}
updateCurrentFrameSize();
ArrowBuilder.getBuilder().setSize(width, height);
if (title != null) {
@ -478,7 +471,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private void createAndShowSwitchPanelsMenu(final JComponent component, final AbstractButton windowButton) {
JPopupMenu menu = new JPopupMenu();
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
Component[] windows = desktopPane.getComponentsInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
MagePaneMenuItem menuItem;
for (int i = 0; i < windows.length; i++) {
@ -492,7 +485,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
MagePane frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
setActive(frame);
});
menuItem.setIcon(window.getFrameIcon());
//menuItem.setIcon(window.getFrameIcon());
menu.add(menuItem);
}
}
@ -543,23 +536,28 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
// showUserRequestDialog(message);
// }
public static void setActive(MagePane frame) {
// Nothing to do
if (activeFrame == frame) {
return;
}
// Deactivate current frame if there is one
if (activeFrame != null) {
activeFrame.deactivated();
}
// If null, no new frame to activate, return early
if (frame == null) {
activeFrame = null;
return;
}
LOGGER.debug("Setting " + frame.getTitle() + " active");
if (activeFrame != null) {
activeFrame.deactivated();
}
activeFrame = frame;
activeFrame.setVisible(true);
activeFrame.toFront();
try {
activeFrame.setSelected(true);
} catch (PropertyVetoException ex) {
LOGGER.error("Error setting " + frame.getTitle() + " active");
}
desktopPane.moveToFront(frame);
activeFrame.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
activeFrame.revalidate();
activeFrame.activated();
activeFrame.setVisible(true);
ArrowBuilder.getBuilder().hideAllPanels();
if (frame instanceof GamePane) {
ArrowBuilder.getBuilder().showPanel(((GamePane) frame).getGameId());
@ -569,23 +567,36 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
private void updateCurrentFrameSize() {
if (activeFrame != null) {
activeFrame.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
}
}
@Override
public void doLayout() {
super.doLayout();
updateCurrentFrameSize();
}
public static void deactivate(MagePane frame) {
frame.setVisible(false);
setActive(getTopMost(frame));
if (activeFrame != frame) {
frame.deactivated();
}
}
private static MagePane getTopMost(MagePane exclude) {
MagePane topmost = null;
int best = Integer.MAX_VALUE;
for (JInternalFrame frame : desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER)) {
for (Component frame : desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER)) {
if (frame.isVisible()) {
int z = desktopPane.getComponentZOrder(frame);
if (z < best) {
if (frame instanceof MagePane) {
// Exclude the tables pane if not connected, we never want to show it when not connected
if (frame instanceof MagePane && (SessionHandler.isConnected() || !(frame instanceof TablesPane))) {
best = z;
if (!frame.equals(exclude)) {
topmost = (MagePane) frame;
@ -604,64 +615,47 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
* @param playerId
*/
public void showGame(UUID gameId, UUID playerId) {
try {
GamePane gamePane = new GamePane();
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
gamePane.setMaximum(true);
gamePane.setVisible(true);
gamePane.showGame(gameId, playerId);
setActive(gamePane);
} catch (PropertyVetoException ex) {
}
GamePane gamePane = new GamePane();
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
gamePane.setVisible(true);
gamePane.showGame(gameId, playerId);
setActive(gamePane);
}
public void watchGame(UUID gameId) {
try {
for (Component component : desktopPane.getComponents()) {
if (component instanceof GamePane
&& ((GamePane) component).getGameId().equals(gameId)) {
setActive((GamePane) component);
return;
}
for (Component component : desktopPane.getComponents()) {
if (component instanceof GamePane
&& ((GamePane) component).getGameId().equals(gameId)) {
setActive((GamePane) component);
return;
}
GamePane gamePane = new GamePane();
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
gamePane.setMaximum(true);
gamePane.setVisible(true);
gamePane.watchGame(gameId);
setActive(gamePane);
} catch (PropertyVetoException ex) {
LOGGER.debug("Problem starting watching game " + gameId, ex);
}
GamePane gamePane = new GamePane();
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
gamePane.setVisible(true);
gamePane.watchGame(gameId);
setActive(gamePane);
}
public void replayGame(UUID gameId) {
try {
GamePane gamePane = new GamePane();
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
gamePane.setMaximum(true);
gamePane.setVisible(true);
gamePane.replayGame(gameId);
setActive(gamePane);
} catch (PropertyVetoException ex) {
}
GamePane gamePane = new GamePane();
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
gamePane.setVisible(true);
gamePane.replayGame(gameId);
setActive(gamePane);
}
public void showDraft(UUID draftId) {
try {
DraftPane draftPane = new DraftPane();
desktopPane.add(draftPane, JLayeredPane.DEFAULT_LAYER);
draftPane.setMaximum(true);
draftPane.setVisible(true);
draftPane.showDraft(draftId);
setActive(draftPane);
} catch (PropertyVetoException ex) {
}
DraftPane draftPane = new DraftPane();
desktopPane.add(draftPane, JLayeredPane.DEFAULT_LAYER);
draftPane.setVisible(true);
draftPane.showDraft(draftId);
setActive(draftPane);
}
public void endDraft(UUID draftId) {
// inform all open draft panes about
for (JInternalFrame window : desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER)) {
for (Component window : desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER)) {
if (window instanceof DraftPane) {
DraftPane draftPane = (DraftPane) window;
draftPane.removeDraft();
@ -670,22 +664,18 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
public void showTournament(UUID tournamentId) {
try {
for (Component component : desktopPane.getComponents()) {
if (component instanceof TournamentPane
&& ((TournamentPane) component).getTournamentId().equals(tournamentId)) {
setActive((TournamentPane) component);
return;
}
for (Component component : desktopPane.getComponents()) {
if (component instanceof TournamentPane
&& ((TournamentPane) component).getTournamentId().equals(tournamentId)) {
setActive((TournamentPane) component);
return;
}
TournamentPane tournamentPane = new TournamentPane();
desktopPane.add(tournamentPane, JLayeredPane.DEFAULT_LAYER);
tournamentPane.setMaximum(true);
tournamentPane.setVisible(true);
tournamentPane.showTournament(tournamentId);
setActive(tournamentPane);
} catch (PropertyVetoException ex) {
}
TournamentPane tournamentPane = new TournamentPane();
desktopPane.add(tournamentPane, JLayeredPane.DEFAULT_LAYER);
tournamentPane.setVisible(true);
tournamentPane.showTournament(tournamentId);
setActive(tournamentPane);
}
public void showGameEndDialog(GameEndView gameEndView) {
@ -748,7 +738,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
LOGGER.debug("connecting (auto): " + currentConnection.getProxyType().toString()
+ ' ' + currentConnection.getProxyHost() + ' ' + currentConnection.getProxyPort() + ' ' + currentConnection.getProxyUsername());
if (MageFrame.connect(currentConnection)) {
showGames(false);
prepareAndShowTablesPane();
return true;
} else {
showMessage("Unable to connect to server");
@ -1014,23 +1004,20 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
public void showGames(boolean setActive) {
public void prepareAndShowTablesPane() {
// Update the tables pane with the new session
this.tablesPane.showTables();
// Show the tables pane if there wasn't already an active pane
MagePane topPanebefore = getTopMost(tablesPane);
if (!tablesPane.isVisible()) {
this.tablesPane.setVisible(true);
this.tablesPane.showTables();
}
if (setActive) {
if (topPanebefore == null) {
setActive(tablesPane);
} else // if other panel was already shown, mamke sure it's topmost again
if (topPanebefore != null) {
setActive(topPanebefore);
}
}
}
public void hideGames() {
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
for (JInternalFrame window : windows) {
Component[] windows = desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
for (Component window : windows) {
if (window instanceof GamePane) {
GamePane gamePane = (GamePane) window;
gamePane.removeGame();
@ -1066,25 +1053,20 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
name = "Deck Editor";
}
// use already open editor
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
for (JInternalFrame window : windows) {
if (window instanceof DeckEditorPane && window.getTitle().equals(name)) {
Component[] windows = desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
for (Component window : windows) {
if (window instanceof DeckEditorPane && ((MagePane) window).getTitle().equals(name)) {
setActive((MagePane) window);
return;
}
}
}
try {
DeckEditorPane deckEditorPane = new DeckEditorPane();
desktopPane.add(deckEditorPane, JLayeredPane.DEFAULT_LAYER);
deckEditorPane.setMaximum(true);
deckEditorPane.setVisible(true);
deckEditorPane.show(mode, deck, name, tableId, time);
setActive(deckEditorPane);
} catch (PropertyVetoException ex) {
LOGGER.fatal(null, ex);
}
DeckEditorPane deckEditorPane = new DeckEditorPane();
desktopPane.add(deckEditorPane, JLayeredPane.DEFAULT_LAYER);
deckEditorPane.setVisible(false);
deckEditorPane.show(mode, deck, name, tableId, time);
setActive(deckEditorPane);
}
public void showUserRequestDialog(final UserRequestMessage userRequestMessage) {
@ -1109,22 +1091,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
public void showCollectionViewer() {
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
for (JInternalFrame window : windows) {
Component[] windows = desktopPane.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
for (Component window : windows) {
if (window instanceof CollectionViewerPane) {
setActive((MagePane) window);
return;
}
}
try {
CollectionViewerPane collectionViewerPane = new CollectionViewerPane();
desktopPane.add(collectionViewerPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
collectionViewerPane.setMaximum(true);
collectionViewerPane.setVisible(true);
setActive(collectionViewerPane);
} catch (PropertyVetoException ex) {
LOGGER.fatal(null, ex);
}
CollectionViewerPane collectionViewerPane = new CollectionViewerPane();
desktopPane.add(collectionViewerPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
collectionViewerPane.setVisible(true);
setActive(collectionViewerPane);
}
static void renderSplashFrame(Graphics2D g) {

View file

@ -36,37 +36,33 @@ package mage.client;
import java.awt.AWTEvent;
import java.awt.KeyboardFocusManager;
import java.beans.PropertyVetoException;
import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public abstract class MagePane extends javax.swing.JInternalFrame {
public abstract class MagePane extends javax.swing.JLayeredPane {
private String title = "no title set";
/**
* Creates new form MagePane
*/
public MagePane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
hideTitle();
}
private void hideTitle() {
if (ui instanceof BasicInternalFrameUI) {
((BasicInternalFrameUI) ui).setNorthPane(null);
}
}
public void changeGUISize() {
}
@Override
public void updateUI() {
super.updateUI();
hideTitle();
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void hideFrame() {
@ -75,11 +71,6 @@ public abstract class MagePane extends javax.swing.JInternalFrame {
public void removeFrame() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
try {
this.setClosed(true);
} catch (PropertyVetoException ex) {
}
MageFrame.deactivate(this);
MageFrame.getDesktop().remove(this);
}
@ -106,18 +97,6 @@ public abstract class MagePane extends javax.swing.JInternalFrame {
setBorder(null);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 765, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 476, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables

View file

@ -1,13 +1,12 @@
package mage.client;
import java.util.*;
import mage.cards.decks.DeckCardLists;
import mage.client.chat.LocalCommands;
import mage.constants.ManaType;
import mage.constants.PlayerAction;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.players.PlayerType;
import mage.players.net.UserData;
import mage.remote.Connection;
import mage.remote.MageRemoteException;
@ -15,6 +14,8 @@ import mage.remote.Session;
import mage.remote.SessionImpl;
import mage.view.*;
import java.util.*;
/**
* Created by IGOUDT on 15-9-2016.
*/
@ -91,11 +92,11 @@ public final class SessionHandler {
session.sendPlayerBoolean(gameId, b);
}
public static String[] getPlayerTypes() {
public static PlayerType[] getPlayerTypes() {
return session.getPlayerTypes();
}
public static boolean joinTournamentTable(UUID roomId, UUID tableId, String text, String selectedItem, Integer integer, DeckCardLists deckCardLists, String s) {
public static boolean joinTournamentTable(UUID roomId, UUID tableId, String text, PlayerType selectedItem, Integer integer, DeckCardLists deckCardLists, String s) {
return session.joinTournamentTable(roomId, tableId, text, selectedItem, integer, deckCardLists, s);
}
@ -233,7 +234,7 @@ public final class SessionHandler {
return session.createTable(roomId, options);
}
public static boolean joinTable(UUID roomId, UUID tableId, String playerName, String human, int skill, DeckCardLists deckCardLists, String text) {
public static boolean joinTable(UUID roomId, UUID tableId, String playerName, PlayerType human, int skill, DeckCardLists deckCardLists, String text) {
return session.joinTable(roomId, tableId, playerName, human, skill, deckCardLists, text);
}

View file

@ -33,52 +33,12 @@
*/
package mage.client.cards;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.text.BadLocationException;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
import mage.cards.CardDimensions;
import mage.cards.MagePermanent;
import mage.cards.Sets;
import mage.cards.TextPopup;
import mage.cards.action.ActionCallback;
import mage.client.MageFrame;
import static mage.client.constants.Constants.CONTENT_MAX_XOFFSET;
import static mage.client.constants.Constants.FRAME_MAX_HEIGHT;
import static mage.client.constants.Constants.FRAME_MAX_WIDTH;
import static mage.client.constants.Constants.NAME_FONT_MAX_SIZE;
import static mage.client.constants.Constants.NAME_MAX_YOFFSET;
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_LEFT;
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
import static mage.client.constants.Constants.SYMBOL_MAX_XOFFSET;
import static mage.client.constants.Constants.SYMBOL_MAX_YOFFSET;
import static mage.client.constants.Constants.TYPE_MAX_YOFFSET;
import mage.client.game.PlayAreaPanel;
import mage.client.util.Config;
import mage.client.util.DefaultActionCallback;
@ -86,13 +46,21 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.view.AbilityView;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import mage.view.StackAbilityView;
import mage.constants.SuperType;
import mage.view.*;
import org.apache.log4j.Logger;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static mage.client.constants.Constants.*;
/**
*
* @author BetaSteward_at_googlemail.com
@ -191,9 +159,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
gImage.drawString(card.getPower() + '/' + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
}
@ -205,9 +173,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.nameFontSize));
gSmall.drawString(card.getName()+"TEST2", Config.dimensions.contentXOffset, Config.dimensions.nameYOffset);
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
}
@ -239,9 +207,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
if (card.getColor().hasColor()) {
sb.append('\n').append(card.getColor().toString());
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
sb.append('\n').append(card.getPower()).append('/').append(card.getToughness());
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
sb.append('\n').append(card.getLoyalty());
}
for (String rule : getRules()) {
@ -262,9 +230,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
return "effect";
}
StringBuilder sb = new StringBuilder();
if (card.getCardTypes().contains(CardType.LAND)) {
if (card.isLand()) {
sb.append("land").append(card.getSuperTypes()).append(card.getSubTypes());
} else if (card.getCardTypes() != null && (card.getCardTypes().contains(CardType.CREATURE) || card.getCardTypes().contains(CardType.PLANESWALKER))) {
} else if (card.getCardTypes() != null && (card.isCreature() || card.isPlanesWalker())) {
sb.append("creature");
}
sb.append(card.getColor()).append(card.getRarity()).append(card.getExpansionSetCode());
@ -300,7 +268,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
protected String getType(CardView card) {
StringBuilder sbType = new StringBuilder();
for (String superType : card.getSuperTypes()) {
for (SuperType superType : card.getSuperTypes()) {
sbType.append(superType).append(' ');
}

View file

@ -1,6 +1,7 @@
package mage.client.cards;
import mage.cards.MageCard;
import mage.client.MagePane;
import mage.client.plugins.impl.Plugins;
import mage.view.CardView;
@ -24,9 +25,12 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
private DragCardTarget currentDragTarget;
private boolean isDragging;
// This should not be strictly needed, but for some reason I can't figure out getDeepestComponentAt and
// getComponentAt do not seem to work correctly for our setup if called on the root MageFrame.
private MagePane currentEventRootMagePane;
public CardDraggerGlassPane(DragCardSource source) {
this.source = source;
}
public void beginDrag(Component c, MouseEvent e) {
@ -46,6 +50,17 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
glassPane.setOpaque(false);
glassPane.setVisible(true);
// Get root mage pane to handle drag targeting in
Component rootMagePane = c;
while (rootMagePane != null && !(rootMagePane instanceof MagePane)) {
rootMagePane = rootMagePane.getParent();
}
if (rootMagePane == null) {
throw new RuntimeException("CardDraggerGlassPane::beginDrag not in a MagePane?");
} else {
currentEventRootMagePane = (MagePane)rootMagePane;
}
// Hook up events
c.addMouseListener(this);
c.addMouseMotionListener(this);
@ -72,19 +87,19 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
// Update the target
currentDragTarget = null;
updateCurrentTarget(SwingUtilities.convertMouseEvent(glassPane, e, currentRoot), false);
updateCurrentTarget(SwingUtilities.convertMouseEvent(glassPane, e, currentEventRootMagePane), false);
}
// e is relative to currentRoot
private void updateCurrentTarget(MouseEvent e, boolean isEnding) {
Component mouseOver = SwingUtilities.getDeepestComponentAt(currentRoot.getContentPane(), e.getX(), e.getY());
Component mouseOver = SwingUtilities.getDeepestComponentAt(currentEventRootMagePane, e.getX(), e.getY());
while (mouseOver != null) {
if (mouseOver instanceof DragCardTarget) {
DragCardTarget target = (DragCardTarget)mouseOver;
MouseEvent targetEvent = SwingUtilities.convertMouseEvent(currentRoot, e, mouseOver);
MouseEvent targetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, mouseOver);
if (target != currentDragTarget) {
if (currentDragTarget != null) {
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentRoot, e, (Component) currentDragTarget);
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, (Component) currentDragTarget);
currentDragTarget.dragCardExit(oldTargetEvent);
}
currentDragTarget = target;
@ -101,7 +116,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
mouseOver = mouseOver.getParent();
}
if (currentDragTarget != null) {
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentRoot, e, (Component)currentDragTarget);
MouseEvent oldTargetEvent = SwingUtilities.convertMouseEvent(currentEventRootMagePane, e, (Component)currentDragTarget);
currentDragTarget.dragCardExit(oldTargetEvent);
}
currentDragTarget = null;
@ -124,7 +139,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
dragComponent.removeMouseMotionListener(this);
// Convert the event into root coords
e = SwingUtilities.convertMouseEvent(dragComponent, e, currentRoot);
e = SwingUtilities.convertMouseEvent(dragComponent, e, currentEventRootMagePane);
// Remove the drag card
glassPane.remove(dragView);
@ -144,7 +159,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
dragView.setLocation(glassE.getX(), glassE.getY());
dragView.repaint();
// Convert the event into root coords and update target
e = SwingUtilities.convertMouseEvent(dragComponent, e, currentRoot);
e = SwingUtilities.convertMouseEvent(dragComponent, e, currentEventRootMagePane);
updateCurrentTarget(e, false);
}

View file

@ -33,26 +33,6 @@
*/
package mage.client.cards;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.Beans;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import mage.cards.MageCard;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.constants.Constants.SortBy;
@ -61,22 +41,26 @@ import mage.client.deckeditor.table.TableModel;
import mage.client.deckeditor.table.UpdateCountsCallback;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardViewCardTypeComparator;
import mage.client.util.CardViewColorComparator;
import mage.client.util.CardViewColorIdentityComparator;
import mage.client.util.CardViewCostComparator;
import mage.client.util.CardViewNameComparator;
import mage.client.util.CardViewRarityComparator;
import mage.client.util.*;
import mage.client.util.Event;
import mage.client.util.GUISizeHelper;
import mage.client.util.Listener;
import mage.client.util.gui.TableSpinnerEditor;
import mage.constants.CardType;
import mage.view.CardView;
import mage.view.CardsView;
import mage.view.SimpleCardView;
import org.mage.card.arcane.CardPanel;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.Beans;
import java.util.*;
import java.util.List;
/**
*
* @author BetaSteward_at_googlemail.com
@ -398,22 +382,22 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
int artifactCount = 0;
for (CardView card : cards.values()) {
if (card.getCardTypes().contains(CardType.LAND)) {
if (card.isLand()) {
landCount++;
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
creatureCount++;
}
if (card.getCardTypes().contains(CardType.SORCERY)) {
if (card.isSorcery()) {
sorceryCount++;
}
if (card.getCardTypes().contains(CardType.INSTANT)) {
if (card.isInstant()) {
instantCount++;
}
if (card.getCardTypes().contains(CardType.ENCHANTMENT)) {
if (card.isEnchantment()) {
enchantmentCount++;
}
if (card.getCardTypes().contains(CardType.ARTIFACT)) {
if (card.isArtifact()) {
artifactCount++;
}
}

View file

@ -1,53 +1,6 @@
package mage.client.cards;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import mage.cards.Card;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import mage.cards.MageCard;
import mage.cards.decks.DeckCardInfo;
import mage.cards.decks.DeckCardLayout;
@ -58,22 +11,28 @@ import mage.client.MageFrame;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardViewCardTypeComparator;
import mage.client.util.CardViewColorComparator;
import mage.client.util.CardViewColorIdentityComparator;
import mage.client.util.CardViewCostComparator;
import mage.client.util.CardViewNameComparator;
import mage.client.util.CardViewRarityComparator;
import mage.client.util.*;
import mage.client.util.Event;
import mage.client.util.GUISizeHelper;
import mage.client.util.Listener;
import mage.constants.CardType;
import mage.constants.SuperType;
import mage.util.RandomUtil;
import mage.view.CardView;
import mage.view.CardsView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardRenderer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Created by StravantUser on 2016-09-20.
*/
@ -511,50 +470,50 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
private final CardTypeCounter creatureCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.CREATURE);
return card.isCreature();
}
};
private final CardTypeCounter landCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.LAND);
return card.isLand();
}
};
private final CardTypeCounter artifactCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ARTIFACT);
return card.isArtifact();
}
};
private final CardTypeCounter enchantmentCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ENCHANTMENT);
return card.isEnchantment();
}
};
private final CardTypeCounter instantCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.INSTANT);
return card.isInstant();
}
};
private final CardTypeCounter sorceryCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.SORCERY);
return card.isSorcery();
}
};
private final CardTypeCounter planeswalkerCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.PLANESWALKER);
return card.isPlanesWalker();
}
};
private final CardTypeCounter tribalCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.TRIBAL);
return card.isTribal();
}
};
@ -1312,8 +1271,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// Sub & Super Types
if (!s) {
for (String str : card.getSuperTypes()) {
s |= str.toLowerCase().contains(searchStr);
for (SuperType str : card.getSuperTypes()) {
s |= str.toString().toLowerCase().contains(searchStr);
}
for (String str : card.getSubTypes()) {
s |= str.toLowerCase().contains(searchStr);
@ -1388,8 +1347,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
t += ' ' + type.toString();
}
// Sub & Super Types
for (String str : card.getSuperTypes()) {
t += ' ' + str.toLowerCase();
for (SuperType type : card.getSuperTypes()) {
t += ' ' + type.toString().toLowerCase();
}
for (String str : card.getSubTypes()) {
t += ' ' + str.toLowerCase();
@ -1523,7 +1482,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) {
for (CardView card : stack) {
if (card.getSuperTypes().contains("Basic")) {
if (card.getSuperTypes().contains(SuperType.BASIC)) {
continue;
}
@ -1896,7 +1855,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// What row to add it to?
ArrayList<ArrayList<CardView>> targetRow;
if (separateCreatures && !newCard.getCardTypes().contains(CardType.CREATURE)) {
if (separateCreatures && !newCard.isCreature()) {
// Ensure row 2 exists
if (cardGrid.size() < 2) {
cardGrid.add(1, new ArrayList<>());

View file

@ -34,28 +34,24 @@
package mage.client.cards;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import mage.cards.CardDimensions;
import mage.cards.MagePermanent;
import mage.cards.Sets;
import mage.client.util.Config;
import mage.client.util.TransformedImageCache;
import mage.view.CounterView;
import mage.view.PermanentView;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.PopupFactory;
import mage.cards.CardDimensions;
import mage.cards.MagePermanent;
import mage.cards.Sets;
import static mage.client.constants.Constants.DAMAGE_MAX_LEFT;
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
import mage.client.util.Config;
import mage.constants.CardType;
import mage.view.CounterView;
import mage.view.PermanentView;
import mage.client.util.TransformedImageCache;
/**
*
@ -113,10 +109,10 @@ public class Permanent extends Card {
if (permanent.getOriginal().getColor().hasColor()) {
sb.append('\n').append(permanent.getOriginal().getColor().toString());
}
if (permanent.getOriginal().getCardTypes().contains(CardType.CREATURE)) {
if (permanent.getOriginal().isCreature()) {
sb.append('\n').append(permanent.getOriginal().getPower()).append('/').append(permanent.getOriginal().getToughness());
}
else if (permanent.getOriginal().getCardTypes().contains(CardType.PLANESWALKER)) {
else if (permanent.getOriginal().isPlanesWalker()) {
sb.append('\n').append(permanent.getOriginal().getLoyalty());
}
for (String rule: getRules()) {

View file

@ -4,6 +4,7 @@ import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.util.IgnoreList;
import mage.interfaces.callback.ClientCallback;
import mage.interfaces.callback.ClientCallbackMethod;
import mage.view.ChatMessage;
import java.text.DateFormat;
@ -58,7 +59,7 @@ public final class LocalCommands {
private static void displayLocalCommandResponse(UUID chatId, String response) {
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
ClientCallback chatMessage = new ClientCallback("chatMessage", chatId,
ClientCallback chatMessage = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
new ChatMessage("", text, timeFormatter.format(new Date()), ChatMessage.MessageColor.BLUE));
MageFrame.getInstance().processCallback(chatMessage);
}

View file

@ -3,6 +3,7 @@ package mage.client.components;
import java.awt.Component;
import java.util.EnumMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.swing.JButton;
public class MageUI {
@ -92,9 +93,9 @@ public class MageUI {
public void doClick(MageComponents name, int waitBeforeClick) throws InterruptedException {
final JButton j = getButton(name);
Thread.sleep(waitBeforeClick);
TimeUnit.MILLISECONDS.sleep(waitBeforeClick);
while (!j.isEnabled()) {
Thread.sleep(10);
TimeUnit.MILLISECONDS.sleep(10);
}
Thread t = new Thread(() -> j.doClick());
t.start();

View file

@ -1,7 +1,7 @@
package mage.client.components.tray;
import java.awt.*;
import java.util.concurrent.TimeUnit;
import mage.client.MageFrame;
import org.apache.log4j.Logger;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
@ -21,7 +21,6 @@ public enum MageTray {
private int state = 0;
public void install() {
if (!SystemTray.isSupported()) {
log.warn("SystemTray is not supported");
@ -97,7 +96,7 @@ public enum MageTray {
int i = 0;
while (state != 3) {
trayIcon.setImage(i == 0 ? mainImage : flashedImage);
Thread.sleep(600);
TimeUnit.MILLISECONDS.sleep(600);
i = i == 0 ? 1 : 0;
}
trayIcon.setImage(mainImage);

View file

@ -53,7 +53,6 @@ public class DeckEditorPane extends MagePane {
* Creates new form TablesPane
*/
public DeckEditorPane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
boolean initialized = false;
if (Plugins.instance.isThemePluginLoaded()) {
Map<String, JComponent> uiMap = new HashMap<>();
@ -105,8 +104,8 @@ public class DeckEditorPane extends MagePane {
deckEditorPanel1 = new mage.client.deckeditor.DeckEditorPanel();
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(deckEditorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
@ -115,14 +114,12 @@ public class DeckEditorPane extends MagePane {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(deckEditorPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void initComponents(Component container) {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
@ -132,7 +129,7 @@ public class DeckEditorPane extends MagePane {
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
);
pack();
}
public DeckEditorPanel getPanel() {

View file

@ -44,7 +44,6 @@ import java.util.concurrent.TimeUnit;
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.filechooser.FileFilter;
import mage.cards.Card;
import mage.cards.Sets;
import mage.cards.decks.Deck;
@ -58,8 +57,8 @@ import mage.client.SessionHandler;
import mage.client.cards.BigCard;
import mage.client.cards.ICardGrid;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.deck.generator.DeckGenerator.DeckGeneratorException;
import mage.client.deck.generator.DeckGenerator;
import mage.client.deck.generator.DeckGenerator.DeckGeneratorException;
import mage.client.dialog.AddLandDialog;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
@ -189,7 +188,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
case LIMITED_BUILDING:
this.btnAddLand.setVisible(true);
this.txtTimeRemaining.setVisible(true);
// Fall through to sideboarding
// Fall through to sideboarding
case SIDEBOARDING:
this.btnSubmit.setVisible(true);
this.btnSubmitTimer.setVisible(true);
@ -711,84 +710,84 @@ public class DeckEditorPanel extends javax.swing.JPanel {
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lblDeckName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnSave)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnLoad)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNew)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnExit))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnImport)
.addContainerGap()
.addComponent(btnGenDeck)
.addContainerGap()
.addComponent(btnAddLand)
.addContainerGap()
.addComponent(btnSubmit)
.addContainerGap()
.addComponent(btnSubmitTimer))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(txtTimeRemaining))
)
.addContainerGap()));
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lblDeckName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnSave)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnLoad)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNew)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnExit))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnImport)
.addContainerGap()
.addComponent(btnGenDeck)
.addContainerGap()
.addComponent(btnAddLand)
.addContainerGap()
.addComponent(btnSubmit)
.addContainerGap()
.addComponent(btnSubmitTimer))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(txtTimeRemaining))
)
.addContainerGap()));
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDeckName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSave)
.addComponent(btnLoad)
.addComponent(btnNew)
.addComponent(btnExit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnImport)
.addComponent(btnGenDeck)
.addComponent(btnAddLand)
.addComponent(btnSubmit)
.addComponent(btnSubmitTimer))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTimeRemaining))
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDeckName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSave)
.addComponent(btnLoad)
.addComponent(btnNew)
.addComponent(btnExit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnImport)
.addComponent(btnGenDeck)
.addComponent(btnAddLand)
.addComponent(btnSubmit)
.addComponent(btnSubmitTimer))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTimeRemaining))
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
}
/**
@ -838,7 +837,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
});
}
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
//fcSelectDeck.setCurrentDirectory(new File());
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
@ -850,10 +848,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
File file = fcSelectDeck.getSelectedFile();
{
/**
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+
* In the case where the user selects the exact same file as was previously
* selected without touching anything else in the dialog, getSelectedFile()
* will erroneously return null due to some combination of our settings.
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+ In
* the case where the user selects the exact same file as was
* previously selected without touching anything else in the
* dialog, getSelectedFile() will erroneously return null due to
* some combination of our settings.
*
* We manually sub in the last selected file in this case.
*/
@ -893,10 +892,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
File file = fcSelectDeck.getSelectedFile();
{
/**
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+
* In the case where the user selects the exact same file as was previously
* selected without touching anything else in the dialog, getSelectedFile()
* will erroneously return null due to some combination of our settings.
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+ In
* the case where the user selects the exact same file as was
* previously selected without touching anything else in the
* dialog, getSelectedFile() will erroneously return null due to
* some combination of our settings.
*
* We manually sub in the last selected file in this case.
*/
@ -1123,7 +1123,7 @@ class UpdateDeckTask extends SwingWorker<Void, Void> {
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
SessionHandler.updateDeck(tableId, deck.getDeckCardLists());
Thread.sleep(5000);
TimeUnit.SECONDS.sleep(5);
}
return null;
}

View file

@ -66,8 +66,8 @@ public class CollectionViewerPane extends MagePane {
private void initComponents(Component container) {
Component component = container != null ? container : new CollectionViewerPanel();
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(component, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
@ -76,8 +76,6 @@ public class CollectionViewerPane extends MagePane {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(component, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
);
pack();
}
@Override

View file

@ -26,10 +26,11 @@
*/
package mage.client.deckeditor.table;
import java.util.Comparator;
import mage.cards.MageCard;
import mage.view.CardView;
import java.util.Comparator;
/**
* {@link MageCard} comparator. Used to sort cards in Deck Editor Table View
* pane.
@ -73,22 +74,22 @@ public class MageCardComparator implements Comparator<CardView> {
break;
// Color
case 3:
aCom = CardHelper.getColor(a);
bCom = CardHelper.getColor(b);
aCom = a.getColorText();
bCom = a.getColorText();
break;
// Type
case 4:
aCom = CardHelper.getType(a);
bCom = CardHelper.getType(b);
aCom = a.getTypeText();
bCom = b.getTypeText();
break;
// Stats, attack and defense
case 5:
aCom = (float) -1;
bCom = (float) -1;
if (CardHelper.isCreature(a)) {
if (a.isCreature()) {
aCom = new Float(a.getPower() + '.' + (a.getToughness().startsWith("-") ? "0" : a.getToughness()));
}
if (CardHelper.isCreature(b)) {
if (b.isCreature()) {
bCom = new Float(b.getPower() + '.' + (b.getToughness().startsWith("-") ? "0" : b.getToughness()));
}
break;

View file

@ -27,24 +27,6 @@
*/
package mage.client.deckeditor.table;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumnModel;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.cards.CardEventSource;
@ -55,7 +37,6 @@ import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.client.util.gui.GuiDisplayUtil;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.view.CardView;
import mage.view.CardsView;
@ -64,6 +45,16 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
/**
* Table Model for card list.
*
@ -133,22 +124,22 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
addCard(card, bigCard, gameId);
}
if (updateCountsCallback != null) {
if (card.getCardTypes().contains(CardType.LAND)) {
if (card.isLand()) {
landCount++;
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
creatureCount++;
}
if (card.getCardTypes().contains(CardType.INSTANT)) {
if (card.isInstant()) {
instantCount++;
}
if (card.getCardTypes().contains(CardType.SORCERY)) {
if (card.isSorcery()) {
sorceryCount++;
}
if (card.getCardTypes().contains(CardType.ENCHANTMENT)) {
if (card.isEnchantment()) {
enchantmentCount++;
}
if (card.getCardTypes().contains(CardType.ARTIFACT)) {
if (card.isArtifact()) {
artifactCount++;
}
}
@ -260,11 +251,11 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, ManaSymbols.Type.TABLE);
return "<html>" + castingCost + "</html>";
case 3:
return CardHelper.getColor(c);
return c.getColorText();
case 4:
return CardHelper.getType(c);
return c.getTypeText();
case 5:
return CardHelper.isCreature(c) ? c.getPower() + '/'
return c.isCreature() ? c.getPower() + '/'
+ c.getToughness() : "-";
case 6:
return c.getRarity().toString();

View file

@ -45,6 +45,7 @@ import java.io.InputStreamReader;
import java.io.Writer;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
@ -391,7 +392,12 @@ public class ConnectDialog extends MageDialog {
connection.setUsername(this.txtUserName.getText().trim());
connection.setPassword(this.txtPassword.getText().trim());
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected());
connection.setUserIdStr(System.getProperty("user.name") + ':' + MagePreferences.getUserNames());
String allMAC = "";
try {
allMAC = connection.getMAC();
} catch (SocketException ex) {
}
connection.setUserIdStr(System.getProperty("user.name") + ":" + System.getProperty("os.name") + ":" + MagePreferences.getUserNames() + ":" + allMAC);
MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor) cbFlag.getEditor()).getImageItem());
PreferencesDialog.setProxyInformation(connection);
@ -429,7 +435,7 @@ public class ConnectDialog extends MageDialog {
if (result) {
lblStatus.setText("");
connected();
MageFrame.getInstance().showGames(false);
MageFrame.getInstance().prepareAndShowTablesPane();
} else {
lblStatus.setText("Could not connect");
}

View file

@ -27,14 +27,16 @@
*/
package mage.client.dialog;
import java.util.UUID;
import javax.swing.JOptionPane;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.players.PlayerType;
import mage.remote.Session;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -143,9 +145,9 @@ public class JoinTableDialog extends MageDialog {
try {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
if (isTournament) {
joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
} else {
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
}
} catch (Exception ex) {

View file

@ -52,6 +52,10 @@
<Component id="lblPassword" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPassword" min="-2" pref="125" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnPreviousConfiguration1" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnPreviousConfiguration2" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="cbDeckType" min="-2" pref="332" max="-2" attributes="1"/>
@ -126,6 +130,8 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnPreviousConfiguration1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnPreviousConfiguration2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
@ -227,6 +233,10 @@
</Component>
<Component class="javax.swing.JTextField" name="txtPassword">
</Component>
<Component class="javax.swing.JButton" name="btnPreviousConfiguration1">
</Component>
<Component class="javax.swing.JButton" name="btnPreviousConfiguration2">
</Component>
<Component class="javax.swing.JLabel" name="lbDeckType">
<Properties>
<Property name="text" type="java.lang.String" value="Deck Type:"/>

View file

@ -27,14 +27,6 @@
*/
package mage.client.dialog;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import javax.swing.*;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
@ -48,12 +40,19 @@ import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence;
import mage.constants.SkillLevel;
import mage.game.match.MatchOptions;
import mage.players.PlayerType;
import mage.view.GameTypeView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class NewTableDialog extends MageDialog {
@ -65,7 +64,7 @@ public class NewTableDialog extends MageDialog {
private UUID roomId;
private String lastSessionId;
private final List<TablePlayerPanel> players = new ArrayList<>();
private final List<String> prefPlayerTypes = new ArrayList<>();
private final List<PlayerType> prefPlayerTypes = new ArrayList<>();
private static final String LIMITED = "Limited";
@ -124,6 +123,8 @@ public class NewTableDialog extends MageDialog {
pnlOtherPlayers = new javax.swing.JPanel();
jSeparator1 = new javax.swing.JSeparator();
btnOK = new javax.swing.JButton();
btnPreviousConfiguration1 = new javax.swing.JButton();
btnPreviousConfiguration2 = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
lblQuitRatio = new javax.swing.JLabel();
lblEdhPowerLevel = new javax.swing.JLabel();
@ -193,6 +194,13 @@ public class NewTableDialog extends MageDialog {
btnOK.setText("OK");
btnOK.addActionListener(evt -> btnOKActionPerformed(evt));
btnPreviousConfiguration1.setText("M1");
btnPreviousConfiguration1.setToolTipText("Load saved Match configuration #1");
btnPreviousConfiguration1.addActionListener(evt -> btnPreviousConfigurationActionPerformed(evt, 1));
btnPreviousConfiguration2.setText("M2");
btnPreviousConfiguration2.setToolTipText("Load saved Match configuration #2");
btnPreviousConfiguration2.addActionListener(evt -> btnPreviousConfigurationActionPerformed(evt, 2));
btnCancel.setText("Cancel");
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
@ -205,157 +213,163 @@ public class NewTableDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblName)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(chkRollbackTurnsAllowed)
.addGap(13, 13, 13)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPassword)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPreviousConfiguration1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPreviousConfiguration2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkRated)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblEdhPowerLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblRange)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblAttack)
.addGap(116, 116, 116)
.addComponent(lblSkillLevel))
.addGroup(layout.createSequentialGroup()
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumWins)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jSeparator2)
.addComponent(player1Panel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING))
.addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblName)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(chkRollbackTurnsAllowed)
.addGap(13, 13, 13)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPassword)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkRated)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblEdhPowerLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblRange)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblAttack)
.addGap(116, 116, 116)
.addComponent(lblSkillLevel))
.addGroup(layout.createSequentialGroup()
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumWins)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jSeparator2)
.addComponent(player1Panel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING))
.addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 660, Short.MAX_VALUE)
.addContainerGap()))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 660, Short.MAX_VALUE)
.addContainerGap()))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPassword)
.addComponent(lbTimeLimit)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType)
.addComponent(lblQuitRatio)
.addComponent(chkRated)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblEdhPowerLevel)
.addComponent(chkRated)
.addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans)
.addComponent(chkRollbackTurnsAllowed))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lblNumPlayers)
.addGap(0, 0, 0)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnPreviousConfiguration1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnPreviousConfiguration2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPassword)
.addComponent(lbTimeLimit)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType)
.addComponent(lblQuitRatio)
.addComponent(chkRated)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblEdhPowerLevel)
.addComponent(chkRated)
.addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans)
.addComponent(chkRollbackTurnsAllowed))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lblNumPlayers)
.addGap(0, 0, 0)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblSkillLevel)
.addComponent(lblNumWins)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblRange)
.addComponent(lblAttack)))
.addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addGap(0, 0, 0)
.addComponent(player1Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel)
.addComponent(btnOK))
.addGap(0, 0, 0))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblSkillLevel)
.addComponent(lblNumWins)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblRange)
.addComponent(lblAttack)))
.addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addGap(0, 0, 0)
.addComponent(player1Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel)
.addComponent(btnOK))
.addGap(0, 0, 0))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(201, 201, 201)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(167, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(201, 201, 201)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(167, Short.MAX_VALUE)))
);
pack();
@ -367,10 +381,15 @@ public class NewTableDialog extends MageDialog {
this.hideDialog();
}//GEN-LAST:event_btnCancelActionPerformed
private void btnPreviousConfigurationActionPerformed(java.awt.event.ActionEvent evt, int i) {//GEN-FIRST:event_btnPreviousConfigurationActionPerformed
currentSettingVersion = i;
setGameSettingsFromPrefs(currentSettingVersion);
}//GEN-LAST:event_btnPreviousConfigurationActionPerformed
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName(), false, 2);
options.getPlayerTypes().add("Human");
options.getPlayerTypes().add(PlayerType.HUMAN);
for (TablePlayerPanel player : players) {
options.getPlayerTypes().add(player.getPlayerType());
}
@ -404,11 +423,11 @@ public class NewTableDialog extends MageDialog {
roomId,
table.getTableId(),
this.player1Panel.getPlayerName(),
"Human", 1,
PlayerType.HUMAN, 1,
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
this.txtPassword.getText())) {
for (TablePlayerPanel player : players) {
if (!player.getPlayerType().equals("Human")) {
if (player.getPlayerType() != PlayerType.HUMAN) {
if (!player.joinTable(roomId, table.getTableId())) {
// error message must be send by the server
SessionHandler.removeTable(roomId, table.getTableId());
@ -509,7 +528,7 @@ public class NewTableDialog extends MageDialog {
if (numPlayers > players.size()) {
while (players.size() != numPlayers) {
TablePlayerPanel playerPanel = new TablePlayerPanel();
String playerType = "Human";
PlayerType playerType = PlayerType.HUMAN;
if (prefPlayerTypes.size() >= players.size() && !players.isEmpty()) {
playerType = prefPlayerTypes.get(players.size() - 1);
}
@ -562,11 +581,12 @@ public class NewTableDialog extends MageDialog {
for (TablePlayerPanel tablePlayerPanel : players) {
tablePlayerPanel.init(i++, tablePlayerPanel.getPlayerType());
}
setGameSettingsFromPrefs();
this.setModal(true);
setGameOptions();
this.setLocation(150, 100);
}
currentSettingVersion = 0;
setGameSettingsFromPrefs(currentSettingVersion);
this.setVisible(true);
}
@ -591,47 +611,61 @@ public class NewTableDialog extends MageDialog {
/**
* set the table settings from java prefs
*/
private void setGameSettingsFromPrefs() {
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME, "Game"));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, ""));
int currentSettingVersion = 0;
private void setGameSettingsFromPrefs(int version) {
currentSettingVersion = version;
String versionStr = "";
if (currentSettingVersion == 1) {
versionStr = "1";
btnPreviousConfiguration1.requestFocus();
} else if (currentSettingVersion == 2) {
versionStr = "2";
btnPreviousConfiguration2.requestFocus();
} else {
btnPreviousConfiguration2.getParent().requestFocus();
}
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, "Game"));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, ""));
String playerTypes = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES, "Human");
String playerTypes = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES + versionStr, "Human");
prefPlayerTypes.clear();
prefPlayerTypes.addAll(Arrays.asList(playerTypes.split(",")));
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));
for (String pType : playerTypes.split(",")) {
prefPlayerTypes.add(PlayerType.getByDescription(pType));
}
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS + versionStr, "2")));
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, "Two Player Duel");
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE + versionStr, "Two Player Duel");
for (GameTypeView gtv : SessionHandler.getGameTypes()) {
if (gtv.getName().equals(gameTypeName)) {
cbGameType.setSelectedItem(gtv);
break;
}
}
int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT, "1500"));
int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT + versionStr, "1500"));
for (MatchTimeLimit mtl : MatchTimeLimit.values()) {
if (mtl.getTimeLimit() == timeLimit) {
this.cbTimeLimit.setSelectedItem(mtl);
break;
}
}
cbDeckType.setSelectedItem(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE, "Limited"));
String deckFile = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, null);
cbDeckType.setSelectedItem(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE + versionStr, "Limited"));
String deckFile = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, null);
if (deckFile != null) {
this.player1Panel.setDeckFile(deckFile);
}
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, "2")));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED, "Yes").equals("Yes"));
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED, "No").equals("Yes"));
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, "0")));
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, "2")));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, "Yes").equals("Yes"));
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, "No").equals("Yes"));
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, "1"));
int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, "1"));
for (RangeOfInfluence roi : RangeOfInfluence.values()) {
if (roi.getRange() == range) {
this.cbRange.setSelectedItem(roi);
break;
}
}
String attackOption = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION, "Attack Multiple Players");
String attackOption = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, "Attack Multiple Players");
for (MultiplayerAttackOption mao : MultiplayerAttackOption.values()) {
if (mao.toString().equals(attackOption)) {
this.cbAttackOption.setSelectedItem(mao);
@ -658,21 +692,27 @@ public class NewTableDialog extends MageDialog {
* @param deckFile
*/
private void saveGameSettingsToPrefs(MatchOptions options, String deckFile) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NAME, options.getName());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, options.getPassword());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE, options.getDeckType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT, Integer.toString(options.getPriorityTime()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, options.getGameType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, Integer.toString(options.getWinsNeeded()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED, options.isRollbackTurnsAllowed() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RATED, options.isRated() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, Integer.toString(options.getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile);
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, spnNumPlayers.getValue().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, Integer.toString(options.getRange().getRange()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION, options.getAttackOption().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL, options.getSkillLevel().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO, Integer.toString(options.getQuitRatio()));
String versionStr = "";
if (currentSettingVersion == 1) {
versionStr = "1";
} else if (currentSettingVersion == 2) {
versionStr = "2";
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, options.getName());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, options.getPassword());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE + versionStr, options.getDeckType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_TIME_LIMIT + versionStr, Integer.toString(options.getPriorityTime()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE + versionStr, options.getGameType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, Integer.toString(options.getWinsNeeded()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, options.isRollbackTurnsAllowed() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, options.isRated() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, Integer.toString(options.getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, deckFile);
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS + versionStr, spnNumPlayers.getValue().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, Integer.toString(options.getRange().getRange()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, options.getAttackOption().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, options.getSkillLevel().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
StringBuilder playerTypesString = new StringBuilder();
for (Object player : players) {
if (playerTypesString.length() > 0) {
@ -681,12 +721,14 @@ public class NewTableDialog extends MageDialog {
TablePlayerPanel tpp = (TablePlayerPanel) player;
playerTypesString.append(tpp.getPlayerType());
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES, playerTypesString.toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES + versionStr, playerTypesString.toString());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOK;
private javax.swing.JButton btnPreviousConfiguration1;
private javax.swing.JButton btnPreviousConfiguration2;
private javax.swing.JComboBox cbAttackOption;
private javax.swing.JComboBox cbDeckType;
private javax.swing.JComboBox cbGameType;
@ -723,5 +765,4 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPassword;
// End of variables declaration//GEN-END:variables
}

View file

@ -64,6 +64,10 @@
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="btnSavedConfiguration1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnSavedConfiguration2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
@ -97,7 +101,7 @@
<Group type="102" alignment="0" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtName" min="-2" pref="124" max="-2" attributes="0"/>
<Component id="txtName" min="-2" pref="224" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbTimeLimit" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -210,6 +214,8 @@
<Component id="pnlPlayers" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnSavedConfiguration1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnSavedConfiguration2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
@ -511,7 +517,23 @@
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="btnOk">
<Component class="javax.swing.JButton" name="btnSavedConfiguration1">
<Properties>
<Property name="text" type="java.lang.String" value="C1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSavedConfigurationActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnSavedConfiguration2">
<Properties>
<Property name="text" type="java.lang.String" value="C2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSavedConfigurationActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnOk">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>

View file

@ -26,28 +26,18 @@
* or implied, of BetaSteward_at_googlemail.com.
*/
/*
/*
* NewTournamentDialog.java
*
* Created on Jan 28, 2011, 12:15:56 PM
*/
package mage.client.dialog;
import java.awt.Component;
import java.awt.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
import java.util.List;
import java.util.UUID;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.SpinnerNumberModel;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import mage.cards.decks.Deck;
import mage.cards.decks.importer.DeckImporterUtil;
@ -65,13 +55,13 @@ import mage.game.draft.DraftOptions;
import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
import mage.game.tournament.TournamentOptions;
import mage.players.PlayerType;
import mage.view.GameTypeView;
import mage.view.TableView;
import mage.view.TournamentTypeView;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class NewTournamentDialog extends MageDialog {
@ -93,7 +83,9 @@ public class NewTournamentDialog extends MageDialog {
private String cubeFromDeckFilename = "";
private boolean automaticChange = false;
/** Creates new form NewTournamentDialog */
/**
* Creates new form NewTournamentDialog
*/
public NewTournamentDialog() {
initComponents();
lastSessionId = "";
@ -121,22 +113,23 @@ public class NewTournamentDialog extends MageDialog {
cbDraftCube.setModel(new DefaultComboBoxModel(SessionHandler.getDraftCubes()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
// update player types
int i=2;
for (TournamentPlayerPanel tournamentPlayerPanel :players) {
int i = 2;
for (TournamentPlayerPanel tournamentPlayerPanel : players) {
tournamentPlayerPanel.init(i++);
}
cbAllowSpectators.setSelected(true);
setTournamentSettingsFromPrefs();
this.setModal(true);
this.setLocation(150, 100);
}
currentSettingVersion = 0;
setTournamentSettingsFromPrefs(currentSettingVersion);
this.setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -183,6 +176,8 @@ public class NewTournamentDialog extends MageDialog {
player1Panel = new mage.client.table.NewPlayerPanel();
pnlPlayers = new javax.swing.JPanel();
pnlOtherPlayers = new javax.swing.JPanel();
btnSavedConfiguration1 = new javax.swing.JButton();
btnSavedConfiguration2 = new javax.swing.JButton();
btnOk = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
pnlRandomPacks = new javax.swing.JPanel();
@ -193,7 +188,7 @@ public class NewTournamentDialog extends MageDialog {
lblName.setText("Name:");
lbTimeLimit.setText("Time Limit:");
lbTimeLimit.setText("Time:");
lbTimeLimit.setToolTipText("The time a player has for the whole match. If a player runs out of time during a game, he loses the complete match. ");
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cbTimeLimit, org.jdesktop.beansbinding.ObjectProperty.create(), lbTimeLimit, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
@ -201,7 +196,7 @@ public class NewTournamentDialog extends MageDialog {
cbTimeLimit.setToolTipText("The time a player has for the whole match. If a player runs out of time during a game, he loses the complete match. ");
lbSkillLevel.setText("Skill Level:");
lbSkillLevel.setText("Skill:");
lbSkillLevel.setToolTipText("The time a player has for the whole match. If a player runs out of time during a game, he loses the complete match. ");
cbSkillLevel.setToolTipText("<HTML>This option can be used to make it easier to find matches<br>\nwith opponents of the appropriate skill level.");
@ -213,7 +208,7 @@ public class NewTournamentDialog extends MageDialog {
lblTournamentType.setText("Tournament Type:");
cbTournamentType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbTournamentType.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
cbTournamentType.addActionListener(evt -> cbTournamentTypeActionPerformed(evt));
lbDeckType.setText("Deck Type:");
@ -235,7 +230,7 @@ public class NewTournamentDialog extends MageDialog {
lblDraftCube.setText("Draft Cube:");
cbDraftCube.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDraftCube.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
cbDraftCube.addActionListener(evt -> cbDraftCubeActionPerformed(evt));
lblNumRounds.setText("Number of Swiss Rounds:");
@ -260,27 +255,27 @@ public class NewTournamentDialog extends MageDialog {
jLabel6.setText("Timing:");
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
cbDraftTiming.addActionListener(evt -> cbDraftTimingActionPerformed(evt));
javax.swing.GroupLayout pnlDraftOptionsLayout = new javax.swing.GroupLayout(pnlDraftOptions);
pnlDraftOptions.setLayout(pnlDraftOptionsLayout);
pnlDraftOptionsLayout.setHorizontalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(19, Short.MAX_VALUE))
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(19, Short.MAX_VALUE))
);
pnlDraftOptionsLayout.setVerticalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addGap(3, 3, 3)
.addGroup(pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addGap(3, 3, 3)
.addGroup(pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
cbAllowSpectators.setText("Allow spectators");
@ -306,14 +301,27 @@ public class NewTournamentDialog extends MageDialog {
javax.swing.GroupLayout pnlPlayersLayout = new javax.swing.GroupLayout(pnlPlayers);
pnlPlayers.setLayout(pnlPlayersLayout);
pnlPlayersLayout.setHorizontalGroup(
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pnlPlayersLayout.setVerticalGroup(
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
btnSavedConfiguration1.setText("T1");
btnSavedConfiguration1.setToolTipText("Load saved tournament configuration #1");
btnSavedConfiguration1.addActionListener(evt -> btnSavedConfigurationActionPerformed(evt, 1));
btnSavedConfiguration1.setVisible(true);
btnSavedConfiguration2.setText("T2");
btnSavedConfiguration2.setToolTipText("Load saved tournament configuration #2");
btnSavedConfiguration2.addActionListener(evt -> btnSavedConfigurationActionPerformed(evt, 2));
btnSavedConfiguration2.setVisible(true);
btnOk.setText("OK");
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
btnOk.setText("OK");
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
@ -333,170 +341,176 @@ public class NewTournamentDialog extends MageDialog {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblNbrPlayers)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblNbrSeats)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumSeats, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblPacks)
.addComponent(lblPlayer1))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblNumRounds))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblConstructionTime)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkRollbackTurnsAllowed))
.addGroup(layout.createSequentialGroup()
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbAllowSpectators))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblDraftCube)
.addComponent(lblTournamentType)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkRated))
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(lblName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbSkillLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPassword)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlRandomPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblNbrPlayers)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblNbrSeats)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumSeats, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblPacks)
.addComponent(lblPlayer1))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblNumRounds))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblConstructionTime)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkRollbackTurnsAllowed))
.addGroup(layout.createSequentialGroup()
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbAllowSpectators))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblDraftCube)
.addComponent(lblTournamentType)
.addComponent(lbDeckType)
.addComponent(lblGameType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkRated))
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(lblName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbSkillLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPassword)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSavedConfiguration1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSavedConfiguration2))
.addGroup(layout.createSequentialGroup()
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlRandomPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName)
.addComponent(lbTimeLimit)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPassword)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbSkillLevel)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblFreeMulligans)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblQuitRatio)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chkRated))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblTournamentType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDraftCube))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblGameType)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPacks)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(pnlPacks, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlRandomPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbAllowSpectators, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumRounds))
.addComponent(lblNbrPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumPlayers)
.addComponent(lblNbrSeats, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumSeats)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPlayer1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblConstructionTime)
.addComponent(chkRollbackTurnsAllowed)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(player1Panel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnOk)
.addComponent(btnCancel))
.addContainerGap())
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName)
.addComponent(lbTimeLimit)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPassword)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnSavedConfiguration1)
.addComponent(btnSavedConfiguration2)
.addComponent(lbSkillLevel)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblFreeMulligans)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblQuitRatio)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chkRated))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblTournamentType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDraftCube))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblGameType)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPacks)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(pnlPacks, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlRandomPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbAllowSpectators, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumRounds))
.addComponent(lblNbrPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumPlayers)
.addComponent(lblNbrSeats, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumSeats)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPlayer1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblConstructionTime)
.addComponent(chkRollbackTurnsAllowed)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(player1Panel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnOk)
.addComponent(btnCancel))
.addContainerGap())
);
bindingGroup.bind();
@ -508,20 +522,25 @@ public class NewTournamentDialog extends MageDialog {
setTournamentOptions((Integer) this.spnNumPlayers.getValue());
}//GEN-LAST:event_cbTournamentTypeActionPerformed
private void btnSavedConfigurationActionPerformed(java.awt.event.ActionEvent evt, int setting) {//GEN-FIRST:event_btnSavedConfigurationActionPerformed
currentSettingVersion = setting;
setTournamentSettingsFromPrefs(currentSettingVersion);
}//GEN-LAST:event_btnSavedConfigurationActionPerformed
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
int numSeats = (Integer)this.spnNumSeats.getValue();
int numSeats = (Integer) this.spnNumSeats.getValue();
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText(), "", numSeats);
tOptions.setTournamentType(tournamentType.getName());
tOptions.setPassword(txtPassword.getText());
tOptions.getPlayerTypes().add("Human");
tOptions.getPlayerTypes().add(PlayerType.HUMAN);
tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
tOptions.setQuitRatio((Integer)spnQuitRatio.getValue());
for (TournamentPlayerPanel player: players) {
tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem());
tOptions.setQuitRatio((Integer) spnQuitRatio.getValue());
for (TournamentPlayerPanel player : players) {
tOptions.getPlayerTypes().add((PlayerType) player.getPlayerType().getSelectedItem());
}
if (!tournamentType.isElimination()) {
tOptions.setNumberRounds((Integer)spnNumRounds.getValue());
tOptions.setNumberRounds((Integer) spnNumRounds.getValue());
}
if (tournamentType.isDraft()) {
DraftOptions options = new DraftOptions();
@ -533,21 +552,21 @@ public class NewTournamentDialog extends MageDialog {
tOptions.setLimitedOptions(new LimitedOptions());
}
if (tournamentType.isLimited()) {
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
tOptions.getLimitedOptions().setConstructionTime((Integer) this.spnConstructTime.getValue() * 60);
tOptions.getLimitedOptions().setIsRandom(tournamentType.isRandom());
if (tournamentType.isCubeBooster()) {
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
if (!(cubeFromDeckFilename.isEmpty())) {
Deck cubeFromDeck = new Deck();
Deck cubeFromDeck = new Deck();
try {
cubeFromDeck = Deck.load(DeckImporterUtil.importDeck(cubeFromDeckFilename), true, true);
} catch (GameException e1) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
}
if (cubeFromDeck != null) {
cubeFromDeck.clearLayouts();
tOptions.getLimitedOptions().setCubeFromDeck(cubeFromDeck);
}
}
}
} else if (tournamentType.isRandom() || tournamentType.isRichMan()) {
this.isRandom = tournamentType.isRandom();
@ -558,18 +577,18 @@ public class NewTournamentDialog extends MageDialog {
if (tournamentType.isRichMan()) {
maxPacks = 36;
}
if (selected.size() > maxPacks ){
if (selected.size() > maxPacks) {
StringBuilder infoString = new StringBuilder("More sets were selected than needed. ");
infoString.append(maxPacks);
infoString.append(" sets will be randomly chosen.");
JOptionPane.showMessageDialog(MageFrame.getDesktop(), infoString, "Information", JOptionPane.INFORMATION_MESSAGE);
Collections.shuffle(selected);
tOptions.getLimitedOptions().getSetCodes().addAll(selected.subList(0, maxPacks));
}else{
tOptions.getLimitedOptions().getSetCodes().addAll(selected);
} else {
tOptions.getLimitedOptions().getSetCodes().addAll(selected);
}
} else {
for (JComboBox pack: packs) {
for (JComboBox pack : packs) {
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
}
}
@ -588,8 +607,8 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
tOptions.getMatchOptions().setSkillLevel((SkillLevel) this.cbSkillLevel.getSelectedItem());
tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue());
tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
tOptions.getMatchOptions().setWinsNeeded((Integer) this.spnNumWins.getValue());
tOptions.getMatchOptions().setFreeMulligans((Integer) this.spnFreeMulligans.getValue());
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
tOptions.getMatchOptions().setRollbackTurnsAllowed(this.chkRollbackTurnsAllowed.isSelected());
@ -605,11 +624,11 @@ public class NewTournamentDialog extends MageDialog {
roomId,
table.getTableId(),
this.player1Panel.getPlayerName(),
"Human", 1,
PlayerType.HUMAN, 1,
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
tOptions.getPassword())) {
for (TournamentPlayerPanel player: players) {
if (!player.getPlayerType().toString().equals("Human")) {
for (TournamentPlayerPanel player : players) {
if (!player.getPlayerType().getSelectedItem().toString().equals("Human")) {
if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
// error message must be send by sever
SessionHandler.removeTable(roomId, table.getTableId());
@ -633,8 +652,8 @@ public class NewTournamentDialog extends MageDialog {
}//GEN-LAST:event_btnCancelActionPerformed
private void updateNumSeats() {
int numPlayers = (Integer)this.spnNumPlayers.getValue();
int numSeats = (Integer)this.spnNumSeats.getValue();
int numPlayers = (Integer) this.spnNumPlayers.getValue();
int numSeats = (Integer) this.spnNumSeats.getValue();
if (numSeats > 2) {
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
@ -652,16 +671,16 @@ public class NewTournamentDialog extends MageDialog {
}
private void spnNumPlayersStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumPlayersStateChanged
int numPlayers = (Integer)this.spnNumPlayers.getValue();
int numPlayers = (Integer) this.spnNumPlayers.getValue();
createPlayers(numPlayers - 1);
int numSeats = (Integer)this.spnNumSeats.getValue();
int numSeats = (Integer) this.spnNumSeats.getValue();
if (numSeats > 2 && numPlayers != numSeats) {
updateNumSeats();
}
}//GEN-LAST:event_spnNumPlayersStateChanged
private void spnNumSeatsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumSeatsStateChanged
int numSeats = (Integer)this.spnNumSeats.getValue();
int numSeats = (Integer) this.spnNumSeats.getValue();
if (numSeats > 2) {
this.spnNumPlayers.setEnabled(false);
} else {
@ -669,11 +688,10 @@ public class NewTournamentDialog extends MageDialog {
}
updateNumSeats();
}//GEN-LAST:event_spnNumSeatsStateChanged
private void spnNumWinsnumPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumWinsnumPlayersChanged
int numSeats = (Integer)this.spnNumSeats.getValue();
int numWins = (Integer)this.spnNumSeats.getValue();
int numSeats = (Integer) this.spnNumSeats.getValue();
int numWins = (Integer) this.spnNumSeats.getValue();
if (numSeats > 2) {
spnNumWins.setValue(1);
}
@ -699,7 +717,6 @@ public class NewTournamentDialog extends MageDialog {
return "";
}
private void cbDraftCubeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDraftCubeActionPerformed
cubeFromDeckFilename = "";
if (cbDraftCube.getSelectedItem().toString().equals("Cube From Deck")) {
@ -718,6 +735,7 @@ public class NewTournamentDialog extends MageDialog {
private void cbGameTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameTypeActionPerformed
setGameOptions();
}//GEN-LAST:event_cbGameTypeActionPerformed
private void setGameOptions() {
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
// int oldValue = (Integer) this.spnNumPlayers.getValue();
@ -747,10 +765,10 @@ public class NewTournamentDialog extends MageDialog {
if (tournamentType.isLimited()) {
this.isRandom = tournamentType.isRandom();
this.isRichMan = tournamentType.isRichMan();
if (this.isRandom || this.isRichMan){
this.isRichMan = tournamentType.isRichMan();
if (this.isRandom || this.isRichMan) {
createRandomPacks();
}else{
} else {
createPacks(tournamentType.getNumBoosters());
}
}
@ -759,8 +777,8 @@ public class NewTournamentDialog extends MageDialog {
private void setNumberOfSwissRoundsMin(int numPlayers) {
// set the number of minimum swiss rounds related to the number of players
int minRounds = (int) Math.ceil(Math.log(numPlayers + 1) / Math.log(2));
int newValue = Math.max((Integer)spnNumRounds.getValue(), minRounds);
int minRounds = (int) Math.ceil(Math.log(numPlayers + 1) / Math.log(2));
int newValue = Math.max((Integer) spnNumRounds.getValue(), minRounds);
this.spnNumRounds.setModel(new SpinnerNumberModel(newValue, minRounds, 10, 1));
this.pack();
this.revalidate();
@ -793,7 +811,7 @@ public class NewTournamentDialog extends MageDialog {
this.lblPacks.setVisible(false);
this.pnlPacks.setVisible(false);
this.pnlRandomPacks.setVisible(false);
} else if (tournamentType.isRandom() || tournamentType.isRichMan()){
} else if (tournamentType.isRandom() || tournamentType.isRichMan()) {
this.lblDraftCube.setVisible(false);
this.cbDraftCube.setVisible(false);
this.lblPacks.setVisible(true);
@ -887,14 +905,13 @@ public class NewTournamentDialog extends MageDialog {
private void packActionPerformed(java.awt.event.ActionEvent evt) {
boolean start = false;
int selectedIndex = 0;
for (JComboBox pack: packs) {
for (JComboBox pack : packs) {
if (!start) {
if (evt.getSource().equals(pack)) {
start = true;
selectedIndex = pack.getSelectedIndex();
}
}
else {
} else {
pack.setSelectedIndex(selectedIndex);
}
}
@ -909,8 +926,7 @@ public class NewTournamentDialog extends MageDialog {
players.add(playerPanel);
}
}
else if (numPlayers < players.size()) {
} else if (numPlayers < players.size()) {
while (players.size() != numPlayers) {
players.remove(players.size() - 1);
}
@ -921,11 +937,9 @@ public class NewTournamentDialog extends MageDialog {
}
private void drawPlayers() {
this.pnlOtherPlayers.removeAll();
for (TournamentPlayerPanel panel: players) {
for (TournamentPlayerPanel panel : players) {
this.pnlOtherPlayers.add(panel);
panel.getPlayerType().addActionListener(evt -> {
if (!automaticChange) {
@ -942,14 +956,13 @@ public class NewTournamentDialog extends MageDialog {
boolean start = false;
int selectedIndex = 0;
automaticChange = true;
for (TournamentPlayerPanel player: players) {
for (TournamentPlayerPanel player : players) {
if (!start) {
if (evt.getSource().equals(player.getPlayerType())) {
start = true;
selectedIndex = player.getPlayerType().getSelectedIndex();
}
}
else {
} else {
player.getPlayerType().setSelectedIndex(selectedIndex);
}
}
@ -959,58 +972,70 @@ public class NewTournamentDialog extends MageDialog {
/**
* set the tournament settings from java prefs
*/
private void setTournamentSettingsFromPrefs () {
int currentSettingVersion = 0;
private void setTournamentSettingsFromPrefs(int version) {
currentSettingVersion = version;
String versionStr = "";
if (currentSettingVersion == 1) {
versionStr = "1";
btnSavedConfiguration1.requestFocus();
} else if (currentSettingVersion == 2) {
versionStr = "2";
btnSavedConfiguration2.requestFocus();
} else {
btnSavedConfiguration2.getParent().requestFocus();
}
int numPlayers;
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, "Tournament"));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PASSWORD, ""));
int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT, "1500"));
for (MatchTimeLimit mtl :MatchTimeLimit.values()) {
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME + versionStr, "Tournament"));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PASSWORD + versionStr, ""));
int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT + versionStr, "1500"));
for (MatchTimeLimit mtl : MatchTimeLimit.values()) {
if (mtl.getTimeLimit() == timeLimit) {
this.cbTimeLimit.setSelectedItem(mtl);
break;
}
}
String skillLevelDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL, "Casual");
for (SkillLevel skillLevel :SkillLevel.values()) {
String skillLevelDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, "Casual");
for (SkillLevel skillLevel : SkillLevel.values()) {
if (skillLevel.toString().equals(skillLevelDefault)) {
this.cbSkillLevel.setSelectedItem(skillLevel);
break;
}
}
int constructionTime = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME, "600")) / 60;
int constructionTime = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME + versionStr, "600")) / 60;
if (constructionTime < CONSTRUCTION_TIME_MIN || constructionTime > CONSTRUCTION_TIME_MAX) {
constructionTime = CONSTRUCTION_TIME_MIN;
}
this.spnConstructTime.setValue(constructionTime);
String tournamentTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, "Sealed Elimination");
String tournamentTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE + versionStr, "Sealed Elimination");
for (TournamentTypeView tournamentTypeView : SessionHandler.getTournamentTypes()) {
if (tournamentTypeView.getName().equals(tournamentTypeName)) {
cbTournamentType.setSelectedItem(tournamentTypeView);
break;
}
}
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS, "0")));
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS, "2")));
this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO, "100")));
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS + versionStr, "2")));
this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO + versionStr, "100")));
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
activatePanelElements(tournamentType);
if (tournamentType.isLimited()) {
if (!tournamentType.isDraft()) {
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED, "2"));
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED + versionStr, "2"));
setTournamentOptions(numPlayers);
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED, ""));
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED + versionStr, ""));
}
if (tournamentType.isDraft()) {
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, "4"));
numPlayers = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT + versionStr, "4"));
setTournamentOptions(numPlayers);
if (!(tournamentType.isRandom() || tournamentType.isRichMan())){
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, ""));
if (!(tournamentType.isRandom() || tournamentType.isRichMan())) {
loadBoosterPacks(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT + versionStr, ""));
}
String draftTiming = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING, "REGULAR");
String draftTiming = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING + versionStr, "REGULAR");
for (TimingOption timingOption : DraftOptions.TimingOption.values()) {
if (timingOption.toString().equals(draftTiming)) {
cbDraftTiming.setSelectedItem(draftTiming);
@ -1019,22 +1044,22 @@ public class NewTournamentDialog extends MageDialog {
}
}
}
this.cbAllowSpectators.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, "Yes").equals("Yes"));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS, "Yes").equals("Yes"));
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED, "No").equals("Yes"));
this.cbAllowSpectators.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS + versionStr, "Yes").equals("Yes"));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS + versionStr, "Yes").equals("Yes"));
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED + versionStr, "No").equals("Yes"));
}
private void loadBoosterPacks(String packString) {
if (!packString.isEmpty()) {
String[] packsArray = packString.substring(1, packString.length() - 1).split(",");
int packNumber = 0;
for (String pack : packsArray ){
for (String pack : packsArray) {
packNumber++;
if (this.packs.size() >= packNumber - 1) {
JComboBox comboBox = this.packs.get(packNumber-1);
JComboBox comboBox = this.packs.get(packNumber - 1);
ComboBoxModel model = comboBox.getModel();
int size = model.getSize();
for(int i=0;i<size;i++) {
for (int i = 0; i < size; i++) {
ExpansionInfo element = (ExpansionInfo) model.getElementAt(i);
if (element.getCode().equals(pack.trim())) {
comboBox.setSelectedIndex(i);
@ -1048,63 +1073,70 @@ public class NewTournamentDialog extends MageDialog {
}
/**
* Save the settings to java prefs to reload it next time the dialog will be created
* Save the settings to java prefs to reload it next time the dialog will be
* created
*
* @param tOptions Tournament options
*/
private void saveTournamentSettingsToPrefs(TournamentOptions tOptions) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, tOptions.getName());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PASSWORD, tOptions.getPassword());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT, Integer.toString(tOptions.getMatchOptions().getPriorityTime()));
if (this.spnConstructTime.isVisible()) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME, Integer.toString(tOptions.getLimitedOptions().getConstructionTime()));
String versionStr = "";
if (currentSettingVersion == 1) {
versionStr = "1";
} else if (currentSettingVersion == 2) {
versionStr = "2";
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, tOptions.getTournamentType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS, Integer.toString(tOptions.getMatchOptions().getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS, Integer.toString(tOptions.getMatchOptions().getWinsNeeded()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO, Integer.toString(tOptions.getQuitRatio()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME + versionStr, tOptions.getName());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PASSWORD + versionStr, tOptions.getPassword());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT + versionStr, Integer.toString(tOptions.getMatchOptions().getPriorityTime()));
if (this.spnConstructTime.isVisible()) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME + versionStr, Integer.toString(tOptions.getLimitedOptions().getConstructionTime()));
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE + versionStr, tOptions.getTournamentType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS + versionStr, Integer.toString(tOptions.getMatchOptions().getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS + versionStr, Integer.toString(tOptions.getMatchOptions().getWinsNeeded()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO + versionStr, Integer.toString(tOptions.getQuitRatio()));
if (tOptions.getTournamentType().startsWith("Sealed")) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED, tOptions.getLimitedOptions().getSetCodes().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED, Integer.toString(tOptions.getPlayerTypes().size()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED + versionStr, tOptions.getLimitedOptions().getSetCodes().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED + versionStr, Integer.toString(tOptions.getPlayerTypes().size()));
}
if (tOptions.getTournamentType().startsWith("Booster")) {
DraftOptions draftOptions = (DraftOptions) tOptions.getLimitedOptions();
if (draftOptions != null) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, draftOptions.getSetCodes().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, Integer.toString(tOptions.getPlayerTypes().size()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING, draftOptions.getTiming().name());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT + versionStr, draftOptions.getSetCodes().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT + versionStr, Integer.toString(tOptions.getPlayerTypes().size()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING + versionStr, draftOptions.getTiming().name());
}
String deckFile = this.player1Panel.getDeckFile();
if (deckFile != null && !deckFile.isEmpty()) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile);
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE + versionStr, deckFile);
}
if (tOptions.getLimitedOptions().getIsRandom()){
if (tOptions.getLimitedOptions().getIsRandom()) {
// save random boosters to prefs
StringBuilder packlist = new StringBuilder();
for (String pack : this.randomPackSelector.getSelectedPacks()){
for (String pack : this.randomPackSelector.getSelectedPacks()) {
packlist.append(pack);
packlist.append(';');
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, packlist.toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT + versionStr, packlist.toString());
}
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, (tOptions.isWatchingAllowed()?"Yes":"No"));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS, (tOptions.getMatchOptions().isRollbackTurnsAllowed()?"Yes":"No"));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED, (tOptions.getMatchOptions().isRated() ? "Yes" : "No"));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS + versionStr, (tOptions.isWatchingAllowed() ? "Yes" : "No"));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS + versionStr, (tOptions.getMatchOptions().isRollbackTurnsAllowed() ? "Yes" : "No"));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED + versionStr, (tOptions.getMatchOptions().isRated() ? "Yes" : "No"));
}
public TableView getTable() {
return table;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk;
private javax.swing.JButton btnSavedConfiguration1;
private javax.swing.JButton btnSavedConfiguration2;
private javax.swing.JCheckBox cbAllowSpectators;
private javax.swing.JComboBox cbDeckType;
private javax.swing.JComboBox cbDraftCube;

View file

@ -39,19 +39,17 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.swing.Icon;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.chat.ChatPanelBasic;
import mage.client.components.MageComponents;
import mage.client.components.tray.MageTray;
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
import mage.client.util.GUISizeHelper;
import mage.client.util.audio.AudioManager;
import mage.client.util.gui.TableUtil;
@ -419,15 +417,8 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
@Override
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
SessionHandler.getTable(roomId, tableId).ifPresent(tableView -> {
this.publish(tableView);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
});
SessionHandler.getTable(roomId, tableId).ifPresent(this::publish);
TimeUnit.SECONDS.sleep(1);
}
return null;
}

View file

@ -99,8 +99,8 @@ public class DraftPane extends MagePane {
jScrollPane1.setViewportView(draftPanel1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 868, Short.MAX_VALUE)
@ -109,14 +109,12 @@ public class DraftPane extends MagePane {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 582, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void initComponents(Component container) {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
@ -125,8 +123,6 @@ public class DraftPane extends MagePane {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
);
pack();
}
// Variables declaration - do not modify//GEN-BEGIN:variables

View file

@ -33,15 +33,6 @@
*/
package mage.client.game;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import mage.cards.MagePermanent;
import mage.client.cards.BigCard;
import mage.client.cards.Permanent;
@ -51,11 +42,19 @@ import mage.client.util.GUISizeHelper;
import mage.client.util.audio.AudioManager;
import mage.client.util.layout.CardLayoutStrategy;
import mage.client.util.layout.impl.OldCardLayoutStrategy;
import mage.constants.CardType;
import mage.utils.CardUtil;
import mage.view.CounterView;
import mage.view.PermanentView;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
/**
*
* @author BetaSteward_at_googlemail.com
@ -155,7 +154,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
changed = true;
} else {
if (!changed) {
changed = CardUtil.isCreature(oldMagePermanent.getOriginalPermanent()) != CardUtil.isCreature(permanent);
changed = oldMagePermanent.getOriginalPermanent().isCreature() != permanent.isCreature();
if (!changed) {
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
int s2 = oldMagePermanent.getLinks().size();
@ -279,9 +278,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
}*/
}
if (permanent.getCardTypes().contains(CardType.ARTIFACT)) {
if (permanent.isArtifact()) {
addedArtifact = true;
} else if (permanent.getCardTypes().contains(CardType.CREATURE)) {
} else if (permanent.isCreature()) {
addedCreature = true;
} else {
addedPermanent = true;
@ -305,7 +304,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
});
t.start();
}
if (((MagePermanent) comp).getOriginal().getCardTypes().contains(CardType.CREATURE)) {
if (((MagePermanent) comp).getOriginal().isCreature()) {
removedCreature = true;
}
}

View file

@ -35,7 +35,8 @@ package mage.client.game;
import java.awt.AWTEvent;
import java.util.UUID;
import javax.swing.SwingUtilities;
import javax.swing.*;
import mage.client.MagePane;
/**
@ -48,10 +49,9 @@ public class GamePane extends MagePane {
* Creates new form GamePane
*/
public GamePane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
SwingUtilities.invokeLater(() -> {
gamePanel.setJLayeredPane(getLayeredPane());
gamePanel.setJLayeredPane(this);
gamePanel.installComponents();
});
@ -96,12 +96,13 @@ public class GamePane extends MagePane {
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jScrollPane1.setBorder(BorderFactory.createEmptyBorder());
gamePanel = new mage.client.game.GamePanel();
jScrollPane1.setViewportView(gamePanel);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)
@ -113,7 +114,6 @@ public class GamePane extends MagePane {
.addGap(0, 400, Short.MAX_VALUE)
);
pack();
}
public UUID getGameId() {

View file

@ -31,6 +31,7 @@ import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import static java.awt.Component.LEFT_ALIGNMENT;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
@ -59,6 +60,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
@ -80,7 +82,6 @@ import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import mage.cards.Card;
import mage.cards.action.ActionCallback;
import mage.choices.Choice;
@ -100,9 +101,7 @@ import mage.client.dialog.PickChoiceDialog;
import mage.client.dialog.PickNumberDialog;
import mage.client.dialog.PickPileDialog;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.*;
import mage.client.dialog.ShowCardsDialog;
import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.plugins.adapters.MageActionCallback;
@ -119,13 +118,11 @@ import mage.constants.Constants;
import mage.constants.EnlargeMode;
import mage.constants.PhaseStep;
import mage.constants.PlayerAction;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_FIRST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_LAST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_FIRST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST;
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
import mage.constants.Zone;
import mage.game.events.PlayerQueryEvent;
import mage.view.AbilityPickerView;
@ -534,8 +531,8 @@ public final class GamePanel extends javax.swing.JPanel {
this.pnlReplay.setVisible(false);
this.gameChatPanel.clear();
SessionHandler.getGameChatId(gameId).ifPresent(uuid ->
this.gameChatPanel.connect(uuid));
SessionHandler.getGameChatId(gameId).ifPresent(uuid
-> this.gameChatPanel.connect(uuid));
if (!SessionHandler.watchGame(gameId)) {
removeGame();
}
@ -816,13 +813,15 @@ public final class GamePanel extends javax.swing.JPanel {
cardsView.put(player.getTopCard().getId(), player.getTopCard());
handleGameInfoWindow(revealed, ShowType.REVEAL_TOP_LIBRARY, player.getName() + "'s top library card", cardsView);
}
} else {
} else if (!players.isEmpty()) {
logger.warn("Couldn't find player.");
logger.warn(" uuid:" + player.getPlayerId());
logger.warn(" players:");
for (PlayAreaPanel p : players.values()) {
logger.warn(String.valueOf(p));
}
} else {
// can happen at the game start before player list is initiated
}
}
if (!menuNameSet) {
@ -1776,24 +1775,24 @@ public final class GamePanel extends javax.swing.JPanel {
pnlReplay.setLayout(gl_pnlReplay);
gl_pnlReplay.setHorizontalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(gl_pnlReplay.createSequentialGroup()
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(gl_pnlReplay.createSequentialGroup()
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
);
gl_pnlReplay.setVerticalGroup(
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
);
// Game info panel (buttons on the right panel)
@ -1867,8 +1866,8 @@ public final class GamePanel extends javax.swing.JPanel {
}
};
String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
"Main2", "Cleanup", "Next_Turn"};
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
"Main2", "Cleanup", "Next_Turn"};
for (String name : phases) {
createPhaseButton(name, phasesMouseAdapter);
}
@ -1905,46 +1904,46 @@ public final class GamePanel extends javax.swing.JPanel {
javax.swing.GroupLayout gl_helperHandButtonsStackArea = new javax.swing.GroupLayout(pnlHelperHandButtonsStackArea);
gl_helperHandButtonsStackArea.setHorizontalGroup(
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
// .addGap(0)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
// .addGap(0)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
)
.addGap(0)
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)))
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlShortCuts, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(stackObjects, 410, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
)
)
.addGap(0)
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)))
);
gl_helperHandButtonsStackArea.setVerticalGroup(
gl_helperHandButtonsStackArea.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
//.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGap(2)
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(stackObjects, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
//.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_helperHandButtonsStackArea.createParallelGroup(Alignment.LEADING)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addGap(2)
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(stackObjects, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_helperHandButtonsStackArea.createSequentialGroup()
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
)
)
)
);
pnlHelperHandButtonsStackArea.setLayout(gl_helperHandButtonsStackArea);
@ -1977,11 +1976,11 @@ public final class GamePanel extends javax.swing.JPanel {
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE)
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
);
}
@ -2188,7 +2187,7 @@ public final class GamePanel extends javax.swing.JPanel {
public void installComponents() {
jLayeredPane.setOpaque(false);
jLayeredPane.add(abilityPicker);
jLayeredPane.add(abilityPicker, JLayeredPane.MODAL_LAYER);
jLayeredPane.add(DialogManager.getManager(gameId), JLayeredPane.MODAL_LAYER, 0);
abilityPicker.setVisible(false);
}
@ -2433,7 +2432,7 @@ class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
SessionHandler.nextPlay(gameId);
Thread.sleep(1000);
TimeUnit.SECONDS.sleep(1);
}
return null;
}

View file

@ -27,11 +27,6 @@
*/
package mage.client.remote;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.UUID;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.SessionHandler;
@ -49,19 +44,15 @@ import mage.client.util.object.SaveObjectUtil;
import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback;
import mage.utils.CompressUtil;
import mage.view.AbilityPickerView;
import mage.view.ChatMessage;
import mage.view.*;
import mage.view.ChatMessage.MessageType;
import mage.view.DeckView;
import mage.view.DraftClientMessage;
import mage.view.DraftView;
import mage.view.GameClientMessage;
import mage.view.GameEndView;
import mage.view.GameView;
import mage.view.TableClientMessage;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -79,38 +70,38 @@ public class CallbackClientImpl implements CallbackClient {
@Override
public synchronized void processCallback(final ClientCallback callback) {
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod().toString());
callback.setData(CompressUtil.decompress(callback.getData()));
SwingUtilities.invokeLater(() -> {
try {
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
switch (callback.getMethod()) {
case "startGame": {
case START_GAME: {
TableClientMessage message = (TableClientMessage) callback.getData();
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
gameStarted(message.getGameId(), message.getPlayerId());
break;
}
case "startTournament": {
case START_TOURNAMENT: {
TableClientMessage message = (TableClientMessage) callback.getData();
tournamentStarted(message.getGameId(), message.getPlayerId());
break;
}
case "startDraft": {
case START_DRAFT: {
TableClientMessage message = (TableClientMessage) callback.getData();
draftStarted(message.getGameId(), message.getPlayerId());
break;
}
case "replayGame":
case REPLAY_GAME:
replayGame(callback.getObjectId());
break;
case "showTournament":
case SHOW_TOURNAMENT:
showTournament(callback.getObjectId());
break;
case "watchGame":
case WATCHGAME:
watchGame(callback.getObjectId());
break;
case "chatMessage": {
case CHATMESSAGE: {
ChatMessage message = (ChatMessage) callback.getData();
// Drop messages from ignored users
@ -154,7 +145,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "serverMessage":
case SERVER_MESSAGE:
if (callback.getData() != null) {
ChatMessage message = (ChatMessage) callback.getData();
if (message.getColor() == ChatMessage.MessageColor.RED) {
@ -164,50 +155,50 @@ public class CallbackClientImpl implements CallbackClient {
}
}
break;
case "joinedTable": {
case JOINED_TABLE: {
TableClientMessage message = (TableClientMessage) callback.getData();
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
break;
}
case "replayInit": {
case REPLAY_INIT: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
break;
}
case "replayDone": {
case REPLAY_DONE: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData(), callback.getMessageId());
}
break;
}
case "replayUpdate": {
case REPLAY_UPDATE: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
break;
}
case "gameInit": {
case GAME_INIT: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
break;
}
case "gameOver": {
case GAME_OVER: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData(), callback.getMessageId());
}
break;
}
case "gameError":
case GAME_ERROR:
frame.showErrorDialog("Game Error", (String) callback.getData());
break;
case "gameAsk": {
case GAME_ASK: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
@ -215,7 +206,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gameTarget": // e.g. Pick triggered ability
case GAME_TARGET: // e.g. Pick triggered ability
{
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
@ -225,7 +216,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gameSelect": {
case GAME_SELECT: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
@ -233,14 +224,14 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gameChooseAbility": {
case GAME_CHOOSE_ABILITY: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickAbility((AbilityPickerView) callback.getData());
}
break;
}
case "gameChoosePile": {
case GAME_CHOOSE_PILE: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
@ -248,7 +239,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gameChooseChoice": {
case GAME_CHOOSE_CHOICE: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
@ -257,7 +248,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gamePlayMana": {
case GAME_PLAY_MANA: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
@ -265,7 +256,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gamePlayXMana": {
case GAME_PLAY_XMANA: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
@ -273,7 +264,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gameSelectAmount": {
case GAME_GET_AMOUNT: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
@ -281,23 +272,23 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "gameUpdate": {
case GAME_UPDATE: {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
break;
}
case "endGameInfo":
case END_GAME_INFO:
MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
break;
case "showUserMessage":
case SHOW_USERMESSAGE:
List<String> messageData = (List<String>) callback.getData();
if (messageData.size() == 2) {
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
}
break;
case "gameInform":
case GAME_INFORM:
if (callback.getMessageId() > gameInformMessageId) {
{
GameClientMessage message = (GameClientMessage) callback.getData();
@ -313,7 +304,7 @@ public class CallbackClientImpl implements CallbackClient {
}
gameInformMessageId = messageId;
break;
case "gameInformPersonal": {
case GAME_INFORM_PERSONAL: {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
@ -322,7 +313,7 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "sideboard": {
case SIDEBOARD: {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
@ -333,17 +324,17 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "construct": {
case CONSTRUCT: {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
construct(deck, message.getTableId(), message.getTime());
break;
}
case "draftOver":
case DRAFT_OVER:
MageFrame.removeDraft(callback.getObjectId());
break;
case "draftPick": {
case DRAFT_PICK: {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
@ -351,14 +342,14 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "draftUpdate": {
case DRAFT_UPDATE: {
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.updateDraft((DraftView) callback.getData());
}
break;
}
case "draftInform": // if (callback.getMessageId() > messageId) {
case DRAFT_INFORM: // if (callback.getMessageId() > messageId) {
{
DraftClientMessage message = (DraftClientMessage) callback.getData();
}
@ -366,7 +357,7 @@ public class CallbackClientImpl implements CallbackClient {
// logger.warn("message out of sequence - ignoring");
// }
break;
case "draftInit": {
case DRAFT_INIT: {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
@ -374,9 +365,9 @@ public class CallbackClientImpl implements CallbackClient {
}
break;
}
case "tournamentInit":
case TOURNAMENT_INIT:
break;
case "userRequestDialog":
case USER_REQUEST_DIALOG:
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
break;
}

View file

@ -34,17 +34,18 @@
package mage.client.table;
import java.io.IOException;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.SessionHandler;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.players.PlayerType;
import javax.swing.*;
import java.io.IOException;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TablePlayerPanel extends javax.swing.JPanel {
@ -52,38 +53,39 @@ public class TablePlayerPanel extends javax.swing.JPanel {
protected final PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
/** Creates new form TablePlayerPanel */
/**
* Creates new form TablePlayerPanel
*/
public TablePlayerPanel() {
initComponents();
this.newPlayerPanel.setVisible(false);
}
public void init(int playerNum, String playerType) {
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()) {
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
}
else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
} else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
cbPlayerType.setSelectedIndex(index);
}
}
if (playerType != null) {
this.cbPlayerType.setSelectedItem(playerType);
}
}
}
public boolean joinTable(UUID roomId, UUID tableId) throws IOException, ClassNotFoundException {
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
}
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (PlayerType) this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), "");
}
return true;
}
public String getPlayerType() {
return (String) this.cbPlayerType.getSelectedItem();
public PlayerType getPlayerType() {
return PlayerType.getByDescription(this.cbPlayerType.getSelectedItem().toString());
}
public void addPlayerTypeEventListener(Listener<Event> listener) {
@ -95,7 +97,8 @@ public class TablePlayerPanel extends javax.swing.JPanel {
}
/** This method is called from within the constructor to
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@ -119,38 +122,37 @@ public class TablePlayerPanel extends javax.swing.JPanel {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPlayerNum)
.addGroup(layout.createSequentialGroup()
.addComponent(lbPlayerType)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbPlayerType, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(newPlayerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE))
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblPlayerNum)
.addGroup(layout.createSequentialGroup()
.addComponent(lbPlayerType)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbPlayerType, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(newPlayerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblPlayerNum)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbPlayerType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbPlayerType)))
.addComponent(newPlayerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
.addContainerGap())
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblPlayerNum)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbPlayerType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbPlayerType)))
.addComponent(newPlayerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
if (getPlayerType() != PlayerType.HUMAN) {
this.newPlayerPanel.setVisible(true);
}
else {
} else {
this.newPlayerPanel.setVisible(false);
}
this.revalidate();

View file

@ -99,8 +99,8 @@ public class TablesPane extends MagePane {
tablesPanel = new mage.client.table.TablesPanel();
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tablesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
@ -110,12 +110,11 @@ public class TablesPane extends MagePane {
.addComponent(tablesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void initComponents(JComponent container) {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
@ -124,7 +123,6 @@ public class TablesPane extends MagePane {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
);
pack();
}
// Variables declaration - do not modify//GEN-BEGIN:variables

View file

@ -33,69 +33,21 @@
*/
package mage.client.table;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.beans.PropertyVetoException;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JToggleButton;
import javax.swing.RowFilter;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.chat.ChatPanelBasic;
import mage.client.components.MageComponents;
import mage.client.dialog.JoinTableDialog;
import mage.client.dialog.NewTableDialog;
import mage.client.dialog.NewTournamentDialog;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
import mage.client.dialog.TableWaitingDialog;
import static mage.client.table.TablesPanel.PASSWORDED;
import mage.client.dialog.*;
import mage.client.util.ButtonColumn;
import mage.client.util.GUISizeHelper;
import mage.client.util.IgnoreList;
import mage.client.util.MageTableRowSorter;
import mage.client.util.gui.GuiDisplayUtil;
import mage.client.util.gui.TableUtil;
import mage.constants.MatchTimeLimit;
import mage.constants.MultiplayerAttackOption;
import mage.constants.PlayerAction;
import mage.constants.RangeOfInfluence;
import mage.constants.SkillLevel;
import mage.constants.*;
import mage.game.match.MatchOptions;
import mage.players.PlayerType;
import mage.remote.MageRemoteException;
import mage.view.MatchView;
import mage.view.RoomUsersView;
@ -103,6 +55,25 @@ import mage.view.TableView;
import mage.view.UserRequestMessage;
import org.apache.log4j.Logger;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.beans.PropertyVetoException;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
import static mage.client.table.TablesPanel.PASSWORDED;
/**
*
* @author BetaSteward_at_googlemail.com
@ -216,7 +187,7 @@ public class TablesPanel extends javax.swing.JPanel {
if (PASSWORDED.equals(pwdColumn)) {
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
} else {
SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), "Human", 1, null, "");
SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), PlayerType.HUMAN, 1, null, "");
}
} else {
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
@ -1188,8 +1159,8 @@ public class TablesPanel extends javax.swing.JPanel {
}
MatchOptions options = new MatchOptions("1", "Two Player Duel", false, 2);
options.getPlayerTypes().add("Human");
options.getPlayerTypes().add("Computer - mad");
options.getPlayerTypes().add(PlayerType.HUMAN);
options.getPlayerTypes().add(PlayerType.COMPUTER_MAD);
options.setDeckType("Limited");
options.setAttackOption(MultiplayerAttackOption.LEFT);
options.setRange(RangeOfInfluence.ALL);
@ -1203,8 +1174,8 @@ public class TablesPanel extends javax.swing.JPanel {
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
table = SessionHandler.createTable(roomId, options);
SessionHandler.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"), "");
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"), "");
SessionHandler.joinTable(roomId, table.getTableId(), "Human", PlayerType.HUMAN, 1, DeckImporterUtil.importDeck("test.dck"), "");
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", PlayerType.COMPUTER_MAD, 5, DeckImporterUtil.importDeck("test.dck"), "");
SessionHandler.startMatch(roomId, table.getTableId());
} catch (HeadlessException ex) {
handleError(ex);
@ -1450,7 +1421,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
if (!tables.isEmpty()) {
this.publish(tables);
}
Thread.sleep(3000);
TimeUnit.SECONDS.sleep(3);
}
return null;
}
@ -1494,7 +1465,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
this.publish(SessionHandler.getRoomUsers(roomId));
Thread.sleep(3000);
TimeUnit.SECONDS.sleep(3);
}
return null;
}
@ -1636,7 +1607,7 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
if (!matches.isEmpty()) {
this.publish(matches);
}
Thread.sleep(10000);
TimeUnit.SECONDS.sleep(10);
}
return null;
}

View file

@ -36,6 +36,7 @@ package mage.client.table;
import mage.cards.decks.DeckCardLists;
import mage.client.SessionHandler;
import mage.players.PlayerType;
import javax.swing.*;
import java.util.UUID;
@ -68,8 +69,8 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
roomId,
tableId,
this.txtPlayerName.getText(),
(String)this.cbPlayerType.getSelectedItem(),
(Integer)spnLevel.getValue(),
(PlayerType) this.cbPlayerType.getSelectedItem(),
(Integer) spnLevel.getValue(),
deckCardLists,
"");
}

View file

@ -83,8 +83,8 @@ public class TournamentPane extends MagePane {
tournamentPanel = new mage.client.tournament.TournamentPanel();
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tournamentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 758, Short.MAX_VALUE)
@ -94,7 +94,6 @@ public class TournamentPane extends MagePane {
.addComponent(tournamentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 526, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables

View file

@ -44,13 +44,12 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import mage.cards.o.Opt;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.chat.ChatPanelBasic;
@ -730,7 +729,7 @@ class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
this.publish(SessionHandler.getTournament(tournamentId));
Thread.sleep(2000);
TimeUnit.SECONDS.sleep(2);
}
return null;
}

View file

@ -1,7 +1,8 @@
package mage.client.util.audio;
import java.io.File;
import java.awt.List;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.sound.sampled.*;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
@ -75,7 +76,7 @@ public class MusicPlayer {
player.breaked_out = true;
player.breaked = true;
try {
Thread.sleep(100);
TimeUnit.MILLISECONDS.sleep(100);
} catch (Exception e) {
log.error("Thread error: " + e);
}
@ -119,7 +120,7 @@ public class MusicPlayer {
public void run() {
try {
Thread.sleep(100);
TimeUnit.MILLISECONDS.sleep(100);
} catch (Exception e) {
}
while (!stopped) {
@ -130,7 +131,7 @@ public class MusicPlayer {
PlayThread.start();
while (!(breaked || breaked_out)) {
try {
Thread.sleep(10);
TimeUnit.MILLISECONDS.sleep(10);
} catch (Exception e) {
log.error("Thread error: " + e);
}

View file

@ -3,6 +3,7 @@ package mage.client.util.gui;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.util.concurrent.TimeUnit;
/**
* Utility class for creating BufferedImage object from Image instance.
@ -65,7 +66,7 @@ public class BufferedImageBuilder {
});
while (!imageLoadStatus.widthDone && !imageLoadStatus.heightDone) {
try {
Thread.sleep(300);
TimeUnit.MILLISECONDS.sleep(300);
} catch (InterruptedException e) {
}
@ -73,8 +74,9 @@ public class BufferedImageBuilder {
}
static class ImageLoadStatus {
public boolean widthDone = false;
public boolean heightDone = false;
}
}
}

View file

@ -1,24 +1,8 @@
package mage.client.util.gui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsConfiguration;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import mage.client.MageFrame;
import mage.client.util.GUISizeHelper;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.utils.CardUtil;
import mage.constants.*;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
@ -26,6 +10,10 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
public final class GuiDisplayUtil {
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
@ -280,9 +268,9 @@ public final class GuiDisplayUtil {
buffer.append("</td></tr></table>");
String pt = "";
if (CardUtil.isCreature(card)) {
if (card.isCreature()) {
pt = card.getPower() + '/' + card.getToughness();
} else if (CardUtil.isPlaneswalker(card)) {
} else if (card.isPlanesWalker()) {
pt = card.getLoyalty();
}
@ -360,8 +348,8 @@ public final class GuiDisplayUtil {
private static String getTypes(CardView card) {
String types = "";
for (String superType : card.getSuperTypes()) {
types += superType + ' ';
for (SuperType superType : card.getSuperTypes()) {
types += superType.toString() + ' ';
}
for (CardType cardType : card.getCardTypes()) {
types += cardType.toString() + ' ';

View file

@ -3,6 +3,7 @@ package mage.client.util.stats;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import org.apache.log4j.Logger;
@ -29,7 +30,7 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
while (!isCancelled()) {
float memUsage = MemoryUsageStatUtil.getMemoryFreeStatPercentage();
this.publish(memUsage >= 0 ? memUsage : null);
Thread.sleep(MEM_USAGE_UPDATE_TIME);
TimeUnit.MILLISECONDS.sleep(MEM_USAGE_UPDATE_TIME);
}
return null;
}

View file

@ -1,27 +1,5 @@
package org.mage.card.arcane;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import mage.cards.MagePermanent;
import mage.cards.TextPopup;
import mage.cards.action.ActionCallback;
@ -31,6 +9,7 @@ import mage.client.plugins.impl.Plugins;
import mage.client.util.audio.AudioManager;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.constants.SuperType;
import mage.view.AbilityView;
import mage.view.CardView;
import mage.view.PermanentView;
@ -38,6 +17,14 @@ import mage.view.StackAbilityView;
import org.apache.log4j.Logger;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Main class for drawing Mage card object.
*
@ -680,8 +667,8 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
protected final String getType(CardView card) {
StringBuilder sbType = new StringBuilder();
for (String superType : card.getSuperTypes()) {
sbType.append(superType).append(' ');
for (SuperType superType : card.getSuperTypes()) {
sbType.append(superType.toString()).append(' ');
}
for (CardType cardType : card.getCardTypes()) {
@ -713,9 +700,9 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
if (card.getColor().hasColor()) {
sb.append('\n').append(card.getColor().toString());
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
sb.append('\n').append(card.getPower()).append('/').append(card.getToughness());
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
sb.append('\n').append(card.getLoyalty());
}
if (card.getRules() == null) {

View file

@ -9,7 +9,6 @@ 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;
import mage.view.CounterView;
import mage.view.PermanentView;
@ -232,9 +231,9 @@ public class CardPanelComponentImpl extends CardPanel {
// PT Text
ptText = new GlowText();
if (CardUtil.isCreature(gameCard)) {
if (gameCard.isCreature()) {
ptText.setText(gameCard.getPower() + '/' + gameCard.getToughness());
} else if (CardUtil.isPlaneswalker(gameCard)) {
} else if (gameCard.isPlanesWalker()) {
ptText.setText(gameCard.getLoyalty());
}
// ptText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
@ -424,7 +423,7 @@ public class CardPanelComponentImpl extends CardPanel {
imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
if (hasSickness() && CardUtil.isCreature(gameCard) && isPermanent()) {
if (hasSickness() && gameCard.isCreature() && isPermanent()) {
overlayPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
overlayPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
} else {
@ -571,11 +570,11 @@ public class CardPanelComponentImpl extends CardPanel {
super.update(card);
// Update card text
if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) {
if (card.isCreature() && card.isPlanesWalker()) {
ptText.setText(card.getPower() + '/' + card.getToughness() + " (" + card.getLoyalty() + ')');
} else if (CardUtil.isCreature(card)) {
} else if (card.isCreature()) {
ptText.setText(card.getPower() + '/' + card.getToughness());
} else if (CardUtil.isPlaneswalker(card)) {
} else if (card.isPlanesWalker()) {
ptText.setText(card.getLoyalty());
} else {
ptText.setText("");
@ -583,7 +582,7 @@ public class CardPanelComponentImpl extends CardPanel {
setText(card);
// Summoning Sickness overlay
if (hasSickness() && CardUtil.isCreature(gameCard) && isPermanent()) {
if (hasSickness() && card.isCreature() && isPermanent()) {
overlayPanel.setVisible(true);
} else {
overlayPanel.setVisible(false);

View file

@ -3,6 +3,7 @@ package org.mage.card.arcane;
import com.google.common.collect.MapMaker;
import mage.cards.action.ActionCallback;
import mage.constants.CardType;
import mage.constants.SuperType;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
@ -157,7 +158,7 @@ public class CardPanelRenderImpl extends CardPanel {
for (CardType type : this.view.getCardTypes()) {
sb.append((char) type.ordinal());
}
for (String s : this.view.getSuperTypes()) {
for (SuperType s : this.view.getSuperTypes()) {
sb.append(s);
}
for (String s : this.view.getSubTypes()) {
@ -216,12 +217,16 @@ public class CardPanelRenderImpl extends CardPanel {
}
}
// Map of generated images
private final static Map<ImageKey, BufferedImage> IMAGE_CACHE = new MapMaker().softValues().makeMap();
// The art image for the card, loaded in from the disk
private BufferedImage artImage;
// Factory to generate card appropriate views
private CardRendererFactory cardRendererFactory = new CardRendererFactory();
// The rendered card image, with or without the art image loaded yet
// = null while invalid
private BufferedImage cardImage;
@ -232,7 +237,7 @@ public class CardPanelRenderImpl extends CardPanel {
super(newGameCard, gameId, loadImage, callback, foil, dimension);
// Renderer
cardRenderer = new ModernCardRenderer(gameCard, isTransformed());
cardRenderer = cardRendererFactory.create(gameCard, isTransformed());
// Draw the parts
initialDraw();
@ -268,6 +273,10 @@ public class CardPanelRenderImpl extends CardPanel {
g.drawImage(cardImage, getCardXOffset(), getCardYOffset(), null);
}
/**
* Create an appropriate card renderer for the
*/
/**
* Render the card to a new BufferedImage at it's current dimensions
*
@ -358,7 +367,7 @@ public class CardPanelRenderImpl extends CardPanel {
// Update renderer
cardImage = null;
cardRenderer = new ModernCardRenderer(gameCard, isTransformed());
cardRenderer = cardRendererFactory.create(gameCard, isTransformed());
cardRenderer.setArtImage(artImage);
// Repaint

View file

@ -5,23 +5,22 @@
*/
package org.mage.card.arcane;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import mage.cards.ArtRect;
import mage.client.dialog.PreferencesDialog;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.utils.CardUtil;
import mage.constants.SuperType;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.RasterFormatException;
import java.util.ArrayList;
import java.util.List;
/**
* @author stravant@gmail.com
*
@ -125,20 +124,29 @@ public abstract class CardRenderer {
this.cardView = card;
this.isTransformed = isTransformed;
if (card.getArtRect() == ArtRect.SPLIT_FUSED) {
parseRules(card.getLeftSplitRules(), textboxKeywords, textboxRules);
parseRules(card.getRightSplitRules(), textboxKeywords, textboxRules);
} else {
parseRules(card.getRules(), textboxKeywords, textboxRules);
}
}
protected void parseRules(List<String> stringRules, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules) {
// Translate the textbox text
for (String rule : card.getRules()) {
for (String rule : stringRules) {
// Kill reminder text
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_REMINDER_TEXT, "false").equals("false")) {
rule = CardRendererUtils.killReminderText(rule).trim();
}
if (!rule.isEmpty()) {
TextboxRule tbRule = TextboxRuleParser.parse(card, rule);
TextboxRule tbRule = TextboxRuleParser.parse(cardView, rule);
if (tbRule.type == TextboxRuleType.SIMPLE_KEYWORD) {
textboxKeywords.add(tbRule);
keywords.add(tbRule);
} else if (tbRule.text.isEmpty()) {
// Nothing to do, rule is empty
} else {
textboxRules.add(tbRule);
rules.add(tbRule);
}
}
}
@ -227,7 +235,7 @@ public abstract class CardRenderer {
// Draw summoning sickness overlay, and possibly other overlays
protected void drawOverlays(Graphics2D g) {
if (CardUtil.isCreature(cardView) && cardView instanceof PermanentView) {
if (cardView.isCreature() && cardView instanceof PermanentView) {
if (((PermanentView) cardView).hasSummoningSickness()) {
int x1 = (int) (0.2 * cardWidth);
int x2 = (int) (0.8 * cardWidth);
@ -258,6 +266,39 @@ public abstract class CardRenderer {
}
}
protected void drawArtIntoRect(Graphics2D g, int x, int y, int w, int h, Rectangle2D artRect, boolean shouldPreserveAspect) {
// Perform a process to make sure that the art is scaled uniformly to fill the frame, cutting
// off the minimum amount necessary to make it completely fill the frame without "squashing" it.
double fullCardImgWidth = artImage.getWidth();
double fullCardImgHeight = artImage.getHeight();
double artWidth = artRect.getWidth() * fullCardImgWidth;
double artHeight = artRect.getHeight() * fullCardImgHeight;
double targetWidth = w;
double targetHeight = h;
double targetAspect = targetWidth / targetHeight;
if (!shouldPreserveAspect) {
// No adjustment to art
} else if (targetAspect * artHeight < artWidth) {
// Trim off some width
artWidth = targetAspect * artHeight;
} else {
// Trim off some height
artHeight = artWidth / targetAspect;
}
try {
BufferedImage subImg
= artImage.getSubimage(
(int) (artRect.getX() * fullCardImgWidth), (int) (artRect.getY() * fullCardImgHeight),
(int) artWidth, (int) artHeight);
g.drawImage(subImg,
x, y,
(int) targetWidth, (int) targetHeight,
null);
} catch (RasterFormatException e) {
// At very small card sizes we may encounter a problem with rounding error making the rect not fit
}
}
// Draw +1/+1 and other counters
protected void drawCounters(Graphics2D g) {
int xPos = (int) (0.65 * cardWidth);
@ -379,7 +420,7 @@ public abstract class CardRenderer {
}
} else {
StringBuilder sbType = new StringBuilder();
for (String superType : cardView.getSuperTypes()) {
for (SuperType superType : cardView.getSuperTypes()) {
sbType.append(superType).append(' ');
}
for (CardType cardType : cardView.getCardTypes()) {

View file

@ -0,0 +1,23 @@
package org.mage.card.arcane;
import mage.cards.ArtRect;
import mage.view.CardView;
/**
* Created by StravantUser on 2017-03-30.
*/
public class CardRendererFactory {
public CardRendererFactory() {
}
public CardRenderer create(CardView card, boolean isTransformed) {
if (card.isSplitCard() && card.getArtRect() != ArtRect.SPLIT_FUSED) {
// Split fused cards still render with the normal frame, showing all abilities
// from both halves in one frame.
return new ModernSplitCardRenderer(card, isTransformed);
} else {
return new ModernCardRenderer(card, isTransformed);
}
}
}

View file

@ -57,7 +57,7 @@ public final class CardRendererUtils {
// Draw a rounded box with a 2-pixel border
// Used on various card parts.
public static void drawRoundedBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Color fill) {
public static void drawRoundedBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Paint fill) {
g.setColor(new Color(0, 0, 0, 150));
g.drawOval(x - 1, y - 1, bevel * 2, h);
g.setPaint(border);
@ -67,7 +67,7 @@ public final class CardRendererUtils {
g.drawOval(x + 1 + w - bevel * 2, y + 1, bevel * 2 - 3, h - 3);
g.drawRect(x + bevel, y, w - 2 * bevel, h - 1);
g.drawRect(x + 1 + bevel, y + 1, w - 2 * bevel - 2, h - 3);
g.setColor(fill);
g.setPaint(fill);
g.fillOval(x + 2, y + 2, bevel * 2 - 4, h - 4);
g.fillOval(x + 2 + w - bevel * 2, y + 2, bevel * 2 - 4, h - 4);
g.fillRect(x + bevel, y + 2, w - 2 * bevel, h - 4);

View file

@ -6,9 +6,11 @@
package org.mage.card.arcane;
import mage.ObjectColor;
import mage.cards.ArtRect;
import mage.cards.FrameStyle;
import mage.client.dialog.PreferencesDialog;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.view.CardView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
@ -18,8 +20,8 @@ import java.awt.*;
import java.awt.font.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.RasterFormatException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
@ -73,10 +75,9 @@ public class ModernCardRenderer extends CardRenderer {
}
private static Font loadFont(String name) {
try {
try(InputStream in = ModernCardRenderer.class.getResourceAsStream("/cardrender/" + name + ".ttf")) {
return Font.createFont(
Font.TRUETYPE_FONT,
ModernCardRenderer.class.getResourceAsStream("/cardrender/" + name + ".ttf"));
Font.TRUETYPE_FONT,in);
} catch (IOException e) {
LOGGER.info("Failed to load font `" + name + "`, couldn't find resource.");
} catch (FontFormatException e) {
@ -311,7 +312,7 @@ public class ModernCardRenderer extends CardRenderer {
} else if (cardView.getFrameStyle().isFullArt() || (cardView.isToken())) {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .63f);
} else {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .42f);
rect = ArtRect.NORMAL.rect;
}
return rect;
}
@ -346,45 +347,42 @@ public class ModernCardRenderer extends CardRenderer {
@Override
protected void drawArt(Graphics2D g) {
if (artImage != null && !cardView.isFaceDown()) {
Rectangle2D artRect = getArtRect();
// Perform a process to make sure that the art is scaled uniformly to fill the frame, cutting
// off the minimum amount necessary to make it completely fill the frame without "squashing" it.
double fullCardImgWidth = artImage.getWidth();
double fullCardImgHeight = artImage.getHeight();
double artWidth = artRect.getWidth() * fullCardImgWidth;
double artHeight = artRect.getHeight() * fullCardImgHeight;
double targetWidth = contentWidth - 2;
double targetHeight = typeLineY - totalContentInset - boxHeight;
double targetAspect = targetWidth / targetHeight;
// Invention rendering, art fills the entire frame
if (useInventionFrame()) {
// No adjustment to art
} else if (targetAspect * artHeight < artWidth) {
// Trim off some width
artWidth = targetAspect * artHeight;
} else {
// Trim off some height
artHeight = artWidth / targetAspect;
drawArtIntoRect(g,
borderWidth, borderWidth,
cardWidth - 2*borderWidth, cardHeight - 2*borderWidth,
getArtRect(), false);
}
try {
BufferedImage subImg
= artImage.getSubimage(
(int) (artRect.getX() * fullCardImgWidth), (int) (artRect.getY() * fullCardImgHeight),
(int) artWidth, (int) artHeight);
if (useInventionFrame()) {
g.drawImage(subImg,
borderWidth, borderWidth,
cardWidth - 2 * borderWidth, cardHeight - 2 * borderWidth,
null);
} else {
g.drawImage(subImg,
boolean shouldPreserveAspect = true;
Rectangle2D sourceRect = getArtRect();
if (cardView.getMageObjectType() == MageObjectType.SPELL) {
ArtRect rect = cardView.getArtRect();
if (rect == ArtRect.SPLIT_FUSED) {
// Special handling for fused, draw the art from both halves stacked on top of one and other
// each filling half of the art rect
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight,
(int) targetWidth, (int) targetHeight,
null);
contentWidth - 2, (typeLineY - totalContentInset - boxHeight)/2,
ArtRect.SPLIT_LEFT.rect, useInventionFrame());
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight + (typeLineY - totalContentInset - boxHeight)/2,
contentWidth - 2, (typeLineY - totalContentInset - boxHeight)/2,
ArtRect.SPLIT_RIGHT.rect, useInventionFrame());
return;
} else if (rect != ArtRect.NORMAL) {
sourceRect = rect.rect;
shouldPreserveAspect = false;
}
} catch (RasterFormatException e) {
// At very small card sizes we may encounter a problem with rounding error making the rect not fit
}
// Normal drawing of art from a source part of the card frame into the rect
drawArtIntoRect(g,
totalContentInset + 1, totalContentInset + boxHeight,
contentWidth - 2, typeLineY - totalContentInset - boxHeight,
sourceRect, shouldPreserveAspect);
}
}
@ -427,7 +425,7 @@ public class ModernCardRenderer extends CardRenderer {
contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
// If it's a planeswalker, extend the textbox left border by some
if (cardView.getCardTypes().contains(CardType.PLANESWALKER)) {
if (cardView.isPlanesWalker()) {
g.setPaint(borderPaint);
g.fillRect(
totalContentInset, typeLineY + boxHeight,
@ -478,17 +476,17 @@ public class ModernCardRenderer extends CardRenderer {
int nameOffset = drawTransformationCircle(g, borderPaint);
// Draw the name line
drawNameLine(g,
drawNameLine(g, cardView.getDisplayName(), manaCostString,
totalContentInset + nameOffset, totalContentInset,
contentWidth - nameOffset, boxHeight);
// Draw the type line
drawTypeLine(g,
drawTypeLine(g, getCardTypeLine(),
totalContentInset, typeLineY,
contentWidth, boxHeight);
// Draw the textbox rules
drawRulesText(g,
drawRulesText(g, textboxKeywords, textboxRules,
totalContentInset + 2, typeLineY + boxHeight + 2,
contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3);
@ -497,13 +495,13 @@ public class ModernCardRenderer extends CardRenderer {
}
// Draw the name line
protected void drawNameLine(Graphics2D g, int x, int y, int w, int h) {
protected void drawNameLine(Graphics2D g, String baseName, String manaCost, int x, int y, int w, int h) {
// Width of the mana symbols
int manaCostWidth;
if (cardView.isAbility()) {
manaCostWidth = 0;
} else {
manaCostWidth = CardRendererUtils.getManaCostWidth(manaCostString, boxTextHeight);
manaCostWidth = CardRendererUtils.getManaCostWidth(manaCost, boxTextHeight);
}
// Available width for name. Add a little bit of slop so that one character
@ -519,7 +517,7 @@ public class ModernCardRenderer extends CardRenderer {
nameStr = "Morph: " + cardView.getName();
}
} else {
nameStr = cardView.getName();
nameStr = baseName;
}
if (!nameStr.isEmpty()) {
AttributedString str = new AttributedString(nameStr);
@ -541,12 +539,12 @@ public class ModernCardRenderer extends CardRenderer {
// Draw the mana symbols
if (!cardView.isAbility() && !cardView.isFaceDown()) {
ManaSymbols.draw(g, manaCostString, x + w - manaCostWidth, y + boxTextOffset, boxTextHeight);
ManaSymbols.draw(g, manaCost, x + w - manaCostWidth, y + boxTextOffset, boxTextHeight);
}
}
// Draw the type line (color indicator, types, and expansion symbol)
protected void drawTypeLine(Graphics2D g, int x, int y, int w, int h) {
protected void drawTypeLine(Graphics2D g, String baseTypeLine, int x, int y, int w, int h) {
// Draw expansion symbol
int expansionSymbolWidth;
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_SET_SYMBOL, "false").equals("false")) {
@ -561,7 +559,7 @@ public class ModernCardRenderer extends CardRenderer {
// Draw type line text
int availableWidth = w - expansionSymbolWidth + 1;
String types = getCardTypeLine();
String types = baseTypeLine;
g.setFont(boxTextFont);
// Replace "Legendary" in type line if there's not enough space
@ -583,7 +581,7 @@ public class ModernCardRenderer extends CardRenderer {
if (breakIndex > 0) {
TextLayout layout = measure.getLayout(0, breakIndex);
g.setColor(getBoxTextColor());
layout.draw(g, x, y + boxTextOffset + boxTextHeight - 1);
layout.draw(g, x, y + (h - boxTextHeight) / 2 + boxTextHeight - 1);
}
}
}
@ -603,7 +601,7 @@ public class ModernCardRenderer extends CardRenderer {
// Is it a creature?
boolean isVehicle = cardView.getSubTypes().contains("Vehicle");
if (cardView.getCardTypes().contains(CardType.CREATURE) || isVehicle) {
if (cardView.isCreature() || isVehicle) {
int x = cardWidth - borderWidth - partWidth;
// Draw PT box
@ -623,7 +621,7 @@ public class ModernCardRenderer extends CardRenderer {
// Draw text
Color textColor;
if (isVehicle) {
boolean isAnimated = !(cardView instanceof PermanentView) || cardView.getCardTypes().contains(CardType.CREATURE);
boolean isAnimated = !(cardView instanceof PermanentView) || cardView.isCreature();
if (isAnimated) {
textColor = Color.white;
} else {
@ -646,7 +644,7 @@ public class ModernCardRenderer extends CardRenderer {
// Is it a walker? (But don't draw the box if it's a non-permanent view
// of a walker without a starting loyalty (EG: Arlin Kord's flipped side).
if (cardView.getCardTypes().contains(CardType.PLANESWALKER)
if (cardView.isPlanesWalker()
&& (cardView instanceof PermanentView || !cardView.getStartingLoyalty().equals("0"))) {
// Draw the PW loyalty box
int w = partWidth;
@ -760,19 +758,19 @@ public class ModernCardRenderer extends CardRenderer {
return layout;
}
protected void drawRulesText(Graphics2D g, int x, int y, int w, int h) {
protected void drawRulesText(Graphics2D g, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules, int x, int y, int w, int h) {
// Gather all rules to render
List<TextboxRule> allRules = new ArrayList<>(textboxRules);
List<TextboxRule> allRules = new ArrayList<>(rules);
// Add the keyword rule if there are any keywords
if (!textboxKeywords.isEmpty()) {
String keywordRulesString = getKeywordRulesString();
if (!keywords.isEmpty()) {
String keywordRulesString = getKeywordRulesString(keywords);
TextboxRule keywordsRule = new TextboxRule(keywordRulesString, new ArrayList<>());
allRules.add(0, keywordsRule);
}
// Basic mana draw mana symbol in textbox (for basic lands)
if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.getCardTypes().contains(CardType.LAND)) {
if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.isLand()) {
drawBasicManaTextbox(g, x, y, w, h, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
return;
}
@ -828,11 +826,11 @@ public class ModernCardRenderer extends CardRenderer {
}
// Get the first line of the textbox, the keyword string
private String getKeywordRulesString() {
private static String getKeywordRulesString(ArrayList<TextboxRule> keywords) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < textboxKeywords.size(); ++i) {
builder.append(textboxKeywords.get(i).text);
if (i != textboxKeywords.size() - 1) {
for (int i = 0; i < keywords.size(); ++i) {
builder.append(keywords.get(i).text);
if (i != keywords.size() - 1) {
builder.append(", ");
}
}

View file

@ -0,0 +1,326 @@
package org.mage.card.arcane;
import mage.ObjectColor;
import mage.abilities.costs.mana.ManaCosts;
import mage.cards.ArtRect;
import mage.constants.CardType;
import mage.view.CardView;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
/**
* Created by StravantUser on 2017-03-30.
*/
public class ModernSplitCardRenderer extends ModernCardRenderer {
private class HalfCardProps {
int x, y, w, h, cw, ch;
String name;
String typeLineString;
String manaCostString;
ObjectColor color;
ArrayList<TextboxRule> rules = new ArrayList<>();
ArrayList<TextboxRule> keywords = new ArrayList<>();
}
private static ArrayList<CardType> ONLY_LAND_TYPE = new ArrayList<CardType>() {{add(CardType.LAND);}};
// Right and left halves of the card content
private HalfCardProps rightHalf = new HalfCardProps();
private HalfCardProps leftHalf = new HalfCardProps();
// Where and how big is the divider between the card halves
private int dividerAt;
private int dividerSize;
// Is fuse / aftermath
private boolean isFuse = false;
private boolean isAftermath = false;
public ModernSplitCardRenderer(CardView view, boolean isTransformed) {
super(view, isTransformed);
rightHalf.manaCostString = ManaSymbols.getStringManaCost(cardView.getRightSplitCosts().getSymbols());
leftHalf.manaCostString = ManaSymbols.getStringManaCost(cardView.getLeftSplitCosts().getSymbols());
rightHalf.color = getColorFromManaCostHack(cardView.getRightSplitCosts());
leftHalf.color = getColorFromManaCostHack(cardView.getLeftSplitCosts());
parseRules(view.getRightSplitRules(), rightHalf.keywords, rightHalf.rules);
parseRules(view.getLeftSplitRules(), leftHalf.keywords, leftHalf.rules);
rightHalf.typeLineString = cardView.getRightSplitTypeLine();
leftHalf.typeLineString = cardView.getLeftSplitTypeLine();
rightHalf.name = cardView.getRightSplitName();
leftHalf.name = cardView.getLeftSplitName();
isFuse = view.getRules().stream().anyMatch(rule -> rule.contains("Fuse"));
isAftermath = view.getRightSplitRules().stream().anyMatch(rule -> rule.contains("Aftermath"));
// It's easier for rendering to swap the card halves here because for aftermath cards
// they "rotate" in opposite directions making consquence and normal split cards
// have the "right" vs "left" as the top half.
if (!isAftermath()) {
HalfCardProps tmp = leftHalf;
leftHalf = rightHalf;
rightHalf = tmp;
}
}
private boolean isAftermath() {
return isAftermath;
}
private boolean isFuse() {
return isFuse;
}
@Override
protected void layout(int cardWidth, int cardHeight) {
// Pass to parent
super.layout(cardWidth, cardHeight);
// Decide size of divider
if (isAftermath()) {
dividerSize = borderWidth;
dividerAt = (int)(cardHeight*0.54);
} else {
int availHeight = cardHeight - totalContentInset - 3*borderWidth;
dividerSize = borderWidth*2;
dividerAt = (int)(totalContentInset + availHeight * 0.5 - borderWidth);
}
// Decide size of each halves box
rightHalf.x = leftHalf.x = totalContentInset;
rightHalf.w = leftHalf.w = cardWidth - 2*totalContentInset;
leftHalf.y = totalContentInset;
leftHalf.h = dividerAt - totalContentInset;
rightHalf.y = dividerAt + dividerSize;
rightHalf.h = cardHeight - rightHalf.y - borderWidth*3;
// Content width / height (Exchanged from width / height if the card part is rotated)
if (isAftermath()) {
leftHalf.cw = leftHalf.w;
leftHalf.ch = leftHalf.h;
} else {
leftHalf.cw = leftHalf.h;
leftHalf.ch = leftHalf.w;
}
rightHalf.cw = rightHalf.h;
rightHalf.ch = rightHalf.w;
// Fuse space
if (isFuse()) {
rightHalf.ch -= boxHeight;
leftHalf.ch -= boxHeight;
}
}
// Ugly hack used here because the card database doesn't actually store color
// for each half of split cards separately.
private ObjectColor getColorFromManaCostHack(ManaCosts costs) {
ObjectColor c = new ObjectColor();
List<String> symbols = costs.getSymbols();
for (String symbol: symbols) {
if (symbol.contains("W")) {
c.setWhite(true);
} else if (symbol.contains("U")) {
c.setBlue(true);
} else if (symbol.contains("B")) {
c.setBlack(true);
} else if (symbol.contains("R")) {
c.setRed(true);
} else if (symbol.contains("G")) {
c.setGreen(true);
}
}
return c;
}
@Override
protected void drawBackground(Graphics2D g) {
if (cardView.isFaceDown()) {
drawCardBack(g);
} else {
{ // Left half background (top of the card)
// Set texture to paint the left with
g.setPaint(getBackgroundPaint(leftHalf.color, cardView.getCardTypes(), cardView.getSubTypes()));
// Draw main part (most of card)
g.fillRoundRect(
borderWidth, borderWidth,
cardWidth - 2*borderWidth, leftHalf.h + contentInset - borderWidth - 2*cornerRadius + (cornerRadius - 1),
cornerRadius - 1, cornerRadius - 1);
// Draw the M15 rounded "swoosh" at the bottom
g.fillRoundRect(
borderWidth, dividerAt - borderWidth - 4*cornerRadius,
cardWidth - 2*borderWidth, cornerRadius * 4,
cornerRadius * 2, cornerRadius * 2);
// Draw the cutout into the "swoosh" for the textbox to lie over
g.fillRect(
borderWidth + contentInset, dividerAt - 2*borderWidth,
cardWidth - borderWidth * 2 - contentInset * 2, borderWidth * 2);
}
{ // Right half background (bottom half of the card)
// Set texture to paint the right with
g.setPaint(getBackgroundPaint(rightHalf.color, cardView.getCardTypes(), cardView.getSubTypes()));
// Draw the M15 rounded "swoosh"es at the top and bottom
g.fillRoundRect(
borderWidth, dividerAt + dividerSize + borderWidth,
cardWidth - 2*borderWidth, rightHalf.h - 2*borderWidth,
cornerRadius*2, cornerRadius*2);
// Draw the cutout into the "swoosh" for the textbox to lie over
g.fillRect(
borderWidth + contentInset, dividerAt + dividerSize,
cardWidth - borderWidth * 2 - contentInset * 2, rightHalf.h);
}
}
}
@Override
protected void drawArt(Graphics2D g) {
if (artImage != null && !cardView.isFaceDown()) {
if (isAftermath()) {
Rectangle2D topRect = ArtRect.AFTERMATH_TOP.rect;
int topLineY = (int) (leftHalf.ch * TYPE_LINE_Y_FRAC);
drawArtIntoRect(g,
leftHalf.x, leftHalf.y + boxHeight, leftHalf.cw, topLineY - boxHeight,
topRect, false);
Rectangle2D bottomRect = ArtRect.AFTERMATH_BOTTOM.rect;
int bottomLineY = (rightHalf.ch - boxHeight) / 2;
drawArtIntoRect(g,
rightHalf.x + rightHalf.w - bottomLineY, rightHalf.y, bottomLineY - boxHeight, rightHalf.h,
bottomRect, false);
} else {
// NOTE: Art rects are reversed here, that is on purpose because we swap the left / right half
// of split cards for rendering for consistency between aftermath and normal split
Rectangle2D topRect = ArtRect.SPLIT_RIGHT.rect;
int topLineY = (int) (leftHalf.ch * TYPE_LINE_Y_FRAC);
drawArtIntoRect(g,
leftHalf.x + boxHeight, leftHalf.y, topLineY - boxHeight, leftHalf.h,
topRect, false);
Rectangle2D bottomRect = ArtRect.SPLIT_LEFT.rect;
int bottomLineY = (int) (rightHalf.ch * TYPE_LINE_Y_FRAC);
drawArtIntoRect(g,
rightHalf.x + boxHeight, rightHalf.y, bottomLineY - boxHeight, rightHalf.h,
bottomRect, false);
}
}
}
protected void drawSplitHalfFrame(Graphics2D g, HalfCardProps half, int typeLineY) {
// Get the border paint
Color boxColor = getBoxColor(half.color, cardView.getCardTypes(), isTransformed);
Paint textboxPaint = getTextboxPaint(half.color, cardView.getCardTypes(), cardWidth);
Paint borderPaint = getBorderPaint(half.color, cardView.getCardTypes(), cardWidth);
// Draw main frame
g.setPaint(borderPaint);
g.drawRect(
0, 0,
half.cw - 1, half.ch - 1);
// Background of textbox
g.setPaint(textboxPaint);
g.fillRect(
1, typeLineY,
half.cw - 2, half.ch - typeLineY - 1);
// Draw the name line box
CardRendererUtils.drawRoundedBox(g,
-borderWidth, 0,
half.cw + 2 * borderWidth, boxHeight,
contentInset,
borderPaint, boxColor);
// Draw the type line box
CardRendererUtils.drawRoundedBox(g,
-borderWidth, typeLineY,
half.cw + 2 * borderWidth, boxHeight - 4,
contentInset,
borderPaint, boxColor);
// Draw the name line
drawNameLine(g, half.name, half.manaCostString,
0, 0,
half.cw, boxHeight);
// Draw the type line
drawTypeLine(g, half.typeLineString,
0, typeLineY,
half.cw, boxHeight - 4);
// Draw the textbox rules
drawRulesText(g, half.keywords, half.rules,
2, typeLineY + boxHeight + 2 - 4,
half.cw - 4, half.ch - typeLineY - boxHeight);
}
private Graphics2D getUnmodifiedHalfContext(Graphics2D g) {
Graphics2D g2 = (Graphics2D)g.create();
g2.translate(leftHalf.x, leftHalf.y);
return g2;
}
private Graphics2D getAftermathHalfContext(Graphics2D g) {
Graphics2D g2 = (Graphics2D)g.create();
g2.translate(rightHalf.x, rightHalf.y);
g2.rotate(Math.PI / 2);
g2.translate(0, -rightHalf.w);
return g2;
}
private Graphics2D getLeftHalfContext(Graphics2D g) {
Graphics2D g2 = (Graphics2D)g.create();
g2.translate(leftHalf.x, leftHalf.y);
g2.rotate(-Math.PI / 2);
g2.translate(-leftHalf.cw, 0);
return g2;
}
private Graphics2D getRightHalfContext(Graphics2D g) {
Graphics2D g2 = (Graphics2D)g.create();
g2.translate(rightHalf.x, rightHalf.y);
g2.rotate(-Math.PI / 2);
g2.translate(-rightHalf.cw, 0);
return g2;
}
@Override
protected void drawFrame(Graphics2D g) {
if (isAftermath()) {
drawSplitHalfFrame(getUnmodifiedHalfContext(g), leftHalf, (int)(leftHalf.ch * TYPE_LINE_Y_FRAC));
drawSplitHalfFrame(getAftermathHalfContext(g), rightHalf, (rightHalf.ch - boxHeight) / 2);
} else {
drawSplitHalfFrame(getLeftHalfContext(g), leftHalf, (int)(leftHalf.ch * TYPE_LINE_Y_FRAC));
drawSplitHalfFrame(getRightHalfContext(g), rightHalf, (int)(rightHalf.ch * TYPE_LINE_Y_FRAC));
if (isFuse()) {
Graphics2D g2 = getRightHalfContext(g);
int totalFuseBoxWidth = rightHalf.cw * 2 + 2 * borderWidth + dividerSize;
Paint boxColor = getTextboxPaint(cardView.getColor(), ONLY_LAND_TYPE, totalFuseBoxWidth);
Paint borderPaint = getBorderPaint(cardView.getColor(), ONLY_LAND_TYPE, totalFuseBoxWidth);
CardRendererUtils.drawRoundedBox(g2,
-borderWidth, rightHalf.ch,
totalFuseBoxWidth, boxHeight,
contentInset,
borderPaint, boxColor);
drawNameLine(g2, "Fuse (You may cast both halves from your hand)", "",
0, rightHalf.ch,
totalFuseBoxWidth - 2*borderWidth, boxHeight);
}
}
}
}

View file

@ -74,6 +74,9 @@ public class TextboxRule {
private final List<AttributeRegion> regions;
protected TextboxRule(String text, List<AttributeRegion> regions, TextboxRuleType type) {
if (text.isEmpty()) {
throw new IllegalArgumentException("Empty rule");
}
this.text = text;
this.type = type;
this.regions = regions;

View file

@ -13,6 +13,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.view.CardView;
import org.apache.log4j.Logger;
import org.apache.log4j.jmx.LoggerDynamicMBean;
/**
*

View file

@ -11,20 +11,21 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.swing.SwingUtilities;
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public final class Util {
public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase().contains("windows");
public static final ThreadPoolExecutor threadPool;
static private int threadCount;
static {
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
public Thread newThread(Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "Util" + threadCount);
thread.setDaemon(true);
@ -34,14 +35,14 @@ public final class Util {
threadPool.prestartAllCoreThreads();
}
public static void broadcast (byte[] data, int port) throws IOException {
public static void broadcast(byte[] data, int port) throws IOException {
DatagramSocket socket = new DatagramSocket();
broadcast(socket, data, port, NetworkInterface.getNetworkInterfaces());
socket.close();
}
private static void broadcast (DatagramSocket socket, byte[] data, int port, Enumeration<NetworkInterface> ifaces)
throws IOException {
private static void broadcast(DatagramSocket socket, byte[] data, int port, Enumeration<NetworkInterface> ifaces)
throws IOException {
for (NetworkInterface iface : Collections.list(ifaces)) {
for (InetAddress address : Collections.list(iface.getInetAddresses())) {
if (!address.isSiteLocalAddress()) {
@ -57,14 +58,14 @@ public final class Util {
}
}
public static void sleep (int millis) {
public static void sleep(int millis) {
try {
Thread.sleep(millis);
TimeUnit.MILLISECONDS.sleep(millis);
} catch (InterruptedException ignored) {
}
}
public static boolean classExists (String className) {
public static boolean classExists(String className) {
try {
Class.forName(className);
return true;
@ -73,7 +74,7 @@ public final class Util {
}
}
public static void wait (Object lock) {
public static void wait(Object lock) {
synchronized (lock) {
try {
lock.wait();
@ -82,7 +83,7 @@ public final class Util {
}
}
public static void invokeAndWait (Runnable runnable) {
public static void invokeAndWait(Runnable runnable) {
try {
SwingUtilities.invokeAndWait(runnable);
} catch (Exception ex) {

View file

@ -1,20 +1,5 @@
package org.mage.plugins.card;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLayeredPane;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
import mage.client.dialog.PreferencesDialog;
@ -30,10 +15,7 @@ import net.xeoh.plugins.base.annotations.events.Init;
import net.xeoh.plugins.base.annotations.events.PluginLoaded;
import net.xeoh.plugins.base.annotations.meta.Author;
import org.apache.log4j.Logger;
import org.mage.card.arcane.Animation;
import org.mage.card.arcane.CardPanel;
import org.mage.card.arcane.CardPanelComponentImpl;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.*;
import org.mage.plugins.card.dl.DownloadGui;
import org.mage.plugins.card.dl.DownloadJob;
import org.mage.plugins.card.dl.Downloader;
@ -43,7 +25,15 @@ import org.mage.plugins.card.dl.sources.GathererSets;
import org.mage.plugins.card.dl.sources.GathererSymbols;
import org.mage.plugins.card.images.ImageCache;
import org.mage.plugins.card.info.CardInfoPaneImpl;
import org.mage.card.arcane.CardPanelRenderImpl;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* {@link CardPlugin} implementation.
@ -108,14 +98,14 @@ public class CardPluginImpl implements CardPlugin {
cardWidthMin = (int) GUISizeHelper.battlefieldCardMinDimension.getWidth();
cardWidthMax = (int) GUISizeHelper.battlefieldCardMaxDimension.getWidth();
}
/**
* Temporary card rendering shim. Split card rendering isn't implemented yet, so
* use old component based rendering for the split cards.
* Temporary card rendering shim. Split card rendering isn't implemented
* yet, so use old component based rendering for the split cards.
*/
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension) {
String fallback = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false");
if (view.isSplitCard() || fallback.equals("true")) {
if (fallback.equals("true")) {
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
} else {
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
@ -584,7 +574,7 @@ public class CardPluginImpl implements CardPlugin {
Animation.showCard(card, count > 0 ? count : 1);
try {
while ((card).getAlpha() + 0.05f < 1) {
Thread.sleep(30);
TimeUnit.MILLISECONDS.sleep(30);
}
} catch (Exception e) {
e.printStackTrace();
@ -598,7 +588,7 @@ public class CardPluginImpl implements CardPlugin {
Animation.hideCard(card, count > 0 ? count : 1);
try {
while ((card).getAlpha() - 0.05f > 0) {
Thread.sleep(30);
TimeUnit.MILLISECONDS.sleep(30);
}
} catch (Exception e) {
e.printStackTrace();

View file

@ -29,6 +29,7 @@ package org.mage.plugins.card.dl.sources;
import java.io.IOException;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
@ -1697,7 +1698,7 @@ public class GrabbagImageSource implements CardImageSource {
public void doPause(String httpImageUrl) {
if (!httpImageUrl.startsWith("/MTG")) {
try {
Thread.sleep(2000);
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException ex) {
}
}

View file

@ -86,13 +86,14 @@ public class MythicspoilerComSource implements CardImageSource {
cardNameAliases.put("THS-soldierofpantheon", "soldierofthepantheon");
cardNameAliases.put("THS-vulpinegolaith", "vulpinegoliath");
cardNameAliases.put("ORI-kothopedhoarderofsouls", "kothophedsoulhoarder");
cardNameAliases.put("BFZ-unisonstrike", "tandemtactics");
cardNameAliases.put("BFZ-eldrazidevastator", "eldrazidevastator");
cardNameAliases.put("BFZ-kozliekschanneler", "kozilekschanneler");
cardNameAliases.put("OGW-wastes", "wastes1");
cardNameAliases.put("OGW-wastes2", "wastes2");
cardNameAliases.put("AER-locketofmyths", "lifecraftersbestiary");
cardNameAliases.put("AER-aegisautomation", "aegisautomaton");
cardNameAliases.put("AKH-illusorywrappins", "illusorywrappings");
cardNameAliases.put("AKH-reducerumble", "reducerubble");
cardNameAliases.put("AKH-forsakethewordly", "forsaketheworldly");
cardNameAliases.put("AKH-kefnatsmonument", "kefnetsmonument");
cardNameAliasesStart = new HashMap<>();
HashSet<String> names = new HashSet<>();
@ -182,14 +183,9 @@ public class MythicspoilerComSource implements CardImageSource {
if (cardNameAliases.containsKey(cardSet + '-' + cardName)) {
cardName = cardNameAliases.get(cardSet + '-' + cardName);
} else if (cardName.endsWith("1") || cardName.endsWith("2") || cardName.endsWith("3") || cardName.endsWith("4") || cardName.endsWith("5")) {
if (!cardName.startsWith("forest")
&& !cardName.startsWith("swamp")
&& !cardName.startsWith("mountain")
&& !cardName.startsWith("island")
&& !cardName.startsWith("plains")) {
cardName = cardName.substring(0, cardName.length() - 1);
}
cardName = cardName.substring(0, cardName.length() - 1);
} else if (cardName.endsWith("promo")) {
cardName = cardName.substring(0, cardName.length() - 5);
}
pageLinks.put(cardName, baseUrl + cardLink);
}
@ -213,7 +209,8 @@ public class MythicspoilerComSource implements CardImageSource {
.replaceAll(" ", "")
.replaceAll("-", "")
.replaceAll("'", "")
.replaceAll(",", "");
.replaceAll(",", "")
.replaceAll("/", "");
String link = setLinks.get(searchName);
return link;
}

View file

@ -24,8 +24,7 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package org.mage.plugins.card.dl.sources;
import java.io.BufferedReader;
@ -41,6 +40,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import mage.client.MageFrame;
import mage.client.dialog.PreferencesDialog;
@ -271,12 +271,12 @@ public class WizardCardsImageSource implements CardImageSource {
public String getNextHttpImageUrl() {
return null;
}
@Override
public String getFileForHttpImage(String httpImageUrl) {
return null;
}
private Map<String, String> getSetLinks(String cardSet) {
ConcurrentHashMap<String, String> setLinks = new ConcurrentHashMap<>();
ExecutorService executor = Executors.newFixedThreadPool(10);
@ -289,7 +289,7 @@ public class WizardCardsImageSource implements CardImageSource {
int firstMultiverseIdLastPage = 0;
Pages:
while (page < 999) {
String searchUrl = "http://gatherer.wizards.com/Pages/Search/Default.aspx?page=" + page +"&output=spoiler&method=visual&action=advanced&set=+[%22" + URLSetName + "%22]";
String searchUrl = "http://gatherer.wizards.com/Pages/Search/Default.aspx?page=" + page + "&output=spoiler&method=visual&action=advanced&set=+[%22" + URLSetName + "%22]";
Document doc = getDocument(searchUrl);
Elements cardsImages = doc.select("img[src^=../../Handlers/]");
if (cardsImages.isEmpty()) {
@ -320,7 +320,7 @@ public class WizardCardsImageSource implements CardImageSource {
while (!executor.isTerminated()) {
try {
Thread.sleep(1000);
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException ie) {
}
}
@ -339,7 +339,7 @@ public class WizardCardsImageSource implements CardImageSource {
int proxyPort = Integer.parseInt(prefs.get("proxyPort", "0"));
URL url = new URL(urlString);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyServer, proxyPort));
HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);
HttpURLConnection uc = (HttpURLConnection) url.openConnection(proxy);
uc.connect();
@ -359,7 +359,7 @@ public class WizardCardsImageSource implements CardImageSource {
Document landDoc = getDocument(urlLandDocument);
Elements variations = landDoc.select("a.variationlink");
Map<String, String> links = new HashMap<>();
if(!variations.isEmpty()) {
if (!variations.isEmpty()) {
int landNumber = 1;
for (Element variation : variations) {
Integer landMultiverseId = Integer.parseInt(variation.attr("onclick").replaceAll("[^\\d]", ""));
@ -374,7 +374,7 @@ public class WizardCardsImageSource implements CardImageSource {
}
private static String generateLink(int landMultiverseId) {
return "/Handlers/Image.ashx?multiverseid=" +landMultiverseId + "&type=card";
return "/Handlers/Image.ashx?multiverseid=" + landMultiverseId + "&type=card";
}
private int getLocalizedMultiverseId(String preferedLanguage, Integer multiverseId) throws IOException {
@ -396,7 +396,7 @@ public class WizardCardsImageSource implements CardImageSource {
Document cardLanguagesDoc = getDocument(cardLanguagesUrl);
Elements languageTableRows = cardLanguagesDoc.select("tr.cardItem");
HashMap<String, Integer> localizedIds = new HashMap<>();
if(!languageTableRows.isEmpty()) {
if (!languageTableRows.isEmpty()) {
for (Element languageTableRow : languageTableRows) {
Elements languageTableColumns = languageTableRow.select("td");
Integer localizedId = Integer.parseInt(languageTableColumns.get(0).select("a").first().attr("href").replaceAll("[^\\d]", ""));
@ -408,14 +408,14 @@ public class WizardCardsImageSource implements CardImageSource {
}
private String normalizeName(String name) {
//Split card
if(name.contains("//")) {
name = name.substring(0, name.indexOf('(') - 1);
}
//Special timeshifted name
if(name.startsWith("XX")) {
name = name.substring(name.indexOf('(') + 1, name.length() - 1);
}
//Split card
if (name.contains("//")) {
name = name.substring(0, name.indexOf('(') - 1);
}
//Special timeshifted name
if (name.startsWith("XX")) {
name = name.substring(name.indexOf('(') + 1, name.length() - 1);
}
return name.replace("\u2014", "-").replace("\u2019", "'")
.replace("\u00C6", "AE").replace("\u00E6", "ae")
.replace("\u00C3\u2020", "AE")
@ -445,7 +445,7 @@ public class WizardCardsImageSource implements CardImageSource {
if (link == null) {
int length = collectorId.length();
if (Character.isLetter(collectorId.charAt(length -1))) {
if (Character.isLetter(collectorId.charAt(length - 1))) {
length -= 1;
}
@ -507,17 +507,17 @@ public class WizardCardsImageSource implements CardImageSource {
}
}
@Override
public int getTotalImages() {
return -1;
}
@Override
public boolean isTokenSource() {
return false;
}
@Override
public void doPause(String httpImageUrl) {
}

View file

@ -1,5 +1,22 @@
package org.mage.plugins.card.images;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import java.nio.file.AccessDeniedException;
import java.util.*;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.FileImageOutputStream;
import javax.swing.*;
import mage.cards.repository.CardInfo;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
@ -15,23 +32,6 @@ import org.mage.plugins.card.dl.sources.*;
import org.mage.plugins.card.properties.SettingsManager;
import org.mage.plugins.card.utils.CardImageUtils;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.FileImageOutputStream;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import java.nio.file.AccessDeniedException;
import java.util.*;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
public class DownloadPictures extends DefaultBoundedRangeModel implements Runnable {
private static final Logger logger = Logger.getLogger(DownloadPictures.class);
@ -316,7 +316,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
List<CardDownloadData> cardsToDownload = Collections.synchronizedList(new ArrayList<>());
allCardsUrls.parallelStream().forEach(card -> {
TFile file = new TFile(CardImageUtils.generateImagePath(card));
logger.debug(card.getName() + " (is_token=" + card.isToken() + "). Image is here:" + file.getAbsolutePath() + " (exists=" + file.exists() +')');
logger.debug(card.getName() + " (is_token=" + card.isToken() + "). Image is here:" + file.getAbsolutePath() + " (exists=" + file.exists() + ')');
if (!file.exists()) {
logger.debug("Missing: " + file.getAbsolutePath());
cardsToDownload.add(card);
@ -345,9 +345,8 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
return list;
}
try(InputStreamReader input = new InputStreamReader(in);
BufferedReader reader = new BufferedReader(input)) {
try (InputStreamReader input = new InputStreamReader(in);
BufferedReader reader = new BufferedReader(input)) {
String line = reader.readLine();
while (line != null) {
@ -486,7 +485,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
executor.shutdown();
while (!executor.isTerminated()) {
try {
Thread.sleep(1000);
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException ie) {
}
}

View file

@ -1,3 +1,52 @@
|Generate|TOK:AKH|Angel of Sanctions||
|Generate|TOK:AKH|Anointer Priest||
|Generate|TOK:AKH|Aven Initiate||
|Generate|TOK:AKH|Aven Wind Guide||
|Generate|TOK:AKH|Beast||
|Generate|TOK:AKH|Cat||
|Generate|TOK:AKH|Drake||
|Generate|TOK:AKH|Glyph Keeper||
|Generate|TOK:AKH|Heart-Piercer Manticore||
|Generate|TOK:AKH|Hippo||
|Generate|TOK:AKH|Honored Hydra||
|Generate|TOK:AKH|Insect||
|Generate|TOK:AKH|Labyrinth Guardian||
|Generate|TOK:AKH|Oketra's Attendant||
|Generate|TOK:AKH|Sacred Cat||
|Generate|TOK:AKH|Snake||
|Generate|TOK:AKH|Tah-Crop Skirmisher||
|Generate|TOK:AKH|Temmet, Vizier of Naktamun||
|Generate|TOK:AKH|Trueheart Duelist||
|Generate|TOK:AKH|Unwavering Initiate||
|Generate|TOK:AKH|Vizier of Many Faces||
|Generate|TOK:AKH|Warrior||
|Generate|TOK:AKH|Wurm||
|Generate|TOK:AKH|Zombie||
|Generate|EMBLEM!:AKH|Emblem Gideon||
|Generate|TOK:MM3|Angel||
|Generate|TOK:MM3|Beast|1|
|Generate|TOK:MM3|Beast|2|
|Generate|TOK:MM3|Bird||
|Generate|TOK:MM3|Centaur||
|Generate|TOK:MM3|Dragon||
|Generate|TOK:MM3|Elemental||
|Generate|TOK:MM3|Elephant||
|Generate|TOK:MM3|Giant Warrior||
|Generate|TOK:MM3|Goblin||
|Generate|TOK:MM3|Goblin Warrior||
|Generate|TOK:MM3|Golem||
|Generate|TOK:MM3|Ooze||
|Generate|TOK:MM3|Saproling||
|Generate|TOK:MM3|Soldier|1|
|Generate|TOK:MM3|Soldier|2|
|Generate|TOK:MM3|Spider||
|Generate|TOK:MM3|Spirit||
|Generate|TOK:MM3|Wurm||
|Generate|TOK:MM3|Zombie||
|Generate|EMBLEM!:MM3|Emblem Domri||
|Generate|TOK:C16|Beast||
|Generate|TOK:C16|Bird|1|
|Generate|TOK:C16|Bird|2|

View file

@ -74,6 +74,6 @@ dd3evg=ddaevg
dd3gvl=ddagvl
dd3jvc=ddajvc
# Remove setname as soon as the images can be downloaded
ignore.urls=TOK,PCA,DDS,ANB,AKH,HOU
ignore.urls=TOK,PCA,ANB,HOU
# sets ordered by release time (newest goes first)
token.lookup.order=ANB,HOU,MM3,DDS,AKH,DD3DVD,DD3EVG,DD3GVL,DD3JVC,H09,AER,PCA,C16,V16,MPS,KLD,DDR,CN2,EMN,EMA,SOI,DDQ,CP,CMA,ARENA,SUS,APAC,EURO,UGIN,C15,OGW,EXP,DDP,BFZ,DRB,V09,V10,V11,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC

View file

@ -1,5 +1,8 @@
package mage.client.game;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import mage.client.components.MageUI;
import mage.interfaces.MageClient;
import mage.interfaces.callback.ClientCallback;
@ -10,9 +13,6 @@ import mage.utils.MageVersion;
import org.apache.log4j.Logger;
import org.junit.Ignore;
import javax.swing.*;
import java.util.concurrent.CountDownLatch;
/**
* Test for emulating the connection from multi mage clients.
*
@ -30,7 +30,7 @@ public class MultiConnectTest {
private static final CountDownLatch latch = new CountDownLatch(USER_CONNECT_COUNT);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static volatile int connected;
@ -116,7 +116,7 @@ public class MultiConnectTest {
private void sleep(int ms) {
try {
Thread.sleep(ms);
TimeUnit.MILLISECONDS.sleep(ms);
} catch (Exception e) {
e.printStackTrace();
}

View file

@ -1,13 +1,13 @@
package mage.client.game;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import mage.client.MageFrame;
import mage.client.components.MageComponents;
import mage.client.components.MageUI;
import org.apache.log4j.Logger;
import org.junit.Ignore;
import javax.swing.*;
/**
* @author ayratn
*/
@ -68,7 +68,7 @@ public class StartMultiGamesTest {
private void sleep(int ms) {
try {
Thread.sleep(ms);
TimeUnit.MILLISECONDS.sleep(ms);
} catch (Exception e) {
e.printStackTrace();
}

View file

@ -1,27 +0,0 @@
package mage.client.util;
import mage.client.deckeditor.table.CardHelper;
import mage.constants.CardType;
import mage.view.CardView;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
/**
* Created by IGOUDT on 3-3-2017.
*/
public class CardHelperTest {
@Test
public void testCardTypeOrder() {
CardView v = new CardView(true);
v.getCardTypes().add(CardType.CREATURE);
v.getCardTypes().add(CardType.ARTIFACT);
String cardtypeText = CardHelper.getType(v);
Assert.assertThat(cardtypeText, is("Artifact Creature"));
}
}

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-common</artifactId>

View file

@ -1,11 +1,13 @@
package mage.cards;
import java.util.List;
import mage.view.PermanentView;
import java.util.List;
public abstract class MagePermanent extends MageCard {
private static final long serialVersionUID = -3469258620601702171L;
public abstract List<MagePermanent> getLinks();
public abstract void update(PermanentView card);
public abstract PermanentView getOriginalPermanent();
}

View file

@ -27,10 +27,6 @@
*/
package mage.interfaces;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import mage.MageException;
import mage.cards.decks.DeckCardLists;
import mage.cards.repository.CardInfo;
@ -40,15 +36,15 @@ import mage.constants.PlayerAction;
import mage.game.GameException;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.players.PlayerType;
import mage.players.net.UserData;
import mage.utils.MageVersion;
import mage.view.DraftPickView;
import mage.view.GameView;
import mage.view.MatchView;
import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.TournamentView;
import mage.view.UserView;
import mage.view.*;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
/**
*
@ -94,9 +90,9 @@ public interface MageServer {
TableView createTournamentTable(String sessionId, UUID roomId, TournamentOptions tournamentOptions) throws MageException;
boolean joinTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean joinTable(String sessionId, UUID roomId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;

View file

@ -28,15 +28,15 @@
package mage.interfaces;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import mage.players.PlayerType;
import mage.utils.MageVersion;
import mage.view.GameTypeView;
import mage.view.TournamentTypeView;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -44,7 +44,7 @@ public class ServerState implements Serializable {
private final List<GameTypeView> gameTypes;
private final List<TournamentTypeView> tournamentTypes;
private final String[] playerTypes;
private final PlayerType[] playerTypes;
private final String[] deckTypes;
private final String[] draftCubes;
private final boolean testMode;
@ -53,7 +53,7 @@ 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,
PlayerType[] playerTypes, String[] deckTypes, String[] draftCubes, boolean testMode,
MageVersion version, long cardsContentVersion, long expansionsContentVersion) {
this.gameTypes = gameTypes;
this.tournamentTypes = tournamentTypes;
@ -81,7 +81,7 @@ public class ServerState implements Serializable {
return tournamentTypes;
}
public String[] getPlayerTypes() {
public PlayerType[] getPlayerTypes() {
return playerTypes;
}

View file

@ -39,18 +39,18 @@ public class ClientCallback implements Serializable {
private UUID objectId;
private Object data;
private String method;
private ClientCallbackMethod method;
private int messageId;
public ClientCallback() {}
public ClientCallback(String method, UUID objectId, Object data) {
public ClientCallback(ClientCallbackMethod method, UUID objectId, Object data) {
this.method = method;
this.objectId = objectId;
this.data = data;
}
public ClientCallback(String method, UUID objectId) {
public ClientCallback(ClientCallbackMethod method, UUID objectId) {
this(method, objectId, null);
}
@ -75,11 +75,11 @@ public class ClientCallback implements Serializable {
this.data = data;
}
public String getMethod() {
public ClientCallbackMethod getMethod() {
return method;
}
public void setMethod(String method) {
public void setMethod(ClientCallbackMethod method) {
this.method = method;
}

View file

@ -0,0 +1,46 @@
package mage.interfaces.callback;
/**
* Created by IGOUDT on 4-4-2017.
*/
public enum ClientCallbackMethod {
CHATMESSAGE("chatMessage"),
TOURNAMENT_INIT("tournamentInit"),
TOURNAMENT_UPDATE("tournamentUpdate"),
TOURNAMENT_OVER("tournamentOver"),
JOINED_TABLE("joinedTable"),
START_DRAFT("startDraft"),
START_TOURNAMENT("startTournament"),
SIDEBOARD("sideboard"),
CONSTRUCT("construct"),
SHOW_USERMESSAGE("showUserMessage"),
WATCHGAME("watchGame"),
REPLAY_GAME("replayGame"),
START_GAME("startGame"),
SHOW_TOURNAMENT("showTournament"),
SHOW_GAME_END_DIALOG("showGameEndDialog"),
SERVER_MESSAGE("serverMessage"),
GAME_INIT("gameInit"),
GAME_OVER("gameOver"),
GAME_INFORM("gameInform"),
GAME_INFORM_PERSONAL("gameInformPersonal"),
GAME_ERROR("gameError"),
GAME_UPDATE("gameUpdate"),
DRAFT_OVER("draftOver"),
REPLAY_DONE("replayDone"),
USER_REQUEST_DIALOG("userRequestDialog"),
REPLAY_UPDATE("replayUpdate"),
REPLAY_INIT("replayInit"),
END_GAME_INFO("endGameInfo"),
GAME_TARGET("gameTarget"),
GAME_CHOOSE_ABILITY("gameChooseAbility"),
GAME_CHOOSE_PILE("gameChoosePile"),
GAME_CHOOSE_CHOICE("gameChooseChoice"), GAME_ASK("gameAsk"), GAME_SELECT("gameSelect"), GAME_PLAY_MANA("gamePlayMana"), GAME_PLAY_XMANA("gamePlayXMana"), GAME_GET_AMOUNT("gameSelectAmount"), DRAFT_INIT("draftInit"), DRAFT_INFORM("draftInform"), DRAFT_PICK("draftPick"), DRAFT_UPDATE("draftUpdate");
String value;
ClientCallbackMethod(String value){
this.value = value;
}
}

View file

@ -56,6 +56,7 @@ public class Connection {
private int clientCardDatabaseVersion;
private boolean forceDBComparison;
private String userIdStr;
private int socketWriteTimeout;
private UserData userData;
@ -76,6 +77,7 @@ public class Connection {
public Connection(String parameter) {
this.parameter = parameter;
socketWriteTimeout = 10000;
}
@Override
@ -258,6 +260,24 @@ public class Connection {
return null;
}
public static String getMAC() throws SocketException {
StringBuilder allMACs = new StringBuilder();
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements();) {
NetworkInterface iface = interfaces.nextElement();
byte[] mac = iface.getHardwareAddress();
if (mac != null) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
sb.append(';');
allMACs.append(sb.toString());
}
}
return allMACs.toString();
}
public void setUserData(UserData userData) {
this.userData = userData;
}
@ -273,4 +293,8 @@ public class Connection {
public void setForceDBComparison(boolean forceDBComparison) {
this.forceDBComparison = forceDBComparison;
}
public int getSocketWriteTimeout() {
return socketWriteTimeout;
}
}

View file

@ -32,8 +32,7 @@ import java.lang.reflect.UndeclaredThrowableException;
import java.net.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import javax.swing.JOptionPane;
import javax.swing.*;
import mage.MageException;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException;
@ -50,6 +49,7 @@ import mage.interfaces.MageClient;
import mage.interfaces.MageServer;
import mage.interfaces.ServerState;
import mage.interfaces.callback.ClientCallback;
import mage.players.PlayerType;
import mage.players.net.UserData;
import mage.utils.CompressUtil;
import mage.view.*;
@ -219,34 +219,35 @@ 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());
@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;
}
} 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 Optional<String> getServerHostname() {
return isConnected() ? Optional.of(connection.getHost()) : Optional.<String>empty();
}
@ -304,14 +305,14 @@ public class SessionImpl implements Session {
to a value greater than 1, an invocation interrupted by a write timeout can be retried.
Note. The write timeout facility applies to writing of both invocations and responses. It applies to push callbacks as well.
*/
metadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
metadata.put(SocketWrapper.WRITE_TIMEOUT, String.valueOf(connection.getSocketWriteTimeout()));
metadata.put("generalizeSocketException", "true");
server = (MageServer) TransporterClient.createTransporterClient(clientLocator.getLocatorURI(), MageServer.class, metadata);
// http://docs.jboss.org/jbossremoting/docs/guide/2.5/html_single/#d0e1057
Map<String, String> clientMetadata = new HashMap<>();
clientMetadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
clientMetadata.put(SocketWrapper.WRITE_TIMEOUT, String.valueOf(connection.getSocketWriteTimeout()));
/* generalizeSocketException
* If set to false, a failed invocation will be retried in the case of
* SocketExceptions. If set to true, a failed invocation will be retried in the case of
@ -472,7 +473,7 @@ 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) {
@ -550,7 +551,7 @@ public class SessionImpl implements Session {
}
@Override
public String[] getPlayerTypes() {
public PlayerType[] getPlayerTypes() {
return serverState.getPlayerTypes();
}
@ -680,7 +681,7 @@ public class SessionImpl implements Session {
}
@Override
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
public boolean joinTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password) {
try {
if (isConnected()) {
// Workaround to fix Can't join table problem
@ -703,7 +704,7 @@ public class SessionImpl implements Session {
}
@Override
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password) {
try {
if (isConnected()) {
// Workaround to fix Can't join table problem
@ -966,7 +967,6 @@ public class SessionImpl implements Session {
return false;
}
@Override
public boolean joinGame(UUID gameId) {
try {

View file

@ -28,6 +28,8 @@
package mage.remote.interfaces;
import java.util.List;
import mage.players.PlayerType;
import mage.view.GameTypeView;
import mage.view.TournamentTypeView;
@ -36,7 +38,7 @@ import mage.view.TournamentTypeView;
*/
public interface GameTypes {
String[] getPlayerTypes();
PlayerType[] getPlayerTypes();
List<GameTypeView> getGameTypes();
List<GameTypeView> getTournamentGameTypes();

View file

@ -30,6 +30,7 @@ package mage.remote.interfaces;
import mage.cards.decks.DeckCardLists;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.players.PlayerType;
import mage.remote.MageRemoteException;
import mage.view.TableView;
import mage.view.TournamentView;
@ -64,13 +65,13 @@ public interface PlayerActions {
// boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId);
boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password);
boolean watchTable(UUID roomId, UUID tableId);
boolean watchTournamentTable(UUID tableId);
boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
boolean joinTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password);
Optional<TableView> getTable(UUID roomId, UUID tableId);

View file

@ -1,12 +1,12 @@
package mage.utils;
import java.util.List;
import mage.ObjectColor;
import mage.cards.Card;
import mage.cards.MagePermanent;
import mage.constants.CardType;
import mage.view.CardView;
import java.util.List;
/**
* Utility class for {@link CardView}
*
@ -21,17 +21,8 @@ public final class CardUtil {
private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*";
public static boolean isCreature(CardView card) {
return is(card, CardType.CREATURE);
}
public static boolean isPlaneswalker(CardView card) {
return is(card, CardType.PLANESWALKER);
}
public static boolean isLand(CardView card) {
return is(card, CardType.LAND);
}
public static boolean isCreature(MagePermanent card) {
return is(card.getOriginal(), CardType.CREATURE);
@ -49,14 +40,6 @@ public final class CardUtil {
return card.getCardTypes().contains(type);
}
public static boolean isBasicLand(Card card) {
return card.getSupertype().contains("Basic");
}
public static boolean isLand(Card card) {
return card.getCardType().contains(CardType.LAND);
}
public static int getColorIdentitySortValue(List<String> manaCost, ObjectColor originalColor, List<String> rules) {
ObjectColor color = new ObjectColor(originalColor);
for (String rule : rules) {

View file

@ -1,21 +1,14 @@
package mage.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import mage.Mana;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.interfaces.rate.RateCallback;
import mage.util.RandomUtil;
import java.util.*;
/**
* Builds deck from provided card pool.
*
@ -246,13 +239,13 @@ public final class DeckBuilder {
this.card = card;
int type;
if (card.getCardType().contains(CardType.CREATURE)) {
if (card.isCreature()) {
type = 10;
} else if (card.getSubtype(null).contains("Equipment")) {
type = 8;
} else if (card.getSubtype(null).contains("Aura")) {
type = 5;
} else if (card.getCardType().contains(CardType.INSTANT)) {
} else if (card.isInstant()) {
type = 7;
} else {
type = 6;

View file

@ -40,8 +40,8 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
*/
public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 22;
public final static String MAGE_VERSION_MINOR_PATCH = "V0";
public final static int MAGE_VERSION_PATCH = 23;
public final static String MAGE_VERSION_MINOR_PATCH = "V1";
public final static String MAGE_VERSION_INFO = "";
private final int major;

View file

@ -31,6 +31,7 @@ package mage.view;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.constants.CardType;
import mage.constants.SuperType;
import java.util.ArrayList;
import java.util.EnumSet;
@ -57,7 +58,7 @@ public class AbilityView extends CardView {
this.loyalty = "";
this.cardTypes = EnumSet.noneOf(CardType.class);
this.subTypes = new ArrayList<>();
this.superTypes = new ArrayList<>();
this.superTypes =EnumSet.noneOf(SuperType.class);
this.color = new ObjectColor();
this.manaCost = ability.getManaCosts().getSymbols();
}

View file

@ -28,20 +28,16 @@
package mage.view;
import java.util.*;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility;
import mage.abilities.costs.mana.ManaCosts;
import mage.cards.Card;
import mage.cards.FrameStyle;
import mage.cards.SplitCard;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.keyword.AftermathAbility;
import mage.cards.*;
import mage.constants.*;
import mage.counters.Counter;
import mage.counters.CounterType;
import mage.designations.Designation;
@ -72,7 +68,7 @@ public class CardView extends SimpleCardView {
protected String startingLoyalty;
protected EnumSet<CardType> cardTypes;
protected List<String> subTypes;
protected List<String> superTypes;
protected EnumSet<SuperType> superTypes;
protected ObjectColor color;
protected ObjectColor frameColor;
protected FrameStyle frameStyle;
@ -103,9 +99,13 @@ public class CardView extends SimpleCardView {
protected String leftSplitName;
protected ManaCosts leftSplitCosts;
protected List<String> leftSplitRules;
protected String leftSplitTypeLine;
protected String rightSplitName;
protected ManaCosts rightSplitCosts;
protected List<String> rightSplitRules;
protected String rightSplitTypeLine;
protected ArtRect artRect = ArtRect.NORMAL;
protected List<UUID> targets;
@ -183,14 +183,17 @@ public class CardView extends SimpleCardView {
this.alternateName = cardView.alternateName;
this.originalName = cardView.originalName;
this.artRect = cardView.artRect;
this.isSplitCard = cardView.isSplitCard;
this.leftSplitName = cardView.leftSplitName;
this.leftSplitCosts = cardView.leftSplitCosts;
this.leftSplitRules = null;
this.leftSplitTypeLine = cardView.leftSplitTypeLine;
this.rightSplitName = cardView.rightSplitName;
this.rightSplitCosts = cardView.rightSplitCosts;
this.rightSplitRules = null;
this.rightSplitTypeLine = cardView.rightSplitTypeLine;
this.targets = null;
@ -212,7 +215,6 @@ public class CardView extends SimpleCardView {
}
/**
*
* @param card
* @param game
* @param controlled is the card view created for the card controller - used
@ -223,8 +225,24 @@ public class CardView extends SimpleCardView {
this(card, game, controlled, false, false);
}
private static String getCardTypeLine(Game game, Card card) {
StringBuilder sbType = new StringBuilder();
for (SuperType superType : card.getSuperType()) {
sbType.append(superType).append(' ');
}
for (CardType cardType : card.getCardType()) {
sbType.append(cardType.toString()).append(' ');
}
if (!card.getSubtype(game).isEmpty()) {
sbType.append("- ");
for (String subType : card.getSubtype(game)) {
sbType.append(subType).append(' ');
}
}
return sbType.toString();
}
/**
*
* @param card
* @param game
* @param controlled is the card view created for the card controller - used
@ -284,13 +302,17 @@ public class CardView extends SimpleCardView {
SplitCard splitCard = null;
if (card.isSplitCard()) {
splitCard = (SplitCard) card;
rotate = true;
rotate = (((SplitCard) card).getSpellAbility().getSpellAbilityType()) != SpellAbilityType.SPLIT_AFTERMATH;
} else if (card instanceof Spell) {
switch (((Spell) card).getSpellAbility().getSpellAbilityType()) {
case SPLIT_FUSED:
splitCard = (SplitCard) ((Spell) card).getCard();
rotate = true;
break;
case SPLIT_AFTERMATH:
splitCard = (SplitCard) ((Spell) card).getCard();
rotate = false;
break;
case SPLIT_LEFT:
case SPLIT_RIGHT:
rotate = true;
@ -302,9 +324,11 @@ public class CardView extends SimpleCardView {
leftSplitName = splitCard.getLeftHalfCard().getName();
leftSplitCosts = splitCard.getLeftHalfCard().getManaCost();
leftSplitRules = splitCard.getLeftHalfCard().getRules(game);
leftSplitTypeLine = getCardTypeLine(game, splitCard.getLeftHalfCard());
rightSplitName = splitCard.getRightHalfCard().getName();
rightSplitCosts = splitCard.getRightHalfCard().getManaCost();
rightSplitRules = splitCard.getRightHalfCard().getRules(game);
rightSplitTypeLine = getCardTypeLine(game, splitCard.getRightHalfCard());
}
this.name = card.getImageName();
@ -349,7 +373,7 @@ public class CardView extends SimpleCardView {
this.toughness = Integer.toString(card.getToughness().getValue());
this.cardTypes = card.getCardType();
this.subTypes = card.getSubtype(game);
this.superTypes = card.getSupertype();
this.superTypes = card.getSuperType();
this.color = card.getColor(game);
this.transformable = card.isTransformable();
this.flipCard = card.isFlipCard();
@ -401,6 +425,31 @@ public class CardView extends SimpleCardView {
}
}
}
// Determine what part of the art to slice out for spells on the stack which originate
// from a split, fuse, or aftermath split card.
SpellAbilityType ty = spell.getSpellAbility().getSpellAbilityType();
if (ty == SpellAbilityType.SPLIT_RIGHT || ty == SpellAbilityType.SPLIT_LEFT || ty == SpellAbilityType.SPLIT_FUSED) {
// Needs a special art rect
if (ty == SpellAbilityType.SPLIT_FUSED) {
artRect = ArtRect.SPLIT_FUSED;
} else if (spell.getCard() != null) {
SplitCard wholeCard = ((SplitCardHalf) spell.getCard()).getParentCard();
Abilities<Ability> aftermathHalfAbilities = wholeCard.getRightHalfCard().getAbilities();
if (aftermathHalfAbilities.stream().anyMatch(ability -> ability instanceof AftermathAbility)) {
if (ty == SpellAbilityType.SPLIT_RIGHT) {
artRect = ArtRect.AFTERMATH_BOTTOM;
} else {
artRect = ArtRect.AFTERMATH_TOP;
}
} else if (ty == SpellAbilityType.SPLIT_RIGHT) {
artRect = ArtRect.SPLIT_RIGHT;
} else {
artRect = ArtRect.SPLIT_LEFT;
}
}
}
// show for modal spell, which mode was choosen
if (spell.getSpellAbility().isModal()) {
for (UUID modeId : spell.getSpellAbility().getModes().getSelectedModes()) {
@ -436,7 +485,7 @@ public class CardView extends SimpleCardView {
}
this.cardTypes = object.getCardType();
this.subTypes = object.getSubtype(null);
this.superTypes = object.getSupertype();
this.superTypes = object.getSuperType();
this.color = object.getColor(null);
this.manaCost = object.getManaCost().getSymbols();
this.convertedManaCost = object.getManaCost().convertedManaCost();
@ -520,7 +569,7 @@ public class CardView extends SimpleCardView {
this.startingLoyalty = "";
this.cardTypes = EnumSet.noneOf(CardType.class);
this.subTypes = new ArrayList<>();
this.superTypes = new ArrayList<>();
this.superTypes = EnumSet.noneOf(SuperType.class);
this.color = new ObjectColor();
this.frameColor = new ObjectColor();
this.frameStyle = FrameStyle.M15_NORMAL;
@ -567,7 +616,7 @@ public class CardView extends SimpleCardView {
this.startingLoyalty = "";
this.cardTypes = token.getCardType();
this.subTypes = token.getSubtype(null);
this.superTypes = token.getSupertype();
this.superTypes = token.getSuperType();
this.color = token.getColor(null);
this.frameColor = token.getFrameColor(null);
this.frameStyle = token.getFrameStyle();
@ -647,7 +696,7 @@ public class CardView extends SimpleCardView {
return subTypes;
}
public List<String> getSuperTypes() {
public EnumSet<SuperType> getSuperTypes() {
return superTypes;
}
@ -785,6 +834,10 @@ public class CardView extends SimpleCardView {
return leftSplitRules;
}
public String getLeftSplitTypeLine() {
return leftSplitTypeLine;
}
public String getRightSplitName() {
return rightSplitName;
}
@ -797,6 +850,14 @@ public class CardView extends SimpleCardView {
return rightSplitRules;
}
public String getRightSplitTypeLine() {
return rightSplitTypeLine;
}
public ArtRect getArtRect() {
return artRect;
}
public CardView getSecondCardFace() {
return this.secondCardFace;
}
@ -893,4 +954,78 @@ public class CardView extends SimpleCardView {
this.canAttack = canAttack;
}
public boolean isCreature() {
return cardTypes.contains(CardType.CREATURE);
}
public boolean isPlanesWalker() {
return cardTypes.contains(CardType.PLANESWALKER);
}
public String getColorText() {
if (getColor().getColorCount() == 0) {
return "Colorless";
} else if (getColor().getColorCount() > 1) {
return "Gold";
} else if (getColor().isBlack()) {
return "Black";
} else if (getColor().isBlue()) {
return "Blue";
} else if (getColor().isWhite()) {
return "White";
} else if (getColor().isGreen()) {
return "Green";
} else if (getColor().isRed()) {
return "Red";
}
return "";
}
public String getTypeText() {
StringBuilder type = new StringBuilder();
for (SuperType superType : getSuperTypes()) {
type.append(superType.toString());
type.append(' ');
}
for (CardType cardType : getCardTypes()) {
type.append(cardType.toString());
type.append(' ');
}
if (!getSubTypes().isEmpty()) {
type.append("- ");
for (String subType : getSubTypes()) {
type.append(subType);
type.append(' ');
}
}
if (type.length() > 0) {
// remove trailing space
type.deleteCharAt(type.length() - 1);
}
return type.toString();
}
public boolean isLand() {
return cardTypes.contains(CardType.LAND);
}
public boolean isInstant() {
return cardTypes.contains(CardType.INSTANT);
}
public boolean isSorcery() {
return cardTypes.contains(CardType.SORCERY);
}
public boolean isEnchantment() {
return cardTypes.contains(CardType.ENCHANTMENT);
}
public boolean isArtifact() {
return cardTypes.contains(CardType.ARTIFACT);
}
public boolean isTribal() {
return cardTypes.contains(CardType.TRIBAL);
}
}

View file

@ -27,10 +27,12 @@
*/
package mage.view;
import mage.game.Seat;
import mage.players.PlayerType;
import mage.players.net.UserData;
import java.io.Serializable;
import java.util.UUID;
import mage.game.Seat;
import mage.players.net.UserData;
/**
*
@ -43,7 +45,7 @@ public class SeatView implements Serializable {
private final String flagName;
private UUID playerId;
private final String playerName;
private final String playerType;
private final PlayerType playerType;
private final String history;
private final int generalRating;
private final int constructedRating;
@ -86,7 +88,7 @@ public class SeatView implements Serializable {
return playerName;
}
public String getPlayerType() {
public PlayerType getPlayerType() {
return playerType;
}

View file

@ -65,12 +65,12 @@ public class StackAbilityView extends CardView {
this.cardTypes = ability.getCardType();
this.subTypes = ability.getSubtype(game);
this.superTypes = ability.getSupertype();
this.superTypes = ability.getSuperType();
this.color = ability.getColor(game);
this.manaCost = ability.getManaCost().getSymbols();
this.cardTypes = ability.getCardType();
this.subTypes = ability.getSubtype(game);
this.superTypes = ability.getSupertype();
this.superTypes = ability.getSuperType();
this.color = ability.getColor(game);
this.manaCost = ability.getManaCost().getSymbols();
this.power = ability.getPower().toString();

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-counter-plugin</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-plugins</artifactId>

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<groupId>org.mage</groupId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-deck-constructed</artifactId>

View file

@ -27,11 +27,6 @@
*/
package mage.deck;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.CanBeYourCommanderAbility;
@ -42,11 +37,12 @@ import mage.cards.ExpansionSet;
import mage.cards.Sets;
import mage.cards.decks.Constructed;
import mage.cards.decks.Deck;
import mage.constants.CardType;
import mage.constants.SetType;
import mage.filter.FilterMana;
import mage.util.CardUtil;
import java.util.*;
/**
*
* @author Plopman
@ -146,8 +142,8 @@ public class Commander extends Constructed {
invalid.put("Commander", "Commander banned (" + commander.getName() + ')');
valid = false;
}
if ((!commander.getCardType().contains(CardType.CREATURE) || !commander.getSupertype().contains("Legendary"))
&& (!commander.getCardType().contains(CardType.PLANESWALKER) || !commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) {
if ((!commander.isCreature() || !commander.isLegendary())
&& (!commander.isPlaneswalker() || !commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) {
invalid.put("Commander", "Commander invalid (" + commander.getName() + ')');
valid = false;
}
@ -501,7 +497,7 @@ public class Commander extends Constructed {
thisMaxPower = Math.max(thisMaxPower, 1);
}
if (card.getCardType().contains(CardType.PLANESWALKER)) {
if (card.isPlaneswalker()) {
if (card.getName().toLowerCase().equals("jace, the mind sculptor")) {
thisMaxPower = Math.max(thisMaxPower, 6);
}
@ -511,7 +507,7 @@ public class Commander extends Constructed {
thisMaxPower = Math.max(thisMaxPower, 4);
}
if (card.getCardType().contains(CardType.LAND)) {
if (card.isLand()) {
thisMaxPower = 0;
}

View file

@ -40,6 +40,7 @@ public class DuelCommander extends Commander {
banned.add("Back to Basics");
banned.add("Black Lotus");
banned.add("Channel");
banned.add("Chrome Mox");
banned.add("Dig Through Time");
banned.add("Entomb");
banned.add("Fastbond");
@ -58,6 +59,7 @@ public class DuelCommander extends Commander {
banned.add("Mana Vault");
banned.add("Mind Twist");
banned.add("Mishras Workshop");
banned.add("Mox Diamond");
banned.add("Mox Emerald");
banned.add("Mox Jet");
banned.add("Mox Pearl");
@ -80,6 +82,7 @@ public class DuelCommander extends Commander {
banned.add("Treasure Cruise");
banned.add("Vampiric Tutor");
bannedCommander.add("Breya, Etherium Shaper");
bannedCommander.add("Derevi, Empyrial Tactician");
bannedCommander.add("Edric, Spymaster of Trest");
bannedCommander.add("Erayo, Soratami Ascendant");
@ -87,7 +90,7 @@ public class DuelCommander extends Commander {
bannedCommander.add("Oloro, Ageless Ascetic");
bannedCommander.add("Rofellos, Llanowar Emissary");
bannedCommander.add("Tasigur, the Golden Fang");
bannedCommander.add("Yisan, the Wanderer Bard");
bannedCommander.add("Vial Smasher the Fierce");
bannedCommander.add("Zur the Enchanter");
}

View file

@ -174,8 +174,8 @@ public class TinyLeaders extends Constructed {
}
return false;
}
if ((commander.getCardType().contains(CardType.CREATURE) && commander.getSupertype().contains("Legendary"))
|| (commander.getCardType().contains(CardType.PLANESWALKER) && commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) {
if ((commander.isCreature() && commander.isLegendary())
|| (commander.isPlaneswalker() && commander.getAbilities().contains(CanBeYourCommanderAbility.getInstance()))) {
if (!bannedCommander.contains(commander.getName())) {
FilterMana color = CardUtil.getColorIdentity(commander);
for (Card card : deck.getCards()) {

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-deck-limited</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-game-canadianhighlanderduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-game-commanderduel</artifactId>

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-game-commanderfreeforall</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-game-freeforall</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-game-momirduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-game-tinyleadersduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-game-twoplayerduel</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-player-ai-draftbot</artifactId>

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-player-ai-ma</artifactId>

View file

@ -1,6 +1,5 @@
package mage.player.ai.ma;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.keyword.HasteAbility;
@ -11,6 +10,8 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author ubeefx, nantuko
*/
@ -27,7 +28,7 @@ public final class ArtificialScoringSystem {
public static int getCardDefinitionScore(final Game game, final Card card) {
int value = 3; //TODO: add new rating system card value
if (card.getCardType().contains(CardType.LAND)) {
if (card.isLand()) {
int score = (int) ((value / 2.0f) * 50);
//TODO: check this for "any color" lands
//TODO: check this for dual and filter lands

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-player-ai</artifactId>

View file

@ -27,6 +27,10 @@
*/
package mage.player.ai;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import mage.MageObject;
import mage.Mana;
import mage.abilities.*;
@ -77,11 +81,6 @@ import mage.util.TournamentUtil;
import mage.util.TreeNode;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
/**
*
* suitable for two player games and some multiplayer games
@ -1480,6 +1479,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
switch (ability.getSpellAbilityType()) {
case SPLIT:
case SPLIT_FUSED:
case SPLIT_AFTERMATH:
MageObject object = game.getObject(ability.getSourceId());
if (object != null) {
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(object, game.getState().getZone(object.getId()), game);
@ -1608,7 +1608,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
int cardNum = 0;
while (deck.getCards().size() < 23 && sortedCards.size() > cardNum) {
Card card = sortedCards.get(cardNum);
if (!card.getSupertype().contains("Basic")) {
if (!card.isBasic()) {
deck.getCards().add(card);
deck.getSideboard().remove(card);
}

View file

@ -4,7 +4,6 @@ import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome;
import mage.target.Target;
@ -57,15 +56,15 @@ public final class RateCard {
return rate;
}
int type;
if (card.getCardType().contains(CardType.PLANESWALKER)) {
if (card.isPlaneswalker()) {
type = 15;
} else if (card.getCardType().contains(CardType.CREATURE)) {
} else if (card.isCreature()) {
type = 10;
} else if (card.getSubtype(null).contains("Equipment")) {
type = 8;
} else if (card.getSubtype(null).contains("Aura")) {
type = 5;
} else if (card.getCardType().contains(CardType.INSTANT)) {
} else if (card.isInstant()) {
type = 7;
} else {
type = 6;
@ -78,8 +77,7 @@ public final class RateCard {
}
private static int isRemoval(Card card) {
if (card.getSubtype(null).contains("Aura") || card.getCardType().contains(CardType.INSTANT)
|| card.getCardType().contains(CardType.SORCERY)) {
if (card.getSubtype(null).contains("Aura") || card.isInstant() || card.isSorcery()) {
for (Ability ability : card.getAbilities()) {
for (Effect effect : ability.getEffects()) {

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-server-plugins</artifactId>
<version>1.4.22</version>
<version>1.4.23</version>
</parent>
<artifactId>mage-player-ai-mcts</artifactId>

Some files were not shown because too many files have changed in this diff Show more