diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index 936db00f11..12548a431a 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mage.MageObject; import mage.ObjectColor; import mage.Constants.CardType; import mage.Constants.Rarity; @@ -116,6 +117,32 @@ public class CardView implements Serializable { } } + public CardView(MageObject card) { + this.id = card.getId(); + + this.name = card.getName(); + if (card instanceof Permanent) { + this.power = Integer.toString(card.getPower().getValue()); + this.toughness = Integer.toString(card.getToughness().getValue()); + this.loyalty = Integer.toString(((Permanent) card).getCounters().getCount(CounterType.LOYALTY)); + } else { + this.power = card.getPower().toString(); + this.toughness = card.getToughness().toString(); + this.loyalty = ""; + } + this.cardTypes = card.getCardType(); + this.subTypes = card.getSubtype(); + this.superTypes = card.getSupertype(); + this.color = card.getColor(); + this.manaCost = card.getManaCost().getSymbols(); + this.convertedManaCost = card.getManaCost().convertedManaCost(); + if (card instanceof PermanentToken) { + this.rarity = Rarity.COMMON; + this.expansionSetCode = ((PermanentToken)card).getExpansionSetCode(); + this.rules = ((PermanentToken)card).getRules(); + } + } + protected CardView() { } diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java index f040c289cf..53a2ea9997 100644 --- a/Mage.Common/src/mage/view/GameView.java +++ b/Mage.Common/src/mage/view/GameView.java @@ -76,10 +76,14 @@ public class GameView implements Serializable { if (stackObject instanceof StackAbility) { MageObject object = game.getObject(stackObject.getSourceId()); Card card = game.getCard(stackObject.getSourceId()); - if (object != null) - stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, object.getName(), new CardView(card))); - else - stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, "", new CardView(card))); + if (card != null) { + if (object != null) + stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, object.getName(), new CardView(card))); + else + stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, "", new CardView(card))); + } else if (object != null) { + stack.put(stackObject.getId(), new CardView(object)); + } } else { stack.put(stackObject.getId(), new CardView((Spell)stackObject)); diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 102c7bb621..7da8d31819 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -164,7 +164,8 @@ public abstract class AbilityImpl> implements Ability { //20100716 - 601.2e if (game.getObject(sourceId) != null) { //game.getObject(sourceId).adjustCosts(this, game); - game.getCard(sourceId).adjustCosts(this, game); + if (game.getCard(sourceId) != null) + game.getCard(sourceId).adjustCosts(this, game); } if (!useAlternativeCost(game)) {