forked from External/mage
* refactored createCopyOnStack to be void * added new interface for modifying copied spellsspells * update implementation of Fork to use new applier * reworked epic effect * add applier to spell copy code * updated implementation of Beamsplitter Mage * updated cards which copy for each possible target * added support for additional copies having targets changed * fixed/ignored failing tests * updated target changing to prevent unnecessary choosing * added test for Twinning Staff * updated implementation of spell copy applier * added new method for choosing order of copies on stack * fixed test failures * [TSR] various text fixes * fixed a test failure * [SLD] fixed Rick, Steadfast Leader only counting Human creatures * updated test framework to handle skips without affecting starting player choice * fixed another test failure * updated copy messaging for consistency * added copy messaging to stack abilities
96 lines
2.9 KiB
Java
96 lines
2.9 KiB
Java
package mage.abilities.effects.common;
|
|
|
|
import mage.abilities.Ability;
|
|
import mage.abilities.Mode;
|
|
import mage.abilities.effects.Effect;
|
|
import mage.abilities.effects.OneShotEffect;
|
|
import mage.constants.Outcome;
|
|
import mage.constants.Zone;
|
|
import mage.game.Game;
|
|
import mage.game.stack.Spell;
|
|
import mage.game.stack.StackObject;
|
|
import mage.players.Player;
|
|
|
|
/**
|
|
* @author BetaSteward_at_googlemail.com
|
|
*/
|
|
public class CopyTargetSpellEffect extends OneShotEffect {
|
|
|
|
private final boolean useController;
|
|
private final boolean useLKI;
|
|
private String copyThatSpellName = "that spell";
|
|
private final boolean chooseTargets;
|
|
|
|
public CopyTargetSpellEffect() {
|
|
this(false);
|
|
}
|
|
|
|
public CopyTargetSpellEffect(boolean useLKI) {
|
|
this(false, useLKI);
|
|
}
|
|
|
|
public CopyTargetSpellEffect(boolean useController, boolean useLKI) {
|
|
this(useController, useLKI, true);
|
|
}
|
|
|
|
public CopyTargetSpellEffect(boolean useController, boolean useLKI, boolean chooseTargets) {
|
|
super(Outcome.Copy);
|
|
this.useController = useController;
|
|
this.useLKI = useLKI;
|
|
this.chooseTargets = chooseTargets;
|
|
}
|
|
|
|
public CopyTargetSpellEffect(final CopyTargetSpellEffect effect) {
|
|
super(effect);
|
|
this.useLKI = effect.useLKI;
|
|
this.useController = effect.useController;
|
|
this.copyThatSpellName = effect.copyThatSpellName;
|
|
this.chooseTargets = effect.chooseTargets;
|
|
}
|
|
|
|
public Effect withSpellName(String copyThatSpellName) {
|
|
this.copyThatSpellName = copyThatSpellName;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public boolean apply(Game game, Ability source) {
|
|
Spell spell;
|
|
if (useLKI) {
|
|
spell = game.getSpellOrLKIStack(targetPointer.getFirst(game, source));
|
|
} else {
|
|
spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
|
|
}
|
|
if (spell == null) {
|
|
spell = (Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK);
|
|
}
|
|
if (spell != null) {
|
|
spell.createCopyOnStack(game, source, useController ? spell.getControllerId() : source.getControllerId(), chooseTargets);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public CopyTargetSpellEffect copy() {
|
|
return new CopyTargetSpellEffect(this);
|
|
}
|
|
|
|
@Override
|
|
public String getText(Mode mode) {
|
|
if (staticText != null && !staticText.isEmpty()) {
|
|
return staticText;
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("copy ");
|
|
if (!mode.getTargets().isEmpty()) {
|
|
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
|
|
} else {
|
|
sb.append(copyThatSpellName);
|
|
}
|
|
if (chooseTargets) {
|
|
sb.append(". You may choose new targets for the copy");
|
|
}
|
|
return sb.toString();
|
|
}
|
|
}
|