forked from External/mage
Added framework method for copying a StackAbility without casting it.
Modified the effects doing so with the new method.
This commit is contained in:
parent
b9ab16d945
commit
8823839a42
34 changed files with 158 additions and 313 deletions
|
|
@ -56,6 +56,8 @@ import mage.constants.ZoneDetail;
|
|||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
|
|
@ -873,4 +875,14 @@ public class Spell extends StackObjImpl implements Card {
|
|||
throw new UnsupportedOperationException("Not supported for Spell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackObject createCopyOnStack(Game game, Ability source, UUID newControllerId, boolean chooseNewTargets) {
|
||||
Spell copy = this.copySpell(newControllerId);
|
||||
game.getStack().push(copy);
|
||||
if (chooseNewTargets) {
|
||||
copy.chooseNewTargets(game, newControllerId);
|
||||
}
|
||||
game.fireEvent(new GameEvent(EventType.COPIED_STACKOBJECT, copy.getId(), this.getId(), newControllerId));
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -580,4 +580,21 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
public void setCanFizzle(boolean canFizzle) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackObject createCopyOnStack(Game game, Ability source, UUID newControllerId, boolean chooseNewTargets) {
|
||||
Ability newAbility = this.copy();
|
||||
newAbility.newId();
|
||||
StackAbility newStackAbility = new StackAbility(newAbility, newControllerId);
|
||||
game.getStack().push(newStackAbility);
|
||||
if (chooseNewTargets && newAbility.getTargets().size() > 0) {
|
||||
Player controller = game.getPlayer(newControllerId);
|
||||
if (controller.chooseUse(newAbility.getEffects().get(0).getOutcome(), "Choose new targets?", source, game)) {
|
||||
newAbility.getTargets().clearChosen();
|
||||
newAbility.getTargets().chooseTargets(newAbility.getEffects().get(0).getOutcome(), newControllerId, newAbility, false, game);
|
||||
}
|
||||
}
|
||||
game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT, newStackAbility.getId(), this.getId(), newControllerId));
|
||||
return newStackAbility;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public interface StackObject extends MageObject, Controllable {
|
|||
|
||||
// int getConvertedManaCost();
|
||||
boolean chooseNewTargets(Game game, UUID playerId, boolean forceChange, boolean onlyOneTarget, FilterPermanent filterNewTarget);
|
||||
|
||||
StackObject createCopyOnStack(Game game, Ability source, UUID newControllerId, boolean chooseNewTargets);
|
||||
|
||||
@Override
|
||||
StackObject copy();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue