mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
Merge origin/master
This commit is contained in:
commit
9741d34e1e
18 changed files with 1414 additions and 1210 deletions
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.client;
|
package mage.client;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
|
@ -85,6 +85,7 @@ import mage.cards.repository.CardRepository;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.chat.ChatPanel;
|
import mage.client.chat.ChatPanel;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
|
import mage.client.components.MageDesktopManager;
|
||||||
import mage.client.components.MageJDesktop;
|
import mage.client.components.MageJDesktop;
|
||||||
import mage.client.components.MageRoundPane;
|
import mage.client.components.MageRoundPane;
|
||||||
import mage.client.components.MageUI;
|
import mage.client.components.MageUI;
|
||||||
|
@ -156,7 +157,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
private static final Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
|
private static final Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
|
||||||
private JLabel title;
|
private JLabel title;
|
||||||
private Rectangle titleRectangle;
|
private Rectangle titleRectangle;
|
||||||
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
|
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
|
||||||
private UUID clientId;
|
private UUID clientId;
|
||||||
private static MagePane activeFrame;
|
private static MagePane activeFrame;
|
||||||
private static boolean liteMode = false;
|
private static boolean liteMode = false;
|
||||||
|
@ -236,6 +237,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
Plugins.getInstance().loadPlugins();
|
Plugins.getInstance().loadPlugins();
|
||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
desktopPane.setDesktopManager(new MageDesktopManager());
|
||||||
|
|
||||||
setSize(1024, 768);
|
setSize(1024, 768);
|
||||||
SettingsManager.getInstance().setScreenWidthAndHeight(1024, 768);
|
SettingsManager.getInstance().setScreenWidthAndHeight(1024, 768);
|
||||||
DialogManager.updateParams(768, 1024, false);
|
DialogManager.updateParams(768, 1024, false);
|
||||||
|
@ -368,7 +372,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
public void setWindowTitle() {
|
public void setWindowTitle() {
|
||||||
setTitle(TITLE_NAME + " Client: "
|
setTitle(TITLE_NAME + " Client: "
|
||||||
+ version == null ? "<not available>" : version.toString() + " Server: "
|
+ version == null ? "<not available>" : version.toString() + " Server: "
|
||||||
+ ((session != null && session.isConnected()) ? session.getVersionInfo():"<not connected>"));
|
+ ((session != null && session.isConnected()) ? session.getVersionInfo() : "<not connected>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTooltipContainer() {
|
private void addTooltipContainer() {
|
||||||
|
@ -585,7 +589,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
if (frame instanceof GamePane) {
|
if (frame instanceof GamePane) {
|
||||||
ArrowBuilder.getBuilder().showPanel(((GamePane) frame).getGameId());
|
ArrowBuilder.getBuilder().showPanel(((GamePane) frame).getGameId());
|
||||||
MusicPlayer.playBGM();
|
MusicPlayer.playBGM();
|
||||||
}else{
|
} else {
|
||||||
MusicPlayer.stopBGM();
|
MusicPlayer.stopBGM();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,7 +642,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
|
|
||||||
public void watchGame(UUID gameId) {
|
public void watchGame(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
for(Component component :desktopPane.getComponents()) {
|
for (Component component : desktopPane.getComponents()) {
|
||||||
if (component instanceof GamePane
|
if (component instanceof GamePane
|
||||||
&& ((GamePane) component).getGameId().equals(gameId)) {
|
&& ((GamePane) component).getGameId().equals(gameId)) {
|
||||||
setActive((GamePane) component);
|
setActive((GamePane) component);
|
||||||
|
@ -691,9 +695,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
|
|
||||||
public void showTournament(UUID tournamentId) {
|
public void showTournament(UUID tournamentId) {
|
||||||
try {
|
try {
|
||||||
for(Component component :desktopPane.getComponents()) {
|
for (Component component : desktopPane.getComponents()) {
|
||||||
if (component instanceof TournamentPane &&
|
if (component instanceof TournamentPane
|
||||||
((TournamentPane) component).getTournamentId().equals(tournamentId)) {
|
&& ((TournamentPane) component).getTournamentId().equals(tournamentId)) {
|
||||||
setActive((TournamentPane) component);
|
setActive((TournamentPane) component);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -780,10 +784,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 always
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* regenerated by the Form Editor.
|
||||||
* always regenerated by the Form Editor.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
@ -1064,7 +1067,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
if (window instanceof DeckEditorPane) {
|
if (window instanceof DeckEditorPane) {
|
||||||
DeckEditorPane deckEditorPane = (DeckEditorPane) window;
|
DeckEditorPane deckEditorPane = (DeckEditorPane) window;
|
||||||
if (deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.LIMITED_BUILDING)
|
if (deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.LIMITED_BUILDING)
|
||||||
|| deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.SIDEBOARDING)){
|
|| deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.SIDEBOARDING)) {
|
||||||
deckEditorPane.removeFrame();
|
deckEditorPane.removeFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1167,7 +1170,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
*/
|
*/
|
||||||
public static void main(final String args[]) {
|
public static void main(final String args[]) {
|
||||||
// Workaround for #451
|
// Workaround for #451
|
||||||
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
|
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
|
||||||
logger.info("Starting MAGE client version " + version);
|
logger.info("Starting MAGE client version " + version);
|
||||||
logger.info("Logging level: " + logger.getEffectiveLevel());
|
logger.info("Logging level: " + logger.getEffectiveLevel());
|
||||||
|
@ -1270,7 +1273,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
games.remove(gameId);
|
games.remove(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static DraftPanel getDraft(UUID draftId) {
|
public static DraftPanel getDraft(UUID draftId) {
|
||||||
return drafts.get(draftId);
|
return drafts.get(draftId);
|
||||||
}
|
}
|
||||||
|
@ -1368,6 +1370,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
||||||
|
|
||||||
private final MagePane frame;
|
private final MagePane frame;
|
||||||
|
|
||||||
public MagePaneMenuItem(MagePane frame) {
|
public MagePaneMenuItem(MagePane frame) {
|
||||||
|
|
|
@ -1,37 +1,36 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cards.java
|
* Cards.java
|
||||||
*
|
*
|
||||||
* Created on Dec 18, 2009, 10:40:12 AM
|
* Created on Dec 18, 2009, 10:40:12 AM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
@ -72,19 +71,21 @@ public class Cards extends javax.swing.JPanel {
|
||||||
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
|
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
private static final Border emptyBorder = new EmptyBorder(0,0,0,0);
|
private static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
|
||||||
|
|
||||||
private int minOffsetY = 0;
|
private int minOffsetY = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines whether component should be visible whenever there is no objects within.
|
* Defines whether component should be visible whenever there is no objects
|
||||||
* True by default.
|
* within. True by default.
|
||||||
*/
|
*/
|
||||||
private boolean isVisibleIfEmpty = true;
|
private boolean isVisibleIfEmpty = true;
|
||||||
|
|
||||||
private Dimension cardDimension;
|
private Dimension cardDimension;
|
||||||
|
|
||||||
/** Creates new form Cards */
|
/**
|
||||||
|
* Creates new form Cards
|
||||||
|
*/
|
||||||
public Cards() {
|
public Cards() {
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +94,7 @@ public class Cards extends javax.swing.JPanel {
|
||||||
initComponents(skipAddingScrollPane);
|
initComponents(skipAddingScrollPane);
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
//cardArea.setOpaque(false);
|
//cardArea.setOpaque(false);
|
||||||
setBackgroundColor(new Color(0,0,0,100));
|
setBackgroundColor(new Color(0, 0, 0, 100));
|
||||||
if (!skipAddingScrollPane) {
|
if (!skipAddingScrollPane) {
|
||||||
jScrollPane1.setOpaque(false);
|
jScrollPane1.setOpaque(false);
|
||||||
jScrollPane1.getViewport().setOpaque(false);
|
jScrollPane1.getViewport().setOpaque(false);
|
||||||
|
@ -105,10 +106,12 @@ public class Cards extends javax.swing.JPanel {
|
||||||
cardArea.setBorder(emptyBorder);
|
cardArea.setBorder(emptyBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanUp() {}
|
public void cleanUp() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets components background color
|
* Sets components background color
|
||||||
|
*
|
||||||
* @param color
|
* @param color
|
||||||
*/
|
*/
|
||||||
public void setBackgroundColor(Color color) {
|
public void setBackgroundColor(Color color) {
|
||||||
|
@ -151,14 +154,14 @@ public class Cards extends javax.swing.JPanel {
|
||||||
if (cardsView.size() == 0 && countCards() > 0) {
|
if (cardsView.size() == 0 && countCards() > 0) {
|
||||||
// problem happens with transformable cards
|
// problem happens with transformable cards
|
||||||
logger.fatal("Card object on the cards panel was not removed");
|
logger.fatal("Card object on the cards panel was not removed");
|
||||||
for (Component comp: cardArea.getComponents()) {
|
for (Component comp : cardArea.getComponents()) {
|
||||||
if (comp instanceof Card) {
|
if (comp instanceof Card) {
|
||||||
Card card = (Card)comp;
|
Card card = (Card) comp;
|
||||||
logger.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
|
logger.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
|
||||||
} else if (comp instanceof MageCard) {
|
} else if (comp instanceof MageCard) {
|
||||||
MageCard mageCard = (MageCard)comp;
|
MageCard mageCard = (MageCard) comp;
|
||||||
logger.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
|
logger.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
|
||||||
} else {
|
} else {
|
||||||
logger.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
|
logger.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
|
||||||
}
|
}
|
||||||
cardArea.remove(comp);
|
cardArea.remove(comp);
|
||||||
|
@ -167,24 +170,24 @@ public class Cards extends javax.swing.JPanel {
|
||||||
|
|
||||||
// order objects for display
|
// order objects for display
|
||||||
java.util.List<CardView> orderedList = new ArrayList<>();
|
java.util.List<CardView> orderedList = new ArrayList<>();
|
||||||
for (CardView card: cardsView.values()) {
|
for (CardView card : cardsView.values()) {
|
||||||
orderedList.add(0, card);
|
orderedList.add(0, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add objects to the panel
|
// add objects to the panel
|
||||||
for (CardView card: orderedList) {
|
for (CardView card : orderedList) {
|
||||||
if (dontDisplayTapped) {
|
if (dontDisplayTapped) {
|
||||||
if (card instanceof PermanentView) {
|
if (card instanceof PermanentView) {
|
||||||
((PermanentView)card).overrideTapped(false);
|
((PermanentView) card).overrideTapped(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (card instanceof StackAbilityView) {
|
if (card instanceof StackAbilityView) {
|
||||||
CardView tmp = ((StackAbilityView)card).getSourceCard();
|
CardView tmp = ((StackAbilityView) card).getSourceCard();
|
||||||
tmp.overrideRules(card.getRules());
|
tmp.overrideRules(card.getRules());
|
||||||
tmp.setIsAbility(true);
|
tmp.setIsAbility(true);
|
||||||
tmp.overrideTargets(card.getTargets());
|
tmp.overrideTargets(card.getTargets());
|
||||||
tmp.overrideId(card.getId());
|
tmp.overrideId(card.getId());
|
||||||
tmp.setAbilityType(((StackAbilityView)card).getAbilityType());
|
tmp.setAbilityType(((StackAbilityView) card).getAbilityType());
|
||||||
card = tmp;
|
card = tmp;
|
||||||
} else {
|
} else {
|
||||||
card.setAbilityType(null);
|
card.setAbilityType(null);
|
||||||
|
@ -212,11 +215,15 @@ public class Cards extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sizeCards(Dimension cardDimension) {
|
public void sizeCards(Dimension cardDimension) {
|
||||||
cardArea.setPreferredSize(new Dimension((int)((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int)(cardDimension.getHeight()) + 20));
|
cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20));
|
||||||
cardArea.revalidate();
|
cardArea.revalidate();
|
||||||
cardArea.repaint();
|
cardArea.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNumberOfCards() {
|
||||||
|
return cards.size();
|
||||||
|
}
|
||||||
|
|
||||||
private Dimension getCardDimension() {
|
private Dimension getCardDimension() {
|
||||||
if (cardDimension == null) {
|
if (cardDimension == null) {
|
||||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||||
|
@ -237,23 +244,23 @@ public class Cards extends javax.swing.JPanel {
|
||||||
|
|
||||||
private void definePosition(MageCard card) {
|
private void definePosition(MageCard card) {
|
||||||
int dx = 0;
|
int dx = 0;
|
||||||
for (Component comp: cardArea.getComponents()) {
|
for (Component comp : cardArea.getComponents()) {
|
||||||
if (!comp.equals(card)) {
|
if (!comp.equals(card)) {
|
||||||
dx = Math.max(dx, (int)comp.getLocation().getX());
|
dx = Math.max(dx, (int) comp.getLocation().getX());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dx += ((CardPanel)card).getCardWidth() + GAP_X;
|
dx += ((CardPanel) card).getCardWidth() + GAP_X;
|
||||||
card.setLocation(dx, (int)card.getLocation().getY());
|
card.setLocation(dx, (int) card.getLocation().getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeCard(UUID cardId) {
|
private void removeCard(UUID cardId) {
|
||||||
for (Component comp: cardArea.getComponents()) {
|
for (Component comp : cardArea.getComponents()) {
|
||||||
if (comp instanceof Card) {
|
if (comp instanceof Card) {
|
||||||
if (((Card)comp).getCardId().equals(cardId)) {
|
if (((Card) comp).getCardId().equals(cardId)) {
|
||||||
cardArea.remove(comp);
|
cardArea.remove(comp);
|
||||||
}
|
}
|
||||||
} else if (comp instanceof MageCard) {
|
} else if (comp instanceof MageCard) {
|
||||||
if (((MageCard)comp).getOriginal().getId().equals(cardId)) {
|
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
||||||
cardArea.remove(comp);
|
cardArea.remove(comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,10 +271,10 @@ public class Cards extends javax.swing.JPanel {
|
||||||
return cardArea.getComponentCount();
|
return cardArea.getComponentCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
@ -288,7 +295,6 @@ public class Cards extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JPanel cardArea;
|
private javax.swing.JPanel cardArea;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
|
@ -320,7 +326,7 @@ public class Cards extends javax.swing.JPanel {
|
||||||
|
|
||||||
for (Component component : cardArea.getComponents()) {
|
for (Component component : cardArea.getComponents()) {
|
||||||
if (component instanceof CardPanel) {
|
if (component instanceof CardPanel) {
|
||||||
cards.add((CardPanel)component);
|
cards.add((CardPanel) component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(cards, new Comparator<CardPanel>() {
|
Collections.sort(cards, new Comparator<CardPanel>() {
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package mage.client.components;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import javax.swing.DefaultDesktopManager;
|
||||||
|
import javax.swing.DesktopManager;
|
||||||
|
import javax.swing.JDesktopPane;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JInternalFrame;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import mage.client.dialog.CardInfoWindowDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class MageDesktopManager extends DefaultDesktopManager {
|
||||||
|
|
||||||
|
static final int DESKTOP_ICON_WIDTH = 250;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void iconifyFrame(JInternalFrame f) {
|
||||||
|
super.iconifyFrame(f);
|
||||||
|
if (f instanceof CardInfoWindowDialog) {
|
||||||
|
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
|
||||||
|
icon.setBounds(f.getX() + (f.getWidth() - DESKTOP_ICON_WIDTH), f.getY(), DESKTOP_ICON_WIDTH, icon.getHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deiconifyFrame(JInternalFrame f) {
|
||||||
|
super.deiconifyFrame(f);
|
||||||
|
if (f instanceof CardInfoWindowDialog) {
|
||||||
|
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
|
||||||
|
f.setBounds(icon.getX() + (DESKTOP_ICON_WIDTH - f.getWidth()), icon.getY(), f.getWidth(), f.getHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
JFrame frame = new JFrame();
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
JDesktopPane desktopPane = new JDesktopPane();
|
||||||
|
DesktopManager dm = new MageDesktopManager();
|
||||||
|
desktopPane.setDesktopManager(dm);
|
||||||
|
JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true);
|
||||||
|
internalFrame.setSize(200, 150);
|
||||||
|
internalFrame.setVisible(true);
|
||||||
|
desktopPane.add(internalFrame);
|
||||||
|
|
||||||
|
frame.add(desktopPane, BorderLayout.CENTER);
|
||||||
|
frame.setSize(800, 600);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,42 +1,39 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CardInfoWindowDialog.java
|
* CardInfoWindowDialog.java
|
||||||
*
|
*
|
||||||
* Created on Feb 1, 2010, 3:00:35 PM
|
* Created on Feb 1, 2010, 3:00:35 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.beans.PropertyVetoException;
|
import java.beans.PropertyVetoException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -61,7 +58,10 @@ import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||||
*/
|
*/
|
||||||
public class CardInfoWindowDialog extends MageDialog {
|
public class CardInfoWindowDialog extends MageDialog {
|
||||||
|
|
||||||
public static enum ShowType { REVEAL, LOOKED_AT, EXILE, GRAVEYARD, OTHER };
|
public static enum ShowType {
|
||||||
|
|
||||||
|
REVEAL, REVEAL_TOP_LIBRARY, LOOKED_AT, EXILE, GRAVEYARD, OTHER
|
||||||
|
};
|
||||||
|
|
||||||
private ShowType showType;
|
private ShowType showType;
|
||||||
private boolean positioned;
|
private boolean positioned;
|
||||||
|
@ -75,7 +75,7 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
this.setModal(false);
|
this.setModal(false);
|
||||||
switch(this.showType) {
|
switch (this.showType) {
|
||||||
case LOOKED_AT:
|
case LOOKED_AT:
|
||||||
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getLookedAtImage()));
|
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getLookedAtImage()));
|
||||||
this.setClosable(true);
|
this.setClosable(true);
|
||||||
|
@ -84,9 +84,12 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getRevealedImage()));
|
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getRevealedImage()));
|
||||||
this.setClosable(true);
|
this.setClosable(true);
|
||||||
break;
|
break;
|
||||||
|
case REVEAL_TOP_LIBRARY:
|
||||||
|
this.setFrameIcon(new ImageIcon(ImageHelper.getImageFromResources("/info/library.png")));
|
||||||
|
this.setClosable(true);
|
||||||
|
break;
|
||||||
case GRAVEYARD:
|
case GRAVEYARD:
|
||||||
this.setFrameIcon(new ImageIcon(ImageHelper.getImageFromResources("/info/grave.png")));
|
this.setFrameIcon(new ImageIcon(ImageHelper.getImageFromResources("/info/grave.png")));
|
||||||
this.setIconifiable(false);
|
|
||||||
this.setClosable(true);
|
this.setClosable(true);
|
||||||
this.setDefaultCloseOperation(HIDE_ON_CLOSE);
|
this.setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
addInternalFrameListener(new InternalFrameAdapter() {
|
addInternalFrameListener(new InternalFrameAdapter() {
|
||||||
|
@ -100,7 +103,7 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getExileImage()));
|
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getExileImage()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// no icon yet
|
// no icon yet
|
||||||
}
|
}
|
||||||
this.setTitelBarToolTip(name);
|
this.setTitelBarToolTip(name);
|
||||||
}
|
}
|
||||||
|
@ -123,6 +126,19 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
showAndPositionWindow();
|
showAndPositionWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
if (showType.equals(ShowType.EXILE)) {
|
||||||
|
if (cards == null || cards.getNumberOfCards() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.show();
|
||||||
|
if (positioned) { // check if in frame rectangle
|
||||||
|
showAndPositionWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showAndPositionWindow() {
|
private void showAndPositionWindow() {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -132,13 +148,13 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
if (width > 0 && height > 0) {
|
if (width > 0 && height > 0) {
|
||||||
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
|
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
|
||||||
if (!positioned) {
|
if (!positioned) {
|
||||||
positioned = true;
|
|
||||||
int xPos = centered.x / 2;
|
int xPos = centered.x / 2;
|
||||||
int yPos = centered.y / 2;
|
int yPos = centered.y / 2;
|
||||||
CardInfoWindowDialog.this.setLocation(xPos, yPos);
|
CardInfoWindowDialog.this.setLocation(xPos, yPos);
|
||||||
show();
|
show();
|
||||||
|
positioned = true;
|
||||||
}
|
}
|
||||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, CardInfoWindowDialog.this);
|
GuiDisplayUtil.keepComponentInsideFrame(centered.x, centered.y, CardInfoWindowDialog.this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -155,16 +171,15 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.hideDialog();
|
this.hideDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
@ -191,7 +206,6 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private mage.client.cards.Cards cards;
|
private mage.client.cards.Cards cards;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
@ -133,7 +133,6 @@ import mage.view.SimpleCardsView;
|
||||||
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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com, nantuko8
|
* @author BetaSteward_at_googlemail.com, nantuko8
|
||||||
|
@ -248,7 +247,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
this.handContainer.cleanUp();
|
this.handContainer.cleanUp();
|
||||||
this.stack.cleanUp();
|
this.stack.cleanUp();
|
||||||
for(Map.Entry<UUID, PlayAreaPanel> playAreaPanelEntry: players.entrySet()) {
|
for (Map.Entry<UUID, PlayAreaPanel> playAreaPanelEntry : players.entrySet()) {
|
||||||
playAreaPanelEntry.getValue().CleanUp();
|
playAreaPanelEntry.getValue().CleanUp();
|
||||||
}
|
}
|
||||||
this.players.clear();
|
this.players.clear();
|
||||||
|
@ -262,23 +261,23 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (pickNumber != null) {
|
if (pickNumber != null) {
|
||||||
pickNumber.removeDialog();
|
pickNumber.removeDialog();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog exileDialog: exiles.values()) {
|
for (CardInfoWindowDialog exileDialog : exiles.values()) {
|
||||||
exileDialog.cleanUp();
|
exileDialog.cleanUp();
|
||||||
exileDialog.removeDialog();
|
exileDialog.removeDialog();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog graveyardDialog: graveyardWindows.values()) {
|
for (CardInfoWindowDialog graveyardDialog : graveyardWindows.values()) {
|
||||||
graveyardDialog.cleanUp();
|
graveyardDialog.cleanUp();
|
||||||
graveyardDialog.removeDialog();
|
graveyardDialog.removeDialog();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog revealDialog: revealed.values()) {
|
for (CardInfoWindowDialog revealDialog : revealed.values()) {
|
||||||
revealDialog.cleanUp();
|
revealDialog.cleanUp();
|
||||||
revealDialog.removeDialog();
|
revealDialog.removeDialog();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog lookedAtDialog: lookedAt.values()) {
|
for (CardInfoWindowDialog lookedAtDialog : lookedAt.values()) {
|
||||||
lookedAtDialog.cleanUp();
|
lookedAtDialog.cleanUp();
|
||||||
lookedAtDialog.removeDialog();
|
lookedAtDialog.removeDialog();
|
||||||
}
|
}
|
||||||
for (ShowCardsDialog pickTargetDialog: pickTarget) {
|
for (ShowCardsDialog pickTargetDialog : pickTarget) {
|
||||||
pickTargetDialog.cleanUp();
|
pickTargetDialog.cleanUp();
|
||||||
pickTargetDialog.removeDialog();
|
pickTargetDialog.removeDialog();
|
||||||
}
|
}
|
||||||
|
@ -340,12 +339,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pnlShortCuts.revalidate();
|
pnlShortCuts.revalidate();
|
||||||
pnlShortCuts.repaint();
|
pnlShortCuts.repaint();
|
||||||
//this.handContainer.sizeHand(0.8, smallMode);
|
//this.handContainer.sizeHand(0.8, smallMode);
|
||||||
for (PlayAreaPanel p: players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
p.sizePlayer(smallMode);
|
p.sizePlayer(smallMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (smallMode) {
|
if (smallMode) {
|
||||||
smallMode = false;
|
smallMode = false;
|
||||||
Dimension bbDimension = new Dimension(256, 367);
|
Dimension bbDimension = new Dimension(256, 367);
|
||||||
|
@ -355,7 +353,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pnlShortCuts.revalidate();
|
pnlShortCuts.revalidate();
|
||||||
pnlShortCuts.repaint();
|
pnlShortCuts.repaint();
|
||||||
this.handContainer.sizeHand(1, smallMode);
|
this.handContainer.sizeHand(1, smallMode);
|
||||||
for (PlayAreaPanel p: players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
p.sizePlayer(smallMode);
|
p.sizePlayer(smallMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +408,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.feedbackPanel.init(gameId);
|
this.feedbackPanel.init(gameId);
|
||||||
this.feedbackPanel.clear();
|
this.feedbackPanel.clear();
|
||||||
|
|
||||||
|
|
||||||
this.btnConcede.setVisible(false);
|
this.btnConcede.setVisible(false);
|
||||||
this.btnStopWatching.setVisible(true);
|
this.btnStopWatching.setVisible(true);
|
||||||
this.btnSwitchHands.setVisible(false);
|
this.btnSwitchHands.setVisible(false);
|
||||||
|
@ -464,7 +461,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
((GamePane)c).removeGame();
|
((GamePane) c).removeGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +486,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
int row = 1;
|
int row = 1;
|
||||||
int playerSeat = 0;
|
int playerSeat = 0;
|
||||||
if (playerId != null) {
|
if (playerId != null) {
|
||||||
for (PlayerView player: game.getPlayers()) {
|
for (PlayerView player : game.getPlayers()) {
|
||||||
if (playerId.equals(player.getPlayerId())) {
|
if (playerId.equals(player.getPlayerId())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -521,8 +518,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (row == 1) {
|
if (row == 1) {
|
||||||
col++;
|
col++;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
col--;
|
col--;
|
||||||
}
|
}
|
||||||
if (col >= numColumns) {
|
if (col >= numColumns) {
|
||||||
|
@ -549,7 +545,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (PlayAreaPanel p: players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
p.sizePlayer(smallMode);
|
p.sizePlayer(smallMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,7 +561,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.handContainer.setVisible(true);
|
this.handContainer.setVisible(true);
|
||||||
handCards.clear();
|
handCards.clear();
|
||||||
if (game.getWatchedHands() != null) {
|
if (game.getWatchedHands() != null) {
|
||||||
for (Map.Entry<String, SimpleCardsView> hand: game.getWatchedHands().entrySet()) {
|
for (Map.Entry<String, SimpleCardsView> hand : game.getWatchedHands().entrySet()) {
|
||||||
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
|
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +577,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
// Get opponents hand cards if available (only possible for players)
|
// Get opponents hand cards if available (only possible for players)
|
||||||
if (game.getOpponentHands() != null) {
|
if (game.getOpponentHands() != null) {
|
||||||
for (Map.Entry<String, SimpleCardsView> hand: game.getOpponentHands().entrySet()) {
|
for (Map.Entry<String, SimpleCardsView> hand : game.getOpponentHands().entrySet()) {
|
||||||
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
|
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(hand.getValue(), loadedCards));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,7 +593,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
hideAll();
|
hideAll();
|
||||||
|
|
||||||
|
|
||||||
if (playerId != null) {
|
if (playerId != null) {
|
||||||
// set visible only if we have any other hand visible than ours
|
// set visible only if we have any other hand visible than ours
|
||||||
btnSwitchHands.setVisible(handCards.size() > 1);
|
btnSwitchHands.setVisible(handCards.size() > 1);
|
||||||
|
@ -646,7 +641,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PlayerView player: game.getPlayers()) {
|
for (PlayerView player : game.getPlayers()) {
|
||||||
if (players.containsKey(player.getPlayerId())) {
|
if (players.containsKey(player.getPlayerId())) {
|
||||||
if (!possibleAttackers.isEmpty()) {
|
if (!possibleAttackers.isEmpty()) {
|
||||||
for (UUID permanentId : possibleAttackers) {
|
for (UUID permanentId : possibleAttackers) {
|
||||||
|
@ -660,7 +655,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
updateSkipButtons(player.isPassedTurn(), player.isPassedUntilEndOfTurn(), player.isPassedUntilNextMain(), player.isPassedAllTurns(), player.isPassedUntilStackResolved());
|
updateSkipButtons(player.isPassedTurn(), player.isPassedUntilEndOfTurn(), player.isPassedUntilNextMain(), player.isPassedAllTurns(), player.isPassedUntilStackResolved());
|
||||||
}
|
}
|
||||||
// update open or remove closed graveyard windows
|
// update open or remove closed graveyard windows
|
||||||
|
|
||||||
graveyards.put(player.getName(), player.getGraveyard());
|
graveyards.put(player.getName(), player.getGraveyard());
|
||||||
if (graveyardWindows.containsKey(player.getName())) {
|
if (graveyardWindows.containsKey(player.getName())) {
|
||||||
CardInfoWindowDialog cardInfoWindowDialog = graveyardWindows.get(player.getName());
|
CardInfoWindowDialog cardInfoWindowDialog = graveyardWindows.get(player.getName());
|
||||||
|
@ -670,12 +664,18 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
cardInfoWindowDialog.loadCards(player.getGraveyard(), bigCard, gameId);
|
cardInfoWindowDialog.loadCards(player.getGraveyard(), bigCard, gameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// show top card window
|
||||||
|
if (player.getTopCard() != null) {
|
||||||
|
CardsView cardsView = new CardsView();
|
||||||
|
cardsView.put(player.getTopCard().getId(), player.getTopCard());
|
||||||
|
handleGameInfoWindow(revealed, ShowType.REVEAL_TOP_LIBRARY, player.getName() + "'s top library card", cardsView);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
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(""+p);
|
logger.warn("" + p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -687,7 +687,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
sb.append("Playing: ");
|
sb.append("Playing: ");
|
||||||
}
|
}
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (PlayerView player: game.getPlayers()) {
|
for (PlayerView player : game.getPlayers()) {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -702,7 +702,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
GameManager.getInstance().setStackSize(game.getStack().size());
|
GameManager.getInstance().setStackSize(game.getStack().size());
|
||||||
displayStack(game, bigCard, feedbackPanel, gameId);
|
displayStack(game, bigCard, feedbackPanel, gameId);
|
||||||
|
|
||||||
for (ExileView exile: game.getExile()) {
|
for (ExileView exile : game.getExile()) {
|
||||||
if (!exiles.containsKey(exile.getId())) {
|
if (!exiles.containsKey(exile.getId())) {
|
||||||
CardInfoWindowDialog newExile = new CardInfoWindowDialog(ShowType.EXILE, exile.getName());
|
CardInfoWindowDialog newExile = new CardInfoWindowDialog(ShowType.EXILE, exile.getName());
|
||||||
exiles.put(exile.getId(), newExile);
|
exiles.put(exile.getId(), newExile);
|
||||||
|
@ -732,40 +732,41 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (turn) { //F4
|
if (turn) { //F4
|
||||||
btnSkipToNextTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
btnSkipToNextTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
||||||
} else {
|
} else {
|
||||||
btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE));
|
btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
}
|
}
|
||||||
if (endOfTurn) { // F5
|
if (endOfTurn) { // F5
|
||||||
btnSkipToEndTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
btnSkipToEndTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
||||||
} else {
|
} else {
|
||||||
btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE));
|
btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
}
|
}
|
||||||
if (nextMain) { // F7
|
if (nextMain) { // F7
|
||||||
btnSkipToNextMain.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
btnSkipToNextMain.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
||||||
} else {
|
} else {
|
||||||
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE));
|
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
}
|
}
|
||||||
if (stack) { // F8
|
if (stack) { // F8
|
||||||
btnSkipStack.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
btnSkipStack.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
||||||
} else {
|
} else {
|
||||||
btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE));
|
btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
}
|
}
|
||||||
if (allTurns) { // F9
|
if (allTurns) { // F9
|
||||||
btnSkipToYourTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
btnSkipToYourTurn.setBorder(new LineBorder(Color.red, BORDER_SIZE));
|
||||||
} else {
|
} else {
|
||||||
btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE));
|
btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the same state for menu selections to all player areas.
|
* Set the same state for menu selections to all player areas.
|
||||||
|
*
|
||||||
* @param manaPoolAutomatic
|
* @param manaPoolAutomatic
|
||||||
* @param manaPoolAutomaticRestricted
|
* @param manaPoolAutomaticRestricted
|
||||||
*/
|
*/
|
||||||
public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
|
public void setMenuStates(boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
|
||||||
for(PlayAreaPanel playAreaPanel: players.values()) {
|
for (PlayAreaPanel playAreaPanel : players.values()) {
|
||||||
playAreaPanel.setMenuStates(manaPoolAutomatic, manaPoolAutomaticRestricted);
|
playAreaPanel.setMenuStates(manaPoolAutomatic, manaPoolAutomaticRestricted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayStack(GameView game, BigCard bigCard, FeedbackPanel feedbackPanel, UUID gameId) {
|
private void displayStack(GameView game, BigCard bigCard, FeedbackPanel feedbackPanel, UUID gameId) {
|
||||||
|
@ -832,16 +833,16 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
// Called if the game frame is deactivated because the tabled the deck editor or other frames go to foreground
|
// Called if the game frame is deactivated because the tabled the deck editor or other frames go to foreground
|
||||||
public void deactivated() {
|
public void deactivated() {
|
||||||
// hide the non modal windows (because otherwise they are shown on top of the new active pane)
|
// hide the non modal windows (because otherwise they are shown on top of the new active pane)
|
||||||
for (CardInfoWindowDialog exileDialog: exiles.values()) {
|
for (CardInfoWindowDialog exileDialog : exiles.values()) {
|
||||||
exileDialog.hideDialog();
|
exileDialog.hideDialog();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog graveyardDialog: graveyardWindows.values()) {
|
for (CardInfoWindowDialog graveyardDialog : graveyardWindows.values()) {
|
||||||
graveyardDialog.hideDialog();
|
graveyardDialog.hideDialog();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog revealDialog: revealed.values()) {
|
for (CardInfoWindowDialog revealDialog : revealed.values()) {
|
||||||
revealDialog.hideDialog();
|
revealDialog.hideDialog();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog lookedAtDialog: lookedAt.values()) {
|
for (CardInfoWindowDialog lookedAtDialog : lookedAt.values()) {
|
||||||
lookedAtDialog.hideDialog();
|
lookedAtDialog.hideDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -849,22 +850,22 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
// Called if the game frame comes to front again
|
// Called if the game frame comes to front again
|
||||||
public void activated() {
|
public void activated() {
|
||||||
// hide the non modal windows (because otherwise they are shown on top of the new active pane)
|
// hide the non modal windows (because otherwise they are shown on top of the new active pane)
|
||||||
for (CardInfoWindowDialog exileDialog: exiles.values()) {
|
for (CardInfoWindowDialog exileDialog : exiles.values()) {
|
||||||
exileDialog.show();
|
exileDialog.show();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog graveyardDialog: graveyardWindows.values()) {
|
for (CardInfoWindowDialog graveyardDialog : graveyardWindows.values()) {
|
||||||
graveyardDialog.show();
|
graveyardDialog.show();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog revealDialog: revealed.values()) {
|
for (CardInfoWindowDialog revealDialog : revealed.values()) {
|
||||||
revealDialog.show();
|
revealDialog.show();
|
||||||
}
|
}
|
||||||
for (CardInfoWindowDialog lookedAtDialog: lookedAt.values()) {
|
for (CardInfoWindowDialog lookedAtDialog : lookedAt.values()) {
|
||||||
lookedAtDialog.show();
|
lookedAtDialog.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openGraveyardWindow(String playerName) {
|
public void openGraveyardWindow(String playerName) {
|
||||||
if(graveyardWindows.containsKey(playerName)) {
|
if (graveyardWindows.containsKey(playerName)) {
|
||||||
CardInfoWindowDialog cardInfoWindowDialog = graveyardWindows.get(playerName);
|
CardInfoWindowDialog cardInfoWindowDialog = graveyardWindows.get(playerName);
|
||||||
if (cardInfoWindowDialog.isVisible()) {
|
if (cardInfoWindowDialog.isVisible()) {
|
||||||
cardInfoWindowDialog.hideDialog();
|
cardInfoWindowDialog.hideDialog();
|
||||||
|
@ -879,15 +880,27 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
newGraveyard.loadCards(graveyards.get(playerName), bigCard, gameId);
|
newGraveyard.loadCards(graveyards.get(playerName), bigCard, gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openTopLibraryWindow(String playerName) {
|
||||||
|
String title = playerName + "'s top library card";
|
||||||
|
if (revealed.containsKey(title)) {
|
||||||
|
CardInfoWindowDialog cardInfoWindowDialog = revealed.get(title);
|
||||||
|
if (cardInfoWindowDialog.isVisible()) {
|
||||||
|
cardInfoWindowDialog.hideDialog();
|
||||||
|
} else {
|
||||||
|
cardInfoWindowDialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showRevealed(GameView game) {
|
private void showRevealed(GameView game) {
|
||||||
for (RevealedView revealView: game.getRevealed()) {
|
for (RevealedView revealView : game.getRevealed()) {
|
||||||
handleGameInfoWindow(revealed, ShowType.REVEAL, revealView.getName(), revealView.getCards());
|
handleGameInfoWindow(revealed, ShowType.REVEAL, revealView.getName(), revealView.getCards());
|
||||||
}
|
}
|
||||||
removeClosedCardInfoWindows(revealed);
|
removeClosedCardInfoWindows(revealed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showLookedAt(GameView game) {
|
private void showLookedAt(GameView game) {
|
||||||
for (LookedAtView lookedAtView: game.getLookedAt()) {
|
for (LookedAtView lookedAtView : game.getLookedAt()) {
|
||||||
handleGameInfoWindow(lookedAt, ShowType.LOOKED_AT, lookedAtView.getName(), lookedAtView.getCards());
|
handleGameInfoWindow(lookedAt, ShowType.LOOKED_AT, lookedAtView.getName(), lookedAtView.getCards());
|
||||||
}
|
}
|
||||||
removeClosedCardInfoWindows(lookedAt);
|
removeClosedCardInfoWindows(lookedAt);
|
||||||
|
@ -904,8 +917,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cardInfoWindowDialog != null && !cardInfoWindowDialog.isClosed()) {
|
if (cardInfoWindowDialog != null && !cardInfoWindowDialog.isClosed()) {
|
||||||
switch(showType) {
|
switch (showType) {
|
||||||
case REVEAL:
|
case REVEAL:
|
||||||
|
case REVEAL_TOP_LIBRARY:
|
||||||
cardInfoWindowDialog.loadCards((CardsView) cardsView, bigCard, gameId);
|
cardInfoWindowDialog.loadCards((CardsView) cardsView, bigCard, gameId);
|
||||||
break;
|
break;
|
||||||
case LOOKED_AT:
|
case LOOKED_AT:
|
||||||
|
@ -929,8 +943,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, false, null, messageId);
|
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, false, null, messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a pick target dialog and allows the player to pick a target (e.g. the pick triggered ability)
|
* Shows a pick target dialog and allows the player to pick a target (e.g.
|
||||||
|
* the pick triggered ability)
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* @param cardView
|
* @param cardView
|
||||||
|
@ -948,7 +964,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (options.containsKey("chosen")) {
|
if (options.containsKey("chosen")) {
|
||||||
choosen = (List<UUID>) options.get("chosen");
|
choosen = (List<UUID>) options.get("chosen");
|
||||||
}
|
}
|
||||||
for(CardView card: gameView.getHand().values()) {
|
for (CardView card : gameView.getHand().values()) {
|
||||||
if (targets == null || targets.isEmpty()) {
|
if (targets == null || targets.isEmpty()) {
|
||||||
card.setPlayable(false);
|
card.setPlayable(false);
|
||||||
card.setChoosable(true);
|
card.setChoosable(true);
|
||||||
|
@ -968,7 +984,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
dialog = showCards(message, cardView, required, options0);
|
dialog = showCards(message, cardView, required, options0);
|
||||||
options0.put("dialog", dialog);
|
options0.put("dialog", dialog);
|
||||||
}
|
}
|
||||||
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId);
|
this.feedbackPanel.getFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId);
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
this.pickTarget.add(dialog);
|
this.pickTarget.add(dialog);
|
||||||
}
|
}
|
||||||
|
@ -1009,13 +1025,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
if (gameView.getActivePlayerId().equals(playerId)) {
|
if (gameView.getActivePlayerId().equals(playerId)) {
|
||||||
activePlayerText = "Your turn";
|
activePlayerText = "Your turn";
|
||||||
} else {
|
} else {
|
||||||
activePlayerText = gameView.getActivePlayerName() +"'s turn";
|
activePlayerText = gameView.getActivePlayerName() + "'s turn";
|
||||||
}
|
}
|
||||||
String priorityPlayerText = "";
|
String priorityPlayerText = "";
|
||||||
if (controllingPlayer) {
|
if (controllingPlayer) {
|
||||||
priorityPlayerText = " / priority " + gameView.getPriorityPlayerName();
|
priorityPlayerText = " / priority " + gameView.getPriorityPlayerName();
|
||||||
}
|
}
|
||||||
String messageToDisplay = message + "<div style='font-size:11pt'>" + activePlayerText +" / " + gameView.getStep().toString() + priorityPlayerText + "</div>";
|
String messageToDisplay = message + "<div style='font-size:11pt'>" + activePlayerText + " / " + gameView.getStep().toString() + priorityPlayerText + "</div>";
|
||||||
|
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId);
|
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId);
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1060,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private void hideAll() {
|
private void hideAll() {
|
||||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||||
((MageActionCallback)callback).hideGameUpdate(gameId);
|
((MageActionCallback) callback).hideGameUpdate(gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShowCardsDialog showCards(String title, CardsView cards, boolean required, Map<String, Serializable> options) {
|
private ShowCardsDialog showCards(String title, CardsView cards, boolean required, Map<String, Serializable> options) {
|
||||||
|
@ -1058,8 +1074,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pickNumber.showDialog(min, max, message);
|
pickNumber.showDialog(min, max, message);
|
||||||
if (pickNumber.isCancel()) {
|
if (pickNumber.isCancel()) {
|
||||||
session.sendPlayerBoolean(gameId, false);
|
session.sendPlayerBoolean(gameId, false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
session.sendPlayerInteger(gameId, pickNumber.getAmount());
|
session.sendPlayerInteger(gameId, pickNumber.getAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1082,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
public void getChoice(Choice choice, UUID objectId) {
|
public void getChoice(Choice choice, UUID objectId) {
|
||||||
hideAll();
|
hideAll();
|
||||||
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
||||||
pickChoice.showDialog(choice, objectId,choiceWindowState);
|
pickChoice.showDialog(choice, objectId, choiceWindowState);
|
||||||
if (choice.isKeyChoice()) {
|
if (choice.isKeyChoice()) {
|
||||||
if (pickChoice.isAutoSelect()) {
|
if (pickChoice.isAutoSelect()) {
|
||||||
session.sendPlayerString(gameId, "#" + choice.getChoiceKey());
|
session.sendPlayerString(gameId, "#" + choice.getChoiceKey());
|
||||||
|
@ -1116,11 +1131,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
feedbackPanel = new mage.client.game.FeedbackPanel();
|
feedbackPanel = new mage.client.game.FeedbackPanel();
|
||||||
|
|
||||||
txtSpellsCast = new javax.swing.JLabel();
|
txtSpellsCast = new javax.swing.JLabel();
|
||||||
Font font = new Font("SansSerif", Font.BOLD,12);
|
Font font = new Font("SansSerif", Font.BOLD, 12);
|
||||||
txtSpellsCast.setFont(font);
|
txtSpellsCast.setFont(font);
|
||||||
Border paddingBorder = BorderFactory.createEmptyBorder(4,4,4,4);
|
Border paddingBorder = BorderFactory.createEmptyBorder(4, 4, 4, 4);
|
||||||
Border border = BorderFactory.createLineBorder(Color.DARK_GRAY,2);
|
Border border = BorderFactory.createLineBorder(Color.DARK_GRAY, 2);
|
||||||
txtSpellsCast.setBorder(BorderFactory.createCompoundBorder(border,paddingBorder));
|
txtSpellsCast.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
|
||||||
txtSpellsCast.setBackground(Color.LIGHT_GRAY);
|
txtSpellsCast.setBackground(Color.LIGHT_GRAY);
|
||||||
txtSpellsCast.setOpaque(true);
|
txtSpellsCast.setOpaque(true);
|
||||||
txtSpellsCast.setToolTipText("spells cast during the current turn");
|
txtSpellsCast.setToolTipText("spells cast during the current turn");
|
||||||
|
@ -1209,7 +1224,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
lblPriority.setLabelFor(txtPriority);
|
lblPriority.setLabelFor(txtPriority);
|
||||||
lblPriority.setText("Priority Player:");
|
lblPriority.setText("Priority Player:");
|
||||||
|
|
||||||
feedbackPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(150, 50, 50),2));
|
feedbackPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(150, 50, 50), 2));
|
||||||
feedbackPanel.setMaximumSize(new java.awt.Dimension(208, 121));
|
feedbackPanel.setMaximumSize(new java.awt.Dimension(208, 121));
|
||||||
feedbackPanel.setMinimumSize(new java.awt.Dimension(208, 121));
|
feedbackPanel.setMinimumSize(new java.awt.Dimension(208, 121));
|
||||||
|
|
||||||
|
@ -1227,7 +1242,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnCancelSkip.setContentAreaFilled(false);
|
btnCancelSkip.setContentAreaFilled(false);
|
||||||
btnCancelSkip.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE));
|
btnCancelSkip.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
btnCancelSkip.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getCancelSkipButtonImage()));
|
btnCancelSkip.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getCancelSkipButtonImage()));
|
||||||
btnCancelSkip.setToolTipText("Cancel all skip actions (F3).");
|
btnCancelSkip.setToolTipText("Cancel all skip actions (F3).");
|
||||||
btnCancelSkip.setFocusable(false);
|
btnCancelSkip.setFocusable(false);
|
||||||
|
@ -1241,7 +1256,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnSkipToNextTurn.setContentAreaFilled(false);
|
btnSkipToNextTurn.setContentAreaFilled(false);
|
||||||
btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE));
|
btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
btnSkipToNextTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipNextTurnButtonImage()));
|
btnSkipToNextTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipNextTurnButtonImage()));
|
||||||
btnSkipToNextTurn.setToolTipText("Skip to next turn (F4).");
|
btnSkipToNextTurn.setToolTipText("Skip to next turn (F4).");
|
||||||
btnSkipToNextTurn.setFocusable(false);
|
btnSkipToNextTurn.setFocusable(false);
|
||||||
|
@ -1264,7 +1279,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnSkipToEndTurn.setContentAreaFilled(false);
|
btnSkipToEndTurn.setContentAreaFilled(false);
|
||||||
btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE));
|
btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
btnSkipToEndTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipEndTurnButtonImage()));
|
btnSkipToEndTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipEndTurnButtonImage()));
|
||||||
btnSkipToEndTurn.setToolTipText("Skip to (opponents/next) end of turn step (F5) - adjust using preferences.");
|
btnSkipToEndTurn.setToolTipText("Skip to (opponents/next) end of turn step (F5) - adjust using preferences.");
|
||||||
btnSkipToEndTurn.setFocusable(false);
|
btnSkipToEndTurn.setFocusable(false);
|
||||||
|
@ -1287,7 +1302,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnSkipToNextMain.setContentAreaFilled(false);
|
btnSkipToNextMain.setContentAreaFilled(false);
|
||||||
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE));
|
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipMainButtonImage()));
|
btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipMainButtonImage()));
|
||||||
btnSkipToNextMain.setToolTipText("Skip to (your) next main phase (F7) - adjust using preferences.");
|
btnSkipToNextMain.setToolTipText("Skip to (your) next main phase (F7) - adjust using preferences.");
|
||||||
btnSkipToNextMain.setFocusable(false);
|
btnSkipToNextMain.setFocusable(false);
|
||||||
|
@ -1310,7 +1325,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnSkipToYourTurn.setContentAreaFilled(false);
|
btnSkipToYourTurn.setContentAreaFilled(false);
|
||||||
btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE));
|
btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
btnSkipToYourTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipYourNextTurnButtonImage()));
|
btnSkipToYourTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipYourNextTurnButtonImage()));
|
||||||
btnSkipToYourTurn.setToolTipText("Skip to your next turn (F9).");
|
btnSkipToYourTurn.setToolTipText("Skip to your next turn (F9).");
|
||||||
btnSkipToYourTurn.setFocusable(false);
|
btnSkipToYourTurn.setFocusable(false);
|
||||||
|
@ -1333,7 +1348,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnSkipStack.setContentAreaFilled(false);
|
btnSkipStack.setContentAreaFilled(false);
|
||||||
btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE));
|
btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipStackButtonImage()));
|
btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipStackButtonImage()));
|
||||||
btnSkipStack.setToolTipText("Skip until stack is resolved (F10).");
|
btnSkipStack.setToolTipText("Skip until stack is resolved (F10).");
|
||||||
btnSkipStack.setFocusable(false);
|
btnSkipStack.setFocusable(false);
|
||||||
|
@ -1356,7 +1371,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnConcede.setContentAreaFilled(false);
|
btnConcede.setContentAreaFilled(false);
|
||||||
btnConcede.setBorder(new EmptyBorder(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE, BORDER_SIZE));
|
btnConcede.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
|
||||||
btnConcede.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getConcedeButtonImage()));
|
btnConcede.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getConcedeButtonImage()));
|
||||||
btnConcede.setToolTipText("Concede the current game.");
|
btnConcede.setToolTipText("Concede the current game.");
|
||||||
btnConcede.setFocusable(false);
|
btnConcede.setFocusable(false);
|
||||||
|
@ -1369,7 +1384,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
KeyStroke ks2 = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
|
KeyStroke ks2 = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
|
||||||
this.getInputMap(c).put(ks2, "F2_PRESS");
|
this.getInputMap(c).put(ks2, "F2_PRESS");
|
||||||
this.getActionMap().put("F2_PRESS", new AbstractAction() {
|
this.getActionMap().put("F2_PRESS", new AbstractAction() {
|
||||||
|
@ -1387,7 +1401,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||||
((MageActionCallback)callback).enlargeCard(EnlargeMode.NORMAL);
|
((MageActionCallback) callback).enlargeCard(EnlargeMode.NORMAL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1397,7 +1411,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||||
((MageActionCallback)callback).enlargeCard(EnlargeMode.ALTERNATE);
|
((MageActionCallback) callback).enlargeCard(EnlargeMode.ALTERNATE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1442,12 +1456,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||||
((MageActionCallback)callback).hideEnlargedCard();
|
((MageActionCallback) callback).hideEnlargedCard();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnSwitchHands.setContentAreaFilled(false);
|
btnSwitchHands.setContentAreaFilled(false);
|
||||||
btnSwitchHands.setBorder(new EmptyBorder(0,0,0,0));
|
btnSwitchHands.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||||
btnSwitchHands.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSwitchHandsButtonImage()));
|
btnSwitchHands.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSwitchHandsButtonImage()));
|
||||||
btnSwitchHands.setFocusable(false);
|
btnSwitchHands.setFocusable(false);
|
||||||
btnSwitchHands.setToolTipText("Switch between your hand cards and hand cards of controlled players.");
|
btnSwitchHands.setToolTipText("Switch between your hand cards and hand cards of controlled players.");
|
||||||
|
@ -1461,7 +1475,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
btnStopWatching.setContentAreaFilled(false);
|
btnStopWatching.setContentAreaFilled(false);
|
||||||
btnStopWatching.setBorder(new EmptyBorder(0,0,0,0));
|
btnStopWatching.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||||
btnStopWatching.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getStopWatchButtonImage()));
|
btnStopWatching.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getStopWatchButtonImage()));
|
||||||
btnStopWatching.setFocusable(false);
|
btnStopWatching.setFocusable(false);
|
||||||
btnStopWatching.setToolTipText("Stop watching this game.");
|
btnStopWatching.setToolTipText("Stop watching this game.");
|
||||||
|
@ -1475,7 +1489,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
stack.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 25));
|
stack.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 25));
|
||||||
stack.setBackgroundColor(new Color(0,0,0,0));
|
stack.setBackgroundColor(new Color(0, 0, 0, 0));
|
||||||
|
|
||||||
btnStopReplay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop.png")));
|
btnStopReplay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop.png")));
|
||||||
btnStopReplay.addActionListener(new java.awt.event.ActionListener() {
|
btnStopReplay.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@ -1521,79 +1535,78 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
|
javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
|
||||||
pnlReplay.setLayout(gl_pnlReplay);
|
pnlReplay.setLayout(gl_pnlReplay);
|
||||||
gl_pnlReplay.setHorizontalGroup(
|
gl_pnlReplay.setHorizontalGroup(
|
||||||
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(gl_pnlReplay.createSequentialGroup()
|
.addGroup(gl_pnlReplay.createSequentialGroup()
|
||||||
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnStopReplay, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(btnNextPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addComponent(btnSkipForward, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
);
|
);
|
||||||
gl_pnlReplay.setVerticalGroup(
|
gl_pnlReplay.setVerticalGroup(
|
||||||
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
gl_pnlReplay.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnSkipForward, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnNextPlay, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnStopReplay, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
|
.addComponent(btnPlay, 0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
|
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Game info panel (buttons on the right panel)
|
// Game info panel (buttons on the right panel)
|
||||||
javax.swing.GroupLayout gl_pnlShortCuts = new javax.swing.GroupLayout(pnlShortCuts);
|
javax.swing.GroupLayout gl_pnlShortCuts = new javax.swing.GroupLayout(pnlShortCuts);
|
||||||
pnlShortCuts.setLayout(gl_pnlShortCuts);
|
pnlShortCuts.setLayout(gl_pnlShortCuts);
|
||||||
gl_pnlShortCuts.setHorizontalGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
gl_pnlShortCuts.setHorizontalGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
||||||
|
.addComponent(btnSkipToNextTurn)
|
||||||
|
.addComponent(btnSkipToEndTurn)
|
||||||
|
.addComponent(btnSkipToNextMain)
|
||||||
|
.addComponent(btnSkipToYourTurn)
|
||||||
|
.addComponent(btnSkipStack)
|
||||||
|
)
|
||||||
|
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
||||||
|
.addComponent(txtSpellsCast)
|
||||||
|
.addComponent(btnSwitchHands)
|
||||||
|
.addComponent(btnCancelSkip)
|
||||||
|
.addComponent(btnConcede)
|
||||||
|
.addComponent(btnStopWatching)
|
||||||
|
)
|
||||||
|
//.addComponent(bigCard, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
|
||||||
|
//.addComponent(feedbackPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
|
||||||
|
//.addComponent(stack, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
|
||||||
|
|
||||||
|
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addContainerGap(51, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
gl_pnlShortCuts.setVerticalGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
||||||
|
//.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
//.addGap(1, 1, 1)
|
||||||
|
//.addComponent(feedbackPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
//.addComponent(stack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 164, Short.MAX_VALUE)
|
||||||
|
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(btnSkipToNextTurn)
|
.addComponent(btnSkipToNextTurn)
|
||||||
.addComponent(btnSkipToEndTurn)
|
.addComponent(btnSkipToEndTurn)
|
||||||
.addComponent(btnSkipToNextMain)
|
.addComponent(btnSkipToNextMain)
|
||||||
.addComponent(btnSkipToYourTurn)
|
.addComponent(btnSkipToYourTurn)
|
||||||
.addComponent(btnSkipStack)
|
.addComponent(btnSkipStack)
|
||||||
)
|
)
|
||||||
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
.addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(txtSpellsCast)
|
.addComponent(txtSpellsCast)
|
||||||
.addComponent(btnSwitchHands)
|
.addComponent(btnSwitchHands)
|
||||||
.addComponent(btnCancelSkip)
|
.addComponent(btnCancelSkip)
|
||||||
.addComponent(btnConcede)
|
.addComponent(btnConcede)
|
||||||
.addComponent(btnStopWatching)
|
.addComponent(btnStopWatching)
|
||||||
)
|
)
|
||||||
//.addComponent(bigCard, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
|
)
|
||||||
//.addComponent(feedbackPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
|
|
||||||
//.addComponent(stack, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
|
|
||||||
|
|
||||||
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addContainerGap(51, Short.MAX_VALUE))
|
|
||||||
);
|
|
||||||
gl_pnlShortCuts.setVerticalGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(gl_pnlShortCuts.createSequentialGroup()
|
|
||||||
//.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
//.addGap(1, 1, 1)
|
|
||||||
//.addComponent(feedbackPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
//.addComponent(stack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 164, Short.MAX_VALUE)
|
|
||||||
.addComponent(pnlReplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
|
|
||||||
.addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
|
||||||
.addComponent(btnSkipToNextTurn)
|
|
||||||
.addComponent(btnSkipToEndTurn)
|
|
||||||
.addComponent(btnSkipToNextMain)
|
|
||||||
.addComponent(btnSkipToYourTurn)
|
|
||||||
.addComponent(btnSkipStack)
|
|
||||||
)
|
|
||||||
.addGroup(gl_pnlShortCuts.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
|
||||||
.addComponent(txtSpellsCast)
|
|
||||||
.addComponent(btnSwitchHands)
|
|
||||||
.addComponent(btnCancelSkip)
|
|
||||||
.addComponent(btnConcede)
|
|
||||||
.addComponent(btnStopWatching)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
pnlBattlefield.setLayout(new java.awt.GridBagLayout());
|
pnlBattlefield.setLayout(new java.awt.GridBagLayout());
|
||||||
|
@ -1610,18 +1623,17 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
|
String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
|
||||||
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
|
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
|
||||||
"Main2", "Cleanup", "Next_Turn"};
|
"Main2", "Cleanup", "Next_Turn"};
|
||||||
for (String name : phases) {
|
for (String name : phases) {
|
||||||
createPhaseButton(name, phasesMouseAdapter);
|
createPhaseButton(name, phasesMouseAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : hoverButtons.keySet()) {
|
for (String name : hoverButtons.keySet()) {
|
||||||
HoverButton hoverButton = hoverButtons.get(name);
|
HoverButton hoverButton = hoverButtons.get(name);
|
||||||
hoverButton.setAlignmentX(LEFT_ALIGNMENT);
|
hoverButton.setAlignmentX(LEFT_ALIGNMENT);
|
||||||
hoverButton.setBounds(X_PHASE_WIDTH - 36, i*36, 36, 36);
|
hoverButton.setBounds(X_PHASE_WIDTH - 36, i * 36, 36, 36);
|
||||||
jPhases.add(hoverButton);
|
jPhases.add(hoverButton);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -1648,22 +1660,22 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
javax.swing.GroupLayout gl_jPanel3 = new javax.swing.GroupLayout(jPanel3);
|
javax.swing.GroupLayout gl_jPanel3 = new javax.swing.GroupLayout(jPanel3);
|
||||||
gl_jPanel3.setHorizontalGroup(
|
gl_jPanel3.setHorizontalGroup(
|
||||||
gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
// .addGap(0)
|
// .addGap(0)
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(helper, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
)
|
)
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(pnlShortCuts, 400, 400, 400)
|
.addComponent(pnlShortCuts, 400, 400, 400)
|
||||||
.addComponent(stack, 400, 400, 400)
|
.addComponent(stack, 400, 400, 400)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.addGap(0)
|
.addGap(0)
|
||||||
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
//.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||||
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
@ -1671,24 +1683,24 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
);
|
);
|
||||||
gl_jPanel3.setVerticalGroup(
|
gl_jPanel3.setVerticalGroup(
|
||||||
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
|
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||||
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(phasesContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
)
|
||||||
|
//.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
|
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||||
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
|
.addGap(2)
|
||||||
|
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(stack, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
)
|
)
|
||||||
//.addPreferredGap(ComponentPlacement.RELATED)
|
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(2)
|
|
||||||
.addComponent(pnlShortCuts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addComponent(stack, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
)
|
|
||||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
|
||||||
.addComponent(helper, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
jPanel3.setLayout(gl_jPanel3);
|
jPanel3.setLayout(gl_jPanel3);
|
||||||
|
|
||||||
|
@ -1697,15 +1709,18 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
// Set individual area sizes of big card pane
|
// Set individual area sizes of big card pane
|
||||||
GridBagLayout gbl = new GridBagLayout();
|
GridBagLayout gbl = new GridBagLayout();
|
||||||
jPanel2.setLayout( gbl );
|
jPanel2.setLayout(gbl);
|
||||||
|
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.gridx = 0; gbc.gridy = 0;
|
gbc.gridx = 0;
|
||||||
gbc.gridwidth = 1; gbc.gridheight = 4; // size 4/5
|
gbc.gridy = 0;
|
||||||
gbc.weightx = 1.0; gbc.weighty = 1.0;
|
gbc.gridwidth = 1;
|
||||||
gbl.setConstraints( bigCard, gbc );
|
gbc.gridheight = 4; // size 4/5
|
||||||
jPanel2.add( bigCard );
|
gbc.weightx = 1.0;
|
||||||
|
gbc.weighty = 1.0;
|
||||||
|
gbl.setConstraints(bigCard, gbc);
|
||||||
|
jPanel2.add(bigCard);
|
||||||
|
|
||||||
jPanel2.setOpaque(false);
|
jPanel2.setOpaque(false);
|
||||||
|
|
||||||
|
@ -1717,82 +1732,82 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE)
|
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 1078, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
|
.addComponent(jSplitPane0, javax.swing.GroupLayout.DEFAULT_SIZE, 798, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeListener() {
|
private void removeListener() {
|
||||||
for (MouseListener ml :this.getMouseListeners()) {
|
for (MouseListener ml : this.getMouseListeners()) {
|
||||||
this.removeMouseListener(ml);
|
this.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnCancelSkip.getMouseListeners()) {
|
for (MouseListener ml : this.btnCancelSkip.getMouseListeners()) {
|
||||||
this.btnCancelSkip.removeMouseListener(ml);
|
this.btnCancelSkip.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnConcede.getMouseListeners()) {
|
for (MouseListener ml : this.btnConcede.getMouseListeners()) {
|
||||||
this.btnConcede.removeMouseListener(ml);
|
this.btnConcede.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnSkipToYourTurn.getMouseListeners()) {
|
for (MouseListener ml : this.btnSkipToYourTurn.getMouseListeners()) {
|
||||||
this.btnSkipToYourTurn.removeMouseListener(ml);
|
this.btnSkipToYourTurn.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnSkipStack.getMouseListeners()) {
|
for (MouseListener ml : this.btnSkipStack.getMouseListeners()) {
|
||||||
this.btnSkipStack.removeMouseListener(ml);
|
this.btnSkipStack.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnSkipToEndTurn.getMouseListeners()) {
|
for (MouseListener ml : this.btnSkipToEndTurn.getMouseListeners()) {
|
||||||
this.btnSkipToEndTurn.removeMouseListener(ml);
|
this.btnSkipToEndTurn.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnSkipToNextMain.getMouseListeners()) {
|
for (MouseListener ml : this.btnSkipToNextMain.getMouseListeners()) {
|
||||||
this.btnSkipToNextMain.removeMouseListener(ml);
|
this.btnSkipToNextMain.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnSkipToNextTurn.getMouseListeners()) {
|
for (MouseListener ml : this.btnSkipToNextTurn.getMouseListeners()) {
|
||||||
this.btnSkipToNextTurn.removeMouseListener(ml);
|
this.btnSkipToNextTurn.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnSwitchHands.getMouseListeners()) {
|
for (MouseListener ml : this.btnSwitchHands.getMouseListeners()) {
|
||||||
this.btnSwitchHands.removeMouseListener(ml);
|
this.btnSwitchHands.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.btnStopWatching.getMouseListeners()) {
|
for (MouseListener ml : this.btnStopWatching.getMouseListeners()) {
|
||||||
this.btnStopWatching.removeMouseListener(ml);
|
this.btnStopWatching.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (MouseListener ml :this.jPhases.getMouseListeners()) {
|
for (MouseListener ml : this.jPhases.getMouseListeners()) {
|
||||||
this.jPhases.removeMouseListener(ml);
|
this.jPhases.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
for (String name : hoverButtons.keySet()) {
|
for (String name : hoverButtons.keySet()) {
|
||||||
HoverButton hoverButton = hoverButtons.get(name);
|
HoverButton hoverButton = hoverButtons.get(name);
|
||||||
for (MouseListener ml :hoverButton.getMouseListeners()) {
|
for (MouseListener ml : hoverButton.getMouseListeners()) {
|
||||||
hoverButton.removeMouseListener(ml);
|
hoverButton.removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ActionListener al :this.btnPlay.getActionListeners()) {
|
for (ActionListener al : this.btnPlay.getActionListeners()) {
|
||||||
this.btnPlay.removeActionListener(al);
|
this.btnPlay.removeActionListener(al);
|
||||||
}
|
}
|
||||||
for (ActionListener al :this.btnStopReplay.getActionListeners()) {
|
for (ActionListener al : this.btnStopReplay.getActionListeners()) {
|
||||||
this.btnStopReplay.removeActionListener(al);
|
this.btnStopReplay.removeActionListener(al);
|
||||||
}
|
}
|
||||||
for (ActionListener al :this.btnNextPlay.getActionListeners()) {
|
for (ActionListener al : this.btnNextPlay.getActionListeners()) {
|
||||||
this.btnNextPlay.removeActionListener(al);
|
this.btnNextPlay.removeActionListener(al);
|
||||||
}
|
}
|
||||||
for (ActionListener al :this.btnNextPlay.getActionListeners()) {
|
for (ActionListener al : this.btnNextPlay.getActionListeners()) {
|
||||||
this.btnNextPlay.removeActionListener(al);
|
this.btnNextPlay.removeActionListener(al);
|
||||||
}
|
}
|
||||||
for (ActionListener al :this.btnPreviousPlay.getActionListeners()) {
|
for (ActionListener al : this.btnPreviousPlay.getActionListeners()) {
|
||||||
this.btnPreviousPlay.removeActionListener(al);
|
this.btnPreviousPlay.removeActionListener(al);
|
||||||
}
|
}
|
||||||
for (ActionListener al :this.btnSkipForward.getActionListeners()) {
|
for (ActionListener al : this.btnSkipForward.getActionListeners()) {
|
||||||
this.btnSkipForward.removeActionListener(al);
|
this.btnSkipForward.removeActionListener(al);
|
||||||
}
|
}
|
||||||
|
|
||||||
final BasicSplitPaneUI myUi = (BasicSplitPaneUI) jSplitPane0.getUI();
|
final BasicSplitPaneUI myUi = (BasicSplitPaneUI) jSplitPane0.getUI();
|
||||||
final BasicSplitPaneDivider divider = myUi.getDivider();
|
final BasicSplitPaneDivider divider = myUi.getDivider();
|
||||||
final JButton upArrowButton = (JButton) divider.getComponent(0);
|
final JButton upArrowButton = (JButton) divider.getComponent(0);
|
||||||
for (ActionListener al: upArrowButton.getActionListeners()) {
|
for (ActionListener al : upArrowButton.getActionListeners()) {
|
||||||
upArrowButton.removeActionListener(al);
|
upArrowButton.removeActionListener(al);
|
||||||
}
|
}
|
||||||
final JButton downArrowButton = (JButton) divider.getComponent(1);
|
final JButton downArrowButton = (JButton) divider.getComponent(1);
|
||||||
for (ActionListener al: downArrowButton.getActionListeners()) {
|
for (ActionListener al : downArrowButton.getActionListeners()) {
|
||||||
downArrowButton.removeActionListener(al);
|
downArrowButton.removeActionListener(al);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1853,12 +1868,12 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
String[] choices = handCards.keySet().toArray(new String[0]);
|
String[] choices = handCards.keySet().toArray(new String[0]);
|
||||||
|
|
||||||
String newChosenHandKey = (String) JOptionPane.showInputDialog(
|
String newChosenHandKey = (String) JOptionPane.showInputDialog(
|
||||||
this,
|
this,
|
||||||
"Choose hand to display:", "Switch between hands",
|
"Choose hand to display:", "Switch between hands",
|
||||||
JOptionPane.PLAIN_MESSAGE,
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
null,
|
null,
|
||||||
choices,
|
choices,
|
||||||
this.chosenHandKey);
|
this.chosenHandKey);
|
||||||
|
|
||||||
if (newChosenHandKey != null && newChosenHandKey.length() > 0) {
|
if (newChosenHandKey != null && newChosenHandKey.length() > 0) {
|
||||||
this.chosenHandKey = newChosenHandKey;
|
this.chosenHandKey = newChosenHandKey;
|
||||||
|
@ -1877,8 +1892,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
private void btnStopReplayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopReplayActionPerformed
|
private void btnStopReplayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopReplayActionPerformed
|
||||||
if (replayTask != null && !replayTask.isDone()) {
|
if (replayTask != null && !replayTask.isDone()) {
|
||||||
replayTask.cancel(true);
|
replayTask.cancel(true);
|
||||||
}
|
} else if (modalQuestion("Are you sure you want to stop replay?", "Stop replay") == JOptionPane.YES_OPTION) {
|
||||||
else if (modalQuestion("Are you sure you want to stop replay?", "Stop replay") == JOptionPane.YES_OPTION) {
|
|
||||||
session.stopReplay(gameId);
|
session.stopReplay(gameId);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnStopReplayActionPerformed
|
}//GEN-LAST:event_btnStopReplayActionPerformed
|
||||||
|
@ -2003,6 +2017,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
private boolean imagePanelState;
|
private boolean imagePanelState;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
|
|
||||||
private final Session session;
|
private final Session session;
|
||||||
|
@ -2032,8 +2047,8 @@ class ReplayTask extends SwingWorker<Void, Collection<MatchView>> {
|
||||||
logger.fatal("Replay Match Task error", ex);
|
logger.fatal("Replay Match Task error", ex);
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
logger.fatal("Replay Match Task error", ex);
|
logger.fatal("Replay Match Task error", ex);
|
||||||
} catch (CancellationException ex) {}
|
} catch (CancellationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,36 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PlayerPanel.java
|
* PlayerPanel.java
|
||||||
*
|
*
|
||||||
* Created on Nov 18, 2009, 3:01:31 PM
|
* Created on Nov 18, 2009, 3:01:31 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
@ -57,18 +56,13 @@ import javax.swing.SwingConstants;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.MageCard;
|
|
||||||
import mage.cards.action.ActionCallback;
|
|
||||||
import mage.cards.decks.importer.DckDeckImporter;
|
import mage.cards.decks.importer.DckDeckImporter;
|
||||||
import mage.cards.repository.CardRepository;
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.components.HoverButton;
|
import mage.client.components.HoverButton;
|
||||||
import mage.client.components.MageRoundPane;
|
import mage.client.components.MageRoundPane;
|
||||||
import mage.client.components.ext.dlg.DialogManager;
|
import mage.client.components.ext.dlg.DialogManager;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.plugins.adapters.MageActionCallback;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
|
||||||
import mage.client.util.CardsViewUtil;
|
import mage.client.util.CardsViewUtil;
|
||||||
import mage.client.util.Command;
|
import mage.client.util.Command;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
|
@ -77,7 +71,6 @@ import mage.components.ImagePanel;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.utils.timer.PriorityTimer;
|
import mage.utils.timer.PriorityTimer;
|
||||||
import mage.view.CardView;
|
|
||||||
import mage.view.ManaPoolView;
|
import mage.view.ManaPoolView;
|
||||||
import mage.view.PlayerView;
|
import mage.view.PlayerView;
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
|
@ -105,18 +98,17 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
private static final int PANEL_HEIGHT_SMALL = 212;
|
private static final int PANEL_HEIGHT_SMALL = 212;
|
||||||
private static final int MANA_LABEL_SIZE_HORIZONTAL = 20;
|
private static final int MANA_LABEL_SIZE_HORIZONTAL = 20;
|
||||||
|
|
||||||
|
|
||||||
private static final Border greenBorder = new LineBorder(Color.green, 3);
|
private static final Border greenBorder = new LineBorder(Color.green, 3);
|
||||||
private static final Border redBorder = new LineBorder(Color.red, 2);
|
private static final Border redBorder = new LineBorder(Color.red, 2);
|
||||||
private static final Border emptyBorder = BorderFactory.createEmptyBorder(0,0,0,0);
|
private static final Border emptyBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0);
|
||||||
|
|
||||||
private static final Dimension topCardDimension = new Dimension(40, 56);
|
|
||||||
|
|
||||||
private int avatarId = -1;
|
private int avatarId = -1;
|
||||||
|
|
||||||
private PriorityTimer timer;
|
private PriorityTimer timer;
|
||||||
|
|
||||||
/** Creates new form PlayerPanel */
|
/**
|
||||||
|
* Creates new form PlayerPanel
|
||||||
|
*/
|
||||||
public PlayerPanelExt() {
|
public PlayerPanelExt() {
|
||||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||||
initComponents();
|
initComponents();
|
||||||
|
@ -158,7 +150,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
if (timer != null) {
|
if (timer != null) {
|
||||||
this.timer.cancel();
|
this.timer.cancel();
|
||||||
}
|
}
|
||||||
topCardPanel.updateCallback(null, gameId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(PlayerView player) {
|
public void update(PlayerView player) {
|
||||||
|
@ -272,26 +263,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
this.btnPlayer.setBorder(emptyBorder);
|
this.btnPlayer.setBorder(emptyBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (player.getTopCard() != null) {
|
|
||||||
if (topCard == null || !topCard.getId().equals(player.getTopCard().getId())) {
|
|
||||||
if (topCard == null) {
|
|
||||||
topCardPanel.setVisible(true);
|
|
||||||
}
|
|
||||||
topCard = player.getTopCard();
|
|
||||||
topCardPanel.update(topCard);
|
|
||||||
topCardPanel.updateImage();
|
|
||||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
|
||||||
((MageActionCallback)callback).refreshSession();
|
|
||||||
topCardPanel.updateCallback(callback, gameId);
|
|
||||||
}
|
|
||||||
} else if (topCard != null) {
|
|
||||||
topCard = null;
|
|
||||||
topCardPanel.setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update(player.getManaPool());
|
update(player.getManaPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +275,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
int h = priorityTimeLeft / 3600;
|
int h = priorityTimeLeft / 3600;
|
||||||
int m = (priorityTimeLeft % 3600) / 60;
|
int m = (priorityTimeLeft % 3600) / 60;
|
||||||
int s = priorityTimeLeft % 60;
|
int s = priorityTimeLeft % 60;
|
||||||
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
|
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void update(ManaPoolView pool) {
|
protected void update(ManaPoolView pool) {
|
||||||
|
@ -316,10 +287,10 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
manaLabels.get("X").setText(Integer.toString(pool.getColorless()));
|
manaLabels.get("X").setText(Integer.toString(pool.getColorless()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
@ -331,6 +302,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
lifeLabel = new JLabel();
|
lifeLabel = new JLabel();
|
||||||
handLabel = new JLabel();
|
handLabel = new JLabel();
|
||||||
poisonLabel = new JLabel();
|
poisonLabel = new JLabel();
|
||||||
|
graveLabel = new JLabel();
|
||||||
libraryLabel = new JLabel();
|
libraryLabel = new JLabel();
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
|
|
||||||
|
@ -341,10 +313,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
// Avatar
|
// Avatar
|
||||||
Image image = ImageHelper.getImageFromResources(DEFAULT_AVATAR_PATH);
|
Image image = ImageHelper.getImageFromResources(DEFAULT_AVATAR_PATH);
|
||||||
|
|
||||||
topCardPanel = Plugins.getInstance().getMageCard(new CardView(CardRepository.instance.findCard("Forest").getMockCard()), bigCard, topCardDimension, gameId, true);
|
|
||||||
topCardPanel.setVisible(false);
|
|
||||||
panelBackground.add(topCardPanel);
|
|
||||||
|
|
||||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||||
avatar = new HoverButton("player", resized, resized, resized, r);
|
avatar = new HoverButton("player", resized, resized, resized, r);
|
||||||
String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
|
String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
|
||||||
|
@ -360,7 +328,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
// timer area /small layout)
|
// timer area /small layout)
|
||||||
timerLabel.setToolTipText("Time left");
|
timerLabel.setToolTipText("Time left");
|
||||||
timerLabel.setSize(80,12);
|
timerLabel.setSize(80, 12);
|
||||||
timerLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
timerLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
// life area
|
// life area
|
||||||
|
@ -395,16 +363,23 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
libraryLabel.setToolTipText("Library");
|
libraryLabel.setToolTipText("Library");
|
||||||
Image imageLibrary = ImageHelper.getImageFromResources("/info/library.png");
|
Image imageLibrary = ImageHelper.getImageFromResources("/info/library.png");
|
||||||
BufferedImage resizedLibrary = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLibrary, BufferedImage.TYPE_INT_ARGB), r);
|
BufferedImage resizedLibrary = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLibrary, BufferedImage.TYPE_INT_ARGB), r);
|
||||||
library = new ImagePanel(resizedLibrary, ImagePanel.ACTUAL);
|
|
||||||
|
library = new HoverButton(null, resizedLibrary, resizedLibrary, resizedLibrary, r);
|
||||||
library.setToolTipText("Library");
|
library.setToolTipText("Library");
|
||||||
library.setOpaque(false);
|
library.setOpaque(false);
|
||||||
|
library.setObserver(new Command() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
btnLibraryActionPerformed(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Grave count and open graveyard button
|
// Grave count and open graveyard button
|
||||||
graveLabel = new JLabel();
|
|
||||||
r = new Rectangle(21, 21);
|
r = new Rectangle(21, 21);
|
||||||
graveLabel.setToolTipText("Graveyard");
|
graveLabel.setToolTipText("Graveyard");
|
||||||
Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png");
|
Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png");
|
||||||
BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r);
|
BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r);
|
||||||
|
|
||||||
grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r);
|
grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r);
|
||||||
grave.setToolTipText("Graveyard");
|
grave.setToolTipText("Graveyard");
|
||||||
grave.setOpaque(false);
|
grave.setOpaque(false);
|
||||||
|
@ -579,195 +554,192 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
|
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
|
||||||
gl_panelBackground.setHorizontalGroup(
|
gl_panelBackground.setHorizontalGroup(
|
||||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(9)
|
.addGap(9)
|
||||||
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
|
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(3)
|
.addGap(3)
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(18)
|
.addGap(18)
|
||||||
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(4)
|
.addGap(4)
|
||||||
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(9)
|
.addGap(9)
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(3)
|
||||||
|
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(2)
|
||||||
|
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(2)
|
||||||
|
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(2)
|
||||||
|
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
|
||||||
|
)
|
||||||
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(3)
|
.addGap(18)
|
||||||
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
|
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(2)
|
.addGap(20)
|
||||||
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(2)
|
.addGap(1)
|
||||||
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)))
|
||||||
|
.addGap(3)
|
||||||
|
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(1)
|
||||||
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
|
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(2)
|
.addGap(19)
|
||||||
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)))
|
||||||
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
|
.addGap(5)
|
||||||
|
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(20)
|
||||||
|
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(40)
|
||||||
|
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(40)
|
||||||
|
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
||||||
|
/*.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(18)
|
||||||
|
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))*/
|
||||||
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(18)
|
||||||
|
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
|
||||||
)
|
)
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(5)
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGap(18)
|
.addGap(40)
|
||||||
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(1)
|
||||||
.addGap(20)
|
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))))
|
||||||
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(6)
|
||||||
.addGap(1)
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)))
|
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGap(3)
|
.addComponent(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
|
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(14))
|
||||||
.addGap(1)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGap(6)
|
||||||
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)
|
.addComponent(zonesPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(14))
|
||||||
.addGap(19)
|
|
||||||
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)))
|
|
||||||
.addGap(5)
|
|
||||||
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(20)
|
|
||||||
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(40)
|
|
||||||
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(40)
|
|
||||||
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
|
||||||
/*.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(18)
|
|
||||||
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))*/
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(18)
|
|
||||||
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
|
|
||||||
)
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(5)
|
|
||||||
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(40)
|
|
||||||
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(1)
|
|
||||||
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))))
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(6)
|
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
|
||||||
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
|
||||||
.addGap(14))
|
|
||||||
|
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
|
||||||
.addGap(6)
|
|
||||||
.addComponent(zonesPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addGap(14))
|
|
||||||
);
|
);
|
||||||
gl_panelBackground.setVerticalGroup(
|
gl_panelBackground.setVerticalGroup(
|
||||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGap(6)
|
||||||
.addGap(6)
|
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
.addComponent(btnPlayer)
|
||||||
.addComponent(btnPlayer)
|
.addComponent(timerLabel)
|
||||||
.addComponent(timerLabel)
|
.addGap(1)
|
||||||
.addGap(1)
|
// Life & Hand
|
||||||
// Life & Hand
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(1)
|
||||||
.addGap(1)
|
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(1)
|
||||||
.addGap(1)
|
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
.addGap(1)
|
||||||
.addGap(1)
|
// Poison
|
||||||
// Poison
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGap(4)
|
||||||
.addGap(4)
|
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
|
.addGap(4)
|
||||||
.addGap(4)
|
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
.addGap(2)
|
||||||
.addGap(2)
|
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
.addGap(2)
|
||||||
.addGap(2)
|
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
.addGap(5)
|
||||||
.addGap(5)
|
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
|
)
|
||||||
)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGap(1)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(1)
|
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||||
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
.addGap(2)
|
||||||
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(2)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
.addGap(14)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(14)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
.addGap(14)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||||
.addGap(14)
|
.addGap(4)
|
||||||
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||||
.addGap(4)
|
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
.addGap(8)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(8)
|
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||||
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
.addGap(39)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(39)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
.addGap(31)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(31)
|
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
/*.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
.addGap(76)
|
||||||
/*.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))*/
|
||||||
.addGap(76)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))*/
|
.addGap(76)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(76)
|
)
|
||||||
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
)
|
.addGap(76)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(76)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
.addGap(76)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||||
.addGap(76)
|
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||||
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
.addGap(31)
|
||||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(31)
|
|
||||||
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
|
||||||
.addComponent(zonesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
)
|
)
|
||||||
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
|
.addComponent(zonesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
panelBackground.setLayout(gl_panelBackground);
|
panelBackground.setLayout(gl_panelBackground);
|
||||||
GroupLayout groupLayout = new GroupLayout(this);
|
GroupLayout groupLayout = new GroupLayout(this);
|
||||||
groupLayout.setHorizontalGroup(
|
groupLayout.setHorizontalGroup(
|
||||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(groupLayout.createSequentialGroup()
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
);
|
);
|
||||||
groupLayout.setVerticalGroup(
|
groupLayout.setVerticalGroup(
|
||||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(groupLayout.createSequentialGroup()
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
);
|
);
|
||||||
setLayout(groupLayout);
|
setLayout(groupLayout);
|
||||||
|
|
||||||
|
@ -780,8 +752,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
timerLabel.setVisible(true);
|
timerLabel.setVisible(true);
|
||||||
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL));
|
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL));
|
||||||
panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL);
|
panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
avatar.setVisible(true);
|
avatar.setVisible(true);
|
||||||
btnPlayer.setVisible(false);
|
btnPlayer.setVisible(false);
|
||||||
timerLabel.setVisible(false);
|
timerLabel.setVisible(false);
|
||||||
|
@ -794,13 +765,12 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
session.sendPlayerManaType(gameId, player.getPlayerId(), manaType);
|
session.sendPlayerManaType(gameId, player.getPlayerId(), manaType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
MageFrame.getGame(gameId).openGraveyardWindow(player.getName());
|
MageFrame.getGame(gameId).openGraveyardWindow(player.getName());
|
||||||
/*if (graveyard == null) {
|
}
|
||||||
graveyard = new ShowCardsDialog();
|
|
||||||
}*/
|
private void btnLibraryActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
//graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
|
MageFrame.getGame(gameId).openTopLibraryWindow(player.getName());
|
||||||
// DialogManager.getManager(gameId).showGraveyardDialog(player.getGraveyard(), bigCard, gameId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
@ -826,9 +796,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
private ImagePanel poison;
|
private ImagePanel poison;
|
||||||
private ImagePanel hand;
|
private ImagePanel hand;
|
||||||
private HoverButton grave;
|
private HoverButton grave;
|
||||||
private ImagePanel library;
|
private HoverButton library;
|
||||||
private CardView topCard;
|
|
||||||
private MageCard topCardPanel;
|
|
||||||
private JButton cheat;
|
private JButton cheat;
|
||||||
private MageRoundPane panelBackground;
|
private MageRoundPane panelBackground;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
package mage.client.util.gui;
|
package mage.client.util.gui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import mage.client.MageFrame;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.MageObjectType;
|
import mage.constants.MageObjectType;
|
||||||
|
import mage.constants.Rarity;
|
||||||
import mage.utils.CardUtil;
|
import mage.utils.CardUtil;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CounterView;
|
import mage.view.CounterView;
|
||||||
|
@ -10,12 +24,8 @@ import org.jdesktop.swingx.JXPanel;
|
||||||
import org.mage.card.arcane.ManaSymbols;
|
import org.mage.card.arcane.ManaSymbols;
|
||||||
import org.mage.card.arcane.UI;
|
import org.mage.card.arcane.UI;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
|
|
||||||
public class GuiDisplayUtil {
|
public class GuiDisplayUtil {
|
||||||
|
|
||||||
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
|
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
|
||||||
private static final Insets DEFAULT_INSETS = new Insets(0, 0, 70, 25);
|
private static final Insets DEFAULT_INSETS = new Insets(0, 0, 70, 25);
|
||||||
private static final Insets COMPONENT_INSETS = new Insets(0, 0, 40, 40);
|
private static final Insets COMPONENT_INSETS = new Insets(0, 0, 40, 40);
|
||||||
|
@ -30,19 +40,18 @@ public class GuiDisplayUtil {
|
||||||
JXPanel descriptionPanel = new JXPanel();
|
JXPanel descriptionPanel = new JXPanel();
|
||||||
|
|
||||||
//descriptionPanel.setAlpha(.8f);
|
//descriptionPanel.setAlpha(.8f);
|
||||||
descriptionPanel.setBounds(0, 0, width, height);
|
descriptionPanel.setBounds(0, 0, width, height);
|
||||||
descriptionPanel.setVisible(false);
|
descriptionPanel.setVisible(false);
|
||||||
descriptionPanel.setLayout(null);
|
descriptionPanel.setLayout(null);
|
||||||
|
|
||||||
//descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));
|
//descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||||
|
|
||||||
JButton j = new JButton("");
|
JButton j = new JButton("");
|
||||||
j.setBounds(0, 0, width, height);
|
j.setBounds(0, 0, width, height);
|
||||||
j.setBackground(Color.black);
|
j.setBackground(Color.black);
|
||||||
j.setLayout(null);
|
j.setLayout(null);
|
||||||
|
|
||||||
JLabel cardText = new JLabel();
|
JLabel cardText = new JLabel();
|
||||||
cardText.setBounds(5, 5, width - 10, height - 10);
|
cardText.setBounds(5, 5, width - 10, height - 10);
|
||||||
cardText.setForeground(Color.white);
|
cardText.setForeground(Color.white);
|
||||||
cardText.setFont(cardNameFont);
|
cardText.setFont(cardNameFont);
|
||||||
cardText.setVerticalAlignment(SwingConstants.TOP);
|
cardText.setVerticalAlignment(SwingConstants.TOP);
|
||||||
|
@ -70,36 +79,52 @@ public class GuiDisplayUtil {
|
||||||
return out.toString().toLowerCase();
|
return out.toString().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void keepComponentInsideScreen(int centerX, int centerY, Component component) {
|
||||||
|
Dimension screenDim = component.getToolkit().getScreenSize();
|
||||||
|
GraphicsConfiguration g = component.getGraphicsConfiguration();
|
||||||
|
|
||||||
public static void keepComponentInsideScreen(int x, int y, Component c) {
|
|
||||||
Dimension screenDim = c.getToolkit().getScreenSize();
|
|
||||||
GraphicsConfiguration g = c.getGraphicsConfiguration();
|
|
||||||
if (g != null) {
|
if (g != null) {
|
||||||
Insets insets = c.getToolkit().getScreenInsets(g);
|
Insets insets = component.getToolkit().getScreenInsets(g); // no usable space like toolbar
|
||||||
boolean setLocation = false;
|
boolean setLocation = false;
|
||||||
if (x + c.getWidth() > screenDim.width - insets.right) {
|
if (centerX + component.getWidth() > screenDim.width - insets.right) {
|
||||||
x = (screenDim.width - insets.right) - c.getWidth();
|
centerX = (screenDim.width - insets.right) - component.getWidth();
|
||||||
setLocation = true;
|
setLocation = true;
|
||||||
} else if (x < insets.left) {
|
} else if (centerX < insets.left) {
|
||||||
x = insets.left;
|
centerX = insets.left;
|
||||||
setLocation = true;
|
setLocation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y + c.getHeight() > screenDim.height - insets.bottom) {
|
if (centerY + component.getHeight() > screenDim.height - insets.bottom) {
|
||||||
y = (screenDim.height - insets.bottom) - c.getHeight();
|
centerY = (screenDim.height - insets.bottom) - component.getHeight();
|
||||||
setLocation = true;
|
setLocation = true;
|
||||||
} else if (y < insets.top) {
|
} else if (centerY < insets.top) {
|
||||||
y = insets.top;
|
centerY = insets.top;
|
||||||
setLocation = true;
|
setLocation = true;
|
||||||
}
|
}
|
||||||
if (setLocation) {
|
if (setLocation) {
|
||||||
c.setLocation(x, y);
|
component.setLocation(centerX, centerY);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("GuiDisplayUtil::keepComponentInsideScreen -> no GraphicsConfiguration");
|
System.out.println("GuiDisplayUtil::keepComponentInsideScreen -> no GraphicsConfiguration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final int OVERLAP_LIMIT = 10;
|
||||||
|
|
||||||
|
public static void keepComponentInsideFrame(int centerX, int centerY, Component component) {
|
||||||
|
Rectangle frameRec = MageFrame.getInstance().getBounds();
|
||||||
|
boolean setLocation = false;
|
||||||
|
if (component.getX() > (frameRec.width - OVERLAP_LIMIT)) {
|
||||||
|
setLocation = true;
|
||||||
|
}
|
||||||
|
if (component.getY() > (frameRec.height - OVERLAP_LIMIT)) {
|
||||||
|
setLocation = true;
|
||||||
|
}
|
||||||
|
if (setLocation) {
|
||||||
|
component.setLocation(centerX, centerY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Point keepComponentInsideParent(Point l, Point parentPoint, Component c, Component parent) {
|
public static Point keepComponentInsideParent(Point l, Point parentPoint, Component c, Component parent) {
|
||||||
int dx = parentPoint.x + parent.getWidth() - DEFAULT_INSETS.right - COMPONENT_INSETS.right;
|
int dx = parentPoint.x + parent.getWidth() - DEFAULT_INSETS.right - COMPONENT_INSETS.right;
|
||||||
if (l.x + c.getWidth() > dx) {
|
if (l.x + c.getWidth() > dx) {
|
||||||
|
@ -117,8 +142,8 @@ public class GuiDisplayUtil {
|
||||||
public static TextLines getTextLinesfromCardView(CardView card) {
|
public static TextLines getTextLinesfromCardView(CardView card) {
|
||||||
TextLines textLines = new TextLines();
|
TextLines textLines = new TextLines();
|
||||||
textLines.lines = new ArrayList<>(card.getRules());
|
textLines.lines = new ArrayList<>(card.getRules());
|
||||||
for (String rule: card.getRules()) {
|
for (String rule : card.getRules()) {
|
||||||
textLines.basicTextLength +=rule.length();
|
textLines.basicTextLength += rule.length();
|
||||||
}
|
}
|
||||||
if (card.getMageObjectType().equals(MageObjectType.PERMANENT)) {
|
if (card.getMageObjectType().equals(MageObjectType.PERMANENT)) {
|
||||||
if (card.getPairedCard() != null) {
|
if (card.getPairedCard() != null) {
|
||||||
|
@ -156,7 +181,7 @@ public class GuiDisplayUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (card.getMageObjectType().isPermanent() && card instanceof PermanentView) {
|
if (card.getMageObjectType().isPermanent() && card instanceof PermanentView) {
|
||||||
int damage = ((PermanentView)card).getDamage();
|
int damage = ((PermanentView) card).getDamage();
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
textLines.lines.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
textLines.lines.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
|
||||||
textLines.basicTextLength += 50;
|
textLines.basicTextLength += 50;
|
||||||
|
@ -183,10 +208,10 @@ public class GuiDisplayUtil {
|
||||||
|
|
||||||
String fontFamily = "tahoma";
|
String fontFamily = "tahoma";
|
||||||
/*if (prefs.fontFamily == CardFontFamily.arial)
|
/*if (prefs.fontFamily == CardFontFamily.arial)
|
||||||
fontFamily = "arial";
|
fontFamily = "arial";
|
||||||
else if (prefs.fontFamily == CardFontFamily.verdana) {
|
else if (prefs.fontFamily == CardFontFamily.verdana) {
|
||||||
fontFamily = "verdana";
|
fontFamily = "verdana";
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
final StringBuilder buffer = new StringBuilder(512);
|
final StringBuilder buffer = new StringBuilder(512);
|
||||||
buffer.append("<html><body style='font-family:");
|
buffer.append("<html><body style='font-family:");
|
||||||
|
@ -198,7 +223,7 @@ public class GuiDisplayUtil {
|
||||||
buffer.append("<tr><td valign='top'><b>");
|
buffer.append("<tr><td valign='top'><b>");
|
||||||
buffer.append(card.getDisplayName());
|
buffer.append(card.getDisplayName());
|
||||||
if (card.isGameObject()) {
|
if (card.isGameObject()) {
|
||||||
buffer.append(" [").append(card.getId().toString().substring(0,3)).append("]");
|
buffer.append(" [").append(card.getId().toString().substring(0, 3)).append("]");
|
||||||
}
|
}
|
||||||
buffer.append("</b></td><td align='right' valign='top' style='width:");
|
buffer.append("</b></td><td align='right' valign='top' style='width:");
|
||||||
buffer.append(symbolCount * 11 + 1);
|
buffer.append(symbolCount * 11 + 1);
|
||||||
|
@ -208,31 +233,31 @@ public class GuiDisplayUtil {
|
||||||
}
|
}
|
||||||
buffer.append("</td></tr></table>");
|
buffer.append("</td></tr></table>");
|
||||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'><tr><td style='margin-left: 1px'>");
|
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'><tr><td style='margin-left: 1px'>");
|
||||||
if(card.getColor().isWhite()) {
|
if (card.getColor().isWhite()) {
|
||||||
buffer.append("<img src='").append(getResourcePath("card/color_ind_white.png")).append("' alt='W'>");
|
buffer.append("<img src='").append(getResourcePath("card/color_ind_white.png")).append("' alt='W'>");
|
||||||
}
|
}
|
||||||
if(card.getColor().isBlue()) {
|
if (card.getColor().isBlue()) {
|
||||||
buffer.append("<img src='").append(getResourcePath("card/color_ind_blue.png")).append("' alt='U'>");
|
buffer.append("<img src='").append(getResourcePath("card/color_ind_blue.png")).append("' alt='U'>");
|
||||||
}
|
}
|
||||||
if(card.getColor().isBlack()) {
|
if (card.getColor().isBlack()) {
|
||||||
buffer.append("<img src='").append(getResourcePath("card/color_ind_black.png")).append("' alt='B'>");
|
buffer.append("<img src='").append(getResourcePath("card/color_ind_black.png")).append("' alt='B'>");
|
||||||
}
|
}
|
||||||
if(card.getColor().isRed()) {
|
if (card.getColor().isRed()) {
|
||||||
buffer.append("<img src='").append(getResourcePath("card/color_ind_red.png")).append("' alt='R'>");
|
buffer.append("<img src='").append(getResourcePath("card/color_ind_red.png")).append("' alt='R'>");
|
||||||
}
|
}
|
||||||
if(card.getColor().isGreen()) {
|
if (card.getColor().isGreen()) {
|
||||||
buffer.append("<img src='").append(getResourcePath("card/color_ind_green.png")).append("' alt='G'>");
|
buffer.append("<img src='").append(getResourcePath("card/color_ind_green.png")).append("' alt='G'>");
|
||||||
}
|
}
|
||||||
if(!card.getColor().isColorless()) {
|
if (!card.getColor().isColorless()) {
|
||||||
buffer.append(" ");
|
buffer.append(" ");
|
||||||
}
|
}
|
||||||
buffer.append(getTypes(card));
|
buffer.append(getTypes(card));
|
||||||
buffer.append("</td><td align='right'>");
|
buffer.append("</td><td align='right'>");
|
||||||
String rarity ;
|
String rarity;
|
||||||
if (card.getRarity() == null) {
|
if (card.getRarity() == null) {
|
||||||
rarity = Rarity.COMMON.getCode();
|
rarity = Rarity.COMMON.getCode();
|
||||||
buffer.append("<b color='black'>");
|
buffer.append("<b color='black'>");
|
||||||
}else {
|
} else {
|
||||||
switch (card.getRarity()) {
|
switch (card.getRarity()) {
|
||||||
case RARE:
|
case RARE:
|
||||||
buffer.append("<b color='#FFBF00'>");
|
buffer.append("<b color='#FFBF00'>");
|
||||||
|
@ -319,8 +344,8 @@ public class GuiDisplayUtil {
|
||||||
// legal = legal.replaceAll("#([^#]+)#", "<i>$1</i>");
|
// legal = legal.replaceAll("#([^#]+)#", "<i>$1</i>");
|
||||||
// legal = legal.replaceAll("\\s*//\\s*", "<hr width='50%'>");
|
// legal = legal.replaceAll("\\s*//\\s*", "<hr width='50%'>");
|
||||||
// legal = legal.replace("\r\n", "<div style='font-size:5pt'></div>");
|
// legal = legal.replace("\r\n", "<div style='font-size:5pt'></div>");
|
||||||
legal = legal.replaceAll("\\{this\\}", card.getName().isEmpty() ? "this":card.getName());
|
legal = legal.replaceAll("\\{this\\}", card.getName().isEmpty() ? "this" : card.getName());
|
||||||
legal = legal.replaceAll("\\{source\\}", card.getName().isEmpty() ? "this":card.getName());
|
legal = legal.replaceAll("\\{source\\}", card.getName().isEmpty() ? "this" : card.getName());
|
||||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.CARD));
|
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.CARD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ import mage.util.CardUtil;
|
||||||
public class DaxosOfMeletis extends CardImpl {
|
public class DaxosOfMeletis extends CardImpl {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 3 or greater");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with power 3 or greater");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 2));
|
filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 2));
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,7 @@ class DaxosOfMeletisEffect extends OneShotEffect {
|
||||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
// move card to exile
|
// move card to exile
|
||||||
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
||||||
// player gains life
|
// player gains life
|
||||||
int cmc = card.getManaCost().convertedManaCost();
|
int cmc = card.getManaCost().convertedManaCost();
|
||||||
if (cmc > 0) {
|
if (cmc > 0) {
|
||||||
|
@ -172,7 +173,7 @@ class DaxosOfMeletisCastFromExileEffect extends AsThoughEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
if (sourceId.equals(cardId)) {
|
if (sourceId.equals(cardId) && source.getControllerId().equals(affectedControllerId)) {
|
||||||
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
|
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
|
||||||
return exileZone != null && exileZone.contains(cardId);
|
return exileZone != null && exileZone.contains(cardId);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +203,10 @@ class DaxosOfMeletisSpendAnyManaEffect extends AsThoughEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||||
return sourceId.equals(getTargetPointer().getFirst(game, source));
|
return source.getControllerId().equals(affectedControllerId)
|
||||||
|
&& objectId == ((FixedTarget) getTargetPointer()).getTarget()
|
||||||
|
&& ((FixedTarget) getTargetPointer()).getZoneChangeCounter() + 1 == game.getState().getZoneChangeCounter(objectId)
|
||||||
|
&& game.getState().getZone(objectId).equals(Zone.STACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
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.players.PlayerList;
|
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.common.TargetNonlandPermanent;
|
import mage.target.common.TargetNonlandPermanent;
|
||||||
|
|
||||||
|
@ -58,7 +57,6 @@ public class CouncilsJudgment extends CardImpl {
|
||||||
super(ownerId, 20, "Council's Judgment", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{W}{W}");
|
super(ownerId, 20, "Council's Judgment", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{W}{W}");
|
||||||
this.expansionSetCode = "VMA";
|
this.expansionSetCode = "VMA";
|
||||||
|
|
||||||
|
|
||||||
// Will of the council - Starting with you, each player votes for a nonland permanent you don't control. Exile each permanent with the most votes or tied for most votes.
|
// Will of the council - Starting with you, each player votes for a nonland permanent you don't control. Exile each permanent with the most votes or tied for most votes.
|
||||||
this.getSpellAbility().addEffect(new CouncilsJudgmentEffect());
|
this.getSpellAbility().addEffect(new CouncilsJudgmentEffect());
|
||||||
}
|
}
|
||||||
|
@ -98,13 +96,9 @@ class CouncilsJudgmentEffect extends OneShotEffect {
|
||||||
FilterNonlandPermanent filter = new FilterNonlandPermanent("a nonland permanent " + controller.getLogName() + " doesn't control");
|
FilterNonlandPermanent filter = new FilterNonlandPermanent("a nonland permanent " + controller.getLogName() + " doesn't control");
|
||||||
filter.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
|
filter.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
|
||||||
//Players each choose a legal permanent
|
//Players each choose a legal permanent
|
||||||
PlayerList playerList = game.getState().getPlayerList().copy();
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
while (!playerList.get().equals(controller.getId()) && controller.isInGame()) {
|
Player player = game.getPlayer(playerId);
|
||||||
playerList.getNext();
|
if (player != null) {
|
||||||
}
|
|
||||||
do {
|
|
||||||
Player player = game.getPlayer(playerList.get());
|
|
||||||
if (player != null && player.isInGame()) {
|
|
||||||
Target target = new TargetNonlandPermanent(filter);
|
Target target = new TargetNonlandPermanent(filter);
|
||||||
target.setNotTarget(true);
|
target.setNotTarget(true);
|
||||||
if (player.choose(Outcome.Exile, target, source.getSourceId(), game)) {
|
if (player.choose(Outcome.Exile, target, source.getSourceId(), game)) {
|
||||||
|
@ -116,8 +110,7 @@ class CouncilsJudgmentEffect extends OneShotEffect {
|
||||||
maxCount = count;
|
maxCount = count;
|
||||||
}
|
}
|
||||||
chosenCards.put(permanent, count);
|
chosenCards.put(permanent, count);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (maxCount == 0) {
|
if (maxCount == 0) {
|
||||||
maxCount = 1;
|
maxCount = 1;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +120,8 @@ class CouncilsJudgmentEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (playerList.getNextInRange(controller, game) != controller && controller.isInGame());
|
}
|
||||||
|
|
||||||
//Exile the card(s) with the most votes.
|
//Exile the card(s) with the most votes.
|
||||||
for (Entry<Permanent, Integer> entry : chosenCards.entrySet()) {
|
for (Entry<Permanent, Integer> entry : chosenCards.entrySet()) {
|
||||||
if (entry.getValue() == maxCount) {
|
if (entry.getValue() == maxCount) {
|
||||||
|
|
|
@ -84,21 +84,21 @@ class PleaForPowerEffect extends OneShotEffect {
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int timeCount = 0;
|
int timeCount = 0;
|
||||||
int knowledgeCount = 0;
|
int knowledgeCount = 0;
|
||||||
for (UUID playerId : controller.getInRange()) {
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player.chooseUse(Outcome.ExtraTurn, "Choose time?", game)) {
|
if (player != null) {
|
||||||
timeCount++;
|
if (player.chooseUse(Outcome.ExtraTurn, "Choose time?", game)) {
|
||||||
game.informPlayers(player.getLogName() + " has chosen: time");
|
timeCount++;
|
||||||
}
|
game.informPlayers(player.getLogName() + " has chosen: time");
|
||||||
else {
|
} else {
|
||||||
knowledgeCount++;
|
knowledgeCount++;
|
||||||
game.informPlayers(player.getLogName() + " has chosen: knowledge");
|
game.informPlayers(player.getLogName() + " has chosen: knowledge");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timeCount > knowledgeCount) {
|
if (timeCount > knowledgeCount) {
|
||||||
new AddExtraTurnControllerEffect().apply(game, source);
|
new AddExtraTurnControllerEffect().apply(game, source);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
controller.drawCards(3, game);
|
controller.drawCards(3, game);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -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 org.mage.test.cards.mana;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class SpendManaAsThoughItWereManaOfAnyColorTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDaxosOfMeletis() {
|
||||||
|
// Put two 2/2 black Zombie creature tokens onto the battlefield.
|
||||||
|
// Flashback (You may cast this card from your graveyard for its flashback cost. Then exile it.)
|
||||||
|
addCard(Zone.LIBRARY, playerA, "Moan of the Unhallowed", 1);
|
||||||
|
|
||||||
|
skipInitShuffling();
|
||||||
|
|
||||||
|
// Daxos of Meletis can't be blocked by creatures with power 3 or greater.
|
||||||
|
// Whenever Daxos of Meletis deals combat damage to a player, exile the top card of that player's library.
|
||||||
|
// You gain life equal to that card's converted mana cost. Until end of turn, you may cast that card and
|
||||||
|
// you may spend mana as though it were mana of any color to cast it.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Daxos of Meletis", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
|
||||||
|
|
||||||
|
attack(2, playerB, "Daxos of Meletis");
|
||||||
|
|
||||||
|
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Moan of the Unhallowed");
|
||||||
|
|
||||||
|
setStopAt(2, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 18);
|
||||||
|
assertLife(playerB, 24);
|
||||||
|
|
||||||
|
assertExileCount(playerA, 0);
|
||||||
|
assertGraveyardCount(playerA, "Moan of the Unhallowed", 1);
|
||||||
|
assertPermanentCount(playerB, "Zombie", 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,9 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.mage.test.cards.triggers;
|
package org.mage.test.cards.triggers;
|
||||||
|
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import org.junit.Ignore;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
@ -133,7 +134,6 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void testWithAnimateDeadDifferentTargets() {
|
public void testWithAnimateDeadDifferentTargets() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||||
|
|
||||||
|
@ -153,35 +153,40 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
|
||||||
// When Staunch Defenders enters the battlefield, you gain 4 life.
|
// When Staunch Defenders enters the battlefield, you gain 4 life.
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1);
|
addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1);
|
||||||
|
|
||||||
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {B}");
|
||||||
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {B}");
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Animate Dead", "Worldgorger Dragon");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Animate Dead", "Worldgorger Dragon");
|
||||||
addTarget(playerA, "Worldgorger Dragon");
|
|
||||||
addTarget(playerA, "Worldgorger Dragon");
|
|
||||||
addTarget(playerA, "Silvercoat Lion");
|
|
||||||
|
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
|
setChoice(playerA, "Worldgorger Dragon");
|
||||||
|
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
|
|
||||||
|
setChoice(playerA, "Silvercoat Lion");
|
||||||
|
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 9);
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 9);
|
||||||
setChoice(playerA, "X=7");
|
setChoice(playerA, "X=9");
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Volcanic Geyser", 1);
|
||||||
assertGraveyardCount(playerA, "Worldgorger Dragon", 1);
|
assertGraveyardCount(playerA, "Worldgorger Dragon", 1);
|
||||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||||
|
|
||||||
assertLife(playerA, 24);
|
assertLife(playerA, 28);
|
||||||
assertLife(playerB, 11);
|
assertLife(playerB, 11);
|
||||||
|
|
||||||
assertGraveyardCount(playerA, "Volcanic Geyser", 1);
|
Assert.assertEquals("Mana pool", "[]", playerA.getManaAvailable(currentGame).toString());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -628,8 +628,10 @@ public class TestPlayer implements Player {
|
||||||
if (targetCardInGraveyard.canTarget(targetObject.getId(), game)) {
|
if (targetCardInGraveyard.canTarget(targetObject.getId(), game)) {
|
||||||
if (alreadyTargetted != null && !alreadyTargetted.contains(targetObject.getId())) {
|
if (alreadyTargetted != null && !alreadyTargetted.contains(targetObject.getId())) {
|
||||||
targetCardInGraveyard.add(targetObject.getId(), game);
|
targetCardInGraveyard.add(targetObject.getId(), game);
|
||||||
choices.remove(choose2);
|
|
||||||
targetFound = true;
|
targetFound = true;
|
||||||
|
if (target.getTargets().size() >= target.getMaxNumberOfTargets()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -810,10 +812,12 @@ public class TestPlayer implements Player {
|
||||||
@Override
|
@Override
|
||||||
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
||||||
if (!choices.isEmpty()) {
|
if (!choices.isEmpty()) {
|
||||||
if (choices.get(0).startsWith("X=")) {
|
for(String choice: choices) {
|
||||||
int xValue = Integer.parseInt(choices.get(0).substring(2));
|
if (choice.startsWith("X=")) {
|
||||||
choices.remove(0);
|
int xValue = Integer.parseInt(choice.substring(2));
|
||||||
return xValue;
|
choices.remove(choice);
|
||||||
|
return xValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return computerPlayer.announceXMana(min, max, message, game, ability);
|
return computerPlayer.announceXMana(min, max, message, game, ability);
|
||||||
|
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -141,18 +140,18 @@ public abstract class AbilityImpl implements Ability {
|
||||||
this.manaCostsToPay = ability.manaCostsToPay.copy();
|
this.manaCostsToPay = ability.manaCostsToPay.copy();
|
||||||
this.costs = ability.costs.copy();
|
this.costs = ability.costs.copy();
|
||||||
this.optionalCosts = ability.optionalCosts.copy();
|
this.optionalCosts = ability.optionalCosts.copy();
|
||||||
for (AlternativeCost cost: ability.alternativeCosts) {
|
for (AlternativeCost cost : ability.alternativeCosts) {
|
||||||
this.alternativeCosts.add((AlternativeCost)cost.copy());
|
this.alternativeCosts.add((AlternativeCost) cost.copy());
|
||||||
}
|
}
|
||||||
if (ability.watchers != null) {
|
if (ability.watchers != null) {
|
||||||
this.watchers = new ArrayList<>();
|
this.watchers = new ArrayList<>();
|
||||||
for (Watcher watcher: ability.watchers) {
|
for (Watcher watcher : ability.watchers) {
|
||||||
watchers.add(watcher.copy());
|
watchers.add(watcher.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ability.subAbilities != null) {
|
if (ability.subAbilities != null) {
|
||||||
this.subAbilities = new ArrayList<>();
|
this.subAbilities = new ArrayList<>();
|
||||||
for (Ability subAbility: ability.subAbilities) {
|
for (Ability subAbility : ability.subAbilities) {
|
||||||
subAbilities.add(subAbility.copy());
|
subAbilities.add(subAbility.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +196,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
//20100716 - 117.12
|
//20100716 - 117.12
|
||||||
if (checkIfClause(game)) {
|
if (checkIfClause(game)) {
|
||||||
for (Effect effect: getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
if (effect instanceof OneShotEffect) {
|
if (effect instanceof OneShotEffect) {
|
||||||
boolean effectResult = effect.apply(game, this);
|
boolean effectResult = effect.apply(game, this);
|
||||||
result &= effectResult;
|
result &= effectResult;
|
||||||
|
@ -214,24 +213,27 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
game.addEffect((ContinuousEffect) effect, this);
|
game.addEffect((ContinuousEffect) effect, this);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* All restrained trigger events are fired now.
|
* All restrained trigger events are fired now. To restrain the
|
||||||
* To restrain the events is mainly neccessary because of the movement of multiple object at once.
|
* events is mainly neccessary because of the movement of
|
||||||
* If the event is fired directly as one object moved, other objects are not already in the correct zone
|
* multiple object at once. If the event is fired directly as
|
||||||
* to check for their effects. (e.g. Valakut, the Molten Pinnacle)
|
* one object moved, other objects are not already in the
|
||||||
|
* correct zone to check for their effects. (e.g. Valakut, the
|
||||||
|
* Molten Pinnacle)
|
||||||
*/
|
*/
|
||||||
game.getState().handleSimultaneousEvent(game);
|
game.getState().handleSimultaneousEvent(game);
|
||||||
game.resetShortLivingLKI();
|
game.resetShortLivingLKI();
|
||||||
/**
|
/**
|
||||||
* game.applyEffects() has to be done at least for every effect that moves cards/permanent between zones,
|
* game.applyEffects() has to be done at least for every effect
|
||||||
* so Static effects work as intened if dependant from the moved objects zone it is in
|
* that moves cards/permanent between zones, so Static effects
|
||||||
* Otherwise for example were static abilities with replacement effects deactivated to late
|
* work as intened if dependant from the moved objects zone it
|
||||||
* Example: {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
|
* is in Otherwise for example were static abilities with
|
||||||
*/
|
* replacement effects deactivated to late Example:
|
||||||
|
* {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
|
||||||
|
*/
|
||||||
if (effect.applyEffectsAfter()) {
|
if (effect.applyEffectsAfter()) {
|
||||||
game.applyEffects();
|
game.applyEffects();
|
||||||
}
|
}
|
||||||
|
@ -265,13 +267,12 @@ public abstract class AbilityImpl implements Ability {
|
||||||
game.getContinuousEffects().applySpliceEffects(this, game);
|
game.getContinuousEffects().applySpliceEffects(this, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sourceObject != null) {
|
if (sourceObject != null) {
|
||||||
sourceObject.adjustChoices(this, game);
|
sourceObject.adjustChoices(this, game);
|
||||||
}
|
}
|
||||||
// TODO: Because all (non targeted) choices have to be done during resolution
|
// TODO: Because all (non targeted) choices have to be done during resolution
|
||||||
// this has to be removed, if all using effects are changed
|
// this has to be removed, if all using effects are changed
|
||||||
for (UUID modeId :this.getModes().getSelectedModes()) {
|
for (UUID modeId : this.getModes().getSelectedModes()) {
|
||||||
this.getModes().setActiveMode(modeId);
|
this.getModes().setActiveMode(modeId);
|
||||||
if (getChoices().size() > 0 && getChoices().choose(game, this) == false) {
|
if (getChoices().size() > 0 && getChoices().choose(game, this) == false) {
|
||||||
logger.debug("activate failed - choice");
|
logger.debug("activate failed - choice");
|
||||||
|
@ -297,7 +298,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
// as buyback, kicker, or convoke costs (see rules 117.8 and 117.9), the player announces his
|
// as buyback, kicker, or convoke costs (see rules 117.8 and 117.9), the player announces his
|
||||||
// or her intentions to pay any or all of those costs (see rule 601.2e).
|
// or her intentions to pay any or all of those costs (see rule 601.2e).
|
||||||
// A player can't apply two alternative methods of casting or two alternative costs to a single spell.
|
// A player can't apply two alternative methods of casting or two alternative costs to a single spell.
|
||||||
if (!activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)){
|
if (!activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)) {
|
||||||
if (getAbilityType().equals(AbilityType.SPELL)
|
if (getAbilityType().equals(AbilityType.SPELL)
|
||||||
&& ((SpellAbility) this).getSpellAbilityType().equals(SpellAbilityType.FACE_DOWN_CREATURE)) {
|
&& ((SpellAbility) this).getSpellAbilityType().equals(SpellAbilityType.FACE_DOWN_CREATURE)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -310,7 +311,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
VariableManaCost variableManaCost = handleManaXCosts(game, noMana, controller);
|
VariableManaCost variableManaCost = handleManaXCosts(game, noMana, controller);
|
||||||
String announceString = handleOtherXCosts(game, controller);
|
String announceString = handleOtherXCosts(game, controller);
|
||||||
|
|
||||||
for (UUID modeId :this.getModes().getSelectedModes()) {
|
for (UUID modeId : this.getModes().getSelectedModes()) {
|
||||||
this.getModes().setActiveMode(modeId);
|
this.getModes().setActiveMode(modeId);
|
||||||
//20121001 - 601.2c
|
//20121001 - 601.2c
|
||||||
// 601.2c The player announces his or her choice of an appropriate player, object, or zone for
|
// 601.2c The player announces his or her choice of an appropriate player, object, or zone for
|
||||||
|
@ -334,7 +335,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) {
|
if (getTargets().size() > 0 && getTargets().chooseTargets(getEffects().get(0).getOutcome(), this.controllerId, this, game) == false) {
|
||||||
if ((variableManaCost != null || announceString != null) && !game.isSimulation()) {
|
if ((variableManaCost != null || announceString != null) && !game.isSimulation()) {
|
||||||
game.informPlayer(controller, (sourceObject != null ? sourceObject.getIdName(): "") + ": no valid targets with this value of X");
|
game.informPlayer(controller, (sourceObject != null ? sourceObject.getIdName() : "") + ": no valid targets with this value of X");
|
||||||
}
|
}
|
||||||
return false; // when activation of ability is canceled during target selection
|
return false; // when activation of ability is canceled during target selection
|
||||||
}
|
}
|
||||||
|
@ -342,7 +343,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
// TODO: Handle optionalCosts at the same time as already OptionalAdditionalSourceCosts are handled.
|
// TODO: Handle optionalCosts at the same time as already OptionalAdditionalSourceCosts are handled.
|
||||||
for (Cost cost : optionalCosts) {
|
for (Cost cost : optionalCosts) {
|
||||||
if (cost instanceof ManaCost) {
|
if (cost instanceof ManaCost) {
|
||||||
cost.clearPaid();
|
cost.clearPaid();
|
||||||
if (controller.chooseUse(Outcome.Benefit, "Pay optional cost " + cost.getText() + "?", game)) {
|
if (controller.chooseUse(Outcome.Benefit, "Pay optional cost " + cost.getText() + "?", game)) {
|
||||||
manaCostsToPay.add((ManaCost) cost);
|
manaCostsToPay.add((ManaCost) cost);
|
||||||
|
@ -353,15 +354,15 @@ public abstract class AbilityImpl implements Ability {
|
||||||
if (sourceObject != null) {
|
if (sourceObject != null) {
|
||||||
sourceObject.adjustCosts(this, game);
|
sourceObject.adjustCosts(this, game);
|
||||||
if (sourceObject instanceof Card) {
|
if (sourceObject instanceof Card) {
|
||||||
for (Ability ability : ((Card)sourceObject).getAbilities(game)) {
|
for (Ability ability : ((Card) sourceObject).getAbilities(game)) {
|
||||||
if (ability instanceof AdjustingSourceCosts) {
|
if (ability instanceof AdjustingSourceCosts) {
|
||||||
((AdjustingSourceCosts)ability).adjustCosts(this, game);
|
((AdjustingSourceCosts) ability).adjustCosts(this, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Ability ability : sourceObject.getAbilities()) {
|
for (Ability ability : sourceObject.getAbilities()) {
|
||||||
if (ability instanceof AdjustingSourceCosts) {
|
if (ability instanceof AdjustingSourceCosts) {
|
||||||
((AdjustingSourceCosts)ability).adjustCosts(this, game);
|
((AdjustingSourceCosts) ability).adjustCosts(this, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,8 +382,8 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID activatorId = controllerId;
|
UUID activatorId = controllerId;
|
||||||
if ((this instanceof ActivatedAbilityImpl) && ((ActivatedAbilityImpl)this).getActivatorId()!= null) {
|
if ((this instanceof ActivatedAbilityImpl) && ((ActivatedAbilityImpl) this).getActivatorId() != null) {
|
||||||
activatorId = ((ActivatedAbilityImpl)this).getActivatorId();
|
activatorId = ((ActivatedAbilityImpl) this).getActivatorId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useAlternativeCost(game)) { // old way still used?
|
if (!useAlternativeCost(game)) { // old way still used?
|
||||||
|
@ -394,7 +395,6 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
|
|
||||||
//20100716 - 601.2g
|
//20100716 - 601.2g
|
||||||
|
|
||||||
if (!costs.pay(this, game, sourceId, activatorId, noMana)) {
|
if (!costs.pay(this, game, sourceId, activatorId, noMana)) {
|
||||||
logger.debug("activate failed - non mana costs");
|
logger.debug("activate failed - non mana costs");
|
||||||
return false;
|
return false;
|
||||||
|
@ -412,14 +412,14 @@ public abstract class AbilityImpl implements Ability {
|
||||||
activated = true;
|
activated = true;
|
||||||
// fire if tapped for mana (may only fire now because else costs of ability itself can be payed with mana of abilities that trigger for that event
|
// fire if tapped for mana (may only fire now because else costs of ability itself can be payed with mana of abilities that trigger for that event
|
||||||
if (this.getAbilityType().equals(AbilityType.MANA)) {
|
if (this.getAbilityType().equals(AbilityType.MANA)) {
|
||||||
for (Cost cost: costs) {
|
for (Cost cost : costs) {
|
||||||
if (cost instanceof TapSourceCost) {
|
if (cost instanceof TapSourceCost) {
|
||||||
Mana mana = null;
|
Mana mana = null;
|
||||||
Effect effect = getEffects().get(0);
|
Effect effect = getEffects().get(0);
|
||||||
if (effect instanceof BasicManaEffect) {
|
if (effect instanceof BasicManaEffect) {
|
||||||
mana = ((BasicManaEffect)effect).getMana(game, this);
|
mana = ((BasicManaEffect) effect).getMana(game, this);
|
||||||
} else if (effect instanceof DynamicManaEffect) {
|
} else if (effect instanceof DynamicManaEffect) {
|
||||||
mana = ((DynamicManaEffect)effect).getMana(game, this);
|
mana = ((DynamicManaEffect) effect).getMana(game, this);
|
||||||
}
|
}
|
||||||
if (mana != null && mana.getAny() == 0) { // if mana == null or Any > 0 the event has to be fired in the mana effect to know which mana was produced
|
if (mana != null && mana.getAny() == 0) { // if mana == null or Any > 0 the event has to be fired in the mana effect to know which mana was produced
|
||||||
ManaEvent event = new ManaEvent(GameEvent.EventType.TAPPED_FOR_MANA, sourceId, sourceId, controllerId, mana);
|
ManaEvent event = new ManaEvent(GameEvent.EventType.TAPPED_FOR_MANA, sourceId, sourceId, controllerId, mana);
|
||||||
|
@ -456,14 +456,14 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ability instanceof OptionalAdditionalSourceCosts) {
|
if (ability instanceof OptionalAdditionalSourceCosts) {
|
||||||
((OptionalAdditionalSourceCosts)ability).addOptionalAdditionalCosts(this, game);
|
((OptionalAdditionalSourceCosts) ability).addOptionalAdditionalCosts(this, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// controller specific alternate spell costs
|
// controller specific alternate spell costs
|
||||||
if (!noMana && !alternativeCostisUsed) {
|
if (!noMana && !alternativeCostisUsed) {
|
||||||
if (this.getAbilityType().equals(AbilityType.SPELL)) {
|
if (this.getAbilityType().equals(AbilityType.SPELL)) {
|
||||||
for (AlternativeSourceCosts alternativeSourceCosts: controller.getAlternativeSourceCosts()) {
|
for (AlternativeSourceCosts alternativeSourceCosts : controller.getAlternativeSourceCosts()) {
|
||||||
if (alternativeSourceCosts.isAvailable(this, game)) {
|
if (alternativeSourceCosts.isAvailable(this, game)) {
|
||||||
if (alternativeSourceCosts.askToActivateAlternativeCosts(this, game)) {
|
if (alternativeSourceCosts.askToActivateAlternativeCosts(this, game)) {
|
||||||
// only one alternative costs may be activated
|
// only one alternative costs may be activated
|
||||||
alternativeCostisUsed = true;
|
alternativeCostisUsed = true;
|
||||||
|
@ -479,7 +479,9 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the setting of non mana X costs
|
* Handles the setting of non mana X costs
|
||||||
* @param controller *
|
*
|
||||||
|
* @param controller
|
||||||
|
*
|
||||||
* @param game
|
* @param game
|
||||||
* @return announce message
|
* @return announce message
|
||||||
*
|
*
|
||||||
|
@ -519,7 +521,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
// its mana cost; see rule 107.3), the player announces the value of that variable.
|
// its mana cost; see rule 107.3), the player announces the value of that variable.
|
||||||
// TODO: Handle announcing other variable costs here like: RemoveVariableCountersSourceCost
|
// TODO: Handle announcing other variable costs here like: RemoveVariableCountersSourceCost
|
||||||
VariableManaCost variableManaCost = null;
|
VariableManaCost variableManaCost = null;
|
||||||
for (ManaCost cost: manaCostsToPay) {
|
for (ManaCost cost : manaCostsToPay) {
|
||||||
if (cost instanceof VariableManaCost) {
|
if (cost instanceof VariableManaCost) {
|
||||||
variableManaCost = (VariableManaCost) cost;
|
variableManaCost = (VariableManaCost) cost;
|
||||||
break; // only one VariableManCost per spell (or is it possible to have more?)
|
break; // only one VariableManCost per spell (or is it possible to have more?)
|
||||||
|
@ -548,7 +550,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
manaSymbol = "W";
|
manaSymbol = "W";
|
||||||
}
|
}
|
||||||
if (manaSymbol == null) {
|
if (manaSymbol == null) {
|
||||||
throw new UnsupportedOperationException("ManaFilter is not supported: " +this.toString() );
|
throw new UnsupportedOperationException("ManaFilter is not supported: " + this.toString());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < amountMana; i++) {
|
for (int i = 0; i < amountMana; i++) {
|
||||||
manaString.append("{").append(manaSymbol).append("}");
|
manaString.append("{").append(manaSymbol).append("}");
|
||||||
|
@ -566,11 +568,12 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
// called at end of turn for each Permanent
|
// called at end of turn for each Permanent
|
||||||
@Override
|
@Override
|
||||||
public void reset(Game game) {}
|
public void reset(Game game) {
|
||||||
|
}
|
||||||
|
|
||||||
// Is this still needed?
|
// Is this still needed?
|
||||||
protected boolean useAlternativeCost(Game game) {
|
protected boolean useAlternativeCost(Game game) {
|
||||||
for (AlternativeCost cost: alternativeCosts) {
|
for (AlternativeCost cost : alternativeCosts) {
|
||||||
if (cost.isAvailable(game, this)) {
|
if (cost.isAvailable(game, this)) {
|
||||||
if (game.getPlayer(this.controllerId).chooseUse(Outcome.Neutral, "Use alternative cost " + cost.getName(), game)) {
|
if (game.getPlayer(this.controllerId).chooseUse(Outcome.Neutral, "Use alternative cost " + cost.getName(), game)) {
|
||||||
return cost.pay(this, game, sourceId, controllerId, false);
|
return cost.pay(this, game, sourceId, controllerId, false);
|
||||||
|
@ -594,18 +597,17 @@ public abstract class AbilityImpl implements Ability {
|
||||||
public void setControllerId(UUID controllerId) {
|
public void setControllerId(UUID controllerId) {
|
||||||
this.controllerId = controllerId;
|
this.controllerId = controllerId;
|
||||||
if (watchers != null) {
|
if (watchers != null) {
|
||||||
for (Watcher watcher: watchers) {
|
for (Watcher watcher : watchers) {
|
||||||
watcher.setControllerId(controllerId);
|
watcher.setControllerId(controllerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (subAbilities != null) {
|
if (subAbilities != null) {
|
||||||
for (Ability subAbility: subAbilities) {
|
for (Ability subAbility : subAbilities) {
|
||||||
subAbility.setControllerId(controllerId);
|
subAbility.setControllerId(controllerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getSourceId() {
|
public UUID getSourceId() {
|
||||||
return sourceId;
|
return sourceId;
|
||||||
|
@ -621,12 +623,12 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (subAbilities != null) {
|
if (subAbilities != null) {
|
||||||
for (Ability subAbility: subAbilities) {
|
for (Ability subAbility : subAbilities) {
|
||||||
subAbility.setSourceId(sourceId);
|
subAbility.setSourceId(sourceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (watchers != null) {
|
if (watchers != null) {
|
||||||
for (Watcher watcher: watchers) {
|
for (Watcher watcher : watchers) {
|
||||||
watcher.setSourceId(sourceId);
|
watcher.setSourceId(sourceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,13 +645,14 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be used by {@link mage.abilities.effects.CostModificationEffect cost modification effects}
|
* Should be used by
|
||||||
|
* {@link mage.abilities.effects.CostModificationEffect cost modification effects}
|
||||||
* to manipulate what is actually paid before resolution.
|
* to manipulate what is actually paid before resolution.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ManaCosts<ManaCost> getManaCostsToPay ( ) {
|
public ManaCosts<ManaCost> getManaCostsToPay() {
|
||||||
return manaCostsToPay;
|
return manaCostsToPay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +674,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
@Override
|
@Override
|
||||||
public Effects getEffects(Game game, EffectType effectType) {
|
public Effects getEffects(Game game, EffectType effectType) {
|
||||||
Effects typedEffects = new Effects();
|
Effects typedEffects = new Effects();
|
||||||
for (Effect effect: getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
if (effect.getEffectType() == effectType) {
|
if (effect.getEffectType() == effectType) {
|
||||||
typedEffects.add(effect);
|
typedEffects.add(effect);
|
||||||
}
|
}
|
||||||
|
@ -760,7 +763,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
String text = modes.getText();
|
String text = modes.getText();
|
||||||
if (!text.isEmpty()) {
|
if (!text.isEmpty()) {
|
||||||
if (sbRule.length() > 1) {
|
if (sbRule.length() > 1) {
|
||||||
String end = sbRule.substring(sbRule.length()-2).trim();
|
String end = sbRule.substring(sbRule.length() - 2).trim();
|
||||||
if (end.isEmpty() || end.equals(":") || end.equals(".")) {
|
if (end.isEmpty() || end.equals(":") || end.equals(".")) {
|
||||||
sbRule.append(Character.toUpperCase(text.charAt(0))).append(text.substring(1));
|
sbRule.append(Character.toUpperCase(text.charAt(0))).append(text.substring(1));
|
||||||
} else {
|
} else {
|
||||||
|
@ -791,9 +794,8 @@ public abstract class AbilityImpl implements Ability {
|
||||||
public void addCost(Cost cost) {
|
public void addCost(Cost cost) {
|
||||||
if (cost != null) {
|
if (cost != null) {
|
||||||
if (cost instanceof ManaCost) {
|
if (cost instanceof ManaCost) {
|
||||||
this.addManaCost((ManaCost)cost);
|
this.addManaCost((ManaCost) cost);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.costs.add(cost);
|
this.costs.add(cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -869,7 +871,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canChooseTarget(Game game) {
|
public boolean canChooseTarget(Game game) {
|
||||||
for (Mode mode: modes.values()) {
|
for (Mode mode : modes.values()) {
|
||||||
if (mode.getTargets().canChoose(sourceId, controllerId, game)) {
|
if (mode.getTargets().canChoose(sourceId, controllerId, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -985,7 +987,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAbilityWord(AbilityWord abilityWord) {
|
public void setAbilityWord(AbilityWord abilityWord) {
|
||||||
this.abilityWord = abilityWord;
|
this.abilityWord = abilityWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -998,7 +1000,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
logger.warn("Could get no object: " + this.toString());
|
logger.warn("Could get no object: " + this.toString());
|
||||||
}
|
}
|
||||||
return new StringBuilder(" activates: ")
|
return new StringBuilder(" activates: ")
|
||||||
.append(object != null ? this.formatRule(modes.getText(), object.getLogName()) :modes.getText())
|
.append(object != null ? this.formatRule(modes.getText(), object.getLogName()) : modes.getText())
|
||||||
.append(" from ")
|
.append(" from ")
|
||||||
.append(getMessageText(game)).toString();
|
.append(getMessageText(game)).toString();
|
||||||
}
|
}
|
||||||
|
@ -1018,7 +1020,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
if (object instanceof Spell) {
|
if (object instanceof Spell) {
|
||||||
Spell spell = (Spell) object;
|
Spell spell = (Spell) object;
|
||||||
String castText = spell.getSpellCastText(game);
|
String castText = spell.getSpellCastText(game);
|
||||||
sb.append((castText.startsWith("Cast ") ? castText.substring(5):castText));
|
sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText));
|
||||||
if (spell.getFromZone() == Zone.GRAVEYARD) {
|
if (spell.getFromZone() == Zone.GRAVEYARD) {
|
||||||
sb.append(" from graveyard");
|
sb.append(" from graveyard");
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1046,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
if (spellAbility.getTargets().size() > 0) {
|
if (spellAbility.getTargets().size() > 0) {
|
||||||
sb.append(half).append(" half targeting ");
|
sb.append(half).append(" half targeting ");
|
||||||
for (Target target: spellAbility.getTargets()) {
|
for (Target target : spellAbility.getTargets()) {
|
||||||
sb.append(target.getTargetedName(game));
|
sb.append(target.getTargetedName(game));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1056,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (SpellAbility spellAbility : spell.getSpellAbilities()) {
|
for (SpellAbility spellAbility : spell.getSpellAbilities()) {
|
||||||
i++;
|
i++;
|
||||||
if ( i > 1) {
|
if (i > 1) {
|
||||||
sb.append(" splicing ");
|
sb.append(" splicing ");
|
||||||
if (spellAbility.name.length() > 5 && spellAbility.name.startsWith("Cast ")) {
|
if (spellAbility.name.length() > 5 && spellAbility.name.startsWith("Cast ")) {
|
||||||
sb.append(spellAbility.name.substring(5));
|
sb.append(spellAbility.name.substring(5));
|
||||||
|
@ -1106,7 +1108,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Choice choice :this.getChoices()) {
|
for (Choice choice : this.getChoices()) {
|
||||||
sb.append(" - ").append(choice.getMessage()).append(": ").append(choice.getChoice());
|
sb.append(" - ").append(choice.getMessage()).append(": ").append(choice.getChoice());
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
@ -1170,12 +1172,12 @@ public abstract class AbilityImpl implements Ability {
|
||||||
public void setSourceObject(MageObject sourceObject, Game game) {
|
public void setSourceObject(MageObject sourceObject, Game game) {
|
||||||
if (sourceObject == null) {
|
if (sourceObject == null) {
|
||||||
this.sourceObject = game.getObject(sourceId);
|
this.sourceObject = game.getObject(sourceId);
|
||||||
|
// if permanent get card /permanent instead of spell
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.sourceObject = sourceObject;
|
this.sourceObject = sourceObject;
|
||||||
}
|
}
|
||||||
this.sourceObjectZoneChangeCounter = game.getState().getZoneChangeCounter(sourceId);
|
this.sourceObjectZoneChangeCounter = game.getState().getZoneChangeCounter(sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,26 +27,25 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities.effects;
|
package mage.abilities.effects;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageObject;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.SpellAbility;
|
||||||
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.PermanentCard;
|
import mage.game.permanent.PermanentCard;
|
||||||
|
import mage.game.stack.Spell;
|
||||||
import mage.game.stack.StackAbility;
|
import mage.game.stack.StackAbility;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.SpellAbility;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
|
||||||
import mage.game.stack.Spell;
|
|
||||||
import mage.target.common.TargetCardInGraveyard;
|
import mage.target.common.TargetCardInGraveyard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,6 +117,9 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
||||||
if (targetId == null) {
|
if (targetId == null) {
|
||||||
Target target = card.getSpellAbility().getTargets().get(0);
|
Target target = card.getSpellAbility().getTargets().get(0);
|
||||||
enchantCardInGraveyard = target instanceof TargetCardInGraveyard;
|
enchantCardInGraveyard = target instanceof TargetCardInGraveyard;
|
||||||
|
if (enchantCardInGraveyard && target != null) {
|
||||||
|
target.clearChosen();
|
||||||
|
}
|
||||||
Player player = game.getPlayer(card.getOwnerId());
|
Player player = game.getPlayer(card.getOwnerId());
|
||||||
Outcome auraOutcome = Outcome.BoostCreature;
|
Outcome auraOutcome = Outcome.BoostCreature;
|
||||||
Ability: for (Ability ability:card.getAbilities()) {
|
Ability: for (Ability ability:card.getAbilities()) {
|
||||||
|
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.effects;
|
package mage.abilities.effects;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -147,6 +146,9 @@ public class ContinuousEffects implements Serializable {
|
||||||
allEffectsLists.add(restrictionUntapNotMoreThanEffects);
|
allEffectsLists.add(restrictionUntapNotMoreThanEffects);
|
||||||
allEffectsLists.add(costModificationEffects);
|
allEffectsLists.add(costModificationEffects);
|
||||||
allEffectsLists.add(spliceCardEffects);
|
allEffectsLists.add(spliceCardEffects);
|
||||||
|
for (ContinuousEffectsList continuousEffectsList : asThoughEffectsMap.values()) {
|
||||||
|
allEffectsLists.add(continuousEffectsList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContinuousEffects copy() {
|
public ContinuousEffects copy() {
|
||||||
|
@ -168,7 +170,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
preventionEffects.removeEndOfCombatEffects();
|
preventionEffects.removeEndOfCombatEffects();
|
||||||
requirementEffects.removeEndOfCombatEffects();
|
requirementEffects.removeEndOfCombatEffects();
|
||||||
restrictionEffects.removeEndOfCombatEffects();
|
restrictionEffects.removeEndOfCombatEffects();
|
||||||
for(ContinuousEffectsList asThoughtlist :asThoughEffectsMap.values()) {
|
for (ContinuousEffectsList asThoughtlist : asThoughEffectsMap.values()) {
|
||||||
asThoughtlist.removeEndOfCombatEffects();
|
asThoughtlist.removeEndOfCombatEffects();
|
||||||
}
|
}
|
||||||
costModificationEffects.removeEndOfCombatEffects();
|
costModificationEffects.removeEndOfCombatEffects();
|
||||||
|
@ -182,7 +184,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
preventionEffects.removeEndOfTurnEffects();
|
preventionEffects.removeEndOfTurnEffects();
|
||||||
requirementEffects.removeEndOfTurnEffects();
|
requirementEffects.removeEndOfTurnEffects();
|
||||||
restrictionEffects.removeEndOfTurnEffects();
|
restrictionEffects.removeEndOfTurnEffects();
|
||||||
for(ContinuousEffectsList asThoughtlist :asThoughEffectsMap.values()) {
|
for (ContinuousEffectsList asThoughtlist : asThoughEffectsMap.values()) {
|
||||||
asThoughtlist.removeEndOfTurnEffects();
|
asThoughtlist.removeEndOfTurnEffects();
|
||||||
}
|
}
|
||||||
costModificationEffects.removeEndOfTurnEffects();
|
costModificationEffects.removeEndOfTurnEffects();
|
||||||
|
@ -197,7 +199,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
requirementEffects.removeInactiveEffects(game);
|
requirementEffects.removeInactiveEffects(game);
|
||||||
restrictionEffects.removeInactiveEffects(game);
|
restrictionEffects.removeInactiveEffects(game);
|
||||||
restrictionUntapNotMoreThanEffects.removeInactiveEffects(game);
|
restrictionUntapNotMoreThanEffects.removeInactiveEffects(game);
|
||||||
for(ContinuousEffectsList asThoughtlist :asThoughEffectsMap.values()) {
|
for (ContinuousEffectsList asThoughtlist : asThoughEffectsMap.values()) {
|
||||||
asThoughtlist.removeInactiveEffects(game);
|
asThoughtlist.removeInactiveEffects(game);
|
||||||
}
|
}
|
||||||
costModificationEffects.removeInactiveEffects(game);
|
costModificationEffects.removeInactiveEffects(game);
|
||||||
|
@ -206,13 +208,13 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
public List<ContinuousEffect> getLayeredEffects(Game game) {
|
public List<ContinuousEffect> getLayeredEffects(Game game) {
|
||||||
List<ContinuousEffect> layerEffects = new ArrayList<>();
|
List<ContinuousEffect> layerEffects = new ArrayList<>();
|
||||||
for (ContinuousEffect effect: layeredEffects) {
|
for (ContinuousEffect effect : layeredEffects) {
|
||||||
switch (effect.getDuration()) {
|
switch (effect.getDuration()) {
|
||||||
case WhileOnBattlefield:
|
case WhileOnBattlefield:
|
||||||
case WhileOnStack:
|
case WhileOnStack:
|
||||||
case WhileInGraveyard:
|
case WhileInGraveyard:
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability: abilities) {
|
for (Ability ability : abilities) {
|
||||||
// If e.g. triggerd abilities (non static) created the effect, the ability must not be in usable zone (e.g. Unearth giving Haste effect)
|
// If e.g. triggerd abilities (non static) created the effect, the ability must not be in usable zone (e.g. Unearth giving Haste effect)
|
||||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
|
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
|
||||||
layerEffects.add(effect);
|
layerEffects.add(effect);
|
||||||
|
@ -232,9 +234,12 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initially effect timestamp is set when game starts in game.loadCard method.
|
* Initially effect timestamp is set when game starts in game.loadCard
|
||||||
* After that timestamp should be updated whenever effect becomes "actual" meaning it becomes turned on
|
* method. After that timestamp should be updated whenever effect becomes
|
||||||
* that is defined by Ability.#isInUseableZone(Game, boolean) method in #getLayeredEffects(Game).
|
* "actual" meaning it becomes turned on that is defined by
|
||||||
|
* Ability.#isInUseableZone(Game, boolean) method in
|
||||||
|
* #getLayeredEffects(Game).
|
||||||
|
*
|
||||||
* @param layerEffects
|
* @param layerEffects
|
||||||
*/
|
*/
|
||||||
private void updateTimestamps(List<ContinuousEffect> layerEffects) {
|
private void updateTimestamps(List<ContinuousEffect> layerEffects) {
|
||||||
|
@ -254,7 +259,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
private List<ContinuousEffect> filterLayeredEffects(List<ContinuousEffect> effects, Layer layer) {
|
private List<ContinuousEffect> filterLayeredEffects(List<ContinuousEffect> effects, Layer layer) {
|
||||||
List<ContinuousEffect> layerEffects = new ArrayList<>();
|
List<ContinuousEffect> layerEffects = new ArrayList<>();
|
||||||
for (ContinuousEffect effect: effects) {
|
for (ContinuousEffect effect : effects) {
|
||||||
if (effect.hasLayer(layer)) {
|
if (effect.hasLayer(layer)) {
|
||||||
layerEffects.add(effect);
|
layerEffects.add(effect);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +269,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
public HashMap<RequirementEffect, HashSet<Ability>> getApplicableRequirementEffects(Permanent permanent, Game game) {
|
public HashMap<RequirementEffect, HashSet<Ability>> getApplicableRequirementEffects(Permanent permanent, Game game) {
|
||||||
HashMap<RequirementEffect, HashSet<Ability>> effects = new HashMap<>();
|
HashMap<RequirementEffect, HashSet<Ability>> effects = new HashMap<>();
|
||||||
for (RequirementEffect effect: requirementEffects) {
|
for (RequirementEffect effect : requirementEffects) {
|
||||||
HashSet<Ability> abilities = requirementEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = requirementEffects.getAbility(effect.getId());
|
||||||
HashSet<Ability> applicableAbilities = new HashSet<>();
|
HashSet<Ability> applicableAbilities = new HashSet<>();
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
|
@ -283,7 +288,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
public HashMap<RestrictionEffect, HashSet<Ability>> getApplicableRestrictionEffects(Permanent permanent, Game game) {
|
public HashMap<RestrictionEffect, HashSet<Ability>> getApplicableRestrictionEffects(Permanent permanent, Game game) {
|
||||||
HashMap<RestrictionEffect, HashSet<Ability>> effects = new HashMap<>();
|
HashMap<RestrictionEffect, HashSet<Ability>> effects = new HashMap<>();
|
||||||
for (RestrictionEffect effect: restrictionEffects) {
|
for (RestrictionEffect effect : restrictionEffects) {
|
||||||
HashSet<Ability> abilities = restrictionEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = restrictionEffects.getAbility(effect.getId());
|
||||||
HashSet<Ability> applicableAbilities = new HashSet<>();
|
HashSet<Ability> applicableAbilities = new HashSet<>();
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
|
@ -302,7 +307,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
public HashMap<RestrictionUntapNotMoreThanEffect, HashSet<Ability>> getApplicableRestrictionUntapNotMoreThanEffects(Player player, Game game) {
|
public HashMap<RestrictionUntapNotMoreThanEffect, HashSet<Ability>> getApplicableRestrictionUntapNotMoreThanEffects(Player player, Game game) {
|
||||||
HashMap<RestrictionUntapNotMoreThanEffect, HashSet<Ability>> effects = new HashMap<>();
|
HashMap<RestrictionUntapNotMoreThanEffect, HashSet<Ability>> effects = new HashMap<>();
|
||||||
for (RestrictionUntapNotMoreThanEffect effect: restrictionUntapNotMoreThanEffects) {
|
for (RestrictionUntapNotMoreThanEffect effect : restrictionUntapNotMoreThanEffects) {
|
||||||
HashSet<Ability> abilities = restrictionUntapNotMoreThanEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = restrictionUntapNotMoreThanEffects.getAbility(effect.getId());
|
||||||
HashSet<Ability> applicableAbilities = new HashSet<>();
|
HashSet<Ability> applicableAbilities = new HashSet<>();
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
|
@ -323,19 +328,20 @@ public class ContinuousEffects implements Serializable {
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
* @param game
|
* @param game
|
||||||
* @return a list of all {@link ReplacementEffect} that apply to the current event
|
* @return a list of all {@link ReplacementEffect} that apply to the current
|
||||||
|
* event
|
||||||
*/
|
*/
|
||||||
private HashMap<ReplacementEffect, HashSet<Ability>> getApplicableReplacementEffects(GameEvent event, Game game) {
|
private HashMap<ReplacementEffect, HashSet<Ability>> getApplicableReplacementEffects(GameEvent event, Game game) {
|
||||||
HashMap<ReplacementEffect, HashSet<Ability>> replaceEffects = new HashMap<>();
|
HashMap<ReplacementEffect, HashSet<Ability>> replaceEffects = new HashMap<>();
|
||||||
if (planeswalkerRedirectionEffect.checksEventType(event, game) && planeswalkerRedirectionEffect.applies(event, null, game)) {
|
if (planeswalkerRedirectionEffect.checksEventType(event, game) && planeswalkerRedirectionEffect.applies(event, null, game)) {
|
||||||
replaceEffects.put(planeswalkerRedirectionEffect, null);
|
replaceEffects.put(planeswalkerRedirectionEffect, null);
|
||||||
}
|
}
|
||||||
if(auraReplacementEffect.checksEventType(event, game) && auraReplacementEffect.applies(event, null, game)){
|
if (auraReplacementEffect.checksEventType(event, game) && auraReplacementEffect.applies(event, null, game)) {
|
||||||
replaceEffects.put(auraReplacementEffect, null);
|
replaceEffects.put(auraReplacementEffect, null);
|
||||||
}
|
}
|
||||||
// boolean checkLKI = event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT);
|
// boolean checkLKI = event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT);
|
||||||
//get all applicable transient Replacement effects
|
//get all applicable transient Replacement effects
|
||||||
for (ReplacementEffect effect: replacementEffects) {
|
for (ReplacementEffect effect : replacementEffects) {
|
||||||
if (!effect.checksEventType(event, game)) {
|
if (!effect.checksEventType(event, game)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +368,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
replaceEffects.put(effect, applicableAbilities);
|
replaceEffects.put(effect, applicableAbilities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (PreventionEffect effect: preventionEffects) {
|
for (PreventionEffect effect : preventionEffects) {
|
||||||
if (!effect.checksEventType(event, game)) {
|
if (!effect.checksEventType(event, game)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +396,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAbilityStillExists(Ability ability, ContinuousEffect effect, GameEvent event, Game game) {
|
private boolean checkAbilityStillExists(Ability ability, ContinuousEffect effect, GameEvent event, Game game) {
|
||||||
switch(effect.getDuration()) { // effects with fixed duration don't need an object with the source ability (e.g. a silence cast with isochronic Scepter has no more a card object
|
switch (effect.getDuration()) { // effects with fixed duration don't need an object with the source ability (e.g. a silence cast with isochronic Scepter has no more a card object
|
||||||
case EndOfCombat:
|
case EndOfCombat:
|
||||||
case EndOfGame:
|
case EndOfGame:
|
||||||
case EndOfStep:
|
case EndOfStep:
|
||||||
|
@ -403,10 +409,10 @@ public class ContinuousEffects implements Serializable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MageObject object;
|
MageObject object;
|
||||||
if (event.getType().equals(EventType.ZONE_CHANGE) &&
|
if (event.getType().equals(EventType.ZONE_CHANGE)
|
||||||
((ZoneChangeEvent)event).getFromZone().equals(Zone.BATTLEFIELD)&&
|
&& ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)
|
||||||
event.getTargetId().equals(ability.getSourceId())) {
|
&& event.getTargetId().equals(ability.getSourceId())) {
|
||||||
object = ((ZoneChangeEvent)event).getTarget();
|
object = ((ZoneChangeEvent) event).getTarget();
|
||||||
} else {
|
} else {
|
||||||
object = game.getObject(ability.getSourceId());
|
object = game.getObject(ability.getSourceId());
|
||||||
}
|
}
|
||||||
|
@ -417,23 +423,23 @@ public class ContinuousEffects implements Serializable {
|
||||||
if (!object.getAbilities().contains(ability)) {
|
if (!object.getAbilities().contains(ability)) {
|
||||||
exists = false;
|
exists = false;
|
||||||
if (object instanceof PermanentCard) {
|
if (object instanceof PermanentCard) {
|
||||||
PermanentCard permanent = (PermanentCard)object;
|
PermanentCard permanent = (PermanentCard) object;
|
||||||
if (permanent.canTransform() && event.getType() == GameEvent.EventType.TRANSFORMED) {
|
if (permanent.canTransform() && event.getType() == GameEvent.EventType.TRANSFORMED) {
|
||||||
exists = permanent.getCard().getAbilities().contains(ability);
|
exists = permanent.getCard().getAbilities().contains(ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (object instanceof PermanentCard) {
|
if (object instanceof PermanentCard) {
|
||||||
PermanentCard permanent = (PermanentCard)object;
|
PermanentCard permanent = (PermanentCard) object;
|
||||||
if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (object instanceof Spell) {
|
} else if (object instanceof Spell) {
|
||||||
Spell spell = (Spell)object;
|
Spell spell = (Spell) object;
|
||||||
if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
@ -447,7 +453,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
private List<CostModificationEffect> getApplicableCostModificationEffects(Game game) {
|
private List<CostModificationEffect> getApplicableCostModificationEffects(Game game) {
|
||||||
List<CostModificationEffect> costEffects = new ArrayList<>();
|
List<CostModificationEffect> costEffects = new ArrayList<>();
|
||||||
|
|
||||||
for (CostModificationEffect effect: costModificationEffects) {
|
for (CostModificationEffect effect : costModificationEffects) {
|
||||||
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
|
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
|
||||||
|
@ -461,6 +467,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
return costEffects;
|
return costEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters out splice effects that are not active.
|
* Filters out splice effects that are not active.
|
||||||
*
|
*
|
||||||
|
@ -470,7 +477,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
private List<SpliceCardEffect> getApplicableSpliceCardEffects(Game game, UUID playerId) {
|
private List<SpliceCardEffect> getApplicableSpliceCardEffects(Game game, UUID playerId) {
|
||||||
List<SpliceCardEffect> spliceEffects = new ArrayList<>();
|
List<SpliceCardEffect> spliceEffects = new ArrayList<>();
|
||||||
|
|
||||||
for (SpliceCardEffect effect: spliceCardEffects) {
|
for (SpliceCardEffect effect : spliceCardEffects) {
|
||||||
HashSet<Ability> abilities = spliceCardEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = spliceCardEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if (ability.getControllerId().equals(playerId) && (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null))) {
|
if (ability.getControllerId().equals(playerId) && (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null))) {
|
||||||
|
@ -491,7 +498,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
public boolean asThough(UUID objectId, AsThoughEffectType type, Ability affectedAbility, UUID controllerId, Game game) {
|
public boolean asThough(UUID objectId, AsThoughEffectType type, Ability affectedAbility, UUID controllerId, Game game) {
|
||||||
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(type, game);
|
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(type, game);
|
||||||
for (AsThoughEffect effect: asThoughEffectsList) {
|
for (AsThoughEffect effect : asThoughEffectsList) {
|
||||||
HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
|
HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if (affectedAbility == null) {
|
if (affectedAbility == null) {
|
||||||
|
@ -509,7 +516,6 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters out asThough effects that are not active.
|
* Filters out asThough effects that are not active.
|
||||||
*
|
*
|
||||||
|
@ -520,7 +526,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
private List<AsThoughEffect> getApplicableAsThoughEffects(AsThoughEffectType type, Game game) {
|
private List<AsThoughEffect> getApplicableAsThoughEffects(AsThoughEffectType type, Game game) {
|
||||||
List<AsThoughEffect> asThoughEffectsList = new ArrayList<>();
|
List<AsThoughEffect> asThoughEffectsList = new ArrayList<>();
|
||||||
if (asThoughEffectsMap.containsKey(type)) {
|
if (asThoughEffectsMap.containsKey(type)) {
|
||||||
for (AsThoughEffect effect: asThoughEffectsMap.get(type)) {
|
for (AsThoughEffect effect : asThoughEffectsMap.get(type)) {
|
||||||
HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
|
HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
|
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null)) {
|
||||||
|
@ -537,55 +543,58 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 601.2e The player determines the total cost of the spell. Usually this is
|
* 601.2e The player determines the total cost of the spell. Usually this is
|
||||||
* just the mana cost. Some spells have additional or alternative costs. Some
|
* just the mana cost. Some spells have additional or alternative costs.
|
||||||
* effects may increase or reduce the cost to pay, or may provide other alternative costs.
|
* Some effects may increase or reduce the cost to pay, or may provide other
|
||||||
* Costs may include paying mana, tapping permanents, sacrificing permanents,
|
* alternative costs. Costs may include paying mana, tapping permanents,
|
||||||
* discarding cards, and so on. The total cost is the mana cost or alternative
|
* sacrificing permanents, discarding cards, and so on. The total cost is
|
||||||
* cost (as determined in rule 601.2b), plus all additional costs and cost increases,
|
* the mana cost or alternative cost (as determined in rule 601.2b), plus
|
||||||
* and minus all cost reductions. If the mana component of the total cost is reduced
|
* all additional costs and cost increases, and minus all cost reductions.
|
||||||
* to nothing by cost reduction effects, it is considered to be {0}.
|
* If the mana component of the total cost is reduced to nothing by cost
|
||||||
* It can’t be reduced to less than {0}. Once the total cost is determined,
|
* reduction effects, it is considered to be {0}. It can’t be reduced to
|
||||||
* any effects that directly affect the total cost are applied.
|
* less than {0}. Once the total cost is determined, any effects that
|
||||||
* Then the resulting total cost becomes “locked in.”
|
* directly affect the total cost are applied. Then the resulting total cost
|
||||||
* If effects would change the total cost after this time, they have no effect.
|
* becomes “locked in.” If effects would change the total cost after this
|
||||||
|
* time, they have no effect.
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Inspects all {@link Permanent permanent's} {@link Ability abilities} on the battlefield
|
* Inspects all {@link Permanent permanent's} {@link Ability abilities} on
|
||||||
* for {@link CostModificationEffect cost modification effects} and applies them if necessary.
|
* the battlefield for
|
||||||
|
* {@link CostModificationEffect cost modification effects} and applies them
|
||||||
|
* if necessary.
|
||||||
*
|
*
|
||||||
* @param abilityToModify
|
* @param abilityToModify
|
||||||
* @param game
|
* @param game
|
||||||
*/
|
*/
|
||||||
public void costModification ( Ability abilityToModify, Game game ) {
|
public void costModification(Ability abilityToModify, Game game) {
|
||||||
List<CostModificationEffect> costEffects = getApplicableCostModificationEffects(game);
|
List<CostModificationEffect> costEffects = getApplicableCostModificationEffects(game);
|
||||||
|
|
||||||
for ( CostModificationEffect effect : costEffects) {
|
for (CostModificationEffect effect : costEffects) {
|
||||||
if(effect.getModificationType() == CostModificationType.INCREASE_COST){
|
if (effect.getModificationType() == CostModificationType.INCREASE_COST) {
|
||||||
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if ( effect.applies(abilityToModify, ability, game) ) {
|
if (effect.applies(abilityToModify, ability, game)) {
|
||||||
effect.apply(game, ability, abilityToModify);
|
effect.apply(game, ability, abilityToModify);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( CostModificationEffect effect : costEffects) {
|
for (CostModificationEffect effect : costEffects) {
|
||||||
if(effect.getModificationType() == CostModificationType.REDUCE_COST){
|
if (effect.getModificationType() == CostModificationType.REDUCE_COST) {
|
||||||
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if ( effect.applies(abilityToModify, ability, game) ) {
|
if (effect.applies(abilityToModify, ability, game)) {
|
||||||
effect.apply(game, ability, abilityToModify);
|
effect.apply(game, ability, abilityToModify);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( CostModificationEffect effect : costEffects) {
|
for (CostModificationEffect effect : costEffects) {
|
||||||
if(effect.getModificationType() == CostModificationType.SET_COST){
|
if (effect.getModificationType() == CostModificationType.SET_COST) {
|
||||||
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = costModificationEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if ( effect.applies(abilityToModify, ability, game) ) {
|
if (effect.applies(abilityToModify, ability, game)) {
|
||||||
effect.apply(game, ability, abilityToModify);
|
effect.apply(game, ability, abilityToModify);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -599,8 +608,8 @@ public class ContinuousEffects implements Serializable {
|
||||||
* @param abilityToModify
|
* @param abilityToModify
|
||||||
* @param game
|
* @param game
|
||||||
*/
|
*/
|
||||||
public void applySpliceEffects ( Ability abilityToModify, Game game ) {
|
public void applySpliceEffects(Ability abilityToModify, Game game) {
|
||||||
if ( ((SpellAbility) abilityToModify).getSpellAbilityType().equals(SpellAbilityType.SPLICE)) {
|
if (((SpellAbility) abilityToModify).getSpellAbilityType().equals(SpellAbilityType.SPLICE)) {
|
||||||
// on a spliced ability of a spell can't be spliced again
|
// on a spliced ability of a spell can't be spliced again
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -610,7 +619,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
for (SpliceCardEffect effect : spliceEffects) {
|
for (SpliceCardEffect effect : spliceEffects) {
|
||||||
HashSet<Ability> abilities = spliceCardEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = spliceCardEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if (effect.applies(abilityToModify, ability, game) ) {
|
if (effect.applies(abilityToModify, ability, game)) {
|
||||||
spliceAbilities.add((SpliceOntoArcaneAbility) ability);
|
spliceAbilities.add((SpliceOntoArcaneAbility) ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -633,7 +642,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
UUID cardId = target.getFirstTarget();
|
UUID cardId = target.getFirstTarget();
|
||||||
if (cardId != null) {
|
if (cardId != null) {
|
||||||
SpliceOntoArcaneAbility selectedAbility = null;
|
SpliceOntoArcaneAbility selectedAbility = null;
|
||||||
for(SpliceOntoArcaneAbility ability :spliceAbilities) {
|
for (SpliceOntoArcaneAbility ability : spliceAbilities) {
|
||||||
if (ability.getSourceId().equals(cardId)) {
|
if (ability.getSourceId().equals(cardId)) {
|
||||||
selectedAbility = ability;
|
selectedAbility = ability;
|
||||||
break;
|
break;
|
||||||
|
@ -658,11 +667,12 @@ public class ContinuousEffects implements Serializable {
|
||||||
* @param event
|
* @param event
|
||||||
* @param targetAbility ability the event is attached to. can be null.
|
* @param targetAbility ability the event is attached to. can be null.
|
||||||
* @param game
|
* @param game
|
||||||
* @param checkPlayableMode true if the event does not really happen but it's checked if the event would be replaced
|
* @param checkPlayableMode true if the event does not really happen but
|
||||||
|
* it's checked if the event would be replaced
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean checkPlayableMode) {
|
public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean checkPlayableMode) {
|
||||||
for (ContinuousRuleModifyingEffect effect: continuousRuleModifyingEffects) {
|
for (ContinuousRuleModifyingEffect effect : continuousRuleModifyingEffects) {
|
||||||
if (!effect.checksEventType(event, game)) {
|
if (!effect.checksEventType(event, game)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -702,7 +712,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
do {
|
do {
|
||||||
HashMap<ReplacementEffect, HashSet<Ability>> rEffects = getApplicableReplacementEffects(event, game);
|
HashMap<ReplacementEffect, HashSet<Ability>> rEffects = getApplicableReplacementEffects(event, game);
|
||||||
// Remove all consumed effects (ability dependant)
|
// Remove all consumed effects (ability dependant)
|
||||||
for (Iterator<ReplacementEffect> it1 = rEffects.keySet().iterator(); it1.hasNext();){
|
for (Iterator<ReplacementEffect> it1 = rEffects.keySet().iterator(); it1.hasNext();) {
|
||||||
ReplacementEffect entry = it1.next();
|
ReplacementEffect entry = it1.next();
|
||||||
if (consumed.containsKey(entry.getId())) {
|
if (consumed.containsKey(entry.getId())) {
|
||||||
HashSet<UUID> consumedAbilitiesIds = consumed.get(entry.getId());
|
HashSet<UUID> consumedAbilitiesIds = consumed.get(entry.getId());
|
||||||
|
@ -814,14 +824,14 @@ public class ContinuousEffects implements Serializable {
|
||||||
removeInactiveEffects(game);
|
removeInactiveEffects(game);
|
||||||
List<ContinuousEffect> layerEffects = getLayeredEffects(game);
|
List<ContinuousEffect> layerEffects = getLayeredEffects(game);
|
||||||
List<ContinuousEffect> layer = filterLayeredEffects(layerEffects, Layer.CopyEffects_1);
|
List<ContinuousEffect> layer = filterLayeredEffects(layerEffects, Layer.CopyEffects_1);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.CopyEffects_1, SubLayer.NA, ability, game);
|
effect.apply(Layer.CopyEffects_1, SubLayer.NA, ability, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Reload layerEffect if copy effects were applied
|
//Reload layerEffect if copy effects were applied
|
||||||
if (layer.size()>0) {
|
if (layer.size() > 0) {
|
||||||
layerEffects = getLayeredEffects(game);
|
layerEffects = getLayeredEffects(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -830,7 +840,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
// for cases when control over permanents with change control abilities is changed
|
// for cases when control over permanents with change control abilities is changed
|
||||||
// e.g. Mind Control is controlled by Steal Enchantment
|
// e.g. Mind Control is controlled by Steal Enchantment
|
||||||
while (true) {
|
while (true) {
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.ControlChangingEffects_2, SubLayer.NA, ability, game);
|
effect.apply(Layer.ControlChangingEffects_2, SubLayer.NA, ability, game);
|
||||||
|
@ -844,21 +854,21 @@ public class ContinuousEffects implements Serializable {
|
||||||
game.getBattlefield().resetPermanentsControl();
|
game.getBattlefield().resetPermanentsControl();
|
||||||
}
|
}
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.TextChangingEffects_3);
|
layer = filterLayeredEffects(layerEffects, Layer.TextChangingEffects_3);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.TextChangingEffects_3, SubLayer.NA, ability, game);
|
effect.apply(Layer.TextChangingEffects_3, SubLayer.NA, ability, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.TypeChangingEffects_4);
|
layer = filterLayeredEffects(layerEffects, Layer.TypeChangingEffects_4);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.TypeChangingEffects_4, SubLayer.NA, ability, game);
|
effect.apply(Layer.TypeChangingEffects_4, SubLayer.NA, ability, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.ColorChangingEffects_5);
|
layer = filterLayeredEffects(layerEffects, Layer.ColorChangingEffects_5);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.ColorChangingEffects_5, SubLayer.NA, ability, game);
|
effect.apply(Layer.ColorChangingEffects_5, SubLayer.NA, ability, game);
|
||||||
|
@ -870,7 +880,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
while (!done) { // loop needed if a added effect adds again an effect (e.g. Level 5- of Joraga Treespeaker)
|
while (!done) { // loop needed if a added effect adds again an effect (e.g. Level 5- of Joraga Treespeaker)
|
||||||
done = true;
|
done = true;
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.AbilityAddingRemovingEffects_6);
|
layer = filterLayeredEffects(layerEffects, Layer.AbilityAddingRemovingEffects_6);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
if (layerEffects.contains(effect)) {
|
if (layerEffects.contains(effect)) {
|
||||||
List<Ability> appliedAbilities = appliedEffects.get(effect);
|
List<Ability> appliedAbilities = appliedEffects.get(effect);
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
|
@ -892,13 +902,13 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.PTChangingEffects_7);
|
layer = filterLayeredEffects(layerEffects, Layer.PTChangingEffects_7);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.PTChangingEffects_7, SubLayer.SetPT_7b, ability, game);
|
effect.apply(Layer.PTChangingEffects_7, SubLayer.SetPT_7b, ability, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, ability, game);
|
effect.apply(Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, ability, game);
|
||||||
|
@ -907,21 +917,21 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
applyCounters.apply(Layer.PTChangingEffects_7, SubLayer.Counters_7d, null, game);
|
applyCounters.apply(Layer.PTChangingEffects_7, SubLayer.Counters_7d, null, game);
|
||||||
|
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.PTChangingEffects_7, SubLayer.SwitchPT_e, ability, game);
|
effect.apply(Layer.PTChangingEffects_7, SubLayer.SwitchPT_e, ability, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.PlayerEffects);
|
layer = filterLayeredEffects(layerEffects, Layer.PlayerEffects);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.PlayerEffects, SubLayer.NA, ability, game);
|
effect.apply(Layer.PlayerEffects, SubLayer.NA, ability, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.RulesEffects);
|
layer = filterLayeredEffects(layerEffects, Layer.RulesEffects);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect : layer) {
|
||||||
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
effect.apply(Layer.RulesEffects, SubLayer.NA, ability, game);
|
effect.apply(Layer.RulesEffects, SubLayer.NA, ability, game);
|
||||||
|
@ -930,9 +940,10 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a continuous ability with a reference to a sourceId.
|
* Adds a continuous ability with a reference to a sourceId. It's used for
|
||||||
* It's used for effects that cease to exist again
|
* effects that cease to exist again So this effects were removed again
|
||||||
* So this effects were removed again before each applyEffecs
|
* before each applyEffecs
|
||||||
|
*
|
||||||
* @param effect
|
* @param effect
|
||||||
* @param sourceId
|
* @param sourceId
|
||||||
* @param source
|
* @param source
|
||||||
|
@ -962,32 +973,32 @@ public class ContinuousEffects implements Serializable {
|
||||||
logger.error("Effect is null: " + source.toString());
|
logger.error("Effect is null: " + source.toString());
|
||||||
return;
|
return;
|
||||||
} else if (source == null) {
|
} else if (source == null) {
|
||||||
logger.warn("Adding effect without ability : " +effect.toString());
|
logger.warn("Adding effect without ability : " + effect.toString());
|
||||||
}
|
}
|
||||||
switch (effect.getEffectType()) {
|
switch (effect.getEffectType()) {
|
||||||
case REPLACEMENT:
|
case REPLACEMENT:
|
||||||
case REDIRECTION:
|
case REDIRECTION:
|
||||||
ReplacementEffect newReplacementEffect = (ReplacementEffect)effect;
|
ReplacementEffect newReplacementEffect = (ReplacementEffect) effect;
|
||||||
replacementEffects.addEffect(newReplacementEffect, source);
|
replacementEffects.addEffect(newReplacementEffect, source);
|
||||||
break;
|
break;
|
||||||
case PREVENTION:
|
case PREVENTION:
|
||||||
PreventionEffect newPreventionEffect = (PreventionEffect)effect;
|
PreventionEffect newPreventionEffect = (PreventionEffect) effect;
|
||||||
preventionEffects.addEffect(newPreventionEffect, source);
|
preventionEffects.addEffect(newPreventionEffect, source);
|
||||||
break;
|
break;
|
||||||
case RESTRICTION:
|
case RESTRICTION:
|
||||||
RestrictionEffect newRestrictionEffect = (RestrictionEffect)effect;
|
RestrictionEffect newRestrictionEffect = (RestrictionEffect) effect;
|
||||||
restrictionEffects.addEffect(newRestrictionEffect, source);
|
restrictionEffects.addEffect(newRestrictionEffect, source);
|
||||||
break;
|
break;
|
||||||
case RESTRICTION_UNTAP_NOT_MORE_THAN:
|
case RESTRICTION_UNTAP_NOT_MORE_THAN:
|
||||||
RestrictionUntapNotMoreThanEffect newRestrictionUntapNotMoreThanEffect = (RestrictionUntapNotMoreThanEffect)effect;
|
RestrictionUntapNotMoreThanEffect newRestrictionUntapNotMoreThanEffect = (RestrictionUntapNotMoreThanEffect) effect;
|
||||||
restrictionUntapNotMoreThanEffects.addEffect(newRestrictionUntapNotMoreThanEffect, source);
|
restrictionUntapNotMoreThanEffects.addEffect(newRestrictionUntapNotMoreThanEffect, source);
|
||||||
break;
|
break;
|
||||||
case REQUIREMENT:
|
case REQUIREMENT:
|
||||||
RequirementEffect newRequirementEffect = (RequirementEffect)effect;
|
RequirementEffect newRequirementEffect = (RequirementEffect) effect;
|
||||||
requirementEffects.addEffect(newRequirementEffect, source);
|
requirementEffects.addEffect(newRequirementEffect, source);
|
||||||
break;
|
break;
|
||||||
case ASTHOUGH:
|
case ASTHOUGH:
|
||||||
AsThoughEffect newAsThoughEffect = (AsThoughEffect)effect;
|
AsThoughEffect newAsThoughEffect = (AsThoughEffect) effect;
|
||||||
if (!asThoughEffectsMap.containsKey(newAsThoughEffect.getAsThoughEffectType())) {
|
if (!asThoughEffectsMap.containsKey(newAsThoughEffect.getAsThoughEffectType())) {
|
||||||
ContinuousEffectsList<AsThoughEffect> list = new ContinuousEffectsList<>();
|
ContinuousEffectsList<AsThoughEffect> list = new ContinuousEffectsList<>();
|
||||||
allEffectsLists.add(list);
|
allEffectsLists.add(list);
|
||||||
|
@ -996,15 +1007,15 @@ public class ContinuousEffects implements Serializable {
|
||||||
asThoughEffectsMap.get(newAsThoughEffect.getAsThoughEffectType()).addEffect(newAsThoughEffect, source);
|
asThoughEffectsMap.get(newAsThoughEffect.getAsThoughEffectType()).addEffect(newAsThoughEffect, source);
|
||||||
break;
|
break;
|
||||||
case COSTMODIFICATION:
|
case COSTMODIFICATION:
|
||||||
CostModificationEffect newCostModificationEffect = (CostModificationEffect)effect;
|
CostModificationEffect newCostModificationEffect = (CostModificationEffect) effect;
|
||||||
costModificationEffects.addEffect(newCostModificationEffect, source);
|
costModificationEffects.addEffect(newCostModificationEffect, source);
|
||||||
break;
|
break;
|
||||||
case SPLICE:
|
case SPLICE:
|
||||||
SpliceCardEffect newSpliceCardEffect = (SpliceCardEffect)effect;
|
SpliceCardEffect newSpliceCardEffect = (SpliceCardEffect) effect;
|
||||||
spliceCardEffects.addEffect(newSpliceCardEffect, source);
|
spliceCardEffects.addEffect(newSpliceCardEffect, source);
|
||||||
break;
|
break;
|
||||||
case CONTINUOUS_RULE_MODIFICATION:
|
case CONTINUOUS_RULE_MODIFICATION:
|
||||||
ContinuousRuleModifyingEffect newContinuousRuleModifiyingEffect = (ContinuousRuleModifyingEffect)effect;
|
ContinuousRuleModifyingEffect newContinuousRuleModifiyingEffect = (ContinuousRuleModifyingEffect) effect;
|
||||||
continuousRuleModifyingEffects.addEffect(newContinuousRuleModifiyingEffect, source);
|
continuousRuleModifyingEffects.addEffect(newContinuousRuleModifiyingEffect, source);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1063,7 +1074,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
requirementEffects.removeEffects(entry.getKey().getId(), entry.getValue());
|
requirementEffects.removeEffects(entry.getKey().getId(), entry.getValue());
|
||||||
break;
|
break;
|
||||||
case ASTHOUGH:
|
case ASTHOUGH:
|
||||||
AsThoughEffect newAsThoughEffect = (AsThoughEffect)entry.getKey();
|
AsThoughEffect newAsThoughEffect = (AsThoughEffect) entry.getKey();
|
||||||
if (!asThoughEffectsMap.containsKey(newAsThoughEffect.getAsThoughEffectType())) {
|
if (!asThoughEffectsMap.containsKey(newAsThoughEffect.getAsThoughEffectType())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1091,10 +1102,10 @@ public class ContinuousEffects implements Serializable {
|
||||||
Map<String, String> texts = new LinkedHashMap<>();
|
Map<String, String> texts = new LinkedHashMap<>();
|
||||||
for (Map.Entry<ReplacementEffect, HashSet<Ability>> entry : rEffects.entrySet()) {
|
for (Map.Entry<ReplacementEffect, HashSet<Ability>> entry : rEffects.entrySet()) {
|
||||||
if (entry.getValue() != null) {
|
if (entry.getValue() != null) {
|
||||||
for (Ability ability :entry.getValue()) {
|
for (Ability ability : entry.getValue()) {
|
||||||
MageObject object = game.getObject(ability.getSourceId());
|
MageObject object = game.getObject(ability.getSourceId());
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), object.getName() +": " + ability.getRule(object.getName()));
|
texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), object.getName() + ": " + ability.getRule(object.getName()));
|
||||||
} else {
|
} else {
|
||||||
texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), entry.getKey().getText(null));
|
texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), entry.getKey().getText(null));
|
||||||
}
|
}
|
||||||
|
@ -1112,7 +1123,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
public UUID getControllerOfSourceId(UUID sourceId) {
|
public UUID getControllerOfSourceId(UUID sourceId) {
|
||||||
UUID controllerFound = null;
|
UUID controllerFound = null;
|
||||||
for (PreventionEffect effect: preventionEffects) {
|
for (PreventionEffect effect : preventionEffects) {
|
||||||
HashSet<Ability> abilities = preventionEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = preventionEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if (ability.getSourceId().equals(sourceId)) {
|
if (ability.getSourceId().equals(sourceId)) {
|
||||||
|
@ -1125,7 +1136,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ReplacementEffect effect: replacementEffects) {
|
for (ReplacementEffect effect : replacementEffects) {
|
||||||
HashSet<Ability> abilities = replacementEffects.getAbility(effect.getId());
|
HashSet<Ability> abilities = replacementEffects.getAbility(effect.getId());
|
||||||
for (Ability ability : abilities) {
|
for (Ability ability : abilities) {
|
||||||
if (ability.getSourceId().equals(sourceId)) {
|
if (ability.getSourceId().equals(sourceId)) {
|
||||||
|
@ -1143,6 +1154,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContinuousEffectSorter implements Comparator<ContinuousEffect>, Serializable {
|
class ContinuousEffectSorter implements Comparator<ContinuousEffect>, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(ContinuousEffect one, ContinuousEffect two) {
|
public int compare(ContinuousEffect one, ContinuousEffect two) {
|
||||||
return Long.compare(one.getOrder(), two.getOrder());
|
return Long.compare(one.getOrder(), two.getOrder());
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.effects.common.search;
|
package mage.abilities.effects.common.search;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -93,9 +92,9 @@ public class SearchLibraryPutInHandEffect extends SearchEffect {
|
||||||
if (controller.searchLibrary(target, game)) {
|
if (controller.searchLibrary(target, game)) {
|
||||||
if (target.getTargets().size() > 0) {
|
if (target.getTargets().size() > 0) {
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
for (UUID cardId: target.getTargets()) {
|
for (UUID cardId : target.getTargets()) {
|
||||||
Card card = controller.getLibrary().remove(cardId, game);
|
Card card = controller.getLibrary().remove(cardId, game);
|
||||||
if (card != null){
|
if (card != null) {
|
||||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, revealCards);
|
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, revealCards);
|
||||||
if (revealCards) {
|
if (revealCards) {
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
|
@ -106,7 +105,7 @@ public class SearchLibraryPutInHandEffect extends SearchEffect {
|
||||||
String name = "Reveal";
|
String name = "Reveal";
|
||||||
Card sourceCard = game.getCard(source.getSourceId());
|
Card sourceCard = game.getCard(source.getSourceId());
|
||||||
if (sourceCard != null) {
|
if (sourceCard != null) {
|
||||||
name = sourceCard.getName();
|
name = sourceCard.getIdName();
|
||||||
}
|
}
|
||||||
controller.revealCards(name, cards, game);
|
controller.revealCards(name, cards, game);
|
||||||
}
|
}
|
||||||
|
@ -126,14 +125,12 @@ public class SearchLibraryPutInHandEffect extends SearchEffect {
|
||||||
if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
|
if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) {
|
||||||
sb.append("up to ").append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" ");
|
sb.append("up to ").append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" ");
|
||||||
sb.append(target.getTargetName()).append(revealCards ? ", reveal them, " : "").append(" and put them into your hand");
|
sb.append(target.getTargetName()).append(revealCards ? ", reveal them, " : "").append(" and put them into your hand");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sb.append("a ").append(target.getTargetName()).append(revealCards ? ", reveal it, " : "").append(" and put that card into your hand");
|
sb.append("a ").append(target.getTargetName()).append(revealCards ? ", reveal it, " : "").append(" and put that card into your hand");
|
||||||
}
|
}
|
||||||
if (forceShuffle) {
|
if (forceShuffle) {
|
||||||
sb.append(". Then shuffle your library");
|
sb.append(". Then shuffle your library");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sb.append(". If you do, shuffle your library");
|
sb.append(". If you do, shuffle your library");
|
||||||
}
|
}
|
||||||
staticText = sb.toString();
|
staticText = sb.toString();
|
||||||
|
|
|
@ -1,35 +1,51 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.game;
|
package mage.game;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.*;
|
import mage.abilities.Abilities;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.ActivatedAbility;
|
||||||
|
import mage.abilities.DelayedTriggeredAbilities;
|
||||||
|
import mage.abilities.DelayedTriggeredAbility;
|
||||||
|
import mage.abilities.Mode;
|
||||||
|
import mage.abilities.SpecialActions;
|
||||||
|
import mage.abilities.StaticAbility;
|
||||||
|
import mage.abilities.TriggeredAbilities;
|
||||||
|
import mage.abilities.TriggeredAbility;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.ContinuousEffects;
|
import mage.abilities.effects.ContinuousEffects;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
|
@ -53,26 +69,22 @@ import mage.players.PlayerList;
|
||||||
import mage.players.Players;
|
import mage.players.Players;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.util.Copyable;
|
import mage.util.Copyable;
|
||||||
|
import mage.util.ThreadLocalStringBuilder;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
import mage.watchers.Watchers;
|
import mage.watchers.Watchers;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import mage.util.ThreadLocalStringBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*
|
*
|
||||||
* since at any time the game state may be copied and restored you cannot
|
* since at any time the game state may be copied and restored you cannot rely
|
||||||
* rely on any object maintaining it's instance
|
* on any object maintaining it's instance it then becomes necessary to only
|
||||||
* it then becomes necessary to only refer to objects by their ids since
|
* refer to objects by their ids since these will always remain constant
|
||||||
* these will always remain constant throughout its lifetime
|
* throughout its lifetime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GameState implements Serializable, Copyable<GameState> {
|
public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
|
|
||||||
private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(1024);
|
private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(1024);
|
||||||
|
|
||||||
private final Players players;
|
private final Players players;
|
||||||
|
@ -154,7 +166,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
this.extraTurn = state.extraTurn;
|
this.extraTurn = state.extraTurn;
|
||||||
this.legendaryRuleActive = state.legendaryRuleActive;
|
this.legendaryRuleActive = state.legendaryRuleActive;
|
||||||
this.effects = state.effects.copy();
|
this.effects = state.effects.copy();
|
||||||
for (TriggeredAbility trigger: state.triggered) {
|
for (TriggeredAbility trigger : state.triggered) {
|
||||||
this.triggered.add(trigger.copy());
|
this.triggered.add(trigger.copy());
|
||||||
}
|
}
|
||||||
this.triggers = state.triggers.copy();
|
this.triggers = state.triggers.copy();
|
||||||
|
@ -163,15 +175,15 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
this.combat = state.combat.copy();
|
this.combat = state.combat.copy();
|
||||||
this.turnMods = state.turnMods.copy();
|
this.turnMods = state.turnMods.copy();
|
||||||
this.watchers = state.watchers.copy();
|
this.watchers = state.watchers.copy();
|
||||||
for (Map.Entry<String, Object> entry: state.values.entrySet()) {
|
for (Map.Entry<String, Object> entry : state.values.entrySet()) {
|
||||||
this.values.put(entry.getKey(), entry.getValue());
|
this.values.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
this.zones.putAll(state.zones);
|
this.zones.putAll(state.zones);
|
||||||
this.simultaneousEvents.addAll(state.simultaneousEvents);
|
this.simultaneousEvents.addAll(state.simultaneousEvents);
|
||||||
for (Map.Entry<UUID, CardState> entry: state.cardState.entrySet()) {
|
for (Map.Entry<UUID, CardState> entry : state.cardState.entrySet()) {
|
||||||
cardState.put(entry.getKey(), entry.getValue().copy());
|
cardState.put(entry.getKey(), entry.getValue().copy());
|
||||||
}
|
}
|
||||||
for (Map.Entry<UUID, CardAttribute> entry: state.cardAttribute.entrySet()) {
|
for (Map.Entry<UUID, CardAttribute> entry : state.cardAttribute.entrySet()) {
|
||||||
cardAttribute.put(entry.getKey(), entry.getValue().copy());
|
cardAttribute.put(entry.getKey(), entry.getValue().copy());
|
||||||
}
|
}
|
||||||
this.zoneChangeCounter.putAll(state.zoneChangeCounter);
|
this.zoneChangeCounter.putAll(state.zoneChangeCounter);
|
||||||
|
@ -204,7 +216,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
this.turnMods = state.turnMods;
|
this.turnMods = state.turnMods;
|
||||||
this.watchers = state.watchers;
|
this.watchers = state.watchers;
|
||||||
this.values = state.values;
|
this.values = state.values;
|
||||||
for (Player copyPlayer: state.players.values()) {
|
for (Player copyPlayer : state.players.values()) {
|
||||||
Player origPlayer = players.get(copyPlayer.getId());
|
Player origPlayer = players.get(copyPlayer.getId());
|
||||||
origPlayer.restore(copyPlayer);
|
origPlayer.restore(copyPlayer);
|
||||||
}
|
}
|
||||||
|
@ -233,33 +245,32 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
sb.append(turn.getValue(turnNum));
|
sb.append(turn.getValue(turnNum));
|
||||||
sb.append(activePlayerId).append(priorityPlayerId);
|
sb.append(activePlayerId).append(priorityPlayerId);
|
||||||
|
|
||||||
for (Player player: players.values()) {
|
for (Player player : players.values()) {
|
||||||
sb.append("player").append(player.getLife()).append("hand");
|
sb.append("player").append(player.getLife()).append("hand");
|
||||||
if (useHidden) {
|
if (useHidden) {
|
||||||
sb.append(player.getHand());
|
sb.append(player.getHand());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sb.append(player.getHand().size());
|
sb.append(player.getHand().size());
|
||||||
}
|
}
|
||||||
sb.append("library").append(player.getLibrary().size()).append("graveyard").append(player.getGraveyard());
|
sb.append("library").append(player.getLibrary().size()).append("graveyard").append(player.getGraveyard());
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("permanents");
|
sb.append("permanents");
|
||||||
for (Permanent permanent: battlefield.getAllPermanents()) {
|
for (Permanent permanent : battlefield.getAllPermanents()) {
|
||||||
sb.append(permanent.getValue());
|
sb.append(permanent.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("spells");
|
sb.append("spells");
|
||||||
for (StackObject spell: stack) {
|
for (StackObject spell : stack) {
|
||||||
sb.append(spell.getControllerId()).append(spell.getName());
|
sb.append(spell.getControllerId()).append(spell.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ExileZone zone: exile.getExileZones()) {
|
for (ExileZone zone : exile.getExileZones()) {
|
||||||
sb.append("exile").append(zone.getName()).append(zone);
|
sb.append("exile").append(zone.getName()).append(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("combat");
|
sb.append("combat");
|
||||||
for (CombatGroup group: combat.getGroups()) {
|
for (CombatGroup group : combat.getGroups()) {
|
||||||
sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
|
sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,12 +283,11 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
sb.append(turn.getValue(turnNum));
|
sb.append(turn.getValue(turnNum));
|
||||||
sb.append(activePlayerId).append(priorityPlayerId);
|
sb.append(activePlayerId).append(priorityPlayerId);
|
||||||
|
|
||||||
for (Player player: players.values()) {
|
for (Player player : players.values()) {
|
||||||
sb.append("player").append(player.isPassed()).append(player.getLife()).append("hand");
|
sb.append("player").append(player.isPassed()).append(player.getLife()).append("hand");
|
||||||
if (useHidden) {
|
if (useHidden) {
|
||||||
sb.append(player.getHand().getValue(game));
|
sb.append(player.getHand().getValue(game));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sb.append(player.getHand().size());
|
sb.append(player.getHand().size());
|
||||||
}
|
}
|
||||||
sb.append("library").append(player.getLibrary().size());
|
sb.append("library").append(player.getLibrary().size());
|
||||||
|
@ -287,38 +297,38 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
sb.append("permanents");
|
sb.append("permanents");
|
||||||
List<String> perms = new ArrayList<>();
|
List<String> perms = new ArrayList<>();
|
||||||
for (Permanent permanent: battlefield.getAllPermanents()) {
|
for (Permanent permanent : battlefield.getAllPermanents()) {
|
||||||
perms.add(permanent.getValue());
|
perms.add(permanent.getValue());
|
||||||
}
|
}
|
||||||
Collections.sort(perms);
|
Collections.sort(perms);
|
||||||
sb.append(perms);
|
sb.append(perms);
|
||||||
|
|
||||||
sb.append("spells");
|
sb.append("spells");
|
||||||
for (StackObject spell: stack) {
|
for (StackObject spell : stack) {
|
||||||
sb.append(spell.getControllerId()).append(spell.getName());
|
sb.append(spell.getControllerId()).append(spell.getName());
|
||||||
sb.append(spell.getStackAbility().toString());
|
sb.append(spell.getStackAbility().toString());
|
||||||
for (Mode mode: spell.getStackAbility().getModes().values()) {
|
for (Mode mode : spell.getStackAbility().getModes().values()) {
|
||||||
if (!mode.getTargets().isEmpty()) {
|
if (!mode.getTargets().isEmpty()) {
|
||||||
sb.append("targets");
|
sb.append("targets");
|
||||||
for (Target target: mode.getTargets()) {
|
for (Target target : mode.getTargets()) {
|
||||||
sb.append(target.getTargets());
|
sb.append(target.getTargets());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mode.getChoices().isEmpty()) {
|
if (!mode.getChoices().isEmpty()) {
|
||||||
sb.append("choices");
|
sb.append("choices");
|
||||||
for (Choice choice: mode.getChoices()) {
|
for (Choice choice : mode.getChoices()) {
|
||||||
sb.append(choice.getChoice());
|
sb.append(choice.getChoice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ExileZone zone: exile.getExileZones()) {
|
for (ExileZone zone : exile.getExileZones()) {
|
||||||
sb.append("exile").append(zone.getName()).append(zone.getValue(game));
|
sb.append("exile").append(zone.getName()).append(zone.getValue(game));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("combat");
|
sb.append("combat");
|
||||||
for (CombatGroup group: combat.getGroups()) {
|
for (CombatGroup group : combat.getGroups()) {
|
||||||
sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
|
sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,12 +341,11 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
sb.append(turn.getValue(turnNum));
|
sb.append(turn.getValue(turnNum));
|
||||||
sb.append(activePlayerId).append(priorityPlayerId);
|
sb.append(activePlayerId).append(priorityPlayerId);
|
||||||
|
|
||||||
for (Player player: players.values()) {
|
for (Player player : players.values()) {
|
||||||
sb.append("player").append(player.isPassed()).append(player.getLife()).append("hand");
|
sb.append("player").append(player.isPassed()).append(player.getLife()).append("hand");
|
||||||
if (playerId == player.getId()) {
|
if (playerId == player.getId()) {
|
||||||
sb.append(player.getHand().getValue(game));
|
sb.append(player.getHand().getValue(game));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sb.append(player.getHand().size());
|
sb.append(player.getHand().size());
|
||||||
}
|
}
|
||||||
sb.append("library").append(player.getLibrary().size());
|
sb.append("library").append(player.getLibrary().size());
|
||||||
|
@ -346,38 +355,38 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
sb.append("permanents");
|
sb.append("permanents");
|
||||||
List<String> perms = new ArrayList<>();
|
List<String> perms = new ArrayList<>();
|
||||||
for (Permanent permanent: battlefield.getAllPermanents()) {
|
for (Permanent permanent : battlefield.getAllPermanents()) {
|
||||||
perms.add(permanent.getValue());
|
perms.add(permanent.getValue());
|
||||||
}
|
}
|
||||||
Collections.sort(perms);
|
Collections.sort(perms);
|
||||||
sb.append(perms);
|
sb.append(perms);
|
||||||
|
|
||||||
sb.append("spells");
|
sb.append("spells");
|
||||||
for (StackObject spell: stack) {
|
for (StackObject spell : stack) {
|
||||||
sb.append(spell.getControllerId()).append(spell.getName());
|
sb.append(spell.getControllerId()).append(spell.getName());
|
||||||
sb.append(spell.getStackAbility().toString());
|
sb.append(spell.getStackAbility().toString());
|
||||||
for (Mode mode: spell.getStackAbility().getModes().values()) {
|
for (Mode mode : spell.getStackAbility().getModes().values()) {
|
||||||
if (!mode.getTargets().isEmpty()) {
|
if (!mode.getTargets().isEmpty()) {
|
||||||
sb.append("targets");
|
sb.append("targets");
|
||||||
for (Target target: mode.getTargets()) {
|
for (Target target : mode.getTargets()) {
|
||||||
sb.append(target.getTargets());
|
sb.append(target.getTargets());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mode.getChoices().isEmpty()) {
|
if (!mode.getChoices().isEmpty()) {
|
||||||
sb.append("choices");
|
sb.append("choices");
|
||||||
for (Choice choice: mode.getChoices()) {
|
for (Choice choice : mode.getChoices()) {
|
||||||
sb.append(choice.getChoice());
|
sb.append(choice.getChoice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ExileZone zone: exile.getExileZones()) {
|
for (ExileZone zone : exile.getExileZones()) {
|
||||||
sb.append("exile").append(zone.getName()).append(zone.getValue(game));
|
sb.append("exile").append(zone.getName()).append(zone.getValue(game));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("combat");
|
sb.append("combat");
|
||||||
for (CombatGroup group: combat.getGroups()) {
|
for (CombatGroup group : combat.getGroups()) {
|
||||||
sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
|
sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,8 +471,9 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the game step counter. This counter isgoing one up for
|
* Gets the game step counter. This counter isgoing one up for every played
|
||||||
* every played step during the game.
|
* step during the game.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getStepNum() {
|
public int getStepNum() {
|
||||||
|
@ -520,7 +530,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
public void applyEffects(Game game) {
|
public void applyEffects(Game game) {
|
||||||
game.resetShortLivingLKI();
|
game.resetShortLivingLKI();
|
||||||
for (Player player: players.values()) {
|
for (Player player : players.values()) {
|
||||||
player.reset();
|
player.reset();
|
||||||
}
|
}
|
||||||
battlefield.reset(game);
|
battlefield.reset(game);
|
||||||
|
@ -557,10 +567,9 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
// public void addMessage(String message) {
|
// public void addMessage(String message) {
|
||||||
// this.messages.add(message);
|
// this.messages.add(message);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all players of the game ignoring range or
|
* Returns a list of all players of the game ignoring range or if a player
|
||||||
* if a player has lost or left the game.
|
* has lost or left the game.
|
||||||
*
|
*
|
||||||
* @return playerList
|
* @return playerList
|
||||||
*/
|
*/
|
||||||
|
@ -569,25 +578,27 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all active players of the game, setting the
|
* Returns a list of all active players of the game, setting the playerId to
|
||||||
* playerId to the current player of the list.
|
* the current player of the list.
|
||||||
*
|
*
|
||||||
* @param playerId
|
* @param playerId
|
||||||
* @return playerList
|
* @return playerList
|
||||||
*/
|
*/
|
||||||
public PlayerList getPlayerList(UUID playerId) {
|
public PlayerList getPlayerList(UUID playerId) {
|
||||||
PlayerList newPlayerList = new PlayerList();
|
PlayerList newPlayerList = new PlayerList();
|
||||||
for (Player player: players.values()) {
|
for (Player player : players.values()) {
|
||||||
if (!player.hasLeft()&& !player.hasLost()) {
|
if (!player.hasLeft() && !player.hasLost()) {
|
||||||
newPlayerList.add(player.getId());
|
newPlayerList.add(player.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newPlayerList.setCurrent(playerId);
|
newPlayerList.setCurrent(playerId);
|
||||||
return newPlayerList;
|
return newPlayerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all active players of the game in range of playerId,
|
* Returns a list of all active players of the game in range of playerId,
|
||||||
* also setting the playerId to the current player of the list.
|
* also setting the playerId to the first/current player of the list. Also
|
||||||
|
* returning the other players in turn order.
|
||||||
*
|
*
|
||||||
* @param playerId
|
* @param playerId
|
||||||
* @param game
|
* @param game
|
||||||
|
@ -597,8 +608,8 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
PlayerList newPlayerList = new PlayerList();
|
PlayerList newPlayerList = new PlayerList();
|
||||||
Player currentPlayer = game.getPlayer(playerId);
|
Player currentPlayer = game.getPlayer(playerId);
|
||||||
if (currentPlayer != null) {
|
if (currentPlayer != null) {
|
||||||
for (Player player: players.values()) {
|
for (Player player : players.values()) {
|
||||||
if (!player.hasLeft()&& !player.hasLost() && currentPlayer.getInRange().contains(player.getId())) {
|
if (!player.hasLeft() && !player.hasLost() && currentPlayer.getInRange().contains(player.getId())) {
|
||||||
newPlayerList.add(player.getId());
|
newPlayerList.add(player.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,11 +648,12 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
List<GameEvent> eventsToHandle = new ArrayList<>();
|
List<GameEvent> eventsToHandle = new ArrayList<>();
|
||||||
eventsToHandle.addAll(simultaneousEvents);
|
eventsToHandle.addAll(simultaneousEvents);
|
||||||
simultaneousEvents.clear();
|
simultaneousEvents.clear();
|
||||||
for (GameEvent event:eventsToHandle) {
|
for (GameEvent event : eventsToHandle) {
|
||||||
this.handleEvent(event, game);
|
this.handleEvent(event, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSimultaneousEvents() {
|
public boolean hasSimultaneousEvents() {
|
||||||
return !simultaneousEvents.isEmpty();
|
return !simultaneousEvents.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -661,7 +673,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
public void addCard(Card card) {
|
public void addCard(Card card) {
|
||||||
setZone(card.getId(), Zone.OUTSIDE);
|
setZone(card.getId(), Zone.OUTSIDE);
|
||||||
for (Ability ability: card.getAbilities()) {
|
for (Ability ability : card.getAbilities()) {
|
||||||
addAbility(ability, card);
|
addAbility(ability, card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,14 +688,15 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
// TODO Watchers?
|
// TODO Watchers?
|
||||||
// TODO Abilities?
|
// TODO Abilities?
|
||||||
if (card.isSplitCard()) {
|
if (card.isSplitCard()) {
|
||||||
removeCopiedCard( ((SplitCard)card).getLeftHalfCard());
|
removeCopiedCard(((SplitCard) card).getLeftHalfCard());
|
||||||
removeCopiedCard( ((SplitCard)card).getRightHalfCard());
|
removeCopiedCard(((SplitCard) card).getRightHalfCard());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for adding abilities that exist permanent on cards/permanents and are not
|
* Used for adding abilities that exist permanent on cards/permanents and
|
||||||
* only gained for a certain time (e.g. until end of turn).
|
* are not only gained for a certain time (e.g. until end of turn).
|
||||||
|
*
|
||||||
* @param ability
|
* @param ability
|
||||||
* @param attachedTo
|
* @param attachedTo
|
||||||
*/
|
*/
|
||||||
|
@ -693,45 +706,45 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
public void addAbility(Ability ability, MageObject attachedTo) {
|
public void addAbility(Ability ability, MageObject attachedTo) {
|
||||||
if (ability instanceof StaticAbility) {
|
if (ability instanceof StaticAbility) {
|
||||||
for (Mode mode: ability.getModes().values()) {
|
for (Mode mode : ability.getModes().values()) {
|
||||||
for (Effect effect: mode.getEffects()) {
|
for (Effect effect : mode.getEffects()) {
|
||||||
if (effect instanceof ContinuousEffect) {
|
if (effect instanceof ContinuousEffect) {
|
||||||
addEffect((ContinuousEffect)effect, ability);
|
addEffect((ContinuousEffect) effect, ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (ability instanceof TriggeredAbility) {
|
||||||
else if (ability instanceof TriggeredAbility) {
|
this.triggers.add((TriggeredAbility) ability, attachedTo);
|
||||||
this.triggers.add((TriggeredAbility)ability, attachedTo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abilities that are applied to other objects or applie for a certain time span
|
* Abilities that are applied to other objects or applie for a certain time
|
||||||
|
* span
|
||||||
|
*
|
||||||
* @param ability
|
* @param ability
|
||||||
* @param sourceId
|
* @param sourceId
|
||||||
* @param attachedTo
|
* @param attachedTo
|
||||||
*/
|
*/
|
||||||
public void addAbility(Ability ability, UUID sourceId, Card attachedTo) {
|
public void addAbility(Ability ability, UUID sourceId, Card attachedTo) {
|
||||||
if (ability instanceof StaticAbility) {
|
if (ability instanceof StaticAbility) {
|
||||||
for (Mode mode: ability.getModes().values()) {
|
for (Mode mode : ability.getModes().values()) {
|
||||||
for (Effect effect: mode.getEffects()) {
|
for (Effect effect : mode.getEffects()) {
|
||||||
if (effect instanceof ContinuousEffect) {
|
if (effect instanceof ContinuousEffect) {
|
||||||
addEffect((ContinuousEffect)effect, sourceId, ability);
|
addEffect((ContinuousEffect) effect, sourceId, ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (ability instanceof TriggeredAbility) {
|
||||||
else if (ability instanceof TriggeredAbility) {
|
|
||||||
// TODO: add sources for triggers - the same way as in addEffect: sources
|
// TODO: add sources for triggers - the same way as in addEffect: sources
|
||||||
this.triggers.add((TriggeredAbility)ability, sourceId, attachedTo);
|
this.triggers.add((TriggeredAbility) ability, sourceId, attachedTo);
|
||||||
}
|
}
|
||||||
for (Watcher watcher: ability.getWatchers()) {
|
for (Watcher watcher : ability.getWatchers()) {
|
||||||
watcher.setControllerId(attachedTo.getOwnerId());
|
watcher.setControllerId(attachedTo.getOwnerId());
|
||||||
watcher.setSourceId(attachedTo.getId());
|
watcher.setSourceId(attachedTo.getId());
|
||||||
watchers.add(watcher);
|
watchers.add(watcher);
|
||||||
}
|
}
|
||||||
for (Ability sub: ability.getSubAbilities()) {
|
for (Ability sub : ability.getSubAbilities()) {
|
||||||
addAbility(sub, sourceId, attachedTo);
|
addAbility(sub, sourceId, attachedTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -739,7 +752,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
public void addCommandObject(CommandObject commandObject) {
|
public void addCommandObject(CommandObject commandObject) {
|
||||||
getCommand().add(commandObject);
|
getCommand().add(commandObject);
|
||||||
setZone(commandObject.getId(), Zone.COMMAND);
|
setZone(commandObject.getId(), Zone.COMMAND);
|
||||||
for (Ability ability: commandObject.getAbilities()) {
|
for (Ability ability : commandObject.getAbilities()) {
|
||||||
addAbility(ability, commandObject);
|
addAbility(ability, commandObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -757,8 +770,8 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDelayedTriggeredAbility(UUID abilityId) {
|
public void removeDelayedTriggeredAbility(UUID abilityId) {
|
||||||
for (DelayedTriggeredAbility ability: delayed) {
|
for (DelayedTriggeredAbility ability : delayed) {
|
||||||
if (ability.getId().equals(abilityId)) {
|
if (ability.getId().equals(abilityId)) {
|
||||||
delayed.remove(ability);
|
delayed.remove(ability);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -767,7 +780,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
public List<TriggeredAbility> getTriggered(UUID controllerId) {
|
public List<TriggeredAbility> getTriggered(UUID controllerId) {
|
||||||
List<TriggeredAbility> triggereds = new ArrayList<>();
|
List<TriggeredAbility> triggereds = new ArrayList<>();
|
||||||
for (TriggeredAbility ability: triggered) {
|
for (TriggeredAbility ability : triggered) {
|
||||||
if (ability.getControllerId().equals(controllerId)) {
|
if (ability.getControllerId().equals(controllerId)) {
|
||||||
triggereds.add(ability);
|
triggereds.add(ability);
|
||||||
}
|
}
|
||||||
|
@ -788,9 +801,9 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Best only use immutable objects, otherwise the states/values of the object may be
|
* Best only use immutable objects, otherwise the states/values of the
|
||||||
* changed by AI simulation, because the Value objects are not copied as the state
|
* object may be changed by AI simulation, because the Value objects are not
|
||||||
* class is copied.
|
* copied as the state class is copied.
|
||||||
*
|
*
|
||||||
* @param valueId
|
* @param valueId
|
||||||
* @param value
|
* @param value
|
||||||
|
@ -800,11 +813,14 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Other abilities are used to implement some special kind of continuous effects that give abilities to non permanents.
|
* Other abilities are used to implement some special kind of continuous
|
||||||
|
* effects that give abilities to non permanents.
|
||||||
*
|
*
|
||||||
* Crucible of Worlds - You may play land cards from your graveyard.
|
* Crucible of Worlds - You may play land cards from your graveyard. Past in
|
||||||
* Past in Flames - Each instant and sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost.
|
* Flames - Each instant and sorcery card in your graveyard gains flashback
|
||||||
* Varolz, the Scar-Striped - Each creature card in your graveyard has scavenge. The scavenge cost is equal to its mana cost.
|
* until end of turn. The flashback cost is equal to its mana cost. Varolz,
|
||||||
|
* the Scar-Striped - Each creature card in your graveyard has scavenge. The
|
||||||
|
* scavenge cost is equal to its mana cost.
|
||||||
*
|
*
|
||||||
* @param objectId
|
* @param objectId
|
||||||
* @param zone
|
* @param zone
|
||||||
|
@ -826,6 +842,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the ability to continuous or triggered abilities
|
* Adds the ability to continuous or triggered abilities
|
||||||
|
*
|
||||||
* @param attachedTo
|
* @param attachedTo
|
||||||
* @param ability
|
* @param ability
|
||||||
*/
|
*/
|
||||||
|
@ -840,8 +857,8 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes Triggered abilities that belong to sourceId
|
* Removes Triggered abilities that belong to sourceId This is used if a
|
||||||
* This is used if a token leaves the battlefield
|
* token leaves the battlefield
|
||||||
*
|
*
|
||||||
* @param sourceId
|
* @param sourceId
|
||||||
*/
|
*/
|
||||||
|
@ -849,7 +866,6 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
triggers.removeAbilitiesOfSource(sourceId);
|
triggers.removeAbilitiesOfSource(sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before applyEffects
|
* Called before applyEffects
|
||||||
*/
|
*/
|
||||||
|
@ -858,7 +874,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
triggers.removeAllGainedAbilities();
|
triggers.removeAllGainedAbilities();
|
||||||
getContinuousEffects().removeAllTemporaryEffects();
|
getContinuousEffects().removeAllTemporaryEffects();
|
||||||
this.setLegendaryRuleActive(true);
|
this.setLegendaryRuleActive(true);
|
||||||
for (CardState state: cardState.values()) {
|
for (CardState state : cardState.values()) {
|
||||||
state.clearAbilities();
|
state.clearAbilities();
|
||||||
}
|
}
|
||||||
cardAttribute.clear();
|
cardAttribute.clear();
|
||||||
|
@ -914,6 +930,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only used for diagnostic purposes of tests
|
* Only used for diagnostic purposes of tests
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TriggeredAbilities getTriggers() {
|
public TriggeredAbilities getTriggers() {
|
||||||
|
@ -981,10 +998,10 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
copiedCards.put(copiedCard.getId(), copiedCard);
|
copiedCards.put(copiedCard.getId(), copiedCard);
|
||||||
addCard(copiedCard);
|
addCard(copiedCard);
|
||||||
if (copiedCard.isSplitCard()) {
|
if (copiedCard.isSplitCard()) {
|
||||||
Card leftCard = ((SplitCard)copiedCard).getLeftHalfCard();
|
Card leftCard = ((SplitCard) copiedCard).getLeftHalfCard();
|
||||||
copiedCards.put(leftCard.getId(), leftCard);
|
copiedCards.put(leftCard.getId(), leftCard);
|
||||||
addCard(leftCard);
|
addCard(leftCard);
|
||||||
Card rightCard = ((SplitCard)copiedCard).getRightHalfCard();
|
Card rightCard = ((SplitCard) copiedCard).getRightHalfCard();
|
||||||
copiedCards.put(rightCard.getId(), rightCard);
|
copiedCards.put(rightCard.getId(), rightCard);
|
||||||
addCard(rightCard);
|
addCard(rightCard);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue