* Spark Double - fixed duplicated counters on copying of another Spark Double (#7553);

This commit is contained in:
Oleg Agafonov 2021-02-22 21:22:31 +04:00
parent f6c0f4c712
commit 2accab79c5
10 changed files with 113 additions and 56 deletions

View file

@ -53,7 +53,15 @@ public class CopyPermanentEffect extends OneShotEffect {
this.applier = applier;
this.filter = filter;
this.useTargetOfAbility = useTarget;
this.staticText = "as a copy of any " + filter.getMessage() + " on the battlefield";
String text = "as a copy of";
if (filter.getMessage().startsWith("a ") || filter.getMessage().startsWith("an ")) {
text += " " + filter.getMessage();
} else {
text += " any " + filter.getMessage() + " on battlefield";
}
text += applier == null ? "" : applier.getText();
this.staticText = text;
}
public CopyPermanentEffect(final CopyPermanentEffect effect) {

View file

@ -182,7 +182,7 @@ public interface Card extends MageObject {
}
/**
* Commander tax calculation. Can be change from {2} to life life cost (see Liesa, Shroud of Dusk)
* Commander tax calculation. Tax logic can be changed (example: from {2} to life cost, see Liesa, Shroud of Dusk)
*
* @param game
* @param source

View file

@ -1687,6 +1687,7 @@ public abstract class GameImpl implements Game, Serializable {
}
}
}
// if it was no copy of copy take the target itself
if (newBluePrint == null) {
newBluePrint = copyFromPermanent.copy();

View file

@ -5,7 +5,6 @@ import mage.abilities.Ability;
import mage.game.Game;
import java.io.Serializable;
import java.util.Objects;
import java.util.UUID;
/**
@ -20,10 +19,14 @@ public abstract class CopyApplier implements Serializable {
// 2. It applies to the blueprint, not the real object (the real object is targetObjectId and can be card or token, even from outside the game like EmptyToken);
// 3. "source" is the current copy ability and can be different from the original copy ability (copy of copy);
// 4. Don't use "source" param at all;
// 5. Use isCopyOfCopy() to detect it (some effects can apply to copy of copy, but others can't -- see Spark Double as an example).
// 5. For exception/non-copyable effects use isCopyOfCopy() to detect that situation (example: 706.9e, Spark Double, Altered Ego).
public abstract boolean apply(Game game, MageObject blueprint, Ability source, UUID targetObjectId);
public boolean isCopyOfCopy(Ability source, UUID targetObjectId) {
return !Objects.equals(targetObjectId, source.getSourceId());
public boolean isCopyOfCopy(Ability source, MageObject blueprint, UUID targetObjectId) {
return blueprint.isCopy();
}
public String getText() {
return "";
}
}