* Fixed a problem that Spell objects were not handled always correctly in game view.
*/
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;
