diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index e8a1de52a1..82b962eb7d 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -61,6 +61,8 @@ import java.io.Serializable; import java.util.*; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; +import mage.cards.Card; +import mage.client.util.CardsViewUtil; /** @@ -86,6 +88,9 @@ public final class GamePanel extends javax.swing.JPanel { private String chosenHandKey = "You"; private boolean smallMode = false; private boolean initialized = false; + + + private Map loadedCards = new HashMap(); private int storedHeight; @@ -412,12 +417,12 @@ public final class GamePanel extends javax.swing.JPanel { this.handContainer.setVisible(false); } else { handCards.clear(); - handCards.put(YOUR_HAND, game.getHand()); + handCards.put(YOUR_HAND, CardsViewUtil.convertSimple(game.getHand(), loadedCards)); // Get opponents hand cards if available if (game.getOpponentHands() != null) { for (Map.Entry hand: game.getOpponentHands().entrySet()) { - handCards.put(hand.getKey(), hand.getValue()); + handCards.put(hand.getKey(), CardsViewUtil.convertSimple(game.getHand(), loadedCards)); } } @@ -544,7 +549,7 @@ public final class GamePanel extends javax.swing.JPanel { ShowCardsDialog newReveal = new ShowCardsDialog(); revealed.put(reveal.getName(), newReveal); } - revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), reveal.getCards(), bigCard, Config.dimensions, gameId, false); + revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), CardsViewUtil.convertSimple(reveal.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false); } } @@ -557,7 +562,7 @@ public final class GamePanel extends javax.swing.JPanel { ShowCardsDialog newReveal = new ShowCardsDialog(); lookedAt.put(looked.getName(), newReveal); } - lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), looked.getCards(), bigCard, Config.dimensions, gameId, false); + lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), CardsViewUtil.convertSimple(looked.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false); } } @@ -723,7 +728,7 @@ public final class GamePanel extends javax.swing.JPanel { jSplitPane2 = new javax.swing.JSplitPane(); handContainer = new HandPanel(); - handCards = new HashMap(); + handCards = new HashMap(); jSplitPane1.setBorder(null); jSplitPane1.setDividerSize(7); @@ -1184,7 +1189,7 @@ public final class GamePanel extends javax.swing.JPanel { if (newChosenHandKey != null && newChosenHandKey.length() > 0) { this.chosenHandKey = newChosenHandKey; - SimpleCardsView cards = handCards.get(chosenHandKey); + CardsView cards = handCards.get(chosenHandKey); handContainer.loadCards(cards, bigCard, gameId); } } @@ -1290,7 +1295,7 @@ public final class GamePanel extends javax.swing.JPanel { private javax.swing.JLabel txtStep; private javax.swing.JLabel txtTurn; - private Map handCards; + private Map handCards; private mage.client.cards.Cards stack; private HandPanel handContainer; diff --git a/Mage.Client/src/main/java/mage/client/game/HandPanel.java b/Mage.Client/src/main/java/mage/client/game/HandPanel.java index f1c520113d..4f077bcfa2 100644 --- a/Mage.Client/src/main/java/mage/client/game/HandPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/HandPanel.java @@ -5,13 +5,13 @@ import mage.client.cards.BigCard; import mage.client.dialog.PreferencesDialog; import mage.client.util.Config; import mage.constants.Zone; -import mage.view.SimpleCardsView; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import java.awt.*; import java.util.UUID; +import mage.view.CardsView; public class HandPanel extends JPanel { @@ -58,8 +58,8 @@ public class HandPanel extends JPanel { hand.setZone(Zone.HAND.toString()); } - public void loadCards(SimpleCardsView cards, BigCard bigCard, UUID gameId) { - hand.loadCards(cards, bigCard, gameId); + public void loadCards(CardsView cards, BigCard bigCard, UUID gameId) { + hand.loadCards(cards, bigCard, gameId, null); hand.sizeCards(getHandCardDimension()); } diff --git a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java index a3c28e8a1f..ed5dd61d12 100644 --- a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java @@ -29,6 +29,7 @@ package mage.client.util; import java.util.List; +import java.util.Map; import mage.cards.Card; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; @@ -53,6 +54,26 @@ public class CardsViewUtil { return cards; } + + public static CardsView convertSimple(SimpleCardsView view, Map loadedCards) { + CardsView cards = new CardsView(); + + for (SimpleCardView simple: view.values()) { + String key = simple.getExpansionSetCode() + "_" + simple.getCardNumber(); + Card card = loadedCards.get(key); + if(card == null) + { + CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber()); + card = cardInfo != null ? cardInfo.getMockCard() : null; + loadedCards.put(key, card); + } + if (card != null) { + cards.put(simple.getId(), new CardView(card, simple.getId())); + } + } + + return cards; + } public static CardsView convertCommandObject(List view) { CardsView cards = new CardsView();