Change all line endings to LF

This commit is contained in:
Fenhl 2016-04-13 16:34:45 +00:00
parent 13d9a56b7a
commit 430ae503c7
17069 changed files with 1263498 additions and 1263497 deletions

View file

@ -1,61 +1,61 @@
package mage.cards;
import java.awt.Image;
import java.util.UUID;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
public abstract class MageCard extends JPanel {
private static final long serialVersionUID = 6089945326434301879L;
public abstract void onBeginAnimation();
public abstract void onEndAnimation();
public abstract boolean isTapped();
public abstract boolean isFlipped();
public abstract void setAlpha(float transparency);
public abstract float getAlpha();
public abstract CardView getOriginal();
// sets the vertical text offset for the card name on the image
public abstract void setTextOffset(int yOffset);
public abstract void setCardBounds(int x, int y, int width, int height);
public abstract void update(CardView card);
public abstract void updateImage();
public abstract Image getImage();
public abstract void setZone(String zone);
public abstract String getZone();
public abstract void updateCallback(ActionCallback callback, UUID gameId);
public abstract void toggleTransformed();
public abstract boolean isTransformed();
public abstract void showCardTitle();
public abstract void setSelected(boolean selected);
public abstract void setCardAreaRef(JPanel cardArea);
public abstract void setChoosable(boolean isChoosable);
public abstract void setPopupMenu(JPopupMenu popupMenu);
public abstract JPopupMenu getPopupMenu();
}
package mage.cards;
import java.awt.Image;
import java.util.UUID;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
public abstract class MageCard extends JPanel {
private static final long serialVersionUID = 6089945326434301879L;
public abstract void onBeginAnimation();
public abstract void onEndAnimation();
public abstract boolean isTapped();
public abstract boolean isFlipped();
public abstract void setAlpha(float transparency);
public abstract float getAlpha();
public abstract CardView getOriginal();
// sets the vertical text offset for the card name on the image
public abstract void setTextOffset(int yOffset);
public abstract void setCardBounds(int x, int y, int width, int height);
public abstract void update(CardView card);
public abstract void updateImage();
public abstract Image getImage();
public abstract void setZone(String zone);
public abstract String getZone();
public abstract void updateCallback(ActionCallback callback, UUID gameId);
public abstract void toggleTransformed();
public abstract boolean isTransformed();
public abstract void showCardTitle();
public abstract void setSelected(boolean selected);
public abstract void setCardAreaRef(JPanel cardArea);
public abstract void setChoosable(boolean isChoosable);
public abstract void setPopupMenu(JPopupMenu popupMenu);
public abstract JPopupMenu getPopupMenu();
}

View file

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

View file

@ -1,17 +1,17 @@
package mage.cards.action;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
public interface ActionCallback {
void mouseClicked(MouseEvent e, TransferData data);
void mousePressed(MouseEvent e, TransferData data);
void mouseReleased(MouseEvent e, TransferData data);
void mouseMoved(MouseEvent e, TransferData data);
void mouseDragged(MouseEvent e, TransferData data);
void mouseEntered(MouseEvent e, TransferData data);
void mouseExited(MouseEvent e, TransferData data);
void mouseWheelMoved(MouseWheelEvent e, TransferData data);
void hideTooltipPopup();
}
package mage.cards.action;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
public interface ActionCallback {
void mouseClicked(MouseEvent e, TransferData data);
void mousePressed(MouseEvent e, TransferData data);
void mouseReleased(MouseEvent e, TransferData data);
void mouseMoved(MouseEvent e, TransferData data);
void mouseDragged(MouseEvent e, TransferData data);
void mouseEntered(MouseEvent e, TransferData data);
void mouseExited(MouseEvent e, TransferData data);
void mouseWheelMoved(MouseWheelEvent e, TransferData data);
void hideTooltipPopup();
}

View file

@ -1,17 +1,17 @@
package mage.cards.action;
import java.awt.Component;
import java.awt.Point;
import java.util.UUID;
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;
}
package mage.cards.action;
import java.awt.Component;
import java.awt.Point;
import java.util.UUID;
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;
}

View file

@ -1,53 +1,53 @@
package mage.cards.action.impl;
import mage.cards.action.ActionCallback;
import mage.cards.action.TransferData;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
/**
* Callback that does nothing on any action
*
* @author nantuko84
*/
public class EmptyCallback implements ActionCallback {
@Override
public void mouseMoved(MouseEvent e, TransferData data) {
}
@Override
public void mouseDragged(MouseEvent e, TransferData data) {
}
@Override
public void mouseEntered(MouseEvent e, TransferData data) {
}
@Override
public void mouseExited(MouseEvent e, TransferData data) {
}
@Override
public void mouseWheelMoved(MouseWheelEvent e, TransferData data) {
}
@Override
public void hideTooltipPopup() {
}
@Override
public void mouseClicked(MouseEvent e, TransferData data) {
}
@Override
public void mousePressed(MouseEvent e, TransferData data) {
}
@Override
public void mouseReleased(MouseEvent e, TransferData data) {
}
}
package mage.cards.action.impl;
import mage.cards.action.ActionCallback;
import mage.cards.action.TransferData;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
/**
* Callback that does nothing on any action
*
* @author nantuko84
*/
public class EmptyCallback implements ActionCallback {
@Override
public void mouseMoved(MouseEvent e, TransferData data) {
}
@Override
public void mouseDragged(MouseEvent e, TransferData data) {
}
@Override
public void mouseEntered(MouseEvent e, TransferData data) {
}
@Override
public void mouseExited(MouseEvent e, TransferData data) {
}
@Override
public void mouseWheelMoved(MouseWheelEvent e, TransferData data) {
}
@Override
public void hideTooltipPopup() {
}
@Override
public void mouseClicked(MouseEvent e, TransferData data) {
}
@Override
public void mousePressed(MouseEvent e, TransferData data) {
}
@Override
public void mouseReleased(MouseEvent e, TransferData data) {
}
}

View file

@ -1,17 +1,17 @@
package mage.components;
import mage.view.CardView;
import java.awt.*;
/**
* Card info pane for displaying card rules.
* Supports drawing mana symbols.
*
* @author nantuko
*/
public interface CardInfoPane {
void setCard(CardView card, Component container);
boolean isCurrentCard (CardView card);
}
package mage.components;
import mage.view.CardView;
import java.awt.*;
/**
* Card info pane for displaying card rules.
* Supports drawing mana symbols.
*
* @author nantuko
*/
public interface CardInfoPane {
void setCard(CardView card, Component container);
boolean isCurrentCard (CardView card);
}

View file

@ -1,101 +1,101 @@
package mage.components;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
@SuppressWarnings("serial")
public class ImagePanel extends JPanel {
public static final int TILED = 0;
public static final int SCALED = 1;
public static final int ACTUAL = 2;
private BufferedImage image;
private int style;
private float alignmentX = 0.5f;
private float alignmentY = 0.5f;
public ImagePanel(BufferedImage image) {
this(image, TILED);
}
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 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, 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 (c instanceof JComponent) {
((JComponent) c).setOpaque(false);
}
}
super.add(component, constraints);
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image == null)
return;
switch (style) {
case TILED:
drawTiled(g);
break;
case SCALED:
Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null);
break;
case ACTUAL:
drawActual(g);
break;
}
}
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);
}
}
}
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);
}
}
package mage.components;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
@SuppressWarnings("serial")
public class ImagePanel extends JPanel {
public static final int TILED = 0;
public static final int SCALED = 1;
public static final int ACTUAL = 2;
private BufferedImage image;
private int style;
private float alignmentX = 0.5f;
private float alignmentY = 0.5f;
public ImagePanel(BufferedImage image) {
this(image, TILED);
}
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 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, 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 (c instanceof JComponent) {
((JComponent) c).setOpaque(false);
}
}
super.add(component, constraints);
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image == null)
return;
switch (style) {
case TILED:
drawTiled(g);
break;
case SCALED:
Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null);
break;
case ACTUAL:
drawActual(g);
break;
}
}
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);
}
}
}
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);
}
}

View file

@ -1,68 +1,68 @@
package mage.filters;
import java.awt.*;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ColorModel;
/**
* Mage abstract class that implements single-input/single-output
* operations performed on {@link java.awt.image.BufferedImage}.
*
* @author nantuko
*/
public abstract class MageBufferedImageOp implements BufferedImageOp {
/**
* Creates compatible image for @param src image.
*/
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dest) {
if (dest == null) {
dest = src.getColorModel();
}
return new BufferedImage(dest, dest.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dest.isAlphaPremultiplied(), null);
}
public RenderingHints getRenderingHints() {
return null;
}
public Rectangle2D getBounds2D(BufferedImage src) {
return new Rectangle(0, 0, src.getWidth(), src.getHeight());
}
public Point2D getPoint2D(Point2D srcPt, Point2D destPt) {
if (destPt == null) {
destPt = new Point2D.Double();
}
destPt.setLocation(srcPt.getX(), srcPt.getY());
return destPt;
}
/**
* Gets ARGB pixels from image. Solves the performance
* issue of BufferedImage.getRGB method.
*/
public int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) {
return (int[]) image.getRaster().getDataElements(x, y, width, height, pixels);
}
return image.getRGB(x, y, width, height, pixels, 0, width);
}
/**
* Sets ARGB pixels in image. Solves the performance
* issue of BufferedImage.setRGB method.
*/
public void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) {
image.getRaster().setDataElements(x, y, width, height, pixels);
} else {
image.setRGB(x, y, width, height, pixels, 0, width);
}
}
}
package mage.filters;
import java.awt.*;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ColorModel;
/**
* Mage abstract class that implements single-input/single-output
* operations performed on {@link java.awt.image.BufferedImage}.
*
* @author nantuko
*/
public abstract class MageBufferedImageOp implements BufferedImageOp {
/**
* Creates compatible image for @param src image.
*/
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dest) {
if (dest == null) {
dest = src.getColorModel();
}
return new BufferedImage(dest, dest.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dest.isAlphaPremultiplied(), null);
}
public RenderingHints getRenderingHints() {
return null;
}
public Rectangle2D getBounds2D(BufferedImage src) {
return new Rectangle(0, 0, src.getWidth(), src.getHeight());
}
public Point2D getPoint2D(Point2D srcPt, Point2D destPt) {
if (destPt == null) {
destPt = new Point2D.Double();
}
destPt.setLocation(srcPt.getX(), srcPt.getY());
return destPt;
}
/**
* Gets ARGB pixels from image. Solves the performance
* issue of BufferedImage.getRGB method.
*/
public int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) {
return (int[]) image.getRaster().getDataElements(x, y, width, height, pixels);
}
return image.getRGB(x, y, width, height, pixels, 0, width);
}
/**
* Sets ARGB pixels in image. Solves the performance
* issue of BufferedImage.setRGB method.
*/
public void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) {
image.getRaster().setDataElements(x, y, width, height, pixels);
} else {
image.setRGB(x, y, width, height, pixels, 0, width);
}
}
}

View file

@ -1,18 +1,18 @@
package mage.interfaces;
import mage.MageException;
/**
* Light weight action interface.
* For executing actions without any context.
*
* @author ayratn, noxx
*/
public interface Action {
/**
* Executes action.
* @throws mage.MageException
*/
void execute() throws MageException;
}
package mage.interfaces;
import mage.MageException;
/**
* Light weight action interface.
* For executing actions without any context.
*
* @author ayratn, noxx
*/
public interface Action {
/**
* Executes action.
* @throws mage.MageException
*/
void execute() throws MageException;
}

View file

@ -1,22 +1,22 @@
package mage.interfaces;
import mage.MageException;
/**
* Exception thrown by plugin on errors.
*
* @author nantuko
*
*/
public class PluginException extends MageException {
private static final long serialVersionUID = 5528005696138392272L;
public PluginException(String message) {
super(message);
}
public PluginException(Throwable t) {
super(t);
}
}
package mage.interfaces;
import mage.MageException;
/**
* Exception thrown by plugin on errors.
*
* @author nantuko
*
*/
public class PluginException extends MageException {
private static final long serialVersionUID = 5528005696138392272L;
public PluginException(String message) {
super(message);
}
public PluginException(Throwable t) {
super(t);
}
}

View file

@ -1,49 +1,49 @@
package mage.interfaces.plugin;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import javax.swing.*;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
import mage.view.PermanentView;
import net.xeoh.plugins.base.Plugin;
/**
* Interface for card plugins
*
* @version 0.6 17.07.2011 added options to #sortPermanents
* @version 0.3 21.11.2010 #getMageCard
* @version 0.2 07.11.2010 #downloadImages
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
* @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);
/**
* Download various symbols (mana, tap, set).
*
* @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 onAddCard(MagePermanent card, int count);
void onRemoveCard(MagePermanent card, int count);
JComponent getCardInfoPane();
BufferedImage getOriginalImage(CardView card);
void changeGUISize();
}
package mage.interfaces.plugin;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import javax.swing.*;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
import mage.view.PermanentView;
import net.xeoh.plugins.base.Plugin;
/**
* Interface for card plugins
*
* @version 0.6 17.07.2011 added options to #sortPermanents
* @version 0.3 21.11.2010 #getMageCard
* @version 0.2 07.11.2010 #downloadImages
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
* @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);
/**
* Download various symbols (mana, tap, set).
*
* @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 onAddCard(MagePermanent card, int count);
void onRemoveCard(MagePermanent card, int count);
JComponent getCardInfoPane();
BufferedImage getOriginalImage(CardView card);
void changeGUISize();
}

View file

@ -1,15 +1,15 @@
package mage.interfaces.plugin;
import mage.interfaces.PluginException;
import net.xeoh.plugins.base.Plugin;
/**
* Interface for counter plugins
*
* @version 0.1 14.112010
* @author nantuko
*/
public interface CounterPlugin extends Plugin {
void addGamePlayed() throws PluginException;
int getGamePlayed() throws PluginException;
}
package mage.interfaces.plugin;
import mage.interfaces.PluginException;
import net.xeoh.plugins.base.Plugin;
/**
* Interface for counter plugins
*
* @version 0.1 14.112010
* @author nantuko
*/
public interface CounterPlugin extends Plugin {
void addGamePlayed() throws PluginException;
int getGamePlayed() throws PluginException;
}

View file

@ -1,18 +1,18 @@
package mage.interfaces.plugin;
import java.util.Map;
import javax.swing.JComponent;
import net.xeoh.plugins.base.Plugin;
/**
* Interface for theme plugins
*
* @version 0.1 31.10.2010
* @author nantuko
*/
public interface ThemePlugin extends Plugin {
void applyInGame(Map<String, JComponent> ui);
JComponent updateTable(Map<String, JComponent> ui);
}
package mage.interfaces.plugin;
import java.util.Map;
import javax.swing.JComponent;
import net.xeoh.plugins.base.Plugin;
/**
* Interface for theme plugins
*
* @version 0.1 31.10.2010
* @author nantuko
*/
public interface ThemePlugin extends Plugin {
void applyInGame(Map<String, JComponent> ui);
JComponent updateTable(Map<String, JComponent> ui);
}

View file

@ -1,16 +1,16 @@
package mage.interfaces.rate;
import java.util.List;
import mage.cards.Card;
import mage.constants.ColoredManaSymbol;
/**
* Interface for the class responsible for rating cards.
*
* @author nantuko
*/
public interface RateCallback {
int rateCard(Card card);
Card getBestBasicLand(ColoredManaSymbol color, List<String> setsToUse);
package mage.interfaces.rate;
import java.util.List;
import mage.cards.Card;
import mage.constants.ColoredManaSymbol;
/**
* Interface for the class responsible for rating cards.
*
* @author nantuko
*/
public interface RateCallback {
int rateCard(Card card);
Card getBestBasicLand(ColoredManaSymbol color, List<String> setsToUse);
}

View file

@ -1,15 +1,15 @@
package mage.remote.traffic;
/**
* Base interface for class wrapping non compressed objects.
* Provides methods for compressing that should be used before sending it over internet and decompressing to get actual
* data.
*
* @author ayrat
*/
public interface ZippedObject<T> {
void zip(T object);
T unzip();
}
package mage.remote.traffic;
/**
* Base interface for class wrapping non compressed objects.
* Provides methods for compressing that should be used before sending it over internet and decompressing to get actual
* data.
*
* @author ayrat
*/
public interface ZippedObject<T> {
void zip(T object);
T unzip();
}

View file

@ -1,54 +1,54 @@
package mage.remote.traffic;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
/**
* Implementation for compressing and decompressing objects using {@link GZIPInputStream} and {@link GZIPOutputStream}.
* Can be used to send any {@link Object} over internet to reduce traffic usage.
*
* @author ayrat
*/
public class ZippedObjectImpl<T> implements ZippedObject<T>, Serializable {
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;
}
package mage.remote.traffic;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
/**
* Implementation for compressing and decompressing objects using {@link GZIPInputStream} and {@link GZIPOutputStream}.
* Can be used to send any {@link Object} over internet to reduce traffic usage.
*
* @author ayrat
*/
public class ZippedObjectImpl<T> implements ZippedObject<T>, Serializable {
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;
}

View file

@ -1,89 +1,89 @@
package mage.utils;
import java.util.List;
import mage.ObjectColor;
import mage.cards.Card;
import mage.cards.MagePermanent;
import mage.constants.CardType;
import mage.view.CardView;
/**
* Utility class for {@link CardView}
*
* @version 0.1 02.11.2010
* @author nantuko
*/
public class CardUtil {
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";
private static final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*";
private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*";
public static boolean isCreature(CardView card) {
return is(card, CardType.CREATURE);
}
public static boolean isPlaneswalker(CardView card) {
return is(card, CardType.PLANESWALKER);
}
public static boolean isLand(CardView card) {
return is(card, CardType.LAND);
}
public static boolean isCreature(MagePermanent card) {
return is(card.getOriginal(), CardType.CREATURE);
}
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 int getColorIdentitySortValue(List<String> manaCost, ObjectColor originalColor, List<String> rules) {
ObjectColor color = new ObjectColor(originalColor);
for (String rule : rules) {
rule = rule.replaceAll("(?i)<i.*?</i>", ""); // Ignoring reminder text in italic
if (rule.matches(regexBlack)) {
color.setBlack(true);
}
if (rule.matches(regexBlue)) {
color.setBlue(true);
}
if (rule.matches(regexGreen)) {
color.setGreen(true);
}
if (rule.matches(regexRed)) {
color.setRed(true);
}
if (rule.matches(regexWhite)) {
color.setWhite(true);
}
}
int hash = 3;
hash = 23 * hash + (color.isWhite() || manaCost.contains("{W}") ? 1 : 0);
hash = 23 * hash + (color.isBlue() || manaCost.contains("{U}") ? 1 : 0);
hash = 23 * hash + (color.isBlack() || manaCost.contains("{B}") ? 1 : 0);
hash = 23 * hash + (color.isRed() || manaCost.contains("{R}") ? 1 : 0);
hash = 23 * hash + (color.isGreen() || manaCost.contains("{G}") ? 1 : 0);
return hash;
}
}
package mage.utils;
import java.util.List;
import mage.ObjectColor;
import mage.cards.Card;
import mage.cards.MagePermanent;
import mage.constants.CardType;
import mage.view.CardView;
/**
* Utility class for {@link CardView}
*
* @version 0.1 02.11.2010
* @author nantuko
*/
public class CardUtil {
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";
private static final String regexRed = ".*\\x7b.{0,2}R.{0,2}\\x7d.*";
private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*";
public static boolean isCreature(CardView card) {
return is(card, CardType.CREATURE);
}
public static boolean isPlaneswalker(CardView card) {
return is(card, CardType.PLANESWALKER);
}
public static boolean isLand(CardView card) {
return is(card, CardType.LAND);
}
public static boolean isCreature(MagePermanent card) {
return is(card.getOriginal(), CardType.CREATURE);
}
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 int getColorIdentitySortValue(List<String> manaCost, ObjectColor originalColor, List<String> rules) {
ObjectColor color = new ObjectColor(originalColor);
for (String rule : rules) {
rule = rule.replaceAll("(?i)<i.*?</i>", ""); // Ignoring reminder text in italic
if (rule.matches(regexBlack)) {
color.setBlack(true);
}
if (rule.matches(regexBlue)) {
color.setBlue(true);
}
if (rule.matches(regexGreen)) {
color.setGreen(true);
}
if (rule.matches(regexRed)) {
color.setRed(true);
}
if (rule.matches(regexWhite)) {
color.setWhite(true);
}
}
int hash = 3;
hash = 23 * hash + (color.isWhite() || manaCost.contains("{W}") ? 1 : 0);
hash = 23 * hash + (color.isBlue() || manaCost.contains("{U}") ? 1 : 0);
hash = 23 * hash + (color.isBlack() || manaCost.contains("{B}") ? 1 : 0);
hash = 23 * hash + (color.isRed() || manaCost.contains("{R}") ? 1 : 0);
hash = 23 * hash + (color.isGreen() || manaCost.contains("{G}") ? 1 : 0);
return hash;
}
}

View file

@ -1,58 +1,58 @@
package mage.utils;
import mage.remote.traffic.ZippedObject;
import mage.remote.traffic.ZippedObjectImpl;
/**
* Helps to compress and decompress data if needed.
*
* @author ayrat
*/
public class CompressUtil {
/**
* Defines should data be compressed or not. True by default.
* Read from system property:
*/
private static boolean compressData = true;
/**
* Defines the system property name to disable any compressing.
*/
private static final String NO_COMPRESS_DATA_PROPERTY = "nocompress";
static {
compressData = System.getProperty(NO_COMPRESS_DATA_PROPERTY) == null;
}
/**
* Hidden constructor
*/
private CompressUtil() {}
/**
* Decompress data, but only if it was compressed previously return original object otherwise.
*
* @param data Data to decompress
* @return Decompressed object
*/
public static Object decompress(Object data) {
if (data == null || !(data instanceof ZippedObject)) {
return data;
}
return ((ZippedObject)data).unzip();
}
/**
* Compress data.
*
* @param data Data to compress
* @return Compressed object
*/
public static Object compress(Object data) {
if (data != null && compressData) {
return new ZippedObjectImpl<Object>(data);
}
return null;
}
}
package mage.utils;
import mage.remote.traffic.ZippedObject;
import mage.remote.traffic.ZippedObjectImpl;
/**
* Helps to compress and decompress data if needed.
*
* @author ayrat
*/
public class CompressUtil {
/**
* Defines should data be compressed or not. True by default.
* Read from system property:
*/
private static boolean compressData = true;
/**
* Defines the system property name to disable any compressing.
*/
private static final String NO_COMPRESS_DATA_PROPERTY = "nocompress";
static {
compressData = System.getProperty(NO_COMPRESS_DATA_PROPERTY) == null;
}
/**
* Hidden constructor
*/
private CompressUtil() {}
/**
* Decompress data, but only if it was compressed previously return original object otherwise.
*
* @param data Data to decompress
* @return Decompressed object
*/
public static Object decompress(Object data) {
if (data == null || !(data instanceof ZippedObject)) {
return data;
}
return ((ZippedObject)data).unzip();
}
/**
* Compress data.
*
* @param data Data to compress
* @return Compressed object
*/
public static Object compress(Object data) {
if (data != null && compressData) {
return new ZippedObjectImpl<Object>(data);
}
return null;
}
}

View file

@ -1,321 +1,321 @@
package mage.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Random;
import mage.Mana;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.interfaces.rate.RateCallback;
/**
* Builds deck from provided card pool.
*
* @author nantuko
*/
public class DeckBuilder {
private static final int DECK_COUNT40[] = {3, 6, 6, 4, 3, 2};
private static final int DECK_COUNT60[] = {4, 9, 9, 5, 5, 3};
private static final int DECK_COST[] = {1, 2, 3, 4, 6, 10};
private static final int MIN_CARD_SCORE = 25;
private static final int MIN_SOURCE = 3; // minmal number of sources for a mana color, will be taken also if ratio would give a lower number
private static Deck deck;
private static int deckCount[];
private static int deckSize;
private static int deckSpells;
private static int deckLands;
/**
* Hide constructor.
*/
private DeckBuilder() {
}
public synchronized static Deck buildDeck(List<Card> spellCardPool, List<ColoredManaSymbol> allowedColors, List<String> setsToUse, List<Card> landCardPool, int deckCardSize, RateCallback callback) {
deckSize = deckCardSize;
deck = new Deck();
final Collection<MageScoredCard> remainingCards = new ArrayList<>();
Set<String> names = new HashSet<>();
for (final Card card : spellCardPool) {
if (names.contains(card.getName())) {
continue;
}
remainingCards.add(new MageScoredCard(card, allowedColors, callback));
names.add(card.getName());
}
// prints score and manaScore to log
// for(MageScoredCard scoreCard :remainingCards) {
// Logger.getLogger(DeckBuilder.class).info(
// new StringBuilder("Score: ")
// .append(scoreCard.getScore())
// .append(" ManaScore: ")
// .append(scoreCard.getManaCostScore(scoreCard.getCard(), allowedColors))
// .append(" ")
// .append(scoreCard.getCard().getName())
// .append(" ")
// .append(scoreCard.getCard().getManaCost().getText()).toString()
// );
// }
int min = 0;
if (deckSize == 40) {
deckCount = DECK_COUNT40;
deckSpells = 23;
deckLands = 17;
} else {
deckCount = DECK_COUNT60;
deckSpells = 35;
deckLands = 25;
}
for (int index = 0; index < deckCount.length; index++) {
final int max = DECK_COST[index];
addCardsToDeck(remainingCards, min, max, deckCount[index]);
min = max + 1;
}
addCardsToDeck(remainingCards, 0, 4, deckSpells - deck.getCards().size());
addCardsToDeck(remainingCards, 5, 10, deckSpells - deck.getCards().size());
addLandsToDeck(allowedColors, setsToUse, landCardPool, callback);
Deck returnedDeck = deck;
deck = null;
return returnedDeck;
}
/**
* 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) {
for (int c = count; c > 0; c--) {
MageScoredCard bestCard = null;
int bestScore = -1;
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;
}
}
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<String> setsToUse, List<Card> landCardPool, RateCallback callback) {
// Calculate statistics per color.
final Map<String, Integer> colorCount = new HashMap<>();
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 (symbol.contains(allowed.toString())) {
count++;
}
}
if (count > 0) {
Integer typeCount = colorCount.get(symbol);
if (typeCount == null) {
typeCount = 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<>();
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() < deckSize) {
ColoredManaSymbol bestColor = null;
//Default to a color in the allowed colors
if (allowedColors != null && !allowedColors.isEmpty()) {
bestColor = allowedColors.get(new Random().nextInt(allowedColors.size()));
}
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, setsToUse);
Integer count = colorSource.get(bestColor.toString());
count++;
colorSource.put(bestColor.toString(), count);
deck.getCards().add(landCard);
}
}
private static class MageScoredCard {
private Card card;
private final 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 };
public MageScoredCard(Card card, List<ColoredManaSymbol> allowedColors, RateCallback cardRater) {
this.card = card;
int type;
if (card.getCardType().contains(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(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);
}
private int getManaCostScore(Card card, List<ColoredManaSymbol> allowedColors) {
int converted = card.getManaCost().convertedManaCost();
final Map<String, Integer> singleCount = new HashMap<>();
int maxSingleCount = 0;
int multicolor = 0;
Set<String> colors = new HashSet<>();
for (String symbol : card.getManaCost().getSymbols()) {
int count = 0;
symbol = symbol.replace("{", "").replace("}", "");
if (isColoredMana(symbol)) {
for (ColoredManaSymbol allowed : allowedColors) {
if (symbol.contains(allowed.toString())) {
count++;
}
}
// colored but no selected colors, go back with negative value
if (count == 0) {
return -30;
}
if (!colors.contains(symbol)) {
multicolor += 1;
colors.add(symbol);
}
Integer typeCount = singleCount.get(symbol);
if (typeCount == null) {
typeCount = 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 getConvertedCost() {
return this.card.getManaCost().convertedManaCost();
}
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") || symbol.contains("/");
}
}
package mage.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Random;
import mage.Mana;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.interfaces.rate.RateCallback;
/**
* Builds deck from provided card pool.
*
* @author nantuko
*/
public class DeckBuilder {
private static final int DECK_COUNT40[] = {3, 6, 6, 4, 3, 2};
private static final int DECK_COUNT60[] = {4, 9, 9, 5, 5, 3};
private static final int DECK_COST[] = {1, 2, 3, 4, 6, 10};
private static final int MIN_CARD_SCORE = 25;
private static final int MIN_SOURCE = 3; // minmal number of sources for a mana color, will be taken also if ratio would give a lower number
private static Deck deck;
private static int deckCount[];
private static int deckSize;
private static int deckSpells;
private static int deckLands;
/**
* Hide constructor.
*/
private DeckBuilder() {
}
public synchronized static Deck buildDeck(List<Card> spellCardPool, List<ColoredManaSymbol> allowedColors, List<String> setsToUse, List<Card> landCardPool, int deckCardSize, RateCallback callback) {
deckSize = deckCardSize;
deck = new Deck();
final Collection<MageScoredCard> remainingCards = new ArrayList<>();
Set<String> names = new HashSet<>();
for (final Card card : spellCardPool) {
if (names.contains(card.getName())) {
continue;
}
remainingCards.add(new MageScoredCard(card, allowedColors, callback));
names.add(card.getName());
}
// prints score and manaScore to log
// for(MageScoredCard scoreCard :remainingCards) {
// Logger.getLogger(DeckBuilder.class).info(
// new StringBuilder("Score: ")
// .append(scoreCard.getScore())
// .append(" ManaScore: ")
// .append(scoreCard.getManaCostScore(scoreCard.getCard(), allowedColors))
// .append(" ")
// .append(scoreCard.getCard().getName())
// .append(" ")
// .append(scoreCard.getCard().getManaCost().getText()).toString()
// );
// }
int min = 0;
if (deckSize == 40) {
deckCount = DECK_COUNT40;
deckSpells = 23;
deckLands = 17;
} else {
deckCount = DECK_COUNT60;
deckSpells = 35;
deckLands = 25;
}
for (int index = 0; index < deckCount.length; index++) {
final int max = DECK_COST[index];
addCardsToDeck(remainingCards, min, max, deckCount[index]);
min = max + 1;
}
addCardsToDeck(remainingCards, 0, 4, deckSpells - deck.getCards().size());
addCardsToDeck(remainingCards, 5, 10, deckSpells - deck.getCards().size());
addLandsToDeck(allowedColors, setsToUse, landCardPool, callback);
Deck returnedDeck = deck;
deck = null;
return returnedDeck;
}
/**
* 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) {
for (int c = count; c > 0; c--) {
MageScoredCard bestCard = null;
int bestScore = -1;
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;
}
}
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<String> setsToUse, List<Card> landCardPool, RateCallback callback) {
// Calculate statistics per color.
final Map<String, Integer> colorCount = new HashMap<>();
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 (symbol.contains(allowed.toString())) {
count++;
}
}
if (count > 0) {
Integer typeCount = colorCount.get(symbol);
if (typeCount == null) {
typeCount = 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<>();
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() < deckSize) {
ColoredManaSymbol bestColor = null;
//Default to a color in the allowed colors
if (allowedColors != null && !allowedColors.isEmpty()) {
bestColor = allowedColors.get(new Random().nextInt(allowedColors.size()));
}
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, setsToUse);
Integer count = colorSource.get(bestColor.toString());
count++;
colorSource.put(bestColor.toString(), count);
deck.getCards().add(landCard);
}
}
private static class MageScoredCard {
private Card card;
private final 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 };
public MageScoredCard(Card card, List<ColoredManaSymbol> allowedColors, RateCallback cardRater) {
this.card = card;
int type;
if (card.getCardType().contains(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(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);
}
private int getManaCostScore(Card card, List<ColoredManaSymbol> allowedColors) {
int converted = card.getManaCost().convertedManaCost();
final Map<String, Integer> singleCount = new HashMap<>();
int maxSingleCount = 0;
int multicolor = 0;
Set<String> colors = new HashSet<>();
for (String symbol : card.getManaCost().getSymbols()) {
int count = 0;
symbol = symbol.replace("{", "").replace("}", "");
if (isColoredMana(symbol)) {
for (ColoredManaSymbol allowed : allowedColors) {
if (symbol.contains(allowed.toString())) {
count++;
}
}
// colored but no selected colors, go back with negative value
if (count == 0) {
return -30;
}
if (!colors.contains(symbol)) {
multicolor += 1;
colors.add(symbol);
}
Integer typeCount = singleCount.get(symbol);
if (typeCount == null) {
typeCount = 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 getConvertedCost() {
return this.card.getManaCost().convertedManaCost();
}
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") || symbol.contains("/");
}
}

View file

@ -1,97 +1,97 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.utils;
import java.io.Serializable;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class MageVersion implements Serializable, Comparable<MageVersion> {
/**
*
*/
public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 10;
public final static String MAGE_VERSION_MINOR_PATCH = "v1";
public final static String MAGE_VERSION_INFO = "";
private final int major;
private final int minor;
private final int patch;
private final String minorPatch; // doesn't matter for compatibility
private String info = "";
public MageVersion(int major, int minor, int patch, String minorPatch, String info) {
this.major = major;
this.minor = minor;
this.patch = patch;
this.minorPatch = minorPatch;
this.info = info;
}
public int getMajor() {
return major;
}
public int getMinor() {
return minor;
}
public int getPatch() {
return patch;
}
public String getMinorPatch() {
return minorPatch;
}
@Override
public String toString() {
return major + "." + minor + "." + patch + info + minorPatch;
}
@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);
}
}
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.utils;
import java.io.Serializable;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class MageVersion implements Serializable, Comparable<MageVersion> {
/**
*
*/
public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 10;
public final static String MAGE_VERSION_MINOR_PATCH = "v1";
public final static String MAGE_VERSION_INFO = "";
private final int major;
private final int minor;
private final int patch;
private final String minorPatch; // doesn't matter for compatibility
private String info = "";
public MageVersion(int major, int minor, int patch, String minorPatch, String info) {
this.major = major;
this.minor = minor;
this.patch = patch;
this.minorPatch = minorPatch;
this.info = info;
}
public int getMajor() {
return major;
}
public int getMinor() {
return minor;
}
public int getPatch() {
return patch;
}
public String getMinorPatch() {
return minorPatch;
}
@Override
public String toString() {
return major + "." + minor + "." + patch + info + minorPatch;
}
@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);
}
}

View file

@ -1,64 +1,64 @@
package mage.utils;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Util method to work with threads.
*
* @author ayrat
*/
@SuppressWarnings("unchecked")
public class ThreadUtils {
public static final ThreadPoolExecutor threadPool;
public static final ThreadPoolExecutor threadPool2;
private static int threadCount;
static {
/** used in CardInfoPaneImpl
*
*/
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "Util" + threadCount);
thread.setDaemon(true);
return thread;
}
});
threadPool.prestartAllCoreThreads();
/**
* Used for MageActionCallback
*/
threadPool2 = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "TP2" + threadCount);
thread.setDaemon(true);
return thread;
}
});
threadPool2.prestartAllCoreThreads();
}
public static void sleep (int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException ignored) {
}
}
public static void wait (Object lock) {
synchronized (lock) {
try {
lock.wait();
} catch (InterruptedException ex) {
}
}
}
}
package mage.utils;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Util method to work with threads.
*
* @author ayrat
*/
@SuppressWarnings("unchecked")
public class ThreadUtils {
public static final ThreadPoolExecutor threadPool;
public static final ThreadPoolExecutor threadPool2;
private static int threadCount;
static {
/** used in CardInfoPaneImpl
*
*/
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "Util" + threadCount);
thread.setDaemon(true);
return thread;
}
});
threadPool.prestartAllCoreThreads();
/**
* Used for MageActionCallback
*/
threadPool2 = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "TP2" + threadCount);
thread.setDaemon(true);
return thread;
}
});
threadPool2.prestartAllCoreThreads();
}
public static void sleep (int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException ignored) {
}
}
public static void wait (Object lock) {
synchronized (lock) {
try {
lock.wait();
} catch (InterruptedException ex) {
}
}
}
}

View file

@ -1,47 +1,47 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
/**
*
* @author Plopman
*/
public interface CommandObjectView extends Serializable {
public String getExpansionSetCode();
public String getName();
public UUID getId();
public List<String> getRules();
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
/**
*
* @author Plopman
*/
public interface CommandObjectView extends Serializable {
public String getExpansionSetCode();
public String getName();
public UUID getId();
public List<String> getRules();
}

View file

@ -1,46 +1,46 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import mage.cards.Card;
import mage.constants.MageObjectType;
import mage.game.Game;
import mage.game.command.Commander;
/**
*
* @author Plopman
*/
public class CommanderView extends CardView implements CommandObjectView, Serializable{
public CommanderView(Commander commander, Card sourceCard, Game game) {
super(sourceCard, game, false);
this.mageObjectType = MageObjectType.COMMANDER;
}
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import mage.cards.Card;
import mage.constants.MageObjectType;
import mage.game.Game;
import mage.game.command.Commander;
/**
*
* @author Plopman
*/
public class CommanderView extends CardView implements CommandObjectView, Serializable{
public CommanderView(Commander commander, Card sourceCard, Game game) {
super(sourceCard, game, false);
this.mageObjectType = MageObjectType.COMMANDER;
}
}

View file

@ -1,59 +1,59 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import mage.cards.decks.Deck;
/**
* @author nantuko
*/
public class DeckView implements Serializable {
private final String name;
private final SimpleCardsView cards;
private final SimpleCardsView sideboard;
public DeckView(Deck deck) {
name = deck.getName();
cards = new SimpleCardsView(deck.getCards(), false);
sideboard = new SimpleCardsView(deck.getSideboard(), false);
}
public String getName() {
return name;
}
public SimpleCardsView getCards() {
return cards;
}
public SimpleCardsView getSideboard() {
return sideboard;
}
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import mage.cards.decks.Deck;
/**
* @author nantuko
*/
public class DeckView implements Serializable {
private final String name;
private final SimpleCardsView cards;
private final SimpleCardsView sideboard;
public DeckView(Deck deck) {
name = deck.getName();
cards = new SimpleCardsView(deck.getCards(), false);
sideboard = new SimpleCardsView(deck.getSideboard(), false);
}
public String getName() {
return name;
}
public SimpleCardsView getCards() {
return cards;
}
public SimpleCardsView getSideboard() {
return sideboard;
}
}

View file

@ -1,184 +1,184 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import mage.game.Game;
import mage.game.GameState;
import mage.game.Table;
import mage.game.match.Match;
import mage.game.match.MatchPlayer;
import mage.players.Player;
/**
* @author LevelX2
*/
public class GameEndView implements Serializable {
private PlayerView clientPlayer = null;
private final List<PlayerView> players = new ArrayList<>();
private final Date startTime;
private final Date endTime;
private String gameInfo;
private final String matchInfo;
private final String additionalInfo;
private boolean won;
private final MatchView matchView;
private int wins;
private int loses;
private final int winsNeeded;
public GameEndView(GameState state, Game game, UUID playerId, Table table) {
startTime = game.getStartTime();
endTime = game.getEndTime();
// set result message
int winner = 0;
Player you = null;
for (Player player: state.getPlayers().values()) {
PlayerView playerView = new PlayerView(player, state, game, playerId, null);
if (playerView.getPlayerId().equals(playerId)) {
clientPlayer = playerView;
you = player;
won = you.hasWon(); // needed to control image
}
players.add(playerView);
if (player.hasWon()) {
winner++;
}
}
if (you != null) {
if (you.hasWon()) {
gameInfo = new StringBuilder("You won the game on turn ").append(game.getTurnNum()).append(".").toString();
} else if (winner > 0) {
gameInfo = new StringBuilder("You lost the game on turn ").append(game.getTurnNum()).append(".").toString();
} else {
gameInfo = new StringBuilder("Game is a draw on Turn ").append(game.getTurnNum()).append(".").toString();
}
}
matchView = new MatchView(table);
Match match = table.getMatch();
MatchPlayer matchWinner = null;
winsNeeded = match.getOptions().getWinsNeeded();
StringBuilder additonalText = new StringBuilder();
for (MatchPlayer matchPlayer: match.getPlayers()) {
if (matchPlayer.getPlayer().equals(you)) {
wins = matchPlayer.getWins();
}
if (matchPlayer.isMatchWinner()) {
matchWinner = matchPlayer;
}
if (matchPlayer.getPlayer().hasTimerTimeout()) {
if (matchPlayer.getPlayer().equals(you)) {
additonalText.append("You run out of time. ");
} else {
additonalText.append(matchPlayer.getName()).append(" runs out of time. ");
}
} else if (matchPlayer.getPlayer().hasIdleTimeout()) {
if (matchPlayer.getPlayer().equals(you)) {
additonalText.append("You lost the match for being idle. ");
} else {
additonalText.append(matchPlayer.getName()).append(" lost for being idle. ");
}
} else if (matchPlayer.hasQuit()) {
if (matchPlayer.getPlayer().equals(you)) {
additonalText.append("You have quit the match. ");
} else {
additonalText.append(matchPlayer.getName()).append(" has quit the match. ");
}
}
}
if (matchWinner != null) {
if (matchWinner.getPlayer().equals(you)) {
matchInfo = "You won the match!";
} else {
matchInfo = new StringBuilder(matchWinner.getName()).append(" won the match!").toString();
}
} else {
matchInfo = new StringBuilder("You need ").append(winsNeeded - wins == 1 ? "one more win ":winsNeeded - wins + " more wins ").append("to win the match.").toString();
}
additionalInfo = additonalText.toString();
}
public Date getStartTime() {
return startTime;
}
public Date getEndTime() {
return endTime;
}
public List<PlayerView> getPlayers() {
return players;
}
public String getGameInfo() {
return gameInfo;
}
public String getMatchInfo() {
return matchInfo;
}
public String getAdditionalInfo() {
return additionalInfo;
}
public boolean hasWon() {
return won;
}
public MatchView getMatchView() {
return matchView;
}
public int getWins() {
return wins;
}
public int getLoses() {
return loses;
}
public int getWinsNeeded() {
return winsNeeded;
}
public PlayerView getClientPlayer() {
return clientPlayer;
}
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import mage.game.Game;
import mage.game.GameState;
import mage.game.Table;
import mage.game.match.Match;
import mage.game.match.MatchPlayer;
import mage.players.Player;
/**
* @author LevelX2
*/
public class GameEndView implements Serializable {
private PlayerView clientPlayer = null;
private final List<PlayerView> players = new ArrayList<>();
private final Date startTime;
private final Date endTime;
private String gameInfo;
private final String matchInfo;
private final String additionalInfo;
private boolean won;
private final MatchView matchView;
private int wins;
private int loses;
private final int winsNeeded;
public GameEndView(GameState state, Game game, UUID playerId, Table table) {
startTime = game.getStartTime();
endTime = game.getEndTime();
// set result message
int winner = 0;
Player you = null;
for (Player player: state.getPlayers().values()) {
PlayerView playerView = new PlayerView(player, state, game, playerId, null);
if (playerView.getPlayerId().equals(playerId)) {
clientPlayer = playerView;
you = player;
won = you.hasWon(); // needed to control image
}
players.add(playerView);
if (player.hasWon()) {
winner++;
}
}
if (you != null) {
if (you.hasWon()) {
gameInfo = new StringBuilder("You won the game on turn ").append(game.getTurnNum()).append(".").toString();
} else if (winner > 0) {
gameInfo = new StringBuilder("You lost the game on turn ").append(game.getTurnNum()).append(".").toString();
} else {
gameInfo = new StringBuilder("Game is a draw on Turn ").append(game.getTurnNum()).append(".").toString();
}
}
matchView = new MatchView(table);
Match match = table.getMatch();
MatchPlayer matchWinner = null;
winsNeeded = match.getOptions().getWinsNeeded();
StringBuilder additonalText = new StringBuilder();
for (MatchPlayer matchPlayer: match.getPlayers()) {
if (matchPlayer.getPlayer().equals(you)) {
wins = matchPlayer.getWins();
}
if (matchPlayer.isMatchWinner()) {
matchWinner = matchPlayer;
}
if (matchPlayer.getPlayer().hasTimerTimeout()) {
if (matchPlayer.getPlayer().equals(you)) {
additonalText.append("You run out of time. ");
} else {
additonalText.append(matchPlayer.getName()).append(" runs out of time. ");
}
} else if (matchPlayer.getPlayer().hasIdleTimeout()) {
if (matchPlayer.getPlayer().equals(you)) {
additonalText.append("You lost the match for being idle. ");
} else {
additonalText.append(matchPlayer.getName()).append(" lost for being idle. ");
}
} else if (matchPlayer.hasQuit()) {
if (matchPlayer.getPlayer().equals(you)) {
additonalText.append("You have quit the match. ");
} else {
additonalText.append(matchPlayer.getName()).append(" has quit the match. ");
}
}
}
if (matchWinner != null) {
if (matchWinner.getPlayer().equals(you)) {
matchInfo = "You won the match!";
} else {
matchInfo = new StringBuilder(matchWinner.getName()).append(" won the match!").toString();
}
} else {
matchInfo = new StringBuilder("You need ").append(winsNeeded - wins == 1 ? "one more win ":winsNeeded - wins + " more wins ").append("to win the match.").toString();
}
additionalInfo = additonalText.toString();
}
public Date getStartTime() {
return startTime;
}
public Date getEndTime() {
return endTime;
}
public List<PlayerView> getPlayers() {
return players;
}
public String getGameInfo() {
return gameInfo;
}
public String getMatchInfo() {
return matchInfo;
}
public String getAdditionalInfo() {
return additionalInfo;
}
public boolean hasWon() {
return won;
}
public MatchView getMatchView() {
return matchView;
}
public int getWins() {
return wins;
}
public int getLoses() {
return loses;
}
public int getWinsNeeded() {
return winsNeeded;
}
public PlayerView getClientPlayer() {
return clientPlayer;
}
}

View file

@ -1,72 +1,72 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.List;
/**
*
* @author LevelX2
*/
public class RoomUsersView implements Serializable {
private static final long serialVersionUID = 1L;
private final int numberActiveGames;
private final int numberGameThreads;
private final int numberMaxGames;
private final List<UsersView> usersView;
public RoomUsersView(List<UsersView> usersView, int numberActiveGames, int numberGameThreads, int numberMaxGames) {
this.numberActiveGames = numberActiveGames;
this.numberGameThreads = numberGameThreads;
this.numberMaxGames = numberMaxGames;
this.usersView = usersView;
}
public int getNumberActiveGames() {
return numberActiveGames;
}
public int getNumberGameThreads() {
return numberGameThreads;
}
public int getNumberMaxGames() {
return numberMaxGames;
}
public List<UsersView> getUsersView() {
return usersView;
}
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.List;
/**
*
* @author LevelX2
*/
public class RoomUsersView implements Serializable {
private static final long serialVersionUID = 1L;
private final int numberActiveGames;
private final int numberGameThreads;
private final int numberMaxGames;
private final List<UsersView> usersView;
public RoomUsersView(List<UsersView> usersView, int numberActiveGames, int numberGameThreads, int numberMaxGames) {
this.numberActiveGames = numberActiveGames;
this.numberGameThreads = numberGameThreads;
this.numberMaxGames = numberMaxGames;
this.usersView = usersView;
}
public int getNumberActiveGames() {
return numberActiveGames;
}
public int getNumberGameThreads() {
return numberGameThreads;
}
public int getNumberMaxGames() {
return numberMaxGames;
}
public List<UsersView> getUsersView() {
return usersView;
}
}

View file

@ -1,82 +1,82 @@
package mage.view;
import java.io.Serializable;
import mage.players.net.UserData;
import mage.players.net.UserSkipPrioritySteps;
/**
* Transfer object for {@link mage.players.net.UserData}
*
* @author ayrat
*/
public class UserDataView implements Serializable {
protected int avatarId;
protected int userGroup;
protected boolean showAbilityPickerForced;
protected boolean allowRequestShowHandCards;
protected boolean confirmEmptyManaPool;
protected UserSkipPrioritySteps userSkipPrioritySteps;
String flagName;
protected boolean askMoveToGraveOrder;
static UserData getDefaultUserData() {
return UserData.getDefaultUserDataView();
}
public static UserDataView getDefaultUserDataView() {
return new UserDataView(getDefaultUserData());
}
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps, String flagName, boolean askMoveToGraveOrder) {
this.avatarId = avatarId;
this.showAbilityPickerForced = showAbilityPickerForced;
this.allowRequestShowHandCards = allowRequestShowHandCards;
this.userSkipPrioritySteps = userSkipPrioritySteps;
this.confirmEmptyManaPool = confirmEmptyManaPool;
this.flagName = flagName;
this.askMoveToGraveOrder = askMoveToGraveOrder;
}
public UserDataView(UserData userData) {
this.avatarId = userData.getAvatarId();
this.userGroup = userData.getGroupId();
this.allowRequestShowHandCards = userData.isAllowRequestShowHandCards();
this.showAbilityPickerForced = userData.isShowAbilityPickerForced();
this.userSkipPrioritySteps = userData.getUserSkipPrioritySteps();
this.confirmEmptyManaPool = userData.confirmEmptyManaPool();
this.flagName = userData.getFlagName();
this.askMoveToGraveOrder = userData.askMoveToGraveOrder();
}
public int getAvatarId() {
return avatarId;
}
public boolean isShowAbilityPickerForced() {
return showAbilityPickerForced;
}
public boolean allowRequestShowHandCards() {
return allowRequestShowHandCards;
}
public UserSkipPrioritySteps getUserSkipPrioritySteps() {
return userSkipPrioritySteps;
}
public boolean confirmEmptyManaPool() {
return confirmEmptyManaPool;
}
public String getFlagName() {
return flagName;
}
public boolean askMoveToGraveOrder() {
return askMoveToGraveOrder;
}
}
package mage.view;
import java.io.Serializable;
import mage.players.net.UserData;
import mage.players.net.UserSkipPrioritySteps;
/**
* Transfer object for {@link mage.players.net.UserData}
*
* @author ayrat
*/
public class UserDataView implements Serializable {
protected int avatarId;
protected int userGroup;
protected boolean showAbilityPickerForced;
protected boolean allowRequestShowHandCards;
protected boolean confirmEmptyManaPool;
protected UserSkipPrioritySteps userSkipPrioritySteps;
String flagName;
protected boolean askMoveToGraveOrder;
static UserData getDefaultUserData() {
return UserData.getDefaultUserDataView();
}
public static UserDataView getDefaultUserDataView() {
return new UserDataView(getDefaultUserData());
}
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps, String flagName, boolean askMoveToGraveOrder) {
this.avatarId = avatarId;
this.showAbilityPickerForced = showAbilityPickerForced;
this.allowRequestShowHandCards = allowRequestShowHandCards;
this.userSkipPrioritySteps = userSkipPrioritySteps;
this.confirmEmptyManaPool = confirmEmptyManaPool;
this.flagName = flagName;
this.askMoveToGraveOrder = askMoveToGraveOrder;
}
public UserDataView(UserData userData) {
this.avatarId = userData.getAvatarId();
this.userGroup = userData.getGroupId();
this.allowRequestShowHandCards = userData.isAllowRequestShowHandCards();
this.showAbilityPickerForced = userData.isShowAbilityPickerForced();
this.userSkipPrioritySteps = userData.getUserSkipPrioritySteps();
this.confirmEmptyManaPool = userData.confirmEmptyManaPool();
this.flagName = userData.getFlagName();
this.askMoveToGraveOrder = userData.askMoveToGraveOrder();
}
public int getAvatarId() {
return avatarId;
}
public boolean isShowAbilityPickerForced() {
return showAbilityPickerForced;
}
public boolean allowRequestShowHandCards() {
return allowRequestShowHandCards;
}
public UserSkipPrioritySteps getUserSkipPrioritySteps() {
return userSkipPrioritySteps;
}
public boolean confirmEmptyManaPool() {
return confirmEmptyManaPool;
}
public String getFlagName() {
return flagName;
}
public boolean askMoveToGraveOrder() {
return askMoveToGraveOrder;
}
}

View file

@ -1,173 +1,173 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.UUID;
import mage.constants.PlayerAction;
/**
*
* @author LevelX2
*/
public class UserRequestMessage implements Serializable {
private static final long serialVersionUID = 1L;
private final String titel;
private final String message;
private UUID relatedUserId;
private String relatedUserName;
private UUID matchId;
private UUID tournamentId;
private UUID gameId;
private UUID roomId;
private UUID tableId;
private String button1Text;
private PlayerAction button1Action;
private String button2Text;
private PlayerAction button2Action;
private String button3Text;
private PlayerAction button3Action;
public UserRequestMessage(String titel, String message) {
this.titel = titel;
this.message = message;
this.button1Action = null;
this.button2Action = null;
this.button3Action = null;
}
public void setMatchId(UUID matchId) {
this.matchId = matchId;
}
public void setGameId(UUID gameId) {
this.gameId = gameId;
}
public void setRelatedUser(UUID userId, String name) {
this.relatedUserId = userId;
this.relatedUserName = name;
}
public void setButton1(String text, PlayerAction buttonAction) {
this.button1Text = text;
this.button1Action = buttonAction;
}
public void setButton2(String text, PlayerAction buttonAction) {
this.button2Text = text;
this.button2Action = buttonAction;
}
public void setButton3(String text, PlayerAction buttonAction) {
this.button3Text = text;
this.button3Action = buttonAction;
}
public String getTitel() {
return titel;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getMessage() {
return message;
}
public UUID getRelatedUserId() {
return relatedUserId;
}
public String getRelatedUserName() {
return relatedUserName;
}
public UUID getMatchId() {
return matchId;
}
public UUID getGameId() {
return gameId;
}
public UUID getTournamentId() {
return tournamentId;
}
public void setTournamentId(UUID tournamentId) {
this.tournamentId = tournamentId;
}
public UUID getRoomId() {
return roomId;
}
public void setRoomId(UUID roomId) {
this.roomId = roomId;
}
public UUID getTableId() {
return tableId;
}
public void setTableId(UUID tableId) {
this.tableId = tableId;
}
public String getButton1Text() {
return button1Text;
}
public PlayerAction getButton1Action() {
return button1Action;
}
public String getButton2Text() {
return button2Text;
}
public PlayerAction getButton2Action() {
return button2Action;
}
public String getButton3Text() {
return button3Text;
}
public PlayerAction getButton3Action() {
return button3Action;
}
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import java.util.UUID;
import mage.constants.PlayerAction;
/**
*
* @author LevelX2
*/
public class UserRequestMessage implements Serializable {
private static final long serialVersionUID = 1L;
private final String titel;
private final String message;
private UUID relatedUserId;
private String relatedUserName;
private UUID matchId;
private UUID tournamentId;
private UUID gameId;
private UUID roomId;
private UUID tableId;
private String button1Text;
private PlayerAction button1Action;
private String button2Text;
private PlayerAction button2Action;
private String button3Text;
private PlayerAction button3Action;
public UserRequestMessage(String titel, String message) {
this.titel = titel;
this.message = message;
this.button1Action = null;
this.button2Action = null;
this.button3Action = null;
}
public void setMatchId(UUID matchId) {
this.matchId = matchId;
}
public void setGameId(UUID gameId) {
this.gameId = gameId;
}
public void setRelatedUser(UUID userId, String name) {
this.relatedUserId = userId;
this.relatedUserName = name;
}
public void setButton1(String text, PlayerAction buttonAction) {
this.button1Text = text;
this.button1Action = buttonAction;
}
public void setButton2(String text, PlayerAction buttonAction) {
this.button2Text = text;
this.button2Action = buttonAction;
}
public void setButton3(String text, PlayerAction buttonAction) {
this.button3Text = text;
this.button3Action = buttonAction;
}
public String getTitel() {
return titel;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getMessage() {
return message;
}
public UUID getRelatedUserId() {
return relatedUserId;
}
public String getRelatedUserName() {
return relatedUserName;
}
public UUID getMatchId() {
return matchId;
}
public UUID getGameId() {
return gameId;
}
public UUID getTournamentId() {
return tournamentId;
}
public void setTournamentId(UUID tournamentId) {
this.tournamentId = tournamentId;
}
public UUID getRoomId() {
return roomId;
}
public void setRoomId(UUID roomId) {
this.roomId = roomId;
}
public UUID getTableId() {
return tableId;
}
public void setTableId(UUID tableId) {
this.tableId = tableId;
}
public String getButton1Text() {
return button1Text;
}
public PlayerAction getButton1Action() {
return button1Action;
}
public String getButton2Text() {
return button2Text;
}
public PlayerAction getButton2Action() {
return button2Action;
}
public String getButton3Text() {
return button3Text;
}
public PlayerAction getButton3Action() {
return button3Action;
}
}

View file

@ -1,93 +1,93 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
/**
*
* @author LevelX2
*/
public class UsersView implements Serializable {
private static final long serialVersionUID = 1L;
private final String flagName;
private final String userName;
private final String matchHistory;
private final int matchQuitRatio;
private final String tourneyHistory;
private final int tourneyQuitRatio;
private final String infoGames;
private final String infoPing;
public UsersView(String flagName, String userName, String matchHistory, int matchQuitRatio,
String tourneyHistory, int tourneyQuitRatio, String infoGames, String infoPing) {
this.flagName = flagName;
this.matchHistory = matchHistory;
this.matchQuitRatio = matchQuitRatio;
this.tourneyHistory = tourneyHistory;
this.tourneyQuitRatio = tourneyQuitRatio;
this.userName = userName;
this.infoGames = infoGames;
this.infoPing = infoPing;
}
public String getFlagName() {
return flagName;
}
public String getUserName() {
return userName;
}
public String getMatchHistory() {
return matchHistory;
}
public int getMatchQuitRatio() {
return matchQuitRatio;
}
public String getTourneyHistory() {
return tourneyHistory;
}
public int getTourneyQuitRatio() {
return tourneyQuitRatio;
}
public String getInfoGames() {
return infoGames;
}
public String getInfoPing() {
return infoPing;
}
}
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
/**
*
* @author LevelX2
*/
public class UsersView implements Serializable {
private static final long serialVersionUID = 1L;
private final String flagName;
private final String userName;
private final String matchHistory;
private final int matchQuitRatio;
private final String tourneyHistory;
private final int tourneyQuitRatio;
private final String infoGames;
private final String infoPing;
public UsersView(String flagName, String userName, String matchHistory, int matchQuitRatio,
String tourneyHistory, int tourneyQuitRatio, String infoGames, String infoPing) {
this.flagName = flagName;
this.matchHistory = matchHistory;
this.matchQuitRatio = matchQuitRatio;
this.tourneyHistory = tourneyHistory;
this.tourneyQuitRatio = tourneyQuitRatio;
this.userName = userName;
this.infoGames = infoGames;
this.infoPing = infoPing;
}
public String getFlagName() {
return flagName;
}
public String getUserName() {
return userName;
}
public String getMatchHistory() {
return matchHistory;
}
public int getMatchQuitRatio() {
return matchQuitRatio;
}
public String getTourneyHistory() {
return tourneyHistory;
}
public int getTourneyQuitRatio() {
return tourneyQuitRatio;
}
public String getInfoGames() {
return infoGames;
}
public String getInfoPing() {
return infoPing;
}
}