Refactor: added docs for a copy stack object code (#7662);

This commit is contained in:
Oleg Agafonov 2021-08-15 17:12:59 +04:00
parent c328c71ef9
commit f21c492ce2
16 changed files with 136 additions and 85 deletions

View file

@ -1058,18 +1058,21 @@ public class Spell extends StackObjectImpl implements Card {
}
@Override
public void createSingleCopy(UUID newControllerId, StackObjectCopyApplier applier, MageObjectReferencePredicate predicate, Game game, Ability source, boolean chooseNewTargets) {
public void createSingleCopy(UUID newControllerId, StackObjectCopyApplier applier, MageObjectReferencePredicate newTargetFilterPredicate, Game game, Ability source, boolean chooseNewTargets) {
Spell spellCopy = this.copySpell(game, source, newControllerId);
if (applier != null) {
applier.modifySpell(spellCopy, game);
}
spellCopy.setZone(Zone.STACK, game); // required for targeting ex: Nivmagus Elemental
game.getStack().push(spellCopy);
if (predicate != null) {
spellCopy.chooseNewTargets(game, newControllerId, true, false, predicate);
// new targets
if (newTargetFilterPredicate != null) {
spellCopy.chooseNewTargets(game, newControllerId, true, false, newTargetFilterPredicate);
} else if (chooseNewTargets || applier != null) { // if applier is non-null but predicate is null then it's extra
spellCopy.chooseNewTargets(game, newControllerId);
}
game.fireEvent(new CopiedStackObjectEvent(this, spellCopy, newControllerId));
}