mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
Merge branch 'master' into akh-card-frame
This commit is contained in:
commit
a2e8cedd02
272 changed files with 7641 additions and 2593 deletions
|
|
@ -1,13 +1,12 @@
|
||||||
package mage.client;
|
package mage.client;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.client.chat.LocalCommands;
|
import mage.client.chat.LocalCommands;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.remote.Connection;
|
import mage.remote.Connection;
|
||||||
import mage.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
|
|
@ -15,6 +14,8 @@ import mage.remote.Session;
|
||||||
import mage.remote.SessionImpl;
|
import mage.remote.SessionImpl;
|
||||||
import mage.view.*;
|
import mage.view.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IGOUDT on 15-9-2016.
|
* Created by IGOUDT on 15-9-2016.
|
||||||
*/
|
*/
|
||||||
|
|
@ -91,11 +92,11 @@ public final class SessionHandler {
|
||||||
session.sendPlayerBoolean(gameId, b);
|
session.sendPlayerBoolean(gameId, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getPlayerTypes() {
|
public static PlayerType[] getPlayerTypes() {
|
||||||
return session.getPlayerTypes();
|
return session.getPlayerTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean joinTournamentTable(UUID roomId, UUID tableId, String text, String selectedItem, Integer integer, DeckCardLists deckCardLists, String s) {
|
public static boolean joinTournamentTable(UUID roomId, UUID tableId, String text, PlayerType selectedItem, Integer integer, DeckCardLists deckCardLists, String s) {
|
||||||
return session.joinTournamentTable(roomId, tableId, text, selectedItem, integer, deckCardLists, s);
|
return session.joinTournamentTable(roomId, tableId, text, selectedItem, integer, deckCardLists, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +234,7 @@ public final class SessionHandler {
|
||||||
return session.createTable(roomId, options);
|
return session.createTable(roomId, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean joinTable(UUID roomId, UUID tableId, String playerName, String human, int skill, DeckCardLists deckCardLists, String text) {
|
public static boolean joinTable(UUID roomId, UUID tableId, String playerName, PlayerType human, int skill, DeckCardLists deckCardLists, String text) {
|
||||||
return session.joinTable(roomId, tableId, playerName, human, skill, deckCardLists, text);
|
return session.joinTable(roomId, tableId, playerName, human, skill, deckCardLists, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,26 +33,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.beans.Beans;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
|
||||||
import javax.swing.table.TableColumn;
|
|
||||||
import javax.swing.table.TableColumnModel;
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.client.constants.Constants.DeckEditorMode;
|
import mage.client.constants.Constants.DeckEditorMode;
|
||||||
import mage.client.constants.Constants.SortBy;
|
import mage.client.constants.Constants.SortBy;
|
||||||
|
|
@ -61,15 +41,8 @@ import mage.client.deckeditor.table.TableModel;
|
||||||
import mage.client.deckeditor.table.UpdateCountsCallback;
|
import mage.client.deckeditor.table.UpdateCountsCallback;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.CardViewCardTypeComparator;
|
import mage.client.util.*;
|
||||||
import mage.client.util.CardViewColorComparator;
|
|
||||||
import mage.client.util.CardViewColorIdentityComparator;
|
|
||||||
import mage.client.util.CardViewCostComparator;
|
|
||||||
import mage.client.util.CardViewNameComparator;
|
|
||||||
import mage.client.util.CardViewRarityComparator;
|
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.GUISizeHelper;
|
|
||||||
import mage.client.util.Listener;
|
|
||||||
import mage.client.util.gui.TableSpinnerEditor;
|
import mage.client.util.gui.TableSpinnerEditor;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
|
@ -77,6 +50,18 @@ import mage.view.CardsView;
|
||||||
import mage.view.SimpleCardView;
|
import mage.view.SimpleCardView;
|
||||||
import org.mage.card.arcane.CardPanel;
|
import org.mage.card.arcane.CardPanel;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
import javax.swing.table.TableColumnModel;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.beans.Beans;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
|
||||||
|
|
@ -34,28 +34,25 @@
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.Color;
|
import mage.cards.CardDimensions;
|
||||||
import java.awt.Dimension;
|
import mage.cards.MagePermanent;
|
||||||
import java.awt.Graphics;
|
import mage.cards.Sets;
|
||||||
import java.awt.Graphics2D;
|
import mage.client.util.Config;
|
||||||
import java.awt.Rectangle;
|
import mage.client.util.TransformedImageCache;
|
||||||
import java.awt.RenderingHints;
|
import mage.constants.CardType;
|
||||||
|
import mage.view.CounterView;
|
||||||
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.PopupFactory;
|
|
||||||
import mage.cards.CardDimensions;
|
|
||||||
import mage.cards.MagePermanent;
|
|
||||||
import mage.cards.Sets;
|
|
||||||
import static mage.client.constants.Constants.DAMAGE_MAX_LEFT;
|
import static mage.client.constants.Constants.DAMAGE_MAX_LEFT;
|
||||||
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
|
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
|
||||||
import mage.client.util.Config;
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.view.CounterView;
|
|
||||||
import mage.view.PermanentView;
|
|
||||||
import mage.client.util.TransformedImageCache;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.util.IgnoreList;
|
import mage.client.util.IgnoreList;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
@ -58,7 +59,7 @@ public final class LocalCommands {
|
||||||
|
|
||||||
private static void displayLocalCommandResponse(UUID chatId, String response) {
|
private static void displayLocalCommandResponse(UUID chatId, String response) {
|
||||||
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
|
final String text = new StringBuilder().append("<font color=yellow>").append(response).append("</font>").toString();
|
||||||
ClientCallback chatMessage = new ClientCallback("chatMessage", chatId,
|
ClientCallback chatMessage = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage("", text, timeFormatter.format(new Date()), ChatMessage.MessageColor.BLUE));
|
new ChatMessage("", text, timeFormatter.format(new Date()), ChatMessage.MessageColor.BLUE));
|
||||||
MageFrame.getInstance().processCallback(chatMessage);
|
MageFrame.getInstance().processCallback(chatMessage);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package mage.client.components;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
|
||||||
public class MageUI {
|
public class MageUI {
|
||||||
|
|
@ -92,9 +93,9 @@ public class MageUI {
|
||||||
|
|
||||||
public void doClick(MageComponents name, int waitBeforeClick) throws InterruptedException {
|
public void doClick(MageComponents name, int waitBeforeClick) throws InterruptedException {
|
||||||
final JButton j = getButton(name);
|
final JButton j = getButton(name);
|
||||||
Thread.sleep(waitBeforeClick);
|
TimeUnit.MILLISECONDS.sleep(waitBeforeClick);
|
||||||
while (!j.isEnabled()) {
|
while (!j.isEnabled()) {
|
||||||
Thread.sleep(10);
|
TimeUnit.MILLISECONDS.sleep(10);
|
||||||
}
|
}
|
||||||
Thread t = new Thread(() -> j.doClick());
|
Thread t = new Thread(() -> j.doClick());
|
||||||
t.start();
|
t.start();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package mage.client.components.tray;
|
package mage.client.components.tray;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||||
|
|
@ -21,7 +21,6 @@ public enum MageTray {
|
||||||
|
|
||||||
private int state = 0;
|
private int state = 0;
|
||||||
|
|
||||||
|
|
||||||
public void install() {
|
public void install() {
|
||||||
if (!SystemTray.isSupported()) {
|
if (!SystemTray.isSupported()) {
|
||||||
log.warn("SystemTray is not supported");
|
log.warn("SystemTray is not supported");
|
||||||
|
|
@ -97,7 +96,7 @@ public enum MageTray {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (state != 3) {
|
while (state != 3) {
|
||||||
trayIcon.setImage(i == 0 ? mainImage : flashedImage);
|
trayIcon.setImage(i == 0 ? mainImage : flashedImage);
|
||||||
Thread.sleep(600);
|
TimeUnit.MILLISECONDS.sleep(600);
|
||||||
i = i == 0 ? 1 : 0;
|
i = i == 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
trayIcon.setImage(mainImage);
|
trayIcon.setImage(mainImage);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.Sets;
|
import mage.cards.Sets;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
|
|
@ -58,8 +57,8 @@ import mage.client.SessionHandler;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.cards.ICardGrid;
|
import mage.client.cards.ICardGrid;
|
||||||
import mage.client.constants.Constants.DeckEditorMode;
|
import mage.client.constants.Constants.DeckEditorMode;
|
||||||
import mage.client.deck.generator.DeckGenerator.DeckGeneratorException;
|
|
||||||
import mage.client.deck.generator.DeckGenerator;
|
import mage.client.deck.generator.DeckGenerator;
|
||||||
|
import mage.client.deck.generator.DeckGenerator.DeckGeneratorException;
|
||||||
import mage.client.dialog.AddLandDialog;
|
import mage.client.dialog.AddLandDialog;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
|
@ -838,7 +837,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
|
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
|
||||||
//fcSelectDeck.setCurrentDirectory(new File());
|
//fcSelectDeck.setCurrentDirectory(new File());
|
||||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||||
|
|
@ -850,10 +848,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
File file = fcSelectDeck.getSelectedFile();
|
File file = fcSelectDeck.getSelectedFile();
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+
|
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+ In
|
||||||
* In the case where the user selects the exact same file as was previously
|
* the case where the user selects the exact same file as was
|
||||||
* selected without touching anything else in the dialog, getSelectedFile()
|
* previously selected without touching anything else in the
|
||||||
* will erroneously return null due to some combination of our settings.
|
* dialog, getSelectedFile() will erroneously return null due to
|
||||||
|
* some combination of our settings.
|
||||||
*
|
*
|
||||||
* We manually sub in the last selected file in this case.
|
* We manually sub in the last selected file in this case.
|
||||||
*/
|
*/
|
||||||
|
|
@ -893,10 +892,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
File file = fcSelectDeck.getSelectedFile();
|
File file = fcSelectDeck.getSelectedFile();
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+
|
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+ In
|
||||||
* In the case where the user selects the exact same file as was previously
|
* the case where the user selects the exact same file as was
|
||||||
* selected without touching anything else in the dialog, getSelectedFile()
|
* previously selected without touching anything else in the
|
||||||
* will erroneously return null due to some combination of our settings.
|
* dialog, getSelectedFile() will erroneously return null due to
|
||||||
|
* some combination of our settings.
|
||||||
*
|
*
|
||||||
* We manually sub in the last selected file in this case.
|
* We manually sub in the last selected file in this case.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1123,7 +1123,7 @@ class UpdateDeckTask extends SwingWorker<Void, Void> {
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
SessionHandler.updateDeck(tableId, deck.getDeckCardLists());
|
SessionHandler.updateDeck(tableId, deck.getDeckCardLists());
|
||||||
Thread.sleep(5000);
|
TimeUnit.SECONDS.sleep(5);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,16 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -143,9 +145,9 @@ public class JoinTableDialog extends MageDialog {
|
||||||
try {
|
try {
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD_JOIN, txtPassword.getText());
|
||||||
if (isTournament) {
|
if (isTournament) {
|
||||||
joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
||||||
} else {
|
} else {
|
||||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
|
|
@ -48,10 +40,18 @@ import mage.constants.MultiplayerAttackOption;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
import mage.constants.SkillLevel;
|
import mage.constants.SkillLevel;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -65,7 +65,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
private UUID roomId;
|
private UUID roomId;
|
||||||
private String lastSessionId;
|
private String lastSessionId;
|
||||||
private final List<TablePlayerPanel> players = new ArrayList<>();
|
private final List<TablePlayerPanel> players = new ArrayList<>();
|
||||||
private final List<String> prefPlayerTypes = new ArrayList<>();
|
private final List<PlayerType> prefPlayerTypes = new ArrayList<>();
|
||||||
|
|
||||||
private static final String LIMITED = "Limited";
|
private static final String LIMITED = "Limited";
|
||||||
|
|
||||||
|
|
@ -370,7 +370,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
||||||
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName(), false, 2);
|
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName(), false, 2);
|
||||||
options.getPlayerTypes().add("Human");
|
options.getPlayerTypes().add(PlayerType.HUMAN);
|
||||||
for (TablePlayerPanel player : players) {
|
for (TablePlayerPanel player : players) {
|
||||||
options.getPlayerTypes().add(player.getPlayerType());
|
options.getPlayerTypes().add(player.getPlayerType());
|
||||||
}
|
}
|
||||||
|
|
@ -404,7 +404,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
roomId,
|
roomId,
|
||||||
table.getTableId(),
|
table.getTableId(),
|
||||||
this.player1Panel.getPlayerName(),
|
this.player1Panel.getPlayerName(),
|
||||||
"Human", 1,
|
PlayerType.HUMAN, 1,
|
||||||
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
|
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
|
||||||
this.txtPassword.getText())) {
|
this.txtPassword.getText())) {
|
||||||
for (TablePlayerPanel player : players) {
|
for (TablePlayerPanel player : players) {
|
||||||
|
|
@ -509,7 +509,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
if (numPlayers > players.size()) {
|
if (numPlayers > players.size()) {
|
||||||
while (players.size() != numPlayers) {
|
while (players.size() != numPlayers) {
|
||||||
TablePlayerPanel playerPanel = new TablePlayerPanel();
|
TablePlayerPanel playerPanel = new TablePlayerPanel();
|
||||||
String playerType = "Human";
|
PlayerType playerType = PlayerType.HUMAN;
|
||||||
if (prefPlayerTypes.size() >= players.size() && !players.isEmpty()) {
|
if (prefPlayerTypes.size() >= players.size() && !players.isEmpty()) {
|
||||||
playerType = prefPlayerTypes.get(players.size() - 1);
|
playerType = prefPlayerTypes.get(players.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
@ -597,7 +597,9 @@ public class NewTableDialog extends MageDialog {
|
||||||
|
|
||||||
String playerTypes = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES, "Human");
|
String playerTypes = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES, "Human");
|
||||||
prefPlayerTypes.clear();
|
prefPlayerTypes.clear();
|
||||||
prefPlayerTypes.addAll(Arrays.asList(playerTypes.split(",")));
|
for(String pType : playerTypes.split(",")) {
|
||||||
|
prefPlayerTypes.add(PlayerType.getByDescription(pType));
|
||||||
|
}
|
||||||
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));
|
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));
|
||||||
|
|
||||||
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, "Two Player Duel");
|
String gameTypeName = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, "Two Player Duel");
|
||||||
|
|
|
||||||
|
|
@ -33,22 +33,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.ComboBoxModel;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import javax.swing.filechooser.FileFilter;
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.cards.repository.ExpansionInfo;
|
import mage.cards.repository.ExpansionInfo;
|
||||||
|
|
@ -65,13 +49,20 @@ import mage.game.draft.DraftOptions;
|
||||||
import mage.game.draft.DraftOptions.TimingOption;
|
import mage.game.draft.DraftOptions.TimingOption;
|
||||||
import mage.game.tournament.LimitedOptions;
|
import mage.game.tournament.LimitedOptions;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import mage.view.TournamentTypeView;
|
import mage.view.TournamentTypeView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class NewTournamentDialog extends MageDialog {
|
public class NewTournamentDialog extends MageDialog {
|
||||||
|
|
@ -93,7 +84,9 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
private String cubeFromDeckFilename = "";
|
private String cubeFromDeckFilename = "";
|
||||||
private boolean automaticChange = false;
|
private boolean automaticChange = false;
|
||||||
|
|
||||||
/** Creates new form NewTournamentDialog */
|
/**
|
||||||
|
* Creates new form NewTournamentDialog
|
||||||
|
*/
|
||||||
public NewTournamentDialog() {
|
public NewTournamentDialog() {
|
||||||
initComponents();
|
initComponents();
|
||||||
lastSessionId = "";
|
lastSessionId = "";
|
||||||
|
|
@ -133,7 +126,8 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
|
* This method is called from within the constructor to
|
||||||
* initialize the form.
|
* 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 regenerated by the Form Editor.
|
* always regenerated by the Form Editor.
|
||||||
|
|
@ -514,11 +508,11 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText(), "", numSeats);
|
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText(), "", numSeats);
|
||||||
tOptions.setTournamentType(tournamentType.getName());
|
tOptions.setTournamentType(tournamentType.getName());
|
||||||
tOptions.setPassword(txtPassword.getText());
|
tOptions.setPassword(txtPassword.getText());
|
||||||
tOptions.getPlayerTypes().add("Human");
|
tOptions.getPlayerTypes().add(PlayerType.HUMAN);
|
||||||
tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
|
tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
|
||||||
tOptions.setQuitRatio((Integer) spnQuitRatio.getValue());
|
tOptions.setQuitRatio((Integer) spnQuitRatio.getValue());
|
||||||
for (TournamentPlayerPanel player : players) {
|
for (TournamentPlayerPanel player : players) {
|
||||||
tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem());
|
tOptions.getPlayerTypes().add((PlayerType) player.getPlayerType().getSelectedItem());
|
||||||
}
|
}
|
||||||
if (!tournamentType.isElimination()) {
|
if (!tournamentType.isElimination()) {
|
||||||
tOptions.setNumberRounds((Integer) spnNumRounds.getValue());
|
tOptions.setNumberRounds((Integer) spnNumRounds.getValue());
|
||||||
|
|
@ -605,7 +599,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
roomId,
|
roomId,
|
||||||
table.getTableId(),
|
table.getTableId(),
|
||||||
this.player1Panel.getPlayerName(),
|
this.player1Panel.getPlayerName(),
|
||||||
"Human", 1,
|
PlayerType.HUMAN, 1,
|
||||||
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
|
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
|
||||||
tOptions.getPassword())) {
|
tOptions.getPassword())) {
|
||||||
for (TournamentPlayerPanel player : players) {
|
for (TournamentPlayerPanel player : players) {
|
||||||
|
|
@ -718,6 +712,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
private void cbGameTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameTypeActionPerformed
|
private void cbGameTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameTypeActionPerformed
|
||||||
setGameOptions();
|
setGameOptions();
|
||||||
}//GEN-LAST:event_cbGameTypeActionPerformed
|
}//GEN-LAST:event_cbGameTypeActionPerformed
|
||||||
|
|
||||||
private void setGameOptions() {
|
private void setGameOptions() {
|
||||||
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
||||||
// int oldValue = (Integer) this.spnNumPlayers.getValue();
|
// int oldValue = (Integer) this.spnNumPlayers.getValue();
|
||||||
|
|
@ -893,8 +888,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
start = true;
|
start = true;
|
||||||
selectedIndex = pack.getSelectedIndex();
|
selectedIndex = pack.getSelectedIndex();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
pack.setSelectedIndex(selectedIndex);
|
pack.setSelectedIndex(selectedIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -909,8 +903,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
|
|
||||||
players.add(playerPanel);
|
players.add(playerPanel);
|
||||||
}
|
}
|
||||||
}
|
} else if (numPlayers < players.size()) {
|
||||||
else if (numPlayers < players.size()) {
|
|
||||||
while (players.size() != numPlayers) {
|
while (players.size() != numPlayers) {
|
||||||
players.remove(players.size() - 1);
|
players.remove(players.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
@ -922,7 +915,6 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void drawPlayers() {
|
private void drawPlayers() {
|
||||||
this.pnlOtherPlayers.removeAll();
|
this.pnlOtherPlayers.removeAll();
|
||||||
for (TournamentPlayerPanel panel : players) {
|
for (TournamentPlayerPanel panel : players) {
|
||||||
|
|
@ -948,8 +940,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
start = true;
|
start = true;
|
||||||
selectedIndex = player.getPlayerType().getSelectedIndex();
|
selectedIndex = player.getPlayerType().getSelectedIndex();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
player.getPlayerType().setSelectedIndex(selectedIndex);
|
player.getPlayerType().setSelectedIndex(selectedIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1051,7 +1042,6 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
* Save the settings to java prefs to reload it next time the dialog will be created
|
* Save the settings to java prefs to reload it next time the dialog will be created
|
||||||
*
|
*
|
||||||
* @param tOptions Tournament options
|
* @param tOptions Tournament options
|
||||||
|
|
||||||
*/
|
*/
|
||||||
private void saveTournamentSettingsToPrefs(TournamentOptions tOptions) {
|
private void saveTournamentSettingsToPrefs(TournamentOptions tOptions) {
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, tOptions.getName());
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, tOptions.getName());
|
||||||
|
|
|
||||||
|
|
@ -39,19 +39,17 @@ import java.util.Optional;
|
||||||
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 java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.Icon;
|
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.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
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_ORDER;
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
||||||
|
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.audio.AudioManager;
|
import mage.client.util.audio.AudioManager;
|
||||||
import mage.client.util.gui.TableUtil;
|
import mage.client.util.gui.TableUtil;
|
||||||
|
|
@ -419,15 +417,8 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
SessionHandler.getTable(roomId, tableId).ifPresent(tableView -> {
|
SessionHandler.getTable(roomId, tableId).ifPresent(this::publish);
|
||||||
|
TimeUnit.SECONDS.sleep(1);
|
||||||
this.publish(tableView);
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.awt.AWTEvent;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import static java.awt.Component.LEFT_ALIGNMENT;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
|
@ -59,6 +60,7 @@ import java.util.Set;
|
||||||
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 java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.GroupLayout;
|
import javax.swing.GroupLayout;
|
||||||
|
|
@ -80,7 +82,6 @@ import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
|
|
@ -100,9 +101,7 @@ import mage.client.dialog.PickChoiceDialog;
|
||||||
import mage.client.dialog.PickNumberDialog;
|
import mage.client.dialog.PickNumberDialog;
|
||||||
import mage.client.dialog.PickPileDialog;
|
import mage.client.dialog.PickPileDialog;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
|
||||||
import static mage.client.dialog.PreferencesDialog.*;
|
import static mage.client.dialog.PreferencesDialog.*;
|
||||||
|
|
||||||
import mage.client.dialog.ShowCardsDialog;
|
import mage.client.dialog.ShowCardsDialog;
|
||||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||||
import mage.client.plugins.adapters.MageActionCallback;
|
import mage.client.plugins.adapters.MageActionCallback;
|
||||||
|
|
@ -119,13 +118,11 @@ import mage.constants.Constants;
|
||||||
import mage.constants.EnlargeMode;
|
import mage.constants.EnlargeMode;
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
|
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_FIRST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_FIRST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_LAST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_ABILITY_LAST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_FIRST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_FIRST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST;
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
|
||||||
|
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.events.PlayerQueryEvent;
|
import mage.game.events.PlayerQueryEvent;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
|
|
@ -534,8 +531,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
this.pnlReplay.setVisible(false);
|
this.pnlReplay.setVisible(false);
|
||||||
this.gameChatPanel.clear();
|
this.gameChatPanel.clear();
|
||||||
SessionHandler.getGameChatId(gameId).ifPresent(uuid ->
|
SessionHandler.getGameChatId(gameId).ifPresent(uuid
|
||||||
this.gameChatPanel.connect(uuid));
|
-> this.gameChatPanel.connect(uuid));
|
||||||
if (!SessionHandler.watchGame(gameId)) {
|
if (!SessionHandler.watchGame(gameId)) {
|
||||||
removeGame();
|
removeGame();
|
||||||
}
|
}
|
||||||
|
|
@ -816,13 +813,15 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
cardsView.put(player.getTopCard().getId(), player.getTopCard());
|
cardsView.put(player.getTopCard().getId(), player.getTopCard());
|
||||||
handleGameInfoWindow(revealed, ShowType.REVEAL_TOP_LIBRARY, player.getName() + "'s top library card", cardsView);
|
handleGameInfoWindow(revealed, ShowType.REVEAL_TOP_LIBRARY, player.getName() + "'s top library card", cardsView);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!players.isEmpty()) {
|
||||||
logger.warn("Couldn't find player.");
|
logger.warn("Couldn't find player.");
|
||||||
logger.warn(" uuid:" + player.getPlayerId());
|
logger.warn(" uuid:" + player.getPlayerId());
|
||||||
logger.warn(" players:");
|
logger.warn(" players:");
|
||||||
for (PlayAreaPanel p : players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
logger.warn(String.valueOf(p));
|
logger.warn(String.valueOf(p));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// can happen at the game start before player list is initiated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!menuNameSet) {
|
if (!menuNameSet) {
|
||||||
|
|
@ -2433,7 +2432,7 @@ class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
SessionHandler.nextPlay(gameId);
|
SessionHandler.nextPlay(gameId);
|
||||||
Thread.sleep(1000);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.remote;
|
package mage.client.remote;
|
||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
|
|
@ -49,19 +44,15 @@ import mage.client.util.object.SaveObjectUtil;
|
||||||
import mage.interfaces.callback.CallbackClient;
|
import mage.interfaces.callback.CallbackClient;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.utils.CompressUtil;
|
import mage.utils.CompressUtil;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.*;
|
||||||
import mage.view.ChatMessage;
|
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
import mage.view.DeckView;
|
|
||||||
import mage.view.DraftClientMessage;
|
|
||||||
import mage.view.DraftView;
|
|
||||||
import mage.view.GameClientMessage;
|
|
||||||
import mage.view.GameEndView;
|
|
||||||
import mage.view.GameView;
|
|
||||||
import mage.view.TableClientMessage;
|
|
||||||
import mage.view.UserRequestMessage;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -79,38 +70,38 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void processCallback(final ClientCallback callback) {
|
public synchronized void processCallback(final ClientCallback callback) {
|
||||||
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod().toString());
|
||||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
try {
|
try {
|
||||||
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
|
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
|
||||||
switch (callback.getMethod()) {
|
switch (callback.getMethod()) {
|
||||||
case "startGame": {
|
case START_GAME: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
|
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
|
||||||
gameStarted(message.getGameId(), message.getPlayerId());
|
gameStarted(message.getGameId(), message.getPlayerId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "startTournament": {
|
case START_TOURNAMENT: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
tournamentStarted(message.getGameId(), message.getPlayerId());
|
tournamentStarted(message.getGameId(), message.getPlayerId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "startDraft": {
|
case START_DRAFT: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
draftStarted(message.getGameId(), message.getPlayerId());
|
draftStarted(message.getGameId(), message.getPlayerId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayGame":
|
case REPLAY_GAME:
|
||||||
replayGame(callback.getObjectId());
|
replayGame(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "showTournament":
|
case SHOW_TOURNAMENT:
|
||||||
showTournament(callback.getObjectId());
|
showTournament(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "watchGame":
|
case WATCHGAME:
|
||||||
watchGame(callback.getObjectId());
|
watchGame(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "chatMessage": {
|
case CHATMESSAGE: {
|
||||||
ChatMessage message = (ChatMessage) callback.getData();
|
ChatMessage message = (ChatMessage) callback.getData();
|
||||||
|
|
||||||
// Drop messages from ignored users
|
// Drop messages from ignored users
|
||||||
|
|
@ -154,7 +145,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "serverMessage":
|
case SERVER_MESSAGE:
|
||||||
if (callback.getData() != null) {
|
if (callback.getData() != null) {
|
||||||
ChatMessage message = (ChatMessage) callback.getData();
|
ChatMessage message = (ChatMessage) callback.getData();
|
||||||
if (message.getColor() == ChatMessage.MessageColor.RED) {
|
if (message.getColor() == ChatMessage.MessageColor.RED) {
|
||||||
|
|
@ -164,50 +155,50 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "joinedTable": {
|
case JOINED_TABLE: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayInit": {
|
case REPLAY_INIT: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.init((GameView) callback.getData());
|
panel.init((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayDone": {
|
case REPLAY_DONE: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "replayUpdate": {
|
case REPLAY_UPDATE: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.updateGame((GameView) callback.getData());
|
panel.updateGame((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameInit": {
|
case GAME_INIT: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.init((GameView) callback.getData());
|
panel.init((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameOver": {
|
case GAME_OVER: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
panel.endMessage((String) callback.getData(), callback.getMessageId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameError":
|
case GAME_ERROR:
|
||||||
frame.showErrorDialog("Game Error", (String) callback.getData());
|
frame.showErrorDialog("Game Error", (String) callback.getData());
|
||||||
break;
|
break;
|
||||||
case "gameAsk": {
|
case GAME_ASK: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -215,7 +206,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameTarget": // e.g. Pick triggered ability
|
case GAME_TARGET: // e.g. Pick triggered ability
|
||||||
{
|
{
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
|
|
@ -225,7 +216,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameSelect": {
|
case GAME_SELECT: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -233,14 +224,14 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameChooseAbility": {
|
case GAME_CHOOSE_ABILITY: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameChoosePile": {
|
case GAME_CHOOSE_PILE: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -248,7 +239,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameChooseChoice": {
|
case GAME_CHOOSE_CHOICE: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
|
|
||||||
|
|
@ -257,7 +248,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gamePlayMana": {
|
case GAME_PLAY_MANA: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -265,7 +256,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gamePlayXMana": {
|
case GAME_PLAY_XMANA: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -273,7 +264,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameSelectAmount": {
|
case GAME_GET_AMOUNT: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -281,23 +272,23 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "gameUpdate": {
|
case GAME_UPDATE: {
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.updateGame((GameView) callback.getData());
|
panel.updateGame((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "endGameInfo":
|
case END_GAME_INFO:
|
||||||
MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
|
MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
|
||||||
break;
|
break;
|
||||||
case "showUserMessage":
|
case SHOW_USERMESSAGE:
|
||||||
List<String> messageData = (List<String>) callback.getData();
|
List<String> messageData = (List<String>) callback.getData();
|
||||||
if (messageData.size() == 2) {
|
if (messageData.size() == 2) {
|
||||||
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
|
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "gameInform":
|
case GAME_INFORM:
|
||||||
if (callback.getMessageId() > gameInformMessageId) {
|
if (callback.getMessageId() > gameInformMessageId) {
|
||||||
{
|
{
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
|
|
@ -313,7 +304,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
gameInformMessageId = messageId;
|
gameInformMessageId = messageId;
|
||||||
break;
|
break;
|
||||||
case "gameInformPersonal": {
|
case GAME_INFORM_PERSONAL: {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -322,7 +313,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "sideboard": {
|
case SIDEBOARD: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
DeckView deckView = message.getDeck();
|
DeckView deckView = message.getDeck();
|
||||||
Deck deck = DeckUtil.construct(deckView);
|
Deck deck = DeckUtil.construct(deckView);
|
||||||
|
|
@ -333,17 +324,17 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "construct": {
|
case CONSTRUCT: {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
DeckView deckView = message.getDeck();
|
DeckView deckView = message.getDeck();
|
||||||
Deck deck = DeckUtil.construct(deckView);
|
Deck deck = DeckUtil.construct(deckView);
|
||||||
construct(deck, message.getTableId(), message.getTime());
|
construct(deck, message.getTableId(), message.getTime());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "draftOver":
|
case DRAFT_OVER:
|
||||||
MageFrame.removeDraft(callback.getObjectId());
|
MageFrame.removeDraft(callback.getObjectId());
|
||||||
break;
|
break;
|
||||||
case "draftPick": {
|
case DRAFT_PICK: {
|
||||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -351,14 +342,14 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "draftUpdate": {
|
case DRAFT_UPDATE: {
|
||||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.updateDraft((DraftView) callback.getData());
|
panel.updateDraft((DraftView) callback.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "draftInform": // if (callback.getMessageId() > messageId) {
|
case DRAFT_INFORM: // if (callback.getMessageId() > messageId) {
|
||||||
{
|
{
|
||||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||||
}
|
}
|
||||||
|
|
@ -366,7 +357,7 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
// logger.warn("message out of sequence - ignoring");
|
// logger.warn("message out of sequence - ignoring");
|
||||||
// }
|
// }
|
||||||
break;
|
break;
|
||||||
case "draftInit": {
|
case DRAFT_INIT: {
|
||||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||||
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
|
|
@ -374,9 +365,9 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "tournamentInit":
|
case TOURNAMENT_INIT:
|
||||||
break;
|
break;
|
||||||
case "userRequestDialog":
|
case USER_REQUEST_DIALOG:
|
||||||
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
|
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,16 @@
|
||||||
|
|
||||||
package mage.client.table;
|
package mage.client.table;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
|
import mage.players.PlayerType;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -58,7 +60,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
||||||
this.newPlayerPanel.setVisible(false);
|
this.newPlayerPanel.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(int playerNum, String playerType) {
|
public void init(int playerNum, PlayerType playerType) {
|
||||||
cbPlayerType.setModel(new DefaultComboBoxModel(SessionHandler.getPlayerTypes()));
|
cbPlayerType.setModel(new DefaultComboBoxModel(SessionHandler.getPlayerTypes()));
|
||||||
this.lblPlayerNum.setText("Player " + playerNum);
|
this.lblPlayerNum.setText("Player " + playerNum);
|
||||||
if (Config.defaultOtherPlayerIndex != null) {
|
if (Config.defaultOtherPlayerIndex != null) {
|
||||||
|
|
@ -77,13 +79,13 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public boolean joinTable(UUID roomId, UUID tableId) throws IOException, ClassNotFoundException {
|
public boolean joinTable(UUID roomId, UUID tableId) throws IOException, ClassNotFoundException {
|
||||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||||
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
|
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (PlayerType) this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlayerType() {
|
public PlayerType getPlayerType() {
|
||||||
return (String) this.cbPlayerType.getSelectedItem();
|
return PlayerType.getByDescription(this.cbPlayerType.getSelectedItem().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerTypeEventListener(Listener<Event> listener) {
|
public void addPlayerTypeEventListener(Listener<Event> listener) {
|
||||||
|
|
|
||||||
|
|
@ -33,69 +33,21 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.table;
|
package mage.client.table;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.HeadlessException;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.beans.PropertyVetoException;
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CancellationException;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import javax.swing.AbstractAction;
|
|
||||||
import javax.swing.Action;
|
|
||||||
import javax.swing.Icon;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JDesktopPane;
|
|
||||||
import javax.swing.JInternalFrame;
|
|
||||||
import javax.swing.JLayeredPane;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.RowFilter;
|
|
||||||
import javax.swing.SwingWorker;
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.dialog.JoinTableDialog;
|
import mage.client.dialog.*;
|
||||||
import mage.client.dialog.NewTableDialog;
|
|
||||||
import mage.client.dialog.NewTournamentDialog;
|
|
||||||
import mage.client.dialog.PreferencesDialog;
|
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
|
|
||||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
|
|
||||||
import mage.client.dialog.TableWaitingDialog;
|
|
||||||
import static mage.client.table.TablesPanel.PASSWORDED;
|
|
||||||
import mage.client.util.ButtonColumn;
|
import mage.client.util.ButtonColumn;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.IgnoreList;
|
import mage.client.util.IgnoreList;
|
||||||
import mage.client.util.MageTableRowSorter;
|
import mage.client.util.MageTableRowSorter;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.client.util.gui.TableUtil;
|
import mage.client.util.gui.TableUtil;
|
||||||
import mage.constants.MatchTimeLimit;
|
import mage.constants.*;
|
||||||
import mage.constants.MultiplayerAttackOption;
|
|
||||||
import mage.constants.PlayerAction;
|
|
||||||
import mage.constants.RangeOfInfluence;
|
|
||||||
import mage.constants.SkillLevel;
|
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
import mage.view.RoomUsersView;
|
import mage.view.RoomUsersView;
|
||||||
|
|
@ -103,6 +55,25 @@ import mage.view.TableView;
|
||||||
import mage.view.UserRequestMessage;
|
import mage.view.UserRequestMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
|
||||||
|
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
|
||||||
|
import static mage.client.table.TablesPanel.PASSWORDED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -216,7 +187,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
if (PASSWORDED.equals(pwdColumn)) {
|
if (PASSWORDED.equals(pwdColumn)) {
|
||||||
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
|
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
|
||||||
} else {
|
} else {
|
||||||
SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), "Human", 1, null, "");
|
SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), PlayerType.HUMAN, 1, null, "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
|
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
|
||||||
|
|
@ -1188,8 +1159,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
MatchOptions options = new MatchOptions("1", "Two Player Duel", false, 2);
|
MatchOptions options = new MatchOptions("1", "Two Player Duel", false, 2);
|
||||||
options.getPlayerTypes().add("Human");
|
options.getPlayerTypes().add(PlayerType.HUMAN);
|
||||||
options.getPlayerTypes().add("Computer - mad");
|
options.getPlayerTypes().add(PlayerType.COMPUTER_MAD);
|
||||||
options.setDeckType("Limited");
|
options.setDeckType("Limited");
|
||||||
options.setAttackOption(MultiplayerAttackOption.LEFT);
|
options.setAttackOption(MultiplayerAttackOption.LEFT);
|
||||||
options.setRange(RangeOfInfluence.ALL);
|
options.setRange(RangeOfInfluence.ALL);
|
||||||
|
|
@ -1203,8 +1174,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
|
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
|
||||||
table = SessionHandler.createTable(roomId, options);
|
table = SessionHandler.createTable(roomId, options);
|
||||||
|
|
||||||
SessionHandler.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"), "");
|
SessionHandler.joinTable(roomId, table.getTableId(), "Human", PlayerType.HUMAN, 1, DeckImporterUtil.importDeck("test.dck"), "");
|
||||||
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", "Computer - mad", 5, DeckImporterUtil.importDeck("test.dck"), "");
|
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", PlayerType.COMPUTER_MAD, 5, DeckImporterUtil.importDeck("test.dck"), "");
|
||||||
SessionHandler.startMatch(roomId, table.getTableId());
|
SessionHandler.startMatch(roomId, table.getTableId());
|
||||||
} catch (HeadlessException ex) {
|
} catch (HeadlessException ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
|
|
@ -1450,7 +1421,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
||||||
if (!tables.isEmpty()) {
|
if (!tables.isEmpty()) {
|
||||||
this.publish(tables);
|
this.publish(tables);
|
||||||
}
|
}
|
||||||
Thread.sleep(3000);
|
TimeUnit.SECONDS.sleep(3);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -1494,7 +1465,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
this.publish(SessionHandler.getRoomUsers(roomId));
|
this.publish(SessionHandler.getRoomUsers(roomId));
|
||||||
Thread.sleep(3000);
|
TimeUnit.SECONDS.sleep(3);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -1636,7 +1607,7 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
if (!matches.isEmpty()) {
|
if (!matches.isEmpty()) {
|
||||||
this.publish(matches);
|
this.publish(matches);
|
||||||
}
|
}
|
||||||
Thread.sleep(10000);
|
TimeUnit.SECONDS.sleep(10);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ package mage.client.table;
|
||||||
|
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
|
import mage.players.PlayerType;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -68,7 +69,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
||||||
roomId,
|
roomId,
|
||||||
tableId,
|
tableId,
|
||||||
this.txtPlayerName.getText(),
|
this.txtPlayerName.getText(),
|
||||||
(String)this.cbPlayerType.getSelectedItem(),
|
(PlayerType) this.cbPlayerType.getSelectedItem(),
|
||||||
(Integer) spnLevel.getValue(),
|
(Integer) spnLevel.getValue(),
|
||||||
deckCardLists,
|
deckCardLists,
|
||||||
"");
|
"");
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,12 @@ import java.util.Optional;
|
||||||
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 java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
import mage.cards.o.Opt;
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.chat.ChatPanelBasic;
|
import mage.client.chat.ChatPanelBasic;
|
||||||
|
|
@ -730,7 +729,7 @@ class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
||||||
protected Void doInBackground() throws Exception {
|
protected Void doInBackground() throws Exception {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
this.publish(SessionHandler.getTournament(tournamentId));
|
this.publish(SessionHandler.getTournament(tournamentId));
|
||||||
Thread.sleep(2000);
|
TimeUnit.SECONDS.sleep(2);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
package mage.client.util.audio;
|
package mage.client.util.audio;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.awt.List;
|
import java.awt.List;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.sound.sampled.*;
|
import javax.sound.sampled.*;
|
||||||
import mage.client.constants.Constants;
|
import mage.client.constants.Constants;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
|
@ -75,7 +76,7 @@ public class MusicPlayer {
|
||||||
player.breaked_out = true;
|
player.breaked_out = true;
|
||||||
player.breaked = true;
|
player.breaked = true;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Thread error: " + e);
|
log.error("Thread error: " + e);
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +120,7 @@ public class MusicPlayer {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
while (!stopped) {
|
while (!stopped) {
|
||||||
|
|
@ -130,7 +131,7 @@ public class MusicPlayer {
|
||||||
PlayThread.start();
|
PlayThread.start();
|
||||||
while (!(breaked || breaked_out)) {
|
while (!(breaked || breaked_out)) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10);
|
TimeUnit.MILLISECONDS.sleep(10);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Thread error: " + e);
|
log.error("Thread error: " + e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package mage.client.util.gui;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.ImageObserver;
|
import java.awt.image.ImageObserver;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for creating BufferedImage object from Image instance.
|
* Utility class for creating BufferedImage object from Image instance.
|
||||||
|
|
@ -65,7 +66,7 @@ public class BufferedImageBuilder {
|
||||||
});
|
});
|
||||||
while (!imageLoadStatus.widthDone && !imageLoadStatus.heightDone) {
|
while (!imageLoadStatus.widthDone && !imageLoadStatus.heightDone) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(300);
|
TimeUnit.MILLISECONDS.sleep(300);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +74,7 @@ public class BufferedImageBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ImageLoadStatus {
|
static class ImageLoadStatus {
|
||||||
|
|
||||||
public boolean widthDone = false;
|
public boolean widthDone = false;
|
||||||
public boolean heightDone = false;
|
public boolean heightDone = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package mage.client.util.stats;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -29,7 +30,7 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
|
||||||
while (!isCancelled()) {
|
while (!isCancelled()) {
|
||||||
float memUsage = MemoryUsageStatUtil.getMemoryFreeStatPercentage();
|
float memUsage = MemoryUsageStatUtil.getMemoryFreeStatPercentage();
|
||||||
this.publish(memUsage >= 0 ? memUsage : null);
|
this.publish(memUsage >= 0 ? memUsage : null);
|
||||||
Thread.sleep(MEM_USAGE_UPDATE_TIME);
|
TimeUnit.MILLISECONDS.sleep(MEM_USAGE_UPDATE_TIME);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,17 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public final class Util {
|
public final class Util {
|
||||||
|
|
||||||
public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
|
public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
|
||||||
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase().contains("windows");
|
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase().contains("windows");
|
||||||
|
|
||||||
public static final ThreadPoolExecutor threadPool;
|
public static final ThreadPoolExecutor threadPool;
|
||||||
static private int threadCount;
|
static private int threadCount;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -59,7 +60,7 @@ public final class Util {
|
||||||
|
|
||||||
public static void sleep(int millis) {
|
public static void sleep(int millis) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(millis);
|
TimeUnit.MILLISECONDS.sleep(millis);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JLayeredPane;
|
import javax.swing.JLayeredPane;
|
||||||
|
|
@ -33,6 +34,7 @@ import org.apache.log4j.Logger;
|
||||||
import org.mage.card.arcane.Animation;
|
import org.mage.card.arcane.Animation;
|
||||||
import org.mage.card.arcane.CardPanel;
|
import org.mage.card.arcane.CardPanel;
|
||||||
import org.mage.card.arcane.CardPanelComponentImpl;
|
import org.mage.card.arcane.CardPanelComponentImpl;
|
||||||
|
import org.mage.card.arcane.CardPanelRenderImpl;
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
import org.mage.plugins.card.dl.DownloadGui;
|
import org.mage.plugins.card.dl.DownloadGui;
|
||||||
import org.mage.plugins.card.dl.DownloadJob;
|
import org.mage.plugins.card.dl.DownloadJob;
|
||||||
|
|
@ -43,7 +45,6 @@ import org.mage.plugins.card.dl.sources.GathererSets;
|
||||||
import org.mage.plugins.card.dl.sources.GathererSymbols;
|
import org.mage.plugins.card.dl.sources.GathererSymbols;
|
||||||
import org.mage.plugins.card.images.ImageCache;
|
import org.mage.plugins.card.images.ImageCache;
|
||||||
import org.mage.plugins.card.info.CardInfoPaneImpl;
|
import org.mage.plugins.card.info.CardInfoPaneImpl;
|
||||||
import org.mage.card.arcane.CardPanelRenderImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CardPlugin} implementation.
|
* {@link CardPlugin} implementation.
|
||||||
|
|
@ -110,8 +111,8 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary card rendering shim. Split card rendering isn't implemented yet, so
|
* Temporary card rendering shim. Split card rendering isn't implemented
|
||||||
* use old component based rendering for the split cards.
|
* yet, so use old component based rendering for the split cards.
|
||||||
*/
|
*/
|
||||||
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension) {
|
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension) {
|
||||||
String fallback = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false");
|
String fallback = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false");
|
||||||
|
|
@ -584,7 +585,7 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
Animation.showCard(card, count > 0 ? count : 1);
|
Animation.showCard(card, count > 0 ? count : 1);
|
||||||
try {
|
try {
|
||||||
while ((card).getAlpha() + 0.05f < 1) {
|
while ((card).getAlpha() + 0.05f < 1) {
|
||||||
Thread.sleep(30);
|
TimeUnit.MILLISECONDS.sleep(30);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -598,7 +599,7 @@ public class CardPluginImpl implements CardPlugin {
|
||||||
Animation.hideCard(card, count > 0 ? count : 1);
|
Animation.hideCard(card, count > 0 ? count : 1);
|
||||||
try {
|
try {
|
||||||
while ((card).getAlpha() - 0.05f > 0) {
|
while ((card).getAlpha() - 0.05f > 0) {
|
||||||
Thread.sleep(30);
|
TimeUnit.MILLISECONDS.sleep(30);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ package org.mage.plugins.card.dl.sources;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.images.CardDownloadData;
|
import org.mage.plugins.card.images.CardDownloadData;
|
||||||
|
|
||||||
|
|
@ -1697,7 +1698,7 @@ public class GrabbagImageSource implements CardImageSource {
|
||||||
public void doPause(String httpImageUrl) {
|
public void doPause(String httpImageUrl) {
|
||||||
if (!httpImageUrl.startsWith("/MTG")) {
|
if (!httpImageUrl.startsWith("/MTG")) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(2000);
|
TimeUnit.SECONDS.sleep(2);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 org.mage.plugins.card.dl.sources;
|
package org.mage.plugins.card.dl.sources;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
|
@ -41,6 +40,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
|
@ -320,7 +320,7 @@ public class WizardCardsImageSource implements CardImageSource {
|
||||||
|
|
||||||
while (!executor.isTerminated()) {
|
while (!executor.isTerminated()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,22 @@
|
||||||
package org.mage.plugins.card.images;
|
package org.mage.plugins.card.images;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
import java.nio.file.AccessDeniedException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import javax.imageio.IIOImage;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.ImageWriteParam;
|
||||||
|
import javax.imageio.ImageWriter;
|
||||||
|
import javax.imageio.stream.FileImageOutputStream;
|
||||||
|
import javax.swing.*;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.client.constants.Constants;
|
import mage.client.constants.Constants;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
|
|
@ -15,23 +32,6 @@ import org.mage.plugins.card.dl.sources.*;
|
||||||
import org.mage.plugins.card.properties.SettingsManager;
|
import org.mage.plugins.card.properties.SettingsManager;
|
||||||
import org.mage.plugins.card.utils.CardImageUtils;
|
import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
|
|
||||||
import javax.imageio.IIOImage;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.imageio.ImageWriteParam;
|
|
||||||
import javax.imageio.ImageWriter;
|
|
||||||
import javax.imageio.stream.FileImageOutputStream;
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.*;
|
|
||||||
import java.nio.file.AccessDeniedException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
public class DownloadPictures extends DefaultBoundedRangeModel implements Runnable {
|
public class DownloadPictures extends DefaultBoundedRangeModel implements Runnable {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DownloadPictures.class);
|
private static final Logger logger = Logger.getLogger(DownloadPictures.class);
|
||||||
|
|
@ -345,7 +345,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try (InputStreamReader input = new InputStreamReader(in);
|
try (InputStreamReader input = new InputStreamReader(in);
|
||||||
BufferedReader reader = new BufferedReader(input)) {
|
BufferedReader reader = new BufferedReader(input)) {
|
||||||
|
|
||||||
|
|
@ -486,7 +485,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
while (!executor.isTerminated()) {
|
while (!executor.isTerminated()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,27 @@
|
||||||
|
|Generate|TOK:AKH|Trueheart Duelist||
|
||||||
|
|
||||||
|
|Generate|TOK:MM3|Angel||
|
||||||
|
|Generate|TOK:MM3|Beast|1|
|
||||||
|
|Generate|TOK:MM3|Beast|2|
|
||||||
|
|Generate|TOK:MM3|Bird||
|
||||||
|
|Generate|TOK:MM3|Centaur||
|
||||||
|
|Generate|TOK:MM3|Dragon||
|
||||||
|
|Generate|TOK:MM3|Elemental||
|
||||||
|
|Generate|TOK:MM3|Elephant||
|
||||||
|
|Generate|TOK:MM3|Giant Warrior||
|
||||||
|
|Generate|TOK:MM3|Goblin||
|
||||||
|
|Generate|TOK:MM3|Goblin Warrior||
|
||||||
|
|Generate|TOK:MM3|Golem||
|
||||||
|
|Generate|TOK:MM3|Ooze||
|
||||||
|
|Generate|TOK:MM3|Saproling||
|
||||||
|
|Generate|TOK:MM3|Soldier|1|
|
||||||
|
|Generate|TOK:MM3|Soldier|2|
|
||||||
|
|Generate|TOK:MM3|Spider||
|
||||||
|
|Generate|TOK:MM3|Spirit||
|
||||||
|
|Generate|TOK:MM3|Wurm||
|
||||||
|
|Generate|TOK:MM3|Zombie||
|
||||||
|
|Generate|EMBLEM!:MM3|Emblem Domri||
|
||||||
|
|
||||||
|Generate|TOK:C16|Beast||
|
|Generate|TOK:C16|Beast||
|
||||||
|Generate|TOK:C16|Bird|1|
|
|Generate|TOK:C16|Bird|1|
|
||||||
|Generate|TOK:C16|Bird|2|
|
|Generate|TOK:C16|Bird|2|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,6 @@ dd3evg=ddaevg
|
||||||
dd3gvl=ddagvl
|
dd3gvl=ddagvl
|
||||||
dd3jvc=ddajvc
|
dd3jvc=ddajvc
|
||||||
# Remove setname as soon as the images can be downloaded
|
# Remove setname as soon as the images can be downloaded
|
||||||
ignore.urls=TOK,PCA,DDS,ANB,AKH,HOU
|
ignore.urls=TOK,PCA,ANB,HOU
|
||||||
# sets ordered by release time (newest goes first)
|
# sets ordered by release time (newest goes first)
|
||||||
token.lookup.order=ANB,HOU,MM3,DDS,AKH,DD3DVD,DD3EVG,DD3GVL,DD3JVC,H09,AER,PCA,C16,V16,MPS,KLD,DDR,CN2,EMN,EMA,SOI,DDQ,CP,CMA,ARENA,SUS,APAC,EURO,UGIN,C15,OGW,EXP,DDP,BFZ,DRB,V09,V10,V11,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC
|
token.lookup.order=ANB,HOU,MM3,DDS,AKH,DD3DVD,DD3EVG,DD3GVL,DD3JVC,H09,AER,PCA,C16,V16,MPS,KLD,DDR,CN2,EMN,EMA,SOI,DDQ,CP,CMA,ARENA,SUS,APAC,EURO,UGIN,C15,OGW,EXP,DDP,BFZ,DRB,V09,V10,V11,V12,V13,V14,V15,TPR,MPRP,DD3,DDO,ORI,MM2,PTC,DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import javax.swing.*;
|
||||||
import mage.client.components.MageUI;
|
import mage.client.components.MageUI;
|
||||||
import mage.interfaces.MageClient;
|
import mage.interfaces.MageClient;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
|
@ -10,9 +13,6 @@ import mage.utils.MageVersion;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for emulating the connection from multi mage clients.
|
* Test for emulating the connection from multi mage clients.
|
||||||
*
|
*
|
||||||
|
|
@ -116,7 +116,7 @@ public class MultiConnectTest {
|
||||||
|
|
||||||
private void sleep(int ms) {
|
private void sleep(int ms) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(ms);
|
TimeUnit.MILLISECONDS.sleep(ms);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import javax.swing.*;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.components.MageUI;
|
import mage.client.components.MageUI;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ayratn
|
* @author ayratn
|
||||||
*/
|
*/
|
||||||
|
|
@ -68,7 +68,7 @@ public class StartMultiGamesTest {
|
||||||
|
|
||||||
private void sleep(int ms) {
|
private void sleep(int ms) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(ms);
|
TimeUnit.MILLISECONDS.sleep(ms);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.interfaces;
|
package mage.interfaces;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
|
|
@ -40,15 +36,15 @@ 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.PlayerType;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.utils.MageVersion;
|
import mage.utils.MageVersion;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.*;
|
||||||
import mage.view.GameView;
|
|
||||||
import mage.view.MatchView;
|
import java.util.List;
|
||||||
import mage.view.RoomUsersView;
|
import java.util.Optional;
|
||||||
import mage.view.TableView;
|
import java.util.Set;
|
||||||
import mage.view.TournamentView;
|
import java.util.UUID;
|
||||||
import mage.view.UserView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -94,9 +90,9 @@ public interface MageServer {
|
||||||
|
|
||||||
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, PlayerType 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, PlayerType 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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,15 @@
|
||||||
|
|
||||||
package mage.interfaces;
|
package mage.interfaces;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import mage.players.PlayerType;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import mage.utils.MageVersion;
|
import mage.utils.MageVersion;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TournamentTypeView;
|
import mage.view.TournamentTypeView;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,7 +44,7 @@ public class ServerState implements Serializable {
|
||||||
|
|
||||||
private final List<GameTypeView> gameTypes;
|
private final List<GameTypeView> gameTypes;
|
||||||
private final List<TournamentTypeView> tournamentTypes;
|
private final List<TournamentTypeView> tournamentTypes;
|
||||||
private final String[] playerTypes;
|
private final PlayerType[] playerTypes;
|
||||||
private final String[] deckTypes;
|
private final String[] deckTypes;
|
||||||
private final String[] draftCubes;
|
private final String[] draftCubes;
|
||||||
private final boolean testMode;
|
private final boolean testMode;
|
||||||
|
|
@ -53,7 +53,7 @@ public class ServerState implements Serializable {
|
||||||
private final long expansionsContentVersion;
|
private final long expansionsContentVersion;
|
||||||
|
|
||||||
public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes,
|
public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes,
|
||||||
String[] playerTypes, String[] deckTypes, String[] draftCubes, boolean testMode,
|
PlayerType[] playerTypes, String[] deckTypes, String[] draftCubes, boolean testMode,
|
||||||
MageVersion version, long cardsContentVersion, long expansionsContentVersion) {
|
MageVersion version, long cardsContentVersion, long expansionsContentVersion) {
|
||||||
this.gameTypes = gameTypes;
|
this.gameTypes = gameTypes;
|
||||||
this.tournamentTypes = tournamentTypes;
|
this.tournamentTypes = tournamentTypes;
|
||||||
|
|
@ -81,7 +81,7 @@ public class ServerState implements Serializable {
|
||||||
return tournamentTypes;
|
return tournamentTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getPlayerTypes() {
|
public PlayerType[] getPlayerTypes() {
|
||||||
return playerTypes;
|
return playerTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,18 +39,18 @@ public class ClientCallback implements Serializable {
|
||||||
|
|
||||||
private UUID objectId;
|
private UUID objectId;
|
||||||
private Object data;
|
private Object data;
|
||||||
private String method;
|
private ClientCallbackMethod method;
|
||||||
private int messageId;
|
private int messageId;
|
||||||
|
|
||||||
public ClientCallback() {}
|
public ClientCallback() {}
|
||||||
|
|
||||||
public ClientCallback(String method, UUID objectId, Object data) {
|
public ClientCallback(ClientCallbackMethod method, UUID objectId, Object data) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.objectId = objectId;
|
this.objectId = objectId;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientCallback(String method, UUID objectId) {
|
public ClientCallback(ClientCallbackMethod method, UUID objectId) {
|
||||||
this(method, objectId, null);
|
this(method, objectId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,11 +75,11 @@ public class ClientCallback implements Serializable {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMethod() {
|
public ClientCallbackMethod getMethod() {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethod(String method) {
|
public void setMethod(ClientCallbackMethod method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package mage.interfaces.callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by IGOUDT on 4-4-2017.
|
||||||
|
*/
|
||||||
|
public enum ClientCallbackMethod {
|
||||||
|
|
||||||
|
CHATMESSAGE("chatMessage"),
|
||||||
|
TOURNAMENT_INIT("tournamentInit"),
|
||||||
|
TOURNAMENT_UPDATE("tournamentUpdate"),
|
||||||
|
TOURNAMENT_OVER("tournamentOver"),
|
||||||
|
JOINED_TABLE("joinedTable"),
|
||||||
|
START_DRAFT("startDraft"),
|
||||||
|
START_TOURNAMENT("startTournament"),
|
||||||
|
SIDEBOARD("sideboard"),
|
||||||
|
CONSTRUCT("construct"),
|
||||||
|
SHOW_USERMESSAGE("showUserMessage"),
|
||||||
|
WATCHGAME("watchGame"),
|
||||||
|
REPLAY_GAME("replayGame"),
|
||||||
|
START_GAME("startGame"),
|
||||||
|
SHOW_TOURNAMENT("showTournament"),
|
||||||
|
SHOW_GAME_END_DIALOG("showGameEndDialog"),
|
||||||
|
SERVER_MESSAGE("serverMessage"),
|
||||||
|
GAME_INIT("gameInit"),
|
||||||
|
GAME_OVER("gameOver"),
|
||||||
|
GAME_INFORM("gameInform"),
|
||||||
|
GAME_INFORM_PERSONAL("gameInformPersonal"),
|
||||||
|
GAME_ERROR("gameError"),
|
||||||
|
GAME_UPDATE("gameUpdate"),
|
||||||
|
DRAFT_OVER("draftOver"),
|
||||||
|
REPLAY_DONE("replayDone"),
|
||||||
|
USER_REQUEST_DIALOG("userRequestDialog"),
|
||||||
|
REPLAY_UPDATE("replayUpdate"),
|
||||||
|
REPLAY_INIT("replayInit"),
|
||||||
|
END_GAME_INFO("endGameInfo"),
|
||||||
|
GAME_TARGET("gameTarget"),
|
||||||
|
GAME_CHOOSE_ABILITY("gameChooseAbility"),
|
||||||
|
GAME_CHOOSE_PILE("gameChoosePile"),
|
||||||
|
GAME_CHOOSE_CHOICE("gameChooseChoice"), GAME_ASK("gameAsk"), GAME_SELECT("gameSelect"), GAME_PLAY_MANA("gamePlayMana"), GAME_PLAY_XMANA("gamePlayXMana"), GAME_GET_AMOUNT("gameSelectAmount"), DRAFT_INIT("draftInit"), DRAFT_INFORM("draftInform"), DRAFT_PICK("draftPick"), DRAFT_UPDATE("draftUpdate");
|
||||||
|
|
||||||
|
String value;
|
||||||
|
|
||||||
|
ClientCallbackMethod(String value){
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,13 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.remote;
|
package mage.remote;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.UndeclaredThrowableException;
|
|
||||||
import java.net.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.cards.decks.InvalidDeckException;
|
import mage.cards.decks.InvalidDeckException;
|
||||||
|
|
@ -50,6 +43,7 @@ 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.PlayerType;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.utils.CompressUtil;
|
import mage.utils.CompressUtil;
|
||||||
import mage.view.*;
|
import mage.view.*;
|
||||||
|
|
@ -62,6 +56,13 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
|
||||||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||||
import org.jboss.remoting.transporter.TransporterClient;
|
import org.jboss.remoting.transporter.TransporterClient;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.UndeclaredThrowableException;
|
||||||
|
import java.net.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -550,7 +551,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerTypes() {
|
public PlayerType[] getPlayerTypes() {
|
||||||
return serverState.getPlayerTypes();
|
return serverState.getPlayerTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -680,7 +681,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
|
public boolean joinTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
// Workaround to fix Can't join table problem
|
// Workaround to fix Can't join table problem
|
||||||
|
|
@ -703,7 +704,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
|
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
// Workaround to fix Can't join table problem
|
// Workaround to fix Can't join table problem
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
package mage.remote.interfaces;
|
package mage.remote.interfaces;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TournamentTypeView;
|
import mage.view.TournamentTypeView;
|
||||||
|
|
||||||
|
|
@ -36,7 +38,7 @@ import mage.view.TournamentTypeView;
|
||||||
*/
|
*/
|
||||||
public interface GameTypes {
|
public interface GameTypes {
|
||||||
|
|
||||||
String[] getPlayerTypes();
|
PlayerType[] getPlayerTypes();
|
||||||
|
|
||||||
List<GameTypeView> getGameTypes();
|
List<GameTypeView> getGameTypes();
|
||||||
List<GameTypeView> getTournamentGameTypes();
|
List<GameTypeView> getTournamentGameTypes();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ package mage.remote.interfaces;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import mage.view.TournamentView;
|
import mage.view.TournamentView;
|
||||||
|
|
@ -64,13 +65,13 @@ public interface PlayerActions {
|
||||||
|
|
||||||
// boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId);
|
// boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId);
|
||||||
|
|
||||||
boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
|
boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password);
|
||||||
|
|
||||||
boolean watchTable(UUID roomId, UUID tableId);
|
boolean watchTable(UUID roomId, UUID tableId);
|
||||||
|
|
||||||
boolean watchTournamentTable(UUID tableId);
|
boolean watchTournamentTable(UUID tableId);
|
||||||
|
|
||||||
boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
|
boolean joinTable(UUID roomId, UUID tableId, String playerName, PlayerType playerType, int skill, DeckCardLists deckList, String password);
|
||||||
|
|
||||||
Optional<TableView> getTable(UUID roomId, UUID tableId);
|
Optional<TableView> getTable(UUID roomId, UUID tableId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,14 @@
|
||||||
package mage.utils;
|
package mage.utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.interfaces.rate.RateCallback;
|
import mage.interfaces.rate.RateCallback;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds deck from provided card pool.
|
* Builds deck from provided card pool.
|
||||||
*
|
*
|
||||||
|
|
@ -246,13 +239,13 @@ public final class DeckBuilder {
|
||||||
this.card = card;
|
this.card = card;
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
if (card.isCreature()) {
|
||||||
type = 10;
|
type = 10;
|
||||||
} else if (card.getSubtype(null).contains("Equipment")) {
|
} else if (card.getSubtype(null).contains("Equipment")) {
|
||||||
type = 8;
|
type = 8;
|
||||||
} else if (card.getSubtype(null).contains("Aura")) {
|
} else if (card.getSubtype(null).contains("Aura")) {
|
||||||
type = 5;
|
type = 5;
|
||||||
} else if (card.getCardType().contains(CardType.INSTANT)) {
|
} else if (card.isInstant()) {
|
||||||
type = 7;
|
type = 7;
|
||||||
} else {
|
} else {
|
||||||
type = 6;
|
type = 6;
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,12 @@
|
||||||
*/
|
*/
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
|
import mage.game.Seat;
|
||||||
|
import mage.players.PlayerType;
|
||||||
|
import mage.players.net.UserData;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.game.Seat;
|
|
||||||
import mage.players.net.UserData;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -43,7 +45,7 @@ public class SeatView implements Serializable {
|
||||||
private final String flagName;
|
private final String flagName;
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
private final String playerType;
|
private final PlayerType playerType;
|
||||||
private final String history;
|
private final String history;
|
||||||
private final int generalRating;
|
private final int generalRating;
|
||||||
private final int constructedRating;
|
private final int constructedRating;
|
||||||
|
|
@ -86,7 +88,7 @@ public class SeatView implements Serializable {
|
||||||
return playerName;
|
return playerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlayerType() {
|
public PlayerType getPlayerType() {
|
||||||
return playerType;
|
return playerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.deck;
|
package mage.deck;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.CanBeYourCommanderAbility;
|
import mage.abilities.common.CanBeYourCommanderAbility;
|
||||||
|
|
@ -42,11 +37,12 @@ import mage.cards.ExpansionSet;
|
||||||
import mage.cards.Sets;
|
import mage.cards.Sets;
|
||||||
import mage.cards.decks.Constructed;
|
import mage.cards.decks.Constructed;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.SetType;
|
import mage.constants.SetType;
|
||||||
import mage.filter.FilterMana;
|
import mage.filter.FilterMana;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Plopman
|
* @author Plopman
|
||||||
|
|
@ -501,7 +497,7 @@ public class Commander extends Constructed {
|
||||||
thisMaxPower = Math.max(thisMaxPower, 1);
|
thisMaxPower = Math.max(thisMaxPower, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.getCardType().contains(CardType.PLANESWALKER)) {
|
if (card.isPlaneswalker()) {
|
||||||
if (card.getName().toLowerCase().equals("jace, the mind sculptor")) {
|
if (card.getName().toLowerCase().equals("jace, the mind sculptor")) {
|
||||||
thisMaxPower = Math.max(thisMaxPower, 6);
|
thisMaxPower = Math.max(thisMaxPower, 6);
|
||||||
}
|
}
|
||||||
|
|
@ -511,7 +507,7 @@ public class Commander extends Constructed {
|
||||||
thisMaxPower = Math.max(thisMaxPower, 4);
|
thisMaxPower = Math.max(thisMaxPower, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.getCardType().contains(CardType.LAND)) {
|
if (card.isLand()) {
|
||||||
thisMaxPower = 0;
|
thisMaxPower = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.player.ai.ma;
|
package mage.player.ai.ma;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.keyword.HasteAbility;
|
import mage.abilities.keyword.HasteAbility;
|
||||||
|
|
@ -11,6 +10,8 @@ import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ubeefx, nantuko
|
* @author ubeefx, nantuko
|
||||||
*/
|
*/
|
||||||
|
|
@ -27,7 +28,7 @@ public final class ArtificialScoringSystem {
|
||||||
|
|
||||||
public static int getCardDefinitionScore(final Game game, final Card card) {
|
public static int getCardDefinitionScore(final Game game, final Card card) {
|
||||||
int value = 3; //TODO: add new rating system card value
|
int value = 3; //TODO: add new rating system card value
|
||||||
if (card.getCardType().contains(CardType.LAND)) {
|
if (card.isLand()) {
|
||||||
int score = (int) ((value / 2.0f) * 50);
|
int score = (int) ((value / 2.0f) * 50);
|
||||||
//TODO: check this for "any color" lands
|
//TODO: check this for "any color" lands
|
||||||
//TODO: check this for dual and filter lands
|
//TODO: check this for dual and filter lands
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
|
|
@ -57,15 +56,15 @@ public final class RateCard {
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
int type;
|
int type;
|
||||||
if (card.getCardType().contains(CardType.PLANESWALKER)) {
|
if (card.isPlaneswalker()) {
|
||||||
type = 15;
|
type = 15;
|
||||||
} else if (card.getCardType().contains(CardType.CREATURE)) {
|
} else if (card.isCreature()) {
|
||||||
type = 10;
|
type = 10;
|
||||||
} else if (card.getSubtype(null).contains("Equipment")) {
|
} else if (card.getSubtype(null).contains("Equipment")) {
|
||||||
type = 8;
|
type = 8;
|
||||||
} else if (card.getSubtype(null).contains("Aura")) {
|
} else if (card.getSubtype(null).contains("Aura")) {
|
||||||
type = 5;
|
type = 5;
|
||||||
} else if (card.getCardType().contains(CardType.INSTANT)) {
|
} else if (card.isInstant()) {
|
||||||
type = 7;
|
type = 7;
|
||||||
} else {
|
} else {
|
||||||
type = 6;
|
type = 6;
|
||||||
|
|
@ -78,8 +77,7 @@ public final class RateCard {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int isRemoval(Card card) {
|
private static int isRemoval(Card card) {
|
||||||
if (card.getSubtype(null).contains("Aura") || card.getCardType().contains(CardType.INSTANT)
|
if (card.getSubtype(null).contains("Aura") || card.isInstant() || card.isSorcery()) {
|
||||||
|| card.getCardType().contains(CardType.SORCERY)) {
|
|
||||||
|
|
||||||
for (Ability ability : card.getAbilities()) {
|
for (Ability ability : card.getAbilities()) {
|
||||||
for (Effect effect : ability.getEffects()) {
|
for (Effect effect : ability.getEffects()) {
|
||||||
|
|
|
||||||
|
|
@ -27,30 +27,13 @@
|
||||||
*/
|
*/
|
||||||
package mage.player.human;
|
package mage.player.human;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.*;
|
||||||
import mage.abilities.ActivatedAbility;
|
|
||||||
import mage.abilities.Mode;
|
|
||||||
import mage.abilities.Modes;
|
|
||||||
import mage.abilities.PlayLandAbility;
|
|
||||||
import mage.abilities.SpecialAction;
|
|
||||||
import mage.abilities.SpellAbility;
|
|
||||||
import mage.abilities.TriggeredAbility;
|
|
||||||
import mage.abilities.costs.VariableCost;
|
import mage.abilities.costs.VariableCost;
|
||||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.costs.mana.PhyrexianManaCost;
|
|
||||||
import mage.abilities.effects.RequirementEffect;
|
import mage.abilities.effects.RequirementEffect;
|
||||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
|
@ -58,22 +41,7 @@ import mage.cards.Cards;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.choices.ChoiceImpl;
|
import mage.choices.ChoiceImpl;
|
||||||
import mage.constants.AbilityType;
|
import mage.constants.*;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Constants;
|
|
||||||
import mage.constants.ManaType;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.PhaseStep;
|
|
||||||
import mage.constants.PlayerAction;
|
|
||||||
import static mage.constants.PlayerAction.HOLD_PRIORITY;
|
|
||||||
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_NO;
|
|
||||||
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL;
|
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_NAME_LAST;
|
|
||||||
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
|
|
||||||
import mage.constants.RangeOfInfluence;
|
|
||||||
import static mage.constants.SpellAbilityType.SPLIT;
|
|
||||||
import static mage.constants.SpellAbilityType.SPLIT_FUSED;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.common.FilterAttackingCreature;
|
import mage.filter.common.FilterAttackingCreature;
|
||||||
import mage.filter.common.FilterBlockingCreature;
|
import mage.filter.common.FilterBlockingCreature;
|
||||||
import mage.filter.common.FilterCreatureForCombat;
|
import mage.filter.common.FilterCreatureForCombat;
|
||||||
|
|
@ -102,6 +70,12 @@ import mage.util.ManaUtil;
|
||||||
import mage.util.MessageToClient;
|
import mage.util.MessageToClient;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL;
|
||||||
|
import static mage.constants.PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -1275,7 +1249,7 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (userData.isUseFirstManaAbility() && object instanceof Permanent && object.getCardType().contains(CardType.LAND)) {
|
if (userData.isUseFirstManaAbility() && object instanceof Permanent && object.isLand()) {
|
||||||
ActivatedAbility ability = abilities.values().iterator().next();
|
ActivatedAbility ability = abilities.values().iterator().next();
|
||||||
if (ability instanceof ActivatedManaAbilityImpl) {
|
if (ability instanceof ActivatedManaAbilityImpl) {
|
||||||
activateAbility(ability, game);
|
activateAbility(ability, game);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ public enum ChatManager {
|
||||||
private static final Logger logger = Logger.getLogger(ChatManager.class);
|
private static final Logger logger = Logger.getLogger(ChatManager.class);
|
||||||
private static final HashMap<String, String> userMessages = new HashMap<>();
|
private static final HashMap<String, String> userMessages = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
private final ConcurrentHashMap<UUID, ChatSession> chatSessions = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<UUID, ChatSession> chatSessions = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public UUID createChatSession(String info) {
|
public UUID createChatSession(String info) {
|
||||||
|
|
@ -159,7 +158,6 @@ public enum ChatManager {
|
||||||
|
|
||||||
userMessages.put(userName, message);
|
userMessages.put(userName, message);
|
||||||
|
|
||||||
|
|
||||||
if (messageType == MessageType.TALK) {
|
if (messageType == MessageType.TALK) {
|
||||||
if (user.getChatLockedUntil() != null) {
|
if (user.getChatLockedUntil() != null) {
|
||||||
if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) {
|
if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) {
|
||||||
|
|
@ -173,8 +171,8 @@ public enum ChatManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay);
|
|
||||||
}
|
}
|
||||||
|
chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,8 +253,8 @@ public enum ChatManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendReconnectMessage(UUID userId) {
|
public void sendReconnectMessage(UUID userId) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
chatSessions.values()
|
-> chatSessions.values()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(chat -> chat.hasUser(userId))
|
.filter(chat -> chat.hasUser(userId))
|
||||||
.forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, MessageType.STATUS, null)));
|
.forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, MessageType.STATUS, null)));
|
||||||
|
|
@ -275,6 +273,4 @@ public enum ChatManager {
|
||||||
return new ArrayList<>(chatSessions.values());
|
return new ArrayList<>(chatSessions.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
|
|
@ -84,30 +85,9 @@ public class ChatSession {
|
||||||
clients.remove(userId);
|
clients.remove(userId);
|
||||||
logger.debug(userName + '(' + reason.toString() + ')' + " removed from chatId " + chatId);
|
logger.debug(userName + '(' + reason.toString() + ')' + " removed from chatId " + chatId);
|
||||||
}
|
}
|
||||||
String message;
|
String message = reason.getMessage();
|
||||||
switch (reason) {
|
|
||||||
case Disconnected:
|
if (!message.isEmpty()) {
|
||||||
message = " has left XMage";
|
|
||||||
break;
|
|
||||||
case LostConnection:
|
|
||||||
message = " has lost connection";
|
|
||||||
break;
|
|
||||||
case SessionExpired:
|
|
||||||
message = " session expired";
|
|
||||||
break;
|
|
||||||
case AdminDisconnect:
|
|
||||||
message = " was disconnected by the Admin";
|
|
||||||
break;
|
|
||||||
case ConnectingOtherInstance:
|
|
||||||
message = " reconnected and replaced still active old session";
|
|
||||||
break;
|
|
||||||
case CleaningUp:
|
|
||||||
message = null;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
message = " left (" + reason.toString() + ')';
|
|
||||||
}
|
|
||||||
if (message != null) {
|
|
||||||
broadcast(null, userName + message, MessageColor.BLUE, true, MessageType.STATUS, null);
|
broadcast(null, userName + message, MessageColor.BLUE, true, MessageType.STATUS, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +98,7 @@ public class ChatSession {
|
||||||
|
|
||||||
public boolean broadcastInfoToUser(User toUser, String message) {
|
public boolean broadcastInfoToUser(User toUser, String message) {
|
||||||
if (clients.containsKey(toUser.getId())) {
|
if (clients.containsKey(toUser.getId())) {
|
||||||
toUser.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(null, message, timeFormatter.format(new Date()), MessageColor.BLUE, MessageType.USER_INFO, null)));
|
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId, new ChatMessage(null, message, timeFormatter.format(new Date()), MessageColor.BLUE, MessageType.USER_INFO, null)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -126,10 +106,10 @@ public class ChatSession {
|
||||||
|
|
||||||
public boolean broadcastWhisperToUser(User fromUser, User toUser, String message) {
|
public boolean broadcastWhisperToUser(User fromUser, User toUser, String message) {
|
||||||
if (clients.containsKey(toUser.getId())) {
|
if (clients.containsKey(toUser.getId())) {
|
||||||
toUser.fireCallback(new ClientCallback("chatMessage", chatId,
|
toUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage(fromUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_FROM, SoundToPlay.PlayerWhispered)));
|
new ChatMessage(fromUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_FROM, SoundToPlay.PlayerWhispered)));
|
||||||
if (clients.containsKey(fromUser.getId())) {
|
if (clients.containsKey(fromUser.getId())) {
|
||||||
fromUser.fireCallback(new ClientCallback("chatMessage", chatId,
|
fromUser.fireCallback(new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId,
|
||||||
new ChatMessage(toUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_TO, null)));
|
new ChatMessage(toUser.getName(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER_TO, null)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -139,24 +119,20 @@ public class ChatSession {
|
||||||
|
|
||||||
public void broadcast(String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
public void broadcast(String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
||||||
if (!message.isEmpty()) {
|
if (!message.isEmpty()) {
|
||||||
HashSet<UUID> clientsToRemove = null;
|
HashSet<UUID> clientsToRemove = new HashSet<>();
|
||||||
ClientCallback clientCallback = new ClientCallback("chatMessage", chatId, new ChatMessage(userName, message, (withTime ? timeFormatter.format(new Date()) : ""), color, messageType, soundToPlay));
|
ClientCallback clientCallback = new ClientCallback(ClientCallbackMethod.CHATMESSAGE, chatId, new ChatMessage(userName, message, (withTime ? timeFormatter.format(new Date()) : ""), color, messageType, soundToPlay));
|
||||||
for (UUID userId : clients.keySet()) {
|
for (UUID userId : clients.keySet()) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
user.get().fireCallback(clientCallback);
|
user.get().fireCallback(clientCallback);
|
||||||
} else {
|
} else {
|
||||||
if (clientsToRemove == null) {
|
|
||||||
clientsToRemove = new HashSet<>();
|
|
||||||
}
|
|
||||||
clientsToRemove.add(userId);
|
clientsToRemove.add(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clientsToRemove != null) {
|
|
||||||
for (UUID userIdToRemove : clientsToRemove) {
|
for (UUID userIdToRemove : clientsToRemove) {
|
||||||
clients.remove(userIdToRemove);
|
clients.remove(userIdToRemove);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,20 @@ package mage.server;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum DisconnectReason {
|
public enum DisconnectReason {
|
||||||
LostConnection, Disconnected, CleaningUp, ConnectingOtherInstance, AdminDisconnect, SessionExpired, Undefined
|
LostConnection(" has lost connection"),
|
||||||
|
Disconnected(" has left XMage"),
|
||||||
|
CleaningUp(" [cleaning up]"),
|
||||||
|
ConnectingOtherInstance(" reconnected and replaced still active old session"),
|
||||||
|
AdminDisconnect(" was disconnected by the Admin"),
|
||||||
|
SessionExpired(" session expired"),
|
||||||
|
Undefined("");
|
||||||
|
|
||||||
|
String message;
|
||||||
|
DisconnectReason(String message){
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage(){
|
||||||
|
return message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ 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.interfaces.callback.ClientCallbackMethod;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.remote.MageVersionException;
|
import mage.remote.MageVersionException;
|
||||||
import mage.server.draft.CubeFactory;
|
import mage.server.draft.CubeFactory;
|
||||||
|
|
@ -74,7 +76,7 @@ import java.util.concurrent.ExecutorService;
|
||||||
public class MageServerImpl implements MageServer {
|
public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(MageServerImpl.class);
|
private static final Logger logger = Logger.getLogger(MageServerImpl.class);
|
||||||
private static final ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor();
|
private static final ExecutorService callExecutor = ThreadExecutor.instance.getCallExecutor();
|
||||||
private static final SecureRandom RANDOM = new SecureRandom();
|
private static final SecureRandom RANDOM = new SecureRandom();
|
||||||
|
|
||||||
private final String adminPassword;
|
private final String adminPassword;
|
||||||
|
|
@ -233,8 +235,8 @@ public class MageServerImpl implements MageServer {
|
||||||
String maxAiOpponents = ConfigSettings.instance.getMaxAiOpponents();
|
String maxAiOpponents = ConfigSettings.instance.getMaxAiOpponents();
|
||||||
if (maxAiOpponents != null) {
|
if (maxAiOpponents != null) {
|
||||||
int aiPlayers = 0;
|
int aiPlayers = 0;
|
||||||
for (String playerType : options.getPlayerTypes()) {
|
for (PlayerType playerType : options.getPlayerTypes()) {
|
||||||
if (!playerType.equals("Human")) {
|
if (playerType != PlayerType.HUMAN) {
|
||||||
aiPlayers++;
|
aiPlayers++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -282,7 +284,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException, GameException {
|
public boolean joinTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final PlayerType playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException, GameException {
|
||||||
return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
|
|
@ -309,7 +311,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTournamentTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException, GameException {
|
public boolean joinTournamentTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final PlayerType playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException, GameException {
|
||||||
return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
|
|
@ -989,11 +991,11 @@ public class MageServerImpl implements MageServer {
|
||||||
public ServerState getServerState() throws MageException {
|
public ServerState getServerState() throws MageException {
|
||||||
try {
|
try {
|
||||||
return new ServerState(
|
return new ServerState(
|
||||||
GameFactory.getInstance().getGameTypes(),
|
GameFactory.instance.getGameTypes(),
|
||||||
TournamentFactory.getInstance().getTournamentTypes(),
|
TournamentFactory.instance.getTournamentTypes(),
|
||||||
PlayerFactory.getInstance().getPlayerTypes().toArray(new String[PlayerFactory.getInstance().getPlayerTypes().size()]),
|
PlayerFactory.instance.getPlayerTypes().toArray(new PlayerType[PlayerFactory.instance.getPlayerTypes().size()]),
|
||||||
DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[DeckValidatorFactory.getInstance().getDeckTypes().size()]),
|
DeckValidatorFactory.instance.getDeckTypes().toArray(new String[DeckValidatorFactory.instance.getDeckTypes().size()]),
|
||||||
CubeFactory.getInstance().getDraftCubes().toArray(new String[CubeFactory.getInstance().getDraftCubes().size()]),
|
CubeFactory.instance.getDraftCubes().toArray(new String[CubeFactory.instance.getDraftCubes().size()]),
|
||||||
testMode,
|
testMode,
|
||||||
Main.getVersion(),
|
Main.getVersion(),
|
||||||
CardRepository.instance.getContentVersionConstant(),
|
CardRepository.instance.getContentVersionConstant(),
|
||||||
|
|
@ -1171,9 +1173,9 @@ public class MageServerImpl implements MageServer {
|
||||||
execute("sendBroadcastMessage", sessionId, () -> {
|
execute("sendBroadcastMessage", sessionId, () -> {
|
||||||
for (User user : UserManager.instance.getUsers()) {
|
for (User user : UserManager.instance.getUsers()) {
|
||||||
if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
|
if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
|
||||||
user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.RED)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, MessageColor.RED)));
|
||||||
} else {
|
} else {
|
||||||
user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.BLUE)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.SERVER_MESSAGE, null, new ChatMessage("SERVER", message, null, MessageColor.BLUE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,6 @@ import org.w3c.dom.Element;
|
||||||
import javax.management.MBeanServer;
|
import javax.management.MBeanServer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -164,31 +163,31 @@ public final class Main {
|
||||||
deleteSavedGames();
|
deleteSavedGames();
|
||||||
ConfigSettings config = ConfigSettings.instance;
|
ConfigSettings config = ConfigSettings.instance;
|
||||||
for (GamePlugin plugin : config.getGameTypes()) {
|
for (GamePlugin plugin : config.getGameTypes()) {
|
||||||
GameFactory.getInstance().addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
GameFactory.instance.addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
||||||
}
|
}
|
||||||
for (GamePlugin plugin : config.getTournamentTypes()) {
|
for (GamePlugin plugin : config.getTournamentTypes()) {
|
||||||
TournamentFactory.getInstance().addTournamentType(plugin.getName(), loadTournamentType(plugin), loadPlugin(plugin));
|
TournamentFactory.instance.addTournamentType(plugin.getName(), loadTournamentType(plugin), loadPlugin(plugin));
|
||||||
}
|
}
|
||||||
for (Plugin plugin : config.getPlayerTypes()) {
|
for (Plugin plugin : config.getPlayerTypes()) {
|
||||||
PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin));
|
PlayerFactory.instance.addPlayerType(plugin.getName(), loadPlugin(plugin));
|
||||||
}
|
}
|
||||||
for (Plugin plugin : config.getDraftCubes()) {
|
for (Plugin plugin : config.getDraftCubes()) {
|
||||||
CubeFactory.getInstance().addDraftCube(plugin.getName(), loadPlugin(plugin));
|
CubeFactory.instance.addDraftCube(plugin.getName(), loadPlugin(plugin));
|
||||||
}
|
}
|
||||||
for (Plugin plugin : config.getDeckTypes()) {
|
for (Plugin plugin : config.getDeckTypes()) {
|
||||||
DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
DeckValidatorFactory.instance.addDeckType(plugin.getName(), loadPlugin(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ExtensionPackage pkg : extensions) {
|
for (ExtensionPackage pkg : extensions) {
|
||||||
Map<String, Class> draftCubes = pkg.getDraftCubes();
|
Map<String, Class> draftCubes = pkg.getDraftCubes();
|
||||||
for (String name : draftCubes.keySet()) {
|
for (String name : draftCubes.keySet()) {
|
||||||
logger.info("Loading extension: [" + name + "] " + draftCubes.get(name).toString());
|
logger.info("Loading extension: [" + name + "] " + draftCubes.get(name).toString());
|
||||||
CubeFactory.getInstance().addDraftCube(name, draftCubes.get(name));
|
CubeFactory.instance.addDraftCube(name, draftCubes.get(name));
|
||||||
}
|
}
|
||||||
Map<String, Class> deckTypes = pkg.getDeckTypes();
|
Map<String, Class> deckTypes = pkg.getDeckTypes();
|
||||||
for (String name : deckTypes.keySet()) {
|
for (String name : deckTypes.keySet()) {
|
||||||
logger.info("Loading extension: [" + name + "] " + deckTypes.get(name));
|
logger.info("Loading extension: [" + name + "] " + deckTypes.get(name));
|
||||||
DeckValidatorFactory.getInstance().addDeckType(name, deckTypes.get(name));
|
DeckValidatorFactory.instance.addDeckType(name, deckTypes.get(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ package mage.server;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.constants.Constants;
|
import mage.constants.Constants;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.players.net.UserGroup;
|
import mage.players.net.UserGroup;
|
||||||
import mage.server.game.GamesRoom;
|
import mage.server.game.GamesRoom;
|
||||||
|
|
@ -423,14 +424,14 @@ public class Session {
|
||||||
List<String> messageData = new LinkedList<>();
|
List<String> messageData = new LinkedList<>();
|
||||||
messageData.add("Error while connecting to server");
|
messageData.add("Error while connecting to server");
|
||||||
messageData.add(message);
|
messageData.add(message);
|
||||||
fireCallback(new ClientCallback("showUserMessage", null, messageData));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendInfoMessageToClient(String message) {
|
public void sendInfoMessageToClient(String message) {
|
||||||
List<String> messageData = new LinkedList<>();
|
List<String> messageData = new LinkedList<>();
|
||||||
messageData.add("Information about connecting to the server");
|
messageData.add("Information about connecting to the server");
|
||||||
messageData.add(message);
|
messageData.add(message);
|
||||||
fireCallback(new ClientCallback("showUserMessage", null, messageData));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Throwable getBasicCause(Throwable cause) {
|
public static Throwable getBasicCause(Throwable cause) {
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ import mage.game.tournament.Tournament;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.server.draft.DraftManager;
|
import mage.server.draft.DraftManager;
|
||||||
import mage.server.game.DeckValidatorFactory;
|
import mage.server.game.DeckValidatorFactory;
|
||||||
import mage.server.game.GameFactory;
|
import mage.server.game.GameFactory;
|
||||||
|
|
@ -87,12 +88,12 @@ public class TableController {
|
||||||
private Tournament tournament;
|
private Tournament tournament;
|
||||||
|
|
||||||
private ScheduledFuture<?> futureTimeout;
|
private ScheduledFuture<?> futureTimeout;
|
||||||
protected static final ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor();
|
protected static final ScheduledExecutorService timeoutExecutor = ThreadExecutor.instance.getTimeoutExecutor();
|
||||||
|
|
||||||
public TableController(UUID roomId, UUID userId, MatchOptions options) {
|
public TableController(UUID roomId, UUID userId, MatchOptions options) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
match = GameFactory.getInstance().createMatch(options.getGameType(), options);
|
match = GameFactory.instance.createMatch(options.getGameType(), options);
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
// TODO: Handle if user == null
|
// TODO: Handle if user == null
|
||||||
|
|
@ -100,14 +101,14 @@ public class TableController {
|
||||||
} else {
|
} else {
|
||||||
controllerName = "System";
|
controllerName = "System";
|
||||||
}
|
}
|
||||||
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), TableRecorderImpl.getInstance(), match, options.getBannedUsers());
|
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, match, options.getBannedUsers());
|
||||||
chatId = ChatManager.instance.createChatSession("Match Table " + table.getId());
|
chatId = ChatManager.instance.createChatSession("Match Table " + table.getId());
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableController(UUID roomId, UUID userId, TournamentOptions options) {
|
public TableController(UUID roomId, UUID userId, TournamentOptions options) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
tournament = TournamentFactory.getInstance().createTournament(options.getTournamentType(), options);
|
tournament = TournamentFactory.instance.createTournament(options.getTournamentType(), options);
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (!user.isPresent()) {
|
if (!user.isPresent()) {
|
||||||
|
|
@ -119,7 +120,7 @@ public class TableController {
|
||||||
} else {
|
} else {
|
||||||
controllerName = "System";
|
controllerName = "System";
|
||||||
}
|
}
|
||||||
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), TableRecorderImpl.getInstance(), tournament, options.getMatchOptions().getBannedUsers());
|
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, tournament, options.getMatchOptions().getBannedUsers());
|
||||||
chatId = ChatManager.instance.createChatSession("Tourn. table " + table.getId());
|
chatId = ChatManager.instance.createChatSession("Tourn. table " + table.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +140,7 @@ public class TableController {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean joinTournament(UUID userId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException {
|
public synchronized boolean joinTournament(UUID userId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws GameException {
|
||||||
if (table.getState() != TableState.WAITING) {
|
if (table.getState() != TableState.WAITING) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -155,13 +156,13 @@ public class TableController {
|
||||||
}
|
}
|
||||||
User user = _user.get();
|
User user = _user.get();
|
||||||
// check password
|
// check password
|
||||||
if (!table.getTournament().getOptions().getPassword().isEmpty() && playerType.equals("Human")) {
|
if (!table.getTournament().getOptions().getPassword().isEmpty() && playerType == PlayerType.HUMAN) {
|
||||||
if (!table.getTournament().getOptions().getPassword().equals(password)) {
|
if (!table.getTournament().getOptions().getPassword().equals(password)) {
|
||||||
user.showUserMessage("Join Table", "Wrong password.");
|
user.showUserMessage("Join Table", "Wrong password.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")) {
|
if (userPlayerMap.containsKey(userId) && playerType == PlayerType.HUMAN) {
|
||||||
user.showUserMessage("Join Table", "You can join a table only one time.");
|
user.showUserMessage("Join Table", "You can join a table only one time.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -228,7 +229,7 @@ public class TableController {
|
||||||
return userPlayerMap.containsKey(userId);
|
return userPlayerMap.containsKey(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean replaceDraftPlayer(Player oldPlayer, String name, String playerType, int skill) {
|
public synchronized boolean replaceDraftPlayer(Player oldPlayer, String name, PlayerType playerType, int skill) {
|
||||||
Optional<Player> newPlayerOpt = createPlayer(name, playerType, skill);
|
Optional<Player> newPlayerOpt = createPlayer(name, playerType, skill);
|
||||||
if (!newPlayerOpt.isPresent() || table.getState() != TableState.DRAFTING) {
|
if (!newPlayerOpt.isPresent() || table.getState() != TableState.DRAFTING) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -246,13 +247,13 @@ public class TableController {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean joinTable(UUID userId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
public synchronized boolean joinTable(UUID userId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
||||||
Optional<User> _user = UserManager.instance.getUser(userId);
|
Optional<User> _user = UserManager.instance.getUser(userId);
|
||||||
if (!_user.isPresent()) {
|
if (!_user.isPresent()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
User user = _user.get();
|
User user = _user.get();
|
||||||
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")) {
|
if (userPlayerMap.containsKey(userId) && playerType == PlayerType.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;
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +262,7 @@ public class TableController {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check password
|
// check password
|
||||||
if (!table.getMatch().getOptions().getPassword().isEmpty() && playerType.equals("Human")) {
|
if (!table.getMatch().getOptions().getPassword().isEmpty() && playerType == PlayerType.HUMAN) {
|
||||||
if (!table.getMatch().getOptions().getPassword().equals(password)) {
|
if (!table.getMatch().getOptions().getPassword().equals(password)) {
|
||||||
user.showUserMessage("Join Table", "Wrong password.");
|
user.showUserMessage("Join Table", "Wrong password.");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -370,7 +371,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, PlayerType playerType, Deck deck) throws GameException {
|
||||||
if (table.getState() != TableState.WAITING) {
|
if (table.getState() != TableState.WAITING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -480,12 +481,12 @@ public class TableController {
|
||||||
// ReplayManager.instance.replayGame(table.getId(), userId);
|
// ReplayManager.instance.replayGame(table.getId(), userId);
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
private Optional<Player> createPlayer(String name, String playerType, int skill) {
|
private Optional<Player> createPlayer(String name, PlayerType playerType, int skill) {
|
||||||
Optional<Player> playerOpt;
|
Optional<Player> playerOpt;
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
playerOpt = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
|
playerOpt = PlayerFactory.instance.createPlayer(playerType, name, RangeOfInfluence.ALL, skill);
|
||||||
} else {
|
} else {
|
||||||
playerOpt = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
|
playerOpt = PlayerFactory.instance.createPlayer(playerType, name, options.getRange(), skill);
|
||||||
}
|
}
|
||||||
if (playerOpt.isPresent()) {
|
if (playerOpt.isPresent()) {
|
||||||
Player player = playerOpt.get();
|
Player player = playerOpt.get();
|
||||||
|
|
@ -876,7 +877,7 @@ public class TableController {
|
||||||
if (table.getState() == TableState.READY_TO_START) {
|
if (table.getState() == TableState.READY_TO_START) {
|
||||||
if (seatNum1 >= 0 && seatNum2 >= 0 && seatNum1 < table.getSeats().length && seatNum2 < table.getSeats().length) {
|
if (seatNum1 >= 0 && seatNum2 >= 0 && seatNum1 < table.getSeats().length && seatNum2 < table.getSeats().length) {
|
||||||
Player swapPlayer = table.getSeats()[seatNum1].getPlayer();
|
Player swapPlayer = table.getSeats()[seatNum1].getPlayer();
|
||||||
String swapType = table.getSeats()[seatNum1].getPlayerType();
|
PlayerType swapType = table.getSeats()[seatNum1].getPlayerType();
|
||||||
table.getSeats()[seatNum1].setPlayer(table.getSeats()[seatNum2].getPlayer());
|
table.getSeats()[seatNum1].setPlayer(table.getSeats()[seatNum2].getPlayer());
|
||||||
table.getSeats()[seatNum1].setPlayerType(table.getSeats()[seatNum2].getPlayerType());
|
table.getSeats()[seatNum1].setPlayerType(table.getSeats()[seatNum2].getPlayerType());
|
||||||
table.getSeats()[seatNum2].setPlayer(swapPlayer);
|
table.getSeats()[seatNum2].setPlayer(swapPlayer);
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,7 @@
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.Deck;
|
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
@ -50,13 +40,22 @@ import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
import mage.players.Player;
|
import mage.players.PlayerType;
|
||||||
import mage.server.game.GameController;
|
import mage.server.game.GameController;
|
||||||
import mage.server.game.GameManager;
|
import mage.server.game.GameManager;
|
||||||
import mage.server.game.GamesRoomManager;
|
import mage.server.game.GamesRoomManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -133,14 +132,14 @@ public enum TableManager {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
public boolean joinTable(UUID userId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
||||||
if (controllers.containsKey(tableId)) {
|
if (controllers.containsKey(tableId)) {
|
||||||
return controllers.get(tableId).joinTable(userId, name, playerType, skill, deckList, password);
|
return controllers.get(tableId).joinTable(userId, name, playerType, skill, deckList, password);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinTournament(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException {
|
public boolean joinTournament(UUID userId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws GameException {
|
||||||
if (controllers.containsKey(tableId)) {
|
if (controllers.containsKey(tableId)) {
|
||||||
return controllers.get(tableId).joinTournament(userId, name, playerType, skill, deckList, password);
|
return controllers.get(tableId).joinTournament(userId, name, playerType, skill, deckList, password);
|
||||||
}
|
}
|
||||||
|
|
@ -376,7 +375,7 @@ public enum TableManager {
|
||||||
logger.debug(chatSession.getChatId() + " " + formatter.format(chatSession.getCreateTime()) + ' ' + chatSession.getInfo() + ' ' + chatSession.getClients().values().toString());
|
logger.debug(chatSession.getChatId() + " " + formatter.format(chatSession.getCreateTime()) + ' ' + chatSession.getInfo() + ' ' + chatSession.getClients().values().toString());
|
||||||
}
|
}
|
||||||
logger.debug("------- Games: " + GameManager.instance.getNumberActiveGames() + " --------------------------------------------");
|
logger.debug("------- Games: " + GameManager.instance.getNumberActiveGames() + " --------------------------------------------");
|
||||||
logger.debug(" Active Game Worker: " + ThreadExecutor.getInstance().getActiveThreads(ThreadExecutor.getInstance().getGameExecutor()));
|
logger.debug(" Active Game Worker: " + ThreadExecutor.instance.getActiveThreads(ThreadExecutor.instance.getGameExecutor()));
|
||||||
for (Entry<UUID, GameController> entry : GameManager.instance.getGameController().entrySet()) {
|
for (Entry<UUID, GameController> entry : GameManager.instance.getGameController().entrySet()) {
|
||||||
logger.debug(entry.getKey() + entry.getValue().getPlayerNameList());
|
logger.debug(entry.getKey() + entry.getValue().getPlayerNameList());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
|
@ -38,6 +34,7 @@ import mage.game.Table;
|
||||||
import mage.game.result.ResultProtos;
|
import mage.game.result.ResultProtos;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.server.draft.DraftSession;
|
import mage.server.draft.DraftSession;
|
||||||
import mage.server.game.GameManager;
|
import mage.server.game.GameManager;
|
||||||
|
|
@ -54,6 +51,11 @@ import mage.server.util.SystemUtil;
|
||||||
import mage.view.TableClientMessage;
|
import mage.view.TableClientMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -247,52 +249,52 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccJoinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
|
public void ccJoinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
|
||||||
fireCallback(new ClientCallback("joinedTable", tableId, new TableClientMessage(roomId, tableId, isTournament)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.JOINED_TABLE, tableId, new TableClientMessage(roomId, tableId, isTournament)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccGameStarted(final UUID gameId, final UUID playerId) {
|
public void ccGameStarted(final UUID gameId, final UUID playerId) {
|
||||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.START_GAME, gameId, new TableClientMessage(gameId, playerId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
|
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
|
||||||
fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, playerId)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.START_DRAFT, draftId, new TableClientMessage(draftId, playerId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccTournamentStarted(final UUID tournamentId, final UUID playerId) {
|
public void ccTournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||||
fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.START_TOURNAMENT, tournamentId, new TableClientMessage(tournamentId, playerId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccSideboard(final Deck deck, final UUID tableId, final int time, boolean limited) {
|
public void ccSideboard(final Deck deck, final UUID tableId, final int time, boolean limited) {
|
||||||
fireCallback(new ClientCallback("sideboard", tableId, new TableClientMessage(deck, tableId, time, limited)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SIDEBOARD, tableId, new TableClientMessage(deck, tableId, time, limited)));
|
||||||
sideboarding.put(tableId, deck);
|
sideboarding.put(tableId, deck);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccConstruct(final Deck deck, final UUID tableId, final int time) {
|
public void ccConstruct(final Deck deck, final UUID tableId, final int time) {
|
||||||
fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time)));
|
fireCallback(new ClientCallback(ClientCallbackMethod.CONSTRUCT, tableId, new TableClientMessage(deck, tableId, time)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccShowTournament(final UUID tournamentId) {
|
public void ccShowTournament(final UUID tournamentId) {
|
||||||
fireCallback(new ClientCallback("showTournament", tournamentId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_TOURNAMENT, tournamentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccShowGameEndDialog(final UUID gameId) {
|
public void ccShowGameEndDialog(final UUID gameId) {
|
||||||
fireCallback(new ClientCallback("showGameEndDialog", gameId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_GAME_END_DIALOG, gameId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showUserMessage(final String titel, String message) {
|
public void showUserMessage(final String titel, String message) {
|
||||||
List<String> messageData = new LinkedList<>();
|
List<String> messageData = new LinkedList<>();
|
||||||
messageData.add(titel);
|
messageData.add(titel);
|
||||||
messageData.add(message);
|
messageData.add(message);
|
||||||
fireCallback(new ClientCallback("showUserMessage", null, messageData));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ccWatchGame(final UUID gameId) {
|
public boolean ccWatchGame(final UUID gameId) {
|
||||||
fireCallback(new ClientCallback("watchGame", gameId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.WATCHGAME, gameId));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ccReplayGame(final UUID gameId) {
|
public void ccReplayGame(final UUID gameId) {
|
||||||
fireCallback(new ClientCallback("replayGame", gameId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_GAME, gameId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayerUUID(final UUID gameId, final UUID data) {
|
public void sendPlayerUUID(final UUID gameId, final UUID data) {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public enum UserManager {
|
||||||
|
|
||||||
private final ConcurrentHashMap<UUID, User> users = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<UUID, User> users = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static final ExecutorService USER_EXECUTOR = ThreadExecutor.getInstance().getCallExecutor();
|
private static final ExecutorService USER_EXECUTOR = ThreadExecutor.instance.getCallExecutor();
|
||||||
|
|
||||||
UserManager() {
|
UserManager() {
|
||||||
expireExecutor.scheduleAtFixedRate(this::checkExpired, 60, 60, TimeUnit.SECONDS);
|
expireExecutor.scheduleAtFixedRate(this::checkExpired, 60, 60, TimeUnit.SECONDS);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package mage.server.challenge;
|
package mage.server.challenge;
|
||||||
|
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.match.Match;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.match.Match;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C U R R E N T L Y U N U S E D
|
* C U R R E N T L Y U N U S E D
|
||||||
|
|
@ -12,13 +13,9 @@ import mage.game.match.Match;
|
||||||
* Loads challenges from scenarios.
|
* Loads challenges from scenarios.
|
||||||
* Configure games by initializing starting game board.
|
* Configure games by initializing starting game board.
|
||||||
*/
|
*/
|
||||||
public class ChallengeManager {
|
public enum ChallengeManager {
|
||||||
|
|
||||||
public static final ChallengeManager instance = new ChallengeManager();
|
instance;
|
||||||
|
|
||||||
public static ChallengeManager getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void prepareChallenge(UUID playerId, Match match) {
|
public void prepareChallenge(UUID playerId, Match match) {
|
||||||
Map<Zone, String> commands = new HashMap<>();
|
Map<Zone, String> commands = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -27,30 +27,27 @@
|
||||||
*/
|
*/
|
||||||
package mage.server.draft;
|
package mage.server.draft;
|
||||||
|
|
||||||
|
import mage.cards.decks.Deck;
|
||||||
|
import mage.game.draft.DraftCube;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import mage.cards.decks.Deck;
|
|
||||||
import mage.game.draft.DraftCube;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class CubeFactory {
|
public enum CubeFactory {
|
||||||
|
|
||||||
private static final CubeFactory INSTANCE = new CubeFactory();
|
instance;
|
||||||
private static final Logger logger = Logger.getLogger(CubeFactory.class);
|
private static final Logger logger = Logger.getLogger(CubeFactory.class);
|
||||||
|
|
||||||
private final Map<String, Class> draftCubes = new LinkedHashMap<>();
|
private final Map<String, Class> draftCubes = new LinkedHashMap<>();
|
||||||
|
|
||||||
public static CubeFactory getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CubeFactory() {}
|
|
||||||
|
|
||||||
public DraftCube createDraftCube(String draftCubeName) {
|
public DraftCube createDraftCube(String draftCubeName) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,6 @@
|
||||||
|
|
||||||
package mage.server.draft;
|
package mage.server.draft;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.game.draft.Draft;
|
import mage.game.draft.Draft;
|
||||||
import mage.game.draft.DraftPlayer;
|
import mage.game.draft.DraftPlayer;
|
||||||
|
|
@ -48,6 +42,13 @@ import mage.server.util.ThreadExecutor;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -152,7 +153,7 @@ public class DraftController {
|
||||||
private synchronized void checkStart() {
|
private synchronized void checkStart() {
|
||||||
if (!draft.isStarted() && allJoined()) {
|
if (!draft.isStarted() && allJoined()) {
|
||||||
draft.setStarted();
|
draft.setStarted();
|
||||||
ThreadExecutor.getInstance().getCallExecutor().execute(this::startDraft);
|
ThreadExecutor.instance.getCallExecutor().execute(this::startDraft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,9 @@
|
||||||
|
|
||||||
package mage.server.draft;
|
package mage.server.draft;
|
||||||
|
|
||||||
import java.rmi.RemoteException;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import mage.game.draft.Draft;
|
import mage.game.draft.Draft;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
|
|
@ -46,6 +39,14 @@ import mage.view.DraftPickView;
|
||||||
import mage.view.DraftView;
|
import mage.view.DraftView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,7 +61,7 @@ public class DraftSession {
|
||||||
protected UUID markedCard;
|
protected UUID markedCard;
|
||||||
|
|
||||||
private ScheduledFuture<?> futureTimeout;
|
private ScheduledFuture<?> futureTimeout;
|
||||||
protected static final ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor();
|
protected static final ScheduledExecutorService timeoutExecutor = ThreadExecutor.instance.getTimeoutExecutor();
|
||||||
|
|
||||||
public DraftSession(Draft draft, UUID userId, UUID playerId) {
|
public DraftSession(Draft draft, UUID userId, UUID playerId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
|
@ -75,7 +76,7 @@ public class DraftSession {
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
if (futureTimeout != null && !futureTimeout.isDone()) {
|
if (futureTimeout != null && !futureTimeout.isDone()) {
|
||||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||||
user.get().fireCallback(new ClientCallback("draftInit", draft.getId(), new DraftClientMessage(getDraftPickView(remaining))));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_INIT, draft.getId(), new DraftClientMessage(getDraftPickView(remaining))));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +89,7 @@ public class DraftSession {
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId).
|
.getUser(userId).
|
||||||
ifPresent(user -> user.fireCallback(
|
ifPresent(user -> user.fireCallback(
|
||||||
new ClientCallback("draftUpdate", draft.getId(), getDraftView())));
|
new ClientCallback(ClientCallbackMethod.DRAFT_UPDATE, draft.getId(), getDraftView())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +99,7 @@ public class DraftSession {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId)
|
.getUser(userId)
|
||||||
.ifPresent(user -> user.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(getDraftView(), message))));
|
.ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_INFORM, draft.getId(), new DraftClientMessage(getDraftView(), message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +108,7 @@ public class DraftSession {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId)
|
.getUser(userId)
|
||||||
.ifPresent(user -> user.fireCallback(new ClientCallback("draftOver", draft.getId())));
|
.ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_OVER, draft.getId())));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +118,7 @@ public class DraftSession {
|
||||||
setupTimeout(timeout);
|
setupTimeout(timeout);
|
||||||
UserManager.instance
|
UserManager.instance
|
||||||
.getUser(userId)
|
.getUser(userId)
|
||||||
.ifPresent(user -> user.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(getDraftPickView(timeout)))));
|
.ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.DRAFT_PICK, draft.getId(), new DraftClientMessage(getDraftPickView(timeout)))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,27 +28,26 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
|
import mage.cards.decks.DeckValidator;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import mage.cards.decks.DeckValidator;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class DeckValidatorFactory {
|
public enum DeckValidatorFactory {
|
||||||
|
|
||||||
private static final DeckValidatorFactory INSTANCE = new DeckValidatorFactory();
|
instance;
|
||||||
private static final Logger logger = Logger.getLogger(DeckValidatorFactory.class);
|
private static final Logger logger = Logger.getLogger(DeckValidatorFactory.class);
|
||||||
|
|
||||||
private final Map<String, Class> deckTypes = new LinkedHashMap<>();
|
private final Map<String, Class> deckTypes = new LinkedHashMap<>();
|
||||||
|
|
||||||
public static DeckValidatorFactory getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DeckValidatorFactory() {}
|
private DeckValidatorFactory() {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,23 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectOutput;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.zip.GZIPOutputStream;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
|
@ -66,37 +49,35 @@ import mage.game.events.TableEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.interfaces.Action;
|
import mage.interfaces.Action;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.server.ChatManager;
|
import mage.server.*;
|
||||||
import mage.server.Main;
|
|
||||||
import mage.server.TableManager;
|
|
||||||
import mage.server.User;
|
|
||||||
import mage.server.UserManager;
|
|
||||||
import mage.server.util.ConfigSettings;
|
import mage.server.util.ConfigSettings;
|
||||||
import mage.server.util.Splitter;
|
import mage.server.util.Splitter;
|
||||||
import mage.server.util.SystemUtil;
|
import mage.server.util.SystemUtil;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
import mage.utils.timer.PriorityTimer;
|
import mage.utils.timer.PriorityTimer;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.*;
|
||||||
import mage.view.CardsView;
|
|
||||||
import mage.view.ChatMessage;
|
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
import mage.view.GameView;
|
|
||||||
import mage.view.PermanentView;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class GameController implements GameCallback {
|
public class GameController implements GameCallback {
|
||||||
|
|
||||||
private static final ExecutorService gameExecutor = ThreadExecutor.getInstance().getGameExecutor();
|
private static final ExecutorService gameExecutor = ThreadExecutor.instance.getGameExecutor();
|
||||||
private static final Logger logger = Logger.getLogger(GameController.class);
|
private static final Logger logger = Logger.getLogger(GameController.class);
|
||||||
|
|
||||||
protected final ScheduledExecutorService joinWaitingExecutor = Executors.newSingleThreadScheduledExecutor();
|
protected final ScheduledExecutorService joinWaitingExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
|
||||||
private ScheduledFuture<?> futureTimeout;
|
private ScheduledFuture<?> futureTimeout;
|
||||||
protected static final ScheduledExecutorService timeoutIdleExecutor = ThreadExecutor.getInstance().getTimeoutIdleExecutor();
|
protected static final ScheduledExecutorService timeoutIdleExecutor = ThreadExecutor.instance.getTimeoutIdleExecutor();
|
||||||
|
|
||||||
private final ConcurrentHashMap<UUID, GameSessionPlayer> gameSessions = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<UUID, GameSessionPlayer> gameSessions = new ConcurrentHashMap<>();
|
||||||
private final ConcurrentHashMap<UUID, GameSessionWatcher> watchers = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<UUID, GameSessionWatcher> watchers = new ConcurrentHashMap<>();
|
||||||
|
|
@ -388,7 +369,7 @@ public class GameController implements GameCallback {
|
||||||
private void checkStart() {
|
private void checkStart() {
|
||||||
if (allJoined()) {
|
if (allJoined()) {
|
||||||
joinWaitingExecutor.shutdownNow();
|
joinWaitingExecutor.shutdownNow();
|
||||||
ThreadExecutor.getInstance().getCallExecutor().execute(this::startGame);
|
ThreadExecutor.instance.getCallExecutor().execute(this::startGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,24 +28,25 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import mage.game.match.Match;
|
import mage.game.match.Match;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.match.MatchType;
|
import mage.game.match.MatchType;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class GameFactory {
|
public enum GameFactory {
|
||||||
|
|
||||||
private static final GameFactory INSTANCE = new GameFactory();
|
instance;
|
||||||
private static final Logger logger = Logger.getLogger(GameFactory.class);
|
private static final Logger logger = Logger.getLogger(GameFactory.class);
|
||||||
|
|
||||||
private final Map<String, Class<Match>> games = new HashMap<>();
|
private final Map<String, Class<Match>> games = new HashMap<>();
|
||||||
|
|
@ -53,9 +54,6 @@ public class GameFactory {
|
||||||
private final List<GameTypeView> gameTypeViews = new ArrayList<>();
|
private final List<GameTypeView> gameTypeViews = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
public static GameFactory getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private GameFactory() {}
|
private GameFactory() {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
|
|
@ -38,6 +34,7 @@ import mage.constants.PlayerAction;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
|
|
@ -45,6 +42,11 @@ import mage.server.util.ThreadExecutor;
|
||||||
import mage.view.*;
|
import mage.view.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -54,7 +56,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
|
|
||||||
private final UUID playerId;
|
private final UUID playerId;
|
||||||
|
|
||||||
private static final ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor();
|
private static final ExecutorService callExecutor = ThreadExecutor.instance.getCallExecutor();
|
||||||
|
|
||||||
public GameSessionPlayer(Game game, UUID userId, UUID playerId) {
|
public GameSessionPlayer(Game game, UUID userId, UUID playerId) {
|
||||||
super(userId, game, true);
|
super(userId, game, true);
|
||||||
|
|
@ -68,7 +70,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
|
|
||||||
public void ask(final String question, final Map<String, Serializable> options) {
|
public void ask(final String question, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(getGameView(), question, options)))
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET, game.getId(), new GameClientMessage(getGameView(), question, options)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +78,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void target(final String question, final CardsView cardView, final Set<UUID> targets, final boolean required, final Map<String, Serializable> options) {
|
public void target(final String question, final CardsView cardView, final Set<UUID> targets, final boolean required, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
user.fireCallback(new ClientCallback("gameTarget", game.getId(), new GameClientMessage(getGameView(), question, cardView, targets, required, options)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET, game.getId(), new GameClientMessage(getGameView(), question, cardView, targets, required, options)));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -84,14 +86,14 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
|
|
||||||
public void select(final String message, final Map<String, Serializable> options) {
|
public void select(final String message, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(getGameView(), message, options))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_SELECT, game.getId(), new GameClientMessage(getGameView(), message, options))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chooseAbility(final AbilityPickerView abilities) {
|
public void chooseAbility(final AbilityPickerView abilities) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities)));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_ABILITY, game.getId(), abilities)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +101,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void choosePile(final String message, final CardsView pile1, final CardsView pile2) {
|
public void choosePile(final String message, final CardsView pile1, final CardsView pile2) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gameChoosePile", game.getId(), new GameClientMessage(message, pile1, pile2))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_PILE, game.getId(), new GameClientMessage(message, pile1, pile2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +109,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void chooseChoice(final Choice choice) {
|
public void chooseChoice(final Choice choice) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gameChooseChoice", game.getId(), new GameClientMessage(choice))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_CHOOSE_CHOICE, game.getId(), new GameClientMessage(choice))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -115,14 +117,14 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void playMana(final String message, final Map<String, Serializable> options) {
|
public void playMana(final String message, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(getGameView(), message, options))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_MANA, game.getId(), new GameClientMessage(getGameView(), message, options))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playXMana(final String message) {
|
public void playXMana(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user
|
||||||
-> user.fireCallback(new ClientCallback("gamePlayXMana", game.getId(), new GameClientMessage(getGameView(), message))));
|
-> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_PLAY_XMANA, game.getId(), new GameClientMessage(getGameView(), message))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -130,14 +132,14 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
public void getAmount(final String message, final int min, final int max) {
|
public void getAmount(final String message, final int min, final int max) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
user.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_GET_AMOUNT, game.getId(), new GameClientMessage(message, min, max)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endGameInfo(Table table) {
|
public void endGameInfo(Table table) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("endGameInfo", game.getId(), getGameEndView(playerId, table))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.END_GAME_INFO, game.getId(), getGameEndView(playerId, table))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +166,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
userRequestMessage.setGameId(game.getId());
|
userRequestMessage.setGameId(game.getId());
|
||||||
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_ROLLBACK_TURN);
|
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_ROLLBACK_TURN);
|
||||||
userRequestMessage.setButton2("Deny", PlayerAction.DENY_PERMISSON_TO_ROLLBACK_TURN);
|
userRequestMessage.setButton2("Deny", PlayerAction.DENY_PERMISSON_TO_ROLLBACK_TURN);
|
||||||
requestedUser.get().fireCallback(new ClientCallback("userRequestDialog", game.getId(), userRequestMessage));
|
requestedUser.get().fireCallback(new ClientCallback(ClientCallbackMethod.USER_REQUEST_DIALOG, game.getId(), userRequestMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +184,7 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
userRequestMessage.setGameId(game.getId());
|
userRequestMessage.setGameId(game.getId());
|
||||||
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_SEE_HAND_CARDS);
|
userRequestMessage.setButton1("Accept", PlayerAction.ADD_PERMISSION_TO_SEE_HAND_CARDS);
|
||||||
userRequestMessage.setButton2("Reject", null);
|
userRequestMessage.setButton2("Reject", null);
|
||||||
user.get().fireCallback(new ClientCallback("userRequestDialog", game.getId(), userRequestMessage));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.USER_REQUEST_DIALOG, game.getId(), userRequestMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,10 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
|
|
@ -45,6 +41,11 @@ import mage.view.GameView;
|
||||||
import mage.view.SimpleCardsView;
|
import mage.view.SimpleCardsView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -67,7 +68,7 @@ public class GameSessionWatcher {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
user.get().fireCallback(new ClientCallback("gameInit", game.getId(), getGameView()));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INIT, game.getId(), getGameView()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,21 +77,21 @@ public class GameSessionWatcher {
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameUpdate", game.getId(), getGameView())));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_UPDATE, game.getId(), getGameView())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inform(final String message) {
|
public void inform(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameInform", game.getId(), new GameClientMessage(getGameView(), message))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM, game.getId(), new GameClientMessage(getGameView(), message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void informPersonal(final String message) {
|
public void informPersonal(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameInformPersonal", game.getId(), new GameClientMessage(getGameView(), message))));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_INFORM_PERSONAL, game.getId(), new GameClientMessage(getGameView(), message))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +100,7 @@ public class GameSessionWatcher {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> {
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
user.removeGameWatchInfo(game.getId());
|
user.removeGameWatchInfo(game.getId());
|
||||||
user.fireCallback(new ClientCallback("gameOver", game.getId(), message));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_OVER, game.getId(), message));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +114,7 @@ public class GameSessionWatcher {
|
||||||
|
|
||||||
public void gameError(final String message) {
|
public void gameError(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback("gameError", game.getId(), message)));
|
UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ERROR, game.getId(), message)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,19 +28,21 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
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.PlayerType;
|
||||||
import mage.server.Room;
|
import mage.server.Room;
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
import mage.view.RoomUsersView;
|
import mage.view.RoomUsersView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -50,8 +52,8 @@ public interface GamesRoom extends Room {
|
||||||
List<TableView> getTables();
|
List<TableView> getTables();
|
||||||
List<MatchView> getFinished();
|
List<MatchView> getFinished();
|
||||||
List<RoomUsersView> getRoomUsersInfo();
|
List<RoomUsersView> getRoomUsersInfo();
|
||||||
boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException;
|
boolean joinTable(UUID userId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException;
|
||||||
boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException;
|
boolean joinTournamentTable(UUID userId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws GameException;
|
||||||
TableView createTable(UUID userId, MatchOptions options);
|
TableView createTable(UUID userId, MatchOptions options);
|
||||||
TableView createTournamentTable(UUID userId, TournamentOptions options);
|
TableView createTournamentTable(UUID userId, TournamentOptions options);
|
||||||
void removeTable(UUID userId, UUID tableId);
|
void removeTable(UUID userId, UUID tableId);
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
|
@ -41,6 +34,7 @@ import mage.game.GameException;
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import mage.server.RoomImpl;
|
import mage.server.RoomImpl;
|
||||||
import mage.server.TableManager;
|
import mage.server.TableManager;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
|
|
@ -54,6 +48,13 @@ import mage.view.TableView;
|
||||||
import mage.view.UsersView;
|
import mage.view.UsersView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -133,7 +134,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
List<RoomUsersView> roomUserInfo = new ArrayList<>();
|
List<RoomUsersView> roomUserInfo = new ArrayList<>();
|
||||||
roomUserInfo.add(new RoomUsersView(users,
|
roomUserInfo.add(new RoomUsersView(users,
|
||||||
GameManager.instance.getNumberActiveGames(),
|
GameManager.instance.getNumberActiveGames(),
|
||||||
ThreadExecutor.getInstance().getActiveThreads(ThreadExecutor.getInstance().getGameExecutor()),
|
ThreadExecutor.instance.getActiveThreads(ThreadExecutor.instance.getGameExecutor()),
|
||||||
ConfigSettings.instance.getMaxGameThreads()
|
ConfigSettings.instance.getMaxGameThreads()
|
||||||
));
|
));
|
||||||
roomUsersView = roomUserInfo;
|
roomUsersView = roomUserInfo;
|
||||||
|
|
@ -145,7 +146,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
public boolean joinTable(UUID userId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException {
|
||||||
if (tables.containsKey(tableId)) {
|
if (tables.containsKey(tableId)) {
|
||||||
return TableManager.instance.joinTable(userId, tableId, name, playerType, skill, deckList, password);
|
return TableManager.instance.joinTable(userId, tableId, name, playerType, skill, deckList, password);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -161,7 +162,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException {
|
public boolean joinTournamentTable(UUID userId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws GameException {
|
||||||
if (tables.containsKey(tableId)) {
|
if (tables.containsKey(tableId)) {
|
||||||
return TableManager.instance.joinTournament(userId, tableId, name, playerType, skill, deckList, password);
|
return TableManager.instance.joinTournament(userId, tableId, name, playerType, skill, deckList, password);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -30,32 +30,26 @@ package mage.server.game;
|
||||||
|
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.players.PlayerType;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class PlayerFactory {
|
public enum PlayerFactory {
|
||||||
|
|
||||||
private static final PlayerFactory INSTANCE = new PlayerFactory();
|
instance;
|
||||||
private static final Logger logger = Logger.getLogger(PlayerFactory.class);
|
private static final Logger logger = Logger.getLogger(PlayerFactory.class);
|
||||||
|
|
||||||
private final Map<String, Class> playerTypes = new LinkedHashMap<>();
|
private final EnumMap<PlayerType, Class> playerTypes = new EnumMap<>(PlayerType.class);
|
||||||
|
|
||||||
public static PlayerFactory getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlayerFactory() {}
|
public Optional<Player> createPlayer(PlayerType playerType, String name, RangeOfInfluence range, int skill) {
|
||||||
|
|
||||||
public Optional<Player> createPlayer(String playerType, String name, RangeOfInfluence range, int skill) {
|
|
||||||
try {
|
try {
|
||||||
Class playerTypeClass = playerTypes.get(playerType);
|
Class playerTypeClass = playerTypes.get(playerType);
|
||||||
if (playerTypeClass != null) {
|
if (playerTypeClass != null) {
|
||||||
|
|
@ -63,8 +57,7 @@ public class PlayerFactory {
|
||||||
Player player = (Player) con.newInstance(name, range, skill);
|
Player player = (Player) con.newInstance(name, range, skill);
|
||||||
logger.trace("Player created: " + name + " - " + player.getId());
|
logger.trace("Player created: " + name + " - " + player.getId());
|
||||||
return Optional.of(player);
|
return Optional.of(player);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
logger.fatal("Unknown player type: " + playerType);
|
logger.fatal("Unknown player type: " + playerType);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -73,13 +66,16 @@ public class PlayerFactory {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPlayerTypes() {
|
public Set<PlayerType> getPlayerTypes() {
|
||||||
return playerTypes.keySet();
|
return playerTypes.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerType(String name, Class playerType) {
|
public void addPlayerType(String name, Class playerType) {
|
||||||
|
PlayerType type = PlayerType.getByDescription(name);
|
||||||
|
if (type != null) {
|
||||||
if (playerType != null) {
|
if (playerType != null) {
|
||||||
this.playerTypes.put(name, playerType);
|
this.playerTypes.put(type, playerType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.GameState;
|
import mage.game.GameState;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
import mage.view.GameView;
|
import mage.view.GameView;
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ public class ReplaySession implements GameCallback {
|
||||||
public void replay() {
|
public void replay() {
|
||||||
replay.start();
|
replay.start();
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame(), null, null))));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_INIT, replay.getGame().getId(), new GameView(replay.next(), replay.getGame(), null, null))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +79,7 @@ public class ReplaySession implements GameCallback {
|
||||||
@Override
|
@Override
|
||||||
public void gameResult(final String result) {
|
public void gameResult(final String result) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_DONE, replay.getGame().getId(), result)));
|
||||||
|
|
||||||
ReplayManager.instance.endReplay(replay.getGame().getId(), userId);
|
ReplayManager.instance.endReplay(replay.getGame().getId(), userId);
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +89,7 @@ public class ReplaySession implements GameCallback {
|
||||||
gameResult("game ended");
|
gameResult("game ended");
|
||||||
} else {
|
} else {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game, null, null))));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_UPDATE, replay.getGame().getId(), new GameView(state, game, null, null))));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,9 @@ import mage.game.Table.TableRecorder;
|
||||||
import mage.game.result.ResultProtos.TableProto;
|
import mage.game.result.ResultProtos.TableProto;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
|
|
||||||
public class TableRecorderImpl implements TableRecorder {
|
public enum TableRecorderImpl implements TableRecorder {
|
||||||
|
|
||||||
private final static TableRecorderImpl INSTANCE = new TableRecorderImpl();
|
instance;
|
||||||
|
|
||||||
public static TableRecorderImpl getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(Table table) {
|
public void record(Table table) {
|
||||||
|
|
|
||||||
|
|
@ -37,17 +37,19 @@ import mage.game.draft.Draft;
|
||||||
import mage.game.events.Listener;
|
import mage.game.events.Listener;
|
||||||
import mage.game.events.PlayerQueryEvent;
|
import mage.game.events.PlayerQueryEvent;
|
||||||
import mage.game.events.TableEvent;
|
import mage.game.events.TableEvent;
|
||||||
import mage.game.match.Match;
|
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.result.ResultProtos.TourneyQuitStatus;
|
import mage.game.result.ResultProtos.TourneyQuitStatus;
|
||||||
import mage.game.tournament.MultiplayerRound;
|
import mage.game.tournament.MultiplayerRound;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
import mage.game.tournament.TournamentPairing;
|
import mage.game.tournament.TournamentPairing;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
import mage.server.*;
|
import mage.players.PlayerType;
|
||||||
|
import mage.server.ChatManager;
|
||||||
|
import mage.server.TableManager;
|
||||||
|
import mage.server.User;
|
||||||
|
import mage.server.UserManager;
|
||||||
import mage.server.draft.DraftController;
|
import mage.server.draft.DraftController;
|
||||||
import mage.server.draft.DraftManager;
|
import mage.server.draft.DraftManager;
|
||||||
import mage.server.draft.DraftSession;
|
|
||||||
import mage.server.game.GamesRoomManager;
|
import mage.server.game.GamesRoomManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
|
|
@ -198,7 +200,7 @@ public class TournamentController {
|
||||||
|
|
||||||
private void checkStart() {
|
private void checkStart() {
|
||||||
if (!started && allJoined()) {
|
if (!started && allJoined()) {
|
||||||
ThreadExecutor.getInstance().getCallExecutor().execute(this::startTournament);
|
ThreadExecutor.instance.getCallExecutor().execute(this::startTournament);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,7 +436,7 @@ public class TournamentController {
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
replacePlayerName = "Draftbot (" + user.get().getName() + ')';
|
replacePlayerName = "Draftbot (" + user.get().getName() + ')';
|
||||||
}
|
}
|
||||||
tableController.replaceDraftPlayer(leavingPlayer.getPlayer(), replacePlayerName, "Computer - draftbot", 5);
|
tableController.replaceDraftPlayer(leavingPlayer.getPlayer(), replacePlayerName, PlayerType.COMPUTER_DRAFT_BOT, 5);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
user.get().removeDraft(leavingPlayer.getPlayer().getId());
|
user.get().removeDraft(leavingPlayer.getPlayer().getId());
|
||||||
user.get().removeTable(leavingPlayer.getPlayer().getId());
|
user.get().removeTable(leavingPlayer.getPlayer().getId());
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,6 @@
|
||||||
|
|
||||||
package mage.server.tournament;
|
package mage.server.tournament;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import mage.cards.Sets;
|
import mage.cards.Sets;
|
||||||
import mage.game.draft.DraftCube;
|
import mage.game.draft.DraftCube;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
|
|
@ -43,23 +37,22 @@ import mage.server.draft.CubeFactory;
|
||||||
import mage.view.TournamentTypeView;
|
import mage.view.TournamentTypeView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class TournamentFactory {
|
public enum TournamentFactory {
|
||||||
private static final TournamentFactory INSTANCE = new TournamentFactory();
|
instance;
|
||||||
private static final Logger logger = Logger.getLogger(TournamentFactory.class);
|
private static final Logger logger = Logger.getLogger(TournamentFactory.class);
|
||||||
|
|
||||||
private final Map<String, Class<Tournament>> tournaments = new HashMap<>();
|
private final Map<String, Class<Tournament>> tournaments = new HashMap<>();
|
||||||
private final Map<String, TournamentType> tournamentTypes = new HashMap<>();
|
private final Map<String, TournamentType> tournamentTypes = new HashMap<>();
|
||||||
private final List<TournamentTypeView> tournamentTypeViews = new ArrayList<>();
|
private final List<TournamentTypeView> tournamentTypeViews = new ArrayList<>();
|
||||||
|
|
||||||
public static TournamentFactory getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TournamentFactory() {}
|
|
||||||
|
|
||||||
public Tournament createTournament(String tournamentType, TournamentOptions options) {
|
public Tournament createTournament(String tournamentType, TournamentOptions options) {
|
||||||
|
|
||||||
|
|
@ -81,9 +74,9 @@ public class TournamentFactory {
|
||||||
DraftCube draftCube;
|
DraftCube draftCube;
|
||||||
|
|
||||||
if (tournament.getOptions().getLimitedOptions().getCubeFromDeck() != null) {
|
if (tournament.getOptions().getLimitedOptions().getCubeFromDeck() != null) {
|
||||||
draftCube = CubeFactory.getInstance().createDeckDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName(), tournament.getOptions().getLimitedOptions().getCubeFromDeck());
|
draftCube = CubeFactory.instance.createDeckDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName(), tournament.getOptions().getLimitedOptions().getCubeFromDeck());
|
||||||
} else {
|
} else {
|
||||||
draftCube = CubeFactory.getInstance().createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName());
|
draftCube = CubeFactory.instance.createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName());
|
||||||
}
|
}
|
||||||
tournament.getOptions().getLimitedOptions().setDraftCube(draftCube);
|
tournament.getOptions().getLimitedOptions().setDraftCube(draftCube);
|
||||||
tournament.setBoosterInfo(tournament.getOptions().getLimitedOptions().getDraftCubeName());
|
tournament.setBoosterInfo(tournament.getOptions().getLimitedOptions().getDraftCubeName());
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ package mage.server.tournament;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
|
|
@ -56,7 +57,7 @@ public class TournamentSession {
|
||||||
protected boolean killed = false;
|
protected boolean killed = false;
|
||||||
|
|
||||||
private ScheduledFuture<?> futureTimeout;
|
private ScheduledFuture<?> futureTimeout;
|
||||||
protected static final ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor();
|
protected static final ScheduledExecutorService timeoutExecutor = ThreadExecutor.instance.getTimeoutExecutor();
|
||||||
|
|
||||||
public TournamentSession(Tournament tournament, UUID userId, UUID tableId, UUID playerId) {
|
public TournamentSession(Tournament tournament, UUID userId, UUID tableId, UUID playerId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
|
@ -69,7 +70,7 @@ public class TournamentSession {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
Optional<User> user = UserManager.instance.getUser(userId);
|
Optional<User> user = UserManager.instance.getUser(userId);
|
||||||
if (user.isPresent()) {
|
if (user.isPresent()) {
|
||||||
user.get().fireCallback(new ClientCallback("tournamentInit", tournament.getId(), getTournamentView()));
|
user.get().fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_INIT, tournament.getId(), getTournamentView()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +80,7 @@ public class TournamentSession {
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("tournamentUpdate", tournament.getId(), getTournamentView())));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_UPDATE, tournament.getId(), getTournamentView())));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +88,7 @@ public class TournamentSession {
|
||||||
public void gameOver(final String message) {
|
public void gameOver(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user ->
|
UserManager.instance.getUser(userId).ifPresent(user ->
|
||||||
user.fireCallback(new ClientCallback("tournamentOver", tournament.getId(), message)));
|
user.fireCallback(new ClientCallback(ClientCallbackMethod.TOURNAMENT_OVER, tournament.getId(), message)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ import java.util.concurrent.TimeUnit;
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ThreadExecutor {
|
public enum ThreadExecutor {
|
||||||
|
instance;
|
||||||
private static final ExecutorService callExecutor = Executors.newCachedThreadPool();
|
private static final ExecutorService callExecutor = Executors.newCachedThreadPool();
|
||||||
private static final ExecutorService userExecutor = Executors.newCachedThreadPool();
|
private static final ExecutorService userExecutor = Executors.newCachedThreadPool();
|
||||||
private static final ExecutorService gameExecutor = Executors.newFixedThreadPool(ConfigSettings.instance.getMaxGameThreads());
|
private static final ExecutorService gameExecutor = Executors.newFixedThreadPool(ConfigSettings.instance.getMaxGameThreads());
|
||||||
|
|
@ -74,14 +74,6 @@ public class ThreadExecutor {
|
||||||
((ThreadPoolExecutor) timeoutIdleExecutor).setThreadFactory(new XMageThreadFactory("TIMEOUT_IDLE"));
|
((ThreadPoolExecutor) timeoutIdleExecutor).setThreadFactory(new XMageThreadFactory("TIMEOUT_IDLE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ThreadExecutor INSTANCE = new ThreadExecutor();
|
|
||||||
|
|
||||||
public static ThreadExecutor getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ThreadExecutor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getActiveThreads(ExecutorService executerService) {
|
public int getActiveThreads(ExecutorService executerService) {
|
||||||
if (executerService instanceof ThreadPoolExecutor) {
|
if (executerService instanceof ThreadPoolExecutor) {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -110,8 +111,8 @@ class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
|
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
|
||||||
Ability ability = game.getAbility(event.getTargetId(), event.getSourceId());
|
Optional<Ability> ability = game.getAbility(event.getTargetId(), event.getSourceId());
|
||||||
if (ability != null && !(ability instanceof ActivatedManaAbilityImpl)) {
|
if (ability.isPresent() && !(ability.get() instanceof ActivatedManaAbilityImpl)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
import mage.util.CardUtil;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -92,7 +91,7 @@ class AlphaStatusDynamicValue implements DynamicValue {
|
||||||
if (enchanted != null) {
|
if (enchanted != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game)) {
|
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game)) {
|
||||||
if (!permanent.getId().equals(enchanted.getId())) {
|
if (!permanent.getId().equals(enchanted.getId())) {
|
||||||
if (CardUtil.shareSubtypes(enchanted, permanent, game)) {
|
if (enchanted.shareSubtypes(permanent, game)) {
|
||||||
xValue += 2;
|
xValue += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
71
Mage.Sets/src/mage/cards/a/AnglerDrake.java
Normal file
71
Mage.Sets/src/mage/cards/a/AnglerDrake.java
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.a;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
||||||
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class AnglerDrake extends CardImpl {
|
||||||
|
|
||||||
|
public AnglerDrake(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}{U}");
|
||||||
|
|
||||||
|
this.subtype.add("Drake");
|
||||||
|
this.power = new MageInt(4);
|
||||||
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
|
// Flying
|
||||||
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
|
// When Angler Drake enters the battlefield, you may return target creature to its owner's hand.
|
||||||
|
Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), true);
|
||||||
|
ability.addTarget(new TargetCreaturePermanent());
|
||||||
|
this.addAbility(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnglerDrake(final AnglerDrake card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnglerDrake copy() {
|
||||||
|
return new AnglerDrake(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
78
Mage.Sets/src/mage/cards/a/AnointerPriest.java
Normal file
78
Mage.Sets/src/mage/cards/a/AnointerPriest.java
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.a;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.common.GainLifeEffect;
|
||||||
|
import mage.abilities.keyword.EmbalmAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.filter.FilterPermanent;
|
||||||
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.permanent.TokenPredicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class AnointerPriest extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterPermanent filter = new FilterCreaturePermanent("a creature token");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(new TokenPredicate());
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnointerPriest(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
|
||||||
|
|
||||||
|
this.subtype.add("Human");
|
||||||
|
this.subtype.add("Cleric");
|
||||||
|
this.power = new MageInt(1);
|
||||||
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
|
// Whenever a creature token enters the battlefield under your control, you gain 1 life.
|
||||||
|
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(new GainLifeEffect(1), filter));
|
||||||
|
|
||||||
|
// Embalm {3}{W}
|
||||||
|
this.addAbility(new EmbalmAbility(new ManaCostsImpl("{3}{W}"), this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnointerPriest(final AnointerPriest card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnointerPriest copy() {
|
||||||
|
return new AnointerPriest(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
114
Mage.Sets/src/mage/cards/a/ArchfiendOfIfnir.java
Normal file
114
Mage.Sets/src/mage/cards/a/ArchfiendOfIfnir.java
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.a;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.common.counter.AddCountersAllEffect;
|
||||||
|
import mage.abilities.keyword.CyclingAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import mage.filter.common.FilterOpponentsCreaturePermanent;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class ArchfiendOfIfnir extends CardImpl {
|
||||||
|
|
||||||
|
public ArchfiendOfIfnir(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{B}");
|
||||||
|
|
||||||
|
this.subtype.add("Demon");
|
||||||
|
this.power = new MageInt(5);
|
||||||
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
|
// Flying
|
||||||
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
|
// Whenever you cycle or discard another card, put a -1/-1 counter on each creature your opponents control.
|
||||||
|
this.addAbility(new ArchfiendOfIfnirTriggeredAbility(new AddCountersAllEffect(CounterType.M1M1.createInstance(1),
|
||||||
|
new FilterOpponentsCreaturePermanent("creature your opponents control"))));
|
||||||
|
|
||||||
|
// Cycling {2}
|
||||||
|
this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArchfiendOfIfnir(final ArchfiendOfIfnir card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArchfiendOfIfnir copy() {
|
||||||
|
return new ArchfiendOfIfnir(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ArchfiendOfIfnirTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
|
ArchfiendOfIfnirTriggeredAbility(Effect effect) {
|
||||||
|
super(Zone.BATTLEFIELD, effect, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchfiendOfIfnirTriggeredAbility(final ArchfiendOfIfnirTriggeredAbility ability) {
|
||||||
|
super(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArchfiendOfIfnirTriggeredAbility copy() {
|
||||||
|
return new ArchfiendOfIfnirTriggeredAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == EventType.DISCARDED_CARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
if (getControllerId().equals(event.getPlayerId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
return "Whenever you cycle or discard another card, " + super.getRule();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards.a;
|
package mage.cards.a;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||||
|
|
@ -45,8 +47,6 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetCardInHand;
|
import mage.target.common.TargetCardInHand;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
|
|
@ -109,7 +109,8 @@ class ArsenalThresherEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
if (arsenalThresher != null) {
|
if (arsenalThresher != null) {
|
||||||
controller.revealCards(arsenalThresher.getIdName(), cards, game);
|
controller.revealCards(arsenalThresher.getIdName(), cards, game);
|
||||||
arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), source, game);
|
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
|
||||||
|
arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), source, game, appliedEffects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
90
Mage.Sets/src/mage/cards/b/BontusMonument.java
Normal file
90
Mage.Sets/src/mage/cards/b/BontusMonument.java
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.b;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.ObjectColor;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.common.GainLifeEffect;
|
||||||
|
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
|
||||||
|
import mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.SuperType;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.FilterSpell;
|
||||||
|
import mage.filter.predicate.Predicates;
|
||||||
|
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||||
|
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class BontusMonument extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterCard filter = new FilterCard("Black creature spells");
|
||||||
|
private static final FilterSpell filter2 = new FilterSpell("a creature spell");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(Predicates.and(new ColorPredicate(ObjectColor.BLACK), new CardTypePredicate(CardType.CREATURE)));
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
filter2.add(new CardTypePredicate(CardType.CREATURE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BontusMonument(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
|
||||||
|
|
||||||
|
addSuperType(SuperType.LEGENDARY);
|
||||||
|
|
||||||
|
// Black creature spells you cast cost {1} less to cast.
|
||||||
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SpellsCostReductionControllerEffect(filter, 1)));
|
||||||
|
|
||||||
|
// Whenever you cast a creature spell, each opponent loses 1 life and you gain 1 life.
|
||||||
|
Ability ability = new SpellCastControllerTriggeredAbility(new LoseLifeOpponentsEffect(1), filter2, false);
|
||||||
|
Effect effect = new GainLifeEffect(1);
|
||||||
|
effect.setText("and you gain 1 life");
|
||||||
|
ability.addEffect(effect);
|
||||||
|
this.addAbility(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BontusMonument(final BontusMonument card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BontusMonument copy() {
|
||||||
|
return new BontusMonument(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ class BoseijuWhoSheltersAllWatcher extends Watcher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
|
if (event.getType() == GameEvent.EventType.MANA_PAID) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
// TODO: Replace identification by name by better method that also works if ability is copied from other land with other name
|
// TODO: Replace identification by name by better method that also works if ability is copied from other land with other name
|
||||||
if (object != null && object.getName().equals("Boseiju, Who Shelters All") && event.getFlag()) {
|
if (object != null && object.getName().equals("Boseiju, Who Shelters All") && event.getFlag()) {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
|
@ -47,8 +48,6 @@ import mage.game.events.EntersTheBattlefieldEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author emerald000
|
* @author emerald000
|
||||||
|
|
@ -120,7 +119,7 @@ class BramblewoodParagonReplacementEffect extends ReplacementEffectImpl {
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||||
if (creature != null) {
|
if (creature != null) {
|
||||||
creature.addCounters(CounterType.P1P1.createInstance(), source, game);
|
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
141
Mage.Sets/src/mage/cards/b/BronzeBombshell.java
Normal file
141
Mage.Sets/src/mage/cards/b/BronzeBombshell.java
Normal file
|
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.b;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jeffwadsworth
|
||||||
|
*/
|
||||||
|
public class BronzeBombshell extends CardImpl {
|
||||||
|
|
||||||
|
public BronzeBombshell(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}");
|
||||||
|
|
||||||
|
this.subtype.add("Construct");
|
||||||
|
this.power = new MageInt(4);
|
||||||
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
|
// When a player other than Bronze Bombshell's owner controls it, that player sacrifices it. If the player does, Bronze Bombshell deals 7 damage to him or her.
|
||||||
|
this.addAbility(new LoseControlTriggeredAbility(new BronzeBombshellEffect(), false));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public BronzeBombshell(final BronzeBombshell card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BronzeBombshell copy() {
|
||||||
|
return new BronzeBombshell(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoseControlTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
|
public LoseControlTriggeredAbility(Effect effect, boolean optional) {
|
||||||
|
super(Zone.BATTLEFIELD, effect, optional);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoseControlTriggeredAbility(final LoseControlTriggeredAbility ability) {
|
||||||
|
super(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoseControlTriggeredAbility copy() {
|
||||||
|
return new LoseControlTriggeredAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
|
return (event.getType() == GameEvent.EventType.LOST_CONTROL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
if (event.getSourceId().equals(getSourceId())) {
|
||||||
|
Permanent sourcePermanent = game.getPermanent(event.getSourceId());
|
||||||
|
if (sourcePermanent != null) {
|
||||||
|
return !(sourcePermanent.getControllerId()).equals(sourcePermanent.getOwnerId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
return "When a player other than {this}'s owner controls it, " + super.getRule();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BronzeBombshellEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
public BronzeBombshellEffect() {
|
||||||
|
super(Outcome.Damage);
|
||||||
|
this.staticText = "that player sacrifices it. If the player does, {this} deals 7 damage to him or her.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public BronzeBombshellEffect(final BronzeBombshellEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BronzeBombshellEffect copy() {
|
||||||
|
return new BronzeBombshellEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Permanent bronzeBombshell = game.getPermanent(source.getSourceId());
|
||||||
|
if (bronzeBombshell != null) {
|
||||||
|
Player newController = game.getPlayer(bronzeBombshell.getControllerId());
|
||||||
|
if (newController != null) {
|
||||||
|
if (bronzeBombshell.sacrifice(source.getId(), game)) {//sacrificed by the new controlling player
|
||||||
|
newController.damage(7, source.getSourceId(), game, false, true);//bronze bombshell does 7 damage to the controller
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
72
Mage.Sets/src/mage/cards/c/CanyonSlough.java
Normal file
72
Mage.Sets/src/mage/cards/c/CanyonSlough.java
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTappedAbility;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.keyword.CyclingAbility;
|
||||||
|
import mage.abilities.mana.BlackManaAbility;
|
||||||
|
import mage.abilities.mana.RedManaAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class CanyonSlough extends CardImpl {
|
||||||
|
|
||||||
|
public CanyonSlough(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
|
||||||
|
|
||||||
|
this.subtype.add("Swamp");
|
||||||
|
this.subtype.add("Mountain");
|
||||||
|
|
||||||
|
// <i>({T}: Add {B} or {R} to your mana pool.)</i>
|
||||||
|
this.addAbility(new BlackManaAbility());
|
||||||
|
this.addAbility(new RedManaAbility());
|
||||||
|
|
||||||
|
// Canyon Slough enters the battlefield tapped.
|
||||||
|
this.addAbility(new EntersBattlefieldTappedAbility());
|
||||||
|
|
||||||
|
// Cycling {2}
|
||||||
|
this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CanyonSlough(final CanyonSlough card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CanyonSlough copy() {
|
||||||
|
return new CanyonSlough(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
86
Mage.Sets/src/mage/cards/c/CartoucheOfSolidarity.java
Normal file
86
Mage.Sets/src/mage/cards/c/CartoucheOfSolidarity.java
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
import mage.abilities.keyword.FirstStrikeAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.AttachmentType;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.permanent.token.WarriorVigilantToken;
|
||||||
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class CartoucheOfSolidarity extends CardImpl {
|
||||||
|
|
||||||
|
public CartoucheOfSolidarity(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||||
|
|
||||||
|
this.subtype.add("Aura");
|
||||||
|
this.subtype.add("Cartouche");
|
||||||
|
|
||||||
|
// Enchant creature you control
|
||||||
|
TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
|
||||||
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||||
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// When Cartouche of Solidarity enters the battlefield, create a 1/1 white Warrior creature token with vigilance.
|
||||||
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new WarriorVigilantToken())));
|
||||||
|
|
||||||
|
// Enchanted creature gets +1/+1 and has first strike.
|
||||||
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, 1, Duration.WhileOnBattlefield)));
|
||||||
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CartoucheOfSolidarity(final CartoucheOfSolidarity card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CartoucheOfSolidarity copy() {
|
||||||
|
return new CartoucheOfSolidarity(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
84
Mage.Sets/src/mage/cards/c/CastOut.java
Normal file
84
Mage.Sets/src/mage/cards/c/CastOut.java
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility;
|
||||||
|
import mage.abilities.keyword.FlashAbility;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||||
|
import mage.abilities.effects.common.ExileUntilSourceLeavesEffect;
|
||||||
|
import mage.abilities.keyword.CyclingAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.TargetController;
|
||||||
|
import mage.filter.common.FilterNonlandPermanent;
|
||||||
|
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class CastOut extends CardImpl {
|
||||||
|
|
||||||
|
private final static FilterNonlandPermanent filter = new FilterNonlandPermanent();
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CastOut(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}");
|
||||||
|
|
||||||
|
// Flash
|
||||||
|
this.addAbility(FlashAbility.getInstance());
|
||||||
|
|
||||||
|
// When Cast Out enters the battlefield, exile target nonland permanent an opponent controls until Cast Out leaves the battlefield.
|
||||||
|
Ability ability = new EntersBattlefieldTriggeredAbility(new ExileUntilSourceLeavesEffect(filter.getMessage()));
|
||||||
|
ability.addTarget(new TargetPermanent(filter));
|
||||||
|
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new OnLeaveReturnExiledToBattlefieldAbility()));
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// Cycling {W}
|
||||||
|
this.addAbility(new CyclingAbility(new ManaCostsImpl("{W}")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CastOut(final CastOut card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CastOut copy() {
|
||||||
|
return new CastOut(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -169,7 +169,7 @@ class CavernOfSoulsWatcher extends Watcher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
|
if (event.getType() == GameEvent.EventType.MANA_PAID) {
|
||||||
if (event.getData() != null && event.getData().equals(originalId)) {
|
if (event.getData() != null && event.getData().equals(originalId)) {
|
||||||
spells.add(event.getTargetId());
|
spells.add(event.getTargetId());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -49,8 +50,6 @@ import mage.players.ManaPoolItem;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.sets.Commander;
|
import mage.sets.Commander;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
|
@ -267,8 +266,8 @@ class CelestialDawnSpendColorlessManaEffect extends AsThoughEffectImpl implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
|
public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
|
||||||
if (mana.getWhite() == 0 && ManaType.COLORLESS != manaType) {
|
if (mana.getWhite() == 0) {
|
||||||
return null;
|
return ManaType.COLORLESS;
|
||||||
}
|
}
|
||||||
return manaType;
|
return manaType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.LoyaltyAbility;
|
import mage.abilities.LoyaltyAbility;
|
||||||
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
|
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
|
||||||
|
|
@ -54,6 +55,10 @@ import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
*/
|
*/
|
||||||
|
|
@ -203,11 +208,7 @@ class ChandraPyromasterEffect2 extends OneShotEffect {
|
||||||
Card card = library.removeFromTop(game);
|
Card card = library.removeFromTop(game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName() + " <this card may be played the turn it was exiled>", source.getSourceId(), game, Zone.LIBRARY, true);
|
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName() + " <this card may be played the turn it was exiled>", source.getSourceId(), game, Zone.LIBRARY, true);
|
||||||
if (!card.getManaCost().isEmpty()) {
|
game.addEffect(new ChandraPyromasterPlayEffect(new MageObjectReference(card, game)), source);
|
||||||
ContinuousEffect effect = new ChandraPyromasterCastFromExileEffect();
|
|
||||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
|
||||||
game.addEffect(effect, source);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -215,15 +216,19 @@ class ChandraPyromasterEffect2 extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChandraPyromasterCastFromExileEffect extends AsThoughEffectImpl {
|
class ChandraPyromasterPlayEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
public ChandraPyromasterCastFromExileEffect() {
|
private final MageObjectReference objectReference;
|
||||||
|
|
||||||
|
public ChandraPyromasterPlayEffect(MageObjectReference objectReference) {
|
||||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||||
staticText = "You may play the card from exile this turn";
|
this.objectReference = objectReference;
|
||||||
|
staticText = "you may play that card until end of turn";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChandraPyromasterCastFromExileEffect(final ChandraPyromasterCastFromExileEffect effect) {
|
public ChandraPyromasterPlayEffect(final ChandraPyromasterPlayEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
|
this.objectReference = effect.objectReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -232,14 +237,19 @@ class ChandraPyromasterCastFromExileEffect extends AsThoughEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChandraPyromasterCastFromExileEffect copy() {
|
public ChandraPyromasterPlayEffect copy() {
|
||||||
return new ChandraPyromasterCastFromExileEffect(this);
|
return new ChandraPyromasterPlayEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
if (targetPointer.getTargets(game, source).contains(sourceId)) {
|
if (objectReference.refersTo(objectId, game) && affectedControllerId.equals(source.getControllerId())) {
|
||||||
return game.getState().getZone(sourceId) == Zone.EXILED;
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
if (controller != null) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
discard();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
76
Mage.Sets/src/mage/cards/c/ChannelerInitiate.java
Normal file
76
Mage.Sets/src/mage/cards/c/ChannelerInitiate.java
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.costs.common.RemoveCountersSourceCost;
|
||||||
|
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||||
|
import mage.abilities.mana.AnyColorManaAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class ChannelerInitiate extends CardImpl {
|
||||||
|
|
||||||
|
public ChannelerInitiate(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}");
|
||||||
|
|
||||||
|
this.subtype.add("Human");
|
||||||
|
this.subtype.add("Druid");
|
||||||
|
this.power = new MageInt(3);
|
||||||
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
|
// When Channeler Initiate enters the battlefield, put three -1/-1 counters on target creature you control.
|
||||||
|
Ability ability = new EntersBattlefieldTriggeredAbility(new AddCountersTargetEffect(CounterType.M1M1.createInstance(3)));
|
||||||
|
ability.addTarget(new TargetControlledCreaturePermanent());
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// {T}, Remove a -1/-1 counter from Channeler Initiate: Add one mana of any color to your mana pool.
|
||||||
|
ability = new AnyColorManaAbility();
|
||||||
|
ability.addCost(new RemoveCountersSourceCost(CounterType.M1M1.createInstance(1)));
|
||||||
|
this.addAbility(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelerInitiate(final ChannelerInitiate card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChannelerInitiate copy() {
|
||||||
|
return new ChannelerInitiate(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
82
Mage.Sets/src/mage/cards/c/Charisma.java
Normal file
82
Mage.Sets/src/mage/cards/c/Charisma.java
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.DealsDamageToACreatureAttachedTriggeredAbility;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.abilities.condition.common.SourceOnBattlefieldCondition;
|
||||||
|
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||||
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jeffwadsworth
|
||||||
|
*/
|
||||||
|
public class Charisma extends CardImpl {
|
||||||
|
|
||||||
|
private static final String rule = "gain control of the other creature for as long as {this} remains on the battlefield";
|
||||||
|
|
||||||
|
public Charisma(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}{U}");
|
||||||
|
|
||||||
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
// Enchant creature
|
||||||
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||||
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// Whenever enchanted creature deals damage to a creature, gain control of the other creature for as long as Charisma remains on the battlefield.
|
||||||
|
Condition condition = new SourceOnBattlefieldCondition();
|
||||||
|
ConditionalContinuousEffect conditionalEffect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), condition, rule);
|
||||||
|
this.addAbility(new DealsDamageToACreatureAttachedTriggeredAbility(conditionalEffect, false, "enchanted creature", false, true));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Charisma(final Charisma card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Charisma copy() {
|
||||||
|
return new Charisma(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,9 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -45,10 +48,6 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
|
|
@ -198,7 +197,7 @@ class ChorusOfTheConclaveReplacementEffect2 extends ReplacementEffectImpl {
|
||||||
String key = event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 1);
|
String key = event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 1);
|
||||||
int xValue = spellX.get(key);
|
int xValue = spellX.get(key);
|
||||||
if (xValue > 0) {
|
if (xValue > 0) {
|
||||||
creature.addCounters(CounterType.P1P1.createInstance(xValue), source, game);
|
creature.addCounters(CounterType.P1P1.createInstance(xValue), source, game, event.getAppliedEffects());
|
||||||
game.informPlayers(sourceObject.getLogName() + ": " + creature.getLogName() + " enters the battlefield with " + xValue + " +1/+1 counter" + (xValue > 1 ? "s" : "") + " on it");
|
game.informPlayers(sourceObject.getLogName() + ": " + creature.getLogName() + " enters the battlefield with " + xValue + " +1/+1 counter" + (xValue > 1 ? "s" : "") + " on it");
|
||||||
}
|
}
|
||||||
spellX.remove(key);
|
spellX.remove(key);
|
||||||
|
|
|
||||||
|
|
@ -81,12 +81,13 @@ class ConflagrateVariableValue implements DynamicValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||||
|
int xValue = sourceAbility.getManaCostsToPay().getX();
|
||||||
for (Cost cost : sourceAbility.getCosts()) {
|
for (Cost cost : sourceAbility.getCosts()) {
|
||||||
if (cost instanceof DiscardTargetCost) {
|
if (cost instanceof DiscardTargetCost) {
|
||||||
return ((DiscardTargetCost) cost).getCards().size();
|
xValue = ((DiscardTargetCost) cost).getCards().size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sourceAbility.getManaCostsToPay().getX();
|
return xValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
87
Mage.Sets/src/mage/cards/c/ConsumingFervor.java
Normal file
87
Mage.Sets/src/mage/cards/c/ConsumingFervor.java
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
|
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.AttachmentType;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.TargetController;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class ConsumingFervor extends CardImpl {
|
||||||
|
|
||||||
|
public ConsumingFervor(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{R}");
|
||||||
|
|
||||||
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
// Enchant creature
|
||||||
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||||
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// Enchanted creature gets +3/+3 and has "At the beginning of your upkeep, put a -1/-1 counter on this creature."
|
||||||
|
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3, Duration.WhileOnBattlefield));
|
||||||
|
Ability grantedAbility = new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.M1M1.createInstance(1)), TargetController.YOU, false);
|
||||||
|
Effect effect = new GainAbilityAttachedEffect(grantedAbility, AttachmentType.AURA);
|
||||||
|
effect.setText("and has \"At the beginning of each upkeep, put a -1/-1 counter on this creature.\"");
|
||||||
|
ability.addEffect(effect);
|
||||||
|
this.addAbility(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConsumingFervor(final ConsumingFervor card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConsumingFervor copy() {
|
||||||
|
return new ConsumingFervor(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
72
Mage.Sets/src/mage/cards/c/CrocodileOfTheCrossing.java
Normal file
72
Mage.Sets/src/mage/cards/c/CrocodileOfTheCrossing.java
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||||
|
import mage.abilities.keyword.HasteAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class CrocodileOfTheCrossing extends CardImpl {
|
||||||
|
|
||||||
|
public CrocodileOfTheCrossing(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
|
||||||
|
|
||||||
|
this.subtype.add("Crocodile");
|
||||||
|
this.power = new MageInt(5);
|
||||||
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
|
// Haste
|
||||||
|
this.addAbility(HasteAbility.getInstance());
|
||||||
|
|
||||||
|
// When Crocodile of the Crossing enters the battlefield, put a -1/-1 counter on target creature you control.
|
||||||
|
Ability ability = new EntersBattlefieldTriggeredAbility(new AddCountersTargetEffect(CounterType.M1M1.createInstance(1)));
|
||||||
|
ability.addTarget(new TargetControlledCreaturePermanent());
|
||||||
|
this.addAbility(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CrocodileOfTheCrossing(final CrocodileOfTheCrossing card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CrocodileOfTheCrossing copy() {
|
||||||
|
return new CrocodileOfTheCrossing(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
64
Mage.Sets/src/mage/cards/c/CursedMinotaur.java
Normal file
64
Mage.Sets/src/mage/cards/c/CursedMinotaur.java
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.c;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.keyword.MenaceAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class CursedMinotaur extends CardImpl {
|
||||||
|
|
||||||
|
public CursedMinotaur(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
|
||||||
|
|
||||||
|
this.subtype.add("Zombie");
|
||||||
|
this.subtype.add("Minotaur");
|
||||||
|
this.power = new MageInt(3);
|
||||||
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
|
// Menace
|
||||||
|
this.addAbility(new MenaceAbility());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CursedMinotaur(final CursedMinotaur card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CursedMinotaur copy() {
|
||||||
|
return new CursedMinotaur(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -46,6 +46,7 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -108,8 +109,8 @@ class DampingMatrixEffect extends ReplacementEffectImpl {
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (object instanceof Permanent && filter.match((Permanent)object, game)) {
|
if (object instanceof Permanent && filter.match((Permanent)object, game)) {
|
||||||
Ability ability = object.getAbilities().get(event.getTargetId());
|
Optional<Ability> ability = object.getAbilities().get(event.getTargetId());
|
||||||
if (ability != null && !(ability instanceof ActivatedManaAbilityImpl)) {
|
if (ability.isPresent() && !(ability.get() instanceof ActivatedManaAbilityImpl)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
import mage.util.CardUtil;
|
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -134,9 +134,9 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
||||||
return new TargetControlledPermanentSharingOpponentPermanentCardType(this);
|
return new TargetControlledPermanentSharingOpponentPermanentCardType(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Player controller = game.getPlayer(sourceControllerId);
|
Player controller = game.getPlayer(sourceControllerId);
|
||||||
Set<CardType> cardTypes = new HashSet<>();
|
EnumSet<CardType> cardTypes =EnumSet.noneOf(CardType.class);
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
||||||
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
||||||
|
|
@ -171,7 +171,7 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
||||||
Permanent target1 = game.getPermanent(source.getFirstTarget());
|
Permanent target1 = game.getPermanent(source.getFirstTarget());
|
||||||
Permanent opponentPermanent = game.getPermanent(id);
|
Permanent opponentPermanent = game.getPermanent(id);
|
||||||
if (target1 != null && opponentPermanent != null) {
|
if (target1 != null && opponentPermanent != null) {
|
||||||
return CardUtil.shareTypes(target1, opponentPermanent);
|
return target1.shareTypes(opponentPermanent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -184,7 +184,7 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (CardUtil.shareTypes(permanent, firstTarget)) {
|
if (permanent.shareTypes(firstTarget)) {
|
||||||
possibleTargets.add(permanent.getId());
|
possibleTargets.add(permanent.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards.d;
|
package mage.cards.d;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
|
@ -45,8 +46,6 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
|
|
@ -104,7 +103,7 @@ class DearlyDepartedEntersBattlefieldEffect extends ReplacementEffectImpl {
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
|
Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
target.addCounters(CounterType.P1P1.createInstance(), source, game);
|
target.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
61
Mage.Sets/src/mage/cards/d/DecisionParalysis.java
Normal file
61
Mage.Sets/src/mage/cards/d/DecisionParalysis.java
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.d;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect;
|
||||||
|
import mage.abilities.effects.common.TapTargetEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author fireshoes
|
||||||
|
*/
|
||||||
|
public class DecisionParalysis extends CardImpl {
|
||||||
|
|
||||||
|
public DecisionParalysis(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}");
|
||||||
|
|
||||||
|
// Tap up to two target creatures. Those creatures don't untap during their controller's next untap step.
|
||||||
|
this.getSpellAbility().addEffect(new TapTargetEffect());
|
||||||
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 2));
|
||||||
|
this.getSpellAbility().addEffect(new DontUntapInControllersNextUntapStepTargetEffect("Those creatures"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionParalysis(final DecisionParalysis card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DecisionParalysis copy() {
|
||||||
|
return new DecisionParalysis(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -42,7 +42,6 @@ import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -102,7 +101,7 @@ class DescendantsPathEffect extends OneShotEffect {
|
||||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
|
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
|
||||||
if (CardUtil.shareSubtypes(card, permanent, game)) {
|
if (card.shareSubtypes(permanent, game)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,6 @@ import mage.game.stack.Spell;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetSpell;
|
import mage.target.TargetSpell;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -90,15 +88,13 @@ class DesertionEffect extends OneShotEffect {
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
Spell targetSpell = game.getStack().getSpell(targetPointer.getFirst(game, source));
|
Spell targetSpell = game.getStack().getSpell(targetPointer.getFirst(game, source));
|
||||||
if (targetSpell != null) {
|
if (targetSpell != null) {
|
||||||
Set<CardType> cardTypes = new HashSet<>(targetSpell.getCardType());
|
|
||||||
if (!cardTypes.isEmpty()) {
|
|
||||||
//targetPointer.getFirst(game, source)
|
//targetPointer.getFirst(game, source)
|
||||||
if (cardTypes.contains(CardType.ARTIFACT) || cardTypes.contains(CardType.CREATURE)) {
|
if (targetSpell.isArtifact() || targetSpell.isCreature()) {
|
||||||
return game.getStack().counter(targetSpell.getId(), source.getSourceId(), game, Zone.BATTLEFIELD, false, ZoneDetail.NONE);
|
return game.getStack().counter(targetSpell.getId(), source.getSourceId(), game, Zone.BATTLEFIELD, false, ZoneDetail.NONE);
|
||||||
} else {
|
} else {
|
||||||
return game.getStack().counter(targetSpell.getId(), source.getSourceId(), game);
|
return game.getStack().counter(targetSpell.getId(), source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
121
Mage.Sets/src/mage/cards/d/Dismantle.java
Normal file
121
Mage.Sets/src/mage/cards/d/Dismantle.java
Normal file
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.d;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.counters.Counter;
|
||||||
|
import mage.counters.CounterType;
|
||||||
|
import mage.filter.common.FilterControlledArtifactPermanent;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
|
import mage.target.Target;
|
||||||
|
import mage.target.common.TargetArtifactPermanent;
|
||||||
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Styxo
|
||||||
|
*/
|
||||||
|
public class Dismantle extends CardImpl {
|
||||||
|
|
||||||
|
public Dismantle(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}");
|
||||||
|
|
||||||
|
// Destroy target artifact. If that artifact had counters on it, put that many +1/+1 counters or charge counters on an artifact you control.
|
||||||
|
this.getSpellAbility().addEffect(new DismantleEffect());
|
||||||
|
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dismantle(final Dismantle card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dismantle copy() {
|
||||||
|
return new Dismantle(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class DismantleEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
public DismantleEffect() {
|
||||||
|
super(Outcome.DestroyPermanent);
|
||||||
|
this.staticText = "Destroy target artifact. If that artifact had counters on it, put that many +1/+1 counters or charge counters on an artifact you control";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DismantleEffect(final DismantleEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DismantleEffect copy() {
|
||||||
|
return new DismantleEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||||
|
if (controller != null) {
|
||||||
|
if (permanent != null) {
|
||||||
|
int counterCount = 0;
|
||||||
|
counterCount = permanent.getCounters(game).values().stream().map((counter) -> counter.getCount()).reduce(counterCount, Integer::sum);
|
||||||
|
permanent.destroy(source.getSourceId(), game, false);
|
||||||
|
if (counterCount > 0) {
|
||||||
|
Target target = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent("an artifact you control"), true);
|
||||||
|
if (target.canChoose(controller.getId(), game)) {
|
||||||
|
controller.chooseTarget(Outcome.Benefit, target, source, game);
|
||||||
|
Permanent artifact = game.getPermanent(target.getFirstTarget());
|
||||||
|
Counter counter;
|
||||||
|
if (controller.chooseUse(Outcome.BoostCreature, "What kind of counters do you want to add?", null, "+1/+1 counters", "Charge counters", source, game)) {
|
||||||
|
counter = CounterType.P1P1.createInstance(counterCount);
|
||||||
|
} else {
|
||||||
|
counter = CounterType.CHARGE.createInstance(counterCount);
|
||||||
|
}
|
||||||
|
if (artifact != null) {
|
||||||
|
artifact.addCounters(counter, source, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue