From ac19cfe379bf33d09024d6ae2da5db8b44c647c5 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 4 Dec 2015 08:24:18 +0100 Subject: [PATCH] Some changes to token expansion set calculation. --- .../src/mage/sets/magic2011/GraveTitan.java | 5 +--- .../java/mage/game/permanent/token/Token.java | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/sets/magic2011/GraveTitan.java b/Mage.Sets/src/mage/sets/magic2011/GraveTitan.java index 22f1f6bfa4..661c3b4553 100644 --- a/Mage.Sets/src/mage/sets/magic2011/GraveTitan.java +++ b/Mage.Sets/src/mage/sets/magic2011/GraveTitan.java @@ -95,10 +95,7 @@ class GraveTitanAbility extends TriggeredAbilityImpl { if (event.getType() == EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { return true; } - if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId())) { - return true; - } - return false; + return event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId()); } @Override diff --git a/Mage/src/main/java/mage/game/permanent/token/Token.java b/Mage/src/main/java/mage/game/permanent/token/Token.java index 5db9c045be..29c01d80f5 100644 --- a/Mage/src/main/java/mage/game/permanent/token/Token.java +++ b/Mage/src/main/java/mage/game/permanent/token/Token.java @@ -149,18 +149,25 @@ public class Token extends MageObjectImpl { // moved here from CreateTokenEffect because not all cards that create tokens use CreateTokenEffect // they use putOntoBattlefield directly - Card source = game.getCard(sourceId); - if (!expansionSetCodeChecked) { - expansionSetCodeChecked = this.updateExpansionSetCode(source); - } - // TODO: Check this setCode handling because it makes no sense if token put into play with e.g. "Feldon of the third Path" - String setCode; + String setCode = null; if (this.getOriginalExpansionSetCode() != null && !this.getOriginalExpansionSetCode().isEmpty()) { setCode = this.getOriginalExpansionSetCode(); } else { - setCode = source != null ? source.getExpansionSetCode() : null; + Card source = game.getCard(sourceId); + if (source != null) { + setCode = source.getExpansionSetCode(); + } else { + MageObject object = game.getObject(sourceId); + if (object instanceof PermanentToken) { + ((PermanentToken) object).getExpansionSetCode(); + } + } } + if (!expansionSetCodeChecked) { + expansionSetCodeChecked = this.updateExpansionSetCode(setCode); + } + GameEvent event = new GameEvent(EventType.CREATE_TOKEN, null, sourceId, controllerId, amount, this.getCardType().contains(CardType.CREATURE)); if (!game.replaceEvent(event)) { amount = event.getAmount(); @@ -258,11 +265,11 @@ public class Token extends MageObjectImpl { } } - public boolean updateExpansionSetCode(Card source) { - if (source == null) { + public boolean updateExpansionSetCode(String setCode) { + if (setCode == null || setCode.isEmpty()) { return false; } - this.setExpansionSetCodeForImage(source.getExpansionSetCode()); + this.setExpansionSetCodeForImage(setCode); return true; } }