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 GameView(GameState state, Game game) { for (Player player : state.getPlayers().values()) { players.add(new PlayerView(player, state, game)); } for (StackObject stackObject : state.getStack()) { if (stackObject instanceof StackAbility) { MageObject object = game.getObject(stackObject.getSourceId()); Card card = game.getCard(stackObject.getSourceId()); if (card != null) { if (object != null) { stack.put( stackObject.getId(), new StackAbilityView( game, (StackAbility) stackObject, card.getName(), new CardView(card))); } else { stack.put( stackObject.getId(), new StackAbilityView(game, (StackAbility) stackObject, "", new CardView(card))); } if (card.canTransform()) { updateLatestCardView(game, card, stackObject.getId()); } checkPaid(stackObject.getId(), (StackAbility) stackObject); } else if (object != null) { if (object instanceof PermanentToken) { PermanentToken token = (PermanentToken) object; stack.put(stackObject.getId(), new CardView(token)); checkPaid(stackObject.getId(), (StackAbility) stackObject); } else { StackAbility stackAbility = ((StackAbility) object); stackAbility.newId(); MageObject emblem = game.getEmblem(stackAbility.getSourceId()); if (emblem != null) { Card sourceCard = game.getCard(((CommandObject) emblem).getSourceId()); if (sourceCard != null) { stackAbility.setName("Emblem " + sourceCard.getName()); stackAbility.setExpansionSetCode(sourceCard.getExpansionSetCode()); } } stack.put(stackObject.getId(), new CardView(stackAbility)); checkPaid(stackObject.getId(), stackAbility); } } } else { stack.put(stackObject.getId(), new CardView((Spell) stackObject)); checkPaid(stackObject.getId(), (Spell) stackObject); } // stackOrder.add(stackObject.getId()); } // Collections.reverse(stackOrder); for (ExileZone exileZone : state.getExile().getExileZones()) { exiles.add(new ExileView(exileZone, game)); } for (String name : state.getRevealed().keySet()) { revealed.add(new RevealedView(name, state.getRevealed().get(name), game)); } this.phase = state.getTurn().getPhaseType(); this.step = state.getTurn().getStepType(); this.turn = state.getTurnNum(); if (state.getActivePlayerId() != null) this.activePlayerName = state.getPlayer(state.getActivePlayerId()).getName(); else this.activePlayerName = ""; if (state.getPriorityPlayerId() != null) this.priorityPlayerName = state.getPlayer(state.getPriorityPlayerId()).getName(); else this.priorityPlayerName = ""; for (CombatGroup combatGroup : state.getCombat().getGroups()) { combat.add(new CombatGroupView(combatGroup, game)); } this.special = state.getSpecialActions().getControlledBy(state.getPriorityPlayerId()).size() > 0; }