From 617374e13fdfb92423884befe1918bd2b666a390 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Sat, 24 Sep 2011 11:00:50 +0400 Subject: [PATCH] fixed night card not displayed in the stack --- .../java/org/mage/card/arcane/CardPanel.java | 3 ++ Mage.Common/src/mage/view/CardView.java | 4 +++ Mage.Common/src/mage/view/GameView.java | 29 +++++++++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index d931a7f346..ef6f8da05e 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -197,6 +197,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti setImage(srcImage); setFoil(foil); } + if (gameCard.isTransformed()) { + toggleTransformed(); + } } catch (Exception e) { e.printStackTrace(); } catch (Error err) { diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index d84800c1c2..01bf7ff6b8 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -345,6 +345,10 @@ public class CardView extends SimpleCardView { return this.secondCardFace; } + public void setTransformed(boolean transformed) { + this.transformed = transformed; + } + public boolean isTransformed() { return this.transformed; } diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java index c9fdb6ad5a..8454292792 100644 --- a/Mage.Common/src/mage/view/GameView.java +++ b/Mage.Common/src/mage/view/GameView.java @@ -32,7 +32,9 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.UUID; +import mage.Constants; import mage.MageObject; import mage.Constants.PhaseStep; import mage.Constants.TurnPhase; @@ -41,6 +43,7 @@ import mage.game.ExileZone; import mage.game.Game; import mage.game.GameState; import mage.game.combat.CombatGroup; +import mage.game.permanent.Permanent; import mage.game.stack.Spell; import mage.game.stack.StackAbility; import mage.game.stack.StackObject; @@ -77,11 +80,15 @@ public class GameView implements Serializable { MageObject object = game.getObject(stackObject.getSourceId()); Card card = game.getCard(stackObject.getSourceId()); if (card != null) { - if (object != null) + if (object != null) { stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, object.getName(), new CardView(card))); - else + } else { stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, "", new CardView(card))); - } else if (object != null) { + } + if (card.canTransform()) { + updateLatestCardView(game, card, stackObject.getId()); + } + } else if (object != null) { stack.put(stackObject.getId(), new CardView(object)); } } @@ -112,6 +119,22 @@ public class GameView implements Serializable { this.special = state.getSpecialActions().getControlledBy(state.getPriorityPlayerId()).size() > 0; } + private void updateLatestCardView(Game game, Card card, UUID stackId) { + if (!card.canTransform()) { + return; + } + Permanent permanent = game.getPermanent(card.getId()); + if (permanent == null) { + permanent = (Permanent)game.getLastKnownInformation(card.getId(), Constants.Zone.BATTLEFIELD); + } + if (permanent != null) { + if (permanent.isTransformed()) { + StackAbilityView stackAbilityView = (StackAbilityView) stack.get(stackId); + stackAbilityView.getSourceCard().setTransformed(true); + } + } + } + public List getPlayers() { return players; }