mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
sonar 220219, criticals
This commit is contained in:
parent
4504ad5e6f
commit
3359c1f3f1
23 changed files with 153 additions and 280 deletions
|
@ -805,7 +805,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
insertArrow = new JLabel();
|
insertArrow = new JLabel();
|
||||||
insertArrow.setSize(20, 20);
|
insertArrow.setSize(20, 20);
|
||||||
insertArrow.setVisible(false);
|
insertArrow.setVisible(false);
|
||||||
cardContent.add(insertArrow, new Integer(1000));
|
cardContent.add(insertArrow, 1000);
|
||||||
|
|
||||||
// Selection panel
|
// Selection panel
|
||||||
selectionPanel = new SelectionBox();
|
selectionPanel = new SelectionBox();
|
||||||
|
|
|
@ -14,6 +14,9 @@ import java.util.UUID;
|
||||||
|
|
||||||
public final class LocalCommands {
|
public final class LocalCommands {
|
||||||
|
|
||||||
|
|
||||||
|
private LocalCommands(){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for commands that do not require server interaction, i.e settings etc
|
* Handler for commands that do not require server interaction, i.e settings etc
|
||||||
* @param chatId
|
* @param chatId
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class MageRoundPane extends JPanel {
|
||||||
private int Y_OFFSET = 30;
|
private int Y_OFFSET = 30;
|
||||||
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window
|
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window
|
||||||
private Color backgroundColor = defaultBackgroundColor;
|
private Color backgroundColor = defaultBackgroundColor;
|
||||||
private static final int alpha = 0;
|
private static final int ALPHA = 0;
|
||||||
private static final Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
|
private static final Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
|
||||||
private static final Map<Key, BufferedImage> IMAGE_CACHE;
|
private static final Map<Key, BufferedImage> IMAGE_CACHE;
|
||||||
|
|
||||||
|
@ -163,8 +163,8 @@ public class MageRoundPane extends JPanel {
|
||||||
/**
|
/**
|
||||||
* Add white translucent substrate
|
* Add white translucent substrate
|
||||||
*/
|
*/
|
||||||
/*if (alpha != 0) {
|
/*if (ALPHA != 0) {
|
||||||
g2.setColor(new Color(255, 255, 255, alpha));
|
g2.setColor(new Color(255, 255, 255, ALPHA));
|
||||||
g2.fillRoundRect(x, y, w, h, arc, arc);
|
g2.fillRoundRect(x, y, w, h, arc, arc);
|
||||||
}*/
|
}*/
|
||||||
g2.setColor(key.backgroundColor);
|
g2.setColor(key.backgroundColor);
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class BackgroundPainter extends AbstractPainter {
|
||||||
|
|
||||||
private final Color bgColor = Color.black;
|
private final Color bgColor = Color.black;
|
||||||
|
|
||||||
static final float bgalpha = 0.6f;
|
static final float BACKGROUND_ALPHA = 0.6f;
|
||||||
|
|
||||||
public BackgroundPainter() {
|
public BackgroundPainter() {
|
||||||
super();
|
super();
|
||||||
|
@ -25,7 +25,7 @@ public class BackgroundPainter extends AbstractPainter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doPaint(Graphics2D g2, Object o, int i, int i1) {
|
protected void doPaint(Graphics2D g2, Object o, int i, int i1) {
|
||||||
float alpha = bgalpha;
|
float alpha = BACKGROUND_ALPHA;
|
||||||
Component c = (Component)o;
|
Component c = (Component)o;
|
||||||
Composite composite = g2.getComposite();
|
Composite composite = g2.getComposite();
|
||||||
if (composite instanceof AlphaComposite) {
|
if (composite instanceof AlphaComposite) {
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package mage.client.components.ext;
|
||||||
|
|
||||||
|
public enum MessageDialogType {
|
||||||
|
INFO,
|
||||||
|
WARNING,
|
||||||
|
ERROR,
|
||||||
|
FLASH_INFO
|
||||||
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
package mage.client.components.ext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author mw, noxx
|
|
||||||
*/
|
|
||||||
public class MessageDlg {
|
|
||||||
|
|
||||||
MessageDlg() {}
|
|
||||||
|
|
||||||
public enum Types {
|
|
||||||
Info, Warning, Error, FlashInfo
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
package mage.client.components.ext.dlg;
|
package mage.client.components.ext.dlg;
|
||||||
|
|
||||||
import mage.client.components.ext.MessageDlg;
|
import mage.client.components.ext.MessageDialogType;
|
||||||
import mage.client.components.ext.dlg.impl.ChoiceDialog;
|
import mage.client.components.ext.dlg.impl.ChoiceDialog;
|
||||||
import mage.client.components.ext.dlg.impl.StackDialog;
|
import mage.client.components.ext.dlg.impl.StackDialog;
|
||||||
|
|
||||||
|
@ -37,9 +37,10 @@ public class DialogContainer extends JPanel {
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
drawContainer = true;
|
drawContainer = true;
|
||||||
|
|
||||||
if (dialogType == DialogManager.MTGDialogs.MessageDialog) {
|
switch (dialogType) {
|
||||||
|
case MESSAGE:
|
||||||
//backgroundColor = new Color(0, 255, 255, 60);
|
//backgroundColor = new Color(0, 255, 255, 60);
|
||||||
if (params.type == MessageDlg.Types.Warning) {
|
if (params.type == MessageDialogType.WARNING) {
|
||||||
backgroundColor = new Color(255, 0, 0, 90);
|
backgroundColor = new Color(255, 0, 0, 90);
|
||||||
} else {
|
} else {
|
||||||
backgroundColor = new Color(0, 0, 0, 90);
|
backgroundColor = new Color(0, 0, 0, 90);
|
||||||
|
@ -49,7 +50,8 @@ public class DialogContainer extends JPanel {
|
||||||
//add(dlg);
|
//add(dlg);
|
||||||
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
|
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
|
||||||
//dlg.updateSize(params.rect.width, params.rect.height);
|
//dlg.updateSize(params.rect.width, params.rect.height);
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.StackDialog) {
|
break;
|
||||||
|
case STACK: {
|
||||||
//backgroundColor = new Color(0, 255, 255, 60);
|
//backgroundColor = new Color(0, 255, 255, 60);
|
||||||
backgroundColor = new Color(0, 0, 0, 50);
|
backgroundColor = new Color(0, 0, 0, 50);
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
|
@ -60,17 +62,19 @@ public class DialogContainer extends JPanel {
|
||||||
int width = params.rect.width;
|
int width = params.rect.width;
|
||||||
int height = params.rect.height - 80;
|
int height = params.rect.height - 80;
|
||||||
dlg.updateSize(width, height);
|
dlg.updateSize(width, height);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
else if (dialogType == DialogManager.MTGDialogs.CombatDialog) {
|
else if (dialogType == DialogManager.MTGDialogs.COMBAT) {
|
||||||
backgroundColor = new Color(0, 0, 0, 60);
|
backgroundColor = new Color(0, 0, 0, 60);
|
||||||
alpha = 0;
|
alpha = 0;
|
||||||
CombatDialog dlg = new CombatDialog(params);
|
COMBAT dlg = new COMBAT(params);
|
||||||
add(dlg);
|
add(dlg);
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||||
|
|
||||||
}*/ else if (dialogType == DialogManager.MTGDialogs.ChoiceDialog) {
|
}*/
|
||||||
|
case CHOICE: {
|
||||||
|
|
||||||
//backgroundColor = new Color(200, 200, 172, 120);
|
//backgroundColor = new Color(200, 200, 172, 120);
|
||||||
//backgroundColor = new Color(180, 150, 200, 120);
|
//backgroundColor = new Color(180, 150, 200, 120);
|
||||||
|
@ -87,7 +91,9 @@ public class DialogContainer extends JPanel {
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||||
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.GraveDialog) {
|
break;
|
||||||
|
}
|
||||||
|
case GRAVEYARD: {
|
||||||
|
|
||||||
backgroundColor = new Color(0, 0, 0, 110);
|
backgroundColor = new Color(0, 0, 0, 110);
|
||||||
|
|
||||||
|
@ -97,7 +103,9 @@ public class DialogContainer extends JPanel {
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||||
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.ExileDialog) {
|
break;
|
||||||
|
}
|
||||||
|
case EXILE: {
|
||||||
|
|
||||||
backgroundColor = new Color(250, 250, 250, 50);
|
backgroundColor = new Color(250, 250, 250, 50);
|
||||||
|
|
||||||
|
@ -107,7 +115,9 @@ public class DialogContainer extends JPanel {
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||||
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.EmblemsDialog) {
|
break;
|
||||||
|
}
|
||||||
|
case EMBLEMS: {
|
||||||
|
|
||||||
backgroundColor = new Color(0, 0, 50, 110);
|
backgroundColor = new Color(0, 0, 50, 110);
|
||||||
|
|
||||||
|
@ -117,66 +127,9 @@ public class DialogContainer extends JPanel {
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||||
|
|
||||||
} /*else if (dialogType == DialogManager.MTGDialogs.GraveDialog) {
|
break;
|
||||||
backgroundColor = new Color(20, 20, 20, 120);
|
|
||||||
alpha = 0;
|
|
||||||
GraveDialog dlg = new GraveDialog(params);
|
|
||||||
add(dlg);
|
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
|
||||||
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.RevealDialog) {
|
|
||||||
backgroundColor = new Color(90, 135, 190, 80);
|
|
||||||
alpha = 0;
|
|
||||||
RevealDialog dlg = new RevealDialog(params);
|
|
||||||
add(dlg);
|
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
|
||||||
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.AssignDamageDialog) {
|
|
||||||
backgroundColor = new Color(255, 255, 255, 130);
|
|
||||||
alpha = 0;
|
|
||||||
AssignDamageDialog dlg = new AssignDamageDialog(params);
|
|
||||||
add(dlg);
|
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.ManaChoiceDialog) {
|
|
||||||
backgroundColor = new Color(0, 255, 255, 60);
|
|
||||||
alpha = 20;
|
|
||||||
ManaChoiceDialog dlg = new ManaChoiceDialog(params);
|
|
||||||
add(dlg);
|
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
|
||||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
|
||||||
|
|
||||||
//isGradient = true;
|
|
||||||
gradient = ImageManager.getGradientImage();
|
|
||||||
if (gradient != null) {
|
|
||||||
b = ImageToBufferedImage.toBufferedImage(gradient);
|
|
||||||
b = Transparency.makeImageTranslucent(b, 0.35);
|
|
||||||
Rectangle2D tr = new Rectangle2D.Double(0, 0, params.rect.width, params.rect.height);
|
|
||||||
//gradient = gradient.getScaledInstance(w, h, Image.SCALE_SMOOTH);
|
|
||||||
tp = new TexturePaint(b, tr);
|
|
||||||
}
|
}
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.ChooseDeckDialog) {
|
|
||||||
MWDeckPanel deckPanel = new MWDeckPanel(params.getDeckList(), params.isAI);
|
|
||||||
deckPanel.setVisible(true);
|
|
||||||
deckPanel.setBounds(0,0,480,320);
|
|
||||||
add(deckPanel);
|
|
||||||
drawContainer = false;
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.ChooseCommonDialog) {
|
|
||||||
MWChoosePanel choosePanel = new MWChoosePanel(params.getObjectList(), params.getTitle());
|
|
||||||
choosePanel.setVisible(true);
|
|
||||||
choosePanel.setBounds(0,0,440,240);
|
|
||||||
add(choosePanel);
|
|
||||||
drawContainer = false;
|
|
||||||
} else if (dialogType == DialogManager.MTGDialogs.AboutDialog) {
|
|
||||||
backgroundColor = new Color(255, 255, 255, 120);
|
|
||||||
alpha = 0;
|
|
||||||
AboutDialog dlg = new AboutDialog();
|
|
||||||
add(dlg);
|
|
||||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MTGDialogs {
|
public enum MTGDialogs {
|
||||||
none, AboutDialog, MessageDialog, StackDialog, AssignDamageDialog, ManaChoiceDialog, ChoiceDialog, EmblemsDialog, GraveDialog, DialogContainer, CombatDialog,
|
NONE, ABOUT, MESSAGE, STACK, ASSIGN_DAMAGE, MANA_CHOICE, CHOICE, EMBLEMS, GRAVEYARD, DialogContainer, COMBAT,
|
||||||
ChooseDeckDialog, ChooseCommonDialog, RevealDialog, ExileDialog
|
CHOOSE_DECK, CHOOSE_COMMON, REVEAL, EXILE
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MTGDialogs currentDialog = MTGDialogs.none;
|
private MTGDialogs currentDialog = MTGDialogs.NONE;
|
||||||
|
|
||||||
private DialogContainer dialogContainer = null;
|
private DialogContainer dialogContainer = null;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
params.gameId = gameId;
|
params.gameId = gameId;
|
||||||
params.feedbackPanel = feedbackPanel;
|
params.feedbackPanel = feedbackPanel;
|
||||||
params.setCards(cards);
|
params.setCards(cards);
|
||||||
dialogContainer = new DialogContainer(MTGDialogs.StackDialog, params);
|
dialogContainer = new DialogContainer(MTGDialogs.STACK, params);
|
||||||
dialogContainer.setVisible(true);
|
dialogContainer.setVisible(true);
|
||||||
add(dialogContainer);
|
add(dialogContainer);
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
params.gameId = gameId;
|
params.gameId = gameId;
|
||||||
//params.feedbackPanel = feedbackPanel;
|
//params.feedbackPanel = feedbackPanel;
|
||||||
params.setCards(cards);
|
params.setCards(cards);
|
||||||
dialogContainer = new DialogContainer(MTGDialogs.GraveDialog, params);
|
dialogContainer = new DialogContainer(MTGDialogs.GRAVEYARD, params);
|
||||||
dialogContainer.setVisible(true);
|
dialogContainer.setVisible(true);
|
||||||
add(dialogContainer);
|
add(dialogContainer);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
params.bigCard = bigCard;
|
params.bigCard = bigCard;
|
||||||
params.gameId = gameId;
|
params.gameId = gameId;
|
||||||
params.setCards(cards);
|
params.setCards(cards);
|
||||||
dialogContainer = new DialogContainer(MTGDialogs.ExileDialog, params);
|
dialogContainer = new DialogContainer(MTGDialogs.EXILE, params);
|
||||||
dialogContainer.setVisible(true);
|
dialogContainer.setVisible(true);
|
||||||
add(dialogContainer);
|
add(dialogContainer);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
params.gameId = gameId;
|
params.gameId = gameId;
|
||||||
//params.feedbackPanel = feedbackPanel;
|
//params.feedbackPanel = feedbackPanel;
|
||||||
params.setCards(cards);
|
params.setCards(cards);
|
||||||
dialogContainer = new DialogContainer(MTGDialogs.EmblemsDialog, params);
|
dialogContainer = new DialogContainer(MTGDialogs.EMBLEMS, params);
|
||||||
dialogContainer.setVisible(true);
|
dialogContainer.setVisible(true);
|
||||||
add(dialogContainer);
|
add(dialogContainer);
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
removeAll();
|
removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentDialog = MTGDialogs.none;
|
this.currentDialog = MTGDialogs.NONE;
|
||||||
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
|
||||||
|
@ -312,6 +312,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -360,7 +361,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
int notches = e.getWheelRotation();
|
int notches = e.getWheelRotation();
|
||||||
// System.out.println("outx:"+notches);
|
// System.out.println("outx:"+notches);
|
||||||
// if (currentDialog != null && currentDialog.equals(MTGDialogs.ChooseCommonDialog)) {
|
// if (currentDialog != null && currentDialog.equals(MTGDialogs.CHOOSE_COMMON)) {
|
||||||
// System.out.println("out:"+1);
|
// System.out.println("out:"+1);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package mage.client.components.ext.dlg;
|
package mage.client.components.ext.dlg;
|
||||||
|
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.components.ext.MessageDlg;
|
import mage.client.components.ext.MessageDialogType;
|
||||||
import mage.client.game.FeedbackPanel;
|
import mage.client.game.FeedbackPanel;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import java.util.UUID;
|
||||||
public class DlgParams {
|
public class DlgParams {
|
||||||
|
|
||||||
public Rectangle rect;
|
public Rectangle rect;
|
||||||
public MessageDlg.Types type;
|
public MessageDialogType type;
|
||||||
public BigCard bigCard;
|
public BigCard bigCard;
|
||||||
public FeedbackPanel feedbackPanel;
|
public FeedbackPanel feedbackPanel;
|
||||||
public UUID gameId;
|
public UUID gameId;
|
||||||
|
@ -33,13 +33,13 @@ public class DlgParams {
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private int opponentID;
|
private int opponentID;
|
||||||
boolean isOptional = false;
|
private boolean isOptional = false;
|
||||||
boolean isChooseAbility = false;
|
private boolean isChooseAbility = false;
|
||||||
boolean isCancelStopsPlaying = true;
|
private boolean isCancelStopsPlaying = true;
|
||||||
|
|
||||||
boolean isAI = false;
|
private boolean isAI = false;
|
||||||
|
|
||||||
public Set<String> manaChoices = new HashSet<>();
|
private Set<String> manaChoices = new HashSet<>();
|
||||||
|
|
||||||
public int getPlayerID() {
|
public int getPlayerID() {
|
||||||
return playerID;
|
return playerID;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CombatDialog.java
|
* COMBAT.java
|
||||||
*
|
*
|
||||||
* Created on Feb 10, 2010, 3:35:02 PM
|
* Created on Feb 10, 2010, 3:35:02 PM
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,7 @@ public class CombatDialog extends MageDialog {
|
||||||
private int lastX = 500;
|
private int lastX = 500;
|
||||||
private int lastY = 300;
|
private int lastY = 300;
|
||||||
|
|
||||||
/** Creates new form CombatDialog */
|
/** Creates new form COMBAT */
|
||||||
public CombatDialog() {
|
public CombatDialog() {
|
||||||
|
|
||||||
JPanel contentPane = new JPanel() {
|
JPanel contentPane = new JPanel() {
|
||||||
|
|
|
@ -164,10 +164,7 @@ public final class DeckBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
Integer typeCount = colorCount.get(symbol);
|
Integer typeCount = colorCount.getOrDefault(symbol, 0);
|
||||||
if (typeCount == null) {
|
|
||||||
typeCount = 0;
|
|
||||||
}
|
|
||||||
typeCount += 1;
|
typeCount += 1;
|
||||||
colorCount.put(symbol, typeCount);
|
colorCount.put(symbol, typeCount);
|
||||||
}
|
}
|
||||||
|
@ -243,9 +240,9 @@ public final class DeckBuilder {
|
||||||
int type;
|
int type;
|
||||||
if (card.isCreature()) {
|
if (card.isCreature()) {
|
||||||
type = 10;
|
type = 10;
|
||||||
} else if (card.getSubtype(null).contains(SubType.EQUIPMENT)) {
|
} else if (card.hasSubtype(SubType.EQUIPMENT, null)) {
|
||||||
type = 8;
|
type = 8;
|
||||||
} else if (card.getSubtype(null).contains(SubType.AURA)) {
|
} else if (card.hasSubtype(SubType.AURA, null)) {
|
||||||
type = 5;
|
type = 5;
|
||||||
} else if (card.isInstant()) {
|
} else if (card.isInstant()) {
|
||||||
type = 7;
|
type = 7;
|
||||||
|
@ -283,10 +280,7 @@ public final class DeckBuilder {
|
||||||
multicolor += 1;
|
multicolor += 1;
|
||||||
colors.add(symbol);
|
colors.add(symbol);
|
||||||
}
|
}
|
||||||
Integer typeCount = singleCount.get(symbol);
|
Integer typeCount = singleCount.getOrDefault(symbol, 0);
|
||||||
if (typeCount == null) {
|
|
||||||
typeCount = 0;
|
|
||||||
}
|
|
||||||
typeCount += 1;
|
typeCount += 1;
|
||||||
singleCount.put(symbol, typeCount);
|
singleCount.put(symbol, typeCount);
|
||||||
maxSingleCount = Math.max(maxSingleCount, typeCount);
|
maxSingleCount = Math.max(maxSingleCount, typeCount);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public enum TableRecordRepository {
|
public enum TableRecordRepository {
|
||||||
|
@ -63,7 +64,7 @@ public enum TableRecordRepository {
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(TableRecordRepository.class).error("Error getting table_records from DB - ", ex);
|
Logger.getLogger(TableRecordRepository.class).error("Error getting table_records from DB - ", ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeDB() {
|
public void closeDB() {
|
||||||
|
|
|
@ -16,10 +16,7 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public enum UserStatsRepository {
|
public enum UserStatsRepository {
|
||||||
|
|
||||||
|
@ -89,7 +86,7 @@ public enum UserStatsRepository {
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(UserStatsRepository.class).error("Error getting all users from DB - ", ex);
|
Logger.getLogger(UserStatsRepository.class).error("Error getting all users from DB - ", ex);
|
||||||
}
|
}
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLatestEndTimeMs() {
|
public long getLatestEndTimeMs() {
|
||||||
|
|
|
@ -12,6 +12,8 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public final class Config {
|
public final class Config {
|
||||||
|
|
||||||
|
private Config(){}
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Config.class);
|
private static final Logger logger = Logger.getLogger(Config.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@ -52,7 +53,6 @@ public enum ServerMessagesUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<String> getMessages() {
|
public List<String> getMessages() {
|
||||||
lock.readLock().lock();
|
lock.readLock().lock();
|
||||||
try {
|
try {
|
||||||
|
@ -66,9 +66,7 @@ public enum ServerMessagesUtil {
|
||||||
log.debug("Reading server messages...");
|
log.debug("Reading server messages...");
|
||||||
List<String> motdMessages = readFromFile();
|
List<String> motdMessages = readFromFile();
|
||||||
List<String> newMessages = new ArrayList<>();
|
List<String> newMessages = new ArrayList<>();
|
||||||
if (motdMessages != null) {
|
|
||||||
newMessages.addAll(motdMessages);
|
newMessages.addAll(motdMessages);
|
||||||
}
|
|
||||||
newMessages.add(getServerStatistics());
|
newMessages.add(getServerStatistics());
|
||||||
newMessages.add(getServerStatistics2());
|
newMessages.add(getServerStatistics2());
|
||||||
|
|
||||||
|
@ -83,7 +81,7 @@ public enum ServerMessagesUtil {
|
||||||
|
|
||||||
private List<String> readFromFile() {
|
private List<String> readFromFile() {
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
File externalFile = null;
|
File externalFile = null;
|
||||||
if (pathToExternalMessages != null) {
|
if (pathToExternalMessages != null) {
|
||||||
|
@ -120,7 +118,7 @@ public enum ServerMessagesUtil {
|
||||||
}
|
}
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
log.warn("Couldn't find server.msg");
|
log.warn("Couldn't find server.msg");
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Scanner scanner = null;
|
Scanner scanner = null;
|
||||||
|
@ -133,8 +131,8 @@ public enum ServerMessagesUtil {
|
||||||
newMessages.add(message.trim());
|
newMessages.add(message.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e,e);
|
log.error(e, e);
|
||||||
} finally {
|
} finally {
|
||||||
StreamUtils.closeQuietly(scanner);
|
StreamUtils.closeQuietly(scanner);
|
||||||
StreamUtils.closeQuietly(is);
|
StreamUtils.closeQuietly(is);
|
||||||
|
@ -168,7 +166,7 @@ public enum ServerMessagesUtil {
|
||||||
return statistics.toString();
|
return statistics.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Timer timer = new Timer(1000 * 60, new ActionListener() {
|
// private Timer timer = new Timer(1000 * 60, new ActionListener() {
|
||||||
// public void actionPerformed(ActionEvent e) {
|
// public void actionPerformed(ActionEvent e) {
|
||||||
// reloadMessages();
|
// reloadMessages();
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -11,6 +11,8 @@ import mage.players.Player;
|
||||||
*/
|
*/
|
||||||
public final class Splitter {
|
public final class Splitter {
|
||||||
|
|
||||||
|
private Splitter(){}
|
||||||
|
|
||||||
public static List<UUID> split(Game game, UUID playerId) {
|
public static List<UUID> split(Game game, UUID playerId) {
|
||||||
List<UUID> players = new ArrayList<>();
|
List<UUID> players = new ArrayList<>();
|
||||||
//players.add(playerId); // add original player
|
//players.add(playerId); // add original player
|
||||||
|
|
|
@ -31,6 +31,8 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
public final class SystemUtil {
|
public final class SystemUtil {
|
||||||
|
|
||||||
|
private SystemUtil(){}
|
||||||
|
|
||||||
public static final DateFormat dateFormat = new SimpleDateFormat("yy-M-dd HH:mm:ss");
|
public static final DateFormat dateFormat = new SimpleDateFormat("yy-M-dd HH:mm:ss");
|
||||||
|
|
||||||
private static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
|
private static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
|
||||||
|
@ -120,7 +122,7 @@ public final class SystemUtil {
|
||||||
String cardInfo = card.getName() + " - " + card.getExpansionSetCode();
|
String cardInfo = card.getName() + " - " + card.getExpansionSetCode();
|
||||||
|
|
||||||
// optional info
|
// optional info
|
||||||
ArrayList<String> resInfo = new ArrayList<>();
|
List<String> resInfo = new ArrayList<>();
|
||||||
for (String param : commandParams) {
|
for (String param : commandParams) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case PARAM_COLOR_COST:
|
case PARAM_COLOR_COST:
|
||||||
|
@ -147,7 +149,7 @@ public final class SystemUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resInfo.size() > 0) {
|
if (!resInfo.isEmpty()) {
|
||||||
cardInfo += ": " + resInfo.stream().collect(Collectors.joining("; "));
|
cardInfo += ": " + resInfo.stream().collect(Collectors.joining("; "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,12 +557,9 @@ public final class SystemUtil {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static Optional<Player> findPlayer(Game game, String name) {
|
private static Optional<Player> findPlayer(Game game, String name) {
|
||||||
for (Player player : game.getPlayers().values()) {
|
return game.getPlayers().values().stream()
|
||||||
if (player.getName().equals(name)) {
|
.filter(player -> player.getName().equals(name)).findFirst();
|
||||||
return Optional.of(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sanitize(String input) {
|
public static String sanitize(String input) {
|
||||||
|
|
|
@ -19,12 +19,12 @@ import mage.watchers.common.BloodthirstWatcher;
|
||||||
*/
|
*/
|
||||||
public final class Antagonism extends CardImpl {
|
public final class Antagonism extends CardImpl {
|
||||||
|
|
||||||
private static final String rule = "{this} deals 2 damage to that player unless one of his or her opponents was dealt damage this turn";
|
private static final String rule = "{this} deals 2 damage to that player unless one of their opponents was dealt damage this turn";
|
||||||
|
|
||||||
public Antagonism(UUID ownerId, CardSetInfo setInfo) {
|
public Antagonism(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
|
||||||
|
|
||||||
// At the beginning of each player's end step, Antagonism deals 2 damage to that player unless one of his or her opponents was dealt damage this turn.
|
// At the beginning of each player's end step, Antagonism deals 2 damage to that player unless one of their opponents was dealt damage this turn.
|
||||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(new ConditionalOneShotEffect(new DamageTargetEffect(2),
|
this.addAbility(new BeginningOfEndStepTriggeredAbility(new ConditionalOneShotEffect(new DamageTargetEffect(2),
|
||||||
new OpponentWasNotDealtDamageCondition(), rule), TargetController.ANY, false));
|
new OpponentWasNotDealtDamageCondition(), rule), TargetController.ANY, false));
|
||||||
|
|
||||||
|
|
|
@ -53,78 +53,6 @@ public final class NullChamber extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NullChamberChooseACardNameEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
public static String INFO_KEY = "NAMED_CARD";
|
|
||||||
|
|
||||||
public enum TypeOfName {
|
|
||||||
NOT_BASIC_LAND_NAME,
|
|
||||||
}
|
|
||||||
|
|
||||||
private final TypeOfName typeOfName;
|
|
||||||
|
|
||||||
public NullChamberChooseACardNameEffect(TypeOfName typeOfName) {
|
|
||||||
super(Outcome.Detriment);
|
|
||||||
this.typeOfName = typeOfName;
|
|
||||||
staticText = setText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NullChamberChooseACardNameEffect(final NullChamberChooseACardNameEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
this.typeOfName = effect.typeOfName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
|
||||||
Player opponent = game.getPlayer(source.getFirstTarget());
|
|
||||||
MageObject sourceObject = game.getPermanentEntering(source.getSourceId());
|
|
||||||
if (sourceObject == null) {
|
|
||||||
sourceObject = game.getObject(source.getSourceId());
|
|
||||||
}
|
|
||||||
if (controller != null
|
|
||||||
&& opponent != null
|
|
||||||
&& sourceObject != null) {
|
|
||||||
Choice cardChoice = new ChoiceImpl();
|
|
||||||
switch (typeOfName) {
|
|
||||||
case NOT_BASIC_LAND_NAME:
|
|
||||||
cardChoice.setChoices(CardRepository.instance.getNotBasicLandNames());
|
|
||||||
cardChoice.setMessage("Choose a card name other than a basic land card name");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cardChoice.clearChoice();
|
|
||||||
if (controller.choose(Outcome.Detriment, cardChoice, game)) {
|
|
||||||
String cardName = cardChoice.getChoice();
|
|
||||||
if (!game.isSimulation()) {
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + ']');
|
|
||||||
}
|
|
||||||
game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName);
|
|
||||||
if (sourceObject instanceof Permanent) {
|
|
||||||
((Permanent) sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Named card: " + cardName), game);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NullChamberChooseACardNameEffect copy() {
|
|
||||||
return new NullChamberChooseACardNameEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String setText() {
|
|
||||||
StringBuilder sb = new StringBuilder("choose a ");
|
|
||||||
switch (typeOfName) {
|
|
||||||
case NOT_BASIC_LAND_NAME:
|
|
||||||
sb.append("card name other than a basic land card");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sb.append(" name");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class NullChamberReplacementEffect extends ContinuousRuleModifyingEffectImpl {
|
class NullChamberReplacementEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class VenarianGoldValue implements DynamicValue {
|
||||||
@Override
|
@Override
|
||||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||||
MageObject mageObject = game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.STACK);
|
MageObject mageObject = game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.STACK);
|
||||||
if (mageObject != null && mageObject instanceof StackObject) {
|
if (mageObject instanceof StackObject) {
|
||||||
return ((StackObject) mageObject).getStackAbility().getManaCostsToPay().getX();
|
return ((StackObject) mageObject).getStackAbility().getManaCostsToPay().getX();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -111,7 +111,7 @@ class CanTargetOnlyWallsPredicate implements Predicate<MageObject> {
|
||||||
for (Mode mode : stackObject.getStackAbility().getModes().values()) {
|
for (Mode mode : stackObject.getStackAbility().getModes().values()) {
|
||||||
for (Target target : mode.getTargets()) {
|
for (Target target : mode.getTargets()) {
|
||||||
Filter filter = target.getFilter();
|
Filter filter = target.getFilter();
|
||||||
if (filter != null && filter instanceof FilterPermanent) {
|
if (filter instanceof FilterPermanent) {
|
||||||
for (Object predicate : filter.getPredicates()) {
|
for (Object predicate : filter.getPredicates()) {
|
||||||
if (predicate instanceof SubtypePredicate) {
|
if (predicate instanceof SubtypePredicate) {
|
||||||
if (predicate.toString().equals("Subtype(Wall)")) {
|
if (predicate.toString().equals("Subtype(Wall)")) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class SkipNextDrawStepTargetEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
public SkipNextDrawStepTargetEffect() {
|
public SkipNextDrawStepTargetEffect() {
|
||||||
super(Duration.OneUse, Outcome.Detriment);
|
super(Duration.OneUse, Outcome.Detriment);
|
||||||
staticText = "Target player skips his or her next draw step";
|
staticText = "Target player skips their next draw step";
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkipNextDrawStepTargetEffect(final SkipNextDrawStepTargetEffect effect) {
|
public SkipNextDrawStepTargetEffect(final SkipNextDrawStepTargetEffect effect) {
|
||||||
|
|
|
@ -19,23 +19,23 @@ import mage.filter.predicate.permanent.CounterPredicate;
|
||||||
*/
|
*/
|
||||||
public class BountyAbility extends DiesCreatureTriggeredAbility {
|
public class BountyAbility extends DiesCreatureTriggeredAbility {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls with a bounty counter on it");
|
private static final FilterCreaturePermanent bountyCounterFilter = new FilterCreaturePermanent("creature an opponent controls with a bounty counter on it");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
bountyCounterFilter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||||
filter.add(new CounterPredicate(CounterType.BOUNTY));
|
bountyCounterFilter.add(new CounterPredicate(CounterType.BOUNTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BountyAbility(Effect effect) {
|
public BountyAbility(Effect effect) {
|
||||||
super(effect, false, filter);
|
super(effect, false, bountyCounterFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BountyAbility(Effect effect, boolean optional) {
|
public BountyAbility(Effect effect, boolean optional) {
|
||||||
super(effect, optional, filter);
|
super(effect, optional, bountyCounterFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BountyAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
public BountyAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||||
super(effect, optional, filter, setTargetPointer);
|
super(effect, optional, bountyCounterFilter, setTargetPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BountyAbility(final BountyAbility ability) {
|
public BountyAbility(final BountyAbility ability) {
|
||||||
|
|
Loading…
Reference in a new issue