From 5925bdf2599f47ac2e3ec67d18ce53a92fea6c58 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 16 Mar 2018 18:25:28 +0100 Subject: [PATCH] * Fixed a problem that Spell objects were not handled always correctly in game view. --- .../src/main/java/mage/view/GameView.java | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/Mage.Common/src/main/java/mage/view/GameView.java b/Mage.Common/src/main/java/mage/view/GameView.java index b354503c56..6dc733112f 100644 --- a/Mage.Common/src/main/java/mage/view/GameView.java +++ b/Mage.Common/src/main/java/mage/view/GameView.java @@ -27,18 +27,14 @@ */ package mage.view; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import java.io.Serializable; -import java.io.BufferedWriter; -import java.io.PrintWriter; -import java.io.FileWriter; -import java.io.IOException; - import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; - import mage.MageObject; import mage.abilities.costs.Cost; import mage.cards.Card; @@ -60,8 +56,6 @@ import mage.game.stack.StackObject; import mage.players.Player; import mage.watchers.common.CastSpellLastTurnWatcher; import org.apache.log4j.Logger; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; /** * @@ -105,7 +99,12 @@ public class GameView implements Serializable { } } for (StackObject stackObject : state.getStack()) { - if (stackObject instanceof StackAbility) { + if (stackObject instanceof Spell) { + // Spell + CardView spellView = new CardView((Spell) stackObject, game, stackObject.getControllerId().equals(createdForPlayerId)); + spellView.paid = ((Spell) stackObject).getSpellAbility().getManaCostsToPay().isPaid(); + stack.put(stackObject.getId(), spellView); + } else if (stackObject instanceof StackAbility) { // Stack Ability MageObject object = game.getObject(stackObject.getSourceId()); Card card = game.getCard(stackObject.getSourceId()); @@ -161,9 +160,7 @@ public class GameView implements Serializable { LOGGER.debug("Stack Object for stack ability not found: " + stackObject.getStackAbility().getRule()); } } else { - // Spell - stack.put(stackObject.getId(), new CardView((Spell) stackObject, game, stackObject.getControllerId().equals(createdForPlayerId))); - checkPaid(stackObject.getId(), (Spell) stackObject); + LOGGER.fatal("Unknown type of StackObject: " + stackObject.getName() + ' ' + stackObject.toString() + ' ' + stackObject.getClass().toString()); } //stackOrder.add(stackObject.getId()); } @@ -223,21 +220,6 @@ public class GameView implements Serializable { cardView.paid = true; } - private void checkPaid(UUID uuid, Spell spell) { - for (Cost cost : spell.getSpellAbility().getManaCostsToPay()) { - if (!cost.isPaid()) { - return; - } - } - CardView cardView = stack.get(uuid); - cardView.paid = true; - } - - private void setPaid(UUID uuid) { - CardView cardView = stack.get(uuid); - cardView.paid = true; - } - private void updateLatestCardView(Game game, Card card, UUID stackId) { if (!card.isTransformable()) { return;