* Lazav, Dimir Mastermind - Fixed a problem that was caused when the owner of the copied card left the game.

This commit is contained in:
LevelX2 2017-01-15 15:41:41 +01:00
parent 97e1ebc569
commit 2974771cb5

View file

@ -28,7 +28,6 @@
package mage.cards.l; package mage.cards.l;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility;
@ -56,7 +55,7 @@ import mage.target.targetpointer.FixedTarget;
public class LazavDimirMastermind extends CardImpl { public class LazavDimirMastermind extends CardImpl {
public LazavDimirMastermind(UUID ownerId, CardSetInfo setInfo) { public LazavDimirMastermind(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{U}{U}{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{U}{B}{B}");
this.supertype.add("Legendary"); this.supertype.add("Legendary");
this.subtype.add("Shapeshifter"); this.subtype.add("Shapeshifter");
@ -85,7 +84,6 @@ public class LazavDimirMastermind extends CardImpl {
class LazavDimirEffect extends ContinuousEffectImpl { class LazavDimirEffect extends ContinuousEffectImpl {
protected UUID IdOfCopiedCard;
protected Card cardToCopy; protected Card cardToCopy;
public LazavDimirEffect() { public LazavDimirEffect() {
@ -96,7 +94,6 @@ class LazavDimirEffect extends ContinuousEffectImpl {
public LazavDimirEffect(final LazavDimirEffect effect) { public LazavDimirEffect(final LazavDimirEffect effect) {
super(effect); super(effect);
this.cardToCopy = effect.cardToCopy; this.cardToCopy = effect.cardToCopy;
this.IdOfCopiedCard = effect.IdOfCopiedCard;
} }
@Override @Override
@ -105,17 +102,23 @@ class LazavDimirEffect extends ContinuousEffectImpl {
} }
@Override @Override
public boolean apply(Game game, Ability source) { public void init(Ability source, Game game) {
Card card = game.getCard(((FixedTarget)getTargetPointer()).getTarget()); super.init(source, game);
Permanent permanent = game.getPermanent(source.getSourceId()); Card card = game.getCard(((FixedTarget) getTargetPointer()).getTarget());
if (card == null || permanent == null) { if (card != null) {
discard();
return false;
}
if (IdOfCopiedCard == null || !IdOfCopiedCard.equals(card.getId())) {
IdOfCopiedCard = card.getId();
cardToCopy = card.copy(); cardToCopy = card.copy();
cardToCopy.assignNewId(); cardToCopy.assignNewId();
} else {
discard();
}
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
discard();
return true;
} }
permanent.getPower().setValue(cardToCopy.getPower().getValue()); permanent.getPower().setValue(cardToCopy.getPower().getValue());
permanent.getToughness().setValue(cardToCopy.getToughness().getValue()); permanent.getToughness().setValue(cardToCopy.getToughness().getValue());