mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Fixed NPE and triggered abilities not working for tokens.
This commit is contained in:
parent
ccca6db6a9
commit
ff32c1698b
3 changed files with 37 additions and 5 deletions
|
@ -33,6 +33,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
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() {
|
protected CardView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,10 +76,14 @@ public class GameView implements Serializable {
|
||||||
if (stackObject instanceof StackAbility) {
|
if (stackObject instanceof StackAbility) {
|
||||||
MageObject object = game.getObject(stackObject.getSourceId());
|
MageObject object = game.getObject(stackObject.getSourceId());
|
||||||
Card card = game.getCard(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)));
|
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)));
|
stack.put(stackObject.getId(), new StackAbilityView((StackAbility)stackObject, "", new CardView(card)));
|
||||||
|
} else if (object != null) {
|
||||||
|
stack.put(stackObject.getId(), new CardView(object));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stack.put(stackObject.getId(), new CardView((Spell)stackObject));
|
stack.put(stackObject.getId(), new CardView((Spell)stackObject));
|
||||||
|
|
|
@ -164,6 +164,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
//20100716 - 601.2e
|
//20100716 - 601.2e
|
||||||
if (game.getObject(sourceId) != null) {
|
if (game.getObject(sourceId) != null) {
|
||||||
//game.getObject(sourceId).adjustCosts(this, game);
|
//game.getObject(sourceId).adjustCosts(this, game);
|
||||||
|
if (game.getCard(sourceId) != null)
|
||||||
game.getCard(sourceId).adjustCosts(this, game);
|
game.getCard(sourceId).adjustCosts(this, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue