mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
[refactoring][minor] Replaced all tabs with four spaces.
This commit is contained in:
parent
e646e4768d
commit
239a4fb100
2891 changed files with 79411 additions and 79411 deletions
|
|
@ -36,34 +36,34 @@ import static mage.constants.Constants.*;
|
|||
*/
|
||||
public class CardDimensions {
|
||||
|
||||
public int frameHeight;
|
||||
public int frameWidth;
|
||||
public int symbolHeight;
|
||||
public int symbolWidth;
|
||||
public int contentXOffset;
|
||||
public int nameYOffset;
|
||||
public int typeYOffset;
|
||||
public int textYOffset;
|
||||
public int textWidth;
|
||||
public int textHeight;
|
||||
public int powBoxTextTop;
|
||||
public int powBoxTextLeft;
|
||||
public int nameFontSize;
|
||||
public int frameHeight;
|
||||
public int frameWidth;
|
||||
public int symbolHeight;
|
||||
public int symbolWidth;
|
||||
public int contentXOffset;
|
||||
public int nameYOffset;
|
||||
public int typeYOffset;
|
||||
public int textYOffset;
|
||||
public int textWidth;
|
||||
public int textHeight;
|
||||
public int powBoxTextTop;
|
||||
public int powBoxTextLeft;
|
||||
public int nameFontSize;
|
||||
|
||||
public CardDimensions(double scaleFactor) {
|
||||
frameHeight = (int)(FRAME_MAX_HEIGHT * scaleFactor);
|
||||
frameWidth = (int)(FRAME_MAX_WIDTH * scaleFactor);
|
||||
symbolHeight = (int)(SYMBOL_MAX_HEIGHT * scaleFactor);
|
||||
symbolWidth = (int)(SYMBOL_MAX_WIDTH * scaleFactor);
|
||||
contentXOffset = (int)(CONTENT_MAX_XOFFSET * scaleFactor);
|
||||
nameYOffset = (int)(NAME_MAX_YOFFSET * scaleFactor);
|
||||
typeYOffset = (int)(TYPE_MAX_YOFFSET * scaleFactor);
|
||||
textYOffset = (int)(TEXT_MAX_YOFFSET * scaleFactor);
|
||||
textWidth = (int)(TEXT_MAX_WIDTH * scaleFactor);
|
||||
textHeight = (int)(TEXT_MAX_HEIGHT * scaleFactor);
|
||||
powBoxTextTop = (int)(POWBOX_TEXT_MAX_TOP * scaleFactor);
|
||||
powBoxTextLeft = (int)(POWBOX_TEXT_MAX_LEFT * scaleFactor);
|
||||
nameFontSize = Math.max(9, (int)(NAME_FONT_MAX_SIZE * scaleFactor));
|
||||
}
|
||||
public CardDimensions(double scaleFactor) {
|
||||
frameHeight = (int)(FRAME_MAX_HEIGHT * scaleFactor);
|
||||
frameWidth = (int)(FRAME_MAX_WIDTH * scaleFactor);
|
||||
symbolHeight = (int)(SYMBOL_MAX_HEIGHT * scaleFactor);
|
||||
symbolWidth = (int)(SYMBOL_MAX_WIDTH * scaleFactor);
|
||||
contentXOffset = (int)(CONTENT_MAX_XOFFSET * scaleFactor);
|
||||
nameYOffset = (int)(NAME_MAX_YOFFSET * scaleFactor);
|
||||
typeYOffset = (int)(TYPE_MAX_YOFFSET * scaleFactor);
|
||||
textYOffset = (int)(TEXT_MAX_YOFFSET * scaleFactor);
|
||||
textWidth = (int)(TEXT_MAX_WIDTH * scaleFactor);
|
||||
textHeight = (int)(TEXT_MAX_HEIGHT * scaleFactor);
|
||||
powBoxTextTop = (int)(POWBOX_TEXT_MAX_TOP * scaleFactor);
|
||||
powBoxTextLeft = (int)(POWBOX_TEXT_MAX_LEFT * scaleFactor);
|
||||
nameFontSize = Math.max(9, (int)(NAME_FONT_MAX_SIZE * scaleFactor));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,24 +9,24 @@ import mage.cards.action.ActionCallback;
|
|||
import mage.view.CardView;
|
||||
|
||||
public abstract class MageCard extends JPanel {
|
||||
private static final long serialVersionUID = 6089945326434301879L;
|
||||
private static final long serialVersionUID = 6089945326434301879L;
|
||||
|
||||
abstract public void onBeginAnimation();
|
||||
abstract public void onEndAnimation();
|
||||
abstract public boolean isTapped();
|
||||
abstract public boolean isFlipped();
|
||||
abstract public void setAlpha(float transparency);
|
||||
abstract public float getAlpha();
|
||||
abstract public CardView getOriginal();
|
||||
abstract public void setCardBounds(int x, int y, int width, int height);
|
||||
abstract public void update(CardView card);
|
||||
abstract public void updateImage();
|
||||
abstract public Image getImage();
|
||||
abstract public void onBeginAnimation();
|
||||
abstract public void onEndAnimation();
|
||||
abstract public boolean isTapped();
|
||||
abstract public boolean isFlipped();
|
||||
abstract public void setAlpha(float transparency);
|
||||
abstract public float getAlpha();
|
||||
abstract public CardView getOriginal();
|
||||
abstract public void setCardBounds(int x, int y, int width, int height);
|
||||
abstract public void update(CardView card);
|
||||
abstract public void updateImage();
|
||||
abstract public Image getImage();
|
||||
abstract public void setFoil(boolean foil);
|
||||
abstract public boolean isFoil();
|
||||
abstract public void setZone(String zone);
|
||||
abstract public String getZone();
|
||||
abstract public void updateCallback(ActionCallback callback, UUID gameId);
|
||||
abstract public void toggleTransformed();
|
||||
abstract public void updateCallback(ActionCallback callback, UUID gameId);
|
||||
abstract public void toggleTransformed();
|
||||
abstract public boolean isTransformed();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||
import mage.view.PermanentView;
|
||||
|
||||
public abstract class MagePermanent extends MageCard {
|
||||
private static final long serialVersionUID = -3469258620601702171L;
|
||||
abstract public List<MagePermanent> getLinks();
|
||||
abstract public void update(PermanentView card);
|
||||
abstract public PermanentView getOriginalPermanent();
|
||||
private static final long serialVersionUID = -3469258620601702171L;
|
||||
abstract public List<MagePermanent> getLinks();
|
||||
abstract public void update(PermanentView card);
|
||||
abstract public PermanentView getOriginalPermanent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ public class TextPopup extends javax.swing.JPanel {
|
|||
initComponents();
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
popupText.setText(text);
|
||||
}
|
||||
public void setText(String text) {
|
||||
popupText.setText(text);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ package mage.cards.action;
|
|||
import java.awt.event.MouseEvent;
|
||||
|
||||
public interface ActionCallback {
|
||||
void mouseClicked(MouseEvent e, TransferData data);
|
||||
void mousePressed(MouseEvent e, TransferData data);
|
||||
void mouseMoved(MouseEvent e, TransferData data);
|
||||
void mouseEntered(MouseEvent e, TransferData data);
|
||||
void mouseExited(MouseEvent e, TransferData dat);
|
||||
void hidePopup();
|
||||
void mouseClicked(MouseEvent e, TransferData data);
|
||||
void mousePressed(MouseEvent e, TransferData data);
|
||||
void mouseMoved(MouseEvent e, TransferData data);
|
||||
void mouseEntered(MouseEvent e, TransferData data);
|
||||
void mouseExited(MouseEvent e, TransferData dat);
|
||||
void hidePopup();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ import mage.cards.TextPopup;
|
|||
import mage.view.CardView;
|
||||
|
||||
public class TransferData {
|
||||
public Component component;
|
||||
public TextPopup popupText;
|
||||
public Point locationOnScreen;
|
||||
public int popupOffsetX;
|
||||
public int popupOffsetY;
|
||||
public UUID gameId;
|
||||
public CardView card;
|
||||
public Component component;
|
||||
public TextPopup popupText;
|
||||
public Point locationOnScreen;
|
||||
public int popupOffsetX;
|
||||
public int popupOffsetY;
|
||||
public UUID gameId;
|
||||
public CardView card;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,28 +12,28 @@ import mage.cards.action.TransferData;
|
|||
*/
|
||||
public class EmptyCallback implements ActionCallback {
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e, TransferData data) {
|
||||
}
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e, TransferData data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e, TransferData data) {
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e, TransferData data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e, TransferData data) {
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e, TransferData data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePopup() {
|
||||
}
|
||||
@Override
|
||||
public void hidePopup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e, TransferData data) {
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e, TransferData data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e, TransferData data) {
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e, TransferData data) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,93 +9,93 @@ import javax.swing.JViewport;
|
|||
|
||||
@SuppressWarnings("serial")
|
||||
public class ImagePanel extends JPanel {
|
||||
public static final int TILED = 0;
|
||||
public static final int SCALED = 1;
|
||||
public static final int ACTUAL = 2;
|
||||
public static final int TILED = 0;
|
||||
public static final int SCALED = 1;
|
||||
public static final int ACTUAL = 2;
|
||||
|
||||
private BufferedImage image;
|
||||
private int style;
|
||||
private float alignmentX = 0.5f;
|
||||
private float alignmentY = 0.5f;
|
||||
private BufferedImage image;
|
||||
private int style;
|
||||
private float alignmentX = 0.5f;
|
||||
private float alignmentY = 0.5f;
|
||||
|
||||
public ImagePanel(BufferedImage image) {
|
||||
this(image, TILED);
|
||||
}
|
||||
public ImagePanel(BufferedImage image) {
|
||||
this(image, TILED);
|
||||
}
|
||||
|
||||
public ImagePanel(BufferedImage image, int style) {
|
||||
this.image = image;
|
||||
this.style = style;
|
||||
setLayout(new BorderLayout());
|
||||
}
|
||||
public ImagePanel(BufferedImage image, int style) {
|
||||
this.image = image;
|
||||
this.style = style;
|
||||
setLayout(new BorderLayout());
|
||||
}
|
||||
|
||||
public void setImageAlignmentX(float alignmentX) {
|
||||
this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
|
||||
}
|
||||
public void setImageAlignmentX(float alignmentX) {
|
||||
this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
|
||||
}
|
||||
|
||||
public void setImageAlignmentY(float alignmentY) {
|
||||
this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
|
||||
public void setImageAlignmentY(float alignmentY) {
|
||||
this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void add(JComponent component) {
|
||||
add(component, null);
|
||||
}
|
||||
public void add(JComponent component) {
|
||||
add(component, null);
|
||||
}
|
||||
|
||||
public void add(JComponent component, Object constraints) {
|
||||
component.setOpaque(false);
|
||||
public void add(JComponent component, Object constraints) {
|
||||
component.setOpaque(false);
|
||||
|
||||
if (component instanceof JScrollPane) {
|
||||
JScrollPane scrollPane = (JScrollPane) component;
|
||||
JViewport viewport = scrollPane.getViewport();
|
||||
viewport.setOpaque(false);
|
||||
Component c = viewport.getView();
|
||||
if (component instanceof JScrollPane) {
|
||||
JScrollPane scrollPane = (JScrollPane) component;
|
||||
JViewport viewport = scrollPane.getViewport();
|
||||
viewport.setOpaque(false);
|
||||
Component c = viewport.getView();
|
||||
|
||||
if (c instanceof JComponent) {
|
||||
((JComponent) c).setOpaque(false);
|
||||
}
|
||||
}
|
||||
if (c instanceof JComponent) {
|
||||
((JComponent) c).setOpaque(false);
|
||||
}
|
||||
}
|
||||
|
||||
super.add(component, constraints);
|
||||
}
|
||||
super.add(component, constraints);
|
||||
}
|
||||
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
if (image == null)
|
||||
return;
|
||||
if (image == null)
|
||||
return;
|
||||
|
||||
switch (style) {
|
||||
case TILED:
|
||||
drawTiled(g);
|
||||
break;
|
||||
switch (style) {
|
||||
case TILED:
|
||||
drawTiled(g);
|
||||
break;
|
||||
|
||||
case SCALED:
|
||||
Dimension d = getSize();
|
||||
g.drawImage(image, 0, 0, d.width, d.height, null);
|
||||
break;
|
||||
case SCALED:
|
||||
Dimension d = getSize();
|
||||
g.drawImage(image, 0, 0, d.width, d.height, null);
|
||||
break;
|
||||
|
||||
case ACTUAL:
|
||||
drawActual(g);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ACTUAL:
|
||||
drawActual(g);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTiled(Graphics g) {
|
||||
Dimension d = getSize();
|
||||
int width = image.getWidth(null);
|
||||
int height = image.getHeight(null);
|
||||
private void drawTiled(Graphics g) {
|
||||
Dimension d = getSize();
|
||||
int width = image.getWidth(null);
|
||||
int height = image.getHeight(null);
|
||||
|
||||
for (int x = 0; x < d.width; x += width) {
|
||||
for (int y = 0; y < d.height; y += height) {
|
||||
g.drawImage(image, x, y, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < d.width; x += width) {
|
||||
for (int y = 0; y < d.height; y += height) {
|
||||
g.drawImage(image, x, y, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawActual(Graphics g) {
|
||||
Dimension d = getSize();
|
||||
float x = (d.width - image.getWidth(null)) * alignmentX;
|
||||
float y = (d.height - image.getHeight(null)) * alignmentY;
|
||||
g.drawImage(image, (int) x, (int) y, this);
|
||||
}
|
||||
private void drawActual(Graphics g) {
|
||||
Dimension d = getSize();
|
||||
float x = (d.width - image.getWidth(null)) * alignmentX;
|
||||
float y = (d.height - image.getHeight(null)) * alignmentY;
|
||||
g.drawImage(image, (int) x, (int) y, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,44 +34,44 @@ package mage.constants;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public final class Constants {
|
||||
private Constants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
private Constants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static final int FRAME_MAX_HEIGHT = 367;
|
||||
public static final int FRAME_MAX_WIDTH = 256;
|
||||
public static final int ART_MAX_HEIGHT = 168;
|
||||
public static final int ART_MAX_WIDTH = 227;
|
||||
public static final int SYMBOL_MAX_HEIGHT = 14;
|
||||
public static final int SYMBOL_MAX_WIDTH = 14;
|
||||
public static final int SYMBOL_MAX_XOFFSET = 27;
|
||||
public static final int SYMBOL_MAX_YOFFSET = 15;
|
||||
public static final int SYMBOL_MAX_SPACE = 14;
|
||||
public static final int CONTENT_MAX_XOFFSET = 15;
|
||||
public static final int ART_MAX_YOFFSET = 37;
|
||||
public static final int NAME_MAX_YOFFSET = 28;
|
||||
public static final int TYPE_MAX_YOFFSET = 223;
|
||||
public static final int ICON_MAX_HEIGHT = 16;
|
||||
public static final int ICON_MAX_WIDTH = 16;
|
||||
public static final int ICON_MAX_XOFFSET = 238;
|
||||
public static final int ICON_MAX_YOFFSET = 210;
|
||||
public static final int TEXT_MAX_YOFFSET = 232;
|
||||
public static final int TEXT_MAX_WIDTH = 227;
|
||||
public static final int TEXT_MAX_HEIGHT = 105;
|
||||
public static final int NAME_FONT_MAX_SIZE = 13;
|
||||
public static final int TEXT_FONT_MAX_SIZE = 11;
|
||||
public static final int POWBOX_MAX_TOP = 336;
|
||||
public static final int POWBOX_MAX_LEFT = 202;
|
||||
public static final int POWBOX_TEXT_MAX_TOP = 352;
|
||||
public static final int POWBOX_TEXT_MAX_LEFT = 212;
|
||||
public static final int DAMAGE_MAX_LEFT = 180;
|
||||
public static final int FRAME_MAX_HEIGHT = 367;
|
||||
public static final int FRAME_MAX_WIDTH = 256;
|
||||
public static final int ART_MAX_HEIGHT = 168;
|
||||
public static final int ART_MAX_WIDTH = 227;
|
||||
public static final int SYMBOL_MAX_HEIGHT = 14;
|
||||
public static final int SYMBOL_MAX_WIDTH = 14;
|
||||
public static final int SYMBOL_MAX_XOFFSET = 27;
|
||||
public static final int SYMBOL_MAX_YOFFSET = 15;
|
||||
public static final int SYMBOL_MAX_SPACE = 14;
|
||||
public static final int CONTENT_MAX_XOFFSET = 15;
|
||||
public static final int ART_MAX_YOFFSET = 37;
|
||||
public static final int NAME_MAX_YOFFSET = 28;
|
||||
public static final int TYPE_MAX_YOFFSET = 223;
|
||||
public static final int ICON_MAX_HEIGHT = 16;
|
||||
public static final int ICON_MAX_WIDTH = 16;
|
||||
public static final int ICON_MAX_XOFFSET = 238;
|
||||
public static final int ICON_MAX_YOFFSET = 210;
|
||||
public static final int TEXT_MAX_YOFFSET = 232;
|
||||
public static final int TEXT_MAX_WIDTH = 227;
|
||||
public static final int TEXT_MAX_HEIGHT = 105;
|
||||
public static final int NAME_FONT_MAX_SIZE = 13;
|
||||
public static final int TEXT_FONT_MAX_SIZE = 11;
|
||||
public static final int POWBOX_MAX_TOP = 336;
|
||||
public static final int POWBOX_MAX_LEFT = 202;
|
||||
public static final int POWBOX_TEXT_MAX_TOP = 352;
|
||||
public static final int POWBOX_TEXT_MAX_LEFT = 212;
|
||||
public static final int DAMAGE_MAX_LEFT = 180;
|
||||
|
||||
public static final double SCALE_FACTOR = 0.5;
|
||||
|
||||
public static final String PLUGINS_DIRECTORY = "plugins/";
|
||||
|
||||
public enum SessionState {
|
||||
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_UNAVAILABLE, SERVER_STARTING;
|
||||
}
|
||||
public static final double SCALE_FACTOR = 0.5;
|
||||
|
||||
public static final String PLUGINS_DIRECTORY = "plugins/";
|
||||
|
||||
public enum SessionState {
|
||||
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_UNAVAILABLE, SERVER_STARTING;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,17 +27,17 @@ import java.awt.*;
|
|||
*/
|
||||
public class HueFilter extends PointFilter {
|
||||
|
||||
public float hue;
|
||||
private float[] hsb = new float[3];
|
||||
public float hue;
|
||||
private float[] hsb = new float[3];
|
||||
|
||||
public HueFilter() {
|
||||
this(0);
|
||||
}
|
||||
public HueFilter() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public HueFilter(float hue) {
|
||||
this.hue = hue;
|
||||
canFilterIndexColorModel = true;
|
||||
}
|
||||
public HueFilter(float hue) {
|
||||
this.hue = hue;
|
||||
canFilterIndexColorModel = true;
|
||||
}
|
||||
|
||||
public void setHue(float hue) {
|
||||
this.hue = hue;
|
||||
|
|
@ -47,22 +47,22 @@ public class HueFilter extends PointFilter {
|
|||
return hue;
|
||||
}
|
||||
|
||||
public int filterRGB(int x, int y, int rgb) {
|
||||
int a = rgb & 0xff000000;
|
||||
int r = (rgb >> 16) & 0xff;
|
||||
int g = (rgb >> 8) & 0xff;
|
||||
int b = rgb & 0xff;
|
||||
Color.RGBtoHSB(r, g, b, hsb);
|
||||
hsb[0] += hue;
|
||||
while (hsb[0] < 0) {
|
||||
hsb[0] += Math.PI*2;
|
||||
public int filterRGB(int x, int y, int rgb) {
|
||||
int a = rgb & 0xff000000;
|
||||
int r = (rgb >> 16) & 0xff;
|
||||
int g = (rgb >> 8) & 0xff;
|
||||
int b = rgb & 0xff;
|
||||
Color.RGBtoHSB(r, g, b, hsb);
|
||||
hsb[0] += hue;
|
||||
while (hsb[0] < 0) {
|
||||
hsb[0] += Math.PI*2;
|
||||
}
|
||||
rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
|
||||
return a | (rgb & 0xffffff);
|
||||
}
|
||||
rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
|
||||
return a | (rgb & 0xffffff);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Change HUE filter";
|
||||
}
|
||||
public String toString() {
|
||||
return "Change HUE filter";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ import mage.utils.MageVersion;
|
|||
*/
|
||||
public interface MageClient extends CallbackClient {
|
||||
|
||||
public UUID getId();
|
||||
public MageVersion getVersion();
|
||||
public void connected(String message);
|
||||
public void disconnected();
|
||||
public void showMessage(String message);
|
||||
public void showError(String message);
|
||||
|
||||
public UUID getId();
|
||||
public MageVersion getVersion();
|
||||
public void connected(String message);
|
||||
public void disconnected();
|
||||
public void showMessage(String message);
|
||||
public void showError(String message);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,89 +46,89 @@ import java.util.UUID;
|
|||
public interface MageServer {
|
||||
|
||||
// connection methods
|
||||
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
|
||||
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||
void deregisterClient(String sessionId) throws MageException;
|
||||
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
|
||||
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||
void deregisterClient(String sessionId) throws MageException;
|
||||
|
||||
// user methods
|
||||
boolean setUserData(String userName, String sessionId, UserDataView userDataView) throws MageException;
|
||||
void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
|
||||
boolean setUserData(String userName, String sessionId, UserDataView userDataView) throws MageException;
|
||||
void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
|
||||
|
||||
// server state methods
|
||||
ServerState getServerState() throws MageException;
|
||||
List<String> getConnectedPlayers(UUID roomId) throws MageException;
|
||||
List<MatchView> getFinishedMatches(UUID roomId) throws MageException;
|
||||
Object getServerMessagesCompressed(String sessionId) throws MageException; // messages of the day
|
||||
List<MatchView> getFinishedMatches(UUID roomId) throws MageException;
|
||||
Object getServerMessagesCompressed(String sessionId) throws MageException; // messages of the day
|
||||
|
||||
// ping - extends session
|
||||
boolean ping(String sessionId) throws MageException;
|
||||
boolean ping(String sessionId) throws MageException;
|
||||
|
||||
//table methods
|
||||
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
|
||||
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) throws MageException, GameException;
|
||||
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill) throws MageException, GameException;
|
||||
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void leaveTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void swapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
|
||||
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
TableView getTable(UUID roomId, UUID tableId) throws MageException;
|
||||
List<TableView> getTables(UUID roomId) throws MageException;
|
||||
//table methods
|
||||
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
|
||||
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) throws MageException, GameException;
|
||||
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill) throws MageException, GameException;
|
||||
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void leaveTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void swapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
|
||||
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
TableView getTable(UUID roomId, UUID tableId) throws MageException;
|
||||
List<TableView> getTables(UUID roomId) throws MageException;
|
||||
|
||||
//chat methods
|
||||
void sendChatMessage(UUID chatId, String userName, String message) throws MageException;
|
||||
void joinChat(UUID chatId, String sessionId, String userName) throws MageException;
|
||||
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
||||
UUID getTableChatId(UUID tableId) throws MageException;
|
||||
UUID getGameChatId(UUID gameId) throws MageException;
|
||||
UUID getRoomChatId(UUID roomId) throws MageException;
|
||||
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
||||
//chat methods
|
||||
void sendChatMessage(UUID chatId, String userName, String message) throws MageException;
|
||||
void joinChat(UUID chatId, String sessionId, String userName) throws MageException;
|
||||
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
||||
UUID getTableChatId(UUID tableId) throws MageException;
|
||||
UUID getGameChatId(UUID gameId) throws MageException;
|
||||
UUID getRoomChatId(UUID roomId) throws MageException;
|
||||
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
||||
|
||||
//room methods
|
||||
UUID getMainRoomId() throws MageException;
|
||||
//room methods
|
||||
UUID getMainRoomId() throws MageException;
|
||||
|
||||
//game methods
|
||||
void startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void joinGame(UUID gameId, String sessionId) throws MageException;
|
||||
void watchGame(UUID gameId, String sessionId) throws MageException;
|
||||
void stopWatching(UUID gameId, String sessionId) throws MageException;
|
||||
void sendPlayerUUID(UUID gameId, String sessionId, UUID data) throws MageException;
|
||||
void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException;
|
||||
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
|
||||
void sendPlayerInteger(UUID gameId, String sessionId, Integer data) throws MageException;
|
||||
void concedeGame(UUID gameId, String sessionId) throws MageException;
|
||||
//game methods
|
||||
void startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void joinGame(UUID gameId, String sessionId) throws MageException;
|
||||
void watchGame(UUID gameId, String sessionId) throws MageException;
|
||||
void stopWatching(UUID gameId, String sessionId) throws MageException;
|
||||
void sendPlayerUUID(UUID gameId, String sessionId, UUID data) throws MageException;
|
||||
void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException;
|
||||
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
|
||||
void sendPlayerInteger(UUID gameId, String sessionId, Integer data) throws MageException;
|
||||
void concedeGame(UUID gameId, String sessionId) throws MageException;
|
||||
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
|
||||
|
||||
//tournament methods
|
||||
void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
||||
TournamentView getTournament(UUID tournamentId) throws MageException;
|
||||
//tournament methods
|
||||
void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
||||
TournamentView getTournament(UUID tournamentId) throws MageException;
|
||||
|
||||
//draft methods
|
||||
void joinDraft(UUID draftId, String sessionId) throws MageException;
|
||||
DraftPickView sendCardPick(UUID draftId, String sessionId, UUID cardId) throws MageException;
|
||||
//draft methods
|
||||
void joinDraft(UUID draftId, String sessionId) throws MageException;
|
||||
DraftPickView sendCardPick(UUID draftId, String sessionId, UUID cardId) throws MageException;
|
||||
|
||||
//challenge methods
|
||||
void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException;
|
||||
//challenge methods
|
||||
void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException;
|
||||
|
||||
//replay methods
|
||||
void replayGame(UUID gameId, String sessionId) throws MageException;
|
||||
void startReplay(UUID gameId, String sessionId) throws MageException;
|
||||
void stopReplay(UUID gameId, String sessionId) throws MageException;
|
||||
void nextPlay(UUID gameId, String sessionId) throws MageException;
|
||||
void previousPlay(UUID gameId, String sessionId) throws MageException;
|
||||
void skipForward(UUID gameId, String sessionId, int moves) throws MageException;
|
||||
//replay methods
|
||||
void replayGame(UUID gameId, String sessionId) throws MageException;
|
||||
void startReplay(UUID gameId, String sessionId) throws MageException;
|
||||
void stopReplay(UUID gameId, String sessionId) throws MageException;
|
||||
void nextPlay(UUID gameId, String sessionId) throws MageException;
|
||||
void previousPlay(UUID gameId, String sessionId) throws MageException;
|
||||
void skipForward(UUID gameId, String sessionId, int moves) throws MageException;
|
||||
|
||||
//test methods
|
||||
void cheat(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
|
||||
boolean cheat(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
|
||||
//test methods
|
||||
void cheat(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
|
||||
boolean cheat(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
|
||||
|
||||
//admin methods
|
||||
List<UserView> getUsers(String sessionId) throws MageException;
|
||||
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
||||
//admin methods
|
||||
List<UserView> getUsers(String sessionId) throws MageException;
|
||||
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ import mage.MageException;
|
|||
*/
|
||||
public class PluginException extends MageException {
|
||||
|
||||
private static final long serialVersionUID = 5528005696138392272L;
|
||||
private static final long serialVersionUID = 5528005696138392272L;
|
||||
|
||||
public PluginException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public PluginException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
public PluginException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public PluginException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,43 +40,43 @@ import mage.view.TournamentTypeView;
|
|||
*/
|
||||
public class ServerState implements Serializable {
|
||||
|
||||
private List<GameTypeView> gameTypes;
|
||||
private List<TournamentTypeView> tournamentTypes;
|
||||
private String[] playerTypes;
|
||||
private String[] deckTypes;
|
||||
private boolean testMode;
|
||||
private MageVersion version;
|
||||
private List<GameTypeView> gameTypes;
|
||||
private List<TournamentTypeView> tournamentTypes;
|
||||
private String[] playerTypes;
|
||||
private String[] deckTypes;
|
||||
private boolean testMode;
|
||||
private MageVersion version;
|
||||
|
||||
public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes, String[] playerTypes, String[] deckTypes, boolean testMode, MageVersion version) {
|
||||
this.gameTypes = gameTypes;
|
||||
this.tournamentTypes = tournamentTypes;
|
||||
this.playerTypes = playerTypes;
|
||||
this.deckTypes = deckTypes;
|
||||
this.testMode = testMode;
|
||||
this.version = version;
|
||||
}
|
||||
public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes, String[] playerTypes, String[] deckTypes, boolean testMode, MageVersion version) {
|
||||
this.gameTypes = gameTypes;
|
||||
this.tournamentTypes = tournamentTypes;
|
||||
this.playerTypes = playerTypes;
|
||||
this.deckTypes = deckTypes;
|
||||
this.testMode = testMode;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public List<GameTypeView> getGameTypes() {
|
||||
return gameTypes;
|
||||
}
|
||||
public List<GameTypeView> getGameTypes() {
|
||||
return gameTypes;
|
||||
}
|
||||
|
||||
public List<TournamentTypeView> getTournamentTypes() {
|
||||
return tournamentTypes;
|
||||
}
|
||||
public List<TournamentTypeView> getTournamentTypes() {
|
||||
return tournamentTypes;
|
||||
}
|
||||
|
||||
public String[] getPlayerTypes() {
|
||||
return playerTypes;
|
||||
}
|
||||
public String[] getPlayerTypes() {
|
||||
return playerTypes;
|
||||
}
|
||||
|
||||
public String[] getDeckTypes() {
|
||||
return deckTypes;
|
||||
}
|
||||
public String[] getDeckTypes() {
|
||||
return deckTypes;
|
||||
}
|
||||
|
||||
public boolean isTestMode() {
|
||||
return testMode;
|
||||
}
|
||||
public boolean isTestMode() {
|
||||
return testMode;
|
||||
}
|
||||
|
||||
public MageVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
public MageVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ package mage.interfaces.callback;
|
|||
*/
|
||||
public interface CallbackClient {
|
||||
|
||||
public void processCallback(ClientCallback callback);
|
||||
public void processCallback(ClientCallback callback);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,58 +37,58 @@ import java.util.UUID;
|
|||
*/
|
||||
public class ClientCallback implements Serializable {
|
||||
|
||||
private UUID objectId;
|
||||
private Object data;
|
||||
private String method;
|
||||
private int messageId;
|
||||
private UUID objectId;
|
||||
private Object data;
|
||||
private String method;
|
||||
private int messageId;
|
||||
|
||||
public ClientCallback() {}
|
||||
public ClientCallback() {}
|
||||
|
||||
public ClientCallback(String method, UUID objectId, Object data) {
|
||||
this.method = method;
|
||||
this.objectId = objectId;
|
||||
this.data = data;
|
||||
}
|
||||
public ClientCallback(String method, UUID objectId, Object data) {
|
||||
this.method = method;
|
||||
this.objectId = objectId;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ClientCallback(String method, UUID objectId) {
|
||||
this(method, objectId, null);
|
||||
}
|
||||
public ClientCallback(String method, UUID objectId) {
|
||||
this(method, objectId, null);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
method = null;
|
||||
data = null;
|
||||
}
|
||||
public void clear() {
|
||||
method = null;
|
||||
data = null;
|
||||
}
|
||||
|
||||
public UUID getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
public UUID getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
public void setObjectId(UUID objectId) {
|
||||
this.objectId = objectId;
|
||||
}
|
||||
public void setObjectId(UUID objectId) {
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import java.util.UUID;
|
|||
* @author nantuko
|
||||
*/
|
||||
public interface CardPlugin extends Plugin {
|
||||
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
||||
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards, Map<String, String> options);
|
||||
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
||||
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards, Map<String, String> options);
|
||||
|
||||
/**
|
||||
* Check for new images.
|
||||
|
|
@ -36,7 +36,7 @@ public interface CardPlugin extends Plugin {
|
|||
* @param imagesPath Path to check in. Can be null, in such case default path should be used.
|
||||
*/
|
||||
public boolean newImages(Set<Card> allCards, String imagesPath);
|
||||
|
||||
|
||||
/**
|
||||
* Download images.
|
||||
*
|
||||
|
|
@ -50,11 +50,11 @@ public interface CardPlugin extends Plugin {
|
|||
*
|
||||
* @param imagesPath Path to check in and store symbols to. Can be null, in such case default path should be used.
|
||||
*/
|
||||
void downloadSymbols(String imagesPath);
|
||||
void downloadSymbols(String imagesPath);
|
||||
|
||||
Image getManaSymbolImage(String symbol);
|
||||
void onAddCard(MagePermanent card, int count);
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
Image getManaSymbolImage(String symbol);
|
||||
void onAddCard(MagePermanent card, int count);
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
JComponent getCardInfoPane();
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ import net.xeoh.plugins.base.Plugin;
|
|||
* @author nantuko
|
||||
*/
|
||||
public interface CounterPlugin extends Plugin {
|
||||
void addGamePlayed() throws PluginException;
|
||||
int getGamePlayed() throws PluginException;
|
||||
void addGamePlayed() throws PluginException;
|
||||
int getGamePlayed() throws PluginException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ import net.xeoh.plugins.base.Plugin;
|
|||
* @author nantuko
|
||||
*/
|
||||
public interface ThemePlugin extends Plugin {
|
||||
void applyInGame(Map<String, JComponent> ui);
|
||||
JComponent updateTable(Map<String, JComponent> ui);
|
||||
void applyInGame(Map<String, JComponent> ui);
|
||||
JComponent updateTable(Map<String, JComponent> ui);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ import mage.cards.Card;
|
|||
* @author nantuko
|
||||
*/
|
||||
public interface RateCallback {
|
||||
int rateCard(Card card);
|
||||
Card getBestBasicLand(Constants.ColoredManaSymbol color);
|
||||
int rateCard(Card card);
|
||||
Card getBestBasicLand(Constants.ColoredManaSymbol color);
|
||||
}
|
||||
|
|
@ -37,171 +37,171 @@ import java.util.Enumeration;
|
|||
*/
|
||||
public class Connection {
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
private String username;
|
||||
private String password;
|
||||
private ProxyType proxyType;
|
||||
private String proxyHost;
|
||||
private int proxyPort;
|
||||
private String proxyUsername;
|
||||
private String proxyPassword;
|
||||
private String host;
|
||||
private int port;
|
||||
private String username;
|
||||
private String password;
|
||||
private ProxyType proxyType;
|
||||
private String proxyHost;
|
||||
private int proxyPort;
|
||||
private String proxyUsername;
|
||||
private String proxyPassword;
|
||||
|
||||
private int avatarId;
|
||||
|
||||
private static final String serialization = "?serializationtype=jboss";
|
||||
private static final String transport = "bisocket";
|
||||
private int avatarId;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (transport + host + Integer.toString(port) + proxyType.toString()).hashCode();
|
||||
}
|
||||
private static final String serialization = "?serializationtype=jboss";
|
||||
private static final String transport = "bisocket";
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (! (object instanceof Connection)) {
|
||||
return false;
|
||||
}
|
||||
Connection otherConnection = (Connection) object;
|
||||
return hashCode() == otherConnection.hashCode();
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (transport + host + Integer.toString(port) + proxyType.toString()).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return host + ":" + Integer.toString(port) + "/" + serialization;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (! (object instanceof Connection)) {
|
||||
return false;
|
||||
}
|
||||
Connection otherConnection = (Connection) object;
|
||||
return hashCode() == otherConnection.hashCode();
|
||||
}
|
||||
|
||||
public String getURI() {
|
||||
if (host.equals("localhost")) {
|
||||
try {
|
||||
InetAddress inet = getLocalAddress();
|
||||
if (inet != null) {
|
||||
return transport + "://" + inet.getHostAddress() + ":" + port + "/" + serialization;
|
||||
}
|
||||
} catch (SocketException ex) {
|
||||
// just use localhost if can't find local ip
|
||||
}
|
||||
}
|
||||
return transport + "://" + host + ":" + port + "/" + serialization;
|
||||
}
|
||||
|
||||
public ProxyType getProxyType() {
|
||||
return proxyType;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return host + ":" + Integer.toString(port) + "/" + serialization;
|
||||
}
|
||||
|
||||
public void setProxyType(ProxyType proxyType) {
|
||||
this.proxyType = proxyType;
|
||||
}
|
||||
public String getURI() {
|
||||
if (host.equals("localhost")) {
|
||||
try {
|
||||
InetAddress inet = getLocalAddress();
|
||||
if (inet != null) {
|
||||
return transport + "://" + inet.getHostAddress() + ":" + port + "/" + serialization;
|
||||
}
|
||||
} catch (SocketException ex) {
|
||||
// just use localhost if can't find local ip
|
||||
}
|
||||
}
|
||||
return transport + "://" + host + ":" + port + "/" + serialization;
|
||||
}
|
||||
|
||||
public enum ProxyType {
|
||||
SOCKS("Socks"), HTTP("HTTP"), NONE("None");
|
||||
public ProxyType getProxyType() {
|
||||
return proxyType;
|
||||
}
|
||||
|
||||
private String text;
|
||||
public void setProxyType(ProxyType proxyType) {
|
||||
this.proxyType = proxyType;
|
||||
}
|
||||
|
||||
ProxyType(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
public enum ProxyType {
|
||||
SOCKS("Socks"), HTTP("HTTP"), NONE("None");
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
private String text;
|
||||
|
||||
public static ProxyType valueByText(String value) {
|
||||
for (ProxyType type : values()) {
|
||||
if (type.text.equals(value)) return type;
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
ProxyType(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
public static ProxyType valueByText(String value) {
|
||||
for (ProxyType type : values()) {
|
||||
if (type.text.equals(value)) return type;
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getProxyHost() {
|
||||
return proxyHost;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setProxyHost(String proxyHost) {
|
||||
this.proxyHost = proxyHost;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int getProxyPort() {
|
||||
return proxyPort;
|
||||
}
|
||||
public String getProxyHost() {
|
||||
return proxyHost;
|
||||
}
|
||||
|
||||
public void setProxyPort(int proxyPort) {
|
||||
this.proxyPort = proxyPort;
|
||||
}
|
||||
public void setProxyHost(String proxyHost) {
|
||||
this.proxyHost = proxyHost;
|
||||
}
|
||||
|
||||
public String getProxyUsername() {
|
||||
return proxyUsername;
|
||||
}
|
||||
public int getProxyPort() {
|
||||
return proxyPort;
|
||||
}
|
||||
|
||||
public void setProxyUsername(String proxyUsername) {
|
||||
this.proxyUsername = proxyUsername;
|
||||
}
|
||||
public void setProxyPort(int proxyPort) {
|
||||
this.proxyPort = proxyPort;
|
||||
}
|
||||
|
||||
public String getProxyPassword() {
|
||||
return proxyPassword;
|
||||
}
|
||||
public String getProxyUsername() {
|
||||
return proxyUsername;
|
||||
}
|
||||
|
||||
public void setProxyPassword(String proxyPassword) {
|
||||
this.proxyPassword = proxyPassword;
|
||||
}
|
||||
|
||||
public static InetAddress getLocalAddress() throws SocketException {
|
||||
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) {
|
||||
NetworkInterface iface = interfaces.nextElement( );
|
||||
if (iface.isLoopback())
|
||||
continue;
|
||||
for (InterfaceAddress addr: iface.getInterfaceAddresses()) {
|
||||
public void setProxyUsername(String proxyUsername) {
|
||||
this.proxyUsername = proxyUsername;
|
||||
}
|
||||
|
||||
public String getProxyPassword() {
|
||||
return proxyPassword;
|
||||
}
|
||||
|
||||
public void setProxyPassword(String proxyPassword) {
|
||||
this.proxyPassword = proxyPassword;
|
||||
}
|
||||
|
||||
public static InetAddress getLocalAddress() throws SocketException {
|
||||
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) {
|
||||
NetworkInterface iface = interfaces.nextElement( );
|
||||
if (iface.isLoopback())
|
||||
continue;
|
||||
for (InterfaceAddress addr: iface.getInterfaceAddresses()) {
|
||||
if (addr != null) {
|
||||
InetAddress iaddr = addr.getAddress();
|
||||
if (iaddr != null && iaddr instanceof Inet4Address) {
|
||||
return iaddr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ import mage.utils.MageVersion;
|
|||
public class MageVersionException extends MageException {
|
||||
|
||||
private MageVersion serverVersion;
|
||||
|
||||
public MageVersionException(MageVersion clientVersion, MageVersion serverVersion) {
|
||||
|
||||
public MageVersionException(MageVersion clientVersion, MageVersion serverVersion) {
|
||||
super("Wrong client version " + clientVersion + ", expecting version " + serverVersion + ". \r\n\r\nPlease download latest version at download.magefree.com and use mage-updater.");
|
||||
this.serverVersion = serverVersion;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -17,38 +17,38 @@ import java.util.zip.GZIPOutputStream;
|
|||
*/
|
||||
public class ZippedObjectImpl<T> implements ZippedObject<T>, Serializable {
|
||||
|
||||
private byte[] data;
|
||||
private byte[] data;
|
||||
|
||||
public ZippedObjectImpl(T object) {
|
||||
zip(object);
|
||||
}
|
||||
|
||||
public void zip(T object) {
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gz = new GZIPOutputStream(bos);
|
||||
ObjectOutputStream oos = new ObjectOutputStream(gz);
|
||||
oos.writeObject(object);
|
||||
oos.close();
|
||||
data = bos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T unzip() {
|
||||
try {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
||||
GZIPInputStream gz = new GZIPInputStream(bis);
|
||||
ObjectInputStream ois = new ObjectInputStream(gz);
|
||||
Object o = ois.readObject();
|
||||
return (T)o;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public ZippedObjectImpl(T object) {
|
||||
zip(object);
|
||||
}
|
||||
|
||||
public void zip(T object) {
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gz = new GZIPOutputStream(bos);
|
||||
ObjectOutputStream oos = new ObjectOutputStream(gz);
|
||||
oos.writeObject(object);
|
||||
oos.close();
|
||||
data = bos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T unzip() {
|
||||
try {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
||||
GZIPInputStream gz = new GZIPInputStream(bis);
|
||||
ObjectInputStream ois = new ObjectInputStream(gz);
|
||||
Object o = ois.readObject();
|
||||
return (T)o;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,40 +12,40 @@ import mage.view.CardView;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class CardUtil {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean isPlaneswalker(MagePermanent card) {
|
||||
return is(card.getOriginal(), CardType.PLANESWALKER);
|
||||
}
|
||||
|
||||
public static boolean isLand(MagePermanent card) {
|
||||
return is(card.getOriginal(), CardType.LAND);
|
||||
}
|
||||
|
||||
public static boolean is(CardView card, CardType type) {
|
||||
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 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);
|
||||
}
|
||||
|
||||
public static boolean isPlaneswalker(MagePermanent card) {
|
||||
return is(card.getOriginal(), CardType.PLANESWALKER);
|
||||
}
|
||||
|
||||
public static boolean isLand(MagePermanent card) {
|
||||
return is(card.getOriginal(), CardType.LAND);
|
||||
}
|
||||
|
||||
public static boolean is(CardView card, CardType type) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class CompressUtil {
|
|||
* Defines should data be compressed or not. True by default.
|
||||
* Read from system property:
|
||||
*/
|
||||
private static boolean compressData = true;
|
||||
private static boolean compressData = true;
|
||||
|
||||
/**
|
||||
* Defines the system property name to disable any compressing.
|
||||
|
|
|
|||
|
|
@ -16,269 +16,269 @@ import java.util.*;
|
|||
*/
|
||||
public class DeckBuilder {
|
||||
|
||||
private static String selectedColors;
|
||||
private static String selectedColors;
|
||||
|
||||
private static final int SPELL_CARD_POOL_SIZE = 60;
|
||||
private static final int SPELL_CARD_POOL_SIZE = 60;
|
||||
|
||||
private static final int DECK_COUNT[] = {3, 6, 6, 4, 3, 2};
|
||||
private static final int DECK_COST[] = {1, 2, 3, 4, 6, 10};
|
||||
private static final int DECK_SPELLS = 24;
|
||||
private static final int DECK_LANDS = 16;
|
||||
private static final int DECK_SIZE = DECK_SPELLS + DECK_LANDS;
|
||||
private static final int MIN_CARD_SCORE = 25;
|
||||
private static final int MIN_SOURCE = 16;
|
||||
private static Deck deck = new Deck();
|
||||
private static final int DECK_COUNT[] = {3, 6, 6, 4, 3, 2};
|
||||
private static final int DECK_COST[] = {1, 2, 3, 4, 6, 10};
|
||||
private static final int DECK_SPELLS = 24;
|
||||
private static final int DECK_LANDS = 16;
|
||||
private static final int DECK_SIZE = DECK_SPELLS + DECK_LANDS;
|
||||
private static final int MIN_CARD_SCORE = 25;
|
||||
private static final int MIN_SOURCE = 16;
|
||||
private static Deck deck = new Deck();
|
||||
|
||||
/**
|
||||
* Hide constructor.
|
||||
*/
|
||||
private DeckBuilder() {
|
||||
}
|
||||
/**
|
||||
* Hide constructor.
|
||||
*/
|
||||
private DeckBuilder() {
|
||||
}
|
||||
|
||||
public synchronized static Deck buildDeck(List<Card> spellCardPool, List<ColoredManaSymbol> allowedColors, List<Card> landCardPool, RateCallback callback) {
|
||||
deck = new Deck();
|
||||
public synchronized static Deck buildDeck(List<Card> spellCardPool, List<ColoredManaSymbol> allowedColors, List<Card> landCardPool, RateCallback callback) {
|
||||
deck = new Deck();
|
||||
|
||||
final Collection<MageScoredCard> remainingCards = new ArrayList<MageScoredCard>();
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (final Card card : spellCardPool) {
|
||||
if (names.contains(card.getName())) {
|
||||
continue;
|
||||
}
|
||||
remainingCards.add(new MageScoredCard(card, allowedColors, callback));
|
||||
names.add(card.getName());
|
||||
}
|
||||
int min = 0;
|
||||
for (int index = 0; index < DECK_COUNT.length; index++) {
|
||||
final int max = DECK_COST[index];
|
||||
addCardsToDeck(remainingCards, min, max, DECK_COUNT[index]);
|
||||
min = max + 1;
|
||||
}
|
||||
addCardsToDeck(remainingCards, 0, 4, DECK_SPELLS - deck.getCards().size());
|
||||
addCardsToDeck(remainingCards, 5, 10, DECK_SPELLS - deck.getCards().size());
|
||||
addLandsToDeck(allowedColors, landCardPool, callback);
|
||||
final Collection<MageScoredCard> remainingCards = new ArrayList<MageScoredCard>();
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (final Card card : spellCardPool) {
|
||||
if (names.contains(card.getName())) {
|
||||
continue;
|
||||
}
|
||||
remainingCards.add(new MageScoredCard(card, allowedColors, callback));
|
||||
names.add(card.getName());
|
||||
}
|
||||
int min = 0;
|
||||
for (int index = 0; index < DECK_COUNT.length; index++) {
|
||||
final int max = DECK_COST[index];
|
||||
addCardsToDeck(remainingCards, min, max, DECK_COUNT[index]);
|
||||
min = max + 1;
|
||||
}
|
||||
addCardsToDeck(remainingCards, 0, 4, DECK_SPELLS - deck.getCards().size());
|
||||
addCardsToDeck(remainingCards, 5, 10, DECK_SPELLS - deck.getCards().size());
|
||||
addLandsToDeck(allowedColors, landCardPool, callback);
|
||||
|
||||
return deck;
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that chosen card can produce mana of specific color.
|
||||
*
|
||||
* @param card
|
||||
* @param allowedColors
|
||||
* @return
|
||||
*/
|
||||
private static boolean cardCardProduceChosenColors(Card card, List<ColoredManaSymbol> allowedColors) {
|
||||
int score = 0;
|
||||
for (Mana mana : card.getMana()) {
|
||||
for (ColoredManaSymbol color : allowedColors) {
|
||||
score = score + mana.getColor(color);
|
||||
}
|
||||
}
|
||||
if (score > 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Checks that chosen card can produce mana of specific color.
|
||||
*
|
||||
* @param card
|
||||
* @param allowedColors
|
||||
* @return
|
||||
*/
|
||||
private static boolean cardCardProduceChosenColors(Card card, List<ColoredManaSymbol> allowedColors) {
|
||||
int score = 0;
|
||||
for (Mana mana : card.getMana()) {
|
||||
for (ColoredManaSymbol color : allowedColors) {
|
||||
score = score + mana.getColor(color);
|
||||
}
|
||||
}
|
||||
if (score > 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chosed best scored card and adds it to the deck.
|
||||
*
|
||||
* @param remainingCards
|
||||
* @param minCost
|
||||
* @param maxCost
|
||||
* @param count
|
||||
*/
|
||||
private static void addCardsToDeck(final Collection<MageScoredCard> remainingCards, final int minCost, final int maxCost,
|
||||
final int count) {
|
||||
/**
|
||||
* Chosed best scored card and adds it to the deck.
|
||||
*
|
||||
* @param remainingCards
|
||||
* @param minCost
|
||||
* @param maxCost
|
||||
* @param count
|
||||
*/
|
||||
private static void addCardsToDeck(final Collection<MageScoredCard> remainingCards, final int minCost, final int maxCost,
|
||||
final int count) {
|
||||
|
||||
for (int c = count; c > 0; c--) {
|
||||
for (int c = count; c > 0; c--) {
|
||||
|
||||
MageScoredCard bestCard = null;
|
||||
int bestScore = -1;
|
||||
MageScoredCard bestCard = null;
|
||||
int bestScore = -1;
|
||||
|
||||
for (final MageScoredCard draftedCard : remainingCards) {
|
||||
for (final MageScoredCard draftedCard : remainingCards) {
|
||||
|
||||
final int score = draftedCard.getScore();
|
||||
final int cost = draftedCard.getConvertedCost();
|
||||
if (score > bestScore && cost >= minCost && cost <= maxCost) {
|
||||
bestScore = score;
|
||||
bestCard = draftedCard;
|
||||
}
|
||||
}
|
||||
final int score = draftedCard.getScore();
|
||||
final int cost = draftedCard.getConvertedCost();
|
||||
if (score > bestScore && cost >= minCost && cost <= maxCost) {
|
||||
bestScore = score;
|
||||
bestCard = draftedCard;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestCard == null || bestScore < MIN_CARD_SCORE) {
|
||||
break;
|
||||
}
|
||||
deck.getCards().add(bestCard.card);
|
||||
remainingCards.remove(bestCard);
|
||||
}
|
||||
}
|
||||
if (bestCard == null || bestScore < MIN_CARD_SCORE) {
|
||||
break;
|
||||
}
|
||||
deck.getCards().add(bestCard.card);
|
||||
remainingCards.remove(bestCard);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds lands from non basic land (if provided), adds basic lands getting them from provided {@link RateCallback}}.
|
||||
*
|
||||
* @param allowedColors
|
||||
* @param landCardPool
|
||||
* @param callback
|
||||
*/
|
||||
private static void addLandsToDeck(List<ColoredManaSymbol> allowedColors, List<Card> landCardPool, RateCallback callback) {
|
||||
/**
|
||||
* Adds lands from non basic land (if provided), adds basic lands getting them from provided {@link RateCallback}}.
|
||||
*
|
||||
* @param allowedColors
|
||||
* @param landCardPool
|
||||
* @param callback
|
||||
*/
|
||||
private static void addLandsToDeck(List<ColoredManaSymbol> allowedColors, List<Card> landCardPool, RateCallback callback) {
|
||||
|
||||
// Calculate statistics per color.
|
||||
final Map<String, Integer> colorCount = new HashMap<String, Integer>();
|
||||
for (final Card card : deck.getCards()) {
|
||||
// Calculate statistics per color.
|
||||
final Map<String, Integer> colorCount = new HashMap<String, Integer>();
|
||||
for (final Card card : deck.getCards()) {
|
||||
|
||||
for (String symbol : card.getManaCost().getSymbols()) {
|
||||
int count = 0;
|
||||
symbol = symbol.replace("{", "").replace("}", "");
|
||||
if (isColoredMana(symbol)) {
|
||||
for (ColoredManaSymbol allowed : allowedColors) {
|
||||
if (allowed.toString().equals(symbol)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
Integer typeCount = colorCount.get(symbol);
|
||||
if (typeCount == null) {
|
||||
typeCount = new Integer(0);
|
||||
}
|
||||
typeCount += 1;
|
||||
colorCount.put(symbol, typeCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String symbol : card.getManaCost().getSymbols()) {
|
||||
int count = 0;
|
||||
symbol = symbol.replace("{", "").replace("}", "");
|
||||
if (isColoredMana(symbol)) {
|
||||
for (ColoredManaSymbol allowed : allowedColors) {
|
||||
if (allowed.toString().equals(symbol)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
Integer typeCount = colorCount.get(symbol);
|
||||
if (typeCount == null) {
|
||||
typeCount = new Integer(0);
|
||||
}
|
||||
typeCount += 1;
|
||||
colorCount.put(symbol, typeCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add suitable non basic lands to deck in order of pack.
|
||||
final Map<String, Integer> colorSource = new HashMap<String, Integer>();
|
||||
for (final ColoredManaSymbol color : ColoredManaSymbol.values()) {
|
||||
colorSource.put(color.toString(), 0);
|
||||
}
|
||||
if (landCardPool != null) {
|
||||
for (final Card landCard : landCardPool) {
|
||||
deck.getCards().add(landCard);
|
||||
for (Mana mana : landCard.getMana()) {
|
||||
for (ColoredManaSymbol color : allowedColors) {
|
||||
int amount = mana.getColor(color);
|
||||
if (amount > 0) {
|
||||
Integer count = colorSource.get(color.toString());
|
||||
count += amount;
|
||||
colorSource.put(color.toString(), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add suitable non basic lands to deck in order of pack.
|
||||
final Map<String, Integer> colorSource = new HashMap<String, Integer>();
|
||||
for (final ColoredManaSymbol color : ColoredManaSymbol.values()) {
|
||||
colorSource.put(color.toString(), 0);
|
||||
}
|
||||
if (landCardPool != null) {
|
||||
for (final Card landCard : landCardPool) {
|
||||
deck.getCards().add(landCard);
|
||||
for (Mana mana : landCard.getMana()) {
|
||||
for (ColoredManaSymbol color : allowedColors) {
|
||||
int amount = mana.getColor(color);
|
||||
if (amount > 0) {
|
||||
Integer count = colorSource.get(color.toString());
|
||||
count += amount;
|
||||
colorSource.put(color.toString(), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add optimal basic lands to deck.
|
||||
while (deck.getCards().size() < DECK_SIZE) {
|
||||
ColoredManaSymbol bestColor = null;
|
||||
int lowestRatio = Integer.MAX_VALUE;
|
||||
for (final ColoredManaSymbol color : ColoredManaSymbol.values()) {
|
||||
// Add optimal basic lands to deck.
|
||||
while (deck.getCards().size() < DECK_SIZE) {
|
||||
ColoredManaSymbol bestColor = null;
|
||||
int lowestRatio = Integer.MAX_VALUE;
|
||||
for (final ColoredManaSymbol color : ColoredManaSymbol.values()) {
|
||||
|
||||
final Integer count = colorCount.get(color.toString());
|
||||
if (count != null && count > 0) {
|
||||
final int source = colorSource.get(color.toString());
|
||||
final int ratio;
|
||||
if (source < MIN_SOURCE) {
|
||||
ratio = source - count;
|
||||
} else {
|
||||
ratio = source * 100 / count;
|
||||
}
|
||||
if (ratio < lowestRatio) {
|
||||
lowestRatio = ratio;
|
||||
bestColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Card landCard = callback.getBestBasicLand(bestColor);
|
||||
Integer count = colorSource.get(bestColor.toString());
|
||||
count++;
|
||||
colorSource.put(bestColor.toString(), count);
|
||||
deck.getCards().add(landCard);
|
||||
}
|
||||
}
|
||||
final Integer count = colorCount.get(color.toString());
|
||||
if (count != null && count > 0) {
|
||||
final int source = colorSource.get(color.toString());
|
||||
final int ratio;
|
||||
if (source < MIN_SOURCE) {
|
||||
ratio = source - count;
|
||||
} else {
|
||||
ratio = source * 100 / count;
|
||||
}
|
||||
if (ratio < lowestRatio) {
|
||||
lowestRatio = ratio;
|
||||
bestColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Card landCard = callback.getBestBasicLand(bestColor);
|
||||
Integer count = colorSource.get(bestColor.toString());
|
||||
count++;
|
||||
colorSource.put(bestColor.toString(), count);
|
||||
deck.getCards().add(landCard);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MageScoredCard {
|
||||
private static class MageScoredCard {
|
||||
|
||||
private Card card;
|
||||
private int score;
|
||||
private Card card;
|
||||
private int score;
|
||||
|
||||
private static final int SINGLE_PENALTY[] = {0, 1, 1, 3, 6, 9};
|
||||
//private static final int DOUBLE_PENALTY[] = { 0, 0, 1, 2, 4, 6 };
|
||||
private static final int SINGLE_PENALTY[] = {0, 1, 1, 3, 6, 9};
|
||||
//private static final int DOUBLE_PENALTY[] = { 0, 0, 1, 2, 4, 6 };
|
||||
|
||||
public MageScoredCard(Card card, List<ColoredManaSymbol> allowedColors, RateCallback cardRater) {
|
||||
this.card = card;
|
||||
public MageScoredCard(Card card, List<ColoredManaSymbol> allowedColors, RateCallback cardRater) {
|
||||
this.card = card;
|
||||
|
||||
int type = 0;
|
||||
if (card.getCardType().contains(Constants.CardType.CREATURE)) {
|
||||
type = 10;
|
||||
} else if (card.getSubtype().contains("Equipment")) {
|
||||
type = 8;
|
||||
} else if (card.getSubtype().contains("Aura")) {
|
||||
type = 5;
|
||||
} else if (card.getCardType().contains(Constants.CardType.INSTANT)) {
|
||||
type = 7;
|
||||
} else {
|
||||
type = 6;
|
||||
}
|
||||
int type = 0;
|
||||
if (card.getCardType().contains(Constants.CardType.CREATURE)) {
|
||||
type = 10;
|
||||
} else if (card.getSubtype().contains("Equipment")) {
|
||||
type = 8;
|
||||
} else if (card.getSubtype().contains("Aura")) {
|
||||
type = 5;
|
||||
} else if (card.getCardType().contains(Constants.CardType.INSTANT)) {
|
||||
type = 7;
|
||||
} else {
|
||||
type = 6;
|
||||
}
|
||||
|
||||
this.score =
|
||||
// 5*card.getValue() + // not possible now
|
||||
3 * cardRater.rateCard(card) +
|
||||
// 3*card.getRemoval() + // not possible now
|
||||
type + getManaCostScore(card, allowedColors);
|
||||
}
|
||||
this.score =
|
||||
// 5*card.getValue() + // not possible now
|
||||
3 * cardRater.rateCard(card) +
|
||||
// 3*card.getRemoval() + // not possible now
|
||||
type + getManaCostScore(card, allowedColors);
|
||||
}
|
||||
|
||||
private int getManaCostScore(Card card, List<ColoredManaSymbol> allowedColors) {
|
||||
int converted = card.getManaCost().convertedManaCost();
|
||||
final Map<String, Integer> singleCount = new HashMap<String, Integer>();
|
||||
int maxSingleCount = 0;
|
||||
int multicolor = 0;
|
||||
Set<String> colors = new HashSet<String>();
|
||||
for (String symbol : card.getManaCost().getSymbols()) {
|
||||
int count = 0;
|
||||
symbol = symbol.replace("{", "").replace("}", "");
|
||||
if (isColoredMana(symbol)) {
|
||||
for (ColoredManaSymbol allowed : allowedColors) {
|
||||
if (allowed.toString().equals(symbol)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count == 0) {
|
||||
return -30;
|
||||
}
|
||||
if (!colors.contains(symbol)) {
|
||||
multicolor += 1;
|
||||
}
|
||||
Integer typeCount = singleCount.get(symbol);
|
||||
if (typeCount == null) {
|
||||
typeCount = new Integer(0);
|
||||
}
|
||||
typeCount += 1;
|
||||
singleCount.put(symbol, typeCount);
|
||||
maxSingleCount = Math.max(maxSingleCount, typeCount);
|
||||
}
|
||||
}
|
||||
int multicolorBonus = multicolor > 1 ? 30 : 0;
|
||||
maxSingleCount = Math.min(maxSingleCount, SINGLE_PENALTY.length - 1);
|
||||
return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]/*-DOUBLE_PENALTY[doubleCount]*/) + multicolorBonus;
|
||||
}
|
||||
private int getManaCostScore(Card card, List<ColoredManaSymbol> allowedColors) {
|
||||
int converted = card.getManaCost().convertedManaCost();
|
||||
final Map<String, Integer> singleCount = new HashMap<String, Integer>();
|
||||
int maxSingleCount = 0;
|
||||
int multicolor = 0;
|
||||
Set<String> colors = new HashSet<String>();
|
||||
for (String symbol : card.getManaCost().getSymbols()) {
|
||||
int count = 0;
|
||||
symbol = symbol.replace("{", "").replace("}", "");
|
||||
if (isColoredMana(symbol)) {
|
||||
for (ColoredManaSymbol allowed : allowedColors) {
|
||||
if (allowed.toString().equals(symbol)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count == 0) {
|
||||
return -30;
|
||||
}
|
||||
if (!colors.contains(symbol)) {
|
||||
multicolor += 1;
|
||||
}
|
||||
Integer typeCount = singleCount.get(symbol);
|
||||
if (typeCount == null) {
|
||||
typeCount = new Integer(0);
|
||||
}
|
||||
typeCount += 1;
|
||||
singleCount.put(symbol, typeCount);
|
||||
maxSingleCount = Math.max(maxSingleCount, typeCount);
|
||||
}
|
||||
}
|
||||
int multicolorBonus = multicolor > 1 ? 30 : 0;
|
||||
maxSingleCount = Math.min(maxSingleCount, SINGLE_PENALTY.length - 1);
|
||||
return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]/*-DOUBLE_PENALTY[doubleCount]*/) + multicolorBonus;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
public int getConvertedCost() {
|
||||
return this.card.getManaCost().convertedManaCost();
|
||||
}
|
||||
public int getConvertedCost() {
|
||||
return this.card.getManaCost().convertedManaCost();
|
||||
}
|
||||
|
||||
public Card getCard() {
|
||||
return this.card;
|
||||
}
|
||||
}
|
||||
public Card getCard() {
|
||||
return this.card;
|
||||
}
|
||||
}
|
||||
|
||||
protected static boolean isColoredMana(String symbol) {
|
||||
return symbol.equals("W") || symbol.equals("G") || symbol.equals("U") || symbol.equals("B") || symbol.equals("R");
|
||||
}
|
||||
protected static boolean isColoredMana(String symbol) {
|
||||
return symbol.equals("W") || symbol.equals("G") || symbol.equals("U") || symbol.equals("B") || symbol.equals("R");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -36,45 +36,45 @@ import java.io.Serializable;
|
|||
*/
|
||||
public class MageVersion implements Serializable, Comparable<MageVersion> {
|
||||
|
||||
private int major;
|
||||
private int minor;
|
||||
private int patch;
|
||||
private int major;
|
||||
private int minor;
|
||||
private int patch;
|
||||
|
||||
private String info = "";
|
||||
|
||||
public MageVersion(int major, int minor, int patch, String info) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.patch = patch;
|
||||
public MageVersion(int major, int minor, int patch, String info) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.patch = patch;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getPatch() {
|
||||
return patch;
|
||||
}
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return major + "." + minor + "." + patch + info;
|
||||
}
|
||||
public int getPatch() {
|
||||
return patch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(MageVersion o) {
|
||||
if (major != o.major)
|
||||
return major - o.major;
|
||||
if (minor != o.minor)
|
||||
return minor - o.minor;
|
||||
if (patch != o.patch)
|
||||
return patch - o.patch;
|
||||
@Override
|
||||
public String toString() {
|
||||
return major + "." + minor + "." + patch + info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(MageVersion o) {
|
||||
if (major != o.major)
|
||||
return major - o.major;
|
||||
if (minor != o.minor)
|
||||
return minor - o.minor;
|
||||
if (patch != o.patch)
|
||||
return patch - o.patch;
|
||||
return info.compareTo(o.info);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,43 +12,43 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
public class ThreadUtils {
|
||||
|
||||
static public ThreadPoolExecutor threadPool;
|
||||
static public ThreadPoolExecutor threadPool;
|
||||
static public ThreadPoolExecutor threadPool2;
|
||||
static private int threadCount;
|
||||
static {
|
||||
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
||||
public Thread newThread (Runnable runnable) {
|
||||
threadCount++;
|
||||
Thread thread = new Thread(runnable, "Util" + threadCount);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
});
|
||||
threadPool.prestartAllCoreThreads();
|
||||
static private int threadCount;
|
||||
static {
|
||||
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
||||
public Thread newThread (Runnable runnable) {
|
||||
threadCount++;
|
||||
Thread thread = new Thread(runnable, "Util" + threadCount);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
});
|
||||
threadPool.prestartAllCoreThreads();
|
||||
threadPool2 = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
||||
public Thread newThread (Runnable runnable) {
|
||||
threadCount++;
|
||||
Thread thread = new Thread(runnable, "TP2" + threadCount);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
});
|
||||
threadPool2.prestartAllCoreThreads();
|
||||
}
|
||||
public Thread newThread (Runnable runnable) {
|
||||
threadCount++;
|
||||
Thread thread = new Thread(runnable, "TP2" + threadCount);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
});
|
||||
threadPool2.prestartAllCoreThreads();
|
||||
}
|
||||
|
||||
static public void sleep (int millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
static public void sleep (int millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void wait (Object lock) {
|
||||
synchronized (lock) {
|
||||
try {
|
||||
lock.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
static public void wait (Object lock) {
|
||||
synchronized (lock) {
|
||||
try {
|
||||
lock.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,19 +42,19 @@ import mage.abilities.Ability;
|
|||
public class AbilityPickerView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Map<UUID, String> choices = new HashMap<UUID, String>();
|
||||
private Map<UUID, String> choices = new HashMap<UUID, String>();
|
||||
|
||||
public AbilityPickerView(Collection<? extends Ability> abilities) {
|
||||
for (Ability ability: abilities) {
|
||||
choices.put(ability.getId(), ability.getRule(true));
|
||||
}
|
||||
}
|
||||
public AbilityPickerView(Collection<? extends Ability> abilities) {
|
||||
for (Ability ability: abilities) {
|
||||
choices.put(ability.getId(), ability.getRule(true));
|
||||
}
|
||||
}
|
||||
|
||||
public AbilityPickerView(Map<UUID, String> modes) {
|
||||
this.choices = modes;
|
||||
}
|
||||
public AbilityPickerView(Map<UUID, String> modes) {
|
||||
this.choices = modes;
|
||||
}
|
||||
|
||||
public Map<UUID, String> getChoices() {
|
||||
return choices;
|
||||
}
|
||||
public Map<UUID, String> getChoices() {
|
||||
return choices;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,27 +40,27 @@ import mage.abilities.Ability;
|
|||
public class AbilityView extends CardView {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String sourceName;
|
||||
private CardView sourceCard;
|
||||
private String sourceName;
|
||||
private CardView sourceCard;
|
||||
|
||||
public AbilityView(Ability ability, String sourceName, CardView sourceCard) {
|
||||
this.id = ability.getId();
|
||||
this.name = "Ability";
|
||||
this.sourceName = sourceName;
|
||||
this.sourceCard = sourceCard;
|
||||
this.rules = new ArrayList<String>();
|
||||
rules.add(ability.getRule());
|
||||
this.power = "";
|
||||
this.toughness = "";
|
||||
this.loyalty = "";
|
||||
this.cardTypes = new ArrayList<CardType>();
|
||||
this.subTypes = new ArrayList<String>();
|
||||
this.superTypes = new ArrayList<String>();
|
||||
this.color = new ObjectColor();
|
||||
this.manaCost = ability.getManaCosts().getSymbols();
|
||||
}
|
||||
public AbilityView(Ability ability, String sourceName, CardView sourceCard) {
|
||||
this.id = ability.getId();
|
||||
this.name = "Ability";
|
||||
this.sourceName = sourceName;
|
||||
this.sourceCard = sourceCard;
|
||||
this.rules = new ArrayList<String>();
|
||||
rules.add(ability.getRule());
|
||||
this.power = "";
|
||||
this.toughness = "";
|
||||
this.loyalty = "";
|
||||
this.cardTypes = new ArrayList<CardType>();
|
||||
this.subTypes = new ArrayList<String>();
|
||||
this.superTypes = new ArrayList<String>();
|
||||
this.color = new ObjectColor();
|
||||
this.manaCost = ability.getManaCosts().getSymbols();
|
||||
}
|
||||
|
||||
public CardView getSourceCard() {
|
||||
return this.sourceCard;
|
||||
}
|
||||
public CardView getSourceCard() {
|
||||
return this.sourceCard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,19 +232,19 @@ public class CardView extends SimpleCardView {
|
|||
}
|
||||
}
|
||||
|
||||
// protected List<String> formatRules(List<String> rules) {
|
||||
// List<String> newRules = new ArrayList<String>();
|
||||
// for (String rule: rules) {
|
||||
// newRules.add(formatRule(rule));
|
||||
// }
|
||||
// return newRules;
|
||||
// }
|
||||
// protected List<String> formatRules(List<String> rules) {
|
||||
// List<String> newRules = new ArrayList<String>();
|
||||
// for (String rule: rules) {
|
||||
// newRules.add(formatRule(rule));
|
||||
// }
|
||||
// return newRules;
|
||||
// }
|
||||
//
|
||||
// protected String formatRule(String rule) {
|
||||
// String replace = rule.replace("{this}", this.name);
|
||||
// replace = replace.replace("{source}", this.name);
|
||||
// return replace;
|
||||
// }
|
||||
// protected String formatRule(String rule) {
|
||||
// String replace = rule.replace("{this}", this.name);
|
||||
// replace = replace.replace("{source}", this.name);
|
||||
// return replace;
|
||||
// }
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
|
|||
|
|
@ -45,46 +45,46 @@ import java.util.UUID;
|
|||
*/
|
||||
public class CardsView extends LinkedHashMap<UUID, CardView> {
|
||||
|
||||
public CardsView() {}
|
||||
public CardsView() {}
|
||||
|
||||
public CardsView(Collection<? extends Card> cards) {
|
||||
for (Card card: cards) {
|
||||
this.put(card.getId(), new CardView(card));
|
||||
}
|
||||
}
|
||||
public CardsView(Collection<? extends Card> cards) {
|
||||
for (Card card: cards) {
|
||||
this.put(card.getId(), new CardView(card));
|
||||
}
|
||||
}
|
||||
|
||||
public CardsView ( Collection<? extends Ability> abilities, Game game ) {
|
||||
for ( Ability ability : abilities ) {
|
||||
Card sourceCard = null;
|
||||
switch ( ability.getZone() ) {
|
||||
case ALL:
|
||||
case EXILED:
|
||||
case GRAVEYARD:
|
||||
sourceCard = game.getCard(ability.getSourceId());
|
||||
break;
|
||||
case BATTLEFIELD:
|
||||
public CardsView ( Collection<? extends Ability> abilities, Game game ) {
|
||||
for ( Ability ability : abilities ) {
|
||||
Card sourceCard = null;
|
||||
switch ( ability.getZone() ) {
|
||||
case ALL:
|
||||
case EXILED:
|
||||
case GRAVEYARD:
|
||||
sourceCard = game.getCard(ability.getSourceId());
|
||||
break;
|
||||
case BATTLEFIELD:
|
||||
sourceCard = game.getPermanent(ability.getSourceId());
|
||||
if (sourceCard == null)
|
||||
sourceCard = (Permanent)game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD);
|
||||
break;
|
||||
sourceCard = (Permanent)game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD);
|
||||
break;
|
||||
case COMMAND:
|
||||
ability.newId();
|
||||
this.put(ability.getId(), new AbilityView(ability, "Emblem", new CardView("Emblem")));
|
||||
break;
|
||||
}
|
||||
if (sourceCard != null) {
|
||||
this.put(ability.getId(), new AbilityView(ability, sourceCard.getName(), new CardView(sourceCard)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sourceCard != null) {
|
||||
this.put(ability.getId(), new AbilityView(ability, sourceCard.getName(), new CardView(sourceCard)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CardsView(Collection<? extends Ability> abilities, GameState state) {
|
||||
for (Ability ability: abilities) {
|
||||
Card sourceCard = state.getPermanent(ability.getSourceId());
|
||||
if (sourceCard != null) {
|
||||
this.put(ability.getId(), new AbilityView(ability, sourceCard.getName(), new CardView(sourceCard)));
|
||||
}
|
||||
}
|
||||
}
|
||||
public CardsView(Collection<? extends Ability> abilities, GameState state) {
|
||||
for (Ability ability: abilities) {
|
||||
Card sourceCard = state.getPermanent(ability.getSourceId());
|
||||
if (sourceCard != null) {
|
||||
this.put(ability.getId(), new AbilityView(ability, sourceCard.getName(), new CardView(sourceCard)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,39 +37,39 @@ import java.io.Serializable;
|
|||
public class ChatMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String username;
|
||||
private String time;
|
||||
private String message;
|
||||
private MessageColor color;
|
||||
private String username;
|
||||
private String time;
|
||||
private String message;
|
||||
private MessageColor color;
|
||||
|
||||
public enum MessageColor {
|
||||
BLACK, RED, GREEN, BLUE, ORANGE;
|
||||
}
|
||||
public enum MessageColor {
|
||||
BLACK, RED, GREEN, BLUE, ORANGE;
|
||||
}
|
||||
|
||||
public ChatMessage(String username, String message, String time, MessageColor color) {
|
||||
this.username = username;
|
||||
this.message = message;
|
||||
this.time = time;
|
||||
this.color = color;
|
||||
}
|
||||
public ChatMessage(String username, String message, String time, MessageColor color) {
|
||||
this.username = username;
|
||||
this.message = message;
|
||||
this.time = time;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public MessageColor getColor() {
|
||||
return color;
|
||||
}
|
||||
public MessageColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isUserMessage() {
|
||||
return color != null && color.equals(MessageColor.BLUE);
|
||||
}
|
||||
public boolean isUserMessage() {
|
||||
return color != null && color.equals(MessageColor.BLUE);
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,45 +43,45 @@ import java.util.UUID;
|
|||
public class CombatGroupView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private CardsView attackers = new CardsView();
|
||||
private CardsView blockers = new CardsView();
|
||||
private String defenderName = "";
|
||||
private CardsView attackers = new CardsView();
|
||||
private CardsView blockers = new CardsView();
|
||||
private String defenderName = "";
|
||||
private UUID defenderId;
|
||||
|
||||
public CombatGroupView(CombatGroup combatGroup, Game game) {
|
||||
Player player = game.getPlayer(combatGroup.getDefenderId());
|
||||
if (player != null) {
|
||||
this.defenderName = player.getName();
|
||||
}
|
||||
else {
|
||||
Permanent perm = game.getPermanent(combatGroup.getDefenderId());
|
||||
if (perm != null)
|
||||
this.defenderName = perm.getName();
|
||||
}
|
||||
public CombatGroupView(CombatGroup combatGroup, Game game) {
|
||||
Player player = game.getPlayer(combatGroup.getDefenderId());
|
||||
if (player != null) {
|
||||
this.defenderName = player.getName();
|
||||
}
|
||||
else {
|
||||
Permanent perm = game.getPermanent(combatGroup.getDefenderId());
|
||||
if (perm != null)
|
||||
this.defenderName = perm.getName();
|
||||
}
|
||||
this.defenderId = combatGroup.getDefenderId();
|
||||
for (UUID id: combatGroup.getAttackers()) {
|
||||
Permanent attacker = game.getPermanent(id);
|
||||
if (attacker != null)
|
||||
attackers.put(id, new PermanentView(attacker, game.getCard(attacker.getId())));
|
||||
}
|
||||
for (UUID id: combatGroup.getBlockerOrder()) {
|
||||
Permanent blocker = game.getPermanent(id);
|
||||
if (blocker != null)
|
||||
blockers.put(id, new PermanentView(blocker, game.getCard(blocker.getId())));
|
||||
}
|
||||
}
|
||||
Permanent attacker = game.getPermanent(id);
|
||||
if (attacker != null)
|
||||
attackers.put(id, new PermanentView(attacker, game.getCard(attacker.getId())));
|
||||
}
|
||||
for (UUID id: combatGroup.getBlockerOrder()) {
|
||||
Permanent blocker = game.getPermanent(id);
|
||||
if (blocker != null)
|
||||
blockers.put(id, new PermanentView(blocker, game.getCard(blocker.getId())));
|
||||
}
|
||||
}
|
||||
|
||||
public String getDefenderName() {
|
||||
return defenderName;
|
||||
}
|
||||
public String getDefenderName() {
|
||||
return defenderName;
|
||||
}
|
||||
|
||||
public CardsView getAttackers() {
|
||||
return attackers;
|
||||
}
|
||||
public CardsView getAttackers() {
|
||||
return attackers;
|
||||
}
|
||||
|
||||
public CardsView getBlockers() {
|
||||
return blockers;
|
||||
}
|
||||
public CardsView getBlockers() {
|
||||
return blockers;
|
||||
}
|
||||
|
||||
public UUID getDefenderId() {
|
||||
return defenderId;
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ import mage.counters.Counter;
|
|||
public class CounterView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private int count;
|
||||
private String name;
|
||||
private int count;
|
||||
|
||||
public CounterView(Counter counter) {
|
||||
this.name = counter.getName();
|
||||
this.count = counter.getCount();
|
||||
}
|
||||
public CounterView(Counter counter) {
|
||||
this.name = counter.getName();
|
||||
this.count = counter.getCount();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,25 +36,25 @@ import java.io.Serializable;
|
|||
*/
|
||||
public class DeckView implements Serializable {
|
||||
|
||||
private String name;
|
||||
private SimpleCardsView cards;
|
||||
private SimpleCardsView sideboard;
|
||||
private String name;
|
||||
private SimpleCardsView cards;
|
||||
private SimpleCardsView sideboard;
|
||||
|
||||
public DeckView(Deck deck) {
|
||||
name = deck.getName();
|
||||
cards = new SimpleCardsView(deck.getCards());
|
||||
sideboard = new SimpleCardsView(deck.getSideboard());
|
||||
}
|
||||
public DeckView(Deck deck) {
|
||||
name = deck.getName();
|
||||
cards = new SimpleCardsView(deck.getCards());
|
||||
sideboard = new SimpleCardsView(deck.getSideboard());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
|
||||
public SimpleCardsView getSideboard() {
|
||||
return sideboard;
|
||||
}
|
||||
public SimpleCardsView getSideboard() {
|
||||
return sideboard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,28 +37,28 @@ import java.io.Serializable;
|
|||
public class DraftClientMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private DraftView draftView;
|
||||
private DraftPickView draftPickView;
|
||||
private String message;
|
||||
private DraftView draftView;
|
||||
private DraftPickView draftPickView;
|
||||
private String message;
|
||||
|
||||
public DraftClientMessage(DraftView draftView) {
|
||||
this.draftView = draftView;
|
||||
}
|
||||
public DraftClientMessage(DraftView draftView) {
|
||||
this.draftView = draftView;
|
||||
}
|
||||
|
||||
public DraftClientMessage(DraftPickView draftPickView) {
|
||||
this.draftPickView = draftPickView;
|
||||
}
|
||||
public DraftClientMessage(DraftPickView draftPickView) {
|
||||
this.draftPickView = draftPickView;
|
||||
}
|
||||
|
||||
public DraftClientMessage(DraftView draftView, String message) {
|
||||
this.message = message;
|
||||
this.draftView = draftView;
|
||||
}
|
||||
public DraftClientMessage(DraftView draftView, String message) {
|
||||
this.message = message;
|
||||
this.draftView = draftView;
|
||||
}
|
||||
|
||||
public DraftPickView getDraftPickView() {
|
||||
return draftPickView;
|
||||
}
|
||||
public DraftPickView getDraftPickView() {
|
||||
return draftPickView;
|
||||
}
|
||||
|
||||
public DraftView getDraftView() {
|
||||
return draftView;
|
||||
}
|
||||
public DraftView getDraftView() {
|
||||
return draftView;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,31 +38,31 @@ import mage.game.draft.DraftPlayer;
|
|||
public class DraftPickView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected SimpleCardsView booster;
|
||||
protected SimpleCardsView picks;
|
||||
protected boolean picking;
|
||||
protected int timeout;
|
||||
protected SimpleCardsView booster;
|
||||
protected SimpleCardsView picks;
|
||||
protected boolean picking;
|
||||
protected int timeout;
|
||||
|
||||
public DraftPickView(DraftPlayer player, int timeout) {
|
||||
this.booster = new SimpleCardsView(player.getBooster());
|
||||
this.picks = new SimpleCardsView(player.getDeck().getSideboard());
|
||||
this.picking = player.isPicking();
|
||||
this.timeout = timeout;
|
||||
}
|
||||
public DraftPickView(DraftPlayer player, int timeout) {
|
||||
this.booster = new SimpleCardsView(player.getBooster());
|
||||
this.picks = new SimpleCardsView(player.getDeck().getSideboard());
|
||||
this.picking = player.isPicking();
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public SimpleCardsView getBooster() {
|
||||
return booster;
|
||||
}
|
||||
public SimpleCardsView getBooster() {
|
||||
return booster;
|
||||
}
|
||||
|
||||
public SimpleCardsView getPicks() {
|
||||
return picks;
|
||||
}
|
||||
public SimpleCardsView getPicks() {
|
||||
return picks;
|
||||
}
|
||||
|
||||
public boolean isPicking() {
|
||||
return this.picking;
|
||||
}
|
||||
public boolean isPicking() {
|
||||
return this.picking;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,27 +41,27 @@ import mage.game.draft.Draft;
|
|||
public class DraftView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<String> sets = new ArrayList<String>();
|
||||
private int boosterNum;
|
||||
private int cardNum;
|
||||
private List<String> sets = new ArrayList<String>();
|
||||
private int boosterNum;
|
||||
private int cardNum;
|
||||
|
||||
public DraftView(Draft draft) {
|
||||
for (ExpansionSet set: draft.getSets()) {
|
||||
sets.add(set.getName());
|
||||
}
|
||||
this.boosterNum = draft.getBoosterNum();
|
||||
this.cardNum = draft.getCardNum();
|
||||
}
|
||||
public DraftView(Draft draft) {
|
||||
for (ExpansionSet set: draft.getSets()) {
|
||||
sets.add(set.getName());
|
||||
}
|
||||
this.boosterNum = draft.getBoosterNum();
|
||||
this.cardNum = draft.getCardNum();
|
||||
}
|
||||
|
||||
public List<String> getSets() {
|
||||
return sets;
|
||||
}
|
||||
public List<String> getSets() {
|
||||
return sets;
|
||||
}
|
||||
|
||||
public int getBoosterNum() {
|
||||
return boosterNum;
|
||||
}
|
||||
public int getBoosterNum() {
|
||||
return boosterNum;
|
||||
}
|
||||
|
||||
public int getCardNum() {
|
||||
return cardNum;
|
||||
}
|
||||
public int getCardNum() {
|
||||
return cardNum;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,23 +40,23 @@ import mage.game.Game;
|
|||
public class ExileView extends SimpleCardsView {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private UUID id;
|
||||
private String name;
|
||||
private UUID id;
|
||||
|
||||
public ExileView(ExileZone exileZone, Game game) {
|
||||
this.name = exileZone.getName();
|
||||
this.id = exileZone.getId();
|
||||
for (Card card: exileZone.getCards(game)) {
|
||||
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
public ExileView(ExileZone exileZone, Game game) {
|
||||
this.name = exileZone.getName();
|
||||
this.id = exileZone.getId();
|
||||
for (Card card: exileZone.getCards(game)) {
|
||||
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,108 +40,108 @@ import java.util.UUID;
|
|||
public class GameClientMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private GameView gameView;
|
||||
private CardsView cardsView;
|
||||
private CardsView cardsView2;
|
||||
private String message;
|
||||
private AbilityPickerView abilityView;
|
||||
private boolean flag;
|
||||
private boolean cancel;
|
||||
private String[] strings;
|
||||
private Set<UUID> targets;
|
||||
private int min;
|
||||
private int max;
|
||||
private Map<String, Serializable> options;
|
||||
private GameView gameView;
|
||||
private CardsView cardsView;
|
||||
private CardsView cardsView2;
|
||||
private String message;
|
||||
private AbilityPickerView abilityView;
|
||||
private boolean flag;
|
||||
private boolean cancel;
|
||||
private String[] strings;
|
||||
private Set<UUID> targets;
|
||||
private int min;
|
||||
private int max;
|
||||
private Map<String, Serializable> options;
|
||||
|
||||
public GameClientMessage(GameView gameView) {
|
||||
this.gameView = gameView;
|
||||
}
|
||||
public GameClientMessage(GameView gameView) {
|
||||
this.gameView = gameView;
|
||||
}
|
||||
|
||||
public GameClientMessage(GameView gameView, String message) {
|
||||
this.gameView = gameView;
|
||||
this.message = message;
|
||||
}
|
||||
public GameClientMessage(GameView gameView, String message) {
|
||||
this.gameView = gameView;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
private GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required) {
|
||||
this.gameView = gameView;
|
||||
this.message = question;
|
||||
this.cardsView = cardView;
|
||||
this.targets = targets;
|
||||
this.flag = required;
|
||||
}
|
||||
private GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required) {
|
||||
this.gameView = gameView;
|
||||
this.message = question;
|
||||
this.cardsView = cardView;
|
||||
this.targets = targets;
|
||||
this.flag = required;
|
||||
}
|
||||
|
||||
public GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||
this(gameView, question, cardView, targets, required);
|
||||
this.options = options;
|
||||
}
|
||||
public GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||
this(gameView, question, cardView, targets, required);
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public GameClientMessage(String[] choices, String message) {
|
||||
this.strings = choices;
|
||||
this.message = message;
|
||||
}
|
||||
public GameClientMessage(String[] choices, String message) {
|
||||
this.strings = choices;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public GameClientMessage(String message, int min, int max) {
|
||||
this.message = message;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public GameClientMessage(String message, CardsView pile1, CardsView pile2) {
|
||||
this.message = message;
|
||||
this.cardsView = pile1;
|
||||
this.cardsView2 = pile2;
|
||||
}
|
||||
public GameClientMessage(String message, int min, int max) {
|
||||
this.message = message;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public GameClientMessage(CardsView cardView, String name) {
|
||||
this.cardsView = cardView;
|
||||
this.message = name;
|
||||
}
|
||||
public GameClientMessage(String message, CardsView pile1, CardsView pile2) {
|
||||
this.message = message;
|
||||
this.cardsView = pile1;
|
||||
this.cardsView2 = pile2;
|
||||
}
|
||||
|
||||
public GameView getGameView() {
|
||||
return gameView;
|
||||
}
|
||||
public GameClientMessage(CardsView cardView, String name) {
|
||||
this.cardsView = cardView;
|
||||
this.message = name;
|
||||
}
|
||||
|
||||
public CardsView getCardsView() {
|
||||
return cardsView;
|
||||
}
|
||||
public GameView getGameView() {
|
||||
return gameView;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public CardsView getCardsView() {
|
||||
return cardsView;
|
||||
}
|
||||
|
||||
public AbilityPickerView getAbilityView() {
|
||||
return abilityView;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
public AbilityPickerView getAbilityView() {
|
||||
return abilityView;
|
||||
}
|
||||
|
||||
public String[] getStrings() {
|
||||
return strings;
|
||||
}
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public Set<UUID> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
public String[] getStrings() {
|
||||
return strings;
|
||||
}
|
||||
|
||||
public CardsView getPile1() {
|
||||
return cardsView;
|
||||
}
|
||||
|
||||
public CardsView getPile2() {
|
||||
return cardsView2;
|
||||
}
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
public Set<UUID> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
public CardsView getPile1() {
|
||||
return cardsView;
|
||||
}
|
||||
|
||||
public Map<String, Serializable> getOptions() {
|
||||
return options;
|
||||
}
|
||||
public CardsView getPile2() {
|
||||
return cardsView2;
|
||||
}
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public Map<String, Serializable> getOptions() {
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,56 +38,56 @@ import mage.game.match.MatchType;
|
|||
public class GameTypeView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private int minPlayers;
|
||||
private int maxPlayers;
|
||||
private int numTeams;
|
||||
private int playersPerTeam;
|
||||
private boolean useRange;
|
||||
private boolean useAttackOption;
|
||||
private String name;
|
||||
private int minPlayers;
|
||||
private int maxPlayers;
|
||||
private int numTeams;
|
||||
private int playersPerTeam;
|
||||
private boolean useRange;
|
||||
private boolean useAttackOption;
|
||||
|
||||
public GameTypeView(MatchType gameType) {
|
||||
this.name = gameType.getName();
|
||||
this.minPlayers = gameType.getMinPlayers();
|
||||
this.maxPlayers = gameType.getMaxPlayers();
|
||||
this.numTeams = gameType.getNumTeams();
|
||||
this.playersPerTeam = gameType.getPlayersPerTeam();
|
||||
this.useAttackOption = gameType.isUseAttackOption();
|
||||
this.useRange = gameType.isUseRange();
|
||||
}
|
||||
public GameTypeView(MatchType gameType) {
|
||||
this.name = gameType.getName();
|
||||
this.minPlayers = gameType.getMinPlayers();
|
||||
this.maxPlayers = gameType.getMaxPlayers();
|
||||
this.numTeams = gameType.getNumTeams();
|
||||
this.playersPerTeam = gameType.getPlayersPerTeam();
|
||||
this.useAttackOption = gameType.isUseAttackOption();
|
||||
this.useRange = gameType.isUseRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getMinPlayers() {
|
||||
return minPlayers;
|
||||
}
|
||||
public int getMinPlayers() {
|
||||
return minPlayers;
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
public int getMaxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
|
||||
public int getNumTeams() {
|
||||
return numTeams;
|
||||
}
|
||||
public int getNumTeams() {
|
||||
return numTeams;
|
||||
}
|
||||
|
||||
public int getPlayersPerTeam() {
|
||||
return playersPerTeam;
|
||||
}
|
||||
public int getPlayersPerTeam() {
|
||||
return playersPerTeam;
|
||||
}
|
||||
|
||||
public boolean isUseRange() {
|
||||
return useRange;
|
||||
}
|
||||
public boolean isUseRange() {
|
||||
return useRange;
|
||||
}
|
||||
|
||||
public boolean isUseAttackOption() {
|
||||
return useAttackOption;
|
||||
}
|
||||
public boolean isUseAttackOption() {
|
||||
return useAttackOption;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,35 +58,35 @@ import java.util.UUID;
|
|||
public class GameView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<PlayerView> players = new ArrayList<PlayerView>();
|
||||
private SimpleCardsView hand;
|
||||
private Map<String, SimpleCardsView> opponentHands;
|
||||
private CardsView stack = new CardsView();
|
||||
private List<PlayerView> players = new ArrayList<PlayerView>();
|
||||
private SimpleCardsView hand;
|
||||
private Map<String, SimpleCardsView> opponentHands;
|
||||
private CardsView stack = new CardsView();
|
||||
//private List<UUID> stackOrder = new ArrayList<UUID>();
|
||||
private List<ExileView> exiles = new ArrayList<ExileView>();
|
||||
private List<RevealedView> revealed = new ArrayList<RevealedView>();
|
||||
private List<LookedAtView> lookedAt = new ArrayList<LookedAtView>();
|
||||
private List<CombatGroupView> combat = new ArrayList<CombatGroupView>();
|
||||
private TurnPhase phase;
|
||||
private PhaseStep step;
|
||||
private String activePlayerName = "";
|
||||
private String priorityPlayerName = "";
|
||||
private int turn;
|
||||
private boolean special = false;
|
||||
private List<ExileView> exiles = new ArrayList<ExileView>();
|
||||
private List<RevealedView> revealed = new ArrayList<RevealedView>();
|
||||
private List<LookedAtView> lookedAt = new ArrayList<LookedAtView>();
|
||||
private List<CombatGroupView> combat = new ArrayList<CombatGroupView>();
|
||||
private TurnPhase phase;
|
||||
private PhaseStep step;
|
||||
private String activePlayerName = "";
|
||||
private String priorityPlayerName = "";
|
||||
private int turn;
|
||||
private boolean special = false;
|
||||
|
||||
public GameView(GameState state, Game game) {
|
||||
for (Player player: state.getPlayers().values()) {
|
||||
players.add(new PlayerView(player, state, game));
|
||||
}
|
||||
for (StackObject stackObject: state.getStack()) {
|
||||
if (stackObject instanceof StackAbility) {
|
||||
MageObject object = game.getObject(stackObject.getSourceId());
|
||||
Card card = game.getCard(stackObject.getSourceId());
|
||||
if (card != null) {
|
||||
if (object != null) {
|
||||
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, object.getName(), new CardView(card)));
|
||||
public GameView(GameState state, Game game) {
|
||||
for (Player player: state.getPlayers().values()) {
|
||||
players.add(new PlayerView(player, state, game));
|
||||
}
|
||||
for (StackObject stackObject: state.getStack()) {
|
||||
if (stackObject instanceof StackAbility) {
|
||||
MageObject object = game.getObject(stackObject.getSourceId());
|
||||
Card card = game.getCard(stackObject.getSourceId());
|
||||
if (card != null) {
|
||||
if (object != null) {
|
||||
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, object.getName(), new CardView(card)));
|
||||
} else {
|
||||
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, "", new CardView(card)));
|
||||
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, "", new CardView(card)));
|
||||
}
|
||||
if (card.canTransform()) {
|
||||
updateLatestCardView(game, card, stackObject.getId());
|
||||
|
|
@ -104,39 +104,39 @@ public class GameView implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
stack.put(stackObject.getId(), new CardView(stackAbility));
|
||||
stack.put(stackObject.getId(), new CardView(stackAbility));
|
||||
checkPaid(stackObject.getId(), stackAbility);
|
||||
}
|
||||
}
|
||||
else {
|
||||
stack.put(stackObject.getId(), new CardView((Spell)stackObject));
|
||||
}
|
||||
}
|
||||
else {
|
||||
stack.put(stackObject.getId(), new CardView((Spell)stackObject));
|
||||
checkPaid(stackObject.getId(), (Spell)stackObject);
|
||||
}
|
||||
}
|
||||
//stackOrder.add(stackObject.getId());
|
||||
}
|
||||
}
|
||||
//Collections.reverse(stackOrder);
|
||||
for (ExileZone exileZone: state.getExile().getExileZones()) {
|
||||
exiles.add(new ExileView(exileZone, game));
|
||||
}
|
||||
for (String name: state.getRevealed().keySet()) {
|
||||
revealed.add(new RevealedView(name, state.getRevealed().get(name), game));
|
||||
}
|
||||
this.phase = state.getTurn().getPhaseType();
|
||||
this.step = state.getTurn().getStepType();
|
||||
this.turn = state.getTurnNum();
|
||||
if (state.getActivePlayerId() != null)
|
||||
this.activePlayerName = state.getPlayer(state.getActivePlayerId()).getName();
|
||||
else
|
||||
this.activePlayerName = "";
|
||||
if (state.getPriorityPlayerId() != null)
|
||||
this.priorityPlayerName = state.getPlayer(state.getPriorityPlayerId()).getName();
|
||||
else
|
||||
this.priorityPlayerName = "";
|
||||
for (CombatGroup combatGroup: state.getCombat().getGroups()) {
|
||||
combat.add(new CombatGroupView(combatGroup, game));
|
||||
}
|
||||
this.special = state.getSpecialActions().getControlledBy(state.getPriorityPlayerId()).size() > 0;
|
||||
}
|
||||
for (ExileZone exileZone: state.getExile().getExileZones()) {
|
||||
exiles.add(new ExileView(exileZone, game));
|
||||
}
|
||||
for (String name: state.getRevealed().keySet()) {
|
||||
revealed.add(new RevealedView(name, state.getRevealed().get(name), game));
|
||||
}
|
||||
this.phase = state.getTurn().getPhaseType();
|
||||
this.step = state.getTurn().getStepType();
|
||||
this.turn = state.getTurnNum();
|
||||
if (state.getActivePlayerId() != null)
|
||||
this.activePlayerName = state.getPlayer(state.getActivePlayerId()).getName();
|
||||
else
|
||||
this.activePlayerName = "";
|
||||
if (state.getPriorityPlayerId() != null)
|
||||
this.priorityPlayerName = state.getPlayer(state.getPriorityPlayerId()).getName();
|
||||
else
|
||||
this.priorityPlayerName = "";
|
||||
for (CombatGroup combatGroup: state.getCombat().getGroups()) {
|
||||
combat.add(new CombatGroupView(combatGroup, game));
|
||||
}
|
||||
this.special = state.getSpecialActions().getControlledBy(state.getPriorityPlayerId()).size() > 0;
|
||||
}
|
||||
|
||||
private void checkPaid(UUID uuid, StackAbility stackAbility) {
|
||||
for (Cost cost : stackAbility.getManaCostsToPay()) {
|
||||
|
|
@ -179,73 +179,73 @@ public class GameView implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public List<PlayerView> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
public List<PlayerView> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
public SimpleCardsView getHand() {
|
||||
return hand;
|
||||
}
|
||||
public SimpleCardsView getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(SimpleCardsView hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
public void setHand(SimpleCardsView hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public Map<String, SimpleCardsView> getOpponentHands() {
|
||||
return opponentHands;
|
||||
}
|
||||
public Map<String, SimpleCardsView> getOpponentHands() {
|
||||
return opponentHands;
|
||||
}
|
||||
|
||||
public void setOpponentHands(Map<String, SimpleCardsView> opponentHands) {
|
||||
this.opponentHands = opponentHands;
|
||||
}
|
||||
public void setOpponentHands(Map<String, SimpleCardsView> opponentHands) {
|
||||
this.opponentHands = opponentHands;
|
||||
}
|
||||
|
||||
public TurnPhase getPhase() {
|
||||
return phase;
|
||||
}
|
||||
public TurnPhase getPhase() {
|
||||
return phase;
|
||||
}
|
||||
|
||||
public PhaseStep getStep() {
|
||||
return step;
|
||||
}
|
||||
public PhaseStep getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public CardsView getStack() {
|
||||
return stack;
|
||||
}
|
||||
public CardsView getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public List<ExileView> getExile() {
|
||||
return exiles;
|
||||
}
|
||||
public List<ExileView> getExile() {
|
||||
return exiles;
|
||||
}
|
||||
|
||||
public List<RevealedView> getRevealed() {
|
||||
return revealed;
|
||||
}
|
||||
public List<RevealedView> getRevealed() {
|
||||
return revealed;
|
||||
}
|
||||
|
||||
public List<LookedAtView> getLookedAt() {
|
||||
return lookedAt;
|
||||
}
|
||||
public List<LookedAtView> getLookedAt() {
|
||||
return lookedAt;
|
||||
}
|
||||
|
||||
public void setLookedAt(List<LookedAtView> list) {
|
||||
this.lookedAt = list;
|
||||
}
|
||||
public void setLookedAt(List<LookedAtView> list) {
|
||||
this.lookedAt = list;
|
||||
}
|
||||
|
||||
public List<CombatGroupView> getCombat() {
|
||||
return combat;
|
||||
}
|
||||
public List<CombatGroupView> getCombat() {
|
||||
return combat;
|
||||
}
|
||||
|
||||
public int getTurn() {
|
||||
return this.turn;
|
||||
}
|
||||
public int getTurn() {
|
||||
return this.turn;
|
||||
}
|
||||
|
||||
public String getActivePlayerName() {
|
||||
return activePlayerName;
|
||||
}
|
||||
public String getActivePlayerName() {
|
||||
return activePlayerName;
|
||||
}
|
||||
|
||||
public String getPriorityPlayerName() {
|
||||
return priorityPlayerName;
|
||||
}
|
||||
public String getPriorityPlayerName() {
|
||||
return priorityPlayerName;
|
||||
}
|
||||
|
||||
public boolean getSpecial() {
|
||||
return special;
|
||||
}
|
||||
public boolean getSpecial() {
|
||||
return special;
|
||||
}
|
||||
|
||||
/*public List<UUID> getStackOrder() {
|
||||
return stackOrder;
|
||||
|
|
|
|||
|
|
@ -40,21 +40,21 @@ import java.io.Serializable;
|
|||
*/
|
||||
public class LookedAtView implements Serializable {
|
||||
|
||||
private String name;
|
||||
private SimpleCardsView cards = new SimpleCardsView();
|
||||
private String name;
|
||||
private SimpleCardsView cards = new SimpleCardsView();
|
||||
|
||||
public LookedAtView(String name, Cards cards, Game game) {
|
||||
this.name = name;
|
||||
for (Card card: cards.getCards(game)) {
|
||||
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
public LookedAtView(String name, Cards cards, Game game) {
|
||||
this.name = name;
|
||||
for (Card card: cards.getCards(game)) {
|
||||
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,52 +40,52 @@ import java.io.Serializable;
|
|||
public class ManaPoolView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int red;
|
||||
private int green;
|
||||
private int blue;
|
||||
private int white;
|
||||
private int black;
|
||||
private int colorless;
|
||||
private int red;
|
||||
private int green;
|
||||
private int blue;
|
||||
private int white;
|
||||
private int black;
|
||||
private int colorless;
|
||||
|
||||
public ManaPoolView(ManaPool pool) {
|
||||
this.red = pool.getRed();
|
||||
this.green = pool.getGreen();
|
||||
this.blue = pool.getBlue();
|
||||
this.white = pool.getWhite();
|
||||
this.black = pool.getBlack();
|
||||
this.colorless = pool.getColorless();
|
||||
for (ConditionalMana mana : pool.getConditionalMana()) {
|
||||
this.red += mana.getRed();
|
||||
this.green += mana.getGreen();
|
||||
this.blue += mana.getBlue();
|
||||
this.white += mana.getWhite();
|
||||
this.black += mana.getBlack();
|
||||
this.colorless += mana.getColorless();
|
||||
}
|
||||
}
|
||||
|
||||
public int getRed() {
|
||||
return red;
|
||||
}
|
||||
public ManaPoolView(ManaPool pool) {
|
||||
this.red = pool.getRed();
|
||||
this.green = pool.getGreen();
|
||||
this.blue = pool.getBlue();
|
||||
this.white = pool.getWhite();
|
||||
this.black = pool.getBlack();
|
||||
this.colorless = pool.getColorless();
|
||||
for (ConditionalMana mana : pool.getConditionalMana()) {
|
||||
this.red += mana.getRed();
|
||||
this.green += mana.getGreen();
|
||||
this.blue += mana.getBlue();
|
||||
this.white += mana.getWhite();
|
||||
this.black += mana.getBlack();
|
||||
this.colorless += mana.getColorless();
|
||||
}
|
||||
}
|
||||
|
||||
public int getGreen() {
|
||||
return green;
|
||||
}
|
||||
public int getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public int getBlue() {
|
||||
return blue;
|
||||
}
|
||||
public int getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public int getWhite() {
|
||||
return white;
|
||||
}
|
||||
public int getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
public int getBlack() {
|
||||
return black;
|
||||
}
|
||||
public int getWhite() {
|
||||
return white;
|
||||
}
|
||||
|
||||
public int getColorless() {
|
||||
return colorless;
|
||||
}
|
||||
public int getBlack() {
|
||||
return black;
|
||||
}
|
||||
|
||||
public int getColorless() {
|
||||
return colorless;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,16 +40,16 @@ import mage.game.match.MatchPlayer;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class MatchView implements Serializable {
|
||||
|
||||
private UUID matchId;
|
||||
|
||||
private UUID matchId;
|
||||
private String matchName;
|
||||
private String gameType;
|
||||
private String deckType;
|
||||
|
||||
|
||||
private List<UUID> games = new ArrayList<UUID>();
|
||||
private String result;
|
||||
private String players;
|
||||
|
||||
private String result;
|
||||
private String players;
|
||||
|
||||
public MatchView(Match match) {
|
||||
this.matchId = match.getId();
|
||||
this.matchName = match.getName();
|
||||
|
|
@ -66,35 +66,35 @@ public class MatchView implements Serializable {
|
|||
players = sb1.substring(0, sb1.length() - 2);
|
||||
result = sb2.substring(0, sb2.length() - 2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public UUID getMatchId() {
|
||||
return matchId;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return matchName;
|
||||
}
|
||||
|
||||
|
||||
public String getGameType() {
|
||||
return gameType;
|
||||
}
|
||||
|
||||
|
||||
public String getDeckType() {
|
||||
return deckType;
|
||||
}
|
||||
|
||||
|
||||
public List<UUID> getGames() {
|
||||
return games;
|
||||
}
|
||||
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,82 +43,82 @@ import mage.game.permanent.PermanentToken;
|
|||
public class PermanentView extends CardView {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean tapped;
|
||||
private boolean flipped;
|
||||
private boolean phasedIn;
|
||||
private boolean faceUp;
|
||||
private boolean summoningSickness;
|
||||
private int damage;
|
||||
private List<UUID> attachments;
|
||||
private List<CounterView> counters;
|
||||
private CardView original;
|
||||
private boolean tapped;
|
||||
private boolean flipped;
|
||||
private boolean phasedIn;
|
||||
private boolean faceUp;
|
||||
private boolean summoningSickness;
|
||||
private int damage;
|
||||
private List<UUID> attachments;
|
||||
private List<CounterView> counters;
|
||||
private CardView original;
|
||||
|
||||
public PermanentView(Permanent permanent, Card card) {
|
||||
super(permanent);
|
||||
this.rules = permanent.getRules();
|
||||
this.tapped = permanent.isTapped();
|
||||
this.flipped = permanent.isFlipped();
|
||||
this.phasedIn = permanent.isPhasedIn();
|
||||
this.faceUp = permanent.isFaceUp();
|
||||
this.summoningSickness = permanent.hasSummoningSickness();
|
||||
this.damage = permanent.getDamage();
|
||||
if (permanent.getAttachments().size() > 0) {
|
||||
attachments = new ArrayList<UUID>();
|
||||
attachments.addAll(permanent.getAttachments());
|
||||
}
|
||||
if (permanent.getCounters().size() > 0) {
|
||||
counters = new ArrayList<CounterView>();
|
||||
for (Counter counter: permanent.getCounters().values()) {
|
||||
counters.add(new CounterView(counter));
|
||||
}
|
||||
}
|
||||
if (permanent instanceof PermanentToken) {
|
||||
original = new CardView(((PermanentToken)permanent).getToken());
|
||||
original.expansionSetCode = permanent.getExpansionSetCode();
|
||||
}
|
||||
else {
|
||||
original = new CardView(card);
|
||||
}
|
||||
this.transformed = permanent.isTransformed();
|
||||
}
|
||||
public PermanentView(Permanent permanent, Card card) {
|
||||
super(permanent);
|
||||
this.rules = permanent.getRules();
|
||||
this.tapped = permanent.isTapped();
|
||||
this.flipped = permanent.isFlipped();
|
||||
this.phasedIn = permanent.isPhasedIn();
|
||||
this.faceUp = permanent.isFaceUp();
|
||||
this.summoningSickness = permanent.hasSummoningSickness();
|
||||
this.damage = permanent.getDamage();
|
||||
if (permanent.getAttachments().size() > 0) {
|
||||
attachments = new ArrayList<UUID>();
|
||||
attachments.addAll(permanent.getAttachments());
|
||||
}
|
||||
if (permanent.getCounters().size() > 0) {
|
||||
counters = new ArrayList<CounterView>();
|
||||
for (Counter counter: permanent.getCounters().values()) {
|
||||
counters.add(new CounterView(counter));
|
||||
}
|
||||
}
|
||||
if (permanent instanceof PermanentToken) {
|
||||
original = new CardView(((PermanentToken)permanent).getToken());
|
||||
original.expansionSetCode = permanent.getExpansionSetCode();
|
||||
}
|
||||
else {
|
||||
original = new CardView(card);
|
||||
}
|
||||
this.transformed = permanent.isTransformed();
|
||||
}
|
||||
|
||||
public boolean isTapped() {
|
||||
return tapped;
|
||||
}
|
||||
public boolean isTapped() {
|
||||
return tapped;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public boolean isFlipped() {
|
||||
return flipped;
|
||||
}
|
||||
public boolean isFlipped() {
|
||||
return flipped;
|
||||
}
|
||||
|
||||
public boolean isPhasedIn() {
|
||||
return phasedIn;
|
||||
}
|
||||
public boolean isPhasedIn() {
|
||||
return phasedIn;
|
||||
}
|
||||
|
||||
public boolean isFaceUp() {
|
||||
return faceUp;
|
||||
}
|
||||
public boolean isFaceUp() {
|
||||
return faceUp;
|
||||
}
|
||||
|
||||
public boolean hasSummoningSickness(){
|
||||
return summoningSickness;
|
||||
}
|
||||
public boolean hasSummoningSickness(){
|
||||
return summoningSickness;
|
||||
}
|
||||
|
||||
public List<UUID> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
public List<UUID> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public List<CounterView> getCounters() {
|
||||
return counters;
|
||||
}
|
||||
public List<CounterView> getCounters() {
|
||||
return counters;
|
||||
}
|
||||
|
||||
public CardView getOriginal() {
|
||||
return original;
|
||||
}
|
||||
|
||||
public void overrideTapped(boolean tapped) {
|
||||
this.tapped = tapped;
|
||||
}
|
||||
public CardView getOriginal() {
|
||||
return original;
|
||||
}
|
||||
|
||||
public void overrideTapped(boolean tapped) {
|
||||
this.tapped = tapped;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,111 +46,111 @@ import mage.players.Player;
|
|||
public class PlayerView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private UUID playerId;
|
||||
private String name;
|
||||
private int life;
|
||||
private int poison;
|
||||
private int libraryCount;
|
||||
private int handCount;
|
||||
private boolean isActive;
|
||||
private boolean hasLeft;
|
||||
private ManaPoolView manaPool;
|
||||
private SimpleCardsView graveyard = new SimpleCardsView();
|
||||
private Map<UUID, PermanentView> battlefield = new HashMap<UUID, PermanentView>();
|
||||
private CardView topCard;
|
||||
private UserDataView userDataView;
|
||||
private UUID playerId;
|
||||
private String name;
|
||||
private int life;
|
||||
private int poison;
|
||||
private int libraryCount;
|
||||
private int handCount;
|
||||
private boolean isActive;
|
||||
private boolean hasLeft;
|
||||
private ManaPoolView manaPool;
|
||||
private SimpleCardsView graveyard = new SimpleCardsView();
|
||||
private Map<UUID, PermanentView> battlefield = new HashMap<UUID, PermanentView>();
|
||||
private CardView topCard;
|
||||
private UserDataView userDataView;
|
||||
|
||||
public PlayerView(Player player, GameState state, Game game) {
|
||||
this.playerId = player.getId();
|
||||
this.name = player.getName();
|
||||
this.life = player.getLife();
|
||||
this.poison = player.getCounters().getCount(CounterType.POISON);
|
||||
this.libraryCount = player.getLibrary().size();
|
||||
this.handCount = player.getHand().size();
|
||||
this.manaPool = new ManaPoolView(player.getManaPool());
|
||||
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
||||
this.hasLeft = player.hasLeft();
|
||||
for (Card card: player.getGraveyard().getCards(game)) {
|
||||
graveyard.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
for (Permanent permanent: state.getBattlefield().getAllPermanents()) {
|
||||
if (showInBattlefield(permanent, state)) {
|
||||
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()));
|
||||
battlefield.put(view.getId(), view);
|
||||
}
|
||||
}
|
||||
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0 ?
|
||||
new CardView(player.getLibrary().getFromTop(game)) : null;
|
||||
if (player.getUserData() != null) {
|
||||
this.userDataView = new UserDataView(player.getUserData());
|
||||
} else {
|
||||
this.userDataView = new UserDataView(0);
|
||||
}
|
||||
}
|
||||
public PlayerView(Player player, GameState state, Game game) {
|
||||
this.playerId = player.getId();
|
||||
this.name = player.getName();
|
||||
this.life = player.getLife();
|
||||
this.poison = player.getCounters().getCount(CounterType.POISON);
|
||||
this.libraryCount = player.getLibrary().size();
|
||||
this.handCount = player.getHand().size();
|
||||
this.manaPool = new ManaPoolView(player.getManaPool());
|
||||
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
||||
this.hasLeft = player.hasLeft();
|
||||
for (Card card: player.getGraveyard().getCards(game)) {
|
||||
graveyard.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
for (Permanent permanent: state.getBattlefield().getAllPermanents()) {
|
||||
if (showInBattlefield(permanent, state)) {
|
||||
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()));
|
||||
battlefield.put(view.getId(), view);
|
||||
}
|
||||
}
|
||||
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0 ?
|
||||
new CardView(player.getLibrary().getFromTop(game)) : null;
|
||||
if (player.getUserData() != null) {
|
||||
this.userDataView = new UserDataView(player.getUserData());
|
||||
} else {
|
||||
this.userDataView = new UserDataView(0);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean showInBattlefield(Permanent permanent, GameState state) {
|
||||
private boolean showInBattlefield(Permanent permanent, GameState state) {
|
||||
|
||||
//show permanents controlled by player or attachments to permanents controlled by player
|
||||
if (permanent.getAttachedTo() == null)
|
||||
return permanent.getControllerId().equals(playerId);
|
||||
else {
|
||||
Permanent attachedTo = state.getPermanent(permanent.getAttachedTo());
|
||||
if (attachedTo != null)
|
||||
return attachedTo.getControllerId().equals(playerId);
|
||||
else
|
||||
return permanent.getControllerId().equals(playerId);
|
||||
}
|
||||
}
|
||||
//show permanents controlled by player or attachments to permanents controlled by player
|
||||
if (permanent.getAttachedTo() == null)
|
||||
return permanent.getControllerId().equals(playerId);
|
||||
else {
|
||||
Permanent attachedTo = state.getPermanent(permanent.getAttachedTo());
|
||||
if (attachedTo != null)
|
||||
return attachedTo.getControllerId().equals(playerId);
|
||||
else
|
||||
return permanent.getControllerId().equals(playerId);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLife() {
|
||||
return this.life;
|
||||
}
|
||||
public int getLife() {
|
||||
return this.life;
|
||||
}
|
||||
|
||||
public int getPoison() {
|
||||
return this.poison;
|
||||
}
|
||||
public int getPoison() {
|
||||
return this.poison;
|
||||
}
|
||||
|
||||
public int getLibraryCount() {
|
||||
return this.libraryCount;
|
||||
}
|
||||
public int getLibraryCount() {
|
||||
return this.libraryCount;
|
||||
}
|
||||
|
||||
public int getHandCount() {
|
||||
return this.handCount;
|
||||
}
|
||||
public int getHandCount() {
|
||||
return this.handCount;
|
||||
}
|
||||
|
||||
public ManaPoolView getManaPool() {
|
||||
return this.manaPool;
|
||||
}
|
||||
public ManaPoolView getManaPool() {
|
||||
return this.manaPool;
|
||||
}
|
||||
|
||||
public SimpleCardsView getGraveyard() {
|
||||
return this.graveyard;
|
||||
}
|
||||
public SimpleCardsView getGraveyard() {
|
||||
return this.graveyard;
|
||||
}
|
||||
|
||||
public Map<UUID, PermanentView> getBattlefield() {
|
||||
return this.battlefield;
|
||||
}
|
||||
public Map<UUID, PermanentView> getBattlefield() {
|
||||
return this.battlefield;
|
||||
}
|
||||
|
||||
public UUID getPlayerId() {
|
||||
return this.playerId;
|
||||
}
|
||||
public UUID getPlayerId() {
|
||||
return this.playerId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.isActive;
|
||||
}
|
||||
public boolean isActive() {
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
public boolean hasLeft() {
|
||||
return this.hasLeft;
|
||||
}
|
||||
public boolean hasLeft() {
|
||||
return this.hasLeft;
|
||||
}
|
||||
|
||||
public CardView getTopCard() {
|
||||
return this.topCard;
|
||||
}
|
||||
public CardView getTopCard() {
|
||||
return this.topCard;
|
||||
}
|
||||
|
||||
public UserDataView getUserData() {
|
||||
return this.userDataView;
|
||||
}
|
||||
public UserDataView getUserData() {
|
||||
return this.userDataView;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,21 +39,21 @@ import mage.game.Game;
|
|||
*/
|
||||
public class RevealedView implements Serializable {
|
||||
|
||||
private String name;
|
||||
private SimpleCardsView cards = new SimpleCardsView();
|
||||
private String name;
|
||||
private SimpleCardsView cards = new SimpleCardsView();
|
||||
|
||||
public RevealedView(String name, Cards cards, Game game) {
|
||||
this.name = name;
|
||||
for (Card card: cards.getCards(game)) {
|
||||
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
public RevealedView(String name, Cards cards, Game game) {
|
||||
this.name = name;
|
||||
for (Card card: cards.getCards(game)) {
|
||||
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
public SimpleCardsView getCards() {
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,20 +42,20 @@ import mage.game.tournament.TournamentPairing;
|
|||
public class RoundView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
List<TournamentGameView> games = new ArrayList<TournamentGameView>();
|
||||
List<TournamentGameView> games = new ArrayList<TournamentGameView>();
|
||||
|
||||
public RoundView(Round round) {
|
||||
for (TournamentPairing pair: round.getPairs()) {
|
||||
if (pair.getMatch() != null) {
|
||||
for (Game game: pair.getMatch().getGames()) {
|
||||
games.add(new TournamentGameView(round.getRoundNumber(), pair, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public RoundView(Round round) {
|
||||
for (TournamentPairing pair: round.getPairs()) {
|
||||
if (pair.getMatch() != null) {
|
||||
for (Game game: pair.getMatch().getGames()) {
|
||||
games.add(new TournamentGameView(round.getRoundNumber(), pair, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<TournamentGameView> getGames() {
|
||||
return games;
|
||||
}
|
||||
public List<TournamentGameView> getGames() {
|
||||
return games;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,28 +39,28 @@ import mage.game.Seat;
|
|||
public class SeatView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private UUID playerId;
|
||||
private String playerName;
|
||||
private String playerType;
|
||||
|
||||
public SeatView(Seat seat) {
|
||||
if (seat.getPlayer() != null) {
|
||||
this.playerId = seat.getPlayer().getId();
|
||||
this.playerName = seat.getPlayer().getName();
|
||||
}
|
||||
this.playerType = seat.getPlayerType();
|
||||
}
|
||||
private UUID playerId;
|
||||
private String playerName;
|
||||
private String playerType;
|
||||
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
public SeatView(Seat seat) {
|
||||
if (seat.getPlayer() != null) {
|
||||
this.playerId = seat.getPlayer().getId();
|
||||
this.playerName = seat.getPlayer().getName();
|
||||
}
|
||||
this.playerType = seat.getPlayerType();
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public String getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public String getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ import java.util.UUID;
|
|||
*/
|
||||
public class SimpleCardView implements Serializable {
|
||||
protected UUID id;
|
||||
protected String expansionSetCode;
|
||||
protected int cardNumber;
|
||||
protected boolean faceDown;
|
||||
protected String expansionSetCode;
|
||||
protected int cardNumber;
|
||||
protected boolean faceDown;
|
||||
|
||||
public SimpleCardView(UUID id, String expansionSetCode, int cardNumber, boolean faceDown) {
|
||||
this.id = id;
|
||||
|
|
@ -47,19 +47,19 @@ public class SimpleCardView implements Serializable {
|
|||
this.cardNumber = cardNumber;
|
||||
this.faceDown = faceDown;
|
||||
}
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public String getExpansionSetCode() {
|
||||
return expansionSetCode;
|
||||
}
|
||||
|
||||
|
||||
public int getCardNumber() {
|
||||
return cardNumber;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFaceDown() {
|
||||
return faceDown;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ import mage.cards.Card;
|
|||
*/
|
||||
public class SimpleCardsView extends HashMap<UUID, SimpleCardView> {
|
||||
|
||||
public SimpleCardsView() {}
|
||||
public SimpleCardsView() {}
|
||||
|
||||
public SimpleCardsView(Collection<Card> cards) {
|
||||
for (Card card: cards) {
|
||||
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
public SimpleCardsView(Collection<Card> cards) {
|
||||
for (Card card: cards) {
|
||||
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,28 +39,28 @@ import mage.game.stack.StackAbility;
|
|||
public class StackAbilityView extends CardView {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String sourceName;
|
||||
private CardView sourceCard;
|
||||
private String sourceName;
|
||||
private CardView sourceCard;
|
||||
|
||||
public StackAbilityView(StackAbility ability, String sourceName, CardView sourceCard) {
|
||||
this.id = ability.getId();
|
||||
this.name = "Ability";
|
||||
this.sourceName = sourceName;
|
||||
this.sourceCard = sourceCard;
|
||||
this.rules = new ArrayList<String>();
|
||||
rules.add(ability.getRule(sourceName));
|
||||
this.power = ability.getPower().toString();
|
||||
this.toughness = ability.getToughness().toString();
|
||||
this.loyalty = "";
|
||||
this.cardTypes = ability.getCardType();
|
||||
this.subTypes = ability.getSubtype();
|
||||
this.superTypes = ability.getSupertype();
|
||||
this.color = ability.getColor();
|
||||
this.manaCost = ability.getManaCost().getSymbols();
|
||||
setTargets(ability.getTargets());
|
||||
}
|
||||
public StackAbilityView(StackAbility ability, String sourceName, CardView sourceCard) {
|
||||
this.id = ability.getId();
|
||||
this.name = "Ability";
|
||||
this.sourceName = sourceName;
|
||||
this.sourceCard = sourceCard;
|
||||
this.rules = new ArrayList<String>();
|
||||
rules.add(ability.getRule(sourceName));
|
||||
this.power = ability.getPower().toString();
|
||||
this.toughness = ability.getToughness().toString();
|
||||
this.loyalty = "";
|
||||
this.cardTypes = ability.getCardType();
|
||||
this.subTypes = ability.getSubtype();
|
||||
this.superTypes = ability.getSupertype();
|
||||
this.color = ability.getColor();
|
||||
this.manaCost = ability.getManaCost().getSymbols();
|
||||
setTargets(ability.getTargets());
|
||||
}
|
||||
|
||||
public CardView getSourceCard() {
|
||||
return this.sourceCard;
|
||||
}
|
||||
public CardView getSourceCard() {
|
||||
return this.sourceCard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,67 +40,67 @@ import mage.cards.decks.Deck;
|
|||
public class TableClientMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private DeckView deck;
|
||||
private DeckView deck;
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID gameId;
|
||||
private UUID playerId;
|
||||
private int time;
|
||||
private UUID tableId;
|
||||
private UUID gameId;
|
||||
private UUID playerId;
|
||||
private int time;
|
||||
private boolean flag = false;
|
||||
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time, boolean flag) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.time = time;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID gameId, UUID playerId) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID roomId, UUID tableId, boolean flag) {
|
||||
this.roomId = roomId;
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.flag = flag;
|
||||
}
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public TableClientMessage(Deck deck, UUID tableId, int time, boolean flag) {
|
||||
this.deck = new DeckView(deck);
|
||||
this.tableId = tableId;
|
||||
this.time = time;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID gameId, UUID playerId) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public TableClientMessage(UUID roomId, UUID tableId, boolean flag) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public DeckView getDeck() {
|
||||
return deck;
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
public UUID getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
public UUID getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public UUID getGameId() {
|
||||
return gameId;
|
||||
}
|
||||
return gameId;
|
||||
}
|
||||
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
public void cleanUp() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,75 +44,75 @@ import mage.game.Table;
|
|||
*/
|
||||
public class TableView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private UUID tableId;
|
||||
private String gameType;
|
||||
private String deckType;
|
||||
private String tableName;
|
||||
private String controllerName;
|
||||
private Date createTime;
|
||||
private TableState tableState;
|
||||
private boolean isTournament;
|
||||
private List<SeatView> seats = new ArrayList<SeatView>();
|
||||
private List<UUID> games = new ArrayList<UUID>();
|
||||
|
||||
public TableView(Table table) {
|
||||
this.tableId = table.getId();
|
||||
this.gameType = table.getGameType();
|
||||
this.tableName = table.getName();
|
||||
this.controllerName = table.getControllerName();
|
||||
this.createTime = table.getCreateTime();
|
||||
this.deckType = table.getDeckType();
|
||||
this.tableState = table.getState();
|
||||
this.isTournament = table.isTournament();
|
||||
for (Seat seat: table.getSeats()) {
|
||||
seats.add(new SeatView(seat));
|
||||
}
|
||||
if (!table.isTournament()) {
|
||||
for (Game game: table.getMatch().getGames()) {
|
||||
games.add(game.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
private UUID tableId;
|
||||
private String gameType;
|
||||
private String deckType;
|
||||
private String tableName;
|
||||
private String controllerName;
|
||||
private Date createTime;
|
||||
private TableState tableState;
|
||||
private boolean isTournament;
|
||||
private List<SeatView> seats = new ArrayList<SeatView>();
|
||||
private List<UUID> games = new ArrayList<UUID>();
|
||||
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
public TableView(Table table) {
|
||||
this.tableId = table.getId();
|
||||
this.gameType = table.getGameType();
|
||||
this.tableName = table.getName();
|
||||
this.controllerName = table.getControllerName();
|
||||
this.createTime = table.getCreateTime();
|
||||
this.deckType = table.getDeckType();
|
||||
this.tableState = table.getState();
|
||||
this.isTournament = table.isTournament();
|
||||
for (Seat seat: table.getSeats()) {
|
||||
seats.add(new SeatView(seat));
|
||||
}
|
||||
if (!table.isTournament()) {
|
||||
for (Game game: table.getMatch().getGames()) {
|
||||
games.add(game.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
public UUID getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
public String getControllerName() {
|
||||
return controllerName;
|
||||
}
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public String getGameType() {
|
||||
return gameType;
|
||||
}
|
||||
public String getControllerName() {
|
||||
return controllerName;
|
||||
}
|
||||
|
||||
public String getDeckType() {
|
||||
return deckType;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public String getGameType() {
|
||||
return gameType;
|
||||
}
|
||||
|
||||
public TableState getTableState() {
|
||||
return tableState;
|
||||
}
|
||||
public String getDeckType() {
|
||||
return deckType;
|
||||
}
|
||||
|
||||
public List<SeatView> getSeats() {
|
||||
return seats;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public List<UUID> getGames() {
|
||||
return games;
|
||||
}
|
||||
public TableState getTableState() {
|
||||
return tableState;
|
||||
}
|
||||
|
||||
public boolean isTournament() {
|
||||
return this.isTournament;
|
||||
}
|
||||
public List<SeatView> getSeats() {
|
||||
return seats;
|
||||
}
|
||||
|
||||
public List<UUID> getGames() {
|
||||
return games;
|
||||
}
|
||||
|
||||
public boolean isTournament() {
|
||||
return this.isTournament;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,49 +41,49 @@ import mage.game.tournament.TournamentPairing;
|
|||
public class TournamentGameView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int roundNum;
|
||||
private UUID matchId;
|
||||
private UUID gameId;
|
||||
private String state;
|
||||
private String result;
|
||||
private String players;
|
||||
private int roundNum;
|
||||
private UUID matchId;
|
||||
private UUID gameId;
|
||||
private String state;
|
||||
private String result;
|
||||
private String players;
|
||||
|
||||
TournamentGameView(int roundNum, TournamentPairing pair, Game game) {
|
||||
this.roundNum = roundNum;
|
||||
this.matchId = pair.getMatch().getId();
|
||||
this.gameId = game.getId();
|
||||
this.players = pair.getPlayer1().getPlayer().getName() + " " + pair.getPlayer2().getPlayer().getName();
|
||||
if (game.isGameOver()) {
|
||||
this.state = "Finished";
|
||||
this.result = game.getWinner();
|
||||
}
|
||||
else {
|
||||
this.state = "Dueling";
|
||||
this.result = "";
|
||||
}
|
||||
}
|
||||
TournamentGameView(int roundNum, TournamentPairing pair, Game game) {
|
||||
this.roundNum = roundNum;
|
||||
this.matchId = pair.getMatch().getId();
|
||||
this.gameId = game.getId();
|
||||
this.players = pair.getPlayer1().getPlayer().getName() + " " + pair.getPlayer2().getPlayer().getName();
|
||||
if (game.isGameOver()) {
|
||||
this.state = "Finished";
|
||||
this.result = game.getWinner();
|
||||
}
|
||||
else {
|
||||
this.state = "Dueling";
|
||||
this.result = "";
|
||||
}
|
||||
}
|
||||
|
||||
public int getRoundNum() {
|
||||
return roundNum;
|
||||
}
|
||||
public int getRoundNum() {
|
||||
return roundNum;
|
||||
}
|
||||
|
||||
public UUID getMatchId() {
|
||||
return this.matchId;
|
||||
}
|
||||
public UUID getMatchId() {
|
||||
return this.matchId;
|
||||
}
|
||||
|
||||
public UUID getGameId() {
|
||||
return this.gameId;
|
||||
}
|
||||
public UUID getGameId() {
|
||||
return this.gameId;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return this.result;
|
||||
}
|
||||
public String getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public String getPlayers() {
|
||||
return this.players;
|
||||
}
|
||||
public String getPlayers() {
|
||||
return this.players;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,25 +38,25 @@ import mage.game.tournament.TournamentPlayer;
|
|||
public class TournamentPlayerView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private String results;
|
||||
private int points;
|
||||
private String name;
|
||||
private String results;
|
||||
private int points;
|
||||
|
||||
TournamentPlayerView(TournamentPlayer player) {
|
||||
this.name = player.getPlayer().getName();
|
||||
this.points = player.getPoints();
|
||||
this.results = player.getResults();
|
||||
}
|
||||
TournamentPlayerView(TournamentPlayer player) {
|
||||
this.name = player.getPlayer().getName();
|
||||
this.points = player.getPoints();
|
||||
this.results = player.getResults();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return this.points;
|
||||
}
|
||||
public int getPoints() {
|
||||
return this.points;
|
||||
}
|
||||
|
||||
public String getResults() {
|
||||
return results;
|
||||
}
|
||||
public String getResults() {
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,48 +38,48 @@ import mage.game.tournament.TournamentType;
|
|||
public class TournamentTypeView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private int minPlayers;
|
||||
private int maxPlayers;
|
||||
private int numBoosters;
|
||||
private boolean draft;
|
||||
private boolean limited;
|
||||
private String name;
|
||||
private int minPlayers;
|
||||
private int maxPlayers;
|
||||
private int numBoosters;
|
||||
private boolean draft;
|
||||
private boolean limited;
|
||||
|
||||
public TournamentTypeView(TournamentType tournamentType) {
|
||||
this.name = tournamentType.getName();
|
||||
this.minPlayers = tournamentType.getMinPlayers();
|
||||
this.maxPlayers = tournamentType.getMaxPlayers();
|
||||
this.numBoosters = tournamentType.getNumBoosters();
|
||||
this.draft = tournamentType.isDraft();
|
||||
this.limited = tournamentType.isLimited();
|
||||
}
|
||||
public TournamentTypeView(TournamentType tournamentType) {
|
||||
this.name = tournamentType.getName();
|
||||
this.minPlayers = tournamentType.getMinPlayers();
|
||||
this.maxPlayers = tournamentType.getMaxPlayers();
|
||||
this.numBoosters = tournamentType.getNumBoosters();
|
||||
this.draft = tournamentType.isDraft();
|
||||
this.limited = tournamentType.isLimited();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getMinPlayers() {
|
||||
return minPlayers;
|
||||
}
|
||||
public int getMinPlayers() {
|
||||
return minPlayers;
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
public int getMaxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
|
||||
public int getNumBoosters() {
|
||||
return numBoosters;
|
||||
}
|
||||
public int getNumBoosters() {
|
||||
return numBoosters;
|
||||
}
|
||||
|
||||
public boolean isDraft() {
|
||||
return draft;
|
||||
}
|
||||
public boolean isDraft() {
|
||||
return draft;
|
||||
}
|
||||
|
||||
public boolean isLimited() {
|
||||
return limited;
|
||||
}
|
||||
public boolean isLimited() {
|
||||
return limited;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,23 +42,23 @@ import mage.game.tournament.TournamentPlayer;
|
|||
public class TournamentView implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
List<RoundView> rounds = new ArrayList<RoundView>();
|
||||
List<TournamentPlayerView> players = new ArrayList<TournamentPlayerView>();
|
||||
List<RoundView> rounds = new ArrayList<RoundView>();
|
||||
List<TournamentPlayerView> players = new ArrayList<TournamentPlayerView>();
|
||||
|
||||
public TournamentView(Tournament tournament) {
|
||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
||||
players.add(new TournamentPlayerView(player));
|
||||
}
|
||||
for (Round round: tournament.getRounds()) {
|
||||
rounds.add(new RoundView(round));
|
||||
}
|
||||
}
|
||||
public TournamentView(Tournament tournament) {
|
||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
||||
players.add(new TournamentPlayerView(player));
|
||||
}
|
||||
for (Round round: tournament.getRounds()) {
|
||||
rounds.add(new RoundView(round));
|
||||
}
|
||||
}
|
||||
|
||||
public List<TournamentPlayerView> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
public List<TournamentPlayerView> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
public List<RoundView> getRounds() {
|
||||
return rounds;
|
||||
}
|
||||
public List<RoundView> getRounds() {
|
||||
return rounds;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@ import java.io.Serializable;
|
|||
*/
|
||||
public class UserDataView implements Serializable {
|
||||
|
||||
protected int avatarId;
|
||||
protected int userGroup;
|
||||
protected int avatarId;
|
||||
protected int userGroup;
|
||||
|
||||
public UserDataView(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
public UserDataView(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public UserDataView(UserData userData) {
|
||||
this.avatarId = userData.getAvatarId();
|
||||
this.userGroup = userData.getGroupId();
|
||||
}
|
||||
public UserDataView(UserData userData) {
|
||||
this.avatarId = userData.getAvatarId();
|
||||
this.userGroup = userData.getGroupId();
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,33 +35,33 @@ import java.util.Date;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class UserView implements Serializable {
|
||||
|
||||
private String userName;
|
||||
private String host;
|
||||
private String sessionId;
|
||||
private Date timeConnected;
|
||||
|
||||
public UserView(String userName, String host, String sessionId, Date timeConnected) {
|
||||
this.userName = userName;
|
||||
this.host = host;
|
||||
this.sessionId = sessionId;
|
||||
this.timeConnected = timeConnected;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
private String userName;
|
||||
private String host;
|
||||
private String sessionId;
|
||||
private Date timeConnected;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
public UserView(String userName, String host, String sessionId, Date timeConnected) {
|
||||
this.userName = userName;
|
||||
this.host = host;
|
||||
this.sessionId = sessionId;
|
||||
this.timeConnected = timeConnected;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public Date getConnectionTime() {
|
||||
return timeConnected;
|
||||
}
|
||||
|
||||
public String getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public Date getConnectionTime() {
|
||||
return timeConnected;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue