* Spark Double - fixed that copy of spark contains legendary type (#6097)

This commit is contained in:
Oleg Agafonov 2019-12-18 17:46:46 +04:00
parent fbff54145e
commit 23ef0e4269
7 changed files with 143 additions and 24 deletions

View file

@ -7,7 +7,6 @@ import mage.abilities.Mode;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
@ -136,6 +135,8 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
} else {
permanent = game.getPermanentOrLKIBattlefield(targetId);
}
// can target card or permanent
Card copyFrom;
ApplyToPermanent applier = new EmptyApplyToPermanent();
if (permanent != null) {

View file

@ -45,6 +45,7 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.game.stack.Spell;
import mage.game.stack.SpellStack;
import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
import mage.game.turn.Phase;
import mage.game.turn.Step;
@ -1568,7 +1569,7 @@ public abstract class GameImpl implements Game, Serializable {
}
newBluePrint.assignNewId();
if (copyFromPermanent.isTransformed()) {
TransformAbility.transform(newBluePrint, copyFromPermanent.getSecondCardFace(), this);
TransformAbility.transform(newBluePrint, newBluePrint.getSecondCardFace(), this);
}
}
if (applier != null) {
@ -1584,7 +1585,7 @@ public abstract class GameImpl implements Game, Serializable {
Ability newAbility = source.copy();
newEffect.init(newAbility, this);
// If there are already copy effects with dration = Custom to the same object, remove the existing effects because they no longer have any effect
// If there are already copy effects with duration = Custom to the same object, remove the existing effects because they no longer have any effect
if (duration == Duration.Custom) {
for (Effect effect : getState().getContinuousEffects().getLayeredEffects(this)) {
if (effect instanceof CopyEffect) {

View file

@ -1,16 +1,27 @@
package mage.util.functions;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.game.Game;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public abstract class ApplyToMageObject {
// WARNING:
// 1. Applier uses for copy effects only;
// 2. It's applies to blueprint, not real object (real object is targetObjectId and can be card or token, even outside from game like EmptyToken);
// 3. "source" is current copy ability and can be different from original copy ability (copy of copy);
// 4. Don't use "source" param at all;
// 5. Use isCopyOfCopy() to detect it (some effects can applies to copy of copy, but other can't -- ses Spark Double as example).
// TODO: check all aplliers implementations - remove source uses, add isCopyOfCopy processing
public abstract boolean apply(Game game, MageObject mageObject, Ability source, UUID targetObjectId);
public boolean isCopyOfCopy(Ability source, UUID targetObjectId) {
return !Objects.equals(targetObjectId, source.getSourceId());
}
}

View file

@ -1,15 +1,17 @@
package mage.util.functions;
import java.io.Serializable;
import java.util.UUID;
import mage.abilities.Ability;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.Serializable;
import java.util.UUID;
/**
* @author noxx
*/
public abstract class ApplyToPermanent extends ApplyToMageObject implements Serializable {
// WARNING: see comments in ApplyToMageObject
public abstract boolean apply(Game game, Permanent permanent, Ability source, UUID targetObjectId);
}