* Fixed token ability (id handling) and token cardType (reset was not correctly done) handling (this fixed problems with copying Planeswalker with Helm of the Host).

This commit is contained in:
LevelX2 2018-05-07 00:44:32 +02:00
parent feb17320c5
commit bb15176a84
5 changed files with 87 additions and 12 deletions

View file

@ -34,7 +34,6 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
/**
@ -108,8 +107,8 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
if (losePreviousTypes) {
permanent.getCardType().clear();
}
for (CardType t : token.getCardType()) {
permanent.addCardType(t);
for (CardType cardType : token.getCardType()) {
permanent.addCardType(cardType);
}
if (type != null && type.isEmpty() || type == null && permanent.isLand()) {
permanent.getSubtype(game).retainAll(SubType.getLandTypes(false));

View file

@ -46,7 +46,7 @@ public class PermanentToken extends PermanentImpl {
super(controllerId, controllerId, token.getName());
this.expansionSetCode = expansionSetCode;
this.token = token.copy();
this.token.getAbilities().newId(); // neccessary if token has ability like DevourAbility()
this.token.getAbilities().newOriginalId(); // neccessary if token has ability like DevourAbility()
this.token.getAbilities().setSourceId(objectId);
this.power.modifyBaseValue(token.getPower().getBaseValueModified());
this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified());
@ -84,7 +84,8 @@ public class PermanentToken extends PermanentImpl {
for (ManaCost cost : token.getManaCost()) {
this.getManaCost().add(cost.copy());
}
this.cardType = token.getCardType();
this.cardType.clear();
this.cardType.addAll(token.getCardType());
this.color = token.getColor(game).copy();
this.frameColor = token.getFrameColor(game);
this.frameStyle = token.getFrameStyle();

View file

@ -33,11 +33,8 @@ import java.util.Locale;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectImpl;
import mage.ObjectColor;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -47,7 +44,6 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.players.Player;
import mage.util.RandomUtil;
import mage.util.SubTypeList;
public abstract class TokenImpl extends MageObjectImpl implements Token {

View file

@ -36,7 +36,6 @@ import mage.constants.SubType;
import mage.constants.SuperType;
import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentToken;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
/**
@ -110,8 +109,8 @@ public class CopyTokenFunction implements Function<Token, Card> {
for (Ability ability0 : sourceObj.getAbilities()) {
Ability ability = ability0.copy();
ability.newId();
ability.setSourceId(target.getId());
ability.newOriginalId(); // The token is independant from the copy from object so it need a new original Id, otherwise there are problems to check for created continuous effects to check if the source (the Token) has still this ability
target.addAbility(ability);
}