mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
commit
e5c5f7f72e
872 changed files with 28395 additions and 7503 deletions
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.mage</groupId>
|
||||
|
|
|
@ -142,6 +142,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
*/
|
||||
/**
|
||||
* Creates new form ChatPanel
|
||||
*
|
||||
* @param addPlayersTab
|
||||
*/
|
||||
public ChatPanel(boolean addPlayersTab) {
|
||||
|
@ -262,6 +263,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
sb.append("</font>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return txtConversation.getText();
|
||||
}
|
||||
|
@ -326,7 +328,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
|
||||
class UserTableModel extends AbstractTableModel {
|
||||
|
||||
private final String[] columnNames = new String[]{" ","Players", "Info", "Games", "Connection"};
|
||||
private final String[] columnNames = new String[]{"Loc", "Players", "Info", "Games", "Connection"};
|
||||
private UsersView[] players = new UsersView[0];
|
||||
|
||||
public void loadData(Collection<RoomUsersView> roomUserInfoList) throws MageRemoteException {
|
||||
|
@ -337,9 +339,9 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(1)).setHeaderValue("Players (" + this.players.length + ")");
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(3)).setHeaderValue(
|
||||
"Games " + roomUserInfo.getNumberActiveGames() +
|
||||
(roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads():" (") +
|
||||
" limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
||||
"Games " + roomUserInfo.getNumberActiveGames()
|
||||
+ (roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads() : " (")
|
||||
+ " limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
||||
th.repaint();
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
@ -397,8 +399,6 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package mage.client.components;
|
||||
|
||||
import mage.client.util.Command;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import javax.swing.JPanel;
|
||||
import mage.client.util.Command;
|
||||
|
||||
/**
|
||||
* Image button with hover.
|
||||
|
@ -48,6 +53,8 @@ public class HoverButton extends JPanel implements MouseListener {
|
|||
static final Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
|
||||
private boolean useMiniFont = false;
|
||||
|
||||
private boolean alignTextLeft = false;
|
||||
|
||||
public HoverButton(String text, Image image, Rectangle size) {
|
||||
this(text, image, image, null, image, size);
|
||||
if (image == null) {
|
||||
|
@ -113,7 +120,7 @@ public class HoverButton extends JPanel implements MouseListener {
|
|||
}
|
||||
topTextOffsetX = calculateOffsetForTop(g2d, topText);
|
||||
g2d.setColor(textBGColor);
|
||||
g2d.drawString(topText, topTextOffsetX+1, 13);
|
||||
g2d.drawString(topText, topTextOffsetX + 1, 13);
|
||||
g2d.setColor(textColor);
|
||||
g2d.drawString(topText, topTextOffsetX, 12);
|
||||
}
|
||||
|
@ -148,8 +155,12 @@ public class HoverButton extends JPanel implements MouseListener {
|
|||
frc = g2d.getFontRenderContext();
|
||||
textWidth = (int) textFontMini.getStringBounds(text, frc).getWidth();
|
||||
}
|
||||
if (alignTextLeft) {
|
||||
textOffsetX = 0;
|
||||
} else {
|
||||
textOffsetX = (imageSize.width - textWidth) / 2;
|
||||
}
|
||||
}
|
||||
return textOffsetX;
|
||||
}
|
||||
|
||||
|
@ -277,4 +288,8 @@ public class HoverButton extends JPanel implements MouseListener {
|
|||
this.textAlwaysVisible = textAlwaysVisible;
|
||||
}
|
||||
|
||||
public void setAlignTextLeft(boolean alignTextLeft) {
|
||||
this.alignTextLeft = alignTextLeft;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package mage.client.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
import org.mage.card.arcane.UI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
/**
|
||||
* Component for displaying text in mage.
|
||||
* Supports drawing mana symbols.
|
||||
* Component for displaying text in mage. Supports drawing mana symbols.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
|
||||
public class MageTextArea extends JEditorPane {
|
||||
|
||||
public MageTextArea() {
|
||||
|
@ -27,10 +24,10 @@ public class MageTextArea extends JEditorPane {
|
|||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
setText(text, 16);
|
||||
setText(text, 0);
|
||||
}
|
||||
|
||||
public void setText(String text, int fontSize) {
|
||||
public void setText(String text, final int panelWidth) {
|
||||
if (text == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -38,23 +35,36 @@ public class MageTextArea extends JEditorPane {
|
|||
final StringBuilder buffer = new StringBuilder(512);
|
||||
// Dialog is a java logical font family, so it should work on all systems
|
||||
buffer.append("<html><body style='font-family:Dialog;font-size:");
|
||||
buffer.append(fontSize);
|
||||
buffer.append(16);
|
||||
buffer.append("pt;margin:3px 3px 3px 3px;color: #FFFFFF'><b><center>");
|
||||
|
||||
text = text.replaceAll("#([^#]+)#", "<i>$1</i>");
|
||||
// Don't know what it does (easy italc?) but it bugs with multiple #HTML color codes (LevelX2)
|
||||
//text = text.replaceAll("#([^#]+)#", "<i>$1</i>");
|
||||
//text = text.replaceAll("\\s*//\\s*", "<hr width='50%'>");
|
||||
text = text.replace("\r\n", "<div style='font-size:5pt'></div>");
|
||||
|
||||
final String basicText = ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.PAY);
|
||||
if (text.length() > 0) {
|
||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.PAY));
|
||||
buffer.append(basicText);
|
||||
}
|
||||
|
||||
buffer.append("</b></center></body></html>");
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MageTextArea.super.setText(buffer.toString());
|
||||
//System.out.println(buffer.toString());
|
||||
String promptText = buffer.toString();
|
||||
MageTextArea.super.setText(promptText);
|
||||
// in case the text don't fit in the panel a tooltip with the text is added
|
||||
if (panelWidth > 0 && MageTextArea.this.getPreferredSize().getWidth() > panelWidth) {
|
||||
// String tooltip = promptText
|
||||
// .replace("color: #FFFFFF'>", "color: #111111'><p width='400'>")
|
||||
// .replace("</body>", "</p></body>");
|
||||
String tooltip = "<html><center><body style='font-family:Dialog;font-size:14;color: #FFFFFF'><p width='500'>" + basicText + "</p></body></html>";
|
||||
MageTextArea.super.setToolTipText(tooltip);
|
||||
} else {
|
||||
MageTextArea.super.setToolTipText(null);
|
||||
}
|
||||
setCaretPosition(0);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.client.dialog;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -46,6 +46,7 @@ import mage.cards.repository.ExpansionRepository;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.constants.Constants.DeckEditorMode;
|
||||
import mage.constants.Rarity;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,12 +54,16 @@ import mage.constants.Rarity;
|
|||
*/
|
||||
public class AddLandDialog extends MageDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MageDialog.class);
|
||||
|
||||
private Deck deck;
|
||||
private final Set<String> setCodesland = new HashSet<>();
|
||||
|
||||
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
|
||||
|
||||
/** Creates new form AddLandDialog */
|
||||
/**
|
||||
* Creates new form AddLandDialog
|
||||
*/
|
||||
public AddLandDialog() {
|
||||
initComponents();
|
||||
this.setModal(true);
|
||||
|
@ -69,7 +74,7 @@ public class AddLandDialog extends MageDialog {
|
|||
SortedSet<String> landSets = new TreeSet<>();
|
||||
if (!mode.equals(DeckEditorMode.FREE_BUILDING)) {
|
||||
// decide from which sets basic lands are taken from
|
||||
for (String setCode :deck.getExpansionSetCodes()) {
|
||||
for (String setCode : deck.getExpansionSetCodes()) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||
if (expansionInfo != null && expansionInfo.hasBasicLands()) {
|
||||
this.setCodesland.add(expansionInfo.getCode());
|
||||
|
@ -79,11 +84,11 @@ public class AddLandDialog extends MageDialog {
|
|||
|
||||
// if sets have no basic land, take land from block
|
||||
if (this.setCodesland.isEmpty()) {
|
||||
for (String setCode :deck.getExpansionSetCodes()) {
|
||||
for (String setCode : deck.getExpansionSetCodes()) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||
if (expansionInfo != null) {
|
||||
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
|
||||
for (ExpansionInfo blockSet: blockSets) {
|
||||
for (ExpansionInfo blockSet : blockSets) {
|
||||
if (blockSet.hasBasicLands()) {
|
||||
this.setCodesland.add(blockSet.getCode());
|
||||
landSets.add(blockSet.getName());
|
||||
|
@ -96,14 +101,14 @@ public class AddLandDialog extends MageDialog {
|
|||
// if still no set with lands found, add list of all available
|
||||
if (this.setCodesland.isEmpty()) {
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
for (ExpansionInfo expansionInfo: basicLandSets) {
|
||||
for (ExpansionInfo expansionInfo : basicLandSets) {
|
||||
landSets.add(expansionInfo.getName());
|
||||
}
|
||||
}
|
||||
if (landSets.isEmpty()) {
|
||||
throw new IllegalArgumentException("No set with basic land was found");
|
||||
}
|
||||
if(landSets.size() > 1) {
|
||||
if (landSets.size() > 1) {
|
||||
landSets.add("<Random lands>");
|
||||
}
|
||||
cbLandSet.setModel(new DefaultComboBoxModel(landSets.toArray()));
|
||||
|
@ -129,7 +134,11 @@ public class AddLandDialog extends MageDialog {
|
|||
criteria.rarities(Rarity.LAND).name(landName);
|
||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||
if (cards.isEmpty()) {
|
||||
throw new IllegalArgumentException("No basic lands found in Set: " + landSetName);
|
||||
logger.error("No basic lands found in Set: " + landSetName);
|
||||
criteria = new CardCriteria();
|
||||
criteria.rarities(Rarity.LAND).name(landName);
|
||||
criteria.setCodes("M15");
|
||||
cards = CardRepository.instance.findCards(criteria);
|
||||
}
|
||||
|
||||
for (int i = 0; i < number; i++) {
|
||||
|
@ -138,10 +147,10 @@ public class AddLandDialog extends MageDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
|
@ -298,11 +307,11 @@ public class AddLandDialog extends MageDialog {
|
|||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
||||
int nForest = ((Number)spnForest.getValue()).intValue();
|
||||
int nIsland = ((Number)spnIsland.getValue()).intValue();
|
||||
int nMountain = ((Number)spnMountain.getValue()).intValue();
|
||||
int nPlains = ((Number)spnPlains.getValue()).intValue();
|
||||
int nSwamp = ((Number)spnSwamp.getValue()).intValue();
|
||||
int nForest = ((Number) spnForest.getValue()).intValue();
|
||||
int nIsland = ((Number) spnIsland.getValue()).intValue();
|
||||
int nMountain = ((Number) spnMountain.getValue()).intValue();
|
||||
int nPlains = ((Number) spnPlains.getValue()).intValue();
|
||||
int nSwamp = ((Number) spnSwamp.getValue()).intValue();
|
||||
|
||||
addLands("Forest", nForest);
|
||||
addLands("Island", nIsland);
|
||||
|
@ -316,7 +325,7 @@ public class AddLandDialog extends MageDialog {
|
|||
autoAddLands();
|
||||
}//GEN-LAST:event_btnAutoAddActionPerformed
|
||||
|
||||
private void autoAddLands(){
|
||||
private void autoAddLands() {
|
||||
int red = 0;
|
||||
int green = 0;
|
||||
int black = 0;
|
||||
|
@ -324,7 +333,9 @@ public class AddLandDialog extends MageDialog {
|
|||
int white = 0;
|
||||
Set<Card> cards = deck.getCards();
|
||||
int land_number = DEFAULT_SEALED_DECK_CARD_NUMBER - cards.size();
|
||||
if(land_number < 0) land_number = 0;
|
||||
if (land_number < 0) {
|
||||
land_number = 0;
|
||||
}
|
||||
for (Card cd : cards) {
|
||||
Mana m = cd.getManaCost().getMana();
|
||||
red += m.getRed();
|
||||
|
@ -334,14 +345,18 @@ public class AddLandDialog extends MageDialog {
|
|||
white += m.getWhite();
|
||||
}
|
||||
int total = red + green + black + blue + white;
|
||||
int redcards = Math.round(land_number*((float)red/(float)total));
|
||||
total -= red; land_number -= redcards;
|
||||
int greencards = Math.round(land_number*((float)green/(float)total));
|
||||
total -= green; land_number -= greencards;
|
||||
int blackcards = Math.round(land_number*((float)black/(float)total));
|
||||
total -= black; land_number -= blackcards;
|
||||
int bluecards = Math.round(land_number*((float)blue/(float)total));
|
||||
total -= blue; land_number -= bluecards;
|
||||
int redcards = Math.round(land_number * ((float) red / (float) total));
|
||||
total -= red;
|
||||
land_number -= redcards;
|
||||
int greencards = Math.round(land_number * ((float) green / (float) total));
|
||||
total -= green;
|
||||
land_number -= greencards;
|
||||
int blackcards = Math.round(land_number * ((float) black / (float) total));
|
||||
total -= black;
|
||||
land_number -= blackcards;
|
||||
int bluecards = Math.round(land_number * ((float) blue / (float) total));
|
||||
total -= blue;
|
||||
land_number -= bluecards;
|
||||
int whitecards = land_number;
|
||||
spnMountain.setValue(redcards);
|
||||
spnForest.setValue(greencards);
|
||||
|
|
|
@ -112,6 +112,25 @@ public class CardInfoWindowDialog extends MageDialog {
|
|||
cards.cleanUp();
|
||||
}
|
||||
|
||||
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
|
||||
boolean changed = cards.loadCards(exile, bigCard, gameId, null);
|
||||
String titel = name + " (" + exile.size() + ")";
|
||||
setTitle(titel);
|
||||
this.setTitelBarToolTip(titel);
|
||||
if (exile.size() > 0) {
|
||||
show();
|
||||
if (changed) {
|
||||
try {
|
||||
this.setIcon(false);
|
||||
} catch (PropertyVetoException ex) {
|
||||
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.hideDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCards(SimpleCardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
cards.loadCards(showCards, bigCard, gameId);
|
||||
showAndPositionWindow();
|
||||
|
@ -120,8 +139,9 @@ public class CardInfoWindowDialog extends MageDialog {
|
|||
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
cards.loadCards(showCards, bigCard, gameId, null);
|
||||
if (showType.equals(ShowType.GRAVEYARD)) {
|
||||
setTitle(name + "'s Graveyard (" + showCards.size() + ")");
|
||||
this.setTitelBarToolTip(name);
|
||||
String titel = name + "'s Graveyard (" + showCards.size() + ")";
|
||||
setTitle(titel);
|
||||
this.setTitelBarToolTip(titel);
|
||||
}
|
||||
showAndPositionWindow();
|
||||
}
|
||||
|
@ -160,22 +180,6 @@ public class CardInfoWindowDialog extends MageDialog {
|
|||
});
|
||||
}
|
||||
|
||||
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
|
||||
boolean changed = cards.loadCards(exile, bigCard, gameId, null);
|
||||
if (exile.size() > 0) {
|
||||
show();
|
||||
if (changed) {
|
||||
try {
|
||||
this.setIcon(false);
|
||||
} catch (PropertyVetoException ex) {
|
||||
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.hideDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
|
|
@ -40,6 +40,7 @@ import java.awt.EventQueue;
|
|||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.MenuComponent;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -119,10 +120,10 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
Object source = event.getSource();
|
||||
boolean dispatch = true;
|
||||
|
||||
if (event.getSource() != null && event.getSource() instanceof TrayIcon) {
|
||||
// https://github.com/magefree/mage/issues/584 - Let's hope this will fix the Linux window problem
|
||||
if (event.getSource() != null && event.getSource() instanceof TrayIcon && !(event instanceof InvocationEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event instanceof MouseEvent && event.getSource() instanceof Component) {
|
||||
MouseEvent e = (MouseEvent) event;
|
||||
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
|
@ -226,7 +227,6 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
|
|
@ -35,17 +35,15 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.DefaultListSelectionModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import static javax.swing.ListSelectionModel.SINGLE_SELECTION;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
|
@ -80,12 +78,12 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private UUID roomId;
|
||||
private final Session session;
|
||||
private String lastSessionId;
|
||||
private JList randomList = new JList();
|
||||
private RandomPacksSelectorDialog randomPackSelector;
|
||||
private JTextArea txtRandomPacks;
|
||||
private final List<TournamentPlayerPanel> players = new ArrayList<>();
|
||||
private final List<JComboBox> packs = new ArrayList<>();
|
||||
private final int CONSTRUCTION_TIME_MIN = 6;
|
||||
private final int CONSTRUCTION_TIME_MAX = 30;
|
||||
private final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||
|
||||
private boolean automaticChange = false;
|
||||
|
||||
|
@ -534,15 +532,8 @@ public class NewTournamentDialog extends MageDialog {
|
|||
if (tournamentType.isCubeBooster()) {
|
||||
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
||||
} else if (tournamentType.isRandom()) {
|
||||
for (Object pack : randomList.getSelectedValuesList()) {
|
||||
String packStr = (String) pack;
|
||||
String code = packStr.substring(0, 3);
|
||||
tOptions.getLimitedOptions().getSetCodes().add(code);
|
||||
}
|
||||
if (tOptions.getLimitedOptions().getSetCodes().size() < 2) {
|
||||
// At least two sets must be chosen.
|
||||
return;
|
||||
}
|
||||
tOptions.getLimitedOptions().getSetCodes().clear();
|
||||
tOptions.getLimitedOptions().getSetCodes().addAll(randomPackSelector.getSelectedPacks());
|
||||
} else {
|
||||
for (JComboBox pack: packs) {
|
||||
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
|
||||
|
@ -724,60 +715,54 @@ public class NewTournamentDialog extends MageDialog {
|
|||
|
||||
private void createRandomPacks() {
|
||||
if (pnlRandomPacks.getComponentCount() == 0) {
|
||||
|
||||
DefaultListModel randomListModel = new DefaultListModel();
|
||||
randomList = new JList(randomListModel);
|
||||
randomList.setToolTipText(randomDraftDescription);
|
||||
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||
for (ExpansionInfo expansion : allExpansions) {
|
||||
String exp = expansion.getCode() + " - " + expansion.getName();
|
||||
randomListModel.addElement(exp);
|
||||
if (randomPackSelector == null) {
|
||||
randomPackSelector = new RandomPacksSelectorDialog();
|
||||
}
|
||||
randomList.setSelectionModel(new DefaultListSelectionModel() {
|
||||
private boolean mGestureStarted;
|
||||
|
||||
@Override
|
||||
public void setSelectionInterval(int index0, int index1) {
|
||||
// Toggle only one element while the user is dragging the mouse
|
||||
if (!mGestureStarted) {
|
||||
if (isSelectedIndex(index0)) {
|
||||
super.removeSelectionInterval(index0, index1);
|
||||
} else {
|
||||
if (getSelectionMode() == SINGLE_SELECTION) {
|
||||
super.setSelectionInterval(index0, index1);
|
||||
} else {
|
||||
super.addSelectionInterval(index0, index1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Disable toggling till the adjusting is over, or keep it
|
||||
// enabled in case setSelectionInterval was called directly.
|
||||
mGestureStarted = getValueIsAdjusting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueIsAdjusting(boolean isAdjusting) {
|
||||
super.setValueIsAdjusting(isAdjusting);
|
||||
|
||||
if (isAdjusting == false) {
|
||||
// Enable toggling
|
||||
mGestureStarted = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
txtRandomPacks = new JTextArea();
|
||||
txtRandomPacks.setEnabled(false);
|
||||
txtRandomPacks.setLineWrap(true);
|
||||
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, "");
|
||||
if (randomPrefs.length() > 0) {
|
||||
for (String exp : randomPrefs.split(";")) {
|
||||
randomList.setSelectedValue(exp, false);
|
||||
}
|
||||
txtRandomPacks.setText(randomPrefs);
|
||||
ArrayList<String> theList = new ArrayList<>();
|
||||
theList.addAll(Arrays.asList(randomPrefs.split(";")));
|
||||
randomPackSelector.setSelectedPacks(theList);
|
||||
} else {
|
||||
randomList.setSelectionInterval(0, randomListModel.size() - 1);
|
||||
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||
StringBuilder packList = new StringBuilder();
|
||||
for (ExpansionInfo exp : allExpansions) {
|
||||
packList.append(exp.getCode());
|
||||
packList.append(";");
|
||||
}
|
||||
JScrollPane list1scr = new JScrollPane(randomList);
|
||||
randomList.setVisibleRowCount(4);
|
||||
pnlRandomPacks.add(list1scr);
|
||||
txtRandomPacks.setText(packList.toString());
|
||||
}
|
||||
|
||||
pnlRandomPacks.add(txtRandomPacks);
|
||||
JButton btnSelectRandomPacks = new JButton();
|
||||
btnSelectRandomPacks.setText("Select packs to be included in the pool");
|
||||
btnSelectRandomPacks.setToolTipText(RandomPacksSelectorDialog.randomDraftDescription);
|
||||
btnSelectRandomPacks.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
showRandomPackSelectorDialog();
|
||||
|
||||
}
|
||||
});
|
||||
pnlRandomPacks.add(btnSelectRandomPacks);
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void showRandomPackSelectorDialog() {
|
||||
randomPackSelector.showDialog();
|
||||
StringBuilder packList = new StringBuilder();
|
||||
for (String str : randomPackSelector.getSelectedPacks()) {
|
||||
packList.append(str);
|
||||
packList.append(";");
|
||||
}
|
||||
this.txtRandomPacks.setText(packList.toString());
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
|
@ -1006,8 +991,8 @@ public class NewTournamentDialog extends MageDialog {
|
|||
if (tOptions.getLimitedOptions().getIsRandom()){
|
||||
// save random boosters to prefs
|
||||
StringBuilder packlist = new StringBuilder();
|
||||
for (Object pack: randomList.getSelectedValuesList()){
|
||||
packlist.append((String)pack);
|
||||
for (String pack : this.randomPackSelector.getSelectedPacks()){
|
||||
packlist.append(pack);
|
||||
packlist.append(";");
|
||||
}
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, packlist.toString());
|
||||
|
|
|
@ -155,7 +155,7 @@
|
|||
<Component class="javax.swing.JCheckBox" name="showToolTipsInAnyZone">
|
||||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Show card tooltips while hoovering with the mouse pointer over a card"/>
|
||||
<Property name="text" type="java.lang.String" value="Show card tooltips while hovering with the mouse pointer over a card"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
<Property name="actionCommand" type="java.lang.String" value=""/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
|
@ -253,7 +253,7 @@
|
|||
<Properties>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Show player names on avatar permanently"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Instead showing the names only if you hoover over the avatar with the mouse, the name is shown all the time."/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Instead showing the names only if you hover over the avatar with the mouse, the name is shown all the time."/>
|
||||
<Property name="horizontalAlignment" type="int" value="2"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
|
@ -1150,21 +1150,21 @@
|
|||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="590" max="32767" attributes="0"/>
|
||||
<Component id="avatarPane" alignment="0" pref="590" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="359" max="32767" attributes="0"/>
|
||||
<Component id="avatarPane" alignment="0" pref="359" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<Container class="javax.swing.JScrollPane" name="avatarPane">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel9">
|
||||
<Container class="javax.swing.JPanel" name="avatarPanel">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
|
@ -1256,6 +1256,14 @@
|
|||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel12">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="11" style="1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Choose your avatar:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="jPanel10">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
|
@ -1328,14 +1336,6 @@
|
|||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="jLabel12">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="11" style="1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Choose your avatar:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="jPanel12">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PreferencesDialog.java
|
||||
|
@ -63,10 +63,11 @@ import mage.client.MageFrame;
|
|||
import mage.client.util.Config;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
import mage.players.net.UserData;
|
||||
import mage.players.net.UserGroup;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.Connection.ProxyType;
|
||||
import mage.view.UserDataView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
@ -112,7 +113,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
public static final String KEY_BIG_CARD_TOGGLED = "bigCardToggled";
|
||||
|
||||
|
||||
// Phases
|
||||
public static final String UPKEEP_YOU = "upkeepYou";
|
||||
public static final String DRAW_YOU = "drawYou";
|
||||
|
@ -155,11 +155,20 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
// user list
|
||||
public static final String KEY_USERS_COLUMNS_WIDTH = "userPanelColumnWidth";
|
||||
public static final String KEY_USERS_COLUMNS_ORDER = "userPanelColumnSort";
|
||||
// table waiting dialog
|
||||
public static final String KEY_TABLE_WAITING_WIDTH = "tableWaitingPanelWidth";
|
||||
public static final String KEY_TABLE_WAITING_HEIGHT = "tableWaitingPanelHeight";
|
||||
public static final String KEY_TABLE_WAITING_COLUMNS_WIDTH = "tableWaitingPanelColumnWidth";
|
||||
public static final String KEY_TABLE_WAITING_COLUMNS_ORDER = "tableWaitingPanelColumnSort";
|
||||
|
||||
public static final String KEY_GAMEPANEL_DIVIDER_LOCATION_0 = "gamepanelDividerLocation0";
|
||||
public static final String KEY_GAMEPANEL_DIVIDER_LOCATION_1 = "gamepanelDividerLocation1";
|
||||
public static final String KEY_GAMEPANEL_DIVIDER_LOCATION_2 = "gamepanelDividerLocation2";
|
||||
|
||||
public static final String KEY_TOURNAMENT_PLAYER_COLUMNS_WIDTH = "tournamentPlayerPanelColumnWidth";
|
||||
public static final String KEY_TOURNAMENT_PLAYER_COLUMNS_ORDER = "tournamentPlayerPanelColumnSort";
|
||||
public static final String KEY_TOURNAMENT_MATCH_COLUMNS_WIDTH = "tournamentMatchPanelColumnWidth";
|
||||
public static final String KEY_TOURNAMENT_MATCH_COLUMNS_ORDER = "tournamentMatchPanelColumnSort";
|
||||
public static final String KEY_TOURNAMENT_DIVIDER_LOCATION_1 = "tournamentPanelDividerLocation1";
|
||||
public static final String KEY_TOURNAMENT_DIVIDER_LOCATION_2 = "tournamentPanelDividerLocation2";
|
||||
|
||||
|
@ -238,7 +247,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_CONNECT_AUTO_CONNECT = "autoConnect";
|
||||
public static final String KEY_CONNECT_FLAG = "connectFlag";
|
||||
|
||||
|
||||
private static final Map<String, String> cache = new HashMap<>();
|
||||
|
||||
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
|
||||
|
@ -280,22 +288,23 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
private final JFileChooser fc_i = new JFileChooser();
|
||||
|
||||
{
|
||||
fc_i.setAcceptAllFileFilterUsed(false);
|
||||
fc_i.addChoosableFileFilter(new ImageFileFilter());
|
||||
}
|
||||
|
||||
private static class ImageFileFilter extends FileFilter{
|
||||
private static class ImageFileFilter extends FileFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
String filename = f.getName();
|
||||
if(f.isDirectory()){
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
if(filename != null){
|
||||
if(filename.endsWith(".jpg") || filename.endsWith(".jpeg") ||
|
||||
filename.endsWith(".png") || filename.endsWith(".bmp")){
|
||||
if (filename != null) {
|
||||
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg")
|
||||
|| filename.endsWith(".png") || filename.endsWith(".bmp")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -308,8 +317,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form PreferencesDialog
|
||||
*
|
||||
|
@ -323,14 +330,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
cbProxyType.setModel(new DefaultComboBoxModel<>(Connection.ProxyType.values()));
|
||||
addAvatars();
|
||||
|
||||
cbPreferedImageLanguage.setModel(new DefaultComboBoxModel<>(new String[] {"en","de","fr","it","es","pt","jp","cn","ru","tw","ko"}));
|
||||
cbPreferedImageLanguage.setModel(new DefaultComboBoxModel<>(new String[]{"en", "de", "fr", "it", "es", "pt", "jp", "cn", "ru", "tw", "ko"}));
|
||||
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
|
@ -413,12 +420,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
txtBattlefieldIBGMPath = new javax.swing.JTextField();
|
||||
btnBattlefieldBGMBrowse = new javax.swing.JButton();
|
||||
tabAvatars = new javax.swing.JPanel();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jPanel9 = new javax.swing.JPanel();
|
||||
avatarPane = new javax.swing.JScrollPane();
|
||||
avatarPanel = new javax.swing.JPanel();
|
||||
jLabel12 = new javax.swing.JLabel();
|
||||
jPanel10 = new javax.swing.JPanel();
|
||||
jPanel13 = new javax.swing.JPanel();
|
||||
jPanel11 = new javax.swing.JPanel();
|
||||
jLabel12 = new javax.swing.JLabel();
|
||||
jPanel12 = new javax.swing.JPanel();
|
||||
jPanel14 = new javax.swing.JPanel();
|
||||
jPanel15 = new javax.swing.JPanel();
|
||||
|
@ -467,7 +474,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
});
|
||||
|
||||
showToolTipsInAnyZone.setSelected(true);
|
||||
showToolTipsInAnyZone.setText("Show card tooltips while hoovering with the mouse pointer over a card");
|
||||
showToolTipsInAnyZone.setText("Show card tooltips while hovering with the mouse pointer over a card");
|
||||
showToolTipsInAnyZone.setToolTipText("");
|
||||
showToolTipsInAnyZone.setActionCommand("");
|
||||
showToolTipsInAnyZone.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
|
@ -526,7 +533,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
showPlayerNamesPermanently.setSelected(true);
|
||||
showPlayerNamesPermanently.setText("Show player names on avatar permanently");
|
||||
showPlayerNamesPermanently.setToolTipText("Instead showing the names only if you hoover over the avatar with the mouse, the name is shown all the time.");
|
||||
showPlayerNamesPermanently.setToolTipText("Instead showing the names only if you hover over the avatar with the mouse, the name is shown all the time.");
|
||||
showPlayerNamesPermanently.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
|
||||
showPlayerNamesPermanently.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
@ -1183,6 +1190,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
tabsPanel.addTab("Sounds", tabSounds);
|
||||
|
||||
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
|
||||
jLabel12.setText("Choose your avatar:");
|
||||
|
||||
jPanel10.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
|
||||
|
||||
javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
|
||||
|
@ -1222,9 +1232,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.addGap(0, 100, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
|
||||
jLabel12.setText("Choose your avatar:");
|
||||
|
||||
jPanel12.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
|
||||
|
||||
javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
|
||||
|
@ -1345,68 +1352,68 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.addGap(0, 100, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
|
||||
jPanel9.setLayout(jPanel9Layout);
|
||||
jPanel9Layout.setHorizontalGroup(
|
||||
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
javax.swing.GroupLayout avatarPanelLayout = new javax.swing.GroupLayout(avatarPanel);
|
||||
avatarPanel.setLayout(avatarPanelLayout);
|
||||
avatarPanelLayout.setHorizontalGroup(
|
||||
avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel12))
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addGap(30, 30, 30)
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel19, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(33, 33, 33)
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addGap(20, 20, 20)
|
||||
.addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(33, 33, 33)
|
||||
.addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(jLabel13))))
|
||||
.addGap(32, 32, 32)
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel9Layout.setVerticalGroup(
|
||||
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
avatarPanelLayout.setVerticalGroup(
|
||||
avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel12)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(26, 26, 26)
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(23, 23, 23)
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(jPanel9Layout.createSequentialGroup()
|
||||
.addGroup(avatarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(avatarPanelLayout.createSequentialGroup()
|
||||
.addComponent(jLabel13)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
|
@ -1415,17 +1422,17 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
.addGap(25, 25, 25))
|
||||
);
|
||||
|
||||
jScrollPane1.setViewportView(jPanel9);
|
||||
avatarPane.setViewportView(avatarPanel);
|
||||
|
||||
javax.swing.GroupLayout tabAvatarsLayout = new javax.swing.GroupLayout(tabAvatars);
|
||||
tabAvatars.setLayout(tabAvatarsLayout);
|
||||
tabAvatarsLayout.setHorizontalGroup(
|
||||
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
|
||||
.addComponent(avatarPane, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
|
||||
);
|
||||
tabAvatarsLayout.setVerticalGroup(
|
||||
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
|
||||
.addComponent(avatarPane, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
tabsPanel.addTab("Avatars", tabAvatars);
|
||||
|
@ -1803,30 +1810,30 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}//GEN-LAST:event_cbEnableGameSoundsActionPerformed
|
||||
|
||||
private void cbEnableBattlefieldBGMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEnableBattlefieldBGMActionPerformed
|
||||
if(cbEnableBattlefieldBGM.isSelected()){
|
||||
if (cbEnableBattlefieldBGM.isSelected()) {
|
||||
txtBattlefieldIBGMPath.setEnabled(true);
|
||||
btnBattlefieldBGMBrowse.setEnabled(true);
|
||||
}else{
|
||||
} else {
|
||||
txtBattlefieldIBGMPath.setEnabled(false);
|
||||
btnBattlefieldBGMBrowse.setEnabled(false);
|
||||
}
|
||||
}//GEN-LAST:event_cbEnableBattlefieldBGMActionPerformed
|
||||
|
||||
private void cbUseDefaultBackgroundActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if(cbUseDefaultBackground.isSelected()){
|
||||
if (cbUseDefaultBackground.isSelected()) {
|
||||
useDefaultBackgroundImage();
|
||||
}else{
|
||||
} else {
|
||||
useSelectBackgroundImage();
|
||||
}
|
||||
}
|
||||
|
||||
private void useDefaultBackgroundImage(){
|
||||
private void useDefaultBackgroundImage() {
|
||||
txtBackgroundImagePath.setEnabled(false);
|
||||
btnBrowseBackgroundImage.setEnabled(false);
|
||||
txtBackgroundImagePath.setText("");
|
||||
}
|
||||
|
||||
private void useSelectBackgroundImage(){
|
||||
private void useSelectBackgroundImage() {
|
||||
String path = cache.get(KEY_BACKGROUND_IMAGE);
|
||||
dialog.txtBackgroundImagePath.setText(path);
|
||||
txtBackgroundImagePath.setEnabled(true);
|
||||
|
@ -1834,50 +1841,50 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
private void cbUseDefaultBattleImageActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if(cbUseDefaultBattleImage.isSelected()){
|
||||
if (cbUseDefaultBattleImage.isSelected()) {
|
||||
useDefaultBattlefield();
|
||||
}else{
|
||||
} else {
|
||||
useSelectedOrRandom();
|
||||
}
|
||||
}
|
||||
|
||||
private void useDefaultBattlefield(){
|
||||
private void useDefaultBattlefield() {
|
||||
cbUseRandomBattleImage.setEnabled(false);
|
||||
txtBattlefieldImagePath.setEnabled(false);
|
||||
btnBrowseBattlefieldImage.setEnabled(false);
|
||||
}
|
||||
|
||||
private void useSelectedOrRandom(){
|
||||
private void useSelectedOrRandom() {
|
||||
cbUseRandomBattleImage.setEnabled(true);
|
||||
String temp = cache.get(KEY_BATTLEFIELD_IMAGE_RANDOM);
|
||||
if(temp != null){
|
||||
if(temp.equals("true")){
|
||||
if (temp != null) {
|
||||
if (temp.equals("true")) {
|
||||
useRandomBattleField();
|
||||
cbUseRandomBattleImage.setSelected(true);
|
||||
}else{
|
||||
} else {
|
||||
useSelectedBattleField();
|
||||
cbUseRandomBattleImage.setSelected(false);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
useSelectedBattleField();
|
||||
cbUseRandomBattleImage.setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void cbUseRandomBattleImageActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if(cbUseRandomBattleImage.isSelected()){
|
||||
if (cbUseRandomBattleImage.isSelected()) {
|
||||
useRandomBattleField();
|
||||
}else{
|
||||
} else {
|
||||
useSelectedBattleField();
|
||||
}
|
||||
}
|
||||
|
||||
private void useRandomBattleField(){
|
||||
private void useRandomBattleField() {
|
||||
txtBattlefieldImagePath.setEnabled(false);
|
||||
btnBrowseBattlefieldImage.setEnabled(false);
|
||||
}
|
||||
|
||||
private void useSelectedBattleField(){
|
||||
private void useSelectedBattleField() {
|
||||
txtBattlefieldImagePath.setEnabled(true);
|
||||
btnBrowseBattlefieldImage.setEnabled(true);
|
||||
}
|
||||
|
@ -1995,12 +2002,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
|
||||
this.pnlProxy.setVisible(true);
|
||||
this.pnlProxySettings.setVisible(true);
|
||||
}
|
||||
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.HTTP) {
|
||||
} else if (cbProxyType.getSelectedItem() == Connection.ProxyType.HTTP) {
|
||||
this.pnlProxy.setVisible(true);
|
||||
this.pnlProxySettings.setVisible(true);
|
||||
}
|
||||
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.NONE) {
|
||||
} else if (cbProxyType.getSelectedItem() == Connection.ProxyType.NONE) {
|
||||
this.pnlProxy.setVisible(false);
|
||||
this.pnlProxySettings.setVisible(false);
|
||||
}
|
||||
|
@ -2059,7 +2064,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
private static void loadPhases(Preferences prefs) {
|
||||
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true","true");
|
||||
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true", "true");
|
||||
load(prefs, dialog.showToolTipsInAnyZone, KEY_SHOW_TOOLTIPS_ANY_ZONE, "true");
|
||||
load(prefs, dialog.showCardName, KEY_SHOW_CARD_NAMES, "true");
|
||||
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
|
||||
|
@ -2072,21 +2077,21 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true");
|
||||
|
||||
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU, "on","on");
|
||||
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU, "on","on");
|
||||
load(prefs, dialog.checkBoxMainYou, MAIN_YOU, "on","on");
|
||||
load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU, "on","on");
|
||||
load(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU, "on","on");
|
||||
load(prefs, dialog.checkBoxMain2You, MAIN_2_YOU, "on","on");
|
||||
load(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU, "on","on");
|
||||
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU, "on", "on");
|
||||
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU, "on", "on");
|
||||
load(prefs, dialog.checkBoxMainYou, MAIN_YOU, "on", "on");
|
||||
load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU, "on", "on");
|
||||
load(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU, "on", "on");
|
||||
load(prefs, dialog.checkBoxMain2You, MAIN_2_YOU, "on", "on");
|
||||
load(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU, "on", "on");
|
||||
|
||||
load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS, "on","on");
|
||||
load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS, "on","on");
|
||||
load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS, "on","on");
|
||||
load(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_OTHERS, "on","on");
|
||||
load(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS, "on","on");
|
||||
load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS, "on","on");
|
||||
load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS, "on","on");
|
||||
load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS, "on", "on");
|
||||
load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS, "on", "on");
|
||||
load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS, "on", "on");
|
||||
load(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_OTHERS, "on", "on");
|
||||
load(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS, "on", "on");
|
||||
load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS, "on", "on");
|
||||
load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS, "on", "on");
|
||||
|
||||
load(prefs, dialog.cbStopAttack, KEY_STOP_ATTACK, "true", "true");
|
||||
load(prefs, dialog.cbStopBlock, KEY_STOP_BLOCK, "true", "true");
|
||||
|
@ -2113,10 +2118,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
//add background load precedure
|
||||
prop = prefs.get(KEY_BACKGROUND_IMAGE_DEFAULT, "true");
|
||||
if(prop.equals("true")){
|
||||
if (prop.equals("true")) {
|
||||
dialog.cbUseDefaultBackground.setSelected(true);
|
||||
dialog.useDefaultBackgroundImage();
|
||||
}else{
|
||||
} else {
|
||||
dialog.cbUseDefaultBackground.setSelected(false);
|
||||
dialog.useSelectBackgroundImage();
|
||||
String path = prefs.get(KEY_BACKGROUND_IMAGE, "");
|
||||
|
@ -2124,20 +2129,20 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
updateCache(KEY_BACKGROUND_IMAGE, path);
|
||||
}
|
||||
prop = prefs.get(KEY_BATTLEFIELD_IMAGE_DEFAULT, "true");
|
||||
if(prop.equals("true")){
|
||||
if (prop.equals("true")) {
|
||||
dialog.cbUseDefaultBattleImage.setSelected(true);
|
||||
dialog.useDefaultBattlefield();
|
||||
}else{
|
||||
} else {
|
||||
dialog.cbUseDefaultBattleImage.setSelected(false);
|
||||
dialog.useSelectedOrRandom();
|
||||
}
|
||||
prop = prefs.get(KEY_BATTLEFIELD_IMAGE_RANDOM, "true");
|
||||
|
||||
if(dialog.cbUseRandomBattleImage.isEnabled()) {
|
||||
if(prop.equals("true")){
|
||||
if (dialog.cbUseRandomBattleImage.isEnabled()) {
|
||||
if (prop.equals("true")) {
|
||||
dialog.cbUseRandomBattleImage.setSelected(true);
|
||||
dialog.useRandomBattleField();
|
||||
}else{
|
||||
} else {
|
||||
dialog.cbUseRandomBattleImage.setSelected(false);
|
||||
dialog.useSelectedBattleField();
|
||||
String path = prefs.get(KEY_BATTLEFIELD_IMAGE, "");
|
||||
|
@ -2235,7 +2240,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static void saveImagesPath(Preferences prefs) {
|
||||
if (!dialog.cbUseDefaultImageFolder.isSelected()) {
|
||||
String path = dialog.txtImageFolderPath.getText();
|
||||
|
@ -2243,19 +2247,19 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
updateCache(KEY_CARD_IMAGES_PATH, path);
|
||||
}
|
||||
// background path save precedure
|
||||
if(!dialog.cbUseDefaultBackground.isSelected()){
|
||||
if (!dialog.cbUseDefaultBackground.isSelected()) {
|
||||
String path = dialog.txtBackgroundImagePath.getText();
|
||||
prefs.put(KEY_BACKGROUND_IMAGE, path);
|
||||
updateCache(KEY_BACKGROUND_IMAGE, path);
|
||||
}
|
||||
if(!dialog.cbUseDefaultBattleImage.isSelected() && !dialog.cbUseRandomBattleImage.isSelected()){
|
||||
if (!dialog.cbUseDefaultBattleImage.isSelected() && !dialog.cbUseRandomBattleImage.isSelected()) {
|
||||
String path = dialog.txtBattlefieldImagePath.getText();
|
||||
prefs.put(KEY_BATTLEFIELD_IMAGE, path);
|
||||
updateCache(KEY_BATTLEFIELD_IMAGE, path);
|
||||
}
|
||||
}
|
||||
|
||||
private static void saveSoundPath(Preferences prefs){
|
||||
private static void saveSoundPath(Preferences prefs) {
|
||||
String path = dialog.txtBattlefieldIBGMPath.getText();
|
||||
prefs.put(KEY_SOUNDS_MATCH_MUSIC_PATH, path);
|
||||
updateCache(KEY_SOUNDS_MATCH_MUSIC_PATH, path);
|
||||
|
@ -2294,13 +2298,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
public static void setPrefValue(String key, boolean value) {
|
||||
switch(key) {
|
||||
switch (key) {
|
||||
case KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS:
|
||||
dialog.cbAllowRequestToShowHandCards.setSelected(value);
|
||||
save(MageFrame.getPreferences(), dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void save(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String noValue, boolean updateCache) {
|
||||
prefs.put(propName, checkBox.isSelected() ? yesValue : noValue);
|
||||
if (updateCache) {
|
||||
|
@ -2416,19 +2421,23 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
}
|
||||
|
||||
public static UserDataView getUserData(){
|
||||
return new UserDataView(
|
||||
getSelectedAvatar(),
|
||||
public static UserData getUserData() {
|
||||
return new UserData(UserGroup.PLAYER,
|
||||
PreferencesDialog.selectedAvatarId,
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
|
||||
getUserSkipPrioritySteps(),
|
||||
MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ASK_MOVE_TO_GRAVE_ORDER, "true").equals("true")
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ASK_MOVE_TO_GRAVE_ORDER, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true")
|
||||
);
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane avatarPane;
|
||||
private javax.swing.JPanel avatarPanel;
|
||||
private javax.swing.JButton btnBattlefieldBGMBrowse;
|
||||
private javax.swing.JButton btnBrowseBackgroundImage;
|
||||
private javax.swing.JButton btnBrowseBattlefieldImage;
|
||||
|
@ -2501,8 +2510,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
private javax.swing.JPanel jPanel19;
|
||||
private javax.swing.JPanel jPanel20;
|
||||
private javax.swing.JPanel jPanel21;
|
||||
private javax.swing.JPanel jPanel9;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JLabel labelPreferedImageLanguage;
|
||||
private javax.swing.JLabel lblProxyPassword;
|
||||
private javax.swing.JLabel lblProxyPort;
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" value="Random Booster Draft Packs Selector"/>
|
||||
<Property name="modal" type="boolean" value="true"/>
|
||||
<Property name="modalExclusionType" type="java.awt.Dialog$ModalExclusionType" editor="org.netbeans.modules.form.editors.EnumEditor">
|
||||
<Value id="APPLICATION_EXCLUDE"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[600, 450]"/>
|
||||
</Property>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="pnlSelect" min="-2" pref="241" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="300" max="32767" attributes="0"/>
|
||||
<Component id="pnlApply" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="pnlPacks" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="pnlPacks" min="-2" pref="372" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="pnlApply" min="-2" pref="32" max="-2" attributes="0"/>
|
||||
<Component id="pnlSelect" min="-2" pref="32" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="java.awt.Panel" name="pnlPacks">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||
<Property name="columns" type="int" value="12"/>
|
||||
<Property name="rows" type="int" value="11"/>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlSelect">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="btnNone">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Select none"/>
|
||||
<Property name="actionCommand" type="java.lang.String" value="none"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNoneActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnAll">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Select all"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAllActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlApply">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="btnApply">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Apply"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="At least two packs must be selected"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnApplyActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JCheckBox;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BrodyL
|
||||
*/
|
||||
public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form RandomPacksSelectorDialog
|
||||
*/
|
||||
private boolean boxesCreated;
|
||||
public final static String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||
|
||||
public RandomPacksSelectorDialog() {
|
||||
initComponents();
|
||||
this.pnlApply.setToolTipText(randomDraftDescription);
|
||||
this.pnlSelect.setToolTipText(randomDraftDescription);
|
||||
boxesCreated = false;
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
createCheckboxes();
|
||||
pnlPacks.setVisible(true);
|
||||
pnlPacks.revalidate();
|
||||
pnlPacks.repaint();
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setVisible(true);
|
||||
this.setModal(true);
|
||||
}
|
||||
|
||||
public void setSelectedPacks(ArrayList<String> packs){
|
||||
if (!boxesCreated){
|
||||
createCheckboxes();
|
||||
}
|
||||
for (Component pack : pnlPacks.getComponents()) {
|
||||
JCheckBox thePack = (JCheckBox) pack;
|
||||
if (packs.contains(thePack.getText())) {
|
||||
thePack.setSelected(true);
|
||||
} else{
|
||||
thePack.setSelected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getSelectedPacks() {
|
||||
ArrayList<String> returnVal = new ArrayList<>();
|
||||
for (Component pack: pnlPacks.getComponents()){
|
||||
JCheckBox thePack = (JCheckBox) pack;
|
||||
if (thePack.isSelected()){
|
||||
returnVal.add(thePack.getText());
|
||||
}
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
private void createCheckboxes() {
|
||||
if (!boxesCreated) {
|
||||
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||
for (ExpansionInfo exp : allExpansions) {
|
||||
JCheckBox pack = new JCheckBox();
|
||||
pack.setSelected(true);
|
||||
pack.setText(exp.getCode());
|
||||
pack.setToolTipText(exp.getName());
|
||||
pnlPacks.add(pack);
|
||||
}
|
||||
pnlPacks.setVisible(true);
|
||||
this.pack();
|
||||
boxesCreated = true;
|
||||
pnlPacks.validate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
pnlPacks = new java.awt.Panel();
|
||||
pnlSelect = new javax.swing.JPanel();
|
||||
btnNone = new javax.swing.JButton();
|
||||
btnAll = new javax.swing.JButton();
|
||||
pnlApply = new javax.swing.JPanel();
|
||||
btnApply = new javax.swing.JButton();
|
||||
|
||||
setTitle("Random Booster Draft Packs Selector");
|
||||
setModal(true);
|
||||
setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
|
||||
setPreferredSize(new java.awt.Dimension(600, 450));
|
||||
setResizable(false);
|
||||
|
||||
pnlPacks.setLayout(new java.awt.GridLayout(11, 12));
|
||||
|
||||
pnlSelect.setLayout(new javax.swing.BoxLayout(pnlSelect, javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
btnNone.setText("Select none");
|
||||
btnNone.setActionCommand("none");
|
||||
btnNone.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnNoneActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
pnlSelect.add(btnNone);
|
||||
|
||||
btnAll.setText("Select all");
|
||||
btnAll.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnAllActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
pnlSelect.add(btnAll);
|
||||
|
||||
pnlApply.setLayout(new javax.swing.BoxLayout(pnlApply, javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
btnApply.setText("Apply");
|
||||
btnApply.setToolTipText("At least two packs must be selected");
|
||||
btnApply.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnApplyActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
pnlApply.add(btnApply);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 300, Short.MAX_VALUE)
|
||||
.addComponent(pnlApply, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(pnlPacks, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(pnlApply, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAllActionPerformed
|
||||
setAllCheckBoxes(true);
|
||||
}//GEN-LAST:event_btnAllActionPerformed
|
||||
|
||||
private void btnNoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoneActionPerformed
|
||||
setAllCheckBoxes(false);
|
||||
}//GEN-LAST:event_btnNoneActionPerformed
|
||||
|
||||
private void btnApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplyActionPerformed
|
||||
if (getSelectedPacks().size() < 2) {
|
||||
// at least 2 packs must be selected.
|
||||
} else {
|
||||
this.setVisible(false);
|
||||
}
|
||||
}//GEN-LAST:event_btnApplyActionPerformed
|
||||
|
||||
private void setAllCheckBoxes(boolean value) {
|
||||
for (Component pack : pnlPacks.getComponents()) {
|
||||
JCheckBox thePack = (JCheckBox) pack;
|
||||
thePack.setSelected(value);
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnAll;
|
||||
private javax.swing.JButton btnApply;
|
||||
private javax.swing.JButton btnNone;
|
||||
private javax.swing.JPanel pnlApply;
|
||||
private java.awt.Panel pnlPacks;
|
||||
private javax.swing.JPanel pnlSelect;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
|
@ -1,50 +1,54 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TableWaitingDialog.java
|
||||
*
|
||||
* Created on Dec 16, 2009, 10:27:44 AM
|
||||
*/
|
||||
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.chat.ChatPanel;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.components.tray.MageTray;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.gui.TableUtil;
|
||||
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
||||
import mage.remote.Session;
|
||||
import mage.view.SeatView;
|
||||
import mage.view.TableView;
|
||||
|
@ -64,8 +68,11 @@ public class TableWaitingDialog extends MageDialog {
|
|||
private Session session;
|
||||
private final TableWaitModel tableWaitModel;
|
||||
private UpdateSeatsTask updateTask;
|
||||
private static final int[] defaultColumnsWidth = {20, 50, 100, 100};
|
||||
|
||||
/** Creates new form TableWaitingDialog */
|
||||
/**
|
||||
* Creates new form TableWaitingDialog
|
||||
*/
|
||||
public TableWaitingDialog() {
|
||||
|
||||
session = MageFrame.getSession();
|
||||
|
@ -73,8 +80,17 @@ public class TableWaitingDialog extends MageDialog {
|
|||
|
||||
initComponents();
|
||||
|
||||
int prefWidth = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLE_WAITING_WIDTH, "500"));
|
||||
int prefHeight = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLE_WAITING_HEIGHT, "400"));
|
||||
if (prefWidth > 40 && prefHeight > 40) {
|
||||
this.setSize(prefWidth, prefHeight);
|
||||
}
|
||||
|
||||
chatPanel.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||
tableSeats.createDefaultColumnsFromModel();
|
||||
TableUtil.setColumnWidthAndOrder(tableSeats, defaultColumnsWidth, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER);
|
||||
tableSeats.setDefaultRenderer(Icon.class, new CountryCellRenderer());
|
||||
|
||||
MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
|
||||
}
|
||||
|
||||
|
@ -97,11 +113,14 @@ public class TableWaitingDialog extends MageDialog {
|
|||
return;
|
||||
}
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
if (getTitle().equals("Waiting for players")) {
|
||||
this.title = getTitle() + " - " + table.getDeckType() + " / " + table.getGameType();
|
||||
this.repaint();
|
||||
}
|
||||
tableWaitModel.loadData(table);
|
||||
this.tableSeats.repaint();
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row, row);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
closeDialog();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -131,8 +150,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
this.setModal(false);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
@ -144,14 +162,15 @@ public class TableWaitingDialog extends MageDialog {
|
|||
this.chatPanel.disconnect();
|
||||
MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON);
|
||||
this.removeDialog();
|
||||
TableUtil.saveColumnWidthAndOrderToPrefs(tableSeats, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER);
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLE_WAITING_WIDTH, Integer.toString(getWidth()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLE_WAITING_HEIGHT, Integer.toString(getHeight()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
|
@ -248,8 +267,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
if (session.startMatch(roomId, tableId)) {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (session.startTournament(roomId, tableId)) {
|
||||
closeDialog();
|
||||
}
|
||||
|
@ -285,7 +303,6 @@ public class TableWaitingDialog extends MageDialog {
|
|||
}
|
||||
}//GEN-LAST:event_btnMoveUpActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
private javax.swing.JButton btnMoveDown;
|
||||
|
@ -300,7 +317,8 @@ public class TableWaitingDialog extends MageDialog {
|
|||
}
|
||||
|
||||
class TableWaitModel extends AbstractTableModel {
|
||||
private final String[] columnNames = new String[]{"Seat Num", "Player Name", "Player Type"};
|
||||
|
||||
private final String[] columnNames = new String[]{"Seat", "Loc", "Player Name", "Player Type"};
|
||||
private SeatView[] seats = new SeatView[0];
|
||||
|
||||
public void loadData(TableView table) {
|
||||
|
@ -324,14 +342,15 @@ class TableWaitModel extends AbstractTableModel {
|
|||
if (arg1 == 0) {
|
||||
return Integer.toString(arg0 + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return Integer.toString(arg0 + 1);
|
||||
case 1:
|
||||
return seats[arg0].getPlayerName();
|
||||
return seats[arg0].getFlagName();
|
||||
case 2:
|
||||
return seats[arg0].getPlayerName();
|
||||
case 3:
|
||||
return seats[arg0].getPlayerType();
|
||||
}
|
||||
}
|
||||
|
@ -350,9 +369,14 @@ class TableWaitModel extends AbstractTableModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex){
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 1:
|
||||
return Icon.class;
|
||||
default:
|
||||
return String.class;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
|
@ -413,7 +437,7 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
|||
private int getPlayersCount(TableView tableView) {
|
||||
int playerCount = 0;
|
||||
if (tableView != null) {
|
||||
for (SeatView seatView: tableView.getSeats()) {
|
||||
for (SeatView seatView : tableView.getSeats()) {
|
||||
if (seatView.getPlayerId() != null && seatView.getPlayerType().equals("Human")) {
|
||||
playerCount++;
|
||||
}
|
||||
|
@ -422,7 +446,6 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
|||
return playerCount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
|
@ -431,7 +454,8 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
|||
logger.fatal("Update Seats Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Seats Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
} catch (CancellationException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +1,36 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FeedbackPanel.java
|
||||
*
|
||||
* Created on 23-Dec-2009, 9:54:01 PM
|
||||
*/
|
||||
|
||||
package mage.client.game;
|
||||
|
||||
import java.awt.Component;
|
||||
|
@ -48,6 +47,7 @@ import mage.client.components.MageTextArea;
|
|||
import mage.client.dialog.MageDialog;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.constants.Constants;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.remote.Session;
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -61,6 +61,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
private static final Logger logger = Logger.getLogger(FeedbackPanel.class);
|
||||
|
||||
public enum FeedbackMode {
|
||||
|
||||
INFORM, QUESTION, CONFIRM, CANCEL, SELECT, END
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,9 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
|
||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
/** Creates new form FeedbackPanel */
|
||||
/**
|
||||
* Creates new form FeedbackPanel
|
||||
*/
|
||||
public FeedbackPanel() {
|
||||
//initComponents();
|
||||
customInitComponents();
|
||||
|
@ -138,6 +141,12 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
endWithTimeout();
|
||||
break;
|
||||
}
|
||||
if (options != null && options.containsKey(Constants.Option.SPECIAL_BUTTON)) {
|
||||
String specialText = (String) options.get(Constants.Option.SPECIAL_BUTTON);
|
||||
this.btnSpecial.setVisible(true);
|
||||
this.btnSpecial.setText(specialText);
|
||||
this.helper.setSpecial(specialText, true);
|
||||
} else {
|
||||
this.btnSpecial.setVisible(special);
|
||||
this.btnSpecial.setText("Special");
|
||||
this.helper.setSpecial("Special", special);
|
||||
|
@ -147,6 +156,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
this.btnSpecial.setText("Pay 2 life");
|
||||
this.helper.setSpecial("Pay 2 life", true);
|
||||
}
|
||||
}
|
||||
|
||||
requestFocusIfPossible();
|
||||
handleOptions(options);
|
||||
|
@ -170,7 +180,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
while (c != null && !(c instanceof GamePane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null && ((GamePane)c).isVisible()) { // check if GamePanel still visible
|
||||
if (c != null && ((GamePane) c).isVisible()) { // check if GamePanel still visible
|
||||
FeedbackPanel.this.btnRight.doClick();
|
||||
}
|
||||
}
|
||||
|
@ -181,8 +191,8 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
private void handleOptions(Map<String, Serializable> options) {
|
||||
if (options != null) {
|
||||
if (options.containsKey("UI.right.btn.text")) {
|
||||
this.btnRight.setText((String)options.get("UI.right.btn.text"));
|
||||
this.helper.setRight((String)options.get("UI.right.btn.text"), true);
|
||||
this.btnRight.setText((String) options.get("UI.right.btn.text"));
|
||||
this.helper.setRight((String) options.get("UI.right.btn.text"), true);
|
||||
}
|
||||
if (options.containsKey("dialog")) {
|
||||
connectedDialog = (MageDialog) options.get("dialog");
|
||||
|
@ -224,7 +234,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
btnUndo = new javax.swing.JButton();
|
||||
btnUndo.setVisible(true);
|
||||
|
||||
setBackground(new java.awt.Color(0,0,0,80));
|
||||
setBackground(new java.awt.Color(0, 0, 0, 80));
|
||||
|
||||
btnRight.setText("Cancel");
|
||||
btnRight.addActionListener(new java.awt.event.ActionListener() {
|
||||
|
|
|
@ -1020,6 +1020,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
}
|
||||
Map<String, Serializable> panelOptions = new HashMap<>();
|
||||
if (options != null) {
|
||||
panelOptions.putAll(options);
|
||||
}
|
||||
panelOptions.put("your_turn", true);
|
||||
String activePlayerText;
|
||||
if (gameView.getActivePlayerId().equals(playerId)) {
|
||||
|
|
|
@ -1,40 +1,43 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.client.game;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.UIManager;
|
||||
import mage.client.components.MageTextArea;
|
||||
|
||||
/**
|
||||
|
@ -58,18 +61,25 @@ public class HelperPanel extends JPanel {
|
|||
private javax.swing.JButton linkSpecial;
|
||||
private javax.swing.JButton linkUndo;
|
||||
|
||||
private final int defaultDismissTimeout = ToolTipManager.sharedInstance().getDismissDelay();
|
||||
private final Object tooltipBackground = UIManager.get("info");
|
||||
|
||||
public HelperPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
|
||||
setBackground(new Color(0, 0, 0, 100));
|
||||
//setLayout(new GridBagLayout());
|
||||
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
|
||||
setOpaque(false);
|
||||
|
||||
JPanel container = new JPanel();
|
||||
|
||||
container.setPreferredSize(new Dimension(100, 30));
|
||||
container.setMinimumSize(new Dimension(20, 20));
|
||||
container.setMaximumSize(new Dimension(2000, 100));
|
||||
container.setLayout(new GridBagLayout());
|
||||
container.setOpaque(false);
|
||||
|
||||
|
@ -101,14 +111,15 @@ public class HelperPanel extends JPanel {
|
|||
btnLeft.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (linkLeft != null) {{
|
||||
Thread worker = new Thread(){
|
||||
if (linkLeft != null) {
|
||||
{
|
||||
Thread worker = new Thread() {
|
||||
@Override
|
||||
public void run(){
|
||||
SwingUtilities.invokeLater(new Runnable(){
|
||||
public void run() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
setState("",false,"",false);
|
||||
public void run() {
|
||||
setState("", false, "", false);
|
||||
setSpecial("", false);
|
||||
linkLeft.doClick();
|
||||
}
|
||||
|
@ -116,7 +127,8 @@ public class HelperPanel extends JPanel {
|
|||
}
|
||||
};
|
||||
worker.start();
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -124,13 +136,13 @@ public class HelperPanel extends JPanel {
|
|||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (linkRight != null) {
|
||||
Thread worker = new Thread(){
|
||||
Thread worker = new Thread() {
|
||||
@Override
|
||||
public void run(){
|
||||
SwingUtilities.invokeLater(new Runnable(){
|
||||
public void run() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
setState("",false,"",false);
|
||||
public void run() {
|
||||
setState("", false, "", false);
|
||||
setSpecial("", false);
|
||||
linkRight.doClick();
|
||||
}
|
||||
|
@ -145,14 +157,15 @@ public class HelperPanel extends JPanel {
|
|||
btnSpecial.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (linkSpecial != null) {{
|
||||
Thread worker = new Thread(){
|
||||
if (linkSpecial != null) {
|
||||
{
|
||||
Thread worker = new Thread() {
|
||||
@Override
|
||||
public void run(){
|
||||
SwingUtilities.invokeLater(new Runnable(){
|
||||
public void run() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
setState("",false,"",false);
|
||||
public void run() {
|
||||
setState("", false, "", false);
|
||||
setSpecial("", false);
|
||||
linkSpecial.doClick();
|
||||
}
|
||||
|
@ -160,27 +173,46 @@ public class HelperPanel extends JPanel {
|
|||
}
|
||||
};
|
||||
worker.start();
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnUndo.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (linkUndo != null) {{
|
||||
Thread worker = new Thread(){
|
||||
if (linkUndo != null) {
|
||||
{
|
||||
Thread worker = new Thread() {
|
||||
@Override
|
||||
public void run(){
|
||||
SwingUtilities.invokeLater(new Runnable(){
|
||||
public void run() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
public void run() {
|
||||
linkUndo.doClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// sets a darker background and higher simiss time fpr tooltip in the feedback / helper panel
|
||||
textArea.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent me) {
|
||||
ToolTipManager.sharedInstance().setDismissDelay(100000);
|
||||
UIManager.put("info", Color.DARK_GRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent me) {
|
||||
ToolTipManager.sharedInstance().setDismissDelay(defaultDismissTimeout);
|
||||
UIManager.put("info", tooltipBackground);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -220,17 +252,18 @@ public class HelperPanel extends JPanel {
|
|||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
if (message.startsWith("Use alternative cost")) {
|
||||
message = "Use alternative cost?";
|
||||
} else if (message.contains("Use ")) {
|
||||
if (message.length() < this.getWidth() / 10) {
|
||||
message = getSmallText(message);
|
||||
} else {
|
||||
message = "Use ability?" + getSmallText(message.substring(0, this.getWidth() / 10));
|
||||
}
|
||||
}
|
||||
textArea.setText(message);
|
||||
// if (message.startsWith("Use alternative cost")) {
|
||||
// message = "Use alternative cost?";
|
||||
// } else if (message.contains("Use ")) {
|
||||
// if (message.length() < this.getWidth() / 10) {
|
||||
// message = getSmallText(message);
|
||||
// } else {
|
||||
// message = "Use ability?" + getSmallText(message.substring(0, this.getWidth() / 10));
|
||||
// }
|
||||
// }
|
||||
textArea.setText(message, this.getWidth());
|
||||
}
|
||||
|
||||
protected String getSmallText(String text) {
|
||||
return "<div style='font-size:11pt'>" + text + "</div>";
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.client.game;
|
||||
|
||||
import java.awt.Color;
|
||||
|
@ -37,7 +37,6 @@ import java.awt.event.MouseEvent;
|
|||
import java.awt.event.MouseListener;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
|
@ -80,7 +79,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
public static final int PANEL_HEIGHT = 242;
|
||||
public static final int PANEL_HEIGHT_SMALL = 190;
|
||||
|
||||
/** Creates new form PlayAreaPanel
|
||||
/**
|
||||
* Creates new form PlayAreaPanel
|
||||
*
|
||||
* @param player
|
||||
* @param bigCard
|
||||
* @param gameId
|
||||
|
@ -97,7 +98,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
popupMenu = new JPopupMenu();
|
||||
if (options.isPlayer) {
|
||||
addPopupMenuPlayer(player.getUserData().allowRequestShowHandCards());
|
||||
addPopupMenuPlayer(player.getUserData().isAllowRequestShowHandCards());
|
||||
} else {
|
||||
addPopupMenuWatcher();
|
||||
}
|
||||
|
@ -110,14 +111,13 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
battlefieldPanel.cleanUp();
|
||||
playerPanel.cleanUp();
|
||||
|
||||
|
||||
for (ActionListener al : btnCheat.getActionListeners() ) {
|
||||
for (ActionListener al : btnCheat.getActionListeners()) {
|
||||
btnCheat.removeActionListener(al);
|
||||
}
|
||||
|
||||
// Taken form : https://community.oracle.com/thread/2183145
|
||||
// removed the internal focus of a popupMenu data to allow GC before another popup menu is selected
|
||||
for(ChangeListener listener : MenuSelectionManager.defaultManager().getChangeListeners()) {
|
||||
for (ChangeListener listener : MenuSelectionManager.defaultManager().getChangeListeners()) {
|
||||
if (listener.getClass().getName().contains("MenuKeyboardHelper")) {
|
||||
try {
|
||||
Field field = listener.getClass().getDeclaredField("menuInputMap");
|
||||
|
@ -130,7 +130,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
for (MouseListener ml :battlefieldPanel.getMainPanel().getMouseListeners()) {
|
||||
for (MouseListener ml : battlefieldPanel.getMainPanel().getMouseListeners()) {
|
||||
battlefieldPanel.getMainPanel().removeMouseListener(ml);
|
||||
}
|
||||
popupMenu.getUI().uninstallUI(this);
|
||||
|
@ -187,7 +187,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
popupMenu.add(menuItem);
|
||||
menuItem.addActionListener(skipListener);
|
||||
|
||||
|
||||
JMenu skipMenu = new JMenu("Skip");
|
||||
skipMenu.setMnemonic(KeyEvent.VK_S);
|
||||
popupMenu.add(skipMenu);
|
||||
|
@ -238,12 +237,13 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
manaPoolMenuItem1.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true": "false");
|
||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false");
|
||||
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState());
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
manaPoolMenuItem2 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true);
|
||||
manaPoolMenuItem2.setMnemonic(KeyEvent.VK_N);
|
||||
manaPoolMenuItem2.setToolTipText("<html>Mana that is already in the mana pool as you start casting a spell or activating an ability<br>"
|
||||
|
@ -255,10 +255,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
manaPoolMenuItem2.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true": "false");
|
||||
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false");
|
||||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted);
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON: PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON : PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -304,9 +304,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean requestsAllowed = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
boolean requestsAllowed = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||
PreferencesDialog.setPrefValue(KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, requestsAllowed);
|
||||
gamePanel.getSession().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON: PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
||||
gamePanel.getSession().sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON : PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -364,8 +364,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
JMenu concedeMenu = new JMenu("Concede");
|
||||
concedeMenu.setMnemonic(KeyEvent.VK_C);
|
||||
popupMenu.add(concedeMenu);
|
||||
|
@ -406,7 +404,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
concedeMenu.add(menuItem);
|
||||
menuItem.addActionListener(concedeListener);
|
||||
|
||||
|
||||
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent Me) {
|
||||
|
@ -419,7 +416,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
this.checkMenu(Me);
|
||||
}
|
||||
|
||||
private void checkMenu(MouseEvent Me){
|
||||
private void checkMenu(MouseEvent Me) {
|
||||
if (Me.isPopupTrigger() && playingMode) {
|
||||
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||
}
|
||||
|
@ -461,13 +458,14 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
public void mouseReleased(MouseEvent Me) {
|
||||
this.checkMenu(Me);
|
||||
}
|
||||
|
||||
// neccessary for linux and mac systems
|
||||
@Override
|
||||
public void mousePressed(MouseEvent Me) {
|
||||
this.checkMenu(Me);
|
||||
}
|
||||
|
||||
private void checkMenu(MouseEvent Me){
|
||||
private void checkMenu(MouseEvent Me) {
|
||||
if (Me.isPopupTrigger() && playingMode) {
|
||||
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||
}
|
||||
|
@ -483,8 +481,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
if (MageFrame.getSession().isTestMode()) {
|
||||
this.playerId = player.getPlayerId();
|
||||
this.btnCheat.setVisible(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.btnCheat.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +490,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
this.playerPanel.update(player);
|
||||
this.battlefieldPanel.update(player.getBattlefield());
|
||||
if (this.allowViewHandCardsMenuItem != null) {
|
||||
this.allowViewHandCardsMenuItem.setSelected(player.getUserData().allowRequestShowHandCards());
|
||||
this.allowViewHandCardsMenuItem.setSelected(player.getUserData().isAllowRequestShowHandCards());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,7 +503,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private void initComponents() {
|
||||
setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0)));
|
||||
setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0, 0)));
|
||||
playerPanel = new PlayerPanelExt();
|
||||
btnCheat = new javax.swing.JButton();
|
||||
//jScrollPane1 = new javax.swing.JScrollPane();
|
||||
|
@ -525,7 +522,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
//Border empty = new EmptyBorder(0,0,0,0);
|
||||
//jScrollPane1.setBorder(empty);
|
||||
//jScrollPane1.setViewportBorder(empty);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createSequentialGroup()
|
||||
|
@ -548,8 +544,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
this.playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT_SMALL));
|
||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 160));
|
||||
this.battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT_SMALL));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT));
|
||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 212));
|
||||
this.battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT));
|
||||
|
|
|
@ -36,6 +36,7 @@ package mage.client.game;
|
|||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -67,6 +68,7 @@ import mage.client.util.CardsViewUtil;
|
|||
import mage.client.util.Command;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
import mage.client.util.gui.countryBox.CountryUtil;
|
||||
import mage.components.ImagePanel;
|
||||
import mage.constants.ManaType;
|
||||
import mage.remote.Session;
|
||||
|
@ -103,6 +105,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
private static final Border emptyBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0);
|
||||
|
||||
private int avatarId = -1;
|
||||
private String flagName = "";
|
||||
|
||||
private PriorityTimer timer;
|
||||
|
||||
|
@ -234,6 +237,11 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
this.avatar.update("player", resized, resized, resized, resized, r);
|
||||
}
|
||||
if (!player.getUserData().getFlagName().equals(flagName)) {
|
||||
flagName = player.getUserData().getFlagName();
|
||||
this.avatarFlag.setIcon(CountryUtil.getCountryFlagIcon(flagName));
|
||||
avatar.repaint();
|
||||
}
|
||||
}
|
||||
this.avatar.setText(player.getName());
|
||||
if (this.timer != null) {
|
||||
|
@ -298,6 +306,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
panelBackground = new MageRoundPane();
|
||||
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT));
|
||||
Rectangle r = new Rectangle(80, 80);
|
||||
avatarFlag = new JLabel();
|
||||
timerLabel = new JLabel();
|
||||
lifeLabel = new JLabel();
|
||||
handLabel = new JLabel();
|
||||
|
@ -315,6 +324,14 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
avatar = new HoverButton("player", resized, resized, resized, r);
|
||||
avatar.setLayout(new GridLayout(4, 1, 0, 0));
|
||||
avatar.add(new JLabel());
|
||||
avatar.add(new JLabel());
|
||||
avatar.add(avatarFlag);
|
||||
avatar.setAlignTextLeft(true);
|
||||
avatarFlag.setHorizontalAlignment(JLabel.LEFT);
|
||||
avatarFlag.setVerticalAlignment(JLabel.BOTTOM);
|
||||
avatar.add(new JLabel());
|
||||
String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
|
||||
if (showPlayerNamePermanently.equals("true")) {
|
||||
avatar.setTextAlwaysVisible(true);
|
||||
|
@ -326,6 +343,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
session.sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
// timer area /small layout)
|
||||
timerLabel.setToolTipText("Time left");
|
||||
timerLabel.setSize(80, 12);
|
||||
|
@ -637,6 +655,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
||||
// .addGroup(gl_panelBackground.createSequentialGroup()
|
||||
// .addComponent(avatarFlag, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(14))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
|
@ -748,12 +768,14 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
protected void sizePlayerPanel(boolean smallMode) {
|
||||
if (smallMode) {
|
||||
avatar.setVisible(false);
|
||||
avatarFlag.setVisible(false);
|
||||
btnPlayer.setVisible(true);
|
||||
timerLabel.setVisible(true);
|
||||
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL));
|
||||
panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL);
|
||||
} else {
|
||||
avatar.setVisible(true);
|
||||
avatarFlag.setVisible(true);
|
||||
btnPlayer.setVisible(false);
|
||||
timerLabel.setVisible(false);
|
||||
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT));
|
||||
|
@ -791,6 +813,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private HoverButton avatar;
|
||||
private JLabel avatarFlag;
|
||||
private JButton btnPlayer;
|
||||
private ImagePanel life;
|
||||
private ImagePanel poison;
|
||||
|
|
|
@ -456,7 +456,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
}
|
||||
|
||||
/**
|
||||
* Show the big card image on mouse position while hoovering over a card
|
||||
* Show the big card image on mouse position while hovering over a card
|
||||
*
|
||||
* @param showAlternative defines if the original image (if it's a copied card) or the opposite side of a transformable card will be shown
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
*
|
||||
* Created on 20-Jan-2011, 9:18:30 PM
|
||||
*/
|
||||
|
||||
package mage.client.tournament;
|
||||
|
||||
import java.awt.Component;
|
||||
|
@ -45,14 +44,21 @@ import java.util.concurrent.CancellationException;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.chat.ChatPanel;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_MATCH_COLUMNS_ORDER;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_MATCH_COLUMNS_WIDTH;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_PLAYER_COLUMNS_ORDER;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_PLAYER_COLUMNS_WIDTH;
|
||||
import mage.client.util.ButtonColumn;
|
||||
import mage.client.util.Format;
|
||||
import mage.client.util.gui.TableUtil;
|
||||
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
||||
import mage.remote.Session;
|
||||
import mage.view.RoundView;
|
||||
import mage.view.TournamentGameView;
|
||||
|
@ -76,7 +82,12 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
private UpdateTournamentTask updateTask;
|
||||
private final DateFormat df;
|
||||
|
||||
/** Creates new form TournamentPanel */
|
||||
private static final int[] defaultColumnsWidthPlayers = {30, 150, 150, 60, 400};
|
||||
private static final int[] defaultColumnsWidthMatches = {60, 140, 140, 400, 80};
|
||||
|
||||
/**
|
||||
* Creates new form TournamentPanel
|
||||
*/
|
||||
public TournamentPanel() {
|
||||
playersModel = new TournamentPlayersTableModel();
|
||||
matchesModel = new TournamentMatchesTableModel();
|
||||
|
@ -88,23 +99,24 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
df = DateFormat.getDateTimeInstance();
|
||||
|
||||
tablePlayers.createDefaultColumnsFromModel();
|
||||
TableUtil.setColumnWidthAndOrder(tablePlayers, defaultColumnsWidthPlayers, KEY_TOURNAMENT_PLAYER_COLUMNS_WIDTH, KEY_TOURNAMENT_PLAYER_COLUMNS_ORDER);
|
||||
tablePlayers.setDefaultRenderer(Icon.class, new CountryCellRenderer());
|
||||
|
||||
tableMatches.createDefaultColumnsFromModel();
|
||||
TableUtil.setColumnWidthAndOrder(tableMatches, defaultColumnsWidthMatches, KEY_TOURNAMENT_MATCH_COLUMNS_WIDTH, KEY_TOURNAMENT_MATCH_COLUMNS_ORDER);
|
||||
|
||||
chatPanel1.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||
chatPanel1.setChatType(ChatPanel.ChatType.TOURNAMENT);
|
||||
|
||||
Action action = new AbstractAction()
|
||||
{
|
||||
Action action = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int modelRow = Integer.valueOf( e.getActionCommand() );
|
||||
|
||||
String state = (String)tableMatches.getValueAt(modelRow, 2);
|
||||
String actionText = (String)tableMatches.getValueAt(modelRow, TournamentMatchesTableModel.ACTION_COLUMN);
|
||||
UUID tableId = UUID.fromString((String)matchesModel.getValueAt(modelRow, TournamentMatchesTableModel.ACTION_COLUMN +1));
|
||||
UUID gameId = UUID.fromString((String)matchesModel.getValueAt(modelRow, TournamentMatchesTableModel.ACTION_COLUMN +3));
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int modelRow = Integer.valueOf(e.getActionCommand());
|
||||
|
||||
String state = (String) tableMatches.getValueAt(modelRow, tableMatches.convertColumnIndexToView(2));
|
||||
String actionText = (String) tableMatches.getValueAt(modelRow, tableMatches.convertColumnIndexToView(TournamentMatchesTableModel.ACTION_COLUMN));
|
||||
UUID tableId = UUID.fromString((String) matchesModel.getValueAt(modelRow, TournamentMatchesTableModel.ACTION_COLUMN + 1));
|
||||
UUID gameId = UUID.fromString((String) matchesModel.getValueAt(modelRow, TournamentMatchesTableModel.ACTION_COLUMN + 3));
|
||||
|
||||
// if (state.equals("Finished") && action.equals("Replay")) {
|
||||
// logger.info("Replaying game " + gameId);
|
||||
|
@ -118,7 +130,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
};
|
||||
|
||||
// action button, don't delete this
|
||||
ButtonColumn buttonColumn = new ButtonColumn(tableMatches, action, TournamentMatchesTableModel.ACTION_COLUMN);
|
||||
ButtonColumn buttonColumn = new ButtonColumn(tableMatches, action, tableMatches.convertColumnIndexToView(TournamentMatchesTableModel.ACTION_COLUMN));
|
||||
|
||||
}
|
||||
|
||||
|
@ -127,6 +139,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
if (this.chatPanel1 != null) {
|
||||
this.chatPanel1.disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void saveDividerLocations() {
|
||||
|
@ -167,8 +180,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
startTasks();
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
hideTournament();
|
||||
}
|
||||
|
||||
|
@ -182,12 +194,15 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
stopTasks();
|
||||
this.chatPanel1.disconnect();
|
||||
this.saveDividerLocations();
|
||||
TableUtil.saveColumnWidthAndOrderToPrefs(tablePlayers, KEY_TOURNAMENT_PLAYER_COLUMNS_WIDTH, KEY_TOURNAMENT_PLAYER_COLUMNS_ORDER);
|
||||
TableUtil.saveColumnWidthAndOrderToPrefs(tableMatches, KEY_TOURNAMENT_MATCH_COLUMNS_WIDTH, KEY_TOURNAMENT_MATCH_COLUMNS_ORDER);
|
||||
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof TournamentPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((TournamentPane)c).removeTournament();
|
||||
((TournamentPane) c).removeTournament();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +216,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((TournamentPane)c).setTitle("Tournament [" + tournament.getTournamentName() +"]");
|
||||
((TournamentPane) c).setTitle("Tournament [" + tournament.getTournamentName() + "]");
|
||||
}
|
||||
txtName.setText(tournament.getTournamentName());
|
||||
txtType.setText(tournament.getTournamentType());
|
||||
|
@ -215,7 +230,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
case "Constructing":
|
||||
String timeLeft = "";
|
||||
if (tournament.getStepStartTime() != null) {
|
||||
timeLeft = Format.getDuration(tournament.getConstructionTime() - (tournament.getServerTime().getTime() - tournament.getStepStartTime().getTime())/1000);
|
||||
timeLeft = Format.getDuration(tournament.getConstructionTime() - (tournament.getServerTime().getTime() - tournament.getStepStartTime().getTime()) / 1000);
|
||||
}
|
||||
txtTournamentState.setText(new StringBuilder(tournament.getTournamentState()).append(" (").append(timeLeft).append(")").toString());
|
||||
break;
|
||||
|
@ -223,7 +238,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
case "Drafting":
|
||||
String usedTime = "";
|
||||
if (tournament.getStepStartTime() != null) {
|
||||
usedTime = Format.getDuration((tournament.getServerTime().getTime() - tournament.getStepStartTime().getTime())/1000);
|
||||
usedTime = Format.getDuration((tournament.getServerTime().getTime() - tournament.getStepStartTime().getTime()) / 1000);
|
||||
}
|
||||
txtTournamentState.setText(tournament.getTournamentState() + " (" + usedTime + ") " + tournament.getRunningInfo());
|
||||
break;
|
||||
|
@ -274,10 +289,10 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
|
@ -505,7 +520,6 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_txtNameActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel actionPanel;
|
||||
private javax.swing.JButton btnCloseWindow;
|
||||
|
@ -532,7 +546,8 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
class TournamentPlayersTableModel extends AbstractTableModel {
|
||||
private final String[] columnNames = new String[]{"Player Name", "State", "Points", "Results"};
|
||||
|
||||
private final String[] columnNames = new String[]{"Loc", "Player Name", "State", "Points", "Results"};
|
||||
private TournamentPlayerView[] players = new TournamentPlayerView[0];
|
||||
|
||||
public void loadData(TournamentView tournament) {
|
||||
|
@ -554,12 +569,14 @@ class TournamentPlayersTableModel extends AbstractTableModel {
|
|||
public Object getValueAt(int arg0, int arg1) {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return players[arg0].getName();
|
||||
return players[arg0].getFlagName();
|
||||
case 1:
|
||||
return players[arg0].getState();
|
||||
return players[arg0].getName();
|
||||
case 2:
|
||||
return Integer.toString(players[arg0].getPoints());
|
||||
return players[arg0].getState();
|
||||
case 3:
|
||||
return Integer.toString(players[arg0].getPoints());
|
||||
case 4:
|
||||
return players[arg0].getResults();
|
||||
}
|
||||
return "";
|
||||
|
@ -577,9 +594,14 @@ class TournamentPlayersTableModel extends AbstractTableModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex){
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return Icon.class;
|
||||
default:
|
||||
return String.class;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
|
@ -599,8 +621,8 @@ class TournamentMatchesTableModel extends AbstractTableModel {
|
|||
public void loadData(TournamentView tournament) {
|
||||
List<TournamentGameView> views = new ArrayList<>();
|
||||
watchingAllowed = tournament.isWatchingAllowed();
|
||||
for (RoundView round: tournament.getRounds()) {
|
||||
for (TournamentGameView game: round.getGames()) {
|
||||
for (RoundView round : tournament.getRounds()) {
|
||||
for (TournamentGameView game : round.getGames()) {
|
||||
views.add(game);
|
||||
}
|
||||
}
|
||||
|
@ -660,7 +682,7 @@ class TournamentMatchesTableModel extends AbstractTableModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex){
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
|
@ -709,7 +731,8 @@ class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
|||
logger.fatal("Update Tournament Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Tournament Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
} catch (CancellationException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ package mage.client.util.gui;
|
|||
import javax.swing.JTable;
|
||||
import javax.swing.table.TableColumn;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import org.mage.card.arcane.Util;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -33,9 +32,13 @@ public class TableUtil {
|
|||
if (widths != null && widths.length > i) {
|
||||
width = widths[i];
|
||||
}
|
||||
if (table.getColumnModel().getColumnCount() >= i) {
|
||||
TableColumn column = table.getColumnModel().getColumn(i++);
|
||||
column.setWidth(width);
|
||||
column.setPreferredWidth(width);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set the column order
|
||||
|
@ -69,7 +72,6 @@ public class TableUtil {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public static int[] getIntArrayFromString(String stringData) {
|
||||
int[] intArray = null;
|
||||
if (stringData != null && !stringData.isEmpty()) {
|
||||
|
@ -79,7 +81,8 @@ public class TableUtil {
|
|||
for (int i = 0; i < lengthW; i++) {
|
||||
try {
|
||||
intArray[i] = Integer.parseInt(items[i]);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return intArray;
|
||||
|
|
|
@ -25,17 +25,12 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.client.util.gui.countryBox;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -43,38 +38,15 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class CountryCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CountryCellRenderer.class);
|
||||
private final Map<String, ImageIcon> flagIconCache = new HashMap<>();
|
||||
|
||||
private final Map<String, String> countryMap = new HashMap<>();
|
||||
|
||||
public CountryCellRenderer() {
|
||||
for( int i = 0; i <= CountryComboBox.countryList.length - 1; i++) {
|
||||
countryMap.put(CountryComboBox.countryList[i][1],CountryComboBox.countryList[i][0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
if(table.convertColumnIndexToView(0) == column) {
|
||||
label.setToolTipText(countryMap.get((String)value));
|
||||
label.setIcon(getCountryFlagIcon((String)value));
|
||||
label.setText("");
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
if (value == null || ((String) value).isEmpty()) {
|
||||
value = (String) "world";
|
||||
}
|
||||
label.setToolTipText(CountryUtil.getCountryName((String) value));
|
||||
label.setIcon(CountryUtil.getCountryFlagIcon((String) value));
|
||||
label.setText("");
|
||||
return label;
|
||||
}
|
||||
|
||||
private ImageIcon getCountryFlagIcon(String countryCode) {
|
||||
ImageIcon flagIcon = flagIconCache.get(countryCode);
|
||||
if (flagIcon == null) {
|
||||
flagIcon = new javax.swing.ImageIcon(getClass().getResource("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" :".png")));
|
||||
if (flagIcon.getImage() == null) {
|
||||
logger.warn("Country flag resource not found: " + countryCode);
|
||||
} else {
|
||||
flagIconCache.put(countryCode, flagIcon);
|
||||
}
|
||||
}
|
||||
return flagIcon;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.client.util.gui.countryBox;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.swing.ImageIcon;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CountryUtil {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CountryUtil.class);
|
||||
private static final Map<String, ImageIcon> flagIconCache = new HashMap<>();
|
||||
private static final Map<String, String> countryMap = new HashMap<>();
|
||||
|
||||
public static ImageIcon getCountryFlagIcon(String countryCode) {
|
||||
ImageIcon flagIcon = flagIconCache.get(countryCode);
|
||||
if (flagIcon == null) {
|
||||
URL url = CountryUtil.class.getResource("/flags/" + countryCode + (countryCode.endsWith(".png") ? "" : ".png"));
|
||||
if (url != null) {
|
||||
flagIcon = new javax.swing.ImageIcon(url);
|
||||
}
|
||||
if (flagIcon == null || flagIcon.getImage() == null) {
|
||||
logger.warn("Country flag resource not found: " + countryCode);
|
||||
flagIconCache.put(countryCode, flagIcon);
|
||||
} else {
|
||||
flagIconCache.put(countryCode, flagIcon);
|
||||
}
|
||||
}
|
||||
return flagIcon;
|
||||
}
|
||||
|
||||
public static String getCountryName(String countryCode) {
|
||||
if (countryMap.isEmpty()) {
|
||||
for (int i = 0; i <= CountryComboBox.countryList.length - 1; i++) {
|
||||
countryMap.put(CountryComboBox.countryList[i][1], CountryComboBox.countryList[i][0]);
|
||||
}
|
||||
}
|
||||
return countryMap.get(countryCode);
|
||||
}
|
||||
}
|
|
@ -242,7 +242,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
showCopySourceButton = new JButton("");
|
||||
showCopySourceButton.setLocation(2, 2);
|
||||
showCopySourceButton.setSize(25, 25);
|
||||
showCopySourceButton.setToolTipText("This permanent is copying a target. To see original image, push this button or turn mouse wheel down while hoovering with the mouse pointer over the permanent.");
|
||||
showCopySourceButton.setToolTipText("This permanent is copying a target. To see original image, push this button or turn mouse wheel down while hovering with the mouse pointer over the permanent.");
|
||||
copyIconPanel.setVisible(((PermanentView) this.gameCard).isCopy());
|
||||
|
||||
showCopySourceButton.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getCopyInformIconImage()));
|
||||
|
|
BIN
Mage.Client/src/main/resources/flags/computer.png
Normal file
BIN
Mage.Client/src/main/resources/flags/computer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-common</artifactId>
|
||||
|
|
|
@ -1,39 +1,38 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.constants;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public final class Constants {
|
||||
|
||||
private Constants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
@ -74,13 +73,16 @@ public final class Constants {
|
|||
public static final int PRIORITY_TIME_SEC = 1200;
|
||||
|
||||
public enum SessionState {
|
||||
|
||||
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_STARTING;
|
||||
}
|
||||
|
||||
public enum Option {
|
||||
|
||||
;
|
||||
|
||||
public static final String POSSIBLE_ATTACKERS = "possibleAttackers";
|
||||
public static final String SPECIAL_BUTTON = "specialButton";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -40,14 +39,14 @@ import mage.constants.PlayerAction;
|
|||
import mage.game.GameException;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.players.net.UserData;
|
||||
import mage.utils.MageVersion;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.RoomUsersView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserDataView;
|
||||
import mage.view.RoomUsersView;
|
||||
import mage.view.UserView;
|
||||
|
||||
/**
|
||||
|
@ -58,22 +57,28 @@ public interface MageServer {
|
|||
|
||||
// connection methods
|
||||
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
|
||||
|
||||
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||
// Not used
|
||||
// void deregisterClient(String sessionId) throws MageException;
|
||||
|
||||
// update methods
|
||||
List<ExpansionInfo> getMissingExpansionData(List<String> codes);
|
||||
|
||||
List<CardInfo> getMissingCardsData(List<String> classNames);
|
||||
|
||||
// user methods
|
||||
boolean setUserData(String userName, String sessionId, UserDataView userDataView) throws MageException;
|
||||
boolean setUserData(String userName, String sessionId, UserData userData) throws MageException;
|
||||
|
||||
void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
|
||||
|
||||
// server state methods
|
||||
ServerState getServerState() throws MageException;
|
||||
|
||||
List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException;
|
||||
|
||||
List<MatchView> getFinishedMatches(UUID roomId) throws MageException;
|
||||
|
||||
Object getServerMessagesCompressed(String sessionId) throws MageException; // messages of the day
|
||||
|
||||
// ping - extends session
|
||||
|
@ -81,27 +86,46 @@ public interface MageServer {
|
|||
|
||||
//table methods
|
||||
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
|
||||
|
||||
TableView createTournamentTable(String sessionId, UUID roomId, TournamentOptions tournamentOptions) throws MageException;
|
||||
|
||||
boolean joinTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
|
||||
|
||||
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
|
||||
|
||||
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||
|
||||
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||
|
||||
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
boolean watchTournamentTable(String sessionId, UUID tableId) throws MageException;
|
||||
|
||||
boolean leaveTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
void swapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
|
||||
|
||||
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
TableView getTable(UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
List<TableView> getTables(UUID roomId) throws MageException;
|
||||
|
||||
//chat methods
|
||||
void sendChatMessage(UUID chatId, String userName, String message) throws MageException;
|
||||
|
||||
void joinChat(UUID chatId, String sessionId, String userName) throws MageException;
|
||||
|
||||
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
||||
|
||||
UUID getTableChatId(UUID tableId) throws MageException;
|
||||
|
||||
UUID getGameChatId(UUID gameId) throws MageException;
|
||||
|
||||
UUID getRoomChatId(UUID roomId) throws MageException;
|
||||
|
||||
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
||||
|
||||
//room methods
|
||||
|
@ -109,50 +133,77 @@ public interface MageServer {
|
|||
|
||||
//game methods
|
||||
boolean startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
void joinGame(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void watchGame(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void stopWatching(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void sendPlayerUUID(UUID gameId, String sessionId, UUID data) throws MageException;
|
||||
|
||||
void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException;
|
||||
|
||||
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
|
||||
|
||||
void sendPlayerInteger(UUID gameId, String sessionId, Integer data) throws MageException;
|
||||
|
||||
void sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException;
|
||||
|
||||
void quitMatch(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
|
||||
|
||||
// priority, undo, concede, mana pool
|
||||
|
||||
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId, Object data) throws MageException;
|
||||
|
||||
//tournament methods
|
||||
boolean startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
||||
|
||||
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
|
||||
|
||||
TournamentView getTournament(UUID tournamentId) throws MageException;
|
||||
|
||||
//draft methods
|
||||
void joinDraft(UUID draftId, String sessionId) throws MageException;
|
||||
|
||||
void quitDraft(UUID draftId, String sessionId) throws MageException;
|
||||
|
||||
DraftPickView sendCardPick(UUID draftId, String sessionId, UUID cardId, Set<UUID> hiddenCards) throws MageException;
|
||||
|
||||
void sendCardMark(UUID draftId, String sessionId, UUID cardId) throws MageException;
|
||||
|
||||
//challenge methods
|
||||
// void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException;
|
||||
|
||||
//replay methods
|
||||
void replayGame(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void startReplay(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void stopReplay(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void nextPlay(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void previousPlay(UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
void skipForward(UUID gameId, String sessionId, int moves) throws MageException;
|
||||
|
||||
//test methods
|
||||
void cheat(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
|
||||
|
||||
boolean cheat(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
|
||||
|
||||
//admin methods
|
||||
List<UserView> getUsers(String sessionId) throws MageException;
|
||||
|
||||
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
||||
|
||||
void endUserSession(String sessionId, String userSessionId) throws MageException;
|
||||
|
||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||
|
||||
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.remote;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
|
@ -34,8 +33,7 @@ import java.net.InterfaceAddress;
|
|||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
import mage.view.UserDataView;
|
||||
import mage.players.net.UserData;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -55,7 +53,7 @@ public class Connection {
|
|||
private int clientCardDatabaseVersion;
|
||||
private boolean forceDBComparison;
|
||||
|
||||
private UserDataView userData;
|
||||
private UserData userData;
|
||||
|
||||
// private int avatarId;
|
||||
// private boolean showAbilityPickerForced;
|
||||
|
@ -63,7 +61,6 @@ public class Connection {
|
|||
// private boolean confirmEmptyManaPool;
|
||||
// private String flagName;
|
||||
// private UserSkipPrioritySteps userSkipPrioritySteps;
|
||||
|
||||
private static final String serialization = "?serializationtype=jboss";
|
||||
private static final String transport = "bisocket";
|
||||
|
||||
|
@ -84,7 +81,7 @@ public class Connection {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (! (object instanceof Connection)) {
|
||||
if (!(object instanceof Connection)) {
|
||||
return false;
|
||||
}
|
||||
Connection otherConnection = (Connection) object;
|
||||
|
@ -119,6 +116,7 @@ public class Connection {
|
|||
}
|
||||
|
||||
public enum ProxyType {
|
||||
|
||||
SOCKS("Socks"), HTTP("HTTP"), NONE("None");
|
||||
|
||||
private final String text;
|
||||
|
@ -207,12 +205,12 @@ public class Connection {
|
|||
}
|
||||
|
||||
public static InetAddress getLocalAddress() throws SocketException {
|
||||
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) {
|
||||
NetworkInterface iface = interfaces.nextElement( );
|
||||
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements();) {
|
||||
NetworkInterface iface = interfaces.nextElement();
|
||||
if (iface.isLoopback()) {
|
||||
continue;
|
||||
}
|
||||
for (InterfaceAddress addr: iface.getInterfaceAddresses()) {
|
||||
for (InterfaceAddress addr : iface.getInterfaceAddresses()) {
|
||||
if (addr != null) {
|
||||
InetAddress iaddr = addr.getAddress();
|
||||
if (iaddr != null && iaddr instanceof Inet4Address) {
|
||||
|
@ -224,11 +222,11 @@ public class Connection {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setUserData(UserDataView userData) {
|
||||
this.userData= userData;
|
||||
public void setUserData(UserData userData) {
|
||||
this.userData = userData;
|
||||
}
|
||||
|
||||
public UserDataView getUserData() {
|
||||
public UserData getUserData() {
|
||||
return userData;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.remote;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -61,8 +60,8 @@ import mage.interfaces.MageClient;
|
|||
import mage.interfaces.MageServer;
|
||||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.players.net.UserData;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameTypeView;
|
||||
import mage.view.MatchView;
|
||||
|
@ -70,7 +69,6 @@ import mage.view.RoomUsersView;
|
|||
import mage.view.TableView;
|
||||
import mage.view.TournamentTypeView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserDataView;
|
||||
import mage.view.UserView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.CannotConnectException;
|
||||
|
@ -223,24 +221,30 @@ public class SessionImpl implements Session {
|
|||
*/
|
||||
clientMetadata.put("numberOfCallRetries", "1");
|
||||
|
||||
|
||||
/**
|
||||
* I'll explain the meaning of "secondaryBindPort" and "secondaryConnectPort", and maybe that will help.
|
||||
* The Remoting bisocket transport creates two ServerSockets on the server. The "primary" ServerSocket is used to create
|
||||
* connections used for ordinary invocations, e.g., a request to create a JMS consumer, and the "secondary" ServerSocket
|
||||
* is used to create "control" connections for internal Remoting messages. The port for the primary ServerSocket is configured
|
||||
* by the "serverBindPort" parameter, and the port for the secondary ServerSocket is, by default, chosen randomly.
|
||||
* The "secondaryBindPort" parameter can be used to assign a specific port to the secondary ServerSocket. Now, if there is a
|
||||
* translating firewall between the client and server, the client should be given the value of the port that is translated
|
||||
* to the actual binding port of the secondary ServerSocket.
|
||||
* For example, your configuration will tell the secondary ServerSocket to bind to port 14000, and it will tell the client to
|
||||
* connect to port 14001. It assumes that there is a firewall which will translate 14001 to 14000. Apparently, that's not happening.
|
||||
* I'll explain the meaning of "secondaryBindPort" and
|
||||
* "secondaryConnectPort", and maybe that will help. The Remoting
|
||||
* bisocket transport creates two ServerSockets on the server. The
|
||||
* "primary" ServerSocket is used to create connections used for
|
||||
* ordinary invocations, e.g., a request to create a JMS consumer,
|
||||
* and the "secondary" ServerSocket is used to create "control"
|
||||
* connections for internal Remoting messages. The port for the
|
||||
* primary ServerSocket is configured by the "serverBindPort"
|
||||
* parameter, and the port for the secondary ServerSocket is, by
|
||||
* default, chosen randomly. The "secondaryBindPort" parameter can
|
||||
* be used to assign a specific port to the secondary ServerSocket.
|
||||
* Now, if there is a translating firewall between the client and
|
||||
* server, the client should be given the value of the port that is
|
||||
* translated to the actual binding port of the secondary
|
||||
* ServerSocket. For example, your configuration will tell the
|
||||
* secondary ServerSocket to bind to port 14000, and it will tell
|
||||
* the client to connect to port 14001. It assumes that there is a
|
||||
* firewall which will translate 14001 to 14000. Apparently, that's
|
||||
* not happening.
|
||||
*/
|
||||
// secondaryBindPort - the port to which the secondary server socket is to be bound. By default, an arbitrary port is selected.
|
||||
|
||||
// secondaryConnectPort - the port clients are to use to connect to the secondary server socket.
|
||||
// By default, the value of secondaryBindPort is used. secondaryConnectPort is useful if the server is behind a translating firewall.
|
||||
|
||||
// Indicated the max number of threads used within oneway thread pool.
|
||||
clientMetadata.put(Client.MAX_NUM_ONEWAY_THREADS, "10");
|
||||
clientMetadata.put(Remoting.USE_CLIENT_CONNECTION_IDENTITY, "true");
|
||||
|
@ -269,7 +273,7 @@ public class SessionImpl implements Session {
|
|||
logger.warn("There should be one callback Connector (number existing = " + callbackConnectors.size() + ")");
|
||||
}
|
||||
|
||||
logger.info("Trying to connect as " + (this.getUserName() == null ? "":this.getUserName()) + " to XMAGE server at " + connection.getHost() + ":" + connection.getPort());
|
||||
logger.info("Trying to connect as " + (this.getUserName() == null ? "" : this.getUserName()) + " to XMAGE server at " + connection.getHost() + ":" + connection.getPort());
|
||||
callbackClient.invoke(null);
|
||||
|
||||
this.sessionId = callbackClient.getSessionId();
|
||||
|
@ -289,8 +293,8 @@ public class SessionImpl implements Session {
|
|||
if (!connection.getUsername().equals("Admin")) {
|
||||
updateDatabase(connection.isForceDBComparison(), serverState);
|
||||
}
|
||||
logger.info("Connected as " + (this.getUserName() == null ? "":this.getUserName()) + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
|
||||
client.connected(this.getUserName() == null ? "":this.getUserName() +"@" + connection.getHost() + ":" + connection.getPort() +" ");
|
||||
logger.info("Connected as " + (this.getUserName() == null ? "" : this.getUserName()) + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
|
||||
client.connected(this.getUserName() == null ? "" : this.getUserName() + "@" + connection.getHost() + ":" + connection.getPort() + " ");
|
||||
return true;
|
||||
}
|
||||
disconnect(false);
|
||||
|
@ -311,14 +315,14 @@ public class SessionImpl implements Session {
|
|||
if (addMessage.isEmpty()) {
|
||||
logger.fatal("", ex);
|
||||
}
|
||||
client.showMessage("Unable to connect to server. " + addMessage + (ex.getMessage() != null ? ex.getMessage():""));
|
||||
client.showMessage("Unable to connect to server. " + addMessage + (ex.getMessage() != null ? ex.getMessage() : ""));
|
||||
} catch (IOException ex) {
|
||||
logger.fatal("", ex);
|
||||
String addMessage = "";
|
||||
if (ex.getMessage() != null && ex.getMessage().startsWith("Unable to perform invocation")) {
|
||||
addMessage = "Maybe the server version is not compatible. ";
|
||||
}
|
||||
client.showMessage("Unable to connect to server. " + addMessage + ex.getMessage() != null ? ex.getMessage():"");
|
||||
client.showMessage("Unable to connect to server. " + addMessage + ex.getMessage() != null ? ex.getMessage() : "");
|
||||
} catch (MageVersionException ex) {
|
||||
if (!canceled) {
|
||||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||
|
@ -334,7 +338,7 @@ public class SessionImpl implements Session {
|
|||
disconnect(false);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unable to connect to server.\n");
|
||||
for (StackTraceElement element :t.getStackTrace()) {
|
||||
for (StackTraceElement element : t.getStackTrace()) {
|
||||
sb.append(element.toString()).append("\n");
|
||||
}
|
||||
client.showMessage(sb.toString());
|
||||
|
@ -350,8 +354,8 @@ public class SessionImpl implements Session {
|
|||
List<CardInfo> cards = server.getMissingCardsData(classNames);
|
||||
CardRepository.instance.addCards(cards);
|
||||
CardRepository.instance.setContentVersion(serverState.getCardsContentVersion());
|
||||
logger.info("Updating client cards DB - existing cards: " + classNames.size() + " new cards: " + cards.size() +
|
||||
" content versions - server: " + serverState.getCardsContentVersion() + " client: " + cardDBVersion);
|
||||
logger.info("Updating client cards DB - existing cards: " + classNames.size() + " new cards: " + cards.size()
|
||||
+ " content versions - server: " + serverState.getCardsContentVersion() + " client: " + cardDBVersion);
|
||||
}
|
||||
|
||||
long expansionDBVersion = ExpansionRepository.instance.getContentVersionFromDB();
|
||||
|
@ -362,8 +366,8 @@ public class SessionImpl implements Session {
|
|||
ExpansionRepository.instance.add(expansion);
|
||||
}
|
||||
ExpansionRepository.instance.setContentVersion(serverState.getExpansionsContentVersion());
|
||||
logger.info("Updating client expansions DB - existing sets: " + setCodes.size() + " new sets: " + expansions.size()+
|
||||
" content versions - server: " + serverState.getExpansionsContentVersion() + " client: " + expansionDBVersion);
|
||||
logger.info("Updating client expansions DB - existing sets: " + setCodes.size() + " new sets: " + expansions.size()
|
||||
+ " content versions - server: " + serverState.getExpansionsContentVersion() + " client: " + expansionDBVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,7 +403,8 @@ public class SessionImpl implements Session {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param askForReconnect - true = connection was lost because of error and ask the user if he want to try to reconnect
|
||||
* @param askForReconnect - true = connection was lost because of error and
|
||||
* ask the user if he want to try to reconnect
|
||||
*/
|
||||
@Override
|
||||
public synchronized void disconnect(boolean askForReconnect) {
|
||||
|
@ -450,10 +455,11 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
class CallbackHandler implements InvokerCallbackHandler {
|
||||
|
||||
@Override
|
||||
public void handleCallback(Callback callback) throws HandleCallbackException {
|
||||
//logger.info("callback handler");
|
||||
client.processCallback((ClientCallback)callback.getCallbackObject());
|
||||
client.processCallback((ClientCallback) callback.getCallbackObject());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -502,7 +508,6 @@ public class SessionImpl implements Session {
|
|||
return serverState.getDraftCubes();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TournamentTypeView> getTournamentTypes() {
|
||||
return serverState.getTournamentTypes();
|
||||
|
@ -1020,6 +1025,7 @@ public class SessionImpl implements Session {
|
|||
|
||||
/**
|
||||
* Remove table - called from admin console
|
||||
*
|
||||
* @param tableId
|
||||
* @return
|
||||
*/
|
||||
|
@ -1107,7 +1113,6 @@ public class SessionImpl implements Session {
|
|||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
||||
try {
|
||||
|
@ -1384,14 +1389,13 @@ public class SessionImpl implements Session {
|
|||
client.showError(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUserName() {
|
||||
return connection.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePreferencesForServer(UserDataView userData) {
|
||||
public boolean updatePreferencesForServer(UserData userData) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.setUserData(connection.getUsername(), sessionId, userData);
|
||||
|
@ -1411,21 +1415,21 @@ public class SessionImpl implements Session {
|
|||
if (isConnected()) {
|
||||
long startTime = System.nanoTime();
|
||||
if (!server.ping(sessionId, pingInfo)) {
|
||||
logger.error("Ping failed: " + this.getUserName() + " Session: " + sessionId + " to MAGE server at " + connection.getHost() +":" + connection.getPort());
|
||||
logger.error("Ping failed: " + this.getUserName() + " Session: " + sessionId + " to MAGE server at " + connection.getHost() + ":" + connection.getPort());
|
||||
throw new MageException("Ping failed");
|
||||
}
|
||||
pingTime.add(System.nanoTime() - startTime);
|
||||
long milliSeconds = TimeUnit.MILLISECONDS.convert(pingTime.getLast(), TimeUnit.NANOSECONDS);
|
||||
String lastPing = milliSeconds > 0 ? milliSeconds+"ms" : "<1ms";
|
||||
String lastPing = milliSeconds > 0 ? milliSeconds + "ms" : "<1ms";
|
||||
if (pingTime.size() > PING_CYCLES) {
|
||||
pingTime.poll();
|
||||
}
|
||||
long sum = 0;
|
||||
for (Long time :pingTime) {
|
||||
for (Long time : pingTime) {
|
||||
sum += time;
|
||||
}
|
||||
milliSeconds = TimeUnit.MILLISECONDS.convert(sum / pingTime.size(), TimeUnit.NANOSECONDS);
|
||||
pingInfo = lastPing + " (Av: " + (milliSeconds > 0 ? milliSeconds + "ms":"<1ms")+")";
|
||||
pingInfo = lastPing + " (Av: " + (milliSeconds > 0 ? milliSeconds + "ms" : "<1ms") + ")";
|
||||
}
|
||||
return true;
|
||||
} catch (MageException ex) {
|
||||
|
@ -1448,7 +1452,6 @@ public class SessionImpl implements Session {
|
|||
|
||||
}
|
||||
|
||||
|
||||
class MageAuthenticator extends Authenticator {
|
||||
|
||||
private final String username;
|
||||
|
@ -1460,7 +1463,7 @@ class MageAuthenticator extends Authenticator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PasswordAuthentication getPasswordAuthentication () {
|
||||
return new PasswordAuthentication (username, password.toCharArray());
|
||||
public PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password.toCharArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.remote.interfaces;
|
||||
|
||||
import mage.view.UserDataView;
|
||||
import mage.players.net.UserData;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
|
@ -36,5 +36,5 @@ public interface ClientData {
|
|||
|
||||
String getUserName();
|
||||
|
||||
boolean updatePreferencesForServer(UserDataView userData);
|
||||
boolean updatePreferencesForServer(UserData userData);
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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;
|
||||
|
@ -41,8 +40,8 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
|
|||
*/
|
||||
public final static int MAGE_VERSION_MAJOR = 1;
|
||||
public final static int MAGE_VERSION_MINOR = 4;
|
||||
public final static int MAGE_VERSION_PATCH = 1;
|
||||
public final static String MAGE_VERSION_MINOR_PATCH = "v3";
|
||||
public final static int MAGE_VERSION_PATCH = 2;
|
||||
public final static String MAGE_VERSION_MINOR_PATCH = "v0";
|
||||
public final static String MAGE_VERSION_INFO = "";
|
||||
|
||||
private final int major;
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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;
|
||||
|
@ -44,12 +43,14 @@ import mage.game.command.Commander;
|
|||
import mage.game.command.Emblem;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.players.net.UserData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class PlayerView implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final UUID playerId;
|
||||
|
@ -67,7 +68,7 @@ public class PlayerView implements Serializable {
|
|||
private final CardsView exile = new CardsView();
|
||||
private final Map<UUID, PermanentView> battlefield = new LinkedHashMap<>();
|
||||
private final CardView topCard;
|
||||
private final UserDataView userDataView;
|
||||
private final UserData userData;
|
||||
private final List<CommandObjectView> commandList = new ArrayList<>();
|
||||
private final List<UUID> attachments = new ArrayList<>();
|
||||
private final int statesSavedSize;
|
||||
|
@ -89,12 +90,12 @@ public class PlayerView implements Serializable {
|
|||
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
||||
this.hasPriority = player.getId().equals(state.getPriorityPlayerId());
|
||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||
this.timerActive = (this.hasPriority && player.isGameUnderControl()) ||
|
||||
(player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId())) ||
|
||||
player.getId().equals(game.getState().getChoosingPlayerId());
|
||||
this.timerActive = (this.hasPriority && player.isGameUnderControl())
|
||||
|| (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId()))
|
||||
|| player.getId().equals(game.getState().getChoosingPlayerId());
|
||||
|
||||
this.hasLeft = player.hasLeft();
|
||||
for (Card card: player.getGraveyard().getCards(game)) {
|
||||
for (Card card : player.getGraveyard().getCards(game)) {
|
||||
graveyard.put(card.getId(), new CardView(card, game, false));
|
||||
}
|
||||
for (ExileZone exileZone : game.getExile().getExileZones()) {
|
||||
|
@ -104,35 +105,34 @@ public class PlayerView implements Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent: state.getBattlefield().getAllPermanents()) {
|
||||
for (Permanent permanent : state.getBattlefield().getAllPermanents()) {
|
||||
if (showInBattlefield(permanent, state)) {
|
||||
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()), createdForPlayerId, game);
|
||||
battlefield.put(view.getId(), view);
|
||||
}
|
||||
}
|
||||
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0 ?
|
||||
new CardView(player.getLibrary().getFromTop(game)) : null;
|
||||
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0
|
||||
? new CardView(player.getLibrary().getFromTop(game)) : null;
|
||||
if (player.getUserData() != null) {
|
||||
this.userDataView = new UserDataView(player.getUserData());
|
||||
this.userData = player.getUserData();
|
||||
} else {
|
||||
this.userDataView = UserDataView.getDefaultUserDataView();
|
||||
this.userData = UserData.getDefaultUserDataView();
|
||||
}
|
||||
|
||||
for (CommandObject commandObject : game.getState().getCommand()) {
|
||||
if (commandObject instanceof Emblem) {
|
||||
Emblem emblem = (Emblem) commandObject;
|
||||
if (emblem.getControllerId().equals(this.playerId)) {
|
||||
Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId());
|
||||
Card sourceCard = game.getCard(((CommandObject) emblem).getSourceId());
|
||||
if (sourceCard != null) {
|
||||
commandList.add(new EmblemView(emblem, sourceCard));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(commandObject instanceof Commander){
|
||||
Commander commander = (Commander)commandObject;
|
||||
if(commander.getControllerId().equals(this.playerId)){
|
||||
} else if (commandObject instanceof Commander) {
|
||||
Commander commander = (Commander) commandObject;
|
||||
if (commander.getControllerId().equals(this.playerId)) {
|
||||
Card sourceCard = game.getCard(commander.getSourceId());
|
||||
if(sourceCard != null){
|
||||
if (sourceCard != null) {
|
||||
commandList.add(new CommanderView(commander, sourceCard, game));
|
||||
}
|
||||
}
|
||||
|
@ -157,13 +157,11 @@ public class PlayerView implements Serializable {
|
|||
//show permanents controlled by player or attachments to permanents controlled by player
|
||||
if (permanent.getAttachedTo() == null) {
|
||||
return permanent.getControllerId().equals(playerId);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Permanent attachedTo = state.getPermanent(permanent.getAttachedTo());
|
||||
if (attachedTo != null) {
|
||||
return attachedTo.getControllerId().equals(playerId);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return permanent.getControllerId().equals(playerId);
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +219,8 @@ public class PlayerView implements Serializable {
|
|||
return this.topCard;
|
||||
}
|
||||
|
||||
public UserDataView getUserData() {
|
||||
return this.userDataView;
|
||||
public UserData getUserData() {
|
||||
return this.userData;
|
||||
}
|
||||
|
||||
public List<CommandObjectView> getCommadObjectList() {
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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;
|
||||
|
@ -37,16 +36,23 @@ import mage.game.Seat;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SeatView implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String flagName;
|
||||
private UUID playerId;
|
||||
private String playerName;
|
||||
private String playerType;
|
||||
private final String playerName;
|
||||
private final String playerType;
|
||||
|
||||
public SeatView(Seat seat) {
|
||||
if (seat.getPlayer() != null) {
|
||||
this.playerId = seat.getPlayer().getId();
|
||||
this.playerName = seat.getPlayer().getName();
|
||||
this.flagName = seat.getPlayer().getUserData().getFlagName();
|
||||
} else {
|
||||
// Empty seat
|
||||
this.playerName = "";
|
||||
this.flagName = "";
|
||||
}
|
||||
this.playerType = seat.getPlayerType();
|
||||
}
|
||||
|
@ -63,4 +69,8 @@ public class SeatView implements Serializable {
|
|||
return playerType;
|
||||
}
|
||||
|
||||
public String getFlagName() {
|
||||
return flagName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* 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;
|
||||
|
@ -35,9 +34,11 @@ import mage.game.tournament.TournamentPlayer;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TournamentPlayerView implements Serializable, Comparable{
|
||||
public class TournamentPlayerView implements Serializable, Comparable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String flagName;
|
||||
private final String name;
|
||||
private final String state;
|
||||
private final String results;
|
||||
|
@ -56,6 +57,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
|
|||
this.points = tournamentPlayer.getPoints();
|
||||
this.results = tournamentPlayer.getResults();
|
||||
this.quit = !tournamentPlayer.isInTournament();
|
||||
this.flagName = tournamentPlayer.getPlayer().getUserData().getFlagName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -83,4 +85,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
|
|||
return ((TournamentPlayerView) t).getPoints() - this.getPoints();
|
||||
}
|
||||
|
||||
public String getFlagName() {
|
||||
return flagName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ public class UserDataView implements Serializable {
|
|||
String flagName;
|
||||
protected boolean askMoveToGraveOrder;
|
||||
|
||||
static UserDataView getDefaultUserDataView() {
|
||||
return new UserDataView(0, false, false, true, null,"world.png", false);
|
||||
static UserData getDefaultUserDataView() {
|
||||
return UserData.getDefaultUserDataView();
|
||||
}
|
||||
|
||||
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-counter-plugin</artifactId>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-theme-plugin</artifactId>
|
||||
|
@ -29,7 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-client</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.mage</groupId>
|
||||
|
@ -31,4 +31,51 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${manifest.file}</manifestFile>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>mage.server.console.ConsoleFrame</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/distribution.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<finalName>mage-console</finalName>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<manifest.file>src/main/resources/META-INF/MANIFEST.MF</manifest.file>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-deck-constructed</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-deck-limited</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-game-commanderduel</artifactId>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-game-commanderfreeforall</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-game-freeforall</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-game-tinyleadersduel</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-game-twoplayerduel</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-player-ai-draftbot</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-player-ai-ma</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-player-ai</artifactId>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-player-ai-mcts</artifactId>
|
||||
|
|
|
@ -27,13 +27,24 @@
|
|||
*/
|
||||
package mage.player.ai;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.PassAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -44,9 +55,6 @@ import mage.target.TargetAmount;
|
|||
import mage.target.TargetCard;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* plays randomly
|
||||
|
@ -89,8 +97,9 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
boolean didSomething = false;
|
||||
Ability ability = getAction(game);
|
||||
// logger.info("simulate " + ability.toString());
|
||||
if (!(ability instanceof PassAbility))
|
||||
if (!(ability instanceof PassAbility)) {
|
||||
didSomething = true;
|
||||
}
|
||||
|
||||
activateAbility((ActivatedAbility) ability, game);
|
||||
|
||||
|
@ -102,17 +111,19 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
List<Ability> playables = getPlayableAbilities(game);
|
||||
Ability ability;
|
||||
while (true) {
|
||||
if (playables.size() == 1)
|
||||
if (playables.size() == 1) {
|
||||
ability = playables.get(0);
|
||||
else
|
||||
} else {
|
||||
ability = playables.get(rnd.nextInt(playables.size()));
|
||||
}
|
||||
List<Ability> options = getPlayableOptions(ability, game);
|
||||
if (!options.isEmpty()) {
|
||||
if (options.size() == 1)
|
||||
if (options.size() == 1) {
|
||||
ability = options.get(0);
|
||||
else
|
||||
} else {
|
||||
ability = options.get(rnd.nextInt(options.size()));
|
||||
}
|
||||
}
|
||||
if (ability.getManaCosts().getVariableCosts().size() > 0) {
|
||||
int amount = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost();
|
||||
if (amount > 0) {
|
||||
|
@ -147,13 +158,13 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
List<Ability> options = getPlayableOptions(source, game);
|
||||
if (options.isEmpty()) {
|
||||
ability = source;
|
||||
}
|
||||
else {
|
||||
if (options.size() == 1)
|
||||
} else {
|
||||
if (options.size() == 1) {
|
||||
ability = options.get(0);
|
||||
else
|
||||
} else {
|
||||
ability = options.get(rnd.nextInt(options.size()));
|
||||
}
|
||||
}
|
||||
if (ability.isUsesStack()) {
|
||||
game.getStack().push(new StackAbility(ability, playerId));
|
||||
if (ability.activate(game, false)) {
|
||||
|
@ -205,7 +216,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
}
|
||||
|
||||
List<Permanent> blockers = getAvailableBlockers(game);
|
||||
for (Permanent blocker: blockers) {
|
||||
for (Permanent blocker : blockers) {
|
||||
int check = rnd.nextInt(numGroups + 1);
|
||||
if (check < numGroups) {
|
||||
CombatGroup group = game.getCombat().getGroups().get(check);
|
||||
|
@ -242,9 +253,10 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
}
|
||||
|
||||
protected boolean chooseRandomTarget(Target target, Ability source, Game game) {
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
|
||||
if (possibleTargets.isEmpty())
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game);
|
||||
if (possibleTargets.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (!target.isRequired(source)) {
|
||||
if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
|
||||
return false;
|
||||
|
@ -266,8 +278,9 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
|
||||
if (this.isHuman())
|
||||
if (this.isHuman()) {
|
||||
return chooseRandom(target, game);
|
||||
}
|
||||
return super.choose(outcome, target, sourceId, game);
|
||||
}
|
||||
|
||||
|
@ -318,7 +331,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
|
||||
@Override
|
||||
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game);
|
||||
if (possibleTargets.isEmpty()) {
|
||||
return !target.isRequired(source);
|
||||
}
|
||||
|
@ -347,11 +360,11 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseUse(Outcome outcome, String message, Game game) {
|
||||
public boolean chooseUse(Outcome outcome, String message, Ability source, Game game) {
|
||||
if (this.isHuman()) {
|
||||
return rnd.nextBoolean();
|
||||
}
|
||||
return super.chooseUse(outcome, message, game);
|
||||
return super.chooseUse(outcome, message, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -396,12 +409,12 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
@Override
|
||||
public Mode chooseMode(Modes modes, Ability source, Game game) {
|
||||
if (this.isHuman()) {
|
||||
Iterator<Mode> it = modes.values().iterator();
|
||||
Iterator<Mode> it = modes.getAvailableModes(source, game).iterator();
|
||||
Mode mode = it.next();
|
||||
if (modes.size() == 1) {
|
||||
return mode;
|
||||
}
|
||||
int modeNum = rnd.nextInt(modes.values().size());
|
||||
int modeNum = rnd.nextInt(modes.getAvailableModes(source, game).size());
|
||||
for (int i = 0; i < modeNum; i++) {
|
||||
mode = it.next();
|
||||
}
|
||||
|
@ -436,8 +449,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
if (targets.size() == 1) {
|
||||
targetId = targets.get(0);
|
||||
amount = remainingDamage;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
targetId = targets.get(rnd.nextInt(targets.size()));
|
||||
amount = rnd.nextInt(damage + 1);
|
||||
}
|
||||
|
@ -445,8 +457,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
if (permanent != null) {
|
||||
permanent.damage(amount, sourceId, game, false, true);
|
||||
remainingDamage -= amount;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Player player = game.getPlayer(targetId);
|
||||
if (player != null) {
|
||||
player.damage(amount, sourceId, game, false, true);
|
||||
|
@ -455,8 +466,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
}
|
||||
targets.remove(targetId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.assignDamage(damage, targets, singleTargetName, sourceId, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-player-aiminimax</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-player-human</artifactId>
|
||||
|
|
|
@ -1,35 +1,50 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.player.human;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.PlayLandAbility;
|
||||
import mage.abilities.SpecialAction;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
|
@ -42,7 +57,14 @@ import mage.cards.Cards;
|
|||
import mage.cards.decks.Deck;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.*;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Constants;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterAttackingCreature;
|
||||
import mage.filter.common.FilterBlockingCreature;
|
||||
import mage.filter.common.FilterCreatureForCombat;
|
||||
|
@ -51,6 +73,7 @@ import mage.filter.predicate.permanent.ControllerIdPredicate;
|
|||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.tournament.Tournament;
|
||||
|
@ -63,13 +86,10 @@ import mage.target.TargetPermanent;
|
|||
import mage.target.common.TargetAttackingCreature;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.target.common.TargetDefender;
|
||||
import mage.util.GameLog;
|
||||
import mage.util.ManaUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import mage.util.GameLog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -85,6 +105,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
protected static final Choice replacementEffectChoice = new ChoiceImpl(true);
|
||||
|
||||
private static final Logger log = Logger.getLogger(HumanPlayer.class);
|
||||
|
||||
static {
|
||||
replacementEffectChoice.setMessage("Choose replacement effect to resolve first");
|
||||
}
|
||||
|
@ -104,7 +125,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
response.clear();
|
||||
log.debug("Waiting response from player: " + getId());
|
||||
game.resumeTimer(getTurnControlledBy());
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
try {
|
||||
response.wait();
|
||||
log.debug("Got response from player: " + getId());
|
||||
|
@ -145,9 +166,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
updateGameStatePriority("chooseMulligan", game);
|
||||
int nextHandSize = game.mulliganDownTo(playerId);
|
||||
game.fireAskPlayerEvent(playerId, new StringBuilder("Mulligan ")
|
||||
.append(getHand().size() > nextHandSize?"down to ":"for free, draw ")
|
||||
.append(getHand().size() > nextHandSize ? "down to " : "for free, draw ")
|
||||
.append(nextHandSize)
|
||||
.append(nextHandSize == 1?" card?":" cards?").toString());
|
||||
.append(nextHandSize == 1 ? " card?" : " cards?").toString());
|
||||
waitForBooleanResponse(game);
|
||||
if (!abort) {
|
||||
return response.getBoolean();
|
||||
|
@ -156,9 +177,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseUse(Outcome outcome, String message, Game game) {
|
||||
public boolean chooseUse(Outcome outcome, String message, Ability source, Game game) {
|
||||
updateGameStatePriority("chooseUse", game);
|
||||
game.fireAskPlayerEvent(playerId, message);
|
||||
game.fireAskPlayerEvent(playerId, addSecondLineWithObjectName(message, source == null ? null : source.getSourceId(), game));
|
||||
waitForBooleanResponse(game);
|
||||
if (!abort) {
|
||||
return response.getBoolean();
|
||||
|
@ -166,6 +187,19 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
private String addSecondLineWithObjectName(String message, UUID sourceId, Game game) {
|
||||
if (sourceId != null) {
|
||||
MageObject mageObject = game.getPermanent(sourceId);
|
||||
if (mageObject == null) {
|
||||
mageObject = game.getCard(sourceId);
|
||||
}
|
||||
if (mageObject != null) {
|
||||
message += "<div style='font-size:11pt'>" + mageObject.getLogName() + "</div>";
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chooseReplacementEffect(Map<String, String> rEffects, Game game) {
|
||||
updateGameStatePriority("chooseEffect", game);
|
||||
|
@ -173,7 +207,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return 0;
|
||||
}
|
||||
if (!autoSelectReplacementEffects.isEmpty()) {
|
||||
for (String autoKey :autoSelectReplacementEffects) {
|
||||
for (String autoKey : autoSelectReplacementEffects) {
|
||||
int count = 0;
|
||||
for (String effectKey : rEffects.keySet()) {
|
||||
if (effectKey.equals(autoKey)) {
|
||||
|
@ -254,18 +288,18 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
List<UUID> chosen = target.getTargets();
|
||||
options.put("chosen", (Serializable)chosen);
|
||||
options.put("chosen", (Serializable) chosen);
|
||||
|
||||
game.fireSelectTargetEvent(getId(), target.getMessage(), targetIds, required, getOptions(target, options));
|
||||
game.fireSelectTargetEvent(getId(), addSecondLineWithObjectName(target.getMessage(), sourceId, game), targetIds, required, getOptions(target, options));
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (!targetIds.contains(response.getUUID())) {
|
||||
continue;
|
||||
}
|
||||
if (target instanceof TargetPermanent) {
|
||||
if (((TargetPermanent)target).canTarget(abilityControllerId, response.getUUID(), sourceId, game, false)) {
|
||||
if (((TargetPermanent) target).canTarget(abilityControllerId, response.getUUID(), sourceId, game, false)) {
|
||||
target.add(response.getUUID(), game);
|
||||
if(target.doneChosing()){
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -276,8 +310,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it with
|
||||
target.remove(response.getUUID());
|
||||
} else {
|
||||
target.addTarget(response.getUUID(), (Ability)object, game);
|
||||
if(target.doneChosing()){
|
||||
target.addTarget(response.getUUID(), (Ability) object, game);
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +322,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
target.remove(response.getUUID());
|
||||
} else {
|
||||
target.addTarget(response.getUUID(), null, game);
|
||||
if(target.doneChosing()){
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -316,12 +350,13 @@ public class HumanPlayer extends PlayerImpl {
|
|||
abilityControllerId = target.getAbilityController();
|
||||
}
|
||||
while (!abort) {
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), abilityControllerId, game);
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), abilityControllerId, game);
|
||||
boolean required = target.isRequired(source);
|
||||
if (possibleTargets.isEmpty() || target.getTargets().size() >= target.getNumberOfTargets()) {
|
||||
required = false;
|
||||
}
|
||||
game.fireSelectTargetEvent(getId(), target.getMessage(), possibleTargets, required, getOptions(target, null));
|
||||
|
||||
game.fireSelectTargetEvent(getId(), addSecondLineWithObjectName(target.getMessage(), source == null ? null : source.getSourceId(), game), possibleTargets, required, getOptions(target, null));
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target.getTargets().contains(response.getUUID())) {
|
||||
|
@ -331,7 +366,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (possibleTargets.contains(response.getUUID())) {
|
||||
if (target.canTarget(abilityControllerId, response.getUUID(), source, game)) {
|
||||
target.addTarget(response.getUUID(), source, game);
|
||||
if(target.doneChosing()){
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +383,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
private Map<String, Serializable> getOptions(Target target, Map<String, Serializable> options ) {
|
||||
private Map<String, Serializable> getOptions(Target target, Map<String, Serializable> options) {
|
||||
if (options == null) {
|
||||
options = new HashMap<>();
|
||||
}
|
||||
|
@ -378,7 +413,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
Map<String, Serializable> options = getOptions(target, null);
|
||||
List<UUID> chosen = target.getTargets();
|
||||
options.put("chosen", (Serializable)chosen);
|
||||
options.put("chosen", (Serializable) chosen);
|
||||
List<UUID> choosable = new ArrayList<>();
|
||||
for (UUID cardId : cards) {
|
||||
if (target.canTarget(cardId, cards, game)) {
|
||||
|
@ -432,7 +467,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
Map<String, Serializable> options = getOptions(target, null);
|
||||
List<UUID> chosen = target.getTargets();
|
||||
options.put("chosen", (Serializable)chosen);
|
||||
options.put("chosen", (Serializable) chosen);
|
||||
List<UUID> choosable = new ArrayList<>();
|
||||
for (UUID cardId : cards) {
|
||||
if (target.canTarget(cardId, cards, game)) {
|
||||
|
@ -442,7 +477,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (!choosable.isEmpty()) {
|
||||
options.put("choosable", (Serializable) choosable);
|
||||
}
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
||||
game.fireSelectTargetEvent(playerId, addSecondLineWithObjectName(target.getMessage(), source == null ? null : source.getSourceId(), game), cards, required, options);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it
|
||||
|
@ -471,8 +506,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
|
||||
updateGameStatePriority("chooseTargetAmount", game);
|
||||
while (!abort) {
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(),
|
||||
target.possibleTargets(source==null?null:source.getSourceId(), playerId, game),
|
||||
game.fireSelectTargetEvent(playerId, addSecondLineWithObjectName(target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), source.getSourceId(), game),
|
||||
target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game),
|
||||
target.isRequired(source),
|
||||
getOptions(target, null));
|
||||
waitForResponse(game);
|
||||
|
@ -495,7 +530,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
passed = false;
|
||||
if (!abort) {
|
||||
if (passedAllTurns) {
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -503,7 +538,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
passedUntilStackResolved = false;
|
||||
boolean dontCheckPassStep = false;
|
||||
if (passedTurn) {
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -512,7 +547,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
// it's a main phase
|
||||
if (!skippedAtLeastOnce || (!playerId.equals(game.getActivePlayerId()) && !this.getUserData().getUserSkipPrioritySteps().isStopOnAllMainPhases())) {
|
||||
skippedAtLeastOnce = true;
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -521,7 +556,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
} else {
|
||||
skippedAtLeastOnce = true;
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -531,7 +566,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
// It's end of turn phase
|
||||
if (!skippedAtLeastOnce || (playerId.equals(game.getActivePlayerId()) && !this.getUserData().getUserSkipPrioritySteps().isStopOnAllEndPhases())) {
|
||||
skippedAtLeastOnce = true;
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -540,20 +575,20 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
} else {
|
||||
skippedAtLeastOnce = true;
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dontCheckPassStep && checkPassStep(game)) {
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (passedUntilStackResolved) {
|
||||
if (dateLastAddedToStack == game.getStack().getDateLastAdded()) {
|
||||
dateLastAddedToStack = game.getStack().getDateLastAdded();
|
||||
if(passWithManaPoolCheck(game)) {
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -564,7 +599,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
updateGameStatePriority("priority", game);
|
||||
game.firePriorityEvent(playerId);
|
||||
waitForResponse(game);
|
||||
if(game.executingRollback()) {
|
||||
if (game.executingRollback()) {
|
||||
return true;
|
||||
}
|
||||
if (response.getBoolean() != null || response.getInteger() != null) {
|
||||
|
@ -628,7 +663,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
game.fireSelectTargetEvent(playerId, "Pick triggered ability (goes to the stack first)", abilities);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (TriggeredAbility ability: abilities) {
|
||||
for (TriggeredAbility ability : abilities) {
|
||||
if (ability.getId().equals(response.getUUID())) {
|
||||
return ability;
|
||||
}
|
||||
|
@ -638,7 +673,6 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean playMana(ManaCost unpaid, String promptText, Game game) {
|
||||
payManaMode = true;
|
||||
|
@ -647,7 +681,6 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected boolean playManaHandling(ManaCost unpaid, String promptText, Game game) {
|
||||
updateGameStatePriority("playMana", game);
|
||||
game.firePlayManaEvent(playerId, "Pay " + promptText);
|
||||
|
@ -666,9 +699,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
ManaCostsImpl<ManaCost> costs = (ManaCostsImpl<ManaCost>) unpaid;
|
||||
for (ManaCost cost : costs.getUnpaid()) {
|
||||
if (cost instanceof PhyrexianManaCost) {
|
||||
PhyrexianManaCost ph = (PhyrexianManaCost)cost;
|
||||
PhyrexianManaCost ph = (PhyrexianManaCost) cost;
|
||||
if (ph.canPay(null, null, playerId, game)) {
|
||||
((PhyrexianManaCost)cost).pay(null, game, null, playerId, false);
|
||||
((PhyrexianManaCost) cost).pay(null, game, null, playerId, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -686,6 +719,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
/**
|
||||
* Gets the amount of mana the player want to spent for a x spell
|
||||
*
|
||||
* @param min
|
||||
* @param max
|
||||
* @param message
|
||||
|
@ -739,8 +773,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
FilterCreatureForCombat filter = filterCreatureForCombat.copy();
|
||||
filter.add(new ControllerIdPredicate(attackingPlayerId));
|
||||
while (!abort) {
|
||||
if (passedAllTurns ||
|
||||
(!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedUntilEndOfTurn || passedUntilNextMain) )) {
|
||||
if (passedAllTurns
|
||||
|| (!getUserData().getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction() && (passedTurn || passedUntilEndOfTurn || passedUntilNextMain))) {
|
||||
return;
|
||||
}
|
||||
Map<String, Serializable> options = new HashMap<>();
|
||||
|
@ -751,17 +785,36 @@ public class HumanPlayer extends PlayerImpl {
|
|||
possibleAttackers.add(possibleAttacker.getId());
|
||||
}
|
||||
}
|
||||
options.put(Constants.Option.POSSIBLE_ATTACKERS, (Serializable)possibleAttackers);
|
||||
options.put(Constants.Option.POSSIBLE_ATTACKERS, (Serializable) possibleAttackers);
|
||||
if (possibleAttackers.size() > 0) {
|
||||
options.put(Constants.Option.SPECIAL_BUTTON, (Serializable) "All attack");
|
||||
}
|
||||
|
||||
game.fireSelectEvent(playerId, "Select attackers", options);
|
||||
waitForResponse(game);
|
||||
if (response.getBoolean() != null) {
|
||||
if (response.getString() != null && response.getString().equals("special")) { // All attack
|
||||
setStoredBookmark(game.bookmarkState());
|
||||
UUID attackedDefender = null;
|
||||
if (game.getCombat().getDefenders().size() > 1) {
|
||||
attackedDefender = selectDefenderForAllAttack(game.getCombat().getDefenders(), game);
|
||||
} else if (game.getCombat().getDefenders().size() == 1) {
|
||||
attackedDefender = game.getCombat().getDefenders().iterator().next();
|
||||
}
|
||||
for (Permanent attacker : game.getBattlefield().getAllActivePermanents(filterCreatureForCombat, getId(), game)) {
|
||||
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
|
||||
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
|
||||
attackedDefender, attacker.getId(), attacker.getControllerId()), game)) {
|
||||
continue;
|
||||
}
|
||||
declareAttacker(attacker.getId(), attackedDefender, game, false);
|
||||
}
|
||||
} else if (response.getBoolean() != null) {
|
||||
// check if enough attackers are declared
|
||||
if (!game.getCombat().getCreaturesForcedToAttack().isEmpty()) {
|
||||
if (!game.getCombat().getAttackers().containsAll(game.getCombat().getCreaturesForcedToAttack().keySet())) {
|
||||
int forcedAttackers = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (UUID creatureId :game.getCombat().getCreaturesForcedToAttack().keySet()) {
|
||||
for (UUID creatureId : game.getCombat().getCreaturesForcedToAttack().keySet()) {
|
||||
boolean validForcedAttacker = false;
|
||||
if (game.getCombat().getAttackers().contains(creatureId)) {
|
||||
Set<UUID> possibleDefender = game.getCombat().getCreaturesForcedToAttack().get(creatureId);
|
||||
|
@ -780,7 +833,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
}
|
||||
if (game.getCombat().getMaxAttackers() > forcedAttackers) {
|
||||
game.informPlayer(this, sb.insert(0," more attacker(s) that are forced to attack.\nCreatures forced to attack: ")
|
||||
game.informPlayer(this, sb.insert(0, " more attacker(s) that are forced to attack.\nCreatures forced to attack: ")
|
||||
.insert(0, Math.min(game.getCombat().getMaxAttackers() - forcedAttackers, game.getCombat().getCreaturesForcedToAttack().size() - forcedAttackers))
|
||||
.insert(0, "You have to attack with ").toString());
|
||||
continue;
|
||||
|
@ -799,8 +852,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (attacker != null) {
|
||||
if (filterCreatureForCombat.match(attacker, null, playerId, game)) {
|
||||
selectDefender(game.getCombat().getDefenders(), attacker.getId(), game);
|
||||
}
|
||||
else if (filterAttack.match(attacker, null, playerId, game) && game.getStack().isEmpty()) {
|
||||
} else if (filterAttack.match(attacker, null, playerId, game) && game.getStack().isEmpty()) {
|
||||
removeAttackerIfPossible(game, attacker);
|
||||
}
|
||||
}
|
||||
|
@ -810,7 +862,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
private void removeAttackerIfPossible(Game game, Permanent attacker) {
|
||||
for (Map.Entry entry : game.getContinuousEffects().getApplicableRequirementEffects(attacker, game).entrySet()) {
|
||||
RequirementEffect effect = (RequirementEffect)entry.getKey();
|
||||
RequirementEffect effect = (RequirementEffect) entry.getKey();
|
||||
if (effect.mustAttack(game)) {
|
||||
if (game.getCombat().getMaxAttackers() >= game.getCombat().getCreaturesForcedToAttack().size() && game.getCombat().getDefenders().size() == 1) {
|
||||
return; // we can't change creatures forced to attack if only one possible defender exists and all forced creatures can attack
|
||||
|
@ -840,8 +892,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (possibleDefender.size() == 1) {
|
||||
declareAttacker(attackerId, defenders.iterator().next(), game, true);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
TargetDefender target = new TargetDefender(possibleDefender, attackerId);
|
||||
target.setNotTarget(true); // player or planswalker hexproof does not prevent attacking a player
|
||||
if (forcedToAttack) {
|
||||
|
@ -860,6 +911,15 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected UUID selectDefenderForAllAttack(Set<UUID> defenders, Game game) {
|
||||
TargetDefender target = new TargetDefender(defenders, null);
|
||||
target.setNotTarget(true); // player or planswalker hexproof does not prevent attacking a player
|
||||
if (chooseTarget(Outcome.Damage, target, null, game)) {
|
||||
return response.getUUID();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectBlockers(Game game, UUID defendingPlayerId) {
|
||||
updateGameStatePriority("selectBlockers", game);
|
||||
|
@ -903,7 +963,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
game.fireSelectTargetEvent(playerId, "Pick attacker", attackers, true);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (Permanent perm: attackers) {
|
||||
for (Permanent perm : attackers) {
|
||||
if (perm.getId().equals(response.getUUID())) {
|
||||
return perm.getId();
|
||||
}
|
||||
|
@ -913,7 +973,6 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game) {
|
||||
updateGameStatePriority("chooseBlockerOrder", game);
|
||||
|
@ -921,7 +980,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
game.fireSelectTargetEvent(playerId, "Pick blocker", blockers, true);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (Permanent perm: blockers) {
|
||||
for (Permanent perm : blockers) {
|
||||
if (perm.getId().equals(response.getUUID())) {
|
||||
return perm.getId();
|
||||
}
|
||||
|
@ -934,7 +993,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
protected void selectCombatGroup(UUID defenderId, UUID blockerId, Game game) {
|
||||
updateGameStatePriority("selectCombatGroup", game);
|
||||
TargetAttackingCreature target = new TargetAttackingCreature();
|
||||
game.fireSelectTargetEvent(playerId, "Select attacker to block", target.possibleTargets(null, playerId, game), false, getOptions(target, null));
|
||||
game.fireSelectTargetEvent(playerId, addSecondLineWithObjectName("Select attacker to block", blockerId, game), target.possibleTargets(null, playerId, game), false, getOptions(target, null));
|
||||
waitForResponse(game);
|
||||
if (response.getBoolean() != null) {
|
||||
// do nothing
|
||||
|
@ -967,8 +1026,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (permanent != null) {
|
||||
permanent.damage(damageAmount, sourceId, game, false, true);
|
||||
remainingDamage -= damageAmount;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Player player = game.getPlayer(target.getFirstTarget());
|
||||
if (player != null) {
|
||||
player.damage(damageAmount, sourceId, game, false, true);
|
||||
|
@ -1081,7 +1139,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
switch(ability.getSpellAbilityType()) {
|
||||
switch (ability.getSpellAbilityType()) {
|
||||
case SPLIT:
|
||||
case SPLIT_FUSED:
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
|
@ -1111,7 +1169,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (modes.size() > 1) {
|
||||
MageObject obj = game.getObject(source.getSourceId());
|
||||
Map<UUID, String> modeMap = new LinkedHashMap<>();
|
||||
for (Mode mode: modes.values()) {
|
||||
for (Mode mode : modes.getAvailableModes(source, game)) {
|
||||
if (!modes.getSelectedModes().contains(mode.getId()) // show only modes not already selected
|
||||
&& mode.getTargets().canChoose(source.getSourceId(), source.getControllerId(), game)) { // and where targets are available
|
||||
String modeText = mode.getEffects().getText(mode);
|
||||
|
@ -1122,15 +1180,24 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
}
|
||||
if (modeMap.size() > 0) {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
game.fireGetModeEvent(playerId, "Choose Mode", modeMap);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
for (Mode mode: modes.values()) {
|
||||
for (Mode mode : modes.getAvailableModes(source, game)) {
|
||||
if (mode.getId().equals(response.getUUID())) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!source.getAbilityType().equals(AbilityType.TRIGGERED)) {
|
||||
done = true;
|
||||
}
|
||||
if (!isInGame()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1150,7 +1217,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public void setResponseString(String responseString) {
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
response.setString(responseString);
|
||||
response.notify();
|
||||
log.debug("Got response string from player: " + getId());
|
||||
|
@ -1159,7 +1226,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public void setResponseManaType(UUID manaTypePlayerId, ManaType manaType) {
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
response.setManaType(manaType);
|
||||
response.setResponseManaTypePlayerId(manaTypePlayerId);
|
||||
response.notify();
|
||||
|
@ -1169,7 +1236,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public void setResponseUUID(UUID responseUUID) {
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
response.setUUID(responseUUID);
|
||||
response.notify();
|
||||
log.debug("Got response UUID from player: " + getId());
|
||||
|
@ -1178,7 +1245,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public void setResponseBoolean(Boolean responseBoolean) {
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
response.setBoolean(responseBoolean);
|
||||
response.notify();
|
||||
log.debug("Got response boolean from player: " + getId());
|
||||
|
@ -1187,7 +1254,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public void setResponseInteger(Integer responseInteger) {
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
response.setInteger(responseInteger);
|
||||
response.notify();
|
||||
log.debug("Got response integer from player: " + getId());
|
||||
|
@ -1197,7 +1264,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
@Override
|
||||
public void abort() {
|
||||
abort = true;
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
response.notify();
|
||||
log.debug("Got cancel action from player: " + getId());
|
||||
}
|
||||
|
@ -1205,7 +1272,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
@Override
|
||||
public void skip() {
|
||||
synchronized(response) {
|
||||
synchronized (response) {
|
||||
response.setInteger(0);
|
||||
response.notify();
|
||||
log.debug("Got skip action from player: " + getId());
|
||||
|
@ -1234,8 +1301,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
protected boolean passWithManaPoolCheck(Game game) {
|
||||
if (userData.confirmEmptyManaPool() &&
|
||||
game.getStack().isEmpty() && getManaPool().count() > 0) {
|
||||
if (userData.confirmEmptyManaPool()
|
||||
&& game.getStack().isEmpty() && getManaPool().count() > 0) {
|
||||
String activePlayerText;
|
||||
if (game.getActivePlayerId().equals(playerId)) {
|
||||
activePlayerText = "Your turn";
|
||||
|
@ -1247,7 +1314,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
priorityPlayerText = " / priority " + game.getPlayer(game.getPriorityPlayerId()).getName();
|
||||
}
|
||||
if (!chooseUse(Outcome.Detriment, GameLog.getPlayerConfirmColoredText("You have still mana in your mana pool. Pass regardless?")
|
||||
+ GameLog.getSmallSecondLineText(activePlayerText + " / " + game.getStep().getType().toString() + priorityPlayerText), game)) {
|
||||
+ GameLog.getSmallSecondLineText(activePlayerText + " / " + game.getStep().getType().toString() + priorityPlayerText), null, game)) {
|
||||
sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, game);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-tournament-boosterdraft</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-tournament-constructed</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-tournament-sealed</artifactId>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-server-plugins</artifactId>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-server</artifactId>
|
||||
|
|
|
@ -34,8 +34,10 @@
|
|||
<tournamentType name="Constructed Swiss" jar="mage-tournament-constructed-${project.version}.jar" className="mage.tournament.ConstructedSwissTournament" typeName="mage.tournament.ConstructedSwissTournamentType"/>
|
||||
<tournamentType name="Booster Draft Elimination" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Booster Draft Elimination (Cube)" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationCubeTournamentType"/>
|
||||
<tournamentType name="Booster Draft Elimination (Random)" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.RandomBoosterDraftEliminationTournament" typeName="mage.tournament.RandomBoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Booster Draft Swiss" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissTournamentType"/>
|
||||
<tournamentType name="Booster Draft Swiss (Cube)" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissCubeTournamentType"/>
|
||||
<tournamentType name="Booster Draft Swiss (Random)" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.RandomBoosterDraftSwissTournament" typeName="mage.tournament.RandomBoosterDraftSwissCubeTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed-${project.version}.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination (Cube)" jar="mage-tournament-sealed-${project.version}.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationCubeTournamentType"/>
|
||||
<tournamentType name="Sealed Swiss" jar="mage-tournament-sealed-${project.version}.jar" className="mage.tournament.SealedSwissTournament" typeName="mage.tournament.SealedSwissTournamentType"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Welcome! You are playing XMage version 1.4.1
|
||||
Welcome! You are playing XMage version 1.4.2
|
||||
Find what was changed since previous versions on project Wiki https://github.com/magefree/mage/wiki
|
||||
Contact us on the XMAGE board of http://www.slightlymagic.net/forum/viewforum.php?f=70 for bug reports or enhancement requests.
|
||||
Download newest version from http://XMage.de
|
|
@ -2,5 +2,5 @@ HotKeys: Alt+E - Enlarge card image
|
|||
Wheel zoom in/out - Enlarge card image
|
||||
F4 - end current turn, response to stack
|
||||
F9 - skip all opponents' turns, no response to stack
|
||||
Welcome! You are playing Mage version 1.4.1
|
||||
Welcome! You are playing Mage version 1.4.2
|
||||
Contact us on www.slightlymagic.net
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -52,6 +51,7 @@ import mage.interfaces.ActionWithResult;
|
|||
import mage.interfaces.MageServer;
|
||||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.players.net.UserData;
|
||||
import mage.remote.MageVersionException;
|
||||
import mage.server.draft.CubeFactory;
|
||||
import mage.server.draft.DraftManager;
|
||||
|
@ -83,7 +83,6 @@ import mage.view.MatchView;
|
|||
import mage.view.RoomUsersView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserDataView;
|
||||
import mage.view.UserView;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -117,7 +116,7 @@ public class MageServerImpl implements MageServer {
|
|||
return SessionManager.getInstance().registerUser(sessionId, userName);
|
||||
} catch (MageException ex) {
|
||||
if (ex instanceof MageVersionException) {
|
||||
throw (MageVersionException)ex;
|
||||
throw (MageVersionException) ex;
|
||||
}
|
||||
handleException(ex);
|
||||
}
|
||||
|
@ -125,11 +124,11 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setUserData(final String userName, final String sessionId, final UserDataView userDataView) throws MageException {
|
||||
public boolean setUserData(final String userName, final String sessionId, final UserData userData) throws MageException {
|
||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||
@Override
|
||||
public Boolean execute() throws MageException {
|
||||
return SessionManager.getInstance().setUserData(userName, sessionId, userDataView);
|
||||
return SessionManager.getInstance().setUserData(userName, sessionId, userData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -293,8 +292,7 @@ public class MageServerImpl implements MageServer {
|
|||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -310,8 +308,7 @@ public class MageServerImpl implements MageServer {
|
|||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -326,8 +323,7 @@ public class MageServerImpl implements MageServer {
|
|||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -343,8 +339,7 @@ public class MageServerImpl implements MageServer {
|
|||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -365,7 +360,6 @@ public class MageServerImpl implements MageServer {
|
|||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||
if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
||||
|
@ -391,7 +385,6 @@ public class MageServerImpl implements MageServer {
|
|||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||
if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
||||
|
@ -412,8 +405,7 @@ public class MageServerImpl implements MageServer {
|
|||
public TournamentView getTournament(UUID tournamentId) throws MageException {
|
||||
try {
|
||||
return TournamentManager.getInstance().getTournamentView(tournamentId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -431,8 +423,7 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
@ -464,8 +455,7 @@ public class MageServerImpl implements MageServer {
|
|||
public UUID getMainRoomId() throws MageException {
|
||||
try {
|
||||
return GamesRoomManager.getInstance().getMainRoomId();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -476,8 +466,7 @@ public class MageServerImpl implements MageServer {
|
|||
public UUID getRoomChatId(UUID roomId) throws MageException {
|
||||
try {
|
||||
return GamesRoomManager.getInstance().getRoom(roomId).getChatId();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -527,8 +516,7 @@ public class MageServerImpl implements MageServer {
|
|||
public UUID getTableChatId(UUID tableId) throws MageException {
|
||||
try {
|
||||
return TableManager.getInstance().getChatId(tableId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -572,8 +560,7 @@ public class MageServerImpl implements MageServer {
|
|||
public UUID getGameChatId(UUID gameId) throws MageException {
|
||||
try {
|
||||
return GameManager.getInstance().getChatId(gameId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -584,8 +571,7 @@ public class MageServerImpl implements MageServer {
|
|||
public UUID getTournamentChatId(UUID tournamentId) throws MageException {
|
||||
try {
|
||||
return TournamentManager.getInstance().getChatId(tournamentId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -675,8 +661,8 @@ public class MageServerImpl implements MageServer {
|
|||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
return DraftManager.getInstance().sendCardPick(draftId, session.getUserId(), cardPick, hiddenCards);
|
||||
} else{
|
||||
logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId);
|
||||
} else {
|
||||
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -691,8 +677,8 @@ public class MageServerImpl implements MageServer {
|
|||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
DraftManager.getInstance().sendCardMark(draftId, session.getUserId(), cardPick);
|
||||
} else{
|
||||
logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId);
|
||||
} else {
|
||||
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -706,8 +692,8 @@ public class MageServerImpl implements MageServer {
|
|||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
GameManager.getInstance().quitMatch(gameId, session.getUserId());
|
||||
} else{
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" +gameId);
|
||||
} else {
|
||||
logger.error("Session not found sessionId: " + sessionId + " gameId:" + gameId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -721,8 +707,8 @@ public class MageServerImpl implements MageServer {
|
|||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
TournamentManager.getInstance().quit(tournamentId, session.getUserId());
|
||||
}else{
|
||||
logger.error("Session not found sessionId: "+ sessionId + " tournamentId:" + tournamentId);
|
||||
} else {
|
||||
logger.error("Session not found sessionId: " + sessionId + " tournamentId:" + tournamentId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -735,7 +721,7 @@ public class MageServerImpl implements MageServer {
|
|||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId);
|
||||
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
||||
return;
|
||||
}
|
||||
UUID tableId = DraftManager.getInstance().getControllerByDraftId(draftId).getTableId();
|
||||
|
@ -755,7 +741,7 @@ public class MageServerImpl implements MageServer {
|
|||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
logger.error("Session not found sessionId: " + sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().sendPlayerAction(playerAction, gameId, session.getUserId(), data);
|
||||
|
@ -893,8 +879,7 @@ public class MageServerImpl implements MageServer {
|
|||
CardRepository.instance.getContentVersionConstant(),
|
||||
ExpansionRepository.instance.getContentVersionConstant()
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
return null;
|
||||
|
@ -1076,8 +1061,7 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.server;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -42,7 +41,6 @@ import mage.players.net.UserData;
|
|||
import mage.players.net.UserGroup;
|
||||
import mage.server.game.GamesRoomManager;
|
||||
import mage.server.util.ConfigSettings;
|
||||
import mage.view.UserDataView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.callback.AsynchInvokerCallbackHandler;
|
||||
import org.jboss.remoting.callback.Callback;
|
||||
|
@ -142,77 +140,49 @@ public class Session {
|
|||
if (user == null) {
|
||||
user = UserManager.getInstance().findUser("Admin");
|
||||
}
|
||||
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, false, false, null, "world.png", false));
|
||||
UserData adminUserData = UserData.getDefaultUserDataView();
|
||||
adminUserData.setGroupId(UserGroup.ADMIN.getGroupId());
|
||||
user.setUserData(adminUserData);
|
||||
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
||||
logger.info("Error connecting Admin!");
|
||||
}
|
||||
this.userId = user.getId();
|
||||
}
|
||||
|
||||
public boolean setUserData(String userName, UserDataView userDataView) {
|
||||
public boolean setUserData(String userName, UserData userData) {
|
||||
User user = UserManager.getInstance().findUser(userName);
|
||||
if (user != null) {
|
||||
UserData userData = user.getUserData();
|
||||
if (userData == null) {
|
||||
userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(),
|
||||
userDataView.isShowAbilityPickerForced(), userDataView.allowRequestShowHandCards(),
|
||||
userDataView.confirmEmptyManaPool(), userDataView.getUserSkipPrioritySteps(),
|
||||
userDataView.getFlagName(), userDataView.askMoveToGraveOrder());
|
||||
if (user.getUserData() == null || user.getUserData().getGroupId() == UserGroup.DEFAULT.getGroupId()) {
|
||||
user.setUserData(userData);
|
||||
} else {
|
||||
if (userDataView.getAvatarId() == 51) { // Update special avatar if first avatar is selected
|
||||
updateAvatar(userName, userData);
|
||||
user.getUserData().update(userData);
|
||||
}
|
||||
userData.setAvatarId(userDataView.getAvatarId());
|
||||
userData.setShowAbilityPickerForced(userDataView.isShowAbilityPickerForced());
|
||||
userData.setAllowRequestShowHandCards(userDataView.allowRequestShowHandCards());
|
||||
userData.setUserSkipPrioritySteps(userDataView.getUserSkipPrioritySteps());
|
||||
userData.setConfirmEmptyManaPool(userDataView.confirmEmptyManaPool());
|
||||
userData.setAskMoveToGraveOrder(userDataView.askMoveToGraveOrder());
|
||||
if (user.getUserData().getAvatarId() == 51) {
|
||||
user.getUserData().setAvatarId(updateAvatar(user.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateAvatar(String userName, UserData userData) {
|
||||
private int updateAvatar(String userName) {
|
||||
//TODO: move to separate class
|
||||
//TODO: add for checking for private key
|
||||
switch (userName) {
|
||||
case "nantuko":
|
||||
userData.setAvatarId(1000);
|
||||
break;
|
||||
case "i_no_k":
|
||||
userData.setAvatarId(1002);
|
||||
break;
|
||||
case "Askael":
|
||||
userData.setAvatarId(1004);
|
||||
break;
|
||||
return 1000;
|
||||
case "North":
|
||||
userData.setAvatarId(1006);
|
||||
break;
|
||||
return 1006;
|
||||
case "BetaSteward":
|
||||
userData.setAvatarId(1008);
|
||||
break;
|
||||
case "Arching":
|
||||
userData.setAvatarId(1010);
|
||||
break;
|
||||
return 1008;
|
||||
case "loki":
|
||||
userData.setAvatarId(1012);
|
||||
break;
|
||||
case "Alive":
|
||||
userData.setAvatarId(1014);
|
||||
break;
|
||||
case "Rahan":
|
||||
userData.setAvatarId(1016);
|
||||
break;
|
||||
return 1012;
|
||||
case "Ayrat":
|
||||
userData.setAvatarId(1018);
|
||||
break;
|
||||
return 1018;
|
||||
case "Bandit":
|
||||
userData.setAvatarId(1020);
|
||||
break;
|
||||
return 1020;
|
||||
}
|
||||
return 51;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -223,7 +193,7 @@ public class Session {
|
|||
public void userLostConnection() {
|
||||
boolean lockSet = false;
|
||||
try {
|
||||
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
if (lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
lockSet = true;
|
||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||
} else {
|
||||
|
@ -243,8 +213,7 @@ public class Session {
|
|||
|
||||
} catch (InterruptedException ex) {
|
||||
logger.error("SESSION LOCK lost connection - userId: " + userId, ex);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (lockSet) {
|
||||
lock.unlock();
|
||||
logger.trace("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
||||
|
@ -256,7 +225,7 @@ public class Session {
|
|||
public void kill(DisconnectReason reason) {
|
||||
boolean lockSet = false;
|
||||
try {
|
||||
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
if (lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||
lockSet = true;
|
||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||
} else {
|
||||
|
@ -265,8 +234,7 @@ public class Session {
|
|||
UserManager.getInstance().removeUser(userId, reason);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.error("SESSION LOCK - kill: userId " + userId, ex);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
if (lockSet) {
|
||||
lock.unlock();
|
||||
logger.debug("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
||||
|
@ -282,7 +250,7 @@ public class Session {
|
|||
callbackHandler.handleCallbackOneway(new Callback(call));
|
||||
} catch (HandleCallbackException ex) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
logger.warn("SESSION CALLBACK EXCEPTION - " + (user != null ? user.getName():"") + " userId " + userId);
|
||||
logger.warn("SESSION CALLBACK EXCEPTION - " + (user != null ? user.getName() : "") + " userId " + userId);
|
||||
logger.warn(" - method: " + call.getMethod());
|
||||
logger.warn(" - cause: " + getBasicCause(ex).toString());
|
||||
logger.trace("Stack trace:", ex);
|
||||
|
|
|
@ -31,9 +31,9 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.MageException;
|
||||
import mage.players.net.UserData;
|
||||
import mage.server.services.LogKeys;
|
||||
import mage.server.services.impl.LogServiceImpl;
|
||||
import mage.view.UserDataView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||
|
||||
|
@ -102,10 +102,10 @@ public class SessionManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean setUserData(String userName, String sessionId, UserDataView userDataView) throws MageException {
|
||||
public boolean setUserData(String userName, String sessionId, UserData userData) throws MageException {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session != null) {
|
||||
session.setUserData(userName, userDataView);
|
||||
session.setUserData(userName, userData);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -119,7 +119,7 @@ public class SessionManager {
|
|||
// session was removed meanwhile by another thread so we can return
|
||||
return;
|
||||
}
|
||||
logger.debug("DISCONNECT " + reason.toString() + " - sessionId: "+ sessionId);
|
||||
logger.debug("DISCONNECT " + reason.toString() + " - sessionId: " + sessionId);
|
||||
sessions.remove(sessionId);
|
||||
switch (reason) {
|
||||
case Disconnected:
|
||||
|
@ -135,7 +135,7 @@ public class SessionManager {
|
|||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED, sessionId);
|
||||
break;
|
||||
default:
|
||||
logger.error("endSession: unexpected reason " + reason.toString() + " - sessionId: "+ sessionId);
|
||||
logger.error("endSession: unexpected reason " + reason.toString() + " - sessionId: " + sessionId);
|
||||
}
|
||||
} else {
|
||||
sessions.remove(sessionId);
|
||||
|
@ -155,6 +155,7 @@ public class SessionManager {
|
|||
|
||||
/**
|
||||
* Admin requested the disconnect of a user
|
||||
*
|
||||
* @param sessionId
|
||||
* @param userSessionId
|
||||
*/
|
||||
|
@ -163,12 +164,12 @@ public class SessionManager {
|
|||
User userAdmin, user;
|
||||
if ((userAdmin = getUserFromSession(sessionId)) != null) {
|
||||
if ((user = getUserFromSession(userSessionId)) != null) {
|
||||
user.showUserMessage("Admin operation","Your session was disconnected by Admin.");
|
||||
user.showUserMessage("Admin operation", "Your session was disconnected by Admin.");
|
||||
userAdmin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected.");
|
||||
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED_BY_ADMIN, sessionId, userSessionId);
|
||||
} else {
|
||||
userAdmin.showUserMessage("Admin operation","User with sessionId " + userSessionId + " could not be found!");
|
||||
userAdmin.showUserMessage("Admin operation", "User with sessionId " + userSessionId + " could not be found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.server;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -103,8 +102,7 @@ public class TableController {
|
|||
User user = UserManager.getInstance().getUser(userId);
|
||||
// TODO: Handle if user == null
|
||||
controllerName = user.getName();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
controllerName = "System";
|
||||
}
|
||||
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match);
|
||||
|
@ -123,8 +121,7 @@ public class TableController {
|
|||
} else {
|
||||
controllerName = user.getName();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
controllerName = "System";
|
||||
}
|
||||
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
|
||||
|
@ -133,7 +130,7 @@ public class TableController {
|
|||
|
||||
private void init() {
|
||||
match.addTableEventListener(
|
||||
new Listener<TableEvent> () {
|
||||
new Listener<TableEvent>() {
|
||||
@Override
|
||||
public void event(TableEvent event) {
|
||||
try {
|
||||
|
@ -171,7 +168,7 @@ public class TableController {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){
|
||||
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")) {
|
||||
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
|
||||
return false;
|
||||
}
|
||||
|
@ -210,7 +207,7 @@ public class TableController {
|
|||
tournamentPlayer.submitDeck(deck);
|
||||
}
|
||||
table.joinTable(player, seat);
|
||||
logger.debug("Player " + player.getName() + " id: "+ player.getId() + " joined tableId: " + table.getId());
|
||||
logger.debug("Player " + player.getName() + " id: " + player.getId() + " joined tableId: " + table.getId());
|
||||
//only inform human players and add them to sessionPlayerMap
|
||||
if (seat.getPlayer().isHuman()) {
|
||||
seat.getPlayer().setUserData(user.getUserData());
|
||||
|
@ -250,7 +247,7 @@ public class TableController {
|
|||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){
|
||||
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")) {
|
||||
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
|
||||
return false;
|
||||
}
|
||||
|
@ -289,7 +286,7 @@ public class TableController {
|
|||
if (player == null) {
|
||||
String message = new StringBuilder("Could not create player ").append(name).append(" of type ").append(seat.getPlayerType()).toString();
|
||||
logger.warn(new StringBuilder("User: ").append(user.getName()).append(" => ").append(message).toString());
|
||||
user.showUserMessage("Join Table",message);
|
||||
user.showUserMessage("Join Table", message);
|
||||
return false;
|
||||
}
|
||||
logger.debug("DECK validated: " + table.getValidator().getName() + " " + player.getName() + " " + deck.getName());
|
||||
|
@ -378,8 +375,7 @@ public class TableController {
|
|||
if (table.getState() == TableState.SIDEBOARDING) {
|
||||
match.submitDeck(playerId, deck);
|
||||
UserManager.getInstance().getUser(userId).removeSideboarding(table.getId());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
TournamentManager.getInstance().submitDeck(tournament.getId(), playerId, deck);
|
||||
UserManager.getInstance().getUser(userId).removeConstructing(playerId);
|
||||
}
|
||||
|
@ -390,7 +386,7 @@ public class TableController {
|
|||
if (tournament != null) {
|
||||
TournamentManager.getInstance().updateDeck(tournament.getId(), playerId, deck);
|
||||
} else {
|
||||
logger.fatal("Tournament == null table: " + table.getId() +" userId: " + userId);
|
||||
logger.fatal("Tournament == null table: " + table.getId() + " userId: " + userId);
|
||||
}
|
||||
} else {
|
||||
if (TableState.SIDEBOARDING.equals(table.getState())) {
|
||||
|
@ -427,13 +423,11 @@ public class TableController {
|
|||
// ReplayManager.getInstance().replayGame(table.getId(), userId);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
private Player createPlayer(String name, String playerType, int skill) {
|
||||
Player player;
|
||||
if (options == null) {
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
|
||||
}
|
||||
if (player != null) {
|
||||
|
@ -443,7 +437,7 @@ public class TableController {
|
|||
}
|
||||
|
||||
public void leaveTableAll() {
|
||||
for (UUID leavingUserId: userPlayerMap.keySet()) {
|
||||
for (UUID leavingUserId : userPlayerMap.keySet()) {
|
||||
leaveTable(leavingUserId);
|
||||
}
|
||||
closeTable();
|
||||
|
@ -488,13 +482,13 @@ public class TableController {
|
|||
if (table.isTournament()) {
|
||||
logger.debug("Quit tournament sub tables for userId: " + userId);
|
||||
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
||||
logger.debug("Quit tournament Id: " + table.getTournament().getId() + "(" +table.getTournament().getTournamentState() + ")");
|
||||
logger.debug("Quit tournament Id: " + table.getTournament().getId() + "(" + table.getTournament().getTournamentState() + ")");
|
||||
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
||||
} else {
|
||||
MatchPlayer matchPlayer = match.getPlayer(playerId);
|
||||
if (matchPlayer != null && !match.hasEnded() && !matchPlayer.hasQuit()) {
|
||||
Game game = match.getGame();
|
||||
if (game != null && !game.hasEnded()){
|
||||
if (game != null && !game.hasEnded()) {
|
||||
Player player = match.getPlayer(playerId).getPlayer();
|
||||
if (player != null && player.isInGame()) {
|
||||
GameManager.getInstance().quitMatch(game.getId(), userId);
|
||||
|
@ -536,7 +530,7 @@ public class TableController {
|
|||
logger.info("Tourn. match started id:" + match.getId() + " tournId: " + table.getTournament().getId());
|
||||
} else {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
logger.info("MATCH started [" + match.getName() + "] " + match.getId() + "(" + user.getName() +")");
|
||||
logger.info("MATCH started [" + match.getName() + "] " + match.getId() + "(" + user.getName() + ")");
|
||||
logger.debug("- " + match.getOptions().getGameType() + " - " + match.getOptions().getDeckType());
|
||||
}
|
||||
match.startMatch();
|
||||
|
@ -558,7 +552,7 @@ public class TableController {
|
|||
GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId, gameOptions);
|
||||
String creator = null;
|
||||
StringBuilder opponent = new StringBuilder();
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) { // no AI players
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) { // no AI players
|
||||
if (!match.getPlayer(entry.getValue()).hasQuit()) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
|
@ -582,7 +576,7 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
// Append AI opponents to the log file
|
||||
for (MatchPlayer mPlayer :match.getPlayers()) {
|
||||
for (MatchPlayer mPlayer : match.getPlayers()) {
|
||||
if (!mPlayer.getPlayer().isHuman()) {
|
||||
if (opponent.length() > 0) {
|
||||
opponent.append(" - ");
|
||||
|
@ -592,9 +586,8 @@ public class TableController {
|
|||
}
|
||||
ServerMessagesUtil.getInstance().incGamesStarted();
|
||||
|
||||
|
||||
// log about game started
|
||||
logger.info("GAME started " + match.getGame().getId() + " [" + match.getName() +"] "+ creator + " - " + opponent.toString());
|
||||
logger.info("GAME started " + match.getGame().getId() + " [" + match.getName() + "] " + creator + " - " + opponent.toString());
|
||||
logger.debug("- matchId: " + match.getId() + " [" + match.getName() + "]");
|
||||
if (match.getGame() != null) {
|
||||
logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId()));
|
||||
|
@ -602,8 +595,7 @@ public class TableController {
|
|||
logger.debug("- no valid game object");
|
||||
}
|
||||
LogServiceImpl.instance.log(LogKeys.KEY_GAME_STARTED, String.valueOf(userPlayerMap.size()), creator, opponent.toString());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error starting game", ex);
|
||||
if (table != null) {
|
||||
TableManager.getInstance().removeTable(table.getId());
|
||||
|
@ -622,7 +614,7 @@ public class TableController {
|
|||
if (userId.equals(this.userId) && table.getState().equals(TableState.STARTING)) {
|
||||
tournament.setStartTime();
|
||||
TournamentManager.getInstance().createTournamentSession(tournament, userPlayerMap, table.getId());
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
logger.info(new StringBuilder("User ").append(user.getName()).append(" tournament started: ").append(tournament.getId()).append(" userId: ").append(user.getId()));
|
||||
|
@ -631,8 +623,7 @@ public class TableController {
|
|||
}
|
||||
ServerMessagesUtil.getInstance().incTournamentsStarted();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error starting tournament", ex);
|
||||
TableManager.getInstance().removeTable(table.getId());
|
||||
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
||||
|
@ -642,7 +633,7 @@ public class TableController {
|
|||
public void startDraft(Draft draft) {
|
||||
table.initDraft();
|
||||
DraftManager.getInstance().createDraftSession(draft, userPlayerMap, table.getId());
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
logger.info(new StringBuilder("User ").append(user.getName()).append(" draft started: ").append(draft.getId()).append(" userId: ").append(user.getId()));
|
||||
|
@ -654,7 +645,7 @@ public class TableController {
|
|||
}
|
||||
|
||||
private void sideboard(UUID playerId, Deck deck) throws MageException {
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
if (entry.getValue().equals(playerId)) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||
|
@ -715,8 +706,7 @@ public class TableController {
|
|||
} else {
|
||||
closeTable();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
closeTable();
|
||||
}
|
||||
} catch (GameException ex) {
|
||||
|
@ -729,7 +719,7 @@ public class TableController {
|
|||
table.sideboard();
|
||||
setupTimeout(Match.SIDEBOARD_TIME);
|
||||
if (table.isTournamentSubTable()) {
|
||||
for (MatchPlayer matchPlayer :match.getPlayers()) {
|
||||
for (MatchPlayer matchPlayer : match.getPlayers()) {
|
||||
if (!matchPlayer.hasQuit()) {
|
||||
TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(matchPlayer.getPlayer().getId());
|
||||
if (tournamentPlayer != null) {
|
||||
|
@ -741,7 +731,7 @@ public class TableController {
|
|||
match.sideboard();
|
||||
cancelTimeout();
|
||||
if (table.isTournamentSubTable()) {
|
||||
for (MatchPlayer matchPlayer :match.getPlayers()) {
|
||||
for (MatchPlayer matchPlayer : match.getPlayers()) {
|
||||
TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(matchPlayer.getPlayer().getId());
|
||||
if (tournamentPlayer != null && tournamentPlayer.getStateInfo().equals("sideboarding")) {
|
||||
tournamentPlayer.setStateInfo("");
|
||||
|
@ -749,9 +739,10 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tables of normal matches or tournament sub tables are no longer
|
||||
* needed, if the match ends.
|
||||
* Tables of normal matches or tournament sub tables are no longer needed,
|
||||
* if the match ends.
|
||||
*
|
||||
*/
|
||||
private void closeTable() {
|
||||
|
@ -761,11 +752,11 @@ public class TableController {
|
|||
|
||||
private void matchEnd() {
|
||||
if (match != null) {
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
MatchPlayer matchPlayer = match.getPlayer(entry.getValue());
|
||||
// opponent(s) left during sideboarding
|
||||
if (matchPlayer != null) {
|
||||
if(!matchPlayer.hasQuit()) {
|
||||
if (!matchPlayer.hasQuit()) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
if (table.getState().equals(TableState.SIDEBOARDING)) {
|
||||
|
@ -819,7 +810,7 @@ public class TableController {
|
|||
}
|
||||
|
||||
private void autoSideboard() {
|
||||
for (MatchPlayer player: match.getPlayers()) {
|
||||
for (MatchPlayer player : match.getPlayers()) {
|
||||
if (!player.isDoneSideboarding()) {
|
||||
match.submitDeck(player.getPlayer().getId(), player.generateDeck());
|
||||
}
|
||||
|
@ -828,7 +819,7 @@ public class TableController {
|
|||
|
||||
public void endDraft(Draft draft) {
|
||||
if (!draft.isAbort()) {
|
||||
for (DraftPlayer player: draft.getPlayers()) {
|
||||
for (DraftPlayer player : draft.getPlayers()) {
|
||||
player.prepareDeck();
|
||||
tournament.getPlayer(player.getPlayer().getId()).setDeck(player.getDeck());
|
||||
}
|
||||
|
@ -871,7 +862,7 @@ public class TableController {
|
|||
|
||||
public boolean isTournamentStillValid() {
|
||||
if (table.getTournament() != null) {
|
||||
if (!table.getState().equals(TableState.WAITING) && !table.getState().equals(TableState.READY_TO_START) && !table.getState().equals(TableState.STARTING) ) {
|
||||
if (!table.getState().equals(TableState.WAITING) && !table.getState().equals(TableState.READY_TO_START) && !table.getState().equals(TableState.STARTING)) {
|
||||
TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(table.getTournament().getId());
|
||||
if (tournamentController != null) {
|
||||
return tournamentController.isTournamentStillValid(table.getState());
|
||||
|
@ -888,7 +879,7 @@ public class TableController {
|
|||
}
|
||||
|
||||
public UUID getUserId(UUID playerId) {
|
||||
for (Map.Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Map.Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
if (entry.getValue().equals(playerId)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
|
@ -900,7 +891,7 @@ public class TableController {
|
|||
// check only normal match table with state != Finished
|
||||
if (!table.isTournament()) {
|
||||
int humanPlayers = 0;
|
||||
int aiPlayers = 0 ;
|
||||
int aiPlayers = 0;
|
||||
int validHumanPlayers = 0;
|
||||
if (!(table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.STARTING) || table.getState().equals(TableState.READY_TO_START))) {
|
||||
if (match == null) {
|
||||
|
@ -917,7 +908,7 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
// check for active players
|
||||
for(Map.Entry<UUID, UUID> userPlayerEntry: userPlayerMap.entrySet()) {
|
||||
for (Map.Entry<UUID, UUID> userPlayerEntry : userPlayerMap.entrySet()) {
|
||||
MatchPlayer matchPlayer = match.getPlayer(userPlayerEntry.getValue());
|
||||
if (matchPlayer == null) {
|
||||
logger.debug("- Match player not found:");
|
||||
|
@ -928,11 +919,11 @@ public class TableController {
|
|||
}
|
||||
if (matchPlayer.getPlayer().isHuman()) {
|
||||
humanPlayers++;
|
||||
if ((table.getState().equals(TableState.WAITING) ||
|
||||
table.getState().equals(TableState.STARTING) ||
|
||||
table.getState().equals(TableState.READY_TO_START)) ||
|
||||
!match.isDoneSideboarding() ||
|
||||
(!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
|
||||
if ((table.getState().equals(TableState.WAITING)
|
||||
|| table.getState().equals(TableState.STARTING)
|
||||
|| table.getState().equals(TableState.READY_TO_START))
|
||||
|| !match.isDoneSideboarding()
|
||||
|| (!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
|
||||
User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
|
||||
if (user == null) {
|
||||
logger.debug("- Active user of match is missing: " + matchPlayer.getName());
|
||||
|
@ -956,7 +947,7 @@ public class TableController {
|
|||
|
||||
void cleanUp() {
|
||||
if (!table.isTournamentSubTable()) {
|
||||
for(Map.Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Map.Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
user.removeTable(entry.getValue());
|
||||
|
@ -973,7 +964,7 @@ public class TableController {
|
|||
public synchronized boolean changeTableState(TableState newTableState) {
|
||||
switch (newTableState) {
|
||||
case WAITING:
|
||||
if (getTable().getState().equals(TableState.STARTING)){
|
||||
if (getTable().getState().equals(TableState.STARTING)) {
|
||||
// tournament already started
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ import mage.server.util.SystemUtil;
|
|||
import mage.view.TableClientMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -63,6 +62,7 @@ public class User {
|
|||
private static final Logger logger = Logger.getLogger(User.class);
|
||||
|
||||
public enum UserState {
|
||||
|
||||
Created, Connected, Disconnected, Reconnected, Expired;
|
||||
}
|
||||
|
||||
|
@ -156,15 +156,15 @@ public class User {
|
|||
long secondsLeft;
|
||||
String sign = "";
|
||||
if (secondsDisconnected > (3 * 60)) {
|
||||
sign="-";
|
||||
secondsLeft = secondsDisconnected - (3 *60);
|
||||
sign = "-";
|
||||
secondsLeft = secondsDisconnected - (3 * 60);
|
||||
} else {
|
||||
secondsLeft = (3 * 60) - secondsDisconnected;
|
||||
}
|
||||
|
||||
int minutes = (int) secondsLeft / 60;
|
||||
int seconds = (int) secondsLeft % 60;
|
||||
return new StringBuilder(sign).append(Integer.toString(minutes)).append(":").append(seconds > 9 ? seconds: "0" + Integer.toString(seconds)).toString();
|
||||
return new StringBuilder(sign).append(Integer.toString(minutes)).append(":").append(seconds > 9 ? seconds : "0" + Integer.toString(seconds)).toString();
|
||||
}
|
||||
|
||||
public long getSecondsDisconnected() {
|
||||
|
@ -221,7 +221,7 @@ public class User {
|
|||
List<String> messageData = new LinkedList<>();
|
||||
messageData.add(titel);
|
||||
messageData.add(message);
|
||||
fireCallback(new ClientCallback("showUserMessage", null, messageData ));
|
||||
fireCallback(new ClientCallback("showUserMessage", null, messageData));
|
||||
}
|
||||
|
||||
public boolean ccWatchGame(final UUID gameId) {
|
||||
|
@ -276,13 +276,14 @@ public class User {
|
|||
}
|
||||
logger.trace(new StringBuilder("isExpired: User ").append(userName).append(" lastActivity: ").append(lastActivity).append(" expired: ").append(expired).toString());
|
||||
return false; /*userState == UserState.Disconnected && */
|
||||
|
||||
}
|
||||
|
||||
private void reconnect() {
|
||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||
for (Entry<UUID, Table> entry : tables.entrySet()) {
|
||||
ccJoinedTable(entry.getValue().getRoomId(), entry.getValue().getId(), entry.getValue().isTournament());
|
||||
}
|
||||
for (Entry<UUID, UUID> entry: userTournaments.entrySet()) {
|
||||
for (Entry<UUID, UUID> entry : userTournaments.entrySet()) {
|
||||
TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(entry.getValue());
|
||||
if (tournamentController != null) {
|
||||
ccTournamentStarted(entry.getValue(), entry.getKey());
|
||||
|
@ -290,22 +291,22 @@ public class User {
|
|||
}
|
||||
}
|
||||
|
||||
for (Entry<UUID, GameSessionPlayer> entry: gameSessions.entrySet()) {
|
||||
for (Entry<UUID, GameSessionPlayer> entry : gameSessions.entrySet()) {
|
||||
ccGameStarted(entry.getValue().getGameId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
GameManager.getInstance().sendPlayerString(entry.getValue().getGameId(), userId, "");
|
||||
}
|
||||
|
||||
for (Entry<UUID, DraftSession> entry: draftSessions.entrySet()) {
|
||||
for (Entry<UUID, DraftSession> entry : draftSessions.entrySet()) {
|
||||
ccDraftStarted(entry.getValue().getDraftId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
entry.getValue().update();
|
||||
}
|
||||
|
||||
for (Entry<UUID, TournamentSession> entry: constructing.entrySet()) {
|
||||
for (Entry<UUID, TournamentSession> entry : constructing.entrySet()) {
|
||||
entry.getValue().construct(0); // TODO: Check if this is correct
|
||||
}
|
||||
for (Entry<UUID, Deck> entry: sideboarding.entrySet()) {
|
||||
for (Entry<UUID, Deck> entry : sideboarding.entrySet()) {
|
||||
TableController controller = TableManager.getInstance().getController(entry.getKey());
|
||||
ccSideboard(entry.getValue(), entry.getKey(), controller.getRemainingTime(), controller.getOptions().isLimited());
|
||||
}
|
||||
|
@ -357,30 +358,30 @@ public class User {
|
|||
|
||||
public void remove(DisconnectReason reason) {
|
||||
logger.trace("REMOVE " + getName() + " Draft sessions " + draftSessions.size());
|
||||
for (DraftSession draftSession: draftSessions.values()) {
|
||||
for (DraftSession draftSession : draftSessions.values()) {
|
||||
draftSession.setKilled();
|
||||
}
|
||||
draftSessions.clear();
|
||||
logger.trace("REMOVE " + getName() + " Tournament sessions " + userTournaments.size());
|
||||
for (UUID tournamentId: userTournaments.values()) {
|
||||
for (UUID tournamentId : userTournaments.values()) {
|
||||
TournamentManager.getInstance().quit(tournamentId, getId());
|
||||
}
|
||||
userTournaments.clear();
|
||||
logger.trace("REMOVE " + getName() + " Tables " + tables.size());
|
||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||
for (Entry<UUID, Table> entry : tables.entrySet()) {
|
||||
logger.debug("-- leave tableId: " + entry.getValue().getId());
|
||||
TableManager.getInstance().leaveTable(userId, entry.getValue().getId());
|
||||
}
|
||||
tables.clear();
|
||||
logger.trace("REMOVE " + getName() + " Game sessions: " + gameSessions.size() );
|
||||
for (GameSessionPlayer gameSessionPlayer: gameSessions.values()) {
|
||||
logger.debug("-- kill game session of gameId: " + gameSessionPlayer.getGameId() );
|
||||
logger.trace("REMOVE " + getName() + " Game sessions: " + gameSessions.size());
|
||||
for (GameSessionPlayer gameSessionPlayer : gameSessions.values()) {
|
||||
logger.debug("-- kill game session of gameId: " + gameSessionPlayer.getGameId());
|
||||
GameManager.getInstance().quitMatch(gameSessionPlayer.getGameId(), userId);
|
||||
gameSessionPlayer.quitGame();
|
||||
}
|
||||
gameSessions.clear();
|
||||
logger.trace("REMOVE " + getName() + " watched Games " + watchedGames.size());
|
||||
for (UUID gameId: watchedGames) {
|
||||
for (UUID gameId : watchedGames) {
|
||||
GameManager.getInstance().stopWatching(gameId, userId);
|
||||
}
|
||||
watchedGames.clear();
|
||||
|
@ -389,10 +390,17 @@ public class User {
|
|||
}
|
||||
|
||||
public void setUserData(UserData userData) {
|
||||
if (this.userData != null) {
|
||||
this.userData.update(userData);
|
||||
} else {
|
||||
this.userData = userData;
|
||||
}
|
||||
}
|
||||
|
||||
public UserData getUserData() {
|
||||
if (userData == null) {// default these to avaiod NPE -> will be updated from client short after
|
||||
return UserData.getDefaultUserDataView();
|
||||
}
|
||||
return this.userData;
|
||||
}
|
||||
|
||||
|
@ -428,7 +436,7 @@ public class User {
|
|||
}
|
||||
|
||||
if (!isConnected()) {
|
||||
tournamentPlayer.setDisconnectInfo(" (discon. "+ getDisconnectDuration() + ")");
|
||||
tournamentPlayer.setDisconnectInfo(" (discon. " + getDisconnectDuration() + ")");
|
||||
} else {
|
||||
tournamentPlayer.setDisconnectInfo("");
|
||||
}
|
||||
|
@ -460,7 +468,7 @@ public class User {
|
|||
}
|
||||
}
|
||||
if (!tablesToDelete.isEmpty()) {
|
||||
for(UUID keyId: tablesToDelete) {
|
||||
for (UUID keyId : tablesToDelete) {
|
||||
removeTable(keyId);
|
||||
}
|
||||
tablesToDelete.clear();
|
||||
|
@ -513,7 +521,7 @@ public class User {
|
|||
if (isConnected()) {
|
||||
return pingInfo;
|
||||
} else {
|
||||
return " (discon. "+ getDisconnectDuration() + ")";
|
||||
return " (discon. " + getDisconnectDuration() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.server.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -76,7 +75,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
public GamesRoomImpl() {
|
||||
updateExecutor.scheduleAtFixedRate(new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
public void run() {
|
||||
try {
|
||||
update();
|
||||
} catch (Exception ex) {
|
||||
|
@ -97,11 +96,10 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
ArrayList<MatchView> matchList = new ArrayList<>();
|
||||
List<Table> allTables = new ArrayList<>(tables.values());
|
||||
Collections.sort(allTables, new TableListSorter());
|
||||
for (Table table: allTables) {
|
||||
for (Table table : allTables) {
|
||||
if (table.getState() != TableState.FINISHED) {
|
||||
tableList.add(new TableView(table));
|
||||
}
|
||||
else if (matchList.size() < 50) {
|
||||
} else if (matchList.size() < 50) {
|
||||
if (table.isTournament()) {
|
||||
matchList.add(new MatchView(table));
|
||||
} else {
|
||||
|
@ -123,7 +121,12 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
users.add(new UsersView(user.getUserData().getFlagName(), user.getName(), user.getInfo(), user.getGameInfo(), user.getPingInfo()));
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("User update exception: " + user.getName() + " - " + ex.toString(), ex);
|
||||
users.add(new UsersView(user.getUserData().getFlagName(), user.getName(), user.getInfo(), "[exception]", user.getPingInfo()));
|
||||
users.add(new UsersView(
|
||||
(user.getUserData() != null && user.getUserData().getFlagName() != null) ? user.getUserData().getFlagName() : "world",
|
||||
user.getName() != null ? user.getName() : "<no name>",
|
||||
user.getInfo() != null ? user.getInfo() : "<no info>",
|
||||
"[exception]",
|
||||
user.getPingInfo() != null ? user.getPingInfo() : "<no ping>"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,14 +225,15 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
* @author LevelX2
|
||||
*/
|
||||
class TableListSorter implements Comparator<Table> {
|
||||
|
||||
@Override
|
||||
public int compare(Table one, Table two) {
|
||||
if (!one.getState().equals(TableState.SIDEBOARDING) && !one.getState().equals(TableState.DUELING)) {
|
||||
if (one.getState().compareTo(two.getState()) != 0 ) {
|
||||
if (one.getState().compareTo(two.getState()) != 0) {
|
||||
return one.getState().compareTo(two.getState());
|
||||
}
|
||||
} else if (!two.getState().equals(TableState.SIDEBOARDING) && !two.getState().equals(TableState.DUELING)) {
|
||||
if (one.getState().compareTo(two.getState()) != 0 ) {
|
||||
if (one.getState().compareTo(two.getState()) != 0) {
|
||||
return one.getState().compareTo(two.getState());
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +263,7 @@ class TableListSorter implements Comparator<Table> {
|
|||
}
|
||||
|
||||
class UserNameSorter implements Comparator<UsersView> {
|
||||
|
||||
@Override
|
||||
public int compare(UsersView one, UsersView two) {
|
||||
return one.getUserName().compareToIgnoreCase(two.getUserName());
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.server.tournament;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
@ -63,7 +62,6 @@ import mage.view.ChatMessage.SoundToPlay;
|
|||
import mage.view.TournamentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -89,7 +87,7 @@ public class TournamentController {
|
|||
|
||||
private void init() {
|
||||
tournament.addTableEventListener(
|
||||
new Listener<TableEvent> () {
|
||||
new Listener<TableEvent>() {
|
||||
@Override
|
||||
public void event(TableEvent event) {
|
||||
switch (event.getEventType()) {
|
||||
|
@ -124,7 +122,7 @@ public class TournamentController {
|
|||
}
|
||||
);
|
||||
tournament.addPlayerQueryEventListener(
|
||||
new Listener<PlayerQueryEvent> () {
|
||||
new Listener<PlayerQueryEvent>() {
|
||||
@Override
|
||||
public void event(PlayerQueryEvent event) {
|
||||
try {
|
||||
|
@ -139,7 +137,7 @@ public class TournamentController {
|
|||
}
|
||||
}
|
||||
);
|
||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
||||
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||
if (!player.getPlayer().isHuman()) {
|
||||
player.setJoined();
|
||||
logger.debug("player " + player.getPlayer().getId() + " has joined tournament " + tournament.getId());
|
||||
|
@ -172,7 +170,7 @@ public class TournamentController {
|
|||
user.addTournament(playerId, tournament.getId());
|
||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||
player.setJoined();
|
||||
logger.debug("player " +player.getPlayer().getName() + " - client has joined tournament " + tournament.getId());
|
||||
logger.debug("player " + player.getPlayer().getName() + " - client has joined tournament " + tournament.getId());
|
||||
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getLogName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS);
|
||||
checkStart();
|
||||
} else {
|
||||
|
@ -209,7 +207,7 @@ public class TournamentController {
|
|||
if (!tournament.allJoined()) {
|
||||
return false;
|
||||
}
|
||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
||||
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||
if (player.getPlayer().isHuman() && tournamentSessions.get(player.getPlayer().getId()) == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -218,7 +216,7 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
private synchronized void startTournament() {
|
||||
for (final TournamentSession tournamentSession: tournamentSessions.values()) {
|
||||
for (final TournamentSession tournamentSession : tournamentSessions.values()) {
|
||||
if (!tournamentSession.init()) {
|
||||
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
|
||||
//TODO: generate client error message
|
||||
|
@ -231,10 +229,10 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
private void endTournament() {
|
||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
||||
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||
player.setStateAtTournamentEnd();
|
||||
}
|
||||
for (final TournamentSession tournamentSession: tournamentSessions.values()) {
|
||||
for (final TournamentSession tournamentSession : tournamentSessions.values()) {
|
||||
tournamentSession.tournamentOver();
|
||||
}
|
||||
this.tournamentSessions.clear();
|
||||
|
@ -387,7 +385,7 @@ public class TournamentController {
|
|||
private boolean checkToReplaceDraftPlayerByAi(UUID userId, TournamentPlayer leavingPlayer) {
|
||||
|
||||
int humans = 0;
|
||||
for (TournamentPlayer tPlayer :tournament.getPlayers()) {
|
||||
for (TournamentPlayer tPlayer : tournament.getPlayers()) {
|
||||
if (tPlayer.getPlayer().isHuman()) {
|
||||
humans++;
|
||||
}
|
||||
|
@ -415,7 +413,7 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
private UUID getPlayerUserId(UUID playerId) {
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
if (entry.getValue().equals(playerId)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
|
@ -437,7 +435,7 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
private void checkPlayersState() {
|
||||
for (TournamentPlayer tournamentPlayer: tournament.getPlayers()) {
|
||||
for (TournamentPlayer tournamentPlayer : tournament.getPlayers()) {
|
||||
if (!tournamentPlayer.isEliminated() && tournamentPlayer.getPlayer().isHuman()) {
|
||||
if (tournamentSessions.containsKey(tournamentPlayer.getPlayer().getId())) {
|
||||
if (tournamentSessions.get(tournamentPlayer.getPlayer().getId()).isKilled()) {
|
||||
|
@ -458,16 +456,16 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check tournaments that are not already finished, if they are in a still valid state
|
||||
* Check tournaments that are not already finished, if they are in a still
|
||||
* valid state
|
||||
*
|
||||
* @param tableState state of the tournament table
|
||||
* @return true - if tournament is valid
|
||||
* false - if tournament is not valid and should be removed
|
||||
* @return true - if tournament is valid false - if tournament is not valid
|
||||
* and should be removed
|
||||
*/
|
||||
|
||||
public boolean isTournamentStillValid(TableState tableState) {
|
||||
int activePlayers = 0;
|
||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
TournamentPlayer tournamentPlayer = tournament.getPlayer(entry.getValue());
|
||||
if (tournamentPlayer != null) {
|
||||
if (!tournamentPlayer.hasQuit()) {
|
||||
|
@ -487,7 +485,7 @@ public class TournamentController {
|
|||
logger.debug("Tournament player is missing - tournamentId: " + tournament.getId() + " state: " + tableState.toString());
|
||||
}
|
||||
}
|
||||
for(TournamentPlayer tournamentPlayer: tournament.getPlayers()) {
|
||||
for (TournamentPlayer tournamentPlayer : tournament.getPlayers()) {
|
||||
if (!tournamentPlayer.getPlayer().isHuman()) {
|
||||
if (!tournamentPlayer.hasQuit()) {
|
||||
activePlayers++;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.mage</groupId>
|
||||
|
|
|
@ -99,7 +99,7 @@ class ArsenalThresherEffect extends OneShotEffect {
|
|||
Permanent arsenalThresher = game.getPermanent(source.getSourceId());
|
||||
FilterArtifactCard filter = new FilterArtifactCard();
|
||||
filter.add(new AnotherCardPredicate());
|
||||
if (you.chooseUse(Outcome.Benefit, "Do you want to reveal other artifacts in your hand?", game)) {
|
||||
if (you.chooseUse(Outcome.Benefit, "Do you want to reveal other artifacts in your hand?", source, game)) {
|
||||
Cards cards = new CardsImpl();
|
||||
if (you.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
|
||||
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
|
||||
|
|
|
@ -111,7 +111,7 @@ class EtherwroughtPageEffect extends OneShotEffect {
|
|||
CardsImpl cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
controller.lookAtCards("Etherwrought Page", cards, game);
|
||||
if (controller.chooseUse(Outcome.Neutral, "Do you wish to put the card into your graveyard?", game)) {
|
||||
if (controller.chooseUse(Outcome.Neutral, "Do you wish to put the card into your graveyard?", source, game)) {
|
||||
return controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -139,7 +139,7 @@ class SovereignsOfLostAlaraEffect extends OneShotEffect {
|
|||
FilterCard filter = new FilterCard("aura that could enchant the lone attacking creature");
|
||||
filter.add(new SubtypePredicate("Aura"));
|
||||
filter.add(new AuraCardCanAttachToPermanentId(attackingCreature.getId()));
|
||||
if (you.chooseUse(Outcome.Benefit, "Do you want to search your library?", game)) {
|
||||
if (you.chooseUse(Outcome.Benefit, "Do you want to search your library?", source, game)) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
target.setNotTarget(true);
|
||||
if (you.searchLibrary(target, game)) {
|
||||
|
|
|
@ -104,7 +104,7 @@ class VectisDominatorEffect extends OneShotEffect {
|
|||
if (player != null) {
|
||||
cost.clearPaid();
|
||||
final StringBuilder sb = new StringBuilder("Pay 2 life? (Otherwise ").append(targetCreature.getName()).append(" will be tapped)");
|
||||
if (player.chooseUse(Outcome.Benefit, sb.toString(), game)) {
|
||||
if (player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
|
||||
cost.pay(source, game, targetCreature.getControllerId(), targetCreature.getControllerId(), true);
|
||||
}
|
||||
if (!cost.isPaid()) {
|
||||
|
|
|
@ -39,9 +39,9 @@ import mage.constants.Rarity;
|
|||
*
|
||||
* @author Sir-Speshkitty
|
||||
*/
|
||||
public class AesthirGlider extends CardImpl {
|
||||
public class AesthirGlider1 extends CardImpl {
|
||||
|
||||
public AesthirGlider(UUID ownerId) {
|
||||
public AesthirGlider1(UUID ownerId) {
|
||||
super(ownerId, 156, "Aesthir Glider", Rarity.COMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}");
|
||||
this.expansionSetCode = "ALL";
|
||||
this.subtype.add("Bird");
|
||||
|
@ -54,12 +54,12 @@ public class AesthirGlider extends CardImpl {
|
|||
this.addAbility(new CantBlockAbility());
|
||||
}
|
||||
|
||||
public AesthirGlider(final AesthirGlider card) {
|
||||
public AesthirGlider1(final AesthirGlider1 card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AesthirGlider copy() {
|
||||
return new AesthirGlider(this);
|
||||
public AesthirGlider1 copy() {
|
||||
return new AesthirGlider1(this);
|
||||
}
|
||||
}
|
52
Mage.Sets/src/mage/sets/alliances/AesthirGlider2.java
Normal file
52
Mage.Sets/src/mage/sets/alliances/AesthirGlider2.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.sets.alliances;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class AesthirGlider2 extends mage.sets.alliances.AesthirGlider1 {
|
||||
|
||||
public AesthirGlider2(UUID ownerId) {
|
||||
super(ownerId);
|
||||
this.cardNumber = 157;
|
||||
this.expansionSetCode = "ALL";
|
||||
}
|
||||
|
||||
public AesthirGlider2(final AesthirGlider2 card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AesthirGlider2 copy() {
|
||||
return new AesthirGlider2(this);
|
||||
}
|
||||
}
|
|
@ -53,9 +53,9 @@ import mage.target.common.TargetControlledPermanent;
|
|||
*
|
||||
* @author Quercitron
|
||||
*/
|
||||
public class SoldeviSage extends CardImpl {
|
||||
public class SoldeviSage1 extends CardImpl {
|
||||
|
||||
public SoldeviSage(UUID ownerId) {
|
||||
public SoldeviSage1(UUID ownerId) {
|
||||
super(ownerId, 51, "Soldevi Sage", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{U}");
|
||||
this.expansionSetCode = "ALL";
|
||||
this.subtype.add("Human");
|
||||
|
@ -70,13 +70,13 @@ public class SoldeviSage extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public SoldeviSage(final SoldeviSage card) {
|
||||
public SoldeviSage1(final SoldeviSage1 card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoldeviSage copy() {
|
||||
return new SoldeviSage(this);
|
||||
public SoldeviSage1 copy() {
|
||||
return new SoldeviSage1(this);
|
||||
}
|
||||
}
|
||||
|
52
Mage.Sets/src/mage/sets/alliances/SoldeviSage2.java
Normal file
52
Mage.Sets/src/mage/sets/alliances/SoldeviSage2.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.sets.alliances;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class SoldeviSage2 extends mage.sets.alliances.SoldeviSage1 {
|
||||
|
||||
public SoldeviSage2(UUID ownerId) {
|
||||
super(ownerId);
|
||||
this.cardNumber = 52;
|
||||
this.expansionSetCode = "ALL";
|
||||
}
|
||||
|
||||
public SoldeviSage2(final SoldeviSage2 card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoldeviSage2 copy() {
|
||||
return new SoldeviSage2(this);
|
||||
}
|
||||
}
|
|
@ -106,7 +106,7 @@ class PutLandOnBattlefieldEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null || !player.chooseUse(Outcome.PutLandInPlay, choiceText, game)) {
|
||||
if (player == null || !player.chooseUse(Outcome.PutLandInPlay, choiceText, source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,27 +29,18 @@ package mage.sets.apocalypse;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsDamageToACreatureTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.RegenerateSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesColorTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesColorSourceEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -70,7 +61,7 @@ public class Spiritmonger extends CardImpl {
|
|||
// {B}: Regenerate Spiritmonger.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{B}")));
|
||||
// {G}: Spiritmonger becomes the color of your choice until end of turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new SpiritmongerChangeColorEffect(), new ManaCostsImpl("{G}")));
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesColorSourceEffect(Duration.EndOfTurn), new ManaCostsImpl("{G}")));
|
||||
}
|
||||
|
||||
public Spiritmonger(final Spiritmonger card) {
|
||||
|
@ -82,37 +73,3 @@ public class Spiritmonger extends CardImpl {
|
|||
return new Spiritmonger(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SpiritmongerChangeColorEffect extends OneShotEffect {
|
||||
|
||||
public SpiritmongerChangeColorEffect() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "{this} becomes the color of your choice until end of turn";
|
||||
}
|
||||
|
||||
public SpiritmongerChangeColorEffect(final SpiritmongerChangeColorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent wildMongrel = game.getPermanent(source.getSourceId());
|
||||
if (player != null && wildMongrel != null) {
|
||||
ChoiceColor colorChoice = new ChoiceColor();
|
||||
if (player.choose(Outcome.Neutral, colorChoice, game)) {
|
||||
game.informPlayers(wildMongrel.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
|
||||
ContinuousEffect effect = new BecomesColorTargetEffect(colorChoice.getColor(), Duration.EndOfTurn, "is " + colorChoice.getChoice());
|
||||
effect.setTargetPointer(new FixedTarget(source.getSourceId()));
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiritmongerChangeColorEffect copy() {
|
||||
return new SpiritmongerChangeColorEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
while (player.isInGame() && player.chooseUse(Outcome.Benefit, "Attach an Aura from the battlefield?", game)) {
|
||||
while (player.isInGame() && player.chooseUse(Outcome.Benefit, "Attach an Aura from the battlefield?", source, game)) {
|
||||
Target targetAura = new TargetPermanent(filterAura);
|
||||
if (player.choose(Outcome.Benefit, targetAura, source.getSourceId(), game)) {
|
||||
Permanent aura = game.getPermanent(targetAura.getFirstTarget());
|
||||
|
@ -137,7 +137,7 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
int count = player.getHand().count(filterAuraCard, game);
|
||||
while (player.isInGame() && count > 0 && player.chooseUse(Outcome.Benefit, "Attach an Aura from your hand?", game)) {
|
||||
while (player.isInGame() && count > 0 && player.chooseUse(Outcome.Benefit, "Attach an Aura from your hand?", source, game)) {
|
||||
TargetCard targetAura = new TargetCard(Zone.PICK, filterAuraCard);
|
||||
if (player.choose(Outcome.Benefit, player.getHand(), targetAura, game)) {
|
||||
Card aura = game.getCard(targetAura.getFirstTarget());
|
||||
|
@ -151,7 +151,7 @@ class BrunaLightOfAlabasterEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
count = player.getGraveyard().count(filterAuraCard, game);
|
||||
while (player.isInGame() && count > 0 && player.chooseUse(Outcome.Benefit, "Attach an Aura from your graveyard?", game)) {
|
||||
while (player.isInGame() && count > 0 && player.chooseUse(Outcome.Benefit, "Attach an Aura from your graveyard?", source, game)) {
|
||||
TargetCard targetAura = new TargetCard(Zone.PICK, filterAuraCard);
|
||||
if (player.choose(Outcome.Benefit, player.getGraveyard(), targetAura, game)) {
|
||||
Card aura = game.getCard(targetAura.getFirstTarget());
|
||||
|
|
|
@ -110,7 +110,7 @@ class DescendantsPathEffect extends OneShotEffect {
|
|||
}
|
||||
if (found) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": Found a creature that shares a creature type with the revealed card.");
|
||||
if (controller.chooseUse(Outcome.Benefit, "Cast the card?", game)) {
|
||||
if (controller.chooseUse(Outcome.Benefit, "Cast the card?", source, game)) {
|
||||
controller.cast(card.getSpellAbility(), game, true);
|
||||
} else {
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " canceled casting the card.");
|
||||
|
|
|
@ -105,7 +105,7 @@ class FettergeistUnlessPaysEffect extends OneShotEffect {
|
|||
if (count == 0) {
|
||||
return true;
|
||||
}
|
||||
if (player.chooseUse(Outcome.Benefit, "Pay " + count + "?", game)) {
|
||||
if (player.chooseUse(Outcome.Benefit, "Pay " + count + "?", source, game)) {
|
||||
GenericManaCost cost = new GenericManaCost(count);
|
||||
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
|
||||
return true;
|
||||
|
|
|
@ -29,17 +29,17 @@ package mage.sets.avacynrestored;
|
|||
|
||||
import mage.constants.*;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksEachTurnStaticAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.combat.AttacksIfAbleAttachedEffect;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
|
@ -51,7 +51,6 @@ public class GuiseOfFire extends CardImpl {
|
|||
this.expansionSetCode = "AVR";
|
||||
this.subtype.add("Aura");
|
||||
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
|
@ -60,8 +59,12 @@ public class GuiseOfFire extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Enchanted creature gets +1/-1 and attacks each turn if able.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, -1, Duration.WhileOnBattlefield)));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new AttacksEachTurnStaticAbility(), AttachmentType.AURA)));
|
||||
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, -1, Duration.WhileOnBattlefield));
|
||||
Effect effect = new AttacksIfAbleAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.AURA);
|
||||
effect.setText("and attacks each turn if able");
|
||||
ability.addEffect(effect);
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
||||
public GuiseOfFire(final GuiseOfFire card) {
|
||||
|
|
|
@ -106,7 +106,7 @@ class KillingWaveEffect extends OneShotEffect {
|
|||
int playerLife = player.getLife();
|
||||
for (Permanent creature : creatures) {
|
||||
String message = "Pay " + amount + " life? If you don't, " + creature.getName() + " will be sacrificed.";
|
||||
if (playerLife - amount - lifePaid >= 0 && player != null && player.chooseUse(Outcome.Neutral, message, game)) {
|
||||
if (playerLife - amount - lifePaid >= 0 && player != null && player.chooseUse(Outcome.Neutral, message, source, game)) {
|
||||
game.informPlayers(player.getLogName() + " pays " + amount + " life. He will not sacrifice " + creature.getName());
|
||||
lifePaid += amount;
|
||||
} else {
|
||||
|
|
|
@ -100,7 +100,7 @@ class PrimalSurgeEffect extends OneShotEffect {
|
|||
if ((cardType.contains(CardType.ARTIFACT) || cardType.contains(CardType.CREATURE)
|
||||
|| cardType.contains(CardType.ENCHANTMENT) || cardType.contains(CardType.LAND)
|
||||
|| cardType.contains(CardType.PLANESWALKER))
|
||||
&& player.chooseUse(Outcome.PutCardInPlay, "Put " + card.getName() + " onto the battlefield?", game)) {
|
||||
&& player.chooseUse(Outcome.PutCardInPlay, "Put " + card.getName() + " onto the battlefield?", source, game)) {
|
||||
card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
|
||||
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
|
|
|
@ -32,7 +32,7 @@ import mage.constants.Rarity;
|
|||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterEnchantment;
|
||||
import mage.filter.common.FilterEnchantmentPermanent;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetArtifactPermanent;
|
||||
|
@ -59,7 +59,7 @@ public class RainOfThorns extends CardImpl {
|
|||
|
||||
Mode mode1 = new Mode();
|
||||
mode1.getEffects().add(new DestroyTargetEffect());
|
||||
mode1.getTargets().add(new TargetPermanent(new FilterEnchantment()));
|
||||
mode1.getTargets().add(new TargetPermanent(new FilterEnchantmentPermanent()));
|
||||
this.getSpellAbility().addMode(mode1);
|
||||
|
||||
Mode mode2 = new Mode();
|
||||
|
|
|
@ -89,7 +89,7 @@ class VexingDevilEffect extends OneShotEffect {
|
|||
if (controller != null && permanent != null) {
|
||||
for (UUID opponentUuid : game.getOpponents(source.getControllerId())) {
|
||||
Player opponent = game.getPlayer(opponentUuid);
|
||||
if (opponent != null && opponent.chooseUse(Outcome.LoseLife, "Make " + permanent.getLogName() + " deal 4 damage to you?", game)) {
|
||||
if (opponent != null && opponent.chooseUse(Outcome.LoseLife, "Make " + permanent.getLogName() + " deal 4 damage to you?", source, game)) {
|
||||
game.informPlayers(opponent.getLogName() + " has chosen to receive 4 damage from " + permanent.getLogName());
|
||||
opponent.damage(4, permanent.getId(), game, false, true);
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
|
|
|
@ -113,7 +113,7 @@ class IwamoriOfTheOpenFistEffect extends OneShotEffect {
|
|||
Player opponent = game.getPlayer(playerId);
|
||||
Target target = new TargetCardInHand(filter);
|
||||
if (opponent != null && target.canChoose(source.getSourceId(), opponent.getId(), game)) {
|
||||
if (opponent.chooseUse(Outcome.PutCreatureInPlay, "Put a legendary creature card from your hand onto the battlefield?", game)) {
|
||||
if (opponent.chooseUse(Outcome.PutCreatureInPlay, "Put a legendary creature card from your hand onto the battlefield?", source, game)) {
|
||||
if (target.chooseTarget(Outcome.PutCreatureInPlay, opponent.getId(), source, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
|
|
|
@ -99,7 +99,7 @@ class OgreMarauderEffect extends OneShotEffect {
|
|||
if (defender != null && sourceObject != null) {
|
||||
Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
|
||||
if (cost.canPay(source, source.getSourceId(), defendingPlayerId, game) &&
|
||||
defender.chooseUse(Outcome.LoseAbility, "Sacrifice a creature to prevent that " + sourceObject.getLogName() + " can't be blocked?", game)) {
|
||||
defender.chooseUse(Outcome.LoseAbility, "Sacrifice a creature to prevent that " + sourceObject.getLogName() + " can't be blocked?", source, game)) {
|
||||
if (!cost.pay(source, game, source.getSourceId(), defendingPlayerId, false)) {
|
||||
// cost was not payed - so source can't be blocked
|
||||
ContinuousEffect effect = new CantBeBlockedSourceEffect(Duration.EndOfTurn);
|
||||
|
|
|
@ -90,9 +90,9 @@ public class ToilsOfNightAndDay extends CardImpl {
|
|||
for (UUID targetId : source.getTargets().get(0).getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
if (player.chooseUse(Outcome.Tap, new StringBuilder("Tap ").append(permanent.getName()).append("?").toString(), game)) {
|
||||
if (player.chooseUse(Outcome.Tap, new StringBuilder("Tap ").append(permanent.getName()).append("?").toString(), source, game)) {
|
||||
permanent.tap(game);
|
||||
} else if (player.chooseUse(Outcome.Untap, new StringBuilder("Untap ").append(permanent.getName()).append("?").toString(), game)) {
|
||||
} else if (player.chooseUse(Outcome.Untap, new StringBuilder("Untap ").append(permanent.getName()).append("?").toString(), source, game)) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class ArbiterOfTheIdealEffect extends OneShotEffect {
|
|||
player.revealCards("Arbiter of the Ideal", cards, game);
|
||||
|
||||
if (card != null) {
|
||||
if (filter.match(card, game) && player.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append("onto battlefield?").toString(), game)) {
|
||||
if (filter.match(card, game) && player.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append("onto battlefield?").toString(), source, game)) {
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
|
|
|
@ -32,7 +32,9 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.ReturnToHandTargetPermanentCost;
|
||||
import mage.abilities.effects.PayCostToAttackBlockEffectImpl;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.combat.CantAttackBlockUnlessPaysSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
|
@ -53,6 +55,12 @@ import mage.target.common.TargetControlledPermanent;
|
|||
*/
|
||||
public class FloodtideSerpent extends CardImpl {
|
||||
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("an enchantment you control");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
}
|
||||
|
||||
public FloodtideSerpent(UUID ownerId) {
|
||||
super(ownerId, 41, "Floodtide Serpent", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}");
|
||||
this.expansionSetCode = "BNG";
|
||||
|
@ -62,8 +70,8 @@ public class FloodtideSerpent extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// Floodtide Serpent can't attack unless you return an enchantment you control to its owner's hand <i>(This cost is paid as attackers are declared.)</i>
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new FloodtideSerpentReplacementEffect()));
|
||||
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackBlockUnlessPaysSourceEffect(
|
||||
new ReturnToHandTargetPermanentCost(new TargetControlledPermanent(filter)), PayCostToAttackBlockEffectImpl.RestrictType.ATTACK)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,24 +93,23 @@ class FloodtideSerpentReplacementEffect extends ReplacementEffectImpl {
|
|||
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
}
|
||||
|
||||
FloodtideSerpentReplacementEffect ( ) {
|
||||
FloodtideSerpentReplacementEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
||||
staticText = "{this} can't attack unless you return an enchantment you control to its owner's hand <i>(This cost is paid as attackers are declared.)</i>";
|
||||
}
|
||||
|
||||
FloodtideSerpentReplacementEffect ( FloodtideSerpentReplacementEffect effect ) {
|
||||
FloodtideSerpentReplacementEffect(FloodtideSerpentReplacementEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player player = game.getPlayer(event.getPlayerId());
|
||||
if ( player != null ) {
|
||||
if (player != null) {
|
||||
ReturnToHandTargetPermanentCost attackCost = new ReturnToHandTargetPermanentCost(new TargetControlledPermanent(filter));
|
||||
if ( attackCost.canPay(source, source.getSourceId(), event.getPlayerId(), game) &&
|
||||
player.chooseUse(Outcome.Neutral, "Return an enchantment you control to hand to attack?", game) )
|
||||
{
|
||||
if (attackCost.pay(source, game, source.getSourceId(), event.getPlayerId(), true) ) {
|
||||
if (attackCost.canPay(source, source.getSourceId(), event.getPlayerId(), game)
|
||||
&& player.chooseUse(Outcome.Neutral, "Return an enchantment you control to hand to attack?", source, game)) {
|
||||
if (attackCost.pay(source, game, source.getSourceId(), event.getPlayerId(), true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +123,6 @@ class FloodtideSerpentReplacementEffect extends ReplacementEffectImpl {
|
|||
return event.getType() == EventType.DECLARE_ATTACKER;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getSourceId().equals(source.getSourceId());
|
||||
|
|
|
@ -95,7 +95,7 @@ class HeroOfLeinaTowerEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
ManaCosts cost = new ManaCostsImpl("{X}");
|
||||
if (you != null && you.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", game)) {
|
||||
if (you != null && you.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", source, game)) {
|
||||
int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
|
||||
cost.add(new GenericManaCost(costX));
|
||||
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
|
||||
|
|
|
@ -171,7 +171,7 @@ class HeroesPodiumEffect extends OneShotEffect {
|
|||
player.lookAtCards("Heroes' Podium", cards, game);
|
||||
|
||||
// You may reveal a legendary creature card from among them and put it into your hand.
|
||||
if (!cards.isEmpty() && legendaryIncluded && player.chooseUse(outcome, "Put a legendary creature card into your hand?", game)) {
|
||||
if (!cards.isEmpty() && legendaryIncluded && player.chooseUse(outcome, "Put a legendary creature card into your hand?", source, game)) {
|
||||
if (cards.size() == 1) {
|
||||
Card card = cards.getRandom(game);
|
||||
cards.remove(card);
|
||||
|
|
|
@ -127,7 +127,7 @@ class DoUnlessTargetPaysCost extends OneShotEffect {
|
|||
}
|
||||
message = CardUtil.replaceSourceName(message, mageObject.getLogName());
|
||||
cost.clearPaid();
|
||||
if (cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(executingEffect.getOutcome(), message, game)) {
|
||||
if (cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(executingEffect.getOutcome(), message, source, game)) {
|
||||
cost.pay(source, game, source.getSourceId(), player.getId(), false);
|
||||
}
|
||||
if (!cost.isPaid()) {
|
||||
|
|
|
@ -108,7 +108,7 @@ class OracleOfBonesCastEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Target target = new TargetCardInHand(filter);
|
||||
if (target.canChoose(source.getSourceId(), controller.getId(), game) &&
|
||||
controller.chooseUse(outcome, "Cast an instant or sorcery card from your hand without paying its mana cost?", game)) {
|
||||
controller.chooseUse(outcome, "Cast an instant or sorcery card from your hand without paying its mana cost?", source, game)) {
|
||||
Card cardToCast = null;
|
||||
boolean cancel = false;
|
||||
while (controller.isInGame() && !cancel) {
|
||||
|
|
|
@ -104,7 +104,7 @@ class SatyrWayfinderEffect extends OneShotEffect {
|
|||
controller.revealCards(sourceObject.getName(), cards, game);
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand);
|
||||
if (properCardFound &&
|
||||
controller.chooseUse(outcome, "Put a land card into your hand?", game) &&
|
||||
controller.chooseUse(outcome, "Put a land card into your hand?", source, game) &&
|
||||
controller.choose(Outcome.DrawCard, cards, target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue