From bafd27f5b3b6a232cf226347a41d0534967e8b89 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 3 Jun 2015 17:05:59 +0200 Subject: [PATCH] Identifier are shown for Looked at and revealed cards view --- .../main/java/mage/client/game/GamePanel.java | 4 +-- .../mage/client/util/gui/GuiDisplayUtil.java | 1 - Mage.Common/src/mage/view/CardView.java | 35 ++++++------------- Mage.Common/src/mage/view/CardsView.java | 2 +- Mage.Common/src/mage/view/CommanderView.java | 2 +- Mage.Common/src/mage/view/DeckView.java | 4 +-- Mage.Common/src/mage/view/DraftPickView.java | 4 +-- Mage.Common/src/mage/view/ExileView.java | 2 +- Mage.Common/src/mage/view/GameView.java | 2 +- Mage.Common/src/mage/view/LookedAtView.java | 2 +- Mage.Common/src/mage/view/PermanentView.java | 2 +- Mage.Common/src/mage/view/PlayerView.java | 4 +-- Mage.Common/src/mage/view/RevealedView.java | 6 ++-- Mage.Common/src/mage/view/SimpleCardView.java | 10 +++++- .../src/mage/view/SimpleCardsView.java | 4 +-- .../mage/server/game/GameSessionPlayer.java | 2 +- .../mage/server/game/GameSessionWatcher.java | 2 +- .../src/mage/sets/tenthedition/Peek.java | 10 +++--- .../keyword/AffinityForLandTypeAbility.java | 8 ++--- Mage/src/mage/game/stack/Spell.java | 8 ++++- 20 files changed, 58 insertions(+), 56 deletions(-) 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 6021b18fbe..2e7483b9c1 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -801,7 +801,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(), CardsViewUtil.convertSimple(reveal.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false); + revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), reveal.getCards(), bigCard, Config.dimensions, gameId, false); } } @@ -814,7 +814,7 @@ public final class GamePanel extends javax.swing.JPanel { 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); + lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), looked.getCards(), bigCard, Config.dimensions, gameId, false); } } diff --git a/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java b/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java index 0c17837273..8252189c8c 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/GuiDisplayUtil.java @@ -13,7 +13,6 @@ import org.mage.card.arcane.UI; import javax.swing.*; import java.awt.*; import java.util.ArrayList; -import mage.client.dialog.MageDialog; import mage.constants.Rarity; public class GuiDisplayUtil { diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index 85b6b1df8c..5829fa3a3b 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -114,20 +114,19 @@ public class CardView extends SimpleCardView { protected boolean isPlayable; protected boolean isChoosable; protected boolean selected; - protected boolean canAttack; - protected boolean gameObject; + protected boolean canAttack; public CardView(Card card) { - this(card, null, null, false); + this(card, null, false); } public CardView(Card card, UUID cardId) { - this(card, null, null, false); + this(card, null, false); this.id = cardId; } public CardView(Card card, Game game, UUID cardId) { - this(card, game, null, false); + this(card, game, false); this.id = cardId; } @@ -135,15 +134,12 @@ public class CardView extends SimpleCardView { * * @param card * @param game - * @param cardId not used? * @param controlled is the card view created for the card controller - used for morph / face down cards to know which player may see information for the card */ - public CardView(Card card, Game game, UUID cardId, boolean controlled) { - super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode()); + public CardView(Card card, Game game, boolean controlled) { + super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), game != null); // no information available for face down cards as long it's not a controlled face down morph card - // TODO: Better handle this in Framework (but currently I'm not sure how to do it there) LevelX2 - this.gameObject = game != null; - + // TODO: Better handle this in Framework (but currently I'm not sure how to do it there) LevelX2 if (game != null && card.isFaceDown(game)) { this.fillEmpty(card, controlled); if (card instanceof Spell) { @@ -301,7 +297,7 @@ public class CardView extends SimpleCardView { } public CardView(MageObject object) { - super(object.getId(), "", 0, false, ""); + super(object.getId(), "", 0, false, "", true); this.name = object.getName(); this.displayName = object.getName(); if (object instanceof Permanent) { @@ -345,11 +341,12 @@ public class CardView extends SimpleCardView { } protected CardView() { - super(null, "", 0, false, ""); + super(null, "", 0, false, "", true); } public CardView(EmblemView emblem) { this(true); + this.gameObject = true; this.id = emblem.getId(); this.mageObjectType = MageObjectType.EMBLEM; this.name = emblem.getName(); @@ -368,13 +365,6 @@ public class CardView extends SimpleCardView { fillEmpty(null, false); } - - public CardView(String name) { - this(true); - this.name = name; - this.displayName = name; - } - private void fillEmpty(Card card, boolean controlled) { this.name = "Face Down"; this.displayName = name; @@ -736,8 +726,5 @@ public class CardView extends SimpleCardView { public void setCanAttack(boolean canAttack) { this.canAttack = canAttack; } - - public boolean isGameObject() { - return gameObject; - } + } diff --git a/Mage.Common/src/mage/view/CardsView.java b/Mage.Common/src/mage/view/CardsView.java index 5728401335..a39a9d6e00 100644 --- a/Mage.Common/src/mage/view/CardsView.java +++ b/Mage.Common/src/mage/view/CardsView.java @@ -66,7 +66,7 @@ public class CardsView extends LinkedHashMap { public CardsView(Game game, Collection cards) { for (Card card: cards) { - this.put(card.getId(), new CardView(card, game, null, false)); + this.put(card.getId(), new CardView(card, game, false)); } } diff --git a/Mage.Common/src/mage/view/CommanderView.java b/Mage.Common/src/mage/view/CommanderView.java index 46e012b374..843a38ae2c 100644 --- a/Mage.Common/src/mage/view/CommanderView.java +++ b/Mage.Common/src/mage/view/CommanderView.java @@ -40,7 +40,7 @@ import mage.game.command.Commander; public class CommanderView extends CardView implements CommandObjectView, Serializable{ public CommanderView(Commander commander, Card sourceCard, Game game) { - super(sourceCard, game, null, false); + super(sourceCard, game, false); this.mageObjectType = MageObjectType.COMMANDER; } } diff --git a/Mage.Common/src/mage/view/DeckView.java b/Mage.Common/src/mage/view/DeckView.java index dccd0f46b0..1542ac4a80 100644 --- a/Mage.Common/src/mage/view/DeckView.java +++ b/Mage.Common/src/mage/view/DeckView.java @@ -41,8 +41,8 @@ public class DeckView implements Serializable { public DeckView(Deck deck) { name = deck.getName(); - cards = new SimpleCardsView(deck.getCards()); - sideboard = new SimpleCardsView(deck.getSideboard()); + cards = new SimpleCardsView(deck.getCards(), false); + sideboard = new SimpleCardsView(deck.getSideboard(), false); } public String getName() { diff --git a/Mage.Common/src/mage/view/DraftPickView.java b/Mage.Common/src/mage/view/DraftPickView.java index 82ee5cc099..b1bf2c22b5 100644 --- a/Mage.Common/src/mage/view/DraftPickView.java +++ b/Mage.Common/src/mage/view/DraftPickView.java @@ -44,8 +44,8 @@ public class DraftPickView implements Serializable { protected int timeout; public DraftPickView(DraftPlayer player, int timeout) { - this.booster = new SimpleCardsView(player.getBooster()); - this.picks = new SimpleCardsView(player.getDeck().getSideboard()); + this.booster = new SimpleCardsView(player.getBooster(), false); + this.picks = new SimpleCardsView(player.getDeck().getSideboard(), false); this.picking = player.isPicking(); this.timeout = timeout; } diff --git a/Mage.Common/src/mage/view/ExileView.java b/Mage.Common/src/mage/view/ExileView.java index b6c3ecc87b..bd0c03752a 100644 --- a/Mage.Common/src/mage/view/ExileView.java +++ b/Mage.Common/src/mage/view/ExileView.java @@ -47,7 +47,7 @@ public class ExileView extends CardsView { this.name = exileZone.getName(); this.id = exileZone.getId(); for (Card card: exileZone.getCards(game)) { - this.put(card.getId(), new CardView(card, game, card.getId(), false)); + this.put(card.getId(), new CardView(card, game, false)); } } diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java index 467780abf1..32b8be1bcd 100644 --- a/Mage.Common/src/mage/view/GameView.java +++ b/Mage.Common/src/mage/view/GameView.java @@ -136,7 +136,7 @@ public class GameView implements Serializable { } else { // Spell - stack.put(stackObject.getId(), new CardView((Spell)stackObject, game, null, stackObject.getControllerId().equals(createdForPlayerId))); + stack.put(stackObject.getId(), new CardView((Spell)stackObject, game, stackObject.getControllerId().equals(createdForPlayerId))); checkPaid(stackObject.getId(), (Spell)stackObject); } //stackOrder.add(stackObject.getId()); diff --git a/Mage.Common/src/mage/view/LookedAtView.java b/Mage.Common/src/mage/view/LookedAtView.java index a7485e7120..db1759c0c0 100644 --- a/Mage.Common/src/mage/view/LookedAtView.java +++ b/Mage.Common/src/mage/view/LookedAtView.java @@ -46,7 +46,7 @@ public class LookedAtView implements Serializable { public LookedAtView(String name, Cards cards, Game game) { this.name = name; for (Card card: cards.getCards(game)) { - this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode())); + this.cards.put(card.getId(), new CardView(card, game, card.getId())); } } diff --git a/Mage.Common/src/mage/view/PermanentView.java b/Mage.Common/src/mage/view/PermanentView.java index 4ce0246ea0..2b7fe476f0 100644 --- a/Mage.Common/src/mage/view/PermanentView.java +++ b/Mage.Common/src/mage/view/PermanentView.java @@ -62,7 +62,7 @@ public class PermanentView extends CardView { private final boolean attachedToPermanent; public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) { - super(permanent, game, null, permanent.getControllerId().equals(createdForPlayerId)); + super(permanent, game, permanent.getControllerId().equals(createdForPlayerId)); this.controlled = permanent.getControllerId().equals(createdForPlayerId); this.rules = permanent.getRules(game); this.tapped = permanent.isTapped(); diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index 343e30332c..fb9e36ad62 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -95,12 +95,12 @@ public class PlayerView implements Serializable { this.hasLeft = player.hasLeft(); for (Card card: player.getGraveyard().getCards(game)) { - graveyard.put(card.getId(), new CardView(card, game, card.getId(), false)); + graveyard.put(card.getId(), new CardView(card, game, false)); } for (ExileZone exileZone : game.getExile().getExileZones()) { for (Card card : exileZone.getCards(game)) { if (player.getId().equals(card.getOwnerId())) { - exile.put(card.getId(), new CardView(card, game, card.getId(), false)); // unnown if it's allowed to look under a face down card + exile.put(card.getId(), new CardView(card, game, false)); // unnown if it's allowed to look under a face down card } } } diff --git a/Mage.Common/src/mage/view/RevealedView.java b/Mage.Common/src/mage/view/RevealedView.java index 3f067267cd..d5f086e410 100644 --- a/Mage.Common/src/mage/view/RevealedView.java +++ b/Mage.Common/src/mage/view/RevealedView.java @@ -40,12 +40,12 @@ import mage.game.Game; public class RevealedView implements Serializable { private final String name; - private final SimpleCardsView cards = new SimpleCardsView(); + private final CardsView cards = new CardsView(); public RevealedView(String name, Cards cards, Game game) { this.name = name; for (Card card: cards.getCards(game)) { - this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode())); + this.cards.put(card.getId(), new CardView(card, game, card.getId())); } } @@ -53,7 +53,7 @@ public class RevealedView implements Serializable { return name; } - public SimpleCardsView getCards() { + public CardsView getCards() { return cards; } } diff --git a/Mage.Common/src/mage/view/SimpleCardView.java b/Mage.Common/src/mage/view/SimpleCardView.java index daf216d72c..fd8abe538c 100644 --- a/Mage.Common/src/mage/view/SimpleCardView.java +++ b/Mage.Common/src/mage/view/SimpleCardView.java @@ -41,13 +41,18 @@ public class SimpleCardView implements Serializable { protected String tokenSetCode; protected int cardNumber; protected boolean usesVariousArt; + protected boolean gameObject; public SimpleCardView(UUID id, String expansionSetCode, int cardNumber, boolean usesVariousArt, String tokenSetCode) { + this(id, expansionSetCode, cardNumber, usesVariousArt, tokenSetCode, false); + } + public SimpleCardView(UUID id, String expansionSetCode, int cardNumber, boolean usesVariousArt, String tokenSetCode, boolean isGameObject) { this.id = id; this.expansionSetCode = expansionSetCode; this.cardNumber = cardNumber; this.usesVariousArt = usesVariousArt; this.tokenSetCode = tokenSetCode; + this.gameObject = isGameObject; } public UUID getId() { @@ -69,5 +74,8 @@ public class SimpleCardView implements Serializable { public String getTokenSetCode() { return tokenSetCode; } - + + public boolean isGameObject() { + return gameObject; + } } diff --git a/Mage.Common/src/mage/view/SimpleCardsView.java b/Mage.Common/src/mage/view/SimpleCardsView.java index d3763e4eed..909d0ee286 100644 --- a/Mage.Common/src/mage/view/SimpleCardsView.java +++ b/Mage.Common/src/mage/view/SimpleCardsView.java @@ -42,9 +42,9 @@ public class SimpleCardsView extends LinkedHashMap { public SimpleCardsView() {} - public SimpleCardsView(Collection cards) { + public SimpleCardsView(Collection cards, boolean isGameObject) { for (Card card: cards) { - this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode())); + this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), isGameObject)); } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java b/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java index e2cd374f6f..2cfff99a56 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java +++ b/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java @@ -237,7 +237,7 @@ public class GameSessionPlayer extends GameSessionWatcher { Map handCards = new HashMap<>(); for (UUID controlledPlayerId : player.getPlayersUnderYourControl()) { Player opponent = game.getPlayer(controlledPlayerId); - handCards.put(opponent.getName(), new SimpleCardsView(opponent.getHand().getCards(game))); + handCards.put(opponent.getName(), new SimpleCardsView(opponent.getHand().getCards(game), true)); } gameView.setOpponentHands(handCards); } diff --git a/Mage.Server/src/main/java/mage/server/game/GameSessionWatcher.java b/Mage.Server/src/main/java/mage/server/game/GameSessionWatcher.java index f269b87f0e..e1db1e08d2 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameSessionWatcher.java +++ b/Mage.Server/src/main/java/mage/server/game/GameSessionWatcher.java @@ -142,7 +142,7 @@ public class GameSessionWatcher { Map handCards = new HashMap<>(); for (Player player: game.getPlayers().values()) { if (player.hasUserPermissionToSeeHand(userId)) { - handCards.put(player.getName(), new SimpleCardsView(player.getHand().getCards(game))); + handCards.put(player.getName(), new SimpleCardsView(player.getHand().getCards(game), true)); gameView.setWatchedHands(handCards); } } diff --git a/Mage.Sets/src/mage/sets/tenthedition/Peek.java b/Mage.Sets/src/mage/sets/tenthedition/Peek.java index 1ef7f16dbe..7f60d71d82 100644 --- a/Mage.Sets/src/mage/sets/tenthedition/Peek.java +++ b/Mage.Sets/src/mage/sets/tenthedition/Peek.java @@ -28,6 +28,7 @@ package mage.sets.tenthedition; import java.util.UUID; +import mage.MageObject; import mage.constants.CardType; import mage.constants.Rarity; @@ -50,10 +51,10 @@ public class Peek extends CardImpl { super(ownerId, 94, "Peek", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{U}"); this.expansionSetCode = "10E"; - // Look at target player's hand. this.getSpellAbility().addEffect(new PeekEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); + // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); } @@ -71,7 +72,7 @@ public class Peek extends CardImpl { class PeekEffect extends OneShotEffect { PeekEffect() { super(Outcome.Detriment); - staticText = "Look at target player's hand"; + staticText = "look at target player's hand"; } PeekEffect(final PeekEffect effect) { @@ -82,8 +83,9 @@ class PeekEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(targetPointer.getFirst(game, source)); - if (player != null && controller != null) { - controller.lookAtCards("Peek", player.getHand(), game); + MageObject sourceObject = source.getSourceObject(game); + if (player != null && controller != null && sourceObject != null) { + controller.lookAtCards(sourceObject.getIdName(), player.getHand(), game); } return true; } diff --git a/Mage/src/mage/abilities/keyword/AffinityForLandTypeAbility.java b/Mage/src/mage/abilities/keyword/AffinityForLandTypeAbility.java index 451aac0c7d..a0fadfd378 100644 --- a/Mage/src/mage/abilities/keyword/AffinityForLandTypeAbility.java +++ b/Mage/src/mage/abilities/keyword/AffinityForLandTypeAbility.java @@ -32,10 +32,8 @@ import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.AdjustingSourceCosts; import mage.abilities.effects.common.AffinityEffect; -import mage.constants.CardType; import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; -import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.util.CardUtil; @@ -50,12 +48,14 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A private final FilterControlledPermanent filter; String text; + String landType; public AffinityForLandTypeAbility(String landType, String text) { super(Zone.OUTSIDE, new AffinityEffect(getFilter(landType))); this.filter = getFilter(landType); setRuleAtTheTop(true); this.text = text; + this.landType = landType; } private static FilterControlledPermanent getFilter(String landType) { @@ -78,7 +78,7 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A @Override public String getRule() { - return "Affinity for " + text; + return "Affinity for " + text + " (This spell costs 1 less to cast for each " + landType + " you control.)"; } @Override @@ -90,4 +90,4 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A } } } -} \ No newline at end of file +} diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index 03c0166028..7fe9215ad0 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -343,7 +343,13 @@ public class Spell extends StackObjImpl implements Card { @Override public String getIdName() { - return getName() + " ["+getId().toString().substring(0,3) +"]"; + String idName; + if (card != null) { + idName = card.getId().toString().substring(0,3); + } else { + idName = getId().toString().substring(0,3); + } + return getName() + " ["+idName+"]"; } @Override