mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
Some changes to userData handling. Added country flag to some dialogs. Saved and restored some more table columns width and order information.
This commit is contained in:
parent
cb3b5f895b
commit
87f3978589
32 changed files with 1982 additions and 1699 deletions
|
|
@ -71,7 +71,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
/**
|
/**
|
||||||
* Chat message color for opponents.
|
* Chat message color for opponents.
|
||||||
*/
|
*/
|
||||||
private static final String OPPONENT_COLOR = "#FF7F50";
|
private static final String OPPONENT_COLOR = "#FF7F50";
|
||||||
/**
|
/**
|
||||||
* Chat message color for client player.
|
* Chat message color for client player.
|
||||||
*/
|
*/
|
||||||
|
|
@ -142,6 +142,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Creates new form ChatPanel
|
* Creates new form ChatPanel
|
||||||
|
*
|
||||||
* @param addPlayersTab
|
* @param addPlayersTab
|
||||||
*/
|
*/
|
||||||
public ChatPanel(boolean addPlayersTab) {
|
public ChatPanel(boolean addPlayersTab) {
|
||||||
|
|
@ -262,6 +263,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
sb.append("</font>");
|
sb.append("</font>");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return txtConversation.getText();
|
return txtConversation.getText();
|
||||||
}
|
}
|
||||||
|
|
@ -326,7 +328,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
class UserTableModel extends AbstractTableModel {
|
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];
|
private UsersView[] players = new UsersView[0];
|
||||||
|
|
||||||
public void loadData(Collection<RoomUsersView> roomUserInfoList) throws MageRemoteException {
|
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(1)).setHeaderValue("Players (" + this.players.length + ")");
|
||||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(3)).setHeaderValue(
|
tcm.getColumn(jTablePlayers.convertColumnIndexToView(3)).setHeaderValue(
|
||||||
"Games " + roomUserInfo.getNumberActiveGames() +
|
"Games " + roomUserInfo.getNumberActiveGames()
|
||||||
(roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads():" (") +
|
+ (roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads() : " (")
|
||||||
" limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
+ " limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
||||||
th.repaint();
|
th.repaint();
|
||||||
this.fireTableDataChanged();
|
this.fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
@ -397,8 +399,6 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
|
@ -486,9 +486,9 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addComponent(jScrollPaneTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE)
|
.addComponent(jScrollPaneTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(txtMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
.addComponent(txtMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
||||||
jTablePlayers = null;
|
jTablePlayers = null;
|
||||||
jScrollPanePlayers = null;
|
jScrollPanePlayers = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
@ -46,6 +46,7 @@ import mage.cards.repository.ExpansionRepository;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.constants.Constants.DeckEditorMode;
|
import mage.client.constants.Constants.DeckEditorMode;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -53,12 +54,16 @@ import mage.constants.Rarity;
|
||||||
*/
|
*/
|
||||||
public class AddLandDialog extends MageDialog {
|
public class AddLandDialog extends MageDialog {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(MageDialog.class);
|
||||||
|
|
||||||
private Deck deck;
|
private Deck deck;
|
||||||
private final Set<String> setCodesland = new HashSet<>();
|
private final Set<String> setCodesland = new HashSet<>();
|
||||||
|
|
||||||
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
|
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
|
||||||
|
|
||||||
/** Creates new form AddLandDialog */
|
/**
|
||||||
|
* Creates new form AddLandDialog
|
||||||
|
*/
|
||||||
public AddLandDialog() {
|
public AddLandDialog() {
|
||||||
initComponents();
|
initComponents();
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
|
|
@ -69,7 +74,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
SortedSet<String> landSets = new TreeSet<>();
|
SortedSet<String> landSets = new TreeSet<>();
|
||||||
if (!mode.equals(DeckEditorMode.FREE_BUILDING)) {
|
if (!mode.equals(DeckEditorMode.FREE_BUILDING)) {
|
||||||
// decide from which sets basic lands are taken from
|
// 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);
|
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||||
if (expansionInfo != null && expansionInfo.hasBasicLands()) {
|
if (expansionInfo != null && expansionInfo.hasBasicLands()) {
|
||||||
this.setCodesland.add(expansionInfo.getCode());
|
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 sets have no basic land, take land from block
|
||||||
if (this.setCodesland.isEmpty()) {
|
if (this.setCodesland.isEmpty()) {
|
||||||
for (String setCode :deck.getExpansionSetCodes()) {
|
for (String setCode : deck.getExpansionSetCodes()) {
|
||||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||||
if (expansionInfo != null) {
|
if (expansionInfo != null) {
|
||||||
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
|
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
|
||||||
for (ExpansionInfo blockSet: blockSets) {
|
for (ExpansionInfo blockSet : blockSets) {
|
||||||
if (blockSet.hasBasicLands()) {
|
if (blockSet.hasBasicLands()) {
|
||||||
this.setCodesland.add(blockSet.getCode());
|
this.setCodesland.add(blockSet.getCode());
|
||||||
landSets.add(blockSet.getName());
|
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 still no set with lands found, add list of all available
|
||||||
if (this.setCodesland.isEmpty()) {
|
if (this.setCodesland.isEmpty()) {
|
||||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||||
for (ExpansionInfo expansionInfo: basicLandSets) {
|
for (ExpansionInfo expansionInfo : basicLandSets) {
|
||||||
landSets.add(expansionInfo.getName());
|
landSets.add(expansionInfo.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (landSets.isEmpty()) {
|
if (landSets.isEmpty()) {
|
||||||
throw new IllegalArgumentException("No set with basic land was found");
|
throw new IllegalArgumentException("No set with basic land was found");
|
||||||
}
|
}
|
||||||
if(landSets.size() > 1) {
|
if (landSets.size() > 1) {
|
||||||
landSets.add("<Random lands>");
|
landSets.add("<Random lands>");
|
||||||
}
|
}
|
||||||
cbLandSet.setModel(new DefaultComboBoxModel(landSets.toArray()));
|
cbLandSet.setModel(new DefaultComboBoxModel(landSets.toArray()));
|
||||||
|
|
@ -129,7 +134,11 @@ public class AddLandDialog extends MageDialog {
|
||||||
criteria.rarities(Rarity.LAND).name(landName);
|
criteria.rarities(Rarity.LAND).name(landName);
|
||||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||||
if (cards.isEmpty()) {
|
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++) {
|
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.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
|
@ -298,11 +307,11 @@ public class AddLandDialog extends MageDialog {
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
||||||
int nForest = ((Number)spnForest.getValue()).intValue();
|
int nForest = ((Number) spnForest.getValue()).intValue();
|
||||||
int nIsland = ((Number)spnIsland.getValue()).intValue();
|
int nIsland = ((Number) spnIsland.getValue()).intValue();
|
||||||
int nMountain = ((Number)spnMountain.getValue()).intValue();
|
int nMountain = ((Number) spnMountain.getValue()).intValue();
|
||||||
int nPlains = ((Number)spnPlains.getValue()).intValue();
|
int nPlains = ((Number) spnPlains.getValue()).intValue();
|
||||||
int nSwamp = ((Number)spnSwamp.getValue()).intValue();
|
int nSwamp = ((Number) spnSwamp.getValue()).intValue();
|
||||||
|
|
||||||
addLands("Forest", nForest);
|
addLands("Forest", nForest);
|
||||||
addLands("Island", nIsland);
|
addLands("Island", nIsland);
|
||||||
|
|
@ -316,7 +325,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
autoAddLands();
|
autoAddLands();
|
||||||
}//GEN-LAST:event_btnAutoAddActionPerformed
|
}//GEN-LAST:event_btnAutoAddActionPerformed
|
||||||
|
|
||||||
private void autoAddLands(){
|
private void autoAddLands() {
|
||||||
int red = 0;
|
int red = 0;
|
||||||
int green = 0;
|
int green = 0;
|
||||||
int black = 0;
|
int black = 0;
|
||||||
|
|
@ -324,7 +333,9 @@ public class AddLandDialog extends MageDialog {
|
||||||
int white = 0;
|
int white = 0;
|
||||||
Set<Card> cards = deck.getCards();
|
Set<Card> cards = deck.getCards();
|
||||||
int land_number = DEFAULT_SEALED_DECK_CARD_NUMBER - cards.size();
|
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) {
|
for (Card cd : cards) {
|
||||||
Mana m = cd.getManaCost().getMana();
|
Mana m = cd.getManaCost().getMana();
|
||||||
red += m.getRed();
|
red += m.getRed();
|
||||||
|
|
@ -334,14 +345,18 @@ public class AddLandDialog extends MageDialog {
|
||||||
white += m.getWhite();
|
white += m.getWhite();
|
||||||
}
|
}
|
||||||
int total = red + green + black + blue + white;
|
int total = red + green + black + blue + white;
|
||||||
int redcards = Math.round(land_number*((float)red/(float)total));
|
int redcards = Math.round(land_number * ((float) red / (float) total));
|
||||||
total -= red; land_number -= redcards;
|
total -= red;
|
||||||
int greencards = Math.round(land_number*((float)green/(float)total));
|
land_number -= redcards;
|
||||||
total -= green; land_number -= greencards;
|
int greencards = Math.round(land_number * ((float) green / (float) total));
|
||||||
int blackcards = Math.round(land_number*((float)black/(float)total));
|
total -= green;
|
||||||
total -= black; land_number -= blackcards;
|
land_number -= greencards;
|
||||||
int bluecards = Math.round(land_number*((float)blue/(float)total));
|
int blackcards = Math.round(land_number * ((float) black / (float) total));
|
||||||
total -= blue; land_number -= bluecards;
|
total -= black;
|
||||||
|
land_number -= blackcards;
|
||||||
|
int bluecards = Math.round(land_number * ((float) blue / (float) total));
|
||||||
|
total -= blue;
|
||||||
|
land_number -= bluecards;
|
||||||
int whitecards = land_number;
|
int whitecards = land_number;
|
||||||
spnMountain.setValue(redcards);
|
spnMountain.setValue(redcards);
|
||||||
spnForest.setValue(greencards);
|
spnForest.setValue(greencards);
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PreferencesDialog.java
|
* PreferencesDialog.java
|
||||||
|
|
@ -63,10 +63,11 @@ import mage.client.MageFrame;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
import mage.client.util.gui.BufferedImageBuilder;
|
import mage.client.util.gui.BufferedImageBuilder;
|
||||||
|
import mage.players.net.UserData;
|
||||||
|
import mage.players.net.UserGroup;
|
||||||
import mage.players.net.UserSkipPrioritySteps;
|
import mage.players.net.UserSkipPrioritySteps;
|
||||||
import mage.remote.Connection;
|
import mage.remote.Connection;
|
||||||
import mage.remote.Connection.ProxyType;
|
import mage.remote.Connection.ProxyType;
|
||||||
import mage.view.UserDataView;
|
|
||||||
import org.apache.log4j.Logger;
|
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";
|
public static final String KEY_BIG_CARD_TOGGLED = "bigCardToggled";
|
||||||
|
|
||||||
|
|
||||||
// Phases
|
// Phases
|
||||||
public static final String UPKEEP_YOU = "upkeepYou";
|
public static final String UPKEEP_YOU = "upkeepYou";
|
||||||
public static final String DRAW_YOU = "drawYou";
|
public static final String DRAW_YOU = "drawYou";
|
||||||
|
|
@ -155,11 +155,20 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
// user list
|
// user list
|
||||||
public static final String KEY_USERS_COLUMNS_WIDTH = "userPanelColumnWidth";
|
public static final String KEY_USERS_COLUMNS_WIDTH = "userPanelColumnWidth";
|
||||||
public static final String KEY_USERS_COLUMNS_ORDER = "userPanelColumnSort";
|
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_0 = "gamepanelDividerLocation0";
|
||||||
public static final String KEY_GAMEPANEL_DIVIDER_LOCATION_1 = "gamepanelDividerLocation1";
|
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_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_1 = "tournamentPanelDividerLocation1";
|
||||||
public static final String KEY_TOURNAMENT_DIVIDER_LOCATION_2 = "tournamentPanelDividerLocation2";
|
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_AUTO_CONNECT = "autoConnect";
|
||||||
public static final String KEY_CONNECT_FLAG = "connectFlag";
|
public static final String KEY_CONNECT_FLAG = "connectFlag";
|
||||||
|
|
||||||
|
|
||||||
private static final Map<String, String> cache = new HashMap<>();
|
private static final Map<String, String> cache = new HashMap<>();
|
||||||
|
|
||||||
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
|
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
|
||||||
|
|
@ -280,23 +288,24 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JFileChooser fc_i = new JFileChooser();
|
private final JFileChooser fc_i = new JFileChooser();
|
||||||
|
|
||||||
{
|
{
|
||||||
fc_i.setAcceptAllFileFilterUsed(false);
|
fc_i.setAcceptAllFileFilterUsed(false);
|
||||||
fc_i.addChoosableFileFilter(new ImageFileFilter());
|
fc_i.addChoosableFileFilter(new ImageFileFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ImageFileFilter extends FileFilter{
|
private static class ImageFileFilter extends FileFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f) {
|
public boolean accept(File f) {
|
||||||
String filename = f.getName();
|
String filename = f.getName();
|
||||||
if(f.isDirectory()){
|
if (f.isDirectory()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(filename != null){
|
if (filename != null) {
|
||||||
if(filename.endsWith(".jpg") || filename.endsWith(".jpeg") ||
|
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg")
|
||||||
filename.endsWith(".png") || filename.endsWith(".bmp")){
|
|| filename.endsWith(".png") || filename.endsWith(".bmp")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -304,12 +313,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "*.png | *.bmp |*.jpg | *.jpeg";
|
return "*.png | *.bmp |*.jpg | *.jpeg";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form PreferencesDialog
|
* Creates new form PreferencesDialog
|
||||||
*
|
*
|
||||||
|
|
@ -323,14 +330,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
cbProxyType.setModel(new DefaultComboBoxModel<>(Connection.ProxyType.values()));
|
cbProxyType.setModel(new DefaultComboBoxModel<>(Connection.ProxyType.values()));
|
||||||
addAvatars();
|
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.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
|
@ -1803,30 +1810,30 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
}//GEN-LAST:event_cbEnableGameSoundsActionPerformed
|
}//GEN-LAST:event_cbEnableGameSoundsActionPerformed
|
||||||
|
|
||||||
private void cbEnableBattlefieldBGMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEnableBattlefieldBGMActionPerformed
|
private void cbEnableBattlefieldBGMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEnableBattlefieldBGMActionPerformed
|
||||||
if(cbEnableBattlefieldBGM.isSelected()){
|
if (cbEnableBattlefieldBGM.isSelected()) {
|
||||||
txtBattlefieldIBGMPath.setEnabled(true);
|
txtBattlefieldIBGMPath.setEnabled(true);
|
||||||
btnBattlefieldBGMBrowse.setEnabled(true);
|
btnBattlefieldBGMBrowse.setEnabled(true);
|
||||||
}else{
|
} else {
|
||||||
txtBattlefieldIBGMPath.setEnabled(false);
|
txtBattlefieldIBGMPath.setEnabled(false);
|
||||||
btnBattlefieldBGMBrowse.setEnabled(false);
|
btnBattlefieldBGMBrowse.setEnabled(false);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_cbEnableBattlefieldBGMActionPerformed
|
}//GEN-LAST:event_cbEnableBattlefieldBGMActionPerformed
|
||||||
|
|
||||||
private void cbUseDefaultBackgroundActionPerformed(java.awt.event.ActionEvent evt) {
|
private void cbUseDefaultBackgroundActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
if(cbUseDefaultBackground.isSelected()){
|
if (cbUseDefaultBackground.isSelected()) {
|
||||||
useDefaultBackgroundImage();
|
useDefaultBackgroundImage();
|
||||||
}else{
|
} else {
|
||||||
useSelectBackgroundImage();
|
useSelectBackgroundImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useDefaultBackgroundImage(){
|
private void useDefaultBackgroundImage() {
|
||||||
txtBackgroundImagePath.setEnabled(false);
|
txtBackgroundImagePath.setEnabled(false);
|
||||||
btnBrowseBackgroundImage.setEnabled(false);
|
btnBrowseBackgroundImage.setEnabled(false);
|
||||||
txtBackgroundImagePath.setText("");
|
txtBackgroundImagePath.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useSelectBackgroundImage(){
|
private void useSelectBackgroundImage() {
|
||||||
String path = cache.get(KEY_BACKGROUND_IMAGE);
|
String path = cache.get(KEY_BACKGROUND_IMAGE);
|
||||||
dialog.txtBackgroundImagePath.setText(path);
|
dialog.txtBackgroundImagePath.setText(path);
|
||||||
txtBackgroundImagePath.setEnabled(true);
|
txtBackgroundImagePath.setEnabled(true);
|
||||||
|
|
@ -1834,50 +1841,50 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cbUseDefaultBattleImageActionPerformed(java.awt.event.ActionEvent evt) {
|
private void cbUseDefaultBattleImageActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
if(cbUseDefaultBattleImage.isSelected()){
|
if (cbUseDefaultBattleImage.isSelected()) {
|
||||||
useDefaultBattlefield();
|
useDefaultBattlefield();
|
||||||
}else{
|
} else {
|
||||||
useSelectedOrRandom();
|
useSelectedOrRandom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useDefaultBattlefield(){
|
private void useDefaultBattlefield() {
|
||||||
cbUseRandomBattleImage.setEnabled(false);
|
cbUseRandomBattleImage.setEnabled(false);
|
||||||
txtBattlefieldImagePath.setEnabled(false);
|
txtBattlefieldImagePath.setEnabled(false);
|
||||||
btnBrowseBattlefieldImage.setEnabled(false);
|
btnBrowseBattlefieldImage.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useSelectedOrRandom(){
|
private void useSelectedOrRandom() {
|
||||||
cbUseRandomBattleImage.setEnabled(true);
|
cbUseRandomBattleImage.setEnabled(true);
|
||||||
String temp = cache.get(KEY_BATTLEFIELD_IMAGE_RANDOM);
|
String temp = cache.get(KEY_BATTLEFIELD_IMAGE_RANDOM);
|
||||||
if(temp != null){
|
if (temp != null) {
|
||||||
if(temp.equals("true")){
|
if (temp.equals("true")) {
|
||||||
useRandomBattleField();
|
useRandomBattleField();
|
||||||
cbUseRandomBattleImage.setSelected(true);
|
cbUseRandomBattleImage.setSelected(true);
|
||||||
}else{
|
} else {
|
||||||
useSelectedBattleField();
|
useSelectedBattleField();
|
||||||
cbUseRandomBattleImage.setSelected(false);
|
cbUseRandomBattleImage.setSelected(false);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
useSelectedBattleField();
|
useSelectedBattleField();
|
||||||
cbUseRandomBattleImage.setSelected(false);
|
cbUseRandomBattleImage.setSelected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cbUseRandomBattleImageActionPerformed(java.awt.event.ActionEvent evt) {
|
private void cbUseRandomBattleImageActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
if(cbUseRandomBattleImage.isSelected()){
|
if (cbUseRandomBattleImage.isSelected()) {
|
||||||
useRandomBattleField();
|
useRandomBattleField();
|
||||||
}else{
|
} else {
|
||||||
useSelectedBattleField();
|
useSelectedBattleField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useRandomBattleField(){
|
private void useRandomBattleField() {
|
||||||
txtBattlefieldImagePath.setEnabled(false);
|
txtBattlefieldImagePath.setEnabled(false);
|
||||||
btnBrowseBattlefieldImage.setEnabled(false);
|
btnBrowseBattlefieldImage.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useSelectedBattleField(){
|
private void useSelectedBattleField() {
|
||||||
txtBattlefieldImagePath.setEnabled(true);
|
txtBattlefieldImagePath.setEnabled(true);
|
||||||
btnBrowseBattlefieldImage.setEnabled(true);
|
btnBrowseBattlefieldImage.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
@ -1995,12 +2002,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
|
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
|
||||||
this.pnlProxy.setVisible(true);
|
this.pnlProxy.setVisible(true);
|
||||||
this.pnlProxySettings.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.pnlProxy.setVisible(true);
|
||||||
this.pnlProxySettings.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.pnlProxy.setVisible(false);
|
||||||
this.pnlProxySettings.setVisible(false);
|
this.pnlProxySettings.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
@ -2059,7 +2064,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadPhases(Preferences prefs) {
|
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.showToolTipsInAnyZone, KEY_SHOW_TOOLTIPS_ANY_ZONE, "true");
|
||||||
load(prefs, dialog.showCardName, KEY_SHOW_CARD_NAMES, "true");
|
load(prefs, dialog.showCardName, KEY_SHOW_CARD_NAMES, "true");
|
||||||
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "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.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true");
|
||||||
|
|
||||||
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU, "on","on");
|
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU, "on", "on");
|
||||||
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU, "on","on");
|
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU, "on", "on");
|
||||||
load(prefs, dialog.checkBoxMainYou, MAIN_YOU, "on","on");
|
load(prefs, dialog.checkBoxMainYou, MAIN_YOU, "on", "on");
|
||||||
load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_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.checkBoxEndOfCYou, END_OF_COMBAT_YOU, "on", "on");
|
||||||
load(prefs, dialog.checkBoxMain2You, MAIN_2_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.checkBoxEndTurnYou, END_OF_TURN_YOU, "on", "on");
|
||||||
|
|
||||||
load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS, "on","on");
|
load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS, "on", "on");
|
||||||
load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS, "on","on");
|
load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS, "on", "on");
|
||||||
load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS, "on","on");
|
load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS, "on", "on");
|
||||||
load(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_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.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS, "on", "on");
|
||||||
load(prefs, dialog.checkBoxMain2Others, MAIN_2_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.checkBoxEndTurnOthers, END_OF_TURN_OTHERS, "on", "on");
|
||||||
|
|
||||||
load(prefs, dialog.cbStopAttack, KEY_STOP_ATTACK, "true", "true");
|
load(prefs, dialog.cbStopAttack, KEY_STOP_ATTACK, "true", "true");
|
||||||
load(prefs, dialog.cbStopBlock, KEY_STOP_BLOCK, "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
|
//add background load precedure
|
||||||
prop = prefs.get(KEY_BACKGROUND_IMAGE_DEFAULT, "true");
|
prop = prefs.get(KEY_BACKGROUND_IMAGE_DEFAULT, "true");
|
||||||
if(prop.equals("true")){
|
if (prop.equals("true")) {
|
||||||
dialog.cbUseDefaultBackground.setSelected(true);
|
dialog.cbUseDefaultBackground.setSelected(true);
|
||||||
dialog.useDefaultBackgroundImage();
|
dialog.useDefaultBackgroundImage();
|
||||||
}else{
|
} else {
|
||||||
dialog.cbUseDefaultBackground.setSelected(false);
|
dialog.cbUseDefaultBackground.setSelected(false);
|
||||||
dialog.useSelectBackgroundImage();
|
dialog.useSelectBackgroundImage();
|
||||||
String path = prefs.get(KEY_BACKGROUND_IMAGE, "");
|
String path = prefs.get(KEY_BACKGROUND_IMAGE, "");
|
||||||
|
|
@ -2124,20 +2129,20 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
updateCache(KEY_BACKGROUND_IMAGE, path);
|
updateCache(KEY_BACKGROUND_IMAGE, path);
|
||||||
}
|
}
|
||||||
prop = prefs.get(KEY_BATTLEFIELD_IMAGE_DEFAULT, "true");
|
prop = prefs.get(KEY_BATTLEFIELD_IMAGE_DEFAULT, "true");
|
||||||
if(prop.equals("true")){
|
if (prop.equals("true")) {
|
||||||
dialog.cbUseDefaultBattleImage.setSelected(true);
|
dialog.cbUseDefaultBattleImage.setSelected(true);
|
||||||
dialog.useDefaultBattlefield();
|
dialog.useDefaultBattlefield();
|
||||||
}else{
|
} else {
|
||||||
dialog.cbUseDefaultBattleImage.setSelected(false);
|
dialog.cbUseDefaultBattleImage.setSelected(false);
|
||||||
dialog.useSelectedOrRandom();
|
dialog.useSelectedOrRandom();
|
||||||
}
|
}
|
||||||
prop = prefs.get(KEY_BATTLEFIELD_IMAGE_RANDOM, "true");
|
prop = prefs.get(KEY_BATTLEFIELD_IMAGE_RANDOM, "true");
|
||||||
|
|
||||||
if(dialog.cbUseRandomBattleImage.isEnabled()) {
|
if (dialog.cbUseRandomBattleImage.isEnabled()) {
|
||||||
if(prop.equals("true")){
|
if (prop.equals("true")) {
|
||||||
dialog.cbUseRandomBattleImage.setSelected(true);
|
dialog.cbUseRandomBattleImage.setSelected(true);
|
||||||
dialog.useRandomBattleField();
|
dialog.useRandomBattleField();
|
||||||
}else{
|
} else {
|
||||||
dialog.cbUseRandomBattleImage.setSelected(false);
|
dialog.cbUseRandomBattleImage.setSelected(false);
|
||||||
dialog.useSelectedBattleField();
|
dialog.useSelectedBattleField();
|
||||||
String path = prefs.get(KEY_BATTLEFIELD_IMAGE, "");
|
String path = prefs.get(KEY_BATTLEFIELD_IMAGE, "");
|
||||||
|
|
@ -2235,7 +2240,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void saveImagesPath(Preferences prefs) {
|
private static void saveImagesPath(Preferences prefs) {
|
||||||
if (!dialog.cbUseDefaultImageFolder.isSelected()) {
|
if (!dialog.cbUseDefaultImageFolder.isSelected()) {
|
||||||
String path = dialog.txtImageFolderPath.getText();
|
String path = dialog.txtImageFolderPath.getText();
|
||||||
|
|
@ -2243,19 +2247,19 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
updateCache(KEY_CARD_IMAGES_PATH, path);
|
updateCache(KEY_CARD_IMAGES_PATH, path);
|
||||||
}
|
}
|
||||||
// background path save precedure
|
// background path save precedure
|
||||||
if(!dialog.cbUseDefaultBackground.isSelected()){
|
if (!dialog.cbUseDefaultBackground.isSelected()) {
|
||||||
String path = dialog.txtBackgroundImagePath.getText();
|
String path = dialog.txtBackgroundImagePath.getText();
|
||||||
prefs.put(KEY_BACKGROUND_IMAGE, path);
|
prefs.put(KEY_BACKGROUND_IMAGE, path);
|
||||||
updateCache(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();
|
String path = dialog.txtBattlefieldImagePath.getText();
|
||||||
prefs.put(KEY_BATTLEFIELD_IMAGE, path);
|
prefs.put(KEY_BATTLEFIELD_IMAGE, path);
|
||||||
updateCache(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();
|
String path = dialog.txtBattlefieldIBGMPath.getText();
|
||||||
prefs.put(KEY_SOUNDS_MATCH_MUSIC_PATH, path);
|
prefs.put(KEY_SOUNDS_MATCH_MUSIC_PATH, path);
|
||||||
updateCache(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) {
|
public static void setPrefValue(String key, boolean value) {
|
||||||
switch(key) {
|
switch (key) {
|
||||||
case KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS:
|
case KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS:
|
||||||
dialog.cbAllowRequestToShowHandCards.setSelected(value);
|
dialog.cbAllowRequestToShowHandCards.setSelected(value);
|
||||||
save(MageFrame.getPreferences(), dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
|
save(MageFrame.getPreferences(), dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void save(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String noValue, boolean updateCache) {
|
private static void save(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String noValue, boolean updateCache) {
|
||||||
prefs.put(propName, checkBox.isSelected() ? yesValue : noValue);
|
prefs.put(propName, checkBox.isSelected() ? yesValue : noValue);
|
||||||
if (updateCache) {
|
if (updateCache) {
|
||||||
|
|
@ -2356,7 +2361,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
try {
|
try {
|
||||||
addAvatar(jPanel10, 51, true, false);
|
addAvatar(jPanel10, 51, true, false);
|
||||||
addAvatar(jPanel13, 13, false, false);
|
addAvatar(jPanel13, 13, false, false);
|
||||||
addAvatar(jPanel11, 9, false, false);
|
addAvatar(jPanel11, 9, false, false);
|
||||||
addAvatar(jPanel12, 53, false, false);
|
addAvatar(jPanel12, 53, false, false);
|
||||||
addAvatar(jPanel14, 10, false, false);
|
addAvatar(jPanel14, 10, false, false);
|
||||||
addAvatar(jPanel15, 39, false, false);
|
addAvatar(jPanel15, 39, false, false);
|
||||||
|
|
@ -2416,15 +2421,15 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserDataView getUserData(){
|
public static UserData getUserData() {
|
||||||
return new UserDataView(
|
return new UserData(UserGroup.PLAYER,
|
||||||
getSelectedAvatar(),
|
getSelectedAvatar(),
|
||||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
|
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_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"),
|
||||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
|
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
|
||||||
getUserSkipPrioritySteps(),
|
getUserSkipPrioritySteps(),
|
||||||
MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world"),
|
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")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,54 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TableWaitingDialog.java
|
* TableWaitingDialog.java
|
||||||
*
|
*
|
||||||
* Created on Dec 16, 2009, 10:27:44 AM
|
* Created on Dec 16, 2009, 10:27:44 AM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import javax.swing.Icon;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.chat.ChatPanel;
|
import mage.client.chat.ChatPanel;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.components.tray.MageTray;
|
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.audio.AudioManager;
|
||||||
|
import mage.client.util.gui.TableUtil;
|
||||||
|
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.SeatView;
|
import mage.view.SeatView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
|
@ -64,8 +68,11 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
private Session session;
|
private Session session;
|
||||||
private final TableWaitModel tableWaitModel;
|
private final TableWaitModel tableWaitModel;
|
||||||
private UpdateSeatsTask updateTask;
|
private UpdateSeatsTask updateTask;
|
||||||
|
private static final int[] defaultColumnsWidth = {20, 50, 100, 100};
|
||||||
|
|
||||||
/** Creates new form TableWaitingDialog */
|
/**
|
||||||
|
* Creates new form TableWaitingDialog
|
||||||
|
*/
|
||||||
public TableWaitingDialog() {
|
public TableWaitingDialog() {
|
||||||
|
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
|
|
@ -73,8 +80,17 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
|
|
||||||
initComponents();
|
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);
|
chatPanel.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||||
tableSeats.createDefaultColumnsFromModel();
|
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);
|
MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,11 +113,14 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int row = this.tableSeats.getSelectedRow();
|
int row = this.tableSeats.getSelectedRow();
|
||||||
|
if (getTitle().equals("Waiting for players")) {
|
||||||
|
this.title = getTitle() + " - " + table.getDeckType() + " / " + table.getGameType();
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
tableWaitModel.loadData(table);
|
tableWaitModel.loadData(table);
|
||||||
this.tableSeats.repaint();
|
this.tableSeats.repaint();
|
||||||
this.tableSeats.getSelectionModel().setSelectionInterval(row, row);
|
this.tableSeats.getSelectionModel().setSelectionInterval(row, row);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -131,8 +150,7 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
this.setModal(false);
|
this.setModal(false);
|
||||||
this.setLocation(100, 100);
|
this.setLocation(100, 100);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -144,14 +162,15 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
this.chatPanel.disconnect();
|
this.chatPanel.disconnect();
|
||||||
MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON);
|
MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON);
|
||||||
this.removeDialog();
|
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.
|
||||||
/** This method is called from within the constructor to
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* initialize the form.
|
* regenerated by the Form Editor.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
|
||||||
* always regenerated by the Form Editor.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
|
@ -248,8 +267,7 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
if (session.startMatch(roomId, tableId)) {
|
if (session.startMatch(roomId, tableId)) {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (session.startTournament(roomId, tableId)) {
|
if (session.startTournament(roomId, tableId)) {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
|
|
@ -285,7 +303,6 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnMoveUpActionPerformed
|
}//GEN-LAST:event_btnMoveUpActionPerformed
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton btnCancel;
|
private javax.swing.JButton btnCancel;
|
||||||
private javax.swing.JButton btnMoveDown;
|
private javax.swing.JButton btnMoveDown;
|
||||||
|
|
@ -300,7 +317,8 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TableWaitModel extends AbstractTableModel {
|
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];
|
private SeatView[] seats = new SeatView[0];
|
||||||
|
|
||||||
public void loadData(TableView table) {
|
public void loadData(TableView table) {
|
||||||
|
|
@ -324,14 +342,15 @@ class TableWaitModel extends AbstractTableModel {
|
||||||
if (arg1 == 0) {
|
if (arg1 == 0) {
|
||||||
return Integer.toString(arg0 + 1);
|
return Integer.toString(arg0 + 1);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
switch (arg1) {
|
switch (arg1) {
|
||||||
case 0:
|
case 0:
|
||||||
return Integer.toString(arg0 + 1);
|
return Integer.toString(arg0 + 1);
|
||||||
case 1:
|
case 1:
|
||||||
return seats[arg0].getPlayerName();
|
return seats[arg0].getFlagName();
|
||||||
case 2:
|
case 2:
|
||||||
|
return seats[arg0].getPlayerName();
|
||||||
|
case 3:
|
||||||
return seats[arg0].getPlayerType();
|
return seats[arg0].getPlayerType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -350,8 +369,13 @@ class TableWaitModel extends AbstractTableModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getColumnClass(int columnIndex){
|
public Class getColumnClass(int columnIndex) {
|
||||||
return String.class;
|
switch (columnIndex) {
|
||||||
|
case 1:
|
||||||
|
return Icon.class;
|
||||||
|
default:
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -413,7 +437,7 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||||
private int getPlayersCount(TableView tableView) {
|
private int getPlayersCount(TableView tableView) {
|
||||||
int playerCount = 0;
|
int playerCount = 0;
|
||||||
if (tableView != null) {
|
if (tableView != null) {
|
||||||
for (SeatView seatView: tableView.getSeats()) {
|
for (SeatView seatView : tableView.getSeats()) {
|
||||||
if (seatView.getPlayerId() != null && seatView.getPlayerType().equals("Human")) {
|
if (seatView.getPlayerId() != null && seatView.getPlayerType().equals("Human")) {
|
||||||
playerCount++;
|
playerCount++;
|
||||||
}
|
}
|
||||||
|
|
@ -422,7 +446,6 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||||
return playerCount;
|
return playerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -431,7 +454,8 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||||
logger.fatal("Update Seats Task error", ex);
|
logger.fatal("Update Seats Task error", ex);
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
logger.fatal("Update Seats Task error", ex);
|
logger.fatal("Update Seats Task error", ex);
|
||||||
} catch (CancellationException ex) {}
|
} catch (CancellationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
@ -37,7 +37,6 @@ import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.GroupLayout;
|
import javax.swing.GroupLayout;
|
||||||
import javax.swing.GroupLayout.Alignment;
|
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 = 242;
|
||||||
public static final int PANEL_HEIGHT_SMALL = 190;
|
public static final int PANEL_HEIGHT_SMALL = 190;
|
||||||
|
|
||||||
/** Creates new form PlayAreaPanel
|
/**
|
||||||
|
* Creates new form PlayAreaPanel
|
||||||
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param bigCard
|
* @param bigCard
|
||||||
* @param gameId
|
* @param gameId
|
||||||
|
|
@ -97,7 +98,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
popupMenu = new JPopupMenu();
|
popupMenu = new JPopupMenu();
|
||||||
if (options.isPlayer) {
|
if (options.isPlayer) {
|
||||||
addPopupMenuPlayer(player.getUserData().allowRequestShowHandCards());
|
addPopupMenuPlayer(player.getUserData().isAllowRequestShowHandCards());
|
||||||
} else {
|
} else {
|
||||||
addPopupMenuWatcher();
|
addPopupMenuWatcher();
|
||||||
}
|
}
|
||||||
|
|
@ -110,14 +111,13 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
battlefieldPanel.cleanUp();
|
battlefieldPanel.cleanUp();
|
||||||
playerPanel.cleanUp();
|
playerPanel.cleanUp();
|
||||||
|
|
||||||
|
for (ActionListener al : btnCheat.getActionListeners()) {
|
||||||
for (ActionListener al : btnCheat.getActionListeners() ) {
|
|
||||||
btnCheat.removeActionListener(al);
|
btnCheat.removeActionListener(al);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taken form : https://community.oracle.com/thread/2183145
|
// 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
|
// 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")) {
|
if (listener.getClass().getName().contains("MenuKeyboardHelper")) {
|
||||||
try {
|
try {
|
||||||
Field field = listener.getClass().getDeclaredField("menuInputMap");
|
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);
|
battlefieldPanel.getMainPanel().removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
popupMenu.getUI().uninstallUI(this);
|
popupMenu.getUI().uninstallUI(this);
|
||||||
|
|
@ -187,7 +187,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
popupMenu.add(menuItem);
|
popupMenu.add(menuItem);
|
||||||
menuItem.addActionListener(skipListener);
|
menuItem.addActionListener(skipListener);
|
||||||
|
|
||||||
|
|
||||||
JMenu skipMenu = new JMenu("Skip");
|
JMenu skipMenu = new JMenu("Skip");
|
||||||
skipMenu.setMnemonic(KeyEvent.VK_S);
|
skipMenu.setMnemonic(KeyEvent.VK_S);
|
||||||
popupMenu.add(skipMenu);
|
popupMenu.add(skipMenu);
|
||||||
|
|
@ -230,35 +229,35 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
manaPoolMenuItem1 = new JCheckBoxMenuItem("Automatically", true);
|
manaPoolMenuItem1 = new JCheckBoxMenuItem("Automatically", true);
|
||||||
manaPoolMenuItem1.setMnemonic(KeyEvent.VK_A);
|
manaPoolMenuItem1.setMnemonic(KeyEvent.VK_A);
|
||||||
manaPoolMenuItem1.setToolTipText("<html>If not active, produced mana goes only to the mana pool<br>"
|
manaPoolMenuItem1.setToolTipText("<html>If not active, produced mana goes only to the mana pool<br>"
|
||||||
+ "and you have to click the type of mana you want to use <br>"
|
+ "and you have to click the type of mana you want to use <br>"
|
||||||
+ "in the player mana pool panel for payment.");
|
+ "in the player mana pool panel for payment.");
|
||||||
manaPoolMenu.add(manaPoolMenuItem1);
|
manaPoolMenu.add(manaPoolMenuItem1);
|
||||||
|
|
||||||
// Auto pay mana from mana pool
|
// Auto pay mana from mana pool
|
||||||
manaPoolMenuItem1.addActionListener(new ActionListener() {
|
manaPoolMenuItem1.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
|
boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true": "false");
|
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false");
|
||||||
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState());
|
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 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true);
|
||||||
manaPoolMenuItem2.setMnemonic(KeyEvent.VK_N);
|
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>"
|
manaPoolMenuItem2.setToolTipText("<html>Mana that is already in the mana pool as you start casting a spell or activating an ability<br>"
|
||||||
+ " needs to be payed manually. So you use the mana in the pool only by clicking on the related<br>"
|
+ " needs to be payed manually. So you use the mana in the pool only by clicking on the related<br>"
|
||||||
+ " mana symbols of mana pool area.");
|
+ " mana symbols of mana pool area.");
|
||||||
manaPoolMenu.add(manaPoolMenuItem2);
|
manaPoolMenu.add(manaPoolMenuItem2);
|
||||||
|
|
||||||
// Auto pay mana from mana pool
|
// Auto pay mana from mana pool
|
||||||
manaPoolMenuItem2.addActionListener(new ActionListener() {
|
manaPoolMenuItem2.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem)e.getSource()).getState();
|
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||||
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true": "false");
|
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false");
|
||||||
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted);
|
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 +303,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
|
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
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);
|
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 +363,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JMenu concedeMenu = new JMenu("Concede");
|
JMenu concedeMenu = new JMenu("Concede");
|
||||||
concedeMenu.setMnemonic(KeyEvent.VK_C);
|
concedeMenu.setMnemonic(KeyEvent.VK_C);
|
||||||
popupMenu.add(concedeMenu);
|
popupMenu.add(concedeMenu);
|
||||||
|
|
@ -406,7 +403,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
concedeMenu.add(menuItem);
|
concedeMenu.add(menuItem);
|
||||||
menuItem.addActionListener(concedeListener);
|
menuItem.addActionListener(concedeListener);
|
||||||
|
|
||||||
|
|
||||||
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent Me) {
|
public void mouseReleased(MouseEvent Me) {
|
||||||
|
|
@ -419,7 +415,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
this.checkMenu(Me);
|
this.checkMenu(Me);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMenu(MouseEvent Me){
|
private void checkMenu(MouseEvent Me) {
|
||||||
if (Me.isPopupTrigger() && playingMode) {
|
if (Me.isPopupTrigger() && playingMode) {
|
||||||
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||||
}
|
}
|
||||||
|
|
@ -461,13 +457,14 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
public void mouseReleased(MouseEvent Me) {
|
public void mouseReleased(MouseEvent Me) {
|
||||||
this.checkMenu(Me);
|
this.checkMenu(Me);
|
||||||
}
|
}
|
||||||
|
|
||||||
// neccessary for linux and mac systems
|
// neccessary for linux and mac systems
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent Me) {
|
public void mousePressed(MouseEvent Me) {
|
||||||
this.checkMenu(Me);
|
this.checkMenu(Me);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMenu(MouseEvent Me){
|
private void checkMenu(MouseEvent Me) {
|
||||||
if (Me.isPopupTrigger() && playingMode) {
|
if (Me.isPopupTrigger() && playingMode) {
|
||||||
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
popupMenu.show(Me.getComponent(), Me.getX(), Me.getY());
|
||||||
}
|
}
|
||||||
|
|
@ -483,8 +480,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
if (MageFrame.getSession().isTestMode()) {
|
if (MageFrame.getSession().isTestMode()) {
|
||||||
this.playerId = player.getPlayerId();
|
this.playerId = player.getPlayerId();
|
||||||
this.btnCheat.setVisible(true);
|
this.btnCheat.setVisible(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.btnCheat.setVisible(false);
|
this.btnCheat.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -493,7 +489,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
this.playerPanel.update(player);
|
this.playerPanel.update(player);
|
||||||
this.battlefieldPanel.update(player.getBattlefield());
|
this.battlefieldPanel.update(player.getBattlefield());
|
||||||
if (this.allowViewHandCardsMenuItem != null) {
|
if (this.allowViewHandCardsMenuItem != null) {
|
||||||
this.allowViewHandCardsMenuItem.setSelected(player.getUserData().allowRequestShowHandCards());
|
this.allowViewHandCardsMenuItem.setSelected(player.getUserData().isAllowRequestShowHandCards());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -506,7 +502,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0)));
|
setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0, 0)));
|
||||||
playerPanel = new PlayerPanelExt();
|
playerPanel = new PlayerPanelExt();
|
||||||
btnCheat = new javax.swing.JButton();
|
btnCheat = new javax.swing.JButton();
|
||||||
//jScrollPane1 = new javax.swing.JScrollPane();
|
//jScrollPane1 = new javax.swing.JScrollPane();
|
||||||
|
|
@ -525,16 +521,15 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
//Border empty = new EmptyBorder(0,0,0,0);
|
//Border empty = new EmptyBorder(0,0,0,0);
|
||||||
//jScrollPane1.setBorder(empty);
|
//jScrollPane1.setBorder(empty);
|
||||||
//jScrollPane1.setViewportBorder(empty);
|
//jScrollPane1.setViewportBorder(empty);
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createSequentialGroup()
|
layout.createSequentialGroup()
|
||||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addComponent(battlefieldPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(battlefieldPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(Alignment.LEADING)
|
layout.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(battlefieldPanel, GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
|
.addComponent(battlefieldPanel, GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
@ -548,8 +543,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
this.playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT_SMALL));
|
this.playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT_SMALL));
|
||||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 160));
|
//this.jScrollPane1.setPreferredSize(new Dimension(160, 160));
|
||||||
this.battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT_SMALL));
|
this.battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT_SMALL));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT));
|
this.playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT));
|
||||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 212));
|
//this.jScrollPane1.setPreferredSize(new Dimension(160, 212));
|
||||||
this.battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT));
|
this.battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT));
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ package mage.client.game;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.awt.GridLayout;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
@ -67,6 +68,7 @@ import mage.client.util.CardsViewUtil;
|
||||||
import mage.client.util.Command;
|
import mage.client.util.Command;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
import mage.client.util.gui.BufferedImageBuilder;
|
import mage.client.util.gui.BufferedImageBuilder;
|
||||||
|
import mage.client.util.gui.countryBox.CountryUtil;
|
||||||
import mage.components.ImagePanel;
|
import mage.components.ImagePanel;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.remote.Session;
|
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 static final Border emptyBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0);
|
||||||
|
|
||||||
private int avatarId = -1;
|
private int avatarId = -1;
|
||||||
|
private String flagName = "";
|
||||||
|
|
||||||
private PriorityTimer timer;
|
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);
|
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||||
this.avatar.update("player", resized, resized, resized, resized, 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());
|
this.avatar.setText(player.getName());
|
||||||
if (this.timer != null) {
|
if (this.timer != null) {
|
||||||
|
|
@ -298,6 +306,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
panelBackground = new MageRoundPane();
|
panelBackground = new MageRoundPane();
|
||||||
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT));
|
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT));
|
||||||
Rectangle r = new Rectangle(80, 80);
|
Rectangle r = new Rectangle(80, 80);
|
||||||
|
avatarFlag = new JLabel();
|
||||||
timerLabel = new JLabel();
|
timerLabel = new JLabel();
|
||||||
lifeLabel = new JLabel();
|
lifeLabel = new JLabel();
|
||||||
handLabel = 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);
|
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||||
avatar = new HoverButton("player", resized, resized, resized, 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.setAlignmentY(CENTER_ALIGNMENT);
|
||||||
|
avatarFlag.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
avatarFlag.setVerticalAlignment(JLabel.BOTTOM);
|
||||||
|
avatar.add(new JLabel());
|
||||||
String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
|
String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
|
||||||
if (showPlayerNamePermanently.equals("true")) {
|
if (showPlayerNamePermanently.equals("true")) {
|
||||||
avatar.setTextAlwaysVisible(true);
|
avatar.setTextAlwaysVisible(true);
|
||||||
|
|
@ -326,6 +343,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
session.sendPlayerUUID(gameId, playerId);
|
session.sendPlayerUUID(gameId, playerId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// timer area /small layout)
|
// timer area /small layout)
|
||||||
timerLabel.setToolTipText("Time left");
|
timerLabel.setToolTipText("Time left");
|
||||||
timerLabel.setSize(80, 12);
|
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(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(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, 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))
|
.addGap(14))
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(6)
|
.addGap(6)
|
||||||
|
|
@ -748,12 +768,14 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
protected void sizePlayerPanel(boolean smallMode) {
|
protected void sizePlayerPanel(boolean smallMode) {
|
||||||
if (smallMode) {
|
if (smallMode) {
|
||||||
avatar.setVisible(false);
|
avatar.setVisible(false);
|
||||||
|
avatarFlag.setVisible(false);
|
||||||
btnPlayer.setVisible(true);
|
btnPlayer.setVisible(true);
|
||||||
timerLabel.setVisible(true);
|
timerLabel.setVisible(true);
|
||||||
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL));
|
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL));
|
||||||
panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL);
|
panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL);
|
||||||
} else {
|
} else {
|
||||||
avatar.setVisible(true);
|
avatar.setVisible(true);
|
||||||
|
avatarFlag.setVisible(true);
|
||||||
btnPlayer.setVisible(false);
|
btnPlayer.setVisible(false);
|
||||||
timerLabel.setVisible(false);
|
timerLabel.setVisible(false);
|
||||||
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT));
|
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT));
|
||||||
|
|
@ -791,6 +813,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private HoverButton avatar;
|
private HoverButton avatar;
|
||||||
|
private JLabel avatarFlag;
|
||||||
private JButton btnPlayer;
|
private JButton btnPlayer;
|
||||||
private ImagePanel life;
|
private ImagePanel life;
|
||||||
private ImagePanel poison;
|
private ImagePanel poison;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
*
|
*
|
||||||
* Created on 20-Jan-2011, 9:18:30 PM
|
* Created on 20-Jan-2011, 9:18:30 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.tournament;
|
package mage.client.tournament;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
|
@ -45,14 +44,21 @@ import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
|
import javax.swing.Icon;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.chat.ChatPanel;
|
import mage.client.chat.ChatPanel;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
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.ButtonColumn;
|
||||||
import mage.client.util.Format;
|
import mage.client.util.Format;
|
||||||
|
import mage.client.util.gui.TableUtil;
|
||||||
|
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.RoundView;
|
import mage.view.RoundView;
|
||||||
import mage.view.TournamentGameView;
|
import mage.view.TournamentGameView;
|
||||||
|
|
@ -76,7 +82,12 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
private UpdateTournamentTask updateTask;
|
private UpdateTournamentTask updateTask;
|
||||||
private final DateFormat df;
|
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() {
|
public TournamentPanel() {
|
||||||
playersModel = new TournamentPlayersTableModel();
|
playersModel = new TournamentPlayersTableModel();
|
||||||
matchesModel = new TournamentMatchesTableModel();
|
matchesModel = new TournamentMatchesTableModel();
|
||||||
|
|
@ -88,23 +99,24 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
df = DateFormat.getDateTimeInstance();
|
df = DateFormat.getDateTimeInstance();
|
||||||
|
|
||||||
tablePlayers.createDefaultColumnsFromModel();
|
tablePlayers.createDefaultColumnsFromModel();
|
||||||
|
TableUtil.setColumnWidthAndOrder(tablePlayers, defaultColumnsWidthPlayers, KEY_TOURNAMENT_PLAYER_COLUMNS_WIDTH, KEY_TOURNAMENT_PLAYER_COLUMNS_ORDER);
|
||||||
|
tablePlayers.setDefaultRenderer(Icon.class, new CountryCellRenderer());
|
||||||
|
|
||||||
tableMatches.createDefaultColumnsFromModel();
|
tableMatches.createDefaultColumnsFromModel();
|
||||||
|
TableUtil.setColumnWidthAndOrder(tableMatches, defaultColumnsWidthMatches, KEY_TOURNAMENT_MATCH_COLUMNS_WIDTH, KEY_TOURNAMENT_MATCH_COLUMNS_ORDER);
|
||||||
|
|
||||||
chatPanel1.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
chatPanel1.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||||
chatPanel1.setChatType(ChatPanel.ChatType.TOURNAMENT);
|
chatPanel1.setChatType(ChatPanel.ChatType.TOURNAMENT);
|
||||||
|
|
||||||
Action action = new AbstractAction()
|
Action action = new AbstractAction() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e) {
|
||||||
{
|
int modelRow = Integer.valueOf(e.getActionCommand());
|
||||||
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));
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
// if (state.equals("Finished") && action.equals("Replay")) {
|
// if (state.equals("Finished") && action.equals("Replay")) {
|
||||||
// logger.info("Replaying game " + gameId);
|
// logger.info("Replaying game " + gameId);
|
||||||
|
|
@ -127,6 +139,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
if (this.chatPanel1 != null) {
|
if (this.chatPanel1 != null) {
|
||||||
this.chatPanel1.disconnect();
|
this.chatPanel1.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveDividerLocations() {
|
private void saveDividerLocations() {
|
||||||
|
|
@ -167,8 +180,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
startTasks();
|
startTasks();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
hideTournament();
|
hideTournament();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,12 +194,15 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
stopTasks();
|
stopTasks();
|
||||||
this.chatPanel1.disconnect();
|
this.chatPanel1.disconnect();
|
||||||
this.saveDividerLocations();
|
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();
|
Component c = this.getParent();
|
||||||
while (c != null && !(c instanceof TournamentPane)) {
|
while (c != null && !(c instanceof TournamentPane)) {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
((TournamentPane)c).removeTournament();
|
((TournamentPane) c).removeTournament();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,7 +216,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
((TournamentPane)c).setTitle("Tournament [" + tournament.getTournamentName() +"]");
|
((TournamentPane) c).setTitle("Tournament [" + tournament.getTournamentName() + "]");
|
||||||
}
|
}
|
||||||
txtName.setText(tournament.getTournamentName());
|
txtName.setText(tournament.getTournamentName());
|
||||||
txtType.setText(tournament.getTournamentType());
|
txtType.setText(tournament.getTournamentType());
|
||||||
|
|
@ -215,7 +230,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
case "Constructing":
|
case "Constructing":
|
||||||
String timeLeft = "";
|
String timeLeft = "";
|
||||||
if (tournament.getStepStartTime() != null) {
|
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());
|
txtTournamentState.setText(new StringBuilder(tournament.getTournamentState()).append(" (").append(timeLeft).append(")").toString());
|
||||||
break;
|
break;
|
||||||
|
|
@ -223,7 +238,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
case "Drafting":
|
case "Drafting":
|
||||||
String usedTime = "";
|
String usedTime = "";
|
||||||
if (tournament.getStepStartTime() != null) {
|
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());
|
txtTournamentState.setText(tournament.getTournamentState() + " (" + usedTime + ") " + tournament.getRunningInfo());
|
||||||
break;
|
break;
|
||||||
|
|
@ -274,10 +289,10 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <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:
|
// TODO add your handling code here:
|
||||||
}//GEN-LAST:event_txtNameActionPerformed
|
}//GEN-LAST:event_txtNameActionPerformed
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JPanel actionPanel;
|
private javax.swing.JPanel actionPanel;
|
||||||
private javax.swing.JButton btnCloseWindow;
|
private javax.swing.JButton btnCloseWindow;
|
||||||
|
|
@ -532,7 +546,8 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TournamentPlayersTableModel extends AbstractTableModel {
|
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];
|
private TournamentPlayerView[] players = new TournamentPlayerView[0];
|
||||||
|
|
||||||
public void loadData(TournamentView tournament) {
|
public void loadData(TournamentView tournament) {
|
||||||
|
|
@ -554,12 +569,14 @@ class TournamentPlayersTableModel extends AbstractTableModel {
|
||||||
public Object getValueAt(int arg0, int arg1) {
|
public Object getValueAt(int arg0, int arg1) {
|
||||||
switch (arg1) {
|
switch (arg1) {
|
||||||
case 0:
|
case 0:
|
||||||
return players[arg0].getName();
|
return players[arg0].getFlagName();
|
||||||
case 1:
|
case 1:
|
||||||
return players[arg0].getState();
|
return players[arg0].getName();
|
||||||
case 2:
|
case 2:
|
||||||
return Integer.toString(players[arg0].getPoints());
|
return players[arg0].getState();
|
||||||
case 3:
|
case 3:
|
||||||
|
return Integer.toString(players[arg0].getPoints());
|
||||||
|
case 4:
|
||||||
return players[arg0].getResults();
|
return players[arg0].getResults();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -577,8 +594,13 @@ class TournamentPlayersTableModel extends AbstractTableModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getColumnClass(int columnIndex){
|
public Class getColumnClass(int columnIndex) {
|
||||||
return String.class;
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return Icon.class;
|
||||||
|
default:
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -599,8 +621,8 @@ class TournamentMatchesTableModel extends AbstractTableModel {
|
||||||
public void loadData(TournamentView tournament) {
|
public void loadData(TournamentView tournament) {
|
||||||
List<TournamentGameView> views = new ArrayList<>();
|
List<TournamentGameView> views = new ArrayList<>();
|
||||||
watchingAllowed = tournament.isWatchingAllowed();
|
watchingAllowed = tournament.isWatchingAllowed();
|
||||||
for (RoundView round: tournament.getRounds()) {
|
for (RoundView round : tournament.getRounds()) {
|
||||||
for (TournamentGameView game: round.getGames()) {
|
for (TournamentGameView game : round.getGames()) {
|
||||||
views.add(game);
|
views.add(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -660,7 +682,7 @@ class TournamentMatchesTableModel extends AbstractTableModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getColumnClass(int columnIndex){
|
public Class getColumnClass(int columnIndex) {
|
||||||
return String.class;
|
return String.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -709,7 +731,8 @@ class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
||||||
logger.fatal("Update Tournament Task error", ex);
|
logger.fatal("Update Tournament Task error", ex);
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
logger.fatal("Update Tournament Task error", 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.JTable;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import org.mage.card.arcane.Util;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -33,9 +32,13 @@ public class TableUtil {
|
||||||
if (widths != null && widths.length > i) {
|
if (widths != null && widths.length > i) {
|
||||||
width = widths[i];
|
width = widths[i];
|
||||||
}
|
}
|
||||||
TableColumn column = table.getColumnModel().getColumn(i++);
|
if (table.getColumnModel().getColumnCount() >= i) {
|
||||||
column.setWidth(width);
|
TableColumn column = table.getColumnModel().getColumn(i++);
|
||||||
column.setPreferredWidth(width);
|
column.setWidth(width);
|
||||||
|
column.setPreferredWidth(width);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the column order
|
// set the column order
|
||||||
|
|
@ -69,7 +72,6 @@ public class TableUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int[] getIntArrayFromString(String stringData) {
|
public static int[] getIntArrayFromString(String stringData) {
|
||||||
int[] intArray = null;
|
int[] intArray = null;
|
||||||
if (stringData != null && !stringData.isEmpty()) {
|
if (stringData != null && !stringData.isEmpty()) {
|
||||||
|
|
@ -79,7 +81,8 @@ public class TableUtil {
|
||||||
for (int i = 0; i < lengthW; i++) {
|
for (int i = 0; i < lengthW; i++) {
|
||||||
try {
|
try {
|
||||||
intArray[i] = Integer.parseInt(items[i]);
|
intArray[i] = Integer.parseInt(items[i]);
|
||||||
} catch (NumberFormatException nfe) {}
|
} catch (NumberFormatException nfe) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return intArray;
|
return intArray;
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,12 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.util.gui.countryBox;
|
package mage.client.util.gui.countryBox;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -43,38 +38,15 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class CountryCellRenderer extends DefaultTableCellRenderer {
|
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
|
@Override
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
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);
|
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
if(table.convertColumnIndexToView(0) == column) {
|
if (value == null || ((String) value).isEmpty()) {
|
||||||
label.setToolTipText(countryMap.get((String)value));
|
value = (String) "world";
|
||||||
label.setIcon(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;
|
label.setToolTipText(CountryUtil.getCountryName((String) value));
|
||||||
|
label.setIcon(CountryUtil.getCountryFlagIcon((String) value));
|
||||||
|
label.setText("");
|
||||||
|
return label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
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 |
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.interfaces;
|
package mage.interfaces;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -40,14 +39,14 @@ import mage.constants.PlayerAction;
|
||||||
import mage.game.GameException;
|
import mage.game.GameException;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.players.net.UserData;
|
||||||
import mage.utils.MageVersion;
|
import mage.utils.MageVersion;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
import mage.view.GameView;
|
import mage.view.GameView;
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
|
import mage.view.RoomUsersView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
import mage.view.UserDataView;
|
|
||||||
import mage.view.RoomUsersView;
|
|
||||||
import mage.view.UserView;
|
import mage.view.UserView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,22 +57,28 @@ public interface MageServer {
|
||||||
|
|
||||||
// connection methods
|
// connection methods
|
||||||
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
|
boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException;
|
||||||
|
|
||||||
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||||
// Not used
|
// Not used
|
||||||
// void deregisterClient(String sessionId) throws MageException;
|
// void deregisterClient(String sessionId) throws MageException;
|
||||||
|
|
||||||
// update methods
|
// update methods
|
||||||
List<ExpansionInfo> getMissingExpansionData(List<String> codes);
|
List<ExpansionInfo> getMissingExpansionData(List<String> codes);
|
||||||
|
|
||||||
List<CardInfo> getMissingCardsData(List<String> classNames);
|
List<CardInfo> getMissingCardsData(List<String> classNames);
|
||||||
|
|
||||||
// user methods
|
// 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;
|
void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
|
||||||
|
|
||||||
// server state methods
|
// server state methods
|
||||||
ServerState getServerState() throws MageException;
|
ServerState getServerState() throws MageException;
|
||||||
|
|
||||||
List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException;
|
List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException;
|
||||||
|
|
||||||
List<MatchView> getFinishedMatches(UUID roomId) throws MageException;
|
List<MatchView> getFinishedMatches(UUID roomId) throws MageException;
|
||||||
|
|
||||||
Object getServerMessagesCompressed(String sessionId) throws MageException; // messages of the day
|
Object getServerMessagesCompressed(String sessionId) throws MageException; // messages of the day
|
||||||
|
|
||||||
// ping - extends session
|
// ping - extends session
|
||||||
|
|
@ -81,27 +86,46 @@ public interface MageServer {
|
||||||
|
|
||||||
//table methods
|
//table methods
|
||||||
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
|
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
|
||||||
|
|
||||||
TableView createTournamentTable(String sessionId, UUID roomId, TournamentOptions tournamentOptions) 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 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 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;
|
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||||
|
|
||||||
void updateDeck(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 watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
boolean watchTournamentTable(String sessionId, UUID tableId) throws MageException;
|
boolean watchTournamentTable(String sessionId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
boolean leaveTable(String sessionId, UUID roomId, 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 swapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
|
||||||
|
|
||||||
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
boolean isTableOwner(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;
|
TableView getTable(UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
List<TableView> getTables(UUID roomId) throws MageException;
|
List<TableView> getTables(UUID roomId) throws MageException;
|
||||||
|
|
||||||
//chat methods
|
//chat methods
|
||||||
void sendChatMessage(UUID chatId, String userName, String message) throws MageException;
|
void sendChatMessage(UUID chatId, String userName, String message) throws MageException;
|
||||||
|
|
||||||
void joinChat(UUID chatId, String sessionId, String userName) throws MageException;
|
void joinChat(UUID chatId, String sessionId, String userName) throws MageException;
|
||||||
|
|
||||||
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
||||||
|
|
||||||
UUID getTableChatId(UUID tableId) throws MageException;
|
UUID getTableChatId(UUID tableId) throws MageException;
|
||||||
|
|
||||||
UUID getGameChatId(UUID gameId) throws MageException;
|
UUID getGameChatId(UUID gameId) throws MageException;
|
||||||
|
|
||||||
UUID getRoomChatId(UUID roomId) throws MageException;
|
UUID getRoomChatId(UUID roomId) throws MageException;
|
||||||
|
|
||||||
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
||||||
|
|
||||||
//room methods
|
//room methods
|
||||||
|
|
@ -109,50 +133,77 @@ public interface MageServer {
|
||||||
|
|
||||||
//game methods
|
//game methods
|
||||||
boolean startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
boolean startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
void joinGame(UUID gameId, String sessionId) throws MageException;
|
void joinGame(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void watchGame(UUID gameId, String sessionId) throws MageException;
|
void watchGame(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void stopWatching(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 sendPlayerUUID(UUID gameId, String sessionId, UUID data) throws MageException;
|
||||||
|
|
||||||
void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException;
|
void sendPlayerString(UUID gameId, String sessionId, String data) throws MageException;
|
||||||
|
|
||||||
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
|
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
|
||||||
|
|
||||||
void sendPlayerInteger(UUID gameId, String sessionId, Integer 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 sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException;
|
||||||
|
|
||||||
void quitMatch(UUID gameId, String sessionId) throws MageException;
|
void quitMatch(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
|
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
|
||||||
|
|
||||||
// priority, undo, concede, mana pool
|
// priority, undo, concede, mana pool
|
||||||
|
|
||||||
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId, Object data) throws MageException;
|
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId, Object data) throws MageException;
|
||||||
|
|
||||||
//tournament methods
|
//tournament methods
|
||||||
boolean startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
boolean startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
|
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
|
||||||
|
|
||||||
TournamentView getTournament(UUID tournamentId) throws MageException;
|
TournamentView getTournament(UUID tournamentId) throws MageException;
|
||||||
|
|
||||||
//draft methods
|
//draft methods
|
||||||
void joinDraft(UUID draftId, String sessionId) throws MageException;
|
void joinDraft(UUID draftId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void quitDraft(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;
|
DraftPickView sendCardPick(UUID draftId, String sessionId, UUID cardId, Set<UUID> hiddenCards) throws MageException;
|
||||||
|
|
||||||
void sendCardMark(UUID draftId, String sessionId, UUID cardId) throws MageException;
|
void sendCardMark(UUID draftId, String sessionId, UUID cardId) throws MageException;
|
||||||
|
|
||||||
//challenge methods
|
//challenge methods
|
||||||
// void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException;
|
// void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException;
|
||||||
|
|
||||||
//replay methods
|
//replay methods
|
||||||
void replayGame(UUID gameId, String sessionId) throws MageException;
|
void replayGame(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void startReplay(UUID gameId, String sessionId) throws MageException;
|
void startReplay(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void stopReplay(UUID gameId, String sessionId) throws MageException;
|
void stopReplay(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void nextPlay(UUID gameId, String sessionId) throws MageException;
|
void nextPlay(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void previousPlay(UUID gameId, String sessionId) throws MageException;
|
void previousPlay(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void skipForward(UUID gameId, String sessionId, int moves) throws MageException;
|
void skipForward(UUID gameId, String sessionId, int moves) throws MageException;
|
||||||
|
|
||||||
//test methods
|
//test methods
|
||||||
void cheat(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
|
void cheat(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
|
||||||
|
|
||||||
boolean cheat(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
|
boolean cheat(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
|
||||||
|
|
||||||
//admin methods
|
//admin methods
|
||||||
List<UserView> getUsers(String sessionId) throws MageException;
|
List<UserView> getUsers(String sessionId) throws MageException;
|
||||||
|
|
||||||
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
||||||
|
|
||||||
void endUserSession(String sessionId, String userSessionId) throws MageException;
|
void endUserSession(String sessionId, String userSessionId) throws MageException;
|
||||||
|
|
||||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.remote;
|
package mage.remote;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
|
|
@ -34,8 +33,7 @@ import java.net.InterfaceAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import mage.players.net.UserSkipPrioritySteps;
|
import mage.players.net.UserData;
|
||||||
import mage.view.UserDataView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -55,7 +53,7 @@ public class Connection {
|
||||||
private int clientCardDatabaseVersion;
|
private int clientCardDatabaseVersion;
|
||||||
private boolean forceDBComparison;
|
private boolean forceDBComparison;
|
||||||
|
|
||||||
private UserDataView userData;
|
private UserData userData;
|
||||||
|
|
||||||
// private int avatarId;
|
// private int avatarId;
|
||||||
// private boolean showAbilityPickerForced;
|
// private boolean showAbilityPickerForced;
|
||||||
|
|
@ -63,7 +61,6 @@ public class Connection {
|
||||||
// private boolean confirmEmptyManaPool;
|
// private boolean confirmEmptyManaPool;
|
||||||
// private String flagName;
|
// private String flagName;
|
||||||
// private UserSkipPrioritySteps userSkipPrioritySteps;
|
// private UserSkipPrioritySteps userSkipPrioritySteps;
|
||||||
|
|
||||||
private static final String serialization = "?serializationtype=jboss";
|
private static final String serialization = "?serializationtype=jboss";
|
||||||
private static final String transport = "bisocket";
|
private static final String transport = "bisocket";
|
||||||
|
|
||||||
|
|
@ -84,7 +81,7 @@ public class Connection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (! (object instanceof Connection)) {
|
if (!(object instanceof Connection)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Connection otherConnection = (Connection) object;
|
Connection otherConnection = (Connection) object;
|
||||||
|
|
@ -119,6 +116,7 @@ public class Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ProxyType {
|
public enum ProxyType {
|
||||||
|
|
||||||
SOCKS("Socks"), HTTP("HTTP"), NONE("None");
|
SOCKS("Socks"), HTTP("HTTP"), NONE("None");
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
@ -207,12 +205,12 @@ public class Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InetAddress getLocalAddress() throws SocketException {
|
public static InetAddress getLocalAddress() throws SocketException {
|
||||||
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) {
|
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements();) {
|
||||||
NetworkInterface iface = interfaces.nextElement( );
|
NetworkInterface iface = interfaces.nextElement();
|
||||||
if (iface.isLoopback()) {
|
if (iface.isLoopback()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (InterfaceAddress addr: iface.getInterfaceAddresses()) {
|
for (InterfaceAddress addr : iface.getInterfaceAddresses()) {
|
||||||
if (addr != null) {
|
if (addr != null) {
|
||||||
InetAddress iaddr = addr.getAddress();
|
InetAddress iaddr = addr.getAddress();
|
||||||
if (iaddr != null && iaddr instanceof Inet4Address) {
|
if (iaddr != null && iaddr instanceof Inet4Address) {
|
||||||
|
|
@ -224,11 +222,11 @@ public class Connection {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserData(UserDataView userData) {
|
public void setUserData(UserData userData) {
|
||||||
this.userData= userData;
|
this.userData = userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDataView getUserData() {
|
public UserData getUserData() {
|
||||||
return userData;
|
return userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.remote;
|
package mage.remote;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -61,8 +60,8 @@ import mage.interfaces.MageClient;
|
||||||
import mage.interfaces.MageServer;
|
import mage.interfaces.MageServer;
|
||||||
import mage.interfaces.ServerState;
|
import mage.interfaces.ServerState;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.players.net.UserData;
|
||||||
import mage.utils.CompressUtil;
|
import mage.utils.CompressUtil;
|
||||||
import mage.players.net.UserSkipPrioritySteps;
|
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
|
|
@ -70,7 +69,6 @@ import mage.view.RoomUsersView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import mage.view.TournamentTypeView;
|
import mage.view.TournamentTypeView;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
import mage.view.UserDataView;
|
|
||||||
import mage.view.UserView;
|
import mage.view.UserView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jboss.remoting.CannotConnectException;
|
import org.jboss.remoting.CannotConnectException;
|
||||||
|
|
@ -168,17 +166,17 @@ public class SessionImpl implements Session {
|
||||||
|
|
||||||
Map<String, String> metadata = new HashMap<>();
|
Map<String, String> metadata = new HashMap<>();
|
||||||
/*
|
/*
|
||||||
5.8.3.1.1. Write timeouts
|
5.8.3.1.1. Write timeouts
|
||||||
The socket timeout facility offered by the JDK applies only to read operations on the socket. As of release 2.5.2,
|
The socket timeout facility offered by the JDK applies only to read operations on the socket. As of release 2.5.2,
|
||||||
the socket and bisocket (and also sslsocket and sslbisocket) transports offer a write timeout facility. When a client
|
the socket and bisocket (and also sslsocket and sslbisocket) transports offer a write timeout facility. When a client
|
||||||
or server is configured, in any of the usual ways, with the parameter org.jboss.remoting.transport.socket.SocketWrapper.WRITE_TIMEOUT
|
or server is configured, in any of the usual ways, with the parameter org.jboss.remoting.transport.socket.SocketWrapper.WRITE_TIMEOUT
|
||||||
(actual value "writeTimeout") set to a positive value (in milliseconds), all write operations will time out if they do
|
(actual value "writeTimeout") set to a positive value (in milliseconds), all write operations will time out if they do
|
||||||
not complete within the configured period. When a write operation times out, the socket upon which the write was invoked
|
not complete within the configured period. When a write operation times out, the socket upon which the write was invoked
|
||||||
will be closed, which is likely to result in a java.net.SocketException.
|
will be closed, which is likely to result in a java.net.SocketException.
|
||||||
Note. A SocketException is considered to be a "retriable" exception, so, if the parameter "numberOfCallRetries" is set
|
Note. A SocketException is considered to be a "retriable" exception, so, if the parameter "numberOfCallRetries" is set
|
||||||
to a value greater than 1, an invocation interrupted by a write timeout can be retried.
|
to a value greater than 1, an invocation interrupted by a write timeout can be retried.
|
||||||
Note. The write timeout facility applies to writing of both invocations and responses. It applies to push callbacks as well.
|
Note. The write timeout facility applies to writing of both invocations and responses. It applies to push callbacks as well.
|
||||||
*/
|
*/
|
||||||
metadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
|
metadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
|
||||||
metadata.put("generalizeSocketException", "true");
|
metadata.put("generalizeSocketException", "true");
|
||||||
server = (MageServer) TransporterClient.createTransporterClient(clientLocator.getLocatorURI(), MageServer.class, metadata);
|
server = (MageServer) TransporterClient.createTransporterClient(clientLocator.getLocatorURI(), MageServer.class, metadata);
|
||||||
|
|
@ -187,60 +185,66 @@ public class SessionImpl implements Session {
|
||||||
Map<String, String> clientMetadata = new HashMap<>();
|
Map<String, String> clientMetadata = new HashMap<>();
|
||||||
|
|
||||||
clientMetadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
|
clientMetadata.put(SocketWrapper.WRITE_TIMEOUT, "2000");
|
||||||
/* generalizeSocketException
|
/* generalizeSocketException
|
||||||
* If set to false, a failed invocation will be retried in the case of
|
* If set to false, a failed invocation will be retried in the case of
|
||||||
* SocketExceptions. If set to true, a failed invocation will be retried in the case of
|
* SocketExceptions. If set to true, a failed invocation will be retried in the case of
|
||||||
* <classname>SocketException</classname>s and also any <classname>IOException</classname>
|
* <classname>SocketException</classname>s and also any <classname>IOException</classname>
|
||||||
* whose message matches the regular expression
|
* whose message matches the regular expression
|
||||||
* <code>^.*(?:connection.*reset|connection.*closed|broken.*pipe).*$</code>.
|
* <code>^.*(?:connection.*reset|connection.*closed|broken.*pipe).*$</code>.
|
||||||
* See also the "numberOfCallRetries" parameter, above. The default value is false.*/
|
* See also the "numberOfCallRetries" parameter, above. The default value is false.*/
|
||||||
clientMetadata.put("generalizeSocketException", "true");
|
clientMetadata.put("generalizeSocketException", "true");
|
||||||
|
|
||||||
/* A remoting server also has the capability to detect when a client is no longer available.
|
/* A remoting server also has the capability to detect when a client is no longer available.
|
||||||
* This is done by estabilishing a lease with the remoting clients that connect to a server.
|
* This is done by estabilishing a lease with the remoting clients that connect to a server.
|
||||||
* On the client side, an org.jboss.remoting.LeasePinger periodically sends PING messages to
|
* On the client side, an org.jboss.remoting.LeasePinger periodically sends PING messages to
|
||||||
* the server, and on the server side an org.jboss.remoting.Lease informs registered listeners
|
* the server, and on the server side an org.jboss.remoting.Lease informs registered listeners
|
||||||
* if the PING doesn't arrive withing the specified timeout period. */
|
* if the PING doesn't arrive withing the specified timeout period. */
|
||||||
clientMetadata.put(Client.ENABLE_LEASE, "true");
|
clientMetadata.put(Client.ENABLE_LEASE, "true");
|
||||||
/*
|
/*
|
||||||
When the socket client invoker makes its first invocation, it will check to see if there is an available
|
When the socket client invoker makes its first invocation, it will check to see if there is an available
|
||||||
socket connection in its pool. Since is the first invocation, there will not be and will create a new socket
|
socket connection in its pool. Since is the first invocation, there will not be and will create a new socket
|
||||||
connection and use it for making the invocation. Then when finished making invocation, will return the still
|
connection and use it for making the invocation. Then when finished making invocation, will return the still
|
||||||
active socket connection to the pool. As more client invocations are made, is possible for the number of
|
active socket connection to the pool. As more client invocations are made, is possible for the number of
|
||||||
socket connections to reach the maximum allowed (which is controlled by 'clientMaxPoolSize' property). At this
|
socket connections to reach the maximum allowed (which is controlled by 'clientMaxPoolSize' property). At this
|
||||||
point, when the next client invocation is made, it will wait up to some configured number of milliseconds, at
|
point, when the next client invocation is made, it will wait up to some configured number of milliseconds, at
|
||||||
which point it will throw an org.jboss.remoting.CannotConnectException. The number of milliseconds is given by
|
which point it will throw an org.jboss.remoting.CannotConnectException. The number of milliseconds is given by
|
||||||
the parameter MicroSocketClientInvoker.CONNECTION_WAIT (actual value "connectionWait"), with a default of
|
the parameter MicroSocketClientInvoker.CONNECTION_WAIT (actual value "connectionWait"), with a default of
|
||||||
30000 milliseconds. Note that if more than one call retry is configured (see next paragraph),
|
30000 milliseconds. Note that if more than one call retry is configured (see next paragraph),
|
||||||
the CannotConnectException will be swallowed.
|
the CannotConnectException will be swallowed.
|
||||||
Once the socket client invoker get an available socket connection from the pool, are not out of the woods yet.
|
Once the socket client invoker get an available socket connection from the pool, are not out of the woods yet.
|
||||||
For example, a network problem could cause a java.net.SocketException. There is also a possibility that the socket
|
For example, a network problem could cause a java.net.SocketException. There is also a possibility that the socket
|
||||||
connection, while still appearing to be valid, has "gone stale" while sitting in the pool. For example, a ServerThread
|
connection, while still appearing to be valid, has "gone stale" while sitting in the pool. For example, a ServerThread
|
||||||
on the other side of the connection could time out and close its socket. If the attempt to complete an invocation
|
on the other side of the connection could time out and close its socket. If the attempt to complete an invocation
|
||||||
fails, then MicroSocketClientInvoker will make a number of attempts, according to the parameter "numberOfCallRetries",
|
fails, then MicroSocketClientInvoker will make a number of attempts, according to the parameter "numberOfCallRetries",
|
||||||
with a default value of 3. Once the configured number of retries has been exhausted,
|
with a default value of 3. Once the configured number of retries has been exhausted,
|
||||||
an org.jboss.remoting.InvocationFailureException will be thrown.
|
an org.jboss.remoting.InvocationFailureException will be thrown.
|
||||||
*/
|
*/
|
||||||
clientMetadata.put("numberOfCallRetries", "1");
|
clientMetadata.put("numberOfCallRetries", "1");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I'll explain the meaning of "secondaryBindPort" and "secondaryConnectPort", and maybe that will help.
|
* I'll explain the meaning of "secondaryBindPort" and
|
||||||
* The Remoting bisocket transport creates two ServerSockets on the server. The "primary" ServerSocket is used to create
|
* "secondaryConnectPort", and maybe that will help. The Remoting
|
||||||
* connections used for ordinary invocations, e.g., a request to create a JMS consumer, and the "secondary" ServerSocket
|
* bisocket transport creates two ServerSockets on the server. The
|
||||||
* is used to create "control" connections for internal Remoting messages. The port for the primary ServerSocket is configured
|
* "primary" ServerSocket is used to create connections used for
|
||||||
* by the "serverBindPort" parameter, and the port for the secondary ServerSocket is, by default, chosen randomly.
|
* ordinary invocations, e.g., a request to create a JMS consumer,
|
||||||
* The "secondaryBindPort" parameter can be used to assign a specific port to the secondary ServerSocket. Now, if there is a
|
* and the "secondary" ServerSocket is used to create "control"
|
||||||
* translating firewall between the client and server, the client should be given the value of the port that is translated
|
* connections for internal Remoting messages. The port for the
|
||||||
* to the actual binding port of the secondary ServerSocket.
|
* primary ServerSocket is configured by the "serverBindPort"
|
||||||
* For example, your configuration will tell the secondary ServerSocket to bind to port 14000, and it will tell the client to
|
* parameter, and the port for the secondary ServerSocket is, by
|
||||||
* connect to port 14001. It assumes that there is a firewall which will translate 14001 to 14000. Apparently, that's not happening.
|
* 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.
|
// 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.
|
// 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.
|
// 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.
|
// Indicated the max number of threads used within oneway thread pool.
|
||||||
clientMetadata.put(Client.MAX_NUM_ONEWAY_THREADS, "10");
|
clientMetadata.put(Client.MAX_NUM_ONEWAY_THREADS, "10");
|
||||||
clientMetadata.put(Remoting.USE_CLIENT_CONNECTION_IDENTITY, "true");
|
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.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);
|
callbackClient.invoke(null);
|
||||||
|
|
||||||
this.sessionId = callbackClient.getSessionId();
|
this.sessionId = callbackClient.getSessionId();
|
||||||
|
|
@ -289,15 +293,15 @@ public class SessionImpl implements Session {
|
||||||
if (!connection.getUsername().equals("Admin")) {
|
if (!connection.getUsername().equals("Admin")) {
|
||||||
updateDatabase(connection.isForceDBComparison(), serverState);
|
updateDatabase(connection.isForceDBComparison(), serverState);
|
||||||
}
|
}
|
||||||
logger.info("Connected as " + (this.getUserName() == null ? "":this.getUserName()) + " to MAGE server at " + 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() +" ");
|
client.connected(this.getUserName() == null ? "" : this.getUserName() + "@" + connection.getHost() + ":" + connection.getPort() + " ");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
disconnect(false);
|
disconnect(false);
|
||||||
// client.showMessage("Unable to connect to server.");
|
// client.showMessage("Unable to connect to server.");
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
logger.fatal("", ex);
|
logger.fatal("", ex);
|
||||||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||||
} catch (UndeclaredThrowableException ex) {
|
} catch (UndeclaredThrowableException ex) {
|
||||||
String addMessage = "";
|
String addMessage = "";
|
||||||
if (ex.getCause() instanceof InvocationFailureException) {
|
if (ex.getCause() instanceof InvocationFailureException) {
|
||||||
|
|
@ -311,17 +315,17 @@ public class SessionImpl implements Session {
|
||||||
if (addMessage.isEmpty()) {
|
if (addMessage.isEmpty()) {
|
||||||
logger.fatal("", ex);
|
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) {
|
} catch (IOException ex) {
|
||||||
logger.fatal("", ex);
|
logger.fatal("", ex);
|
||||||
String addMessage = "";
|
String addMessage = "";
|
||||||
if (ex.getMessage() != null && ex.getMessage().startsWith("Unable to perform invocation")) {
|
if (ex.getMessage() != null && ex.getMessage().startsWith("Unable to perform invocation")) {
|
||||||
addMessage = "Maybe the server version is not compatible. ";
|
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) {
|
} catch (MageVersionException ex) {
|
||||||
if (!canceled) {
|
if (!canceled) {
|
||||||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||||
}
|
}
|
||||||
disconnect(false);
|
disconnect(false);
|
||||||
} catch (CannotConnectException ex) {
|
} catch (CannotConnectException ex) {
|
||||||
|
|
@ -334,7 +338,7 @@ public class SessionImpl implements Session {
|
||||||
disconnect(false);
|
disconnect(false);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Unable to connect to server.\n");
|
sb.append("Unable to connect to server.\n");
|
||||||
for (StackTraceElement element :t.getStackTrace()) {
|
for (StackTraceElement element : t.getStackTrace()) {
|
||||||
sb.append(element.toString()).append("\n");
|
sb.append(element.toString()).append("\n");
|
||||||
}
|
}
|
||||||
client.showMessage(sb.toString());
|
client.showMessage(sb.toString());
|
||||||
|
|
@ -350,8 +354,8 @@ public class SessionImpl implements Session {
|
||||||
List<CardInfo> cards = server.getMissingCardsData(classNames);
|
List<CardInfo> cards = server.getMissingCardsData(classNames);
|
||||||
CardRepository.instance.addCards(cards);
|
CardRepository.instance.addCards(cards);
|
||||||
CardRepository.instance.setContentVersion(serverState.getCardsContentVersion());
|
CardRepository.instance.setContentVersion(serverState.getCardsContentVersion());
|
||||||
logger.info("Updating client cards DB - existing cards: " + classNames.size() + " new cards: " + cards.size() +
|
logger.info("Updating client cards DB - existing cards: " + classNames.size() + " new cards: " + cards.size()
|
||||||
" content versions - server: " + serverState.getCardsContentVersion() + " client: " + cardDBVersion);
|
+ " content versions - server: " + serverState.getCardsContentVersion() + " client: " + cardDBVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
long expansionDBVersion = ExpansionRepository.instance.getContentVersionFromDB();
|
long expansionDBVersion = ExpansionRepository.instance.getContentVersionFromDB();
|
||||||
|
|
@ -362,8 +366,8 @@ public class SessionImpl implements Session {
|
||||||
ExpansionRepository.instance.add(expansion);
|
ExpansionRepository.instance.add(expansion);
|
||||||
}
|
}
|
||||||
ExpansionRepository.instance.setContentVersion(serverState.getExpansionsContentVersion());
|
ExpansionRepository.instance.setContentVersion(serverState.getExpansionsContentVersion());
|
||||||
logger.info("Updating client expansions DB - existing sets: " + setCodes.size() + " new sets: " + expansions.size()+
|
logger.info("Updating client expansions DB - existing sets: " + setCodes.size() + " new sets: " + expansions.size()
|
||||||
" content versions - server: " + serverState.getExpansionsContentVersion() + " client: " + expansionDBVersion);
|
+ " 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
|
@Override
|
||||||
public synchronized void disconnect(boolean askForReconnect) {
|
public synchronized void disconnect(boolean askForReconnect) {
|
||||||
|
|
@ -450,10 +455,11 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
class CallbackHandler implements InvokerCallbackHandler {
|
class CallbackHandler implements InvokerCallbackHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCallback(Callback callback) throws HandleCallbackException {
|
public void handleCallback(Callback callback) throws HandleCallbackException {
|
||||||
//logger.info("callback handler");
|
//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();
|
return serverState.getDraftCubes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TournamentTypeView> getTournamentTypes() {
|
public List<TournamentTypeView> getTournamentTypes() {
|
||||||
return serverState.getTournamentTypes();
|
return serverState.getTournamentTypes();
|
||||||
|
|
@ -1020,6 +1025,7 @@ public class SessionImpl implements Session {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove table - called from admin console
|
* Remove table - called from admin console
|
||||||
|
*
|
||||||
* @param tableId
|
* @param tableId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -1107,7 +1113,6 @@ public class SessionImpl implements Session {
|
||||||
// }
|
// }
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -1384,14 +1389,13 @@ public class SessionImpl implements Session {
|
||||||
client.showError(ex.getMessage());
|
client.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return connection.getUsername();
|
return connection.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updatePreferencesForServer(UserDataView userData) {
|
public boolean updatePreferencesForServer(UserData userData) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.setUserData(connection.getUsername(), sessionId, userData);
|
server.setUserData(connection.getUsername(), sessionId, userData);
|
||||||
|
|
@ -1411,26 +1415,26 @@ public class SessionImpl implements Session {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
if (!server.ping(sessionId, pingInfo)) {
|
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");
|
throw new MageException("Ping failed");
|
||||||
}
|
}
|
||||||
pingTime.add(System.nanoTime() - startTime);
|
pingTime.add(System.nanoTime() - startTime);
|
||||||
long milliSeconds = TimeUnit.MILLISECONDS.convert(pingTime.getLast(), TimeUnit.NANOSECONDS);
|
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) {
|
if (pingTime.size() > PING_CYCLES) {
|
||||||
pingTime.poll();
|
pingTime.poll();
|
||||||
}
|
}
|
||||||
long sum = 0;
|
long sum = 0;
|
||||||
for (Long time :pingTime) {
|
for (Long time : pingTime) {
|
||||||
sum += time;
|
sum += time;
|
||||||
}
|
}
|
||||||
milliSeconds = TimeUnit.MILLISECONDS.convert(sum / pingTime.size(), TimeUnit.NANOSECONDS);
|
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;
|
return true;
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
|
|
@ -1448,7 +1452,6 @@ public class SessionImpl implements Session {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MageAuthenticator extends Authenticator {
|
class MageAuthenticator extends Authenticator {
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
|
|
@ -1460,7 +1463,7 @@ class MageAuthenticator extends Authenticator {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PasswordAuthentication getPasswordAuthentication () {
|
public PasswordAuthentication getPasswordAuthentication() {
|
||||||
return new PasswordAuthentication (username, password.toCharArray());
|
return new PasswordAuthentication(username, password.toCharArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.remote.interfaces;
|
package mage.remote.interfaces;
|
||||||
|
|
||||||
import mage.view.UserDataView;
|
import mage.players.net.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author noxx
|
* @author noxx
|
||||||
|
|
@ -36,5 +36,5 @@ public interface ClientData {
|
||||||
|
|
||||||
String getUserName();
|
String getUserName();
|
||||||
|
|
||||||
boolean updatePreferencesForServer(UserDataView userData);
|
boolean updatePreferencesForServer(UserData userData);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -44,12 +43,14 @@ import mage.game.command.Commander;
|
||||||
import mage.game.command.Emblem;
|
import mage.game.command.Emblem;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.players.net.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class PlayerView implements Serializable {
|
public class PlayerView implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final UUID playerId;
|
private final UUID playerId;
|
||||||
|
|
@ -67,7 +68,7 @@ public class PlayerView implements Serializable {
|
||||||
private final CardsView exile = new CardsView();
|
private final CardsView exile = new CardsView();
|
||||||
private final Map<UUID, PermanentView> battlefield = new LinkedHashMap<>();
|
private final Map<UUID, PermanentView> battlefield = new LinkedHashMap<>();
|
||||||
private final CardView topCard;
|
private final CardView topCard;
|
||||||
private final UserDataView userDataView;
|
private final UserData userData;
|
||||||
private final List<CommandObjectView> commandList = new ArrayList<>();
|
private final List<CommandObjectView> commandList = new ArrayList<>();
|
||||||
private final List<UUID> attachments = new ArrayList<>();
|
private final List<UUID> attachments = new ArrayList<>();
|
||||||
private final int statesSavedSize;
|
private final int statesSavedSize;
|
||||||
|
|
@ -89,12 +90,12 @@ public class PlayerView implements Serializable {
|
||||||
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
||||||
this.hasPriority = player.getId().equals(state.getPriorityPlayerId());
|
this.hasPriority = player.getId().equals(state.getPriorityPlayerId());
|
||||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||||
this.timerActive = (this.hasPriority && player.isGameUnderControl()) ||
|
this.timerActive = (this.hasPriority && player.isGameUnderControl())
|
||||||
(player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId())) ||
|
|| (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId()))
|
||||||
player.getId().equals(game.getState().getChoosingPlayerId());
|
|| player.getId().equals(game.getState().getChoosingPlayerId());
|
||||||
|
|
||||||
this.hasLeft = player.hasLeft();
|
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));
|
graveyard.put(card.getId(), new CardView(card, game, false));
|
||||||
}
|
}
|
||||||
for (ExileZone exileZone : game.getExile().getExileZones()) {
|
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)) {
|
if (showInBattlefield(permanent, state)) {
|
||||||
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()), createdForPlayerId, game);
|
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()), createdForPlayerId, game);
|
||||||
battlefield.put(view.getId(), view);
|
battlefield.put(view.getId(), view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0 ?
|
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0
|
||||||
new CardView(player.getLibrary().getFromTop(game)) : null;
|
? new CardView(player.getLibrary().getFromTop(game)) : null;
|
||||||
if (player.getUserData() != null) {
|
if (player.getUserData() != null) {
|
||||||
this.userDataView = new UserDataView(player.getUserData());
|
this.userData = player.getUserData();
|
||||||
} else {
|
} else {
|
||||||
this.userDataView = UserDataView.getDefaultUserDataView();
|
this.userData = UserData.getDefaultUserDataView();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CommandObject commandObject : game.getState().getCommand()) {
|
for (CommandObject commandObject : game.getState().getCommand()) {
|
||||||
if (commandObject instanceof Emblem) {
|
if (commandObject instanceof Emblem) {
|
||||||
Emblem emblem = (Emblem) commandObject;
|
Emblem emblem = (Emblem) commandObject;
|
||||||
if (emblem.getControllerId().equals(this.playerId)) {
|
if (emblem.getControllerId().equals(this.playerId)) {
|
||||||
Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId());
|
Card sourceCard = game.getCard(((CommandObject) emblem).getSourceId());
|
||||||
if (sourceCard != null) {
|
if (sourceCard != null) {
|
||||||
commandList.add(new EmblemView(emblem, sourceCard));
|
commandList.add(new EmblemView(emblem, sourceCard));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (commandObject instanceof Commander) {
|
||||||
else if(commandObject instanceof Commander){
|
Commander commander = (Commander) commandObject;
|
||||||
Commander commander = (Commander)commandObject;
|
if (commander.getControllerId().equals(this.playerId)) {
|
||||||
if(commander.getControllerId().equals(this.playerId)){
|
|
||||||
Card sourceCard = game.getCard(commander.getSourceId());
|
Card sourceCard = game.getCard(commander.getSourceId());
|
||||||
if(sourceCard != null){
|
if (sourceCard != null) {
|
||||||
commandList.add(new CommanderView(commander, sourceCard, game));
|
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
|
//show permanents controlled by player or attachments to permanents controlled by player
|
||||||
if (permanent.getAttachedTo() == null) {
|
if (permanent.getAttachedTo() == null) {
|
||||||
return permanent.getControllerId().equals(playerId);
|
return permanent.getControllerId().equals(playerId);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Permanent attachedTo = state.getPermanent(permanent.getAttachedTo());
|
Permanent attachedTo = state.getPermanent(permanent.getAttachedTo());
|
||||||
if (attachedTo != null) {
|
if (attachedTo != null) {
|
||||||
return attachedTo.getControllerId().equals(playerId);
|
return attachedTo.getControllerId().equals(playerId);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return permanent.getControllerId().equals(playerId);
|
return permanent.getControllerId().equals(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -221,8 +219,8 @@ public class PlayerView implements Serializable {
|
||||||
return this.topCard;
|
return this.topCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDataView getUserData() {
|
public UserData getUserData() {
|
||||||
return this.userDataView;
|
return this.userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CommandObjectView> getCommadObjectList() {
|
public List<CommandObjectView> getCommadObjectList() {
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -37,16 +36,23 @@ import mage.game.Seat;
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class SeatView implements Serializable {
|
public class SeatView implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final String flagName;
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private String playerName;
|
private final String playerName;
|
||||||
private String playerType;
|
private final String playerType;
|
||||||
|
|
||||||
public SeatView(Seat seat) {
|
public SeatView(Seat seat) {
|
||||||
if (seat.getPlayer() != null) {
|
if (seat.getPlayer() != null) {
|
||||||
this.playerId = seat.getPlayer().getId();
|
this.playerId = seat.getPlayer().getId();
|
||||||
this.playerName = seat.getPlayer().getName();
|
this.playerName = seat.getPlayer().getName();
|
||||||
|
this.flagName = seat.getPlayer().getUserData().getFlagName();
|
||||||
|
} else {
|
||||||
|
// Empty seat
|
||||||
|
this.playerName = "";
|
||||||
|
this.flagName = "";
|
||||||
}
|
}
|
||||||
this.playerType = seat.getPlayerType();
|
this.playerType = seat.getPlayerType();
|
||||||
}
|
}
|
||||||
|
|
@ -63,4 +69,8 @@ public class SeatView implements Serializable {
|
||||||
return playerType;
|
return playerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFlagName() {
|
||||||
|
return flagName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -35,9 +34,11 @@ import mage.game.tournament.TournamentPlayer;
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class TournamentPlayerView implements Serializable, Comparable{
|
public class TournamentPlayerView implements Serializable, Comparable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final String flagName;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String state;
|
private final String state;
|
||||||
private final String results;
|
private final String results;
|
||||||
|
|
@ -46,7 +47,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
|
||||||
|
|
||||||
TournamentPlayerView(TournamentPlayer tournamentPlayer) {
|
TournamentPlayerView(TournamentPlayer tournamentPlayer) {
|
||||||
this.name = tournamentPlayer.getPlayer().getName();
|
this.name = tournamentPlayer.getPlayer().getName();
|
||||||
StringBuilder sb = new StringBuilder(tournamentPlayer.getState().toString());
|
StringBuilder sb = new StringBuilder(tournamentPlayer.getState().toString());
|
||||||
String stateInfo = tournamentPlayer.getStateInfo();
|
String stateInfo = tournamentPlayer.getStateInfo();
|
||||||
if (!stateInfo.isEmpty()) {
|
if (!stateInfo.isEmpty()) {
|
||||||
sb.append(" (").append(stateInfo).append(")");
|
sb.append(" (").append(stateInfo).append(")");
|
||||||
|
|
@ -56,6 +57,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
|
||||||
this.points = tournamentPlayer.getPoints();
|
this.points = tournamentPlayer.getPoints();
|
||||||
this.results = tournamentPlayer.getResults();
|
this.results = tournamentPlayer.getResults();
|
||||||
this.quit = !tournamentPlayer.isInTournament();
|
this.quit = !tournamentPlayer.isInTournament();
|
||||||
|
this.flagName = tournamentPlayer.getPlayer().getUserData().getFlagName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
@ -83,4 +85,7 @@ public class TournamentPlayerView implements Serializable, Comparable{
|
||||||
return ((TournamentPlayerView) t).getPoints() - this.getPoints();
|
return ((TournamentPlayerView) t).getPoints() - this.getPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFlagName() {
|
||||||
|
return flagName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package mage.view;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
|
import mage.players.net.UserGroup;
|
||||||
import mage.players.net.UserSkipPrioritySteps;
|
import mage.players.net.UserSkipPrioritySteps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,8 +21,8 @@ public class UserDataView implements Serializable {
|
||||||
String flagName;
|
String flagName;
|
||||||
protected boolean askMoveToGraveOrder;
|
protected boolean askMoveToGraveOrder;
|
||||||
|
|
||||||
static UserDataView getDefaultUserDataView() {
|
static UserData getDefaultUserDataView() {
|
||||||
return new UserDataView(0, false, false, true, null,"world.png", false);
|
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, "world.png", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
|
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -52,6 +51,7 @@ import mage.interfaces.ActionWithResult;
|
||||||
import mage.interfaces.MageServer;
|
import mage.interfaces.MageServer;
|
||||||
import mage.interfaces.ServerState;
|
import mage.interfaces.ServerState;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.players.net.UserData;
|
||||||
import mage.remote.MageVersionException;
|
import mage.remote.MageVersionException;
|
||||||
import mage.server.draft.CubeFactory;
|
import mage.server.draft.CubeFactory;
|
||||||
import mage.server.draft.DraftManager;
|
import mage.server.draft.DraftManager;
|
||||||
|
|
@ -83,7 +83,6 @@ import mage.view.MatchView;
|
||||||
import mage.view.RoomUsersView;
|
import mage.view.RoomUsersView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
import mage.view.UserDataView;
|
|
||||||
import mage.view.UserView;
|
import mage.view.UserView;
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -117,7 +116,7 @@ public class MageServerImpl implements MageServer {
|
||||||
return SessionManager.getInstance().registerUser(sessionId, userName);
|
return SessionManager.getInstance().registerUser(sessionId, userName);
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
if (ex instanceof MageVersionException) {
|
if (ex instanceof MageVersionException) {
|
||||||
throw (MageVersionException)ex;
|
throw (MageVersionException) ex;
|
||||||
}
|
}
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -125,11 +124,11 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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() {
|
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
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 {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -310,8 +308,7 @@ public class MageServerImpl implements MageServer {
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -326,8 +323,7 @@ public class MageServerImpl implements MageServer {
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -343,8 +339,7 @@ public class MageServerImpl implements MageServer {
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -365,7 +360,6 @@ public class MageServerImpl implements MageServer {
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
||||||
|
|
@ -391,7 +385,6 @@ public class MageServerImpl implements MageServer {
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
||||||
|
|
@ -412,8 +405,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public TournamentView getTournament(UUID tournamentId) throws MageException {
|
public TournamentView getTournament(UUID tournamentId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return TournamentManager.getInstance().getTournamentView(tournamentId);
|
return TournamentManager.getInstance().getTournamentView(tournamentId);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -424,15 +416,14 @@ public class MageServerImpl implements MageServer {
|
||||||
public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
||||||
try {
|
try {
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ChatManager.getInstance().broadcast(chatId, userName, StringEscapeUtils.escapeHtml4(message), MessageColor.BLUE);
|
ChatManager.getInstance().broadcast(chatId, userName, StringEscapeUtils.escapeHtml4(message), MessageColor.BLUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -464,8 +455,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public UUID getMainRoomId() throws MageException {
|
public UUID getMainRoomId() throws MageException {
|
||||||
try {
|
try {
|
||||||
return GamesRoomManager.getInstance().getMainRoomId();
|
return GamesRoomManager.getInstance().getMainRoomId();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -476,8 +466,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public UUID getRoomChatId(UUID roomId) throws MageException {
|
public UUID getRoomChatId(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GamesRoomManager.getInstance().getRoom(roomId).getChatId();
|
return GamesRoomManager.getInstance().getRoom(roomId).getChatId();
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -527,8 +516,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public UUID getTableChatId(UUID tableId) throws MageException {
|
public UUID getTableChatId(UUID tableId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return TableManager.getInstance().getChatId(tableId);
|
return TableManager.getInstance().getChatId(tableId);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -572,8 +560,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public UUID getGameChatId(UUID gameId) throws MageException {
|
public UUID getGameChatId(UUID gameId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GameManager.getInstance().getChatId(gameId);
|
return GameManager.getInstance().getChatId(gameId);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -584,8 +571,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public UUID getTournamentChatId(UUID tournamentId) throws MageException {
|
public UUID getTournamentChatId(UUID tournamentId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return TournamentManager.getInstance().getChatId(tournamentId);
|
return TournamentManager.getInstance().getChatId(tournamentId);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -675,8 +661,8 @@ public class MageServerImpl implements MageServer {
|
||||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
return DraftManager.getInstance().sendCardPick(draftId, session.getUserId(), cardPick, hiddenCards);
|
return DraftManager.getInstance().sendCardPick(draftId, session.getUserId(), cardPick, hiddenCards);
|
||||||
} else{
|
} else {
|
||||||
logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId);
|
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -691,8 +677,8 @@ public class MageServerImpl implements MageServer {
|
||||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
DraftManager.getInstance().sendCardMark(draftId, session.getUserId(), cardPick);
|
DraftManager.getInstance().sendCardMark(draftId, session.getUserId(), cardPick);
|
||||||
} else{
|
} else {
|
||||||
logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId);
|
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -706,8 +692,8 @@ public class MageServerImpl implements MageServer {
|
||||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
GameManager.getInstance().quitMatch(gameId, session.getUserId());
|
GameManager.getInstance().quitMatch(gameId, session.getUserId());
|
||||||
} else{
|
} else {
|
||||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" +gameId);
|
logger.error("Session not found sessionId: " + sessionId + " gameId:" + gameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -721,8 +707,8 @@ public class MageServerImpl implements MageServer {
|
||||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
TournamentManager.getInstance().quit(tournamentId, session.getUserId());
|
TournamentManager.getInstance().quit(tournamentId, session.getUserId());
|
||||||
}else{
|
} else {
|
||||||
logger.error("Session not found sessionId: "+ sessionId + " tournamentId:" + tournamentId);
|
logger.error("Session not found sessionId: " + sessionId + " tournamentId:" + tournamentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -735,7 +721,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
logger.error("Session not found sessionId: "+ sessionId + " draftId:" + draftId);
|
logger.error("Session not found sessionId: " + sessionId + " draftId:" + draftId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID tableId = DraftManager.getInstance().getControllerByDraftId(draftId).getTableId();
|
UUID tableId = DraftManager.getInstance().getControllerByDraftId(draftId).getTableId();
|
||||||
|
|
@ -755,7 +741,7 @@ public class MageServerImpl implements MageServer {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
logger.error("Session not found sessionId: " + sessionId + " gameId:" + gameId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GameManager.getInstance().sendPlayerAction(playerAction, gameId, session.getUserId(), data);
|
GameManager.getInstance().sendPlayerAction(playerAction, gameId, session.getUserId(), data);
|
||||||
|
|
@ -893,8 +879,7 @@ public class MageServerImpl implements MageServer {
|
||||||
CardRepository.instance.getContentVersionConstant(),
|
CardRepository.instance.getContentVersionConstant(),
|
||||||
ExpansionRepository.instance.getContentVersionConstant()
|
ExpansionRepository.instance.getContentVersionConstant()
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -925,7 +910,7 @@ public class MageServerImpl implements MageServer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleException(Exception ex) throws MageException {
|
public void handleException(Exception ex) throws MageException {
|
||||||
if (!ex.getMessage().equals("No message")) {
|
if (!ex.getMessage().equals("No message")) {
|
||||||
|
|
@ -936,12 +921,12 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameView getGameView(final UUID gameId, final String sessionId, final UUID playerId) throws MageException {
|
public GameView getGameView(final UUID gameId, final String sessionId, final UUID playerId) throws MageException {
|
||||||
return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult<GameView>() {
|
return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult<GameView>() {
|
||||||
@Override
|
@Override
|
||||||
public GameView execute() throws MageException {
|
public GameView execute() throws MageException {
|
||||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||||
return GameManager.getInstance().getGameView(gameId, userId, playerId);
|
return GameManager.getInstance().getGameView(gameId, userId, playerId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1009,9 +994,9 @@ public class MageServerImpl implements MageServer {
|
||||||
public Object getServerMessagesCompressed(String sessionId) throws MageException {
|
public Object getServerMessagesCompressed(String sessionId) throws MageException {
|
||||||
return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult<Object>() {
|
return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object execute() throws MageException {
|
public Object execute() throws MageException {
|
||||||
return CompressUtil.compress(ServerMessagesUtil.getInstance().getMessages());
|
return CompressUtil.compress(ServerMessagesUtil.getInstance().getMessages());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1061,23 +1046,22 @@ public class MageServerImpl implements MageServer {
|
||||||
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
||||||
try {
|
try {
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
||||||
try {
|
try {
|
||||||
action.execute();
|
action.execute();
|
||||||
} catch (MageException me) {
|
} catch (MageException me) {
|
||||||
throw new RuntimeException(me);
|
throw new RuntimeException(me);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogServiceImpl.instance.log(LogKeys.KEY_NOT_VALID_SESSION_INTERNAL, actionName, sessionId);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
LogServiceImpl.instance.log(LogKeys.KEY_NOT_VALID_SESSION_INTERNAL, actionName, sessionId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -42,7 +41,6 @@ import mage.players.net.UserData;
|
||||||
import mage.players.net.UserGroup;
|
import mage.players.net.UserGroup;
|
||||||
import mage.server.game.GamesRoomManager;
|
import mage.server.game.GamesRoomManager;
|
||||||
import mage.server.util.ConfigSettings;
|
import mage.server.util.ConfigSettings;
|
||||||
import mage.view.UserDataView;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jboss.remoting.callback.AsynchInvokerCallbackHandler;
|
import org.jboss.remoting.callback.AsynchInvokerCallbackHandler;
|
||||||
import org.jboss.remoting.callback.Callback;
|
import org.jboss.remoting.callback.Callback;
|
||||||
|
|
@ -144,75 +142,45 @@ public class Session {
|
||||||
}
|
}
|
||||||
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, false, false, null, "world.png", false));
|
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, false, false, null, "world.png", false));
|
||||||
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
||||||
logger.info("Error connecting Admin!");
|
logger.info("Error connecting Admin!");
|
||||||
}
|
}
|
||||||
this.userId = user.getId();
|
this.userId = user.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setUserData(String userName, UserDataView userDataView) {
|
public boolean setUserData(String userName, UserData userData) {
|
||||||
User user = UserManager.getInstance().findUser(userName);
|
User user = UserManager.getInstance().findUser(userName);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
UserData userData = user.getUserData();
|
if (user.getUserData() == null || user.getUserData().getGroupId() == UserGroup.DEFAULT.getGroupId()) {
|
||||||
if (userData == null) {
|
|
||||||
userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(),
|
|
||||||
userDataView.isShowAbilityPickerForced(), userDataView.allowRequestShowHandCards(),
|
|
||||||
userDataView.confirmEmptyManaPool(), userDataView.getUserSkipPrioritySteps(),
|
|
||||||
userDataView.getFlagName(), userDataView.askMoveToGraveOrder());
|
|
||||||
user.setUserData(userData);
|
user.setUserData(userData);
|
||||||
} else {
|
} else {
|
||||||
if (userDataView.getAvatarId() == 51) { // Update special avatar if first avatar is selected
|
user.getUserData().update(userData);
|
||||||
updateAvatar(userName, userData);
|
}
|
||||||
}
|
if (user.getUserData().getAvatarId() == 51) {
|
||||||
userData.setAvatarId(userDataView.getAvatarId());
|
user.getUserData().setAvatarId(updateAvatar(user.getName()));
|
||||||
userData.setShowAbilityPickerForced(userDataView.isShowAbilityPickerForced());
|
|
||||||
userData.setAllowRequestShowHandCards(userDataView.allowRequestShowHandCards());
|
|
||||||
userData.setUserSkipPrioritySteps(userDataView.getUserSkipPrioritySteps());
|
|
||||||
userData.setConfirmEmptyManaPool(userDataView.confirmEmptyManaPool());
|
|
||||||
userData.setAskMoveToGraveOrder(userDataView.askMoveToGraveOrder());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAvatar(String userName, UserData userData) {
|
private int updateAvatar(String userName) {
|
||||||
//TODO: move to separate class
|
//TODO: move to separate class
|
||||||
//TODO: add for checking for private key
|
//TODO: add for checking for private key
|
||||||
switch (userName) {
|
switch (userName) {
|
||||||
case "nantuko":
|
case "nantuko":
|
||||||
userData.setAvatarId(1000);
|
return 1000;
|
||||||
break;
|
|
||||||
case "i_no_k":
|
|
||||||
userData.setAvatarId(1002);
|
|
||||||
break;
|
|
||||||
case "Askael":
|
|
||||||
userData.setAvatarId(1004);
|
|
||||||
break;
|
|
||||||
case "North":
|
case "North":
|
||||||
userData.setAvatarId(1006);
|
return 1006;
|
||||||
break;
|
|
||||||
case "BetaSteward":
|
case "BetaSteward":
|
||||||
userData.setAvatarId(1008);
|
return 1008;
|
||||||
break;
|
|
||||||
case "Arching":
|
|
||||||
userData.setAvatarId(1010);
|
|
||||||
break;
|
|
||||||
case "loki":
|
case "loki":
|
||||||
userData.setAvatarId(1012);
|
return 1012;
|
||||||
break;
|
|
||||||
case "Alive":
|
|
||||||
userData.setAvatarId(1014);
|
|
||||||
break;
|
|
||||||
case "Rahan":
|
|
||||||
userData.setAvatarId(1016);
|
|
||||||
break;
|
|
||||||
case "Ayrat":
|
case "Ayrat":
|
||||||
userData.setAvatarId(1018);
|
return 1018;
|
||||||
break;
|
|
||||||
case "Bandit":
|
case "Bandit":
|
||||||
userData.setAvatarId(1020);
|
return 1020;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
return 51;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
|
@ -220,10 +188,10 @@ public class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
// because different threads can activate this
|
// because different threads can activate this
|
||||||
public void userLostConnection() {
|
public void userLostConnection() {
|
||||||
boolean lockSet = false;
|
boolean lockSet = false;
|
||||||
try {
|
try {
|
||||||
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
if (lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||||
lockSet = true;
|
lockSet = true;
|
||||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -243,9 +211,8 @@ public class Session {
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
logger.error("SESSION LOCK lost connection - userId: " + userId, ex);
|
logger.error("SESSION LOCK lost connection - userId: " + userId, ex);
|
||||||
}
|
} finally {
|
||||||
finally {
|
if (lockSet) {
|
||||||
if (lockSet) {
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
logger.trace("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
logger.trace("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +223,7 @@ public class Session {
|
||||||
public void kill(DisconnectReason reason) {
|
public void kill(DisconnectReason reason) {
|
||||||
boolean lockSet = false;
|
boolean lockSet = false;
|
||||||
try {
|
try {
|
||||||
if(lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
if (lock.tryLock(5000, TimeUnit.MILLISECONDS)) {
|
||||||
lockSet = true;
|
lockSet = true;
|
||||||
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
logger.debug("SESSION LOCK SET sessionId: " + sessionId);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -265,9 +232,8 @@ public class Session {
|
||||||
UserManager.getInstance().removeUser(userId, reason);
|
UserManager.getInstance().removeUser(userId, reason);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
logger.error("SESSION LOCK - kill: userId " + userId, ex);
|
logger.error("SESSION LOCK - kill: userId " + userId, ex);
|
||||||
}
|
} finally {
|
||||||
finally {
|
if (lockSet) {
|
||||||
if (lockSet) {
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
logger.debug("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
logger.debug("SESSION LOCK UNLOCK sessionId: " + sessionId);
|
||||||
|
|
||||||
|
|
@ -282,7 +248,7 @@ public class Session {
|
||||||
callbackHandler.handleCallbackOneway(new Callback(call));
|
callbackHandler.handleCallbackOneway(new Callback(call));
|
||||||
} catch (HandleCallbackException ex) {
|
} catch (HandleCallbackException ex) {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
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(" - method: " + call.getMethod());
|
||||||
logger.warn(" - cause: " + getBasicCause(ex).toString());
|
logger.warn(" - cause: " + getBasicCause(ex).toString());
|
||||||
logger.trace("Stack trace:", ex);
|
logger.trace("Stack trace:", ex);
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
|
import mage.players.net.UserData;
|
||||||
import mage.server.services.LogKeys;
|
import mage.server.services.LogKeys;
|
||||||
import mage.server.services.impl.LogServiceImpl;
|
import mage.server.services.impl.LogServiceImpl;
|
||||||
import mage.view.UserDataView;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class SessionManager {
|
||||||
public boolean registerUser(String sessionId, String userName) throws MageException {
|
public boolean registerUser(String sessionId, String userName) throws MageException {
|
||||||
Session session = sessions.get(sessionId);
|
Session session = sessions.get(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
String returnMessage = session.registerUser(userName);
|
String returnMessage = session.registerUser(userName);
|
||||||
if (returnMessage == null) {
|
if (returnMessage == null) {
|
||||||
LogServiceImpl.instance.log(LogKeys.KEY_USER_CONNECTED, userName, session.getHost(), sessionId);
|
LogServiceImpl.instance.log(LogKeys.KEY_USER_CONNECTED, userName, session.getHost(), sessionId);
|
||||||
|
|
||||||
|
|
@ -102,10 +102,10 @@ public class SessionManager {
|
||||||
return false;
|
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);
|
Session session = sessions.get(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.setUserData(userName, userDataView);
|
session.setUserData(userName, userData);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -119,7 +119,7 @@ public class SessionManager {
|
||||||
// session was removed meanwhile by another thread so we can return
|
// session was removed meanwhile by another thread so we can return
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.debug("DISCONNECT " + reason.toString() + " - sessionId: "+ sessionId);
|
logger.debug("DISCONNECT " + reason.toString() + " - sessionId: " + sessionId);
|
||||||
sessions.remove(sessionId);
|
sessions.remove(sessionId);
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case Disconnected:
|
case Disconnected:
|
||||||
|
|
@ -135,7 +135,7 @@ public class SessionManager {
|
||||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED, sessionId);
|
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED, sessionId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.error("endSession: unexpected reason " + reason.toString() + " - sessionId: "+ sessionId);
|
logger.error("endSession: unexpected reason " + reason.toString() + " - sessionId: " + sessionId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sessions.remove(sessionId);
|
sessions.remove(sessionId);
|
||||||
|
|
@ -155,6 +155,7 @@ public class SessionManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin requested the disconnect of a user
|
* Admin requested the disconnect of a user
|
||||||
|
*
|
||||||
* @param sessionId
|
* @param sessionId
|
||||||
* @param userSessionId
|
* @param userSessionId
|
||||||
*/
|
*/
|
||||||
|
|
@ -163,12 +164,12 @@ public class SessionManager {
|
||||||
User userAdmin, user;
|
User userAdmin, user;
|
||||||
if ((userAdmin = getUserFromSession(sessionId)) != null) {
|
if ((userAdmin = getUserFromSession(sessionId)) != null) {
|
||||||
if ((user = getUserFromSession(userSessionId)) != 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.");
|
userAdmin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected.");
|
||||||
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
||||||
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED_BY_ADMIN, sessionId, userSessionId);
|
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED_BY_ADMIN, sessionId, userSessionId);
|
||||||
} else {
|
} 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.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -103,8 +102,7 @@ public class TableController {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
// TODO: Handle if user == null
|
// TODO: Handle if user == null
|
||||||
controllerName = user.getName();
|
controllerName = user.getName();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
controllerName = "System";
|
controllerName = "System";
|
||||||
}
|
}
|
||||||
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match);
|
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 {
|
} else {
|
||||||
controllerName = user.getName();
|
controllerName = user.getName();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
controllerName = "System";
|
controllerName = "System";
|
||||||
}
|
}
|
||||||
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
|
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
|
||||||
|
|
@ -133,20 +130,20 @@ public class TableController {
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
match.addTableEventListener(
|
match.addTableEventListener(
|
||||||
new Listener<TableEvent> () {
|
new Listener<TableEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void event(TableEvent event) {
|
public void event(TableEvent event) {
|
||||||
try {
|
try {
|
||||||
switch (event.getEventType()) {
|
switch (event.getEventType()) {
|
||||||
case SIDEBOARD:
|
case SIDEBOARD:
|
||||||
sideboard(event.getPlayerId(), event.getDeck());
|
sideboard(event.getPlayerId(), event.getDeck());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
} catch (MageException ex) {
|
||||||
|
logger.fatal("Table event listener error", ex);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
|
||||||
logger.fatal("Table event listener error", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,13 +168,13 @@ public class TableController {
|
||||||
return false;
|
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());
|
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Deck deck = null;
|
Deck deck = null;
|
||||||
if (!table.getTournament().getTournamentType().isLimited()) {
|
if (!table.getTournament().getTournamentType().isLimited()) {
|
||||||
if (deckList != null) {
|
if (deckList != null) {
|
||||||
deck = Deck.load(deckList, false, false);
|
deck = Deck.load(deckList, false, false);
|
||||||
} else {
|
} else {
|
||||||
user.showUserMessage("Join Table", "No valid deck selected!");
|
user.showUserMessage("Join Table", "No valid deck selected!");
|
||||||
|
|
@ -210,7 +207,7 @@ public class TableController {
|
||||||
tournamentPlayer.submitDeck(deck);
|
tournamentPlayer.submitDeck(deck);
|
||||||
}
|
}
|
||||||
table.joinTable(player, seat);
|
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
|
//only inform human players and add them to sessionPlayerMap
|
||||||
if (seat.getPlayer().isHuman()) {
|
if (seat.getPlayer().isHuman()) {
|
||||||
seat.getPlayer().setUserData(user.getUserData());
|
seat.getPlayer().setUserData(user.getUserData());
|
||||||
|
|
@ -250,7 +247,7 @@ public class TableController {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return false;
|
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());
|
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -289,7 +286,7 @@ public class TableController {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
String message = new StringBuilder("Could not create player ").append(name).append(" of type ").append(seat.getPlayerType()).toString();
|
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());
|
logger.warn(new StringBuilder("User: ").append(user.getName()).append(" => ").append(message).toString());
|
||||||
user.showUserMessage("Join Table",message);
|
user.showUserMessage("Join Table", message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logger.debug("DECK validated: " + table.getValidator().getName() + " " + player.getName() + " " + deck.getName());
|
logger.debug("DECK validated: " + table.getValidator().getName() + " " + player.getName() + " " + deck.getName());
|
||||||
|
|
@ -312,7 +309,7 @@ public class TableController {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(UUID userId, Player player, String playerType, Deck deck) throws GameException {
|
public void addPlayer(UUID userId, Player player, String playerType, Deck deck) throws GameException {
|
||||||
if (table.getState() != TableState.WAITING) {
|
if (table.getState() != TableState.WAITING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -378,8 +375,7 @@ public class TableController {
|
||||||
if (table.getState() == TableState.SIDEBOARDING) {
|
if (table.getState() == TableState.SIDEBOARDING) {
|
||||||
match.submitDeck(playerId, deck);
|
match.submitDeck(playerId, deck);
|
||||||
UserManager.getInstance().getUser(userId).removeSideboarding(table.getId());
|
UserManager.getInstance().getUser(userId).removeSideboarding(table.getId());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
TournamentManager.getInstance().submitDeck(tournament.getId(), playerId, deck);
|
TournamentManager.getInstance().submitDeck(tournament.getId(), playerId, deck);
|
||||||
UserManager.getInstance().getUser(userId).removeConstructing(playerId);
|
UserManager.getInstance().getUser(userId).removeConstructing(playerId);
|
||||||
}
|
}
|
||||||
|
|
@ -390,7 +386,7 @@ public class TableController {
|
||||||
if (tournament != null) {
|
if (tournament != null) {
|
||||||
TournamentManager.getInstance().updateDeck(tournament.getId(), playerId, deck);
|
TournamentManager.getInstance().updateDeck(tournament.getId(), playerId, deck);
|
||||||
} else {
|
} else {
|
||||||
logger.fatal("Tournament == null table: " + table.getId() +" userId: " + userId);
|
logger.fatal("Tournament == null table: " + table.getId() + " userId: " + userId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (TableState.SIDEBOARDING.equals(table.getState())) {
|
if (TableState.SIDEBOARDING.equals(table.getState())) {
|
||||||
|
|
@ -427,13 +423,11 @@ public class TableController {
|
||||||
// ReplayManager.getInstance().replayGame(table.getId(), userId);
|
// ReplayManager.getInstance().replayGame(table.getId(), userId);
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private Player createPlayer(String name, String playerType, int skill) {
|
private Player createPlayer(String name, String playerType, int skill) {
|
||||||
Player player;
|
Player player;
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
|
player = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
|
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
|
||||||
}
|
}
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
|
@ -443,7 +437,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leaveTableAll() {
|
public void leaveTableAll() {
|
||||||
for (UUID leavingUserId: userPlayerMap.keySet()) {
|
for (UUID leavingUserId : userPlayerMap.keySet()) {
|
||||||
leaveTable(leavingUserId);
|
leaveTable(leavingUserId);
|
||||||
}
|
}
|
||||||
closeTable();
|
closeTable();
|
||||||
|
|
@ -488,13 +482,13 @@ public class TableController {
|
||||||
if (table.isTournament()) {
|
if (table.isTournament()) {
|
||||||
logger.debug("Quit tournament sub tables for userId: " + userId);
|
logger.debug("Quit tournament sub tables for userId: " + userId);
|
||||||
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), 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);
|
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
||||||
} else {
|
} else {
|
||||||
MatchPlayer matchPlayer = match.getPlayer(playerId);
|
MatchPlayer matchPlayer = match.getPlayer(playerId);
|
||||||
if (matchPlayer != null && !match.hasEnded() && !matchPlayer.hasQuit()) {
|
if (matchPlayer != null && !match.hasEnded() && !matchPlayer.hasQuit()) {
|
||||||
Game game = match.getGame();
|
Game game = match.getGame();
|
||||||
if (game != null && !game.hasEnded()){
|
if (game != null && !game.hasEnded()) {
|
||||||
Player player = match.getPlayer(playerId).getPlayer();
|
Player player = match.getPlayer(playerId).getPlayer();
|
||||||
if (player != null && player.isInGame()) {
|
if (player != null && player.isInGame()) {
|
||||||
GameManager.getInstance().quitMatch(game.getId(), userId);
|
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());
|
logger.info("Tourn. match started id:" + match.getId() + " tournId: " + table.getTournament().getId());
|
||||||
} else {
|
} else {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
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());
|
logger.debug("- " + match.getOptions().getGameType() + " - " + match.getOptions().getDeckType());
|
||||||
}
|
}
|
||||||
match.startMatch();
|
match.startMatch();
|
||||||
|
|
@ -558,7 +552,7 @@ public class TableController {
|
||||||
GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId, gameOptions);
|
GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId, gameOptions);
|
||||||
String creator = null;
|
String creator = null;
|
||||||
StringBuilder opponent = new StringBuilder();
|
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()) {
|
if (!match.getPlayer(entry.getValue()).hasQuit()) {
|
||||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
@ -582,7 +576,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Append AI opponents to the log file
|
// Append AI opponents to the log file
|
||||||
for (MatchPlayer mPlayer :match.getPlayers()) {
|
for (MatchPlayer mPlayer : match.getPlayers()) {
|
||||||
if (!mPlayer.getPlayer().isHuman()) {
|
if (!mPlayer.getPlayer().isHuman()) {
|
||||||
if (opponent.length() > 0) {
|
if (opponent.length() > 0) {
|
||||||
opponent.append(" - ");
|
opponent.append(" - ");
|
||||||
|
|
@ -592,9 +586,8 @@ public class TableController {
|
||||||
}
|
}
|
||||||
ServerMessagesUtil.getInstance().incGamesStarted();
|
ServerMessagesUtil.getInstance().incGamesStarted();
|
||||||
|
|
||||||
|
|
||||||
// log about game started
|
// 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() + "]");
|
logger.debug("- matchId: " + match.getId() + " [" + match.getName() + "]");
|
||||||
if (match.getGame() != null) {
|
if (match.getGame() != null) {
|
||||||
logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId()));
|
logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId()));
|
||||||
|
|
@ -602,8 +595,7 @@ public class TableController {
|
||||||
logger.debug("- no valid game object");
|
logger.debug("- no valid game object");
|
||||||
}
|
}
|
||||||
LogServiceImpl.instance.log(LogKeys.KEY_GAME_STARTED, String.valueOf(userPlayerMap.size()), creator, opponent.toString());
|
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);
|
logger.fatal("Error starting game", ex);
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
TableManager.getInstance().removeTable(table.getId());
|
TableManager.getInstance().removeTable(table.getId());
|
||||||
|
|
@ -622,7 +614,7 @@ public class TableController {
|
||||||
if (userId.equals(this.userId) && table.getState().equals(TableState.STARTING)) {
|
if (userId.equals(this.userId) && table.getState().equals(TableState.STARTING)) {
|
||||||
tournament.setStartTime();
|
tournament.setStartTime();
|
||||||
TournamentManager.getInstance().createTournamentSession(tournament, userPlayerMap, table.getId());
|
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());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
logger.info(new StringBuilder("User ").append(user.getName()).append(" tournament started: ").append(tournament.getId()).append(" userId: ").append(user.getId()));
|
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();
|
ServerMessagesUtil.getInstance().incTournamentsStarted();
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
logger.fatal("Error starting tournament", ex);
|
logger.fatal("Error starting tournament", ex);
|
||||||
TableManager.getInstance().removeTable(table.getId());
|
TableManager.getInstance().removeTable(table.getId());
|
||||||
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
||||||
|
|
@ -642,7 +633,7 @@ public class TableController {
|
||||||
public void startDraft(Draft draft) {
|
public void startDraft(Draft draft) {
|
||||||
table.initDraft();
|
table.initDraft();
|
||||||
DraftManager.getInstance().createDraftSession(draft, userPlayerMap, table.getId());
|
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());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
logger.info(new StringBuilder("User ").append(user.getName()).append(" draft started: ").append(draft.getId()).append(" userId: ").append(user.getId()));
|
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 {
|
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)) {
|
if (entry.getValue().equals(playerId)) {
|
||||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||||
|
|
@ -715,8 +706,7 @@ public class TableController {
|
||||||
} else {
|
} else {
|
||||||
closeTable();
|
closeTable();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
closeTable();
|
closeTable();
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
|
|
@ -729,7 +719,7 @@ public class TableController {
|
||||||
table.sideboard();
|
table.sideboard();
|
||||||
setupTimeout(Match.SIDEBOARD_TIME);
|
setupTimeout(Match.SIDEBOARD_TIME);
|
||||||
if (table.isTournamentSubTable()) {
|
if (table.isTournamentSubTable()) {
|
||||||
for (MatchPlayer matchPlayer :match.getPlayers()) {
|
for (MatchPlayer matchPlayer : match.getPlayers()) {
|
||||||
if (!matchPlayer.hasQuit()) {
|
if (!matchPlayer.hasQuit()) {
|
||||||
TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(matchPlayer.getPlayer().getId());
|
TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(matchPlayer.getPlayer().getId());
|
||||||
if (tournamentPlayer != null) {
|
if (tournamentPlayer != null) {
|
||||||
|
|
@ -741,7 +731,7 @@ public class TableController {
|
||||||
match.sideboard();
|
match.sideboard();
|
||||||
cancelTimeout();
|
cancelTimeout();
|
||||||
if (table.isTournamentSubTable()) {
|
if (table.isTournamentSubTable()) {
|
||||||
for (MatchPlayer matchPlayer :match.getPlayers()) {
|
for (MatchPlayer matchPlayer : match.getPlayers()) {
|
||||||
TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(matchPlayer.getPlayer().getId());
|
TournamentPlayer tournamentPlayer = table.getTournament().getPlayer(matchPlayer.getPlayer().getId());
|
||||||
if (tournamentPlayer != null && tournamentPlayer.getStateInfo().equals("sideboarding")) {
|
if (tournamentPlayer != null && tournamentPlayer.getStateInfo().equals("sideboarding")) {
|
||||||
tournamentPlayer.setStateInfo("");
|
tournamentPlayer.setStateInfo("");
|
||||||
|
|
@ -749,9 +739,10 @@ public class TableController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tables of normal matches or tournament sub tables are no longer
|
* Tables of normal matches or tournament sub tables are no longer needed,
|
||||||
* needed, if the match ends.
|
* if the match ends.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void closeTable() {
|
private void closeTable() {
|
||||||
|
|
@ -761,11 +752,11 @@ public class TableController {
|
||||||
|
|
||||||
private void matchEnd() {
|
private void matchEnd() {
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||||
MatchPlayer matchPlayer = match.getPlayer(entry.getValue());
|
MatchPlayer matchPlayer = match.getPlayer(entry.getValue());
|
||||||
// opponent(s) left during sideboarding
|
// opponent(s) left during sideboarding
|
||||||
if (matchPlayer != null) {
|
if (matchPlayer != null) {
|
||||||
if(!matchPlayer.hasQuit()) {
|
if (!matchPlayer.hasQuit()) {
|
||||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (table.getState().equals(TableState.SIDEBOARDING)) {
|
if (table.getState().equals(TableState.SIDEBOARDING)) {
|
||||||
|
|
@ -801,13 +792,13 @@ public class TableController {
|
||||||
cancelTimeout();
|
cancelTimeout();
|
||||||
if (seconds > 0) {
|
if (seconds > 0) {
|
||||||
futureTimeout = timeoutExecutor.schedule(
|
futureTimeout = timeoutExecutor.schedule(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
autoSideboard();
|
autoSideboard();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
seconds, TimeUnit.SECONDS
|
seconds, TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -819,7 +810,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void autoSideboard() {
|
private void autoSideboard() {
|
||||||
for (MatchPlayer player: match.getPlayers()) {
|
for (MatchPlayer player : match.getPlayers()) {
|
||||||
if (!player.isDoneSideboarding()) {
|
if (!player.isDoneSideboarding()) {
|
||||||
match.submitDeck(player.getPlayer().getId(), player.generateDeck());
|
match.submitDeck(player.getPlayer().getId(), player.generateDeck());
|
||||||
}
|
}
|
||||||
|
|
@ -828,7 +819,7 @@ public class TableController {
|
||||||
|
|
||||||
public void endDraft(Draft draft) {
|
public void endDraft(Draft draft) {
|
||||||
if (!draft.isAbort()) {
|
if (!draft.isAbort()) {
|
||||||
for (DraftPlayer player: draft.getPlayers()) {
|
for (DraftPlayer player : draft.getPlayers()) {
|
||||||
player.prepareDeck();
|
player.prepareDeck();
|
||||||
tournament.getPlayer(player.getPlayer().getId()).setDeck(player.getDeck());
|
tournament.getPlayer(player.getPlayer().getId()).setDeck(player.getDeck());
|
||||||
}
|
}
|
||||||
|
|
@ -871,7 +862,7 @@ public class TableController {
|
||||||
|
|
||||||
public boolean isTournamentStillValid() {
|
public boolean isTournamentStillValid() {
|
||||||
if (table.getTournament() != null) {
|
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());
|
TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(table.getTournament().getId());
|
||||||
if (tournamentController != null) {
|
if (tournamentController != null) {
|
||||||
return tournamentController.isTournamentStillValid(table.getState());
|
return tournamentController.isTournamentStillValid(table.getState());
|
||||||
|
|
@ -888,7 +879,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUserId(UUID playerId) {
|
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)) {
|
if (entry.getValue().equals(playerId)) {
|
||||||
return entry.getKey();
|
return entry.getKey();
|
||||||
}
|
}
|
||||||
|
|
@ -900,7 +891,7 @@ public class TableController {
|
||||||
// check only normal match table with state != Finished
|
// check only normal match table with state != Finished
|
||||||
if (!table.isTournament()) {
|
if (!table.isTournament()) {
|
||||||
int humanPlayers = 0;
|
int humanPlayers = 0;
|
||||||
int aiPlayers = 0 ;
|
int aiPlayers = 0;
|
||||||
int validHumanPlayers = 0;
|
int validHumanPlayers = 0;
|
||||||
if (!(table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.STARTING) || table.getState().equals(TableState.READY_TO_START))) {
|
if (!(table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.STARTING) || table.getState().equals(TableState.READY_TO_START))) {
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
|
|
@ -917,7 +908,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check for active players
|
// 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());
|
MatchPlayer matchPlayer = match.getPlayer(userPlayerEntry.getValue());
|
||||||
if (matchPlayer == null) {
|
if (matchPlayer == null) {
|
||||||
logger.debug("- Match player not found:");
|
logger.debug("- Match player not found:");
|
||||||
|
|
@ -928,11 +919,11 @@ public class TableController {
|
||||||
}
|
}
|
||||||
if (matchPlayer.getPlayer().isHuman()) {
|
if (matchPlayer.getPlayer().isHuman()) {
|
||||||
humanPlayers++;
|
humanPlayers++;
|
||||||
if ((table.getState().equals(TableState.WAITING) ||
|
if ((table.getState().equals(TableState.WAITING)
|
||||||
table.getState().equals(TableState.STARTING) ||
|
|| table.getState().equals(TableState.STARTING)
|
||||||
table.getState().equals(TableState.READY_TO_START)) ||
|
|| table.getState().equals(TableState.READY_TO_START))
|
||||||
!match.isDoneSideboarding() ||
|
|| !match.isDoneSideboarding()
|
||||||
(!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
|
|| (!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
|
||||||
User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
|
User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
logger.debug("- Active user of match is missing: " + matchPlayer.getName());
|
logger.debug("- Active user of match is missing: " + matchPlayer.getName());
|
||||||
|
|
@ -956,7 +947,7 @@ public class TableController {
|
||||||
|
|
||||||
void cleanUp() {
|
void cleanUp() {
|
||||||
if (!table.isTournamentSubTable()) {
|
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());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.removeTable(entry.getValue());
|
user.removeTable(entry.getValue());
|
||||||
|
|
@ -973,7 +964,7 @@ public class TableController {
|
||||||
public synchronized boolean changeTableState(TableState newTableState) {
|
public synchronized boolean changeTableState(TableState newTableState) {
|
||||||
switch (newTableState) {
|
switch (newTableState) {
|
||||||
case WAITING:
|
case WAITING:
|
||||||
if (getTable().getState().equals(TableState.STARTING)){
|
if (getTable().getState().equals(TableState.STARTING)) {
|
||||||
// tournament already started
|
// tournament already started
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,6 @@ public class User {
|
||||||
this.watchedGames = new ArrayList<>();
|
this.watchedGames = new ArrayList<>();
|
||||||
this.tablesToDelete = new ArrayList<>();
|
this.tablesToDelete = new ArrayList<>();
|
||||||
this.sessionId = "";
|
this.sessionId = "";
|
||||||
// default these to avaiod NPE -> will be updated from client short after
|
|
||||||
this.userData = new UserData(UserGroup.PLAYER, 0, false, false, false, null, "world.png", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
@ -393,10 +391,17 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserData(UserData userData) {
|
public void setUserData(UserData userData) {
|
||||||
this.userData = userData;
|
if (this.userData != null) {
|
||||||
|
this.userData.update(userData);
|
||||||
|
} else {
|
||||||
|
this.userData = userData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserData getUserData() {
|
public UserData getUserData() {
|
||||||
|
if (userData == null) {// default these to avaiod NPE -> will be updated from client short after
|
||||||
|
return new UserData(UserGroup.DEFAULT, 0, false, false, false, null, "world.png", false);
|
||||||
|
}
|
||||||
return this.userData;
|
return this.userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.server.tournament;
|
package mage.server.tournament;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
@ -63,7 +62,6 @@ import mage.view.ChatMessage.SoundToPlay;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -89,57 +87,57 @@ public class TournamentController {
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
tournament.addTableEventListener(
|
tournament.addTableEventListener(
|
||||||
new Listener<TableEvent> () {
|
new Listener<TableEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void event(TableEvent event) {
|
public void event(TableEvent event) {
|
||||||
switch (event.getEventType()) {
|
switch (event.getEventType()) {
|
||||||
case CHECK_STATE_PLAYERS:
|
case CHECK_STATE_PLAYERS:
|
||||||
checkPlayersState();
|
checkPlayersState();
|
||||||
break;
|
break;
|
||||||
case INFO:
|
case INFO:
|
||||||
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, MessageType.STATUS);
|
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK, true, MessageType.STATUS);
|
||||||
logger.debug(tournament.getId() + " " + event.getMessage());
|
logger.debug(tournament.getId() + " " + event.getMessage());
|
||||||
break;
|
break;
|
||||||
case START_DRAFT:
|
case START_DRAFT:
|
||||||
startDraft(event.getDraft());
|
startDraft(event.getDraft());
|
||||||
break;
|
break;
|
||||||
case CONSTRUCT:
|
|
||||||
if (!isAbort()) {
|
|
||||||
construct();
|
|
||||||
} else {
|
|
||||||
endTournament();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case START_MATCH:
|
|
||||||
if (!isAbort()) {
|
|
||||||
initTournament(); // set state
|
|
||||||
startMatch(event.getPair(), event.getMatchOptions());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case END:
|
|
||||||
endTournament();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
tournament.addPlayerQueryEventListener(
|
|
||||||
new Listener<PlayerQueryEvent> () {
|
|
||||||
@Override
|
|
||||||
public void event(PlayerQueryEvent event) {
|
|
||||||
try {
|
|
||||||
switch (event.getQueryType()) {
|
|
||||||
case CONSTRUCT:
|
case CONSTRUCT:
|
||||||
construct(event.getPlayerId(), event.getMax());
|
if (!isAbort()) {
|
||||||
|
construct();
|
||||||
|
} else {
|
||||||
|
endTournament();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case START_MATCH:
|
||||||
|
if (!isAbort()) {
|
||||||
|
initTournament(); // set state
|
||||||
|
startMatch(event.getPair(), event.getMatchOptions());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case END:
|
||||||
|
endTournament();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
|
||||||
logger.fatal("Player event listener error", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
tournament.addPlayerQueryEventListener(
|
||||||
|
new Listener<PlayerQueryEvent>() {
|
||||||
|
@Override
|
||||||
|
public void event(PlayerQueryEvent event) {
|
||||||
|
try {
|
||||||
|
switch (event.getQueryType()) {
|
||||||
|
case CONSTRUCT:
|
||||||
|
construct(event.getPlayerId(), event.getMax());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (MageException ex) {
|
||||||
|
logger.fatal("Player event listener error", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||||
if (!player.getPlayer().isHuman()) {
|
if (!player.getPlayer().isHuman()) {
|
||||||
player.setJoined();
|
player.setJoined();
|
||||||
logger.debug("player " + player.getPlayer().getId() + " has joined tournament " + tournament.getId());
|
logger.debug("player " + player.getPlayer().getId() + " has joined tournament " + tournament.getId());
|
||||||
|
|
@ -172,22 +170,22 @@ public class TournamentController {
|
||||||
user.addTournament(playerId, tournament.getId());
|
user.addTournament(playerId, tournament.getId());
|
||||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||||
player.setJoined();
|
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);
|
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getLogName() + " has joined the tournament", MessageColor.BLACK, true, MessageType.STATUS);
|
||||||
checkStart();
|
checkStart();
|
||||||
} else {
|
} else {
|
||||||
logger.error("User not found userId: " + userId + " tournamentId: " + tournament.getId());
|
logger.error("User not found userId: " + userId + " tournamentId: " + tournament.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rejoin(UUID playerId) {
|
public void rejoin(UUID playerId) {
|
||||||
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
||||||
if (tournamentSession == null) {
|
if (tournamentSession == null) {
|
||||||
logger.fatal("Tournament session not found - playerId:" + playerId + " tournamentId " + tournament.getId());
|
logger.fatal("Tournament session not found - playerId:" + playerId + " tournamentId " + tournament.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!tournamentSession.init()) {
|
if (!tournamentSession.init()) {
|
||||||
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
|
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tournamentSession.update();
|
tournamentSession.update();
|
||||||
|
|
@ -196,12 +194,12 @@ public class TournamentController {
|
||||||
private void checkStart() {
|
private void checkStart() {
|
||||||
if (!started && allJoined()) {
|
if (!started && allJoined()) {
|
||||||
ThreadExecutor.getInstance().getCallExecutor().execute(
|
ThreadExecutor.getInstance().getCallExecutor().execute(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
startTournament();
|
startTournament();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +207,7 @@ public class TournamentController {
|
||||||
if (!tournament.allJoined()) {
|
if (!tournament.allJoined()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||||
if (player.getPlayer().isHuman() && tournamentSessions.get(player.getPlayer().getId()) == null) {
|
if (player.getPlayer().isHuman() && tournamentSessions.get(player.getPlayer().getId()) == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -218,9 +216,9 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void startTournament() {
|
private synchronized void startTournament() {
|
||||||
for (final TournamentSession tournamentSession: tournamentSessions.values()) {
|
for (final TournamentSession tournamentSession : tournamentSessions.values()) {
|
||||||
if (!tournamentSession.init()) {
|
if (!tournamentSession.init()) {
|
||||||
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
|
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
|
||||||
//TODO: generate client error message
|
//TODO: generate client error message
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -231,10 +229,10 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endTournament() {
|
private void endTournament() {
|
||||||
for (TournamentPlayer player: tournament.getPlayers()) {
|
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||||
player.setStateAtTournamentEnd();
|
player.setStateAtTournamentEnd();
|
||||||
}
|
}
|
||||||
for (final TournamentSession tournamentSession: tournamentSessions.values()) {
|
for (final TournamentSession tournamentSession : tournamentSessions.values()) {
|
||||||
tournamentSession.tournamentOver();
|
tournamentSession.tournamentOver();
|
||||||
}
|
}
|
||||||
this.tournamentSessions.clear();
|
this.tournamentSessions.clear();
|
||||||
|
|
@ -296,7 +294,7 @@ public class TournamentController {
|
||||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||||
if (player != null && !player.hasQuit()) {
|
if (player != null && !player.hasQuit()) {
|
||||||
tournamentSessions.get(playerId).submitDeck(deck);
|
tournamentSessions.get(playerId).submitDeck(deck);
|
||||||
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getLogName() + " has submitted his tournament deck", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerSubmittedDeck);
|
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getLogName() + " has submitted his tournament deck", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerSubmittedDeck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -387,7 +385,7 @@ public class TournamentController {
|
||||||
private boolean checkToReplaceDraftPlayerByAi(UUID userId, TournamentPlayer leavingPlayer) {
|
private boolean checkToReplaceDraftPlayerByAi(UUID userId, TournamentPlayer leavingPlayer) {
|
||||||
|
|
||||||
int humans = 0;
|
int humans = 0;
|
||||||
for (TournamentPlayer tPlayer :tournament.getPlayers()) {
|
for (TournamentPlayer tPlayer : tournament.getPlayers()) {
|
||||||
if (tPlayer.getPlayer().isHuman()) {
|
if (tPlayer.getPlayer().isHuman()) {
|
||||||
humans++;
|
humans++;
|
||||||
}
|
}
|
||||||
|
|
@ -415,7 +413,7 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID getPlayerUserId(UUID playerId) {
|
private UUID getPlayerUserId(UUID playerId) {
|
||||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||||
if (entry.getValue().equals(playerId)) {
|
if (entry.getValue().equals(playerId)) {
|
||||||
return entry.getKey();
|
return entry.getKey();
|
||||||
}
|
}
|
||||||
|
|
@ -437,7 +435,7 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPlayersState() {
|
private void checkPlayersState() {
|
||||||
for (TournamentPlayer tournamentPlayer: tournament.getPlayers()) {
|
for (TournamentPlayer tournamentPlayer : tournament.getPlayers()) {
|
||||||
if (!tournamentPlayer.isEliminated() && tournamentPlayer.getPlayer().isHuman()) {
|
if (!tournamentPlayer.isEliminated() && tournamentPlayer.getPlayer().isHuman()) {
|
||||||
if (tournamentSessions.containsKey(tournamentPlayer.getPlayer().getId())) {
|
if (tournamentSessions.containsKey(tournamentPlayer.getPlayer().getId())) {
|
||||||
if (tournamentSessions.get(tournamentPlayer.getPlayer().getId()).isKilled()) {
|
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
|
* @param tableState state of the tournament table
|
||||||
* @return true - if tournament is valid
|
* @return true - if tournament is valid false - if tournament is not valid
|
||||||
* false - if tournament is not valid and should be removed
|
* and should be removed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean isTournamentStillValid(TableState tableState) {
|
public boolean isTournamentStillValid(TableState tableState) {
|
||||||
int activePlayers = 0;
|
int activePlayers = 0;
|
||||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||||
TournamentPlayer tournamentPlayer = tournament.getPlayer(entry.getValue());
|
TournamentPlayer tournamentPlayer = tournament.getPlayer(entry.getValue());
|
||||||
if (tournamentPlayer != null) {
|
if (tournamentPlayer != null) {
|
||||||
if (!tournamentPlayer.hasQuit()) {
|
if (!tournamentPlayer.hasQuit()) {
|
||||||
|
|
@ -487,7 +485,7 @@ public class TournamentController {
|
||||||
logger.debug("Tournament player is missing - tournamentId: " + tournament.getId() + " state: " + tableState.toString());
|
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.getPlayer().isHuman()) {
|
||||||
if (!tournamentPlayer.hasQuit()) {
|
if (!tournamentPlayer.hasQuit()) {
|
||||||
activePlayers++;
|
activePlayers++;
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,6 @@ import mage.target.common.TargetCreaturePermanentAmount;
|
||||||
import mage.target.common.TargetPermanentOrPlayer;
|
import mage.target.common.TargetPermanentOrPlayer;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -119,7 +117,6 @@ public class TestPlayer implements Player {
|
||||||
|
|
||||||
private final ComputerPlayer computerPlayer;
|
private final ComputerPlayer computerPlayer;
|
||||||
|
|
||||||
|
|
||||||
public TestPlayer(ComputerPlayer computerPlayer) {
|
public TestPlayer(ComputerPlayer computerPlayer) {
|
||||||
this.computerPlayer = computerPlayer;
|
this.computerPlayer = computerPlayer;
|
||||||
AIPlayer = false;
|
AIPlayer = false;
|
||||||
|
|
@ -157,7 +154,8 @@ public class TestPlayer implements Player {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param maxCallsWithoutAction max number of priority passes a player may have for this test (default = 100)
|
* @param maxCallsWithoutAction max number of priority passes a player may
|
||||||
|
* have for this test (default = 100)
|
||||||
*/
|
*/
|
||||||
public void setMaxCallsWithoutAction(int maxCallsWithoutAction) {
|
public void setMaxCallsWithoutAction(int maxCallsWithoutAction) {
|
||||||
this.maxCallsWithoutAction = maxCallsWithoutAction;
|
this.maxCallsWithoutAction = maxCallsWithoutAction;
|
||||||
|
|
@ -427,7 +425,7 @@ public class TestPlayer implements Player {
|
||||||
if (numberOfActions == actions.size()) {
|
if (numberOfActions == actions.size()) {
|
||||||
foundNoAction++;
|
foundNoAction++;
|
||||||
if (foundNoAction > maxCallsWithoutAction) {
|
if (foundNoAction > maxCallsWithoutAction) {
|
||||||
throw new AssertionError("More priority calls to " +getName() + " and doing no action than allowed (" + maxCallsWithoutAction +")");
|
throw new AssertionError("More priority calls to " + getName() + " and doing no action than allowed (" + maxCallsWithoutAction + ")");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foundNoAction = 0;
|
foundNoAction = 0;
|
||||||
|
|
@ -609,7 +607,7 @@ public class TestPlayer implements Player {
|
||||||
if (target instanceof TargetCardInGraveyard) {
|
if (target instanceof TargetCardInGraveyard) {
|
||||||
TargetCardInGraveyard targetCardInGraveyard = ((TargetCardInGraveyard) target);
|
TargetCardInGraveyard targetCardInGraveyard = ((TargetCardInGraveyard) target);
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
for(UUID playerId: this.getInRange()) {
|
for (UUID playerId : this.getInRange()) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
possibleTargets.addAll(player.getGraveyard());
|
possibleTargets.addAll(player.getGraveyard());
|
||||||
|
|
@ -812,7 +810,7 @@ public class TestPlayer implements Player {
|
||||||
@Override
|
@Override
|
||||||
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
||||||
if (!choices.isEmpty()) {
|
if (!choices.isEmpty()) {
|
||||||
for(String choice: choices) {
|
for (String choice : choices) {
|
||||||
if (choice.startsWith("X=")) {
|
if (choice.startsWith("X=")) {
|
||||||
int xValue = Integer.parseInt(choice.substring(2));
|
int xValue = Integer.parseInt(choice.substring(2));
|
||||||
choices.remove(choice);
|
choices.remove(choice);
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,33 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.cards.decks;
|
package mage.cards.decks;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
|
@ -61,7 +58,7 @@ public class Deck implements Serializable {
|
||||||
Deck deck = new Deck();
|
Deck deck = new Deck();
|
||||||
deck.setName(deckCardLists.getName());
|
deck.setName(deckCardLists.getName());
|
||||||
List<String> deckCardNames = new ArrayList<>();
|
List<String> deckCardNames = new ArrayList<>();
|
||||||
for (DeckCardInfo deckCardInfo: deckCardLists.getCards()) {
|
for (DeckCardInfo deckCardInfo : deckCardLists.getCards()) {
|
||||||
Card card = createCard(deckCardInfo, mockCards);
|
Card card = createCard(deckCardInfo, mockCards);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
deck.cards.add(card);
|
deck.cards.add(card);
|
||||||
|
|
@ -71,7 +68,7 @@ public class Deck implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> sbCardNames = new ArrayList<>();
|
List<String> sbCardNames = new ArrayList<>();
|
||||||
for (DeckCardInfo deckCardInfo: deckCardLists.getSideboard()) {
|
for (DeckCardInfo deckCardInfo : deckCardLists.getSideboard()) {
|
||||||
Card card = createCard(deckCardInfo, mockCards);
|
Card card = createCard(deckCardInfo, mockCards);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
deck.sideboard.add(card);
|
deck.sideboard.add(card);
|
||||||
|
|
@ -97,9 +94,9 @@ public class Deck implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GameException createCardNotFoundGameException(DeckCardInfo deckCardInfo, String deckName) {
|
private static GameException createCardNotFoundGameException(DeckCardInfo deckCardInfo, String deckName) {
|
||||||
return new GameException("Card not found - " + deckCardInfo.getCardName() + " - " + deckCardInfo.getSetCode() + " for deck - " + deckName + "\n" +
|
return new GameException("Card not found - " + deckCardInfo.getCardName() + " - " + deckCardInfo.getSetCode() + " for deck - " + deckName + "\n"
|
||||||
"Possible reason is, that you use cards in your deck, that are only supported in newer versions of the server.\n" +
|
+ "Possible reason is, that you use cards in your deck, that are only supported in newer versions of the server.\n"
|
||||||
"So it can help to use the same card from another set, that's already supported from this server." );
|
+ "So it can help to use the same card from another set, that's already supported from this server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Card createCard(DeckCardInfo deckCardInfo, boolean mockCards) {
|
private static Card createCard(DeckCardInfo deckCardInfo, boolean mockCards) {
|
||||||
|
|
@ -119,11 +116,11 @@ public class Deck implements Serializable {
|
||||||
DeckCardLists deckCardLists = new DeckCardLists();
|
DeckCardLists deckCardLists = new DeckCardLists();
|
||||||
|
|
||||||
deckCardLists.setName(name);
|
deckCardLists.setName(name);
|
||||||
for (Card card: cards) {
|
for (Card card : cards) {
|
||||||
|
|
||||||
deckCardLists.getCards().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode()));
|
deckCardLists.getCards().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode()));
|
||||||
}
|
}
|
||||||
for (Card card: sideboard) {
|
for (Card card : sideboard) {
|
||||||
deckCardLists.getSideboard().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode()));
|
deckCardLists.getSideboard().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.players;
|
package mage.players;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -35,7 +34,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageItem;
|
import mage.MageItem;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Abilities;
|
import mage.abilities.Abilities;
|
||||||
|
|
@ -84,37 +82,66 @@ import mage.util.Copyable;
|
||||||
public interface Player extends MageItem, Copyable<Player> {
|
public interface Player extends MageItem, Copyable<Player> {
|
||||||
|
|
||||||
boolean isHuman();
|
boolean isHuman();
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
String getLogName();
|
String getLogName();
|
||||||
|
|
||||||
RangeOfInfluence getRange();
|
RangeOfInfluence getRange();
|
||||||
|
|
||||||
Library getLibrary();
|
Library getLibrary();
|
||||||
|
|
||||||
Cards getSideboard();
|
Cards getSideboard();
|
||||||
|
|
||||||
Graveyard getGraveyard();
|
Graveyard getGraveyard();
|
||||||
|
|
||||||
Abilities<Ability> getAbilities();
|
Abilities<Ability> getAbilities();
|
||||||
|
|
||||||
void addAbility(Ability ability);
|
void addAbility(Ability ability);
|
||||||
|
|
||||||
Counters getCounters();
|
Counters getCounters();
|
||||||
|
|
||||||
int getLife();
|
int getLife();
|
||||||
|
|
||||||
void initLife(int life);
|
void initLife(int life);
|
||||||
|
|
||||||
void setLife(int life, Game game);
|
void setLife(int life, Game game);
|
||||||
|
|
||||||
int loseLife(int amount, Game game);
|
int loseLife(int amount, Game game);
|
||||||
|
|
||||||
int gainLife(int amount, Game game);
|
int gainLife(int amount, Game game);
|
||||||
|
|
||||||
int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
|
int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
|
||||||
|
|
||||||
int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList<UUID> appliedEffects);
|
int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList<UUID> appliedEffects);
|
||||||
|
|
||||||
// to handle rule changing effects (613.10)
|
// to handle rule changing effects (613.10)
|
||||||
boolean isCanLoseLife();
|
boolean isCanLoseLife();
|
||||||
|
|
||||||
void setCanLoseLife(boolean canLoseLife);
|
void setCanLoseLife(boolean canLoseLife);
|
||||||
|
|
||||||
void setCanGainLife(boolean canGainLife);
|
void setCanGainLife(boolean canGainLife);
|
||||||
|
|
||||||
boolean isCanGainLife();
|
boolean isCanGainLife();
|
||||||
|
|
||||||
void setCanPayLifeCost(boolean canPayLifeCost);
|
void setCanPayLifeCost(boolean canPayLifeCost);
|
||||||
|
|
||||||
boolean canPayLifeCost();
|
boolean canPayLifeCost();
|
||||||
|
|
||||||
void setCanPaySacrificeCost(boolean canPaySacrificeCost);
|
void setCanPaySacrificeCost(boolean canPaySacrificeCost);
|
||||||
|
|
||||||
boolean canPaySacrificeCost();
|
boolean canPaySacrificeCost();
|
||||||
|
|
||||||
void setLifeTotalCanChange(boolean lifeTotalCanChange);
|
void setLifeTotalCanChange(boolean lifeTotalCanChange);
|
||||||
|
|
||||||
boolean isLifeTotalCanChange();
|
boolean isLifeTotalCanChange();
|
||||||
|
|
||||||
void setLoseByZeroOrLessLife(boolean loseByZeroOrLessLife);
|
void setLoseByZeroOrLessLife(boolean loseByZeroOrLessLife);
|
||||||
|
|
||||||
boolean canLoseByZeroOrLessLife();
|
boolean canLoseByZeroOrLessLife();
|
||||||
|
|
||||||
void setPlayCardsFromGraveyard(boolean playCardsFromGraveyard);
|
void setPlayCardsFromGraveyard(boolean playCardsFromGraveyard);
|
||||||
|
|
||||||
boolean canPlayCardsFromGraveyard();
|
boolean canPlayCardsFromGraveyard();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,64 +151,101 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
*/
|
*/
|
||||||
List<AlternativeSourceCosts> getAlternativeSourceCosts();
|
List<AlternativeSourceCosts> getAlternativeSourceCosts();
|
||||||
|
|
||||||
|
|
||||||
Cards getHand();
|
Cards getHand();
|
||||||
|
|
||||||
int getLandsPlayed();
|
int getLandsPlayed();
|
||||||
|
|
||||||
int getLandsPerTurn();
|
int getLandsPerTurn();
|
||||||
|
|
||||||
void setLandsPerTurn(int landsPerTurn);
|
void setLandsPerTurn(int landsPerTurn);
|
||||||
|
|
||||||
int getLoyaltyUsePerTurn();
|
int getLoyaltyUsePerTurn();
|
||||||
|
|
||||||
void setLoyaltyUsePerTurn(int loyaltyUsePerTurn);
|
void setLoyaltyUsePerTurn(int loyaltyUsePerTurn);
|
||||||
|
|
||||||
int getMaxHandSize();
|
int getMaxHandSize();
|
||||||
|
|
||||||
void setMaxHandSize(int maxHandSize);
|
void setMaxHandSize(int maxHandSize);
|
||||||
|
|
||||||
int getMaxAttackedBy();
|
int getMaxAttackedBy();
|
||||||
|
|
||||||
void setMaxAttackedBy(int maxAttackedBy);
|
void setMaxAttackedBy(int maxAttackedBy);
|
||||||
|
|
||||||
boolean isPassed();
|
boolean isPassed();
|
||||||
|
|
||||||
boolean isEmptyDraw();
|
boolean isEmptyDraw();
|
||||||
|
|
||||||
void pass(Game game);
|
void pass(Game game);
|
||||||
|
|
||||||
void resetPassed();
|
void resetPassed();
|
||||||
|
|
||||||
boolean getPassedTurn();
|
boolean getPassedTurn();
|
||||||
|
|
||||||
boolean getPassedUntilEndOfTurn();
|
boolean getPassedUntilEndOfTurn();
|
||||||
|
|
||||||
boolean getPassedUntilNextMain();
|
boolean getPassedUntilNextMain();
|
||||||
|
|
||||||
boolean getPassedUntilStackResolved();
|
boolean getPassedUntilStackResolved();
|
||||||
|
|
||||||
boolean getPassedAllTurns();
|
boolean getPassedAllTurns();
|
||||||
|
|
||||||
boolean hasLost();
|
boolean hasLost();
|
||||||
|
|
||||||
boolean hasWon();
|
boolean hasWon();
|
||||||
|
|
||||||
boolean hasQuit();
|
boolean hasQuit();
|
||||||
|
|
||||||
void quit(Game game);
|
void quit(Game game);
|
||||||
|
|
||||||
boolean hasTimerTimeout();
|
boolean hasTimerTimeout();
|
||||||
|
|
||||||
void timerTimeout(Game game);
|
void timerTimeout(Game game);
|
||||||
|
|
||||||
boolean hasIdleTimeout();
|
boolean hasIdleTimeout();
|
||||||
|
|
||||||
void idleTimeout(Game game);
|
void idleTimeout(Game game);
|
||||||
|
|
||||||
boolean hasLeft();
|
boolean hasLeft();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player is still active in game (has not left, lost or won the game).
|
* Player is still active in game (has not left, lost or won the game).
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean isInGame();
|
boolean isInGame();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called if other player left the game
|
* Called if other player left the game
|
||||||
|
*
|
||||||
* @param game
|
* @param game
|
||||||
*/
|
*/
|
||||||
void otherPlayerLeftGame(Game game);
|
void otherPlayerLeftGame(Game game);
|
||||||
|
|
||||||
ManaPool getManaPool();
|
ManaPool getManaPool();
|
||||||
|
|
||||||
Set<UUID> getInRange();
|
Set<UUID> getInRange();
|
||||||
|
|
||||||
boolean isTopCardRevealed();
|
boolean isTopCardRevealed();
|
||||||
|
|
||||||
void setTopCardRevealed(boolean topCardRevealed);
|
void setTopCardRevealed(boolean topCardRevealed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data from the client Preferences (e.g. avatarId or showAbilityPickerForce)
|
* Get data from the client Preferences (e.g. avatarId or
|
||||||
|
* showAbilityPickerForce)
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
UserData getUserData();
|
UserData getUserData();
|
||||||
|
|
||||||
void setUserData(UserData userData);
|
void setUserData(UserData userData);
|
||||||
|
|
||||||
boolean canLose(Game game);
|
boolean canLose(Game game);
|
||||||
|
|
||||||
boolean autoLoseGame();
|
boolean autoLoseGame();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of players which turns under you control.
|
* Returns a set of players which turns under you control. Doesn't include
|
||||||
* Doesn't include yourself.
|
* yourself.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -189,6 +253,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines player whose turn this player controls at the moment.
|
* Defines player whose turn this player controls at the moment.
|
||||||
|
*
|
||||||
* @param game
|
* @param game
|
||||||
* @param playerId
|
* @param playerId
|
||||||
*/
|
*/
|
||||||
|
|
@ -211,7 +276,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
/**
|
/**
|
||||||
* Returns false in case player don't control the game.
|
* Returns false in case player don't control the game.
|
||||||
*
|
*
|
||||||
* Note: For effects like "You control target player during that player's next turn".
|
* Note: For effects like "You control target player during that player's
|
||||||
|
* next turn".
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -220,103 +286,165 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
/**
|
/**
|
||||||
* Returns false in case you don't control the game.
|
* Returns false in case you don't control the game.
|
||||||
*
|
*
|
||||||
* Note: For effects like "You control target player during that player's next turn".
|
* Note: For effects like "You control target player during that player's
|
||||||
|
* next turn".
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
void setGameUnderYourControl(boolean value);
|
void setGameUnderYourControl(boolean value);
|
||||||
|
|
||||||
boolean isTestMode();
|
boolean isTestMode();
|
||||||
|
|
||||||
void setTestMode(boolean value);
|
void setTestMode(boolean value);
|
||||||
|
|
||||||
void addAction(String action);
|
void addAction(String action);
|
||||||
|
|
||||||
int getActionCount();
|
int getActionCount();
|
||||||
|
|
||||||
void setAllowBadMoves(boolean allowBadMoves);
|
void setAllowBadMoves(boolean allowBadMoves);
|
||||||
|
|
||||||
void init(Game game);
|
void init(Game game);
|
||||||
|
|
||||||
void init(Game game, boolean testMode);
|
void init(Game game, boolean testMode);
|
||||||
|
|
||||||
void useDeck(Deck deck, Game game);
|
void useDeck(Deck deck, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before each applyEffects, to rest all what can be applyed by continuous effects
|
* Called before each applyEffects, to rest all what can be applyed by
|
||||||
|
* continuous effects
|
||||||
*/
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void shuffleLibrary(Game game);
|
void shuffleLibrary(Game game);
|
||||||
|
|
||||||
int drawCards(int num, Game game);
|
int drawCards(int num, Game game);
|
||||||
|
|
||||||
int drawCards(int num, Game game, ArrayList<UUID> appliedEffects);
|
int drawCards(int num, Game game, ArrayList<UUID> appliedEffects);
|
||||||
|
|
||||||
boolean cast(SpellAbility ability, Game game, boolean noMana);
|
boolean cast(SpellAbility ability, Game game, boolean noMana);
|
||||||
|
|
||||||
SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana);
|
SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana);
|
||||||
|
|
||||||
boolean putInHand(Card card, Game game);
|
boolean putInHand(Card card, Game game);
|
||||||
|
|
||||||
boolean removeFromHand(Card card, Game game);
|
boolean removeFromHand(Card card, Game game);
|
||||||
|
|
||||||
boolean removeFromBattlefield(Permanent permanent, Game game);
|
boolean removeFromBattlefield(Permanent permanent, Game game);
|
||||||
|
|
||||||
boolean putInGraveyard(Card card, Game game, boolean fromBattlefield);
|
boolean putInGraveyard(Card card, Game game, boolean fromBattlefield);
|
||||||
|
|
||||||
boolean removeFromGraveyard(Card card, Game game);
|
boolean removeFromGraveyard(Card card, Game game);
|
||||||
|
|
||||||
boolean removeFromLibrary(Card card, Game game);
|
boolean removeFromLibrary(Card card, Game game);
|
||||||
|
|
||||||
boolean searchLibrary(TargetCardInLibrary target, Game game);
|
boolean searchLibrary(TargetCardInLibrary target, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param target
|
* @param target
|
||||||
* @param game
|
* @param game
|
||||||
* @param targetPlayerId player whose library will be searched
|
* @param targetPlayerId player whose library will be searched
|
||||||
* @return true if search was successful
|
* @return true if search was successful
|
||||||
*/
|
*/
|
||||||
boolean searchLibrary(TargetCardInLibrary target, Game game, UUID targetPlayerId);
|
boolean searchLibrary(TargetCardInLibrary target, Game game, UUID targetPlayerId);
|
||||||
|
|
||||||
boolean canPlayLand();
|
boolean canPlayLand();
|
||||||
|
|
||||||
boolean playLand(Card card, Game game);
|
boolean playLand(Card card, Game game);
|
||||||
|
|
||||||
boolean activateAbility(ActivatedAbility ability, Game game);
|
boolean activateAbility(ActivatedAbility ability, Game game);
|
||||||
|
|
||||||
boolean triggerAbility(TriggeredAbility ability, Game game);
|
boolean triggerAbility(TriggeredAbility ability, Game game);
|
||||||
|
|
||||||
boolean canBeTargetedBy(MageObject source, UUID sourceControllerId, Game game);
|
boolean canBeTargetedBy(MageObject source, UUID sourceControllerId, Game game);
|
||||||
|
|
||||||
boolean hasProtectionFrom(MageObject source, Game game);
|
boolean hasProtectionFrom(MageObject source, Game game);
|
||||||
|
|
||||||
boolean flipCoin(Game game);
|
boolean flipCoin(Game game);
|
||||||
|
|
||||||
boolean flipCoin(Game game, ArrayList<UUID> appliedEffects);
|
boolean flipCoin(Game game, ArrayList<UUID> appliedEffects);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
void discard(int amount, Ability source, Game game);
|
void discard(int amount, Ability source, Game game);
|
||||||
|
|
||||||
Card discardOne(boolean random, Ability source, Game game);
|
Card discardOne(boolean random, Ability source, Game game);
|
||||||
|
|
||||||
Cards discard(int amount, boolean random, Ability source, Game game);
|
Cards discard(int amount, boolean random, Ability source, Game game);
|
||||||
|
|
||||||
void discardToMax(Game game);
|
void discardToMax(Game game);
|
||||||
|
|
||||||
boolean discard(Card card, Ability source, Game game);
|
boolean discard(Card card, Ability source, Game game);
|
||||||
|
|
||||||
void lost(Game game);
|
void lost(Game game);
|
||||||
|
|
||||||
void lostForced(Game game);
|
void lostForced(Game game);
|
||||||
|
|
||||||
void won(Game game);
|
void won(Game game);
|
||||||
|
|
||||||
void leave();
|
void leave();
|
||||||
|
|
||||||
void concede(Game game);
|
void concede(Game game);
|
||||||
|
|
||||||
void abort();
|
void abort();
|
||||||
|
|
||||||
void abortReset();
|
void abortReset();
|
||||||
|
|
||||||
void skip();
|
void skip();
|
||||||
|
|
||||||
// priority, undo, ...
|
// priority, undo, ...
|
||||||
void sendPlayerAction(PlayerAction passPriorityAction, Game game);
|
void sendPlayerAction(PlayerAction passPriorityAction, Game game);
|
||||||
|
|
||||||
int getStoredBookmark();
|
int getStoredBookmark();
|
||||||
|
|
||||||
void setStoredBookmark(int bookmark);
|
void setStoredBookmark(int bookmark);
|
||||||
|
|
||||||
void resetStoredBookmark(Game game);
|
void resetStoredBookmark(Game game);
|
||||||
|
|
||||||
void revealCards(String name, Cards cards, Game game);
|
void revealCards(String name, Cards cards, Game game);
|
||||||
|
|
||||||
void revealCards(String name, Cards cards, Game game, boolean postToLog);
|
void revealCards(String name, Cards cards, Game game, boolean postToLog);
|
||||||
|
|
||||||
void lookAtCards(String name, Card card, Game game);
|
void lookAtCards(String name, Card card, Game game);
|
||||||
|
|
||||||
void lookAtCards(String name, Cards cards, Game game);
|
void lookAtCards(String name, Cards cards, Game game);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Player copy();
|
Player copy();
|
||||||
|
|
||||||
void restore(Player player);
|
void restore(Player player);
|
||||||
|
|
||||||
void setResponseString(String responseString);
|
void setResponseString(String responseString);
|
||||||
|
|
||||||
void setResponseUUID(UUID responseUUID);
|
void setResponseUUID(UUID responseUUID);
|
||||||
|
|
||||||
void setResponseBoolean(Boolean responseBoolean);
|
void setResponseBoolean(Boolean responseBoolean);
|
||||||
|
|
||||||
void setResponseInteger(Integer data);
|
void setResponseInteger(Integer data);
|
||||||
|
|
||||||
void setResponseManaType(UUID manaTypePlayerId, ManaType responseManaType);
|
void setResponseManaType(UUID manaTypePlayerId, ManaType responseManaType);
|
||||||
|
|
||||||
boolean priority(Game game);
|
boolean priority(Game game);
|
||||||
|
|
||||||
boolean choose(Outcome outcome, Target target, UUID sourceId, Game game);
|
boolean choose(Outcome outcome, Target target, UUID sourceId, Game game);
|
||||||
|
|
||||||
boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options);
|
boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options);
|
||||||
|
|
||||||
boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game);
|
boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game);
|
||||||
|
|
||||||
boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game);
|
boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game);
|
||||||
|
|
||||||
boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game);
|
boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game);
|
||||||
|
|
||||||
boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game);
|
boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game);
|
||||||
|
|
||||||
boolean chooseMulligan(Game game);
|
boolean chooseMulligan(Game game);
|
||||||
|
|
||||||
boolean chooseUse(Outcome outcome, String message, Game game);
|
boolean chooseUse(Outcome outcome, String message, Game game);
|
||||||
|
|
||||||
boolean choose(Outcome outcome, Choice choice, Game game);
|
boolean choose(Outcome outcome, Choice choice, Game game);
|
||||||
|
|
||||||
boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game);
|
boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game);
|
||||||
|
|
||||||
boolean playMana(ManaCost unpaid, String promptText, Game game);
|
boolean playMana(ManaCost unpaid, String promptText, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -348,13 +476,20 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
int announceXCost(int min, int max, String message, Game game, Ability ability, VariableCost variableCost);
|
int announceXCost(int min, int max, String message, Game game, Ability ability, VariableCost variableCost);
|
||||||
|
|
||||||
int chooseReplacementEffect(Map<String, String> abilityMap, Game game);
|
int chooseReplacementEffect(Map<String, String> abilityMap, Game game);
|
||||||
|
|
||||||
TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game);
|
TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game);
|
||||||
|
|
||||||
Mode chooseMode(Modes modes, Ability source, Game game);
|
Mode chooseMode(Modes modes, Ability source, Game game);
|
||||||
|
|
||||||
void selectAttackers(Game game, UUID attackingPlayerId);
|
void selectAttackers(Game game, UUID attackingPlayerId);
|
||||||
|
|
||||||
void selectBlockers(Game game, UUID defendingPlayerId);
|
void selectBlockers(Game game, UUID defendingPlayerId);
|
||||||
|
|
||||||
UUID chooseAttackerOrder(List<Permanent> attacker, Game game);
|
UUID chooseAttackerOrder(List<Permanent> attacker, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Choose the order in which blockers get damage assigned to
|
* Choose the order in which blockers get damage assigned to
|
||||||
|
*
|
||||||
* @param blockers list of blockers where to choose the next one from
|
* @param blockers list of blockers where to choose the next one from
|
||||||
* @param combatGroup the concerning combat group
|
* @param combatGroup the concerning combat group
|
||||||
* @param blockerOrder the already set order of blockers
|
* @param blockerOrder the already set order of blockers
|
||||||
|
|
@ -362,35 +497,52 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
* @return blocker next to add to the blocker order
|
* @return blocker next to add to the blocker order
|
||||||
*/
|
*/
|
||||||
UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game);
|
UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game);
|
||||||
|
|
||||||
void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game);
|
void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game);
|
||||||
|
|
||||||
int getAmount(int min, int max, String message, Game game);
|
int getAmount(int min, int max, String message, Game game);
|
||||||
|
|
||||||
void sideboard(Match match, Deck deck);
|
void sideboard(Match match, Deck deck);
|
||||||
|
|
||||||
void construct(Tournament tournament, Deck deck);
|
void construct(Tournament tournament, Deck deck);
|
||||||
|
|
||||||
void pickCard(List<Card> cards, Deck deck, Draft draft);
|
void pickCard(List<Card> cards, Deck deck, Draft draft);
|
||||||
|
|
||||||
void declareAttacker(UUID attackerId, UUID defenderId, Game game, boolean allowUndo);
|
void declareAttacker(UUID attackerId, UUID defenderId, Game game, boolean allowUndo);
|
||||||
|
|
||||||
void declareBlocker(UUID defenderId, UUID blockerId, UUID attackerId, Game game);
|
void declareBlocker(UUID defenderId, UUID blockerId, UUID attackerId, Game game);
|
||||||
|
|
||||||
List<Permanent> getAvailableAttackers(Game game);
|
List<Permanent> getAvailableAttackers(Game game);
|
||||||
|
|
||||||
List<Permanent> getAvailableAttackers(UUID defenderId, Game game);
|
List<Permanent> getAvailableAttackers(UUID defenderId, Game game);
|
||||||
|
|
||||||
List<Permanent> getAvailableBlockers(Game game);
|
List<Permanent> getAvailableBlockers(Game game);
|
||||||
|
|
||||||
void beginTurn(Game game);
|
void beginTurn(Game game);
|
||||||
|
|
||||||
void endOfTurn(Game game);
|
void endOfTurn(Game game);
|
||||||
|
|
||||||
void phasing(Game game);
|
void phasing(Game game);
|
||||||
|
|
||||||
void untap(Game game);
|
void untap(Game game);
|
||||||
|
|
||||||
ManaOptions getManaAvailable(Game game);
|
ManaOptions getManaAvailable(Game game);
|
||||||
|
|
||||||
List<Ability> getPlayable(Game game, boolean hidden);
|
List<Ability> getPlayable(Game game, boolean hidden);
|
||||||
|
|
||||||
List<Ability> getPlayableOptions(Ability ability, Game game);
|
List<Ability> getPlayableOptions(Ability ability, Game game);
|
||||||
|
|
||||||
|
|
||||||
Set<UUID> getPlayableInHand(Game game);
|
Set<UUID> getPlayableInHand(Game game);
|
||||||
|
|
||||||
LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game);
|
LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game);
|
||||||
|
|
||||||
void addCounters(Counter counter, Game game);
|
void addCounters(Counter counter, Game game);
|
||||||
|
|
||||||
List<UUID> getAttachments();
|
List<UUID> getAttachments();
|
||||||
|
|
||||||
boolean addAttachment(UUID permanentId, Game game);
|
boolean addAttachment(UUID permanentId, Game game);
|
||||||
boolean removeAttachment(Permanent permanent, Game game);
|
|
||||||
|
boolean removeAttachment(Permanent permanent, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals that the player becomes active player in this turn.
|
* Signals that the player becomes active player in this turn.
|
||||||
|
|
@ -422,10 +574,13 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
int getPriorityTimeLeft();
|
int getPriorityTimeLeft();
|
||||||
|
|
||||||
void setReachedNextTurnAfterLeaving(boolean reachedNextTurnAfterLeaving);
|
void setReachedNextTurnAfterLeaving(boolean reachedNextTurnAfterLeaving);
|
||||||
|
|
||||||
boolean hasReachedNextTurnAfterLeaving();
|
boolean hasReachedNextTurnAfterLeaving();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a AI player is able to join a table
|
* Checks if a AI player is able to join a table i.e. Draft - bot can not
|
||||||
* i.e. Draft - bot can not enter a table with constructed format
|
* enter a table with constructed format
|
||||||
|
*
|
||||||
* @param table
|
* @param table
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -433,12 +588,14 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the commanderId of the player
|
* Set the commanderId of the player
|
||||||
|
*
|
||||||
* @param commanderId
|
* @param commanderId
|
||||||
*/
|
*/
|
||||||
void setCommanderId(UUID commanderId);
|
void setCommanderId(UUID commanderId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the commanderId of the player
|
* Get the commanderId of the player
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
UUID getCommanderId();
|
UUID getCommanderId();
|
||||||
|
|
@ -454,7 +611,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||||
|
|
||||||
boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
boolean moveCards(List<Card> cards, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||||
|
|
||||||
boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game);
|
boolean moveCards(Card card, Zone fromZone, Zone toZone, Ability source, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -476,12 +635,13 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
* @param withName show the card name in the log
|
* @param withName show the card name in the log
|
||||||
* @param fromZone
|
* @param fromZone
|
||||||
* @return
|
* @return
|
||||||
* */
|
*
|
||||||
|
*/
|
||||||
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName);
|
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses card.moveToExile and posts a inform message about moving the card to exile
|
* Uses card.moveToExile and posts a inform message about moving the card to
|
||||||
* into the game log
|
* exile into the game log
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param exileId exile zone id (optional)
|
* @param exileId exile zone id (optional)
|
||||||
|
|
@ -495,8 +655,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId, Game game, Zone fromZone, boolean withName);
|
boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId, Game game, Zone fromZone, boolean withName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses card.moveToZone and posts a inform message about moving the card to graveyard
|
* Uses card.moveToZone and posts a inform message about moving the card to
|
||||||
* into the game log
|
* graveyard into the game log
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param sourceId
|
* @param sourceId
|
||||||
|
|
@ -506,10 +666,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
*/
|
*/
|
||||||
boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone);
|
boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal used to move cards
|
* Internal used to move cards Use commonly player.moveCards()
|
||||||
* Use commonly player.moveCards()
|
|
||||||
*
|
*
|
||||||
* @param cards
|
* @param cards
|
||||||
* @param source
|
* @param source
|
||||||
|
|
@ -520,8 +678,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
boolean moveCardsToGraveyardWithInfo(List<Card> cards, Ability source, Game game, Zone fromZone);
|
boolean moveCardsToGraveyardWithInfo(List<Card> cards, Ability source, Game game, Zone fromZone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses card.moveToZone and posts a inform message about moving the card to graveyard
|
* Uses card.moveToZone and posts a inform message about moving the card to
|
||||||
* into the game log
|
* graveyard into the game log
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param sourceId
|
* @param sourceId
|
||||||
|
|
@ -533,9 +691,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
*/
|
*/
|
||||||
boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean toTop, boolean withName);
|
boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean toTop, boolean withName);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses putOntoBattlefield and posts also a info message about in the game log
|
* Uses putOntoBattlefield and posts also a info message about in the game
|
||||||
|
* log
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param game
|
* @param game
|
||||||
|
|
@ -546,7 +704,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId);
|
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses putOntoBattlefield and posts also a info message about in the game log
|
* Uses putOntoBattlefield and posts also a info message about in the game
|
||||||
|
* log
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param game
|
* @param game
|
||||||
|
|
@ -558,7 +717,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped);
|
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses putOntoBattlefield and posts also a info message about in the game log
|
* Uses putOntoBattlefield and posts also a info message about in the game
|
||||||
|
* log
|
||||||
*
|
*
|
||||||
* @param card
|
* @param card
|
||||||
* @param game
|
* @param game
|
||||||
|
|
@ -580,30 +740,38 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
boolean hasOpponent(UUID playerToCheckId, Game game);
|
boolean hasOpponent(UUID playerToCheckId, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free resources on match end
|
* Free resources on match end
|
||||||
*/
|
*/
|
||||||
void cleanUpOnMatchEnd();
|
void cleanUpOnMatchEnd();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the next cast spell has the set sourceId, the spell will
|
* If the next cast spell has the set sourceId, the spell will be cast
|
||||||
* be cast without mana.
|
* without mana.
|
||||||
*
|
*
|
||||||
* @param sourceId the source that can be cast without mana
|
* @param sourceId the source that can be cast without mana
|
||||||
* @param manaCosts alternate ManaCost, null if it can be cast without mana cost
|
* @param manaCosts alternate ManaCost, null if it can be cast without mana
|
||||||
|
* cost
|
||||||
*/
|
*/
|
||||||
void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts);
|
void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts);
|
||||||
|
|
||||||
UUID getCastSourceIdWithAlternateMana();
|
UUID getCastSourceIdWithAlternateMana();
|
||||||
|
|
||||||
ManaCosts getCastSourceIdManaCosts();
|
ManaCosts getCastSourceIdManaCosts();
|
||||||
|
|
||||||
// permission handling to show hand cards
|
// permission handling to show hand cards
|
||||||
void addPermissionToShowHandCards(UUID watcherUserId);
|
void addPermissionToShowHandCards(UUID watcherUserId);
|
||||||
|
|
||||||
boolean hasUserPermissionToSeeHand(UUID userId);
|
boolean hasUserPermissionToSeeHand(UUID userId);
|
||||||
|
|
||||||
void revokePermissionToSeeHandCards();
|
void revokePermissionToSeeHandCards();
|
||||||
|
|
||||||
boolean isRequestToShowHandCardsAllowed();
|
boolean isRequestToShowHandCardsAllowed();
|
||||||
|
|
||||||
Set<UUID> getUsersAllowedToSeeHandCards();
|
Set<UUID> getUsersAllowedToSeeHandCards();
|
||||||
|
|
||||||
boolean isInPayManaMode();
|
boolean isInPayManaMode();
|
||||||
|
|
||||||
void setMatchPlayer(MatchPlayer matchPlayer);
|
void setMatchPlayer(MatchPlayer matchPlayer);
|
||||||
|
|
||||||
MatchPlayer getMatchPlayer();
|
MatchPlayer getMatchPlayer();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
protected UserData userData;
|
protected UserData userData;
|
||||||
protected MatchPlayer matchPlayer;
|
protected MatchPlayer matchPlayer;
|
||||||
|
|
||||||
|
protected String flagName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* During some steps we can't play anything
|
* During some steps we can't play anything
|
||||||
*/
|
*/
|
||||||
|
|
@ -571,7 +573,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if the player has the control itself - false if the player is controlled by another player
|
* returns true if the player has the control itself - false if the player
|
||||||
|
* is controlled by another player
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -701,7 +705,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
if (random) {
|
if (random) {
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
Card card = this.getHand().getRandom(game);
|
Card card = this.getHand().getRandom(game);
|
||||||
if(card != null) {
|
if (card != null) {
|
||||||
discardedCards.add(card);
|
discardedCards.add(card);
|
||||||
discard(card, source, game);
|
discard(card, source, game);
|
||||||
}
|
}
|
||||||
|
|
@ -917,7 +921,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
return castSourceIdManaCosts;
|
return castSourceIdManaCosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInPayManaMode() {
|
public boolean isInPayManaMode() {
|
||||||
return payManaMode;
|
return payManaMode;
|
||||||
|
|
@ -939,7 +942,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
// some effects set sourceId to cast without paying mana costs
|
// some effects set sourceId to cast without paying mana costs
|
||||||
if (ability.getSourceId().equals(getCastSourceIdWithAlternateMana())) {
|
if (ability.getSourceId().equals(getCastSourceIdWithAlternateMana())) {
|
||||||
ManaCosts alternateCosts = getCastSourceIdManaCosts();
|
ManaCosts alternateCosts = getCastSourceIdManaCosts();
|
||||||
Ability spellAbility = spell.getSpellAbility();
|
Ability spellAbility = spell.getSpellAbility();
|
||||||
if (alternateCosts == null) {
|
if (alternateCosts == null) {
|
||||||
noMana = true;
|
noMana = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1096,7 +1099,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
if (ability instanceof PlayLandAbility) {
|
if (ability instanceof PlayLandAbility) {
|
||||||
|
|
||||||
|
|
||||||
Card card = game.getCard(ability.getSourceId());
|
Card card = game.getCard(ability.getSourceId());
|
||||||
result = playLand(card, game);
|
result = playLand(card, game);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1679,7 +1681,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
} else if (source instanceof Card) {
|
} else if (source instanceof Card) {
|
||||||
sourceAbilities = ((Card) source).getAbilities(game);
|
sourceAbilities = ((Card) source).getAbilities(game);
|
||||||
sourceControllerId = ((Card) source).getOwnerId();
|
sourceControllerId = ((Card) source).getOwnerId();
|
||||||
} else if (source instanceof CommandObject){
|
} else if (source instanceof CommandObject) {
|
||||||
sourceControllerId = ((CommandObject) source).getControllerId();
|
sourceControllerId = ((CommandObject) source).getControllerId();
|
||||||
sourceAbilities = ((CommandObject) source).getAbilities();
|
sourceAbilities = ((CommandObject) source).getAbilities();
|
||||||
}
|
}
|
||||||
|
|
@ -2033,7 +2035,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
Permanent attacker = game.getPermanent(attackerId);
|
Permanent attacker = game.getPermanent(attackerId);
|
||||||
if (attacker != null && attacker.canAttack(defenderId, game) && attacker.getControllerId().equals(playerId)) {
|
if (attacker != null && attacker.canAttack(defenderId, game) && attacker.getControllerId().equals(playerId)) {
|
||||||
if(!game.getCombat().declareAttacker(attackerId, defenderId, playerId, game)) {
|
if (!game.getCombat().declareAttacker(attackerId, defenderId, playerId, game)) {
|
||||||
game.undo(playerId);
|
game.undo(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2285,64 +2287,64 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canPlayCardByAlternateCost(Card sourceObject, ManaOptions available, Ability ability, Game game) {
|
protected boolean canPlayCardByAlternateCost(Card sourceObject, ManaOptions available, Ability ability, Game game) {
|
||||||
if (sourceObject != null && !(sourceObject instanceof Permanent)) {
|
if (sourceObject != null && !(sourceObject instanceof Permanent)) {
|
||||||
for (Ability alternateSourceCostsAbility : sourceObject.getAbilities()) {
|
for (Ability alternateSourceCostsAbility : sourceObject.getAbilities()) {
|
||||||
// if cast for noMana no Alternative costs are allowed
|
// if cast for noMana no Alternative costs are allowed
|
||||||
if (alternateSourceCostsAbility instanceof AlternativeSourceCosts) {
|
if (alternateSourceCostsAbility instanceof AlternativeSourceCosts) {
|
||||||
if (((AlternativeSourceCosts) alternateSourceCostsAbility).isAvailable(ability, game)) {
|
if (((AlternativeSourceCosts) alternateSourceCostsAbility).isAvailable(ability, game)) {
|
||||||
if (alternateSourceCostsAbility.getCosts().canPay(ability, playerId, playerId, game)) {
|
if (alternateSourceCostsAbility.getCosts().canPay(ability, playerId, playerId, game)) {
|
||||||
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
||||||
for (Cost cost : alternateSourceCostsAbility.getCosts()) {
|
for (Cost cost : alternateSourceCostsAbility.getCosts()) {
|
||||||
if (cost instanceof ManaCost) {
|
if (cost instanceof ManaCost) {
|
||||||
manaCosts.add((ManaCost) cost);
|
manaCosts.add((ManaCost) cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manaCosts.size() == 0) {
|
if (manaCosts.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (Mana mana : manaCosts.getOptions()) {
|
for (Mana mana : manaCosts.getOptions()) {
|
||||||
for (Mana avail : available) {
|
for (Mana avail : available) {
|
||||||
if (mana.enough(avail)) {
|
if (mana.enough(avail)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// controller specific alternate spell costs
|
// controller specific alternate spell costs
|
||||||
for (AlternativeSourceCosts alternateSourceCosts: getAlternativeSourceCosts()) {
|
for (AlternativeSourceCosts alternateSourceCosts : getAlternativeSourceCosts()) {
|
||||||
if (alternateSourceCosts instanceof Ability) {
|
if (alternateSourceCosts instanceof Ability) {
|
||||||
if (alternateSourceCosts.isAvailable(ability, game)) {
|
if (alternateSourceCosts.isAvailable(ability, game)) {
|
||||||
if (((Ability) alternateSourceCosts).getCosts().canPay(ability, playerId, playerId, game)) {
|
if (((Ability) alternateSourceCosts).getCosts().canPay(ability, playerId, playerId, game)) {
|
||||||
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
||||||
for (Cost cost : ((Ability) alternateSourceCosts).getCosts()) {
|
for (Cost cost : ((Ability) alternateSourceCosts).getCosts()) {
|
||||||
if (cost instanceof ManaCost) {
|
if (cost instanceof ManaCost) {
|
||||||
manaCosts.add((ManaCost) cost);
|
manaCosts.add((ManaCost) cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manaCosts.size() == 0) {
|
if (manaCosts.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (Mana mana : manaCosts.getOptions()) {
|
for (Mana mana : manaCosts.getOptions()) {
|
||||||
for (Mana avail : available) {
|
for (Mana avail : available) {
|
||||||
if (mana.enough(avail)) {
|
if (mana.enough(avail)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canLandPlayAlternateSourceCostsAbility(Card sourceObject, ManaOptions available, Ability ability, Game game) {
|
protected boolean canLandPlayAlternateSourceCostsAbility(Card sourceObject, ManaOptions available, Ability ability, Game game) {
|
||||||
|
|
@ -2847,7 +2849,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game) {
|
public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game) {
|
||||||
ArrayList<Card> cardList = new ArrayList<>();
|
ArrayList<Card> cardList = new ArrayList<>();
|
||||||
for (UUID cardId: cards) {
|
for (UUID cardId : cards) {
|
||||||
if (fromZone.equals(Zone.BATTLEFIELD)) {
|
if (fromZone.equals(Zone.BATTLEFIELD)) {
|
||||||
Permanent permanent = game.getPermanent(cardId);
|
Permanent permanent = game.getPermanent(cardId);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
|
@ -2878,10 +2880,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
game.fireEvent(new ZoneChangeGroupEvent(cards, source == null ? null : source.getSourceId(), this.getId(), fromZone, toZone));
|
game.fireEvent(new ZoneChangeGroupEvent(cards, source == null ? null : source.getSourceId(), this.getId(), fromZone, toZone));
|
||||||
switch(toZone) {
|
switch (toZone) {
|
||||||
case EXILED:
|
case EXILED:
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for(Card card: cards) {
|
for (Card card : cards) {
|
||||||
result |= moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, true);
|
result |= moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, true);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -2889,7 +2891,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
return moveCardsToGraveyardWithInfo(cards, source, game, fromZone);
|
return moveCardsToGraveyardWithInfo(cards, source, game, fromZone);
|
||||||
case HAND:
|
case HAND:
|
||||||
result = false;
|
result = false;
|
||||||
for(Card card: cards) {
|
for (Card card : cards) {
|
||||||
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone);
|
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -2912,7 +2914,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
StringBuilder sb = new StringBuilder(this.getLogName()).append(" puts ").append(withName ? card.getLogName() : "a face down card");
|
StringBuilder sb = new StringBuilder(this.getLogName()).append(" puts ").append(withName ? card.getLogName() : "a face down card");
|
||||||
switch(fromZone) {
|
switch (fromZone) {
|
||||||
case EXILED:
|
case EXILED:
|
||||||
sb.append(" from exile zone ");
|
sb.append(" from exile zone ");
|
||||||
break;
|
break;
|
||||||
|
|
@ -3051,8 +3053,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
if (card instanceof PermanentCard) {
|
if (card instanceof PermanentCard) {
|
||||||
card = game.getCard(card.getId());
|
card = game.getCard(card.getId());
|
||||||
}
|
}
|
||||||
game.informPlayers(this.getLogName() + " moves " + (withName ? card.getLogName() : "a card face down") + " " +
|
game.informPlayers(this.getLogName() + " moves " + (withName ? card.getLogName() : "a card face down") + " "
|
||||||
(fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + " " : "") + "to the exile zone");
|
+ (fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + " " : "") + "to the exile zone");
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
@ -3075,7 +3077,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId(), tapped, facedown)) {
|
if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId(), tapped, facedown)) {
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
game.informPlayers(new StringBuilder(this.getLogName())
|
game.informPlayers(new StringBuilder(this.getLogName())
|
||||||
.append(" puts ").append(facedown ? "a card face down ":card.getLogName())
|
.append(" puts ").append(facedown ? "a card face down " : card.getLogName())
|
||||||
.append(" from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ")
|
.append(" from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ")
|
||||||
.append("onto the Battlefield").toString());
|
.append("onto the Battlefield").toString());
|
||||||
}
|
}
|
||||||
|
|
@ -3129,7 +3131,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
usersAllowedToSeeHandCards.add(watcherUserId);
|
usersAllowedToSeeHandCards.add(watcherUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRequestToShowHandCardsAllowed() {
|
public boolean isRequestToShowHandCardsAllowed() {
|
||||||
return userData.isAllowRequestShowHandCards();
|
return userData.isAllowRequestShowHandCards();
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,21 @@ public class UserData implements Serializable {
|
||||||
this.askMoveToGraveOrder = askMoveToGraveOrder;
|
this.askMoveToGraveOrder = askMoveToGraveOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(UserData userData) {
|
||||||
|
this.groupId = userData.groupId;
|
||||||
|
this.avatarId = userData.avatarId;
|
||||||
|
this.showAbilityPickerForced = userData.showAbilityPickerForced;
|
||||||
|
this.allowRequestShowHandCards = userData.allowRequestShowHandCards;
|
||||||
|
this.userSkipPrioritySteps = userData.userSkipPrioritySteps;
|
||||||
|
this.confirmEmptyManaPool = userData.confirmEmptyManaPool;
|
||||||
|
this.flagName = userData.flagName;
|
||||||
|
this.askMoveToGraveOrder = userData.askMoveToGraveOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserData getDefaultUserDataView() {
|
||||||
|
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, "world.png", false);
|
||||||
|
}
|
||||||
|
|
||||||
public void setGroupId(int groupId) {
|
public void setGroupId(int groupId) {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ public enum UserGroup {
|
||||||
|
|
||||||
COMPUTER(0),
|
COMPUTER(0),
|
||||||
PLAYER(1),
|
PLAYER(1),
|
||||||
|
DEFAULT(2),
|
||||||
MAGE(3),
|
MAGE(3),
|
||||||
ADMIN(7),
|
ADMIN(7),
|
||||||
OWNER(15);
|
OWNER(15);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue