Removed majority of memory leaks from game / editor / dialog handling.

This commit is contained in:
LevelX2 2014-02-02 21:57:02 +01:00
parent 11df1dc059
commit 0a18a7bea6
24 changed files with 215 additions and 138 deletions

View file

@ -661,7 +661,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void showGameEndDialog(GameEndView gameEndView) {
GameEndDialog gameEndDialog = new GameEndDialog(gameEndView);
desktopPane.add(gameEndDialog, JLayeredPane.POPUP_LAYER);
desktopPane.add(gameEndDialog, JLayeredPane.MODAL_LAYER);
gameEndDialog.showDialog();
}

View file

@ -83,6 +83,10 @@ public class BigCard extends JComponent {
this.getWidth()*1000/1142,this.getWidth()*1000/2539);
}
public void clearUp() {
}
public void setCard(UUID cardId, Image image, List<String> strings, boolean foil) {
if (this.cardId == null || !this.cardId.equals(cardId)) {
if (this.panel != null) {

View file

@ -28,6 +28,16 @@
package mage.client.cards;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.MouseListener;
import java.util.List;
import java.util.UUID;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import mage.cards.CardDimensions;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
@ -38,12 +48,6 @@ import mage.view.CardView;
import mage.view.CardsView;
import mage.view.SimpleCardsView;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
import java.util.*;
import java.util.List;
public class CardArea extends JPanel {
private boolean reloaded = false;
@ -71,10 +75,12 @@ public class CardArea extends JPanel {
public void loadCards(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
this.reloaded = true;
cardArea.removeAll();
if (showCards != null && showCards.size() < 10)
if (showCards != null && showCards.size() < 10) {
loadCardsFew(showCards, bigCard, gameId, listener);
else
}
else {
loadCardsMany(showCards, bigCard, gameId, listener, dimension);
}
cardArea.revalidate();
this.revalidate();
@ -113,8 +119,9 @@ public class CardArea extends JPanel {
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, gameId, true);
cardImg.setBounds(rectangle);
if (listener != null)
if (listener != null) {
cardImg.addMouseListener(listener);
}
cardArea.add(cardImg);
cardArea.moveToFront(cardImg);
cardImg.update(card);

View file

@ -44,6 +44,8 @@ import javax.swing.border.Border;
import java.awt.*;
import java.util.*;
import java.util.Map.Entry;
import mage.cards.action.ActionCallback;
import mage.client.plugins.adapters.MageActionCallback;
import org.apache.log4j.Logger;
/**
@ -86,6 +88,13 @@ public class Cards extends javax.swing.JPanel {
}
}
public void cleanUp() {
ActionCallback actionCallback = Plugins.getInstance().getActionCallback();
if (actionCallback instanceof MageActionCallback) {
((MageActionCallback) actionCallback).setCardPreviewComponent(null);
}
}
/**
* Sets components background color
* @param color

View file

@ -260,7 +260,7 @@ public class AddLandDialog extends MageDialog {
}// </editor-fold>//GEN-END:initComponents
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
this.hideDialog();
this.removeDialog();
}//GEN-LAST:event_btnCancelActionPerformed
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
@ -275,7 +275,7 @@ public class AddLandDialog extends MageDialog {
addLands("Mountain", nMountain);
addLands("Plains", nPlains);
addLands("Swamp", nSwamp);
this.hideDialog();
this.removeDialog();
}//GEN-LAST:event_btnAddActionPerformed
private void btnAutoAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAutoAddActionPerformed

View file

@ -38,6 +38,7 @@ import java.beans.PropertyVetoException;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
import mage.client.cards.BigCard;
import mage.client.util.Config;
import mage.view.ExileView;
@ -50,10 +51,15 @@ public class ExileZoneDialog extends MageDialog {
/** Creates new form ExileZoneDialog */
public ExileZoneDialog() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
this.setModal(false);
}
public void cleanUp() {
cards.cleanUp();
}
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
this.title = exile.getName();
this.setTitelBarToolTip(exile.getName());

View file

@ -45,6 +45,7 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.ImageIcon;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import mage.client.MageFrame;
import mage.client.game.GamePanel;
@ -120,8 +121,6 @@ public class GameEndDialog extends MageDialog {
int winsNeeded = gameEndView.getWinsNeeded() - gameEndView.getWins();
lblMatchInfo.setText(new StringBuilder("You need ").append(winsNeeded == 1 ? "one win ":winsNeeded + " wins ").append("to win the match.").toString());
}
}
private void saveGameLog(GameEndView gameEndView) {

View file

@ -33,15 +33,21 @@
*/
package mage.client.dialog;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.awt.AWTEvent;
import java.awt.ActiveEvent;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.KeyboardFocusManager;
import java.awt.MenuComponent;
import java.awt.TrayIcon;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import mage.client.MageFrame;
import org.apache.log4j.Logger;
/**
*
@ -174,11 +180,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
java.util.logging.Logger.getLogger(MageDialog.class.getName()).log(Level.SEVERE, "setClosed(false) failed", ex);
}
MageFrame.getDesktop().remove(this);
// this.ui.uninstallUI(this);
logger.warn("Remove Dialog " + this.getClass().getName() + " Components left: " + this.getComponentCount());
for (Component comp : this.getComponents()) {
logger.warn("Existing Component: " + comp.getClass().getName());
}
}
/**

View file

@ -34,6 +34,14 @@
package mage.client.dialog;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.Serializable;
import java.util.Map;
import java.util.UUID;
import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
import mage.cards.CardDimensions;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
@ -43,14 +51,7 @@ import mage.client.util.SettingsManager;
import mage.client.util.gui.GuiDisplayUtil;
import mage.view.CardsView;
import mage.view.SimpleCardsView;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.Serializable;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
/**
* @author BetaSteward_at_googlemail.com
@ -63,10 +64,15 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
* Creates new form ShowCardsDialog
*/
public ShowCardsDialog() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
this.setModal(false);
}
public void cleanUp() {
}
public void loadCards(String name, SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
loadCards(name, CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId, modal);
}

View file

@ -40,7 +40,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jSplitPane1" pref="279" max="32767" attributes="0"/>
<Component id="jSplitPane1" pref="283" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnMoveDown" alignment="3" min="-2" max="-2" attributes="0"/>

View file

@ -34,22 +34,21 @@
package mage.client.dialog;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import mage.client.components.MageComponents;
import mage.client.components.tray.MageTray;
import mage.remote.Session;
import mage.view.SeatView;
import mage.view.TableView;
import org.apache.log4j.Logger;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import mage.client.components.MageComponents;
import mage.client.components.tray.MageTray;
import mage.client.util.AudioManager;
import mage.remote.Session;
import mage.view.SeatView;
import mage.view.TableView;
import org.apache.log4j.Logger;
/**
*
@ -343,8 +342,9 @@ class TableWaitModel extends AbstractTableModel {
public String getColumnName(int columnIndex) {
String colName = "";
if (columnIndex <= getColumnCount())
if (columnIndex <= getColumnCount()) {
colName = columnNames[columnIndex];
}
return colName;
}
@ -411,15 +411,15 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
}
private int getPlayersCount(TableView tableView) {
int count = 0;
int playerCount = 0;
if (tableView != null) {
for (SeatView seatView: tableView.getSeats()) {
if (seatView.getPlayerId() != null && seatView.getPlayerType().equals("Human")) {
count++;
playerCount++;
}
}
}
return count;
return playerCount;
}

View file

@ -35,13 +35,10 @@
package mage.client.draft;
import java.awt.Component;
import java.awt.KeyboardFocusManager;
import java.beans.PropertyVetoException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import mage.client.MageFrame;
import mage.client.MagePane;
import mage.client.plugins.impl.Plugins;
@ -77,7 +74,8 @@ public class DraftPane extends MagePane {
}
public void hideDraft() {
this.hideFrame();
draftPanel1.cleanUp();
this.removeFrame();
}
/** This method is called from within the constructor to

View file

@ -90,9 +90,16 @@ public class DraftPanel extends javax.swing.JPanel {
);
}
public void clear() {
public void cleanUp() {
draftPicks.clear();
draftBooster.clear();
if (countdown != null) {
countdown.stop();
for (ActionListener al : countdown.getActionListeners()) {
countdown.removeActionListener(al);
}
}
}
public synchronized void showDraft(UUID draftId) {
@ -162,7 +169,6 @@ public class DraftPanel extends javax.swing.JPanel {
}
public void hideDraft() {
this.clear();
Component c = this.getParent();
while (c != null && !(c instanceof DraftPane)) {
c = c.getParent();

View file

@ -102,6 +102,11 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
this.bigCard = bigCard;
}
public void cleanUp() {
permanents.clear();
Plugins.getInstance().sortPermanents(ui, permanents.values());
}
public void update(Map<UUID, PermanentView> battlefield) {
boolean changed = false;
@ -281,28 +286,28 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
}
}
private Rectangle findEmptySpace(Dimension size) {
int battlefieldWidth = this.getWidth();
Rectangle r = new Rectangle(size);
boolean intersects;
while (true) {
intersects = false;
for (MagePermanent perm: permanents.values()) {
Rectangle pr = perm.getBounds();
if (r.intersects(pr)) {
intersects = true;
if (pr.x + pr.width + r.width > battlefieldWidth)
r.setLocation(0, pr.y + pr.height + 1);
else
r.translate(pr.x + pr.width - r.x, 0);
break;
}
}
if (!intersects)
break;
}
return r;
}
// private Rectangle findEmptySpace(Dimension size) {
// int battlefieldWidth = this.getWidth();
// Rectangle r = new Rectangle(size);
// boolean intersects;
// while (true) {
// intersects = false;
// for (MagePermanent perm: permanents.values()) {
// Rectangle pr = perm.getBounds();
// if (r.intersects(pr)) {
// intersects = true;
// if (pr.x + pr.width + r.width > battlefieldWidth)
// r.setLocation(0, pr.y + pr.height + 1);
// else
// r.translate(pr.x + pr.width - r.x, 0);
// break;
// }
// }
// if (!intersects)
// break;
// }
// return r;
// }
@Override
public boolean isOptimizedDrawingEnabled () {

View file

@ -277,7 +277,8 @@ public class FeedbackPanel extends javax.swing.JPanel {
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
this.selected = true;
if (connectedDialog != null) {
connectedDialog.hideDialog();
connectedDialog.removeDialog();
connectedDialog = null;
}
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
session.sendPlayerInteger(gameId, 0);

View file

@ -38,8 +38,6 @@ import java.awt.KeyboardFocusManager;
import java.util.UUID;
import javax.swing.SwingUtilities;
import mage.client.MagePane;
import mage.client.dialog.MageDialog;
import org.apache.log4j.Logger;
/**
*
@ -47,8 +45,6 @@ import org.apache.log4j.Logger;
*/
public class GamePane extends MagePane {
private static final Logger logger = Logger.getLogger(MageDialog.class);
/** Creates new form GamePane */
public GamePane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
@ -71,8 +67,6 @@ public class GamePane extends MagePane {
public void cleanUp() {
gamePanel.cleanUp();
this.getInputMap().clear();
this.getActionMap().clear();
}
public void hideGame() {

View file

@ -46,9 +46,11 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@ -127,6 +129,7 @@ public final class GamePanel extends javax.swing.JPanel {
private String chosenHandKey = "You";
private boolean smallMode = false;
private boolean initialized = false;
private int lastUpdatedTurn;
private Map<String, Card> loadedCards = new HashMap<String, Card>();
@ -204,6 +207,8 @@ public final class GamePanel extends javax.swing.JPanel {
this.removeListener();
this.handContainer.cleanUp();
this.stack.cleanUp();
for(Map.Entry<UUID, PlayAreaPanel> playAreaPanelEntry: players.entrySet()) {
playAreaPanelEntry.getValue().CleanUp();
}
@ -215,20 +220,20 @@ public final class GamePanel extends javax.swing.JPanel {
jLayeredPane.remove(DialogManager.getManager(gameId));
DialogManager.removeGame(gameId);
this.getInputMap().clear();
this.getActionMap().clear();
// this.pnlBattlefield.removeAll();
// this.getUI().uninstallUI(this);
if (pickNumber != null) {
pickNumber.removeDialog();
}
for (ExileZoneDialog exile: exiles.values()) {
exile.hideDialog();
for (ExileZoneDialog exileDialog: exiles.values()) {
exileDialog.cleanUp();
exileDialog.removeDialog();
}
for (ShowCardsDialog reveal: revealed.values()) {
reveal.hideDialog();
for (ShowCardsDialog revealDialog: revealed.values()) {
revealDialog.cleanUp();
revealDialog.removeDialog();
}
for (ShowCardsDialog lookedAtDialog: lookedAt.values()) {
lookedAtDialog.cleanUp();
lookedAtDialog.removeDialog();
}
try {
@ -393,6 +398,7 @@ public final class GamePanel extends javax.swing.JPanel {
public synchronized void init(GameView game) {
addPlayers(game);
updateGame(game);
lastUpdatedTurn = game.getTurn();
}
private void addPlayers(GameView game) {
@ -598,16 +604,27 @@ public final class GamePanel extends javax.swing.JPanel {
}
private void showRevealed(GameView game) {
for (ShowCardsDialog reveal: revealed.values()) {
reveal.clearReloaded();
}
// List<String> toRemove = new ArrayList<String>();
// toRemove.addAll(revealed.keySet());
// for (ShowCardsDialog reveal: revealed.values()) {
// reveal.clearReloaded(); // seems not to be used
// }
for (RevealedView reveal: game.getRevealed()) {
if (!revealed.containsKey(reveal.getName())) {
ShowCardsDialog newReveal = new ShowCardsDialog();
revealed.put(reveal.getName(), newReveal);
}
revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), CardsViewUtil.convertSimple(reveal.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false);
// toRemove.add(reveal.getName());
}
// for (String revealName: toRemove) {
// ShowCardsDialog revealDialog = revealed.get(revealName);
// if (revealDialog != null) {
// revealed.remove(revealName);
// revealDialog.cleanUp();
// revealDialog.removeDialog();
// }
// }
}
private void showLookedAt(GameView game) {
@ -616,8 +633,8 @@ public final class GamePanel extends javax.swing.JPanel {
}
for (LookedAtView looked: game.getLookedAt()) {
if (!lookedAt.containsKey(looked.getName())) {
ShowCardsDialog newReveal = new ShowCardsDialog();
lookedAt.put(looked.getName(), newReveal);
ShowCardsDialog newLookedAt = new ShowCardsDialog();
lookedAt.put(looked.getName(), newLookedAt);
}
lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), CardsViewUtil.convertSimple(looked.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false);
}
@ -675,7 +692,11 @@ public final class GamePanel extends javax.swing.JPanel {
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), options, messageId);
if (PhaseManager.getInstance().isSkip(gameView, message)) {
this.feedbackPanel.doClick();
logger.debug(new StringBuilder("Phase skipped: ").append(message).append(" id: ").append(messageId));
} else {
logger.debug(new StringBuilder("Phase not skipped: ").append(message).append(" id: ").append(messageId));
}
}
public void playMana(String message, GameView gameView, int messageId) {

View file

@ -58,6 +58,10 @@ public class HandPanel extends JPanel {
hand.setZone(Zone.HAND.toString());
}
public void cleanUp() {
hand.cleanUp();
}
public void loadCards(CardsView cards, BigCard bigCard, UUID gameId) {
hand.loadCards(cards, bigCard, gameId, null);
hand.sizeCards(getHandCardDimension());

View file

@ -27,25 +27,29 @@
*/
package mage.client.game;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.lang.reflect.Field;
import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.MenuSelectionManager;
import javax.swing.event.ChangeListener;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.view.PlayerView;
import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.UUID;
import javax.swing.event.MenuKeyListener;
import javax.swing.plaf.basic.BasicPopupMenuUI;
/**
*
* @author BetaSteward_at_googlemail.com
@ -67,12 +71,14 @@ public class PlayAreaPanel extends javax.swing.JPanel {
initComponents();
setOpaque(false);
battlefieldPanel.setOpaque(false);
popupMenu = new JPopupMenu();
if (isPlayer) {
addPopupMenuPlayer();
} else {
addPopupMenuWatcher();
}
this.add(popupMenu);
}
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me, int priorityTime, boolean isPlayer, GamePanel gamePanel) {
@ -83,28 +89,33 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
public void CleanUp() {
for (MouseListener ml :battlefieldPanel.getMainPanel().getMouseListeners()) {
battlefieldPanel.getMainPanel().removeMouseListener(ml);
}
battlefieldPanel.cleanUp();
playerPanel.cleanUp();
for (KeyListener kl: popupMenu.getKeyListeners()) {
popupMenu.removeKeyListener(kl);
}
for (MenuKeyListener mkl: popupMenu.getMenuKeyListeners()) {
popupMenu.removeMenuKeyListener(mkl);
for (ActionListener al : btnCheat.getActionListeners() ) {
btnCheat.removeActionListener(al);
}
for (Component child : popupMenu.getComponents()) {
if (child instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) child;
for (ActionListener al: menuItem.getActionListeners()) {
menuItem.removeActionListener(al);
}
// Taken form : https://community.oracle.com/thread/2183145
// removed the internal focus of a popupMenu data to allow GC before another popup menu is selected
for(ChangeListener listener : MenuSelectionManager.defaultManager().getChangeListeners()) {
if (listener.getClass().getName().contains("MenuKeyboardHelper")) {
try {
Field field = listener.getClass().getDeclaredField("menuInputMap");
field.setAccessible(true);
field.set(listener, null);
} catch (Exception e) {
// ignored
}
break;
}
}
for (MouseListener ml :battlefieldPanel.getMainPanel().getMouseListeners()) {
battlefieldPanel.getMainPanel().removeMouseListener(ml);
}
popupMenu.getUI().uninstallUI(this);
}
@ -199,6 +210,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
}
});
}
private void addPopupMenuWatcher() {
@ -217,7 +229,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
}
});
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent Me) {
@ -226,6 +237,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
}
}
});
}
public final void init(PlayerView player, BigCard bigCard, UUID gameId, int priorityTime) {

View file

@ -153,8 +153,11 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
public void cleanUp() {
if (timer != null) {
this.timer.cancel();
}
topCardPanel.updateCallback(null, gameId);
}
public void update(PlayerView player) {
this.player = player;

View file

@ -104,8 +104,6 @@ public class PhaseManager {
if (prefKey != null) {
String prop = prefs.get(prefKey, PHASE_ON);
return !prop.equals(PHASE_ON);
} else {
logger.warn(new StringBuilder("Message not found: ").append(message));
}
return false;
}

View file

@ -1,10 +1,9 @@
package mage.client.util;
import java.awt.Point;
import java.awt.Rectangle;
import org.mage.card.arcane.CardPanel;
import java.awt.*;
/**
* Contains dynamic settings for client.
*

View file

@ -88,6 +88,7 @@ public class GameState implements Serializable, Copyable<GameState> {
private final Players players;
private final PlayerList playerList;
private final Turn turn;
// revealed cards <Name, <Cards>>, will be reset if all players pass priority
private final Revealed revealed;
private final Map<UUID, LookedAt> lookedAt = new HashMap<UUID, LookedAt>();
private final DelayedTriggeredAbilities delayed;

View file

@ -56,8 +56,9 @@ public class Revealed extends HashMap<String, Cards> implements Serializable, Co
}
public void add(String name, Cards cards) {
if (!this.containsKey(name))
if (!this.containsKey(name)) {
createRevealed(name);
}
this.put(name, cards.copy());
}
@ -78,9 +79,10 @@ public class Revealed extends HashMap<String, Cards> implements Serializable, Co
public Card getCard(UUID cardId, Game game) {
for (Cards cards: this.values()) {
if (cards.contains(cardId))
if (cards.contains(cardId)) {
return game.getCard(cardId);
}
}
return null;
}