mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
rearrange and update comments
This commit is contained in:
@@ -40,13 +40,12 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean preserveNumber = sa.hasParam("PreserveNumber"); // Redirect is not supposed to change number of targets
|
boolean preserveNumber = sa.hasParam("PreserveNumber"); // Redirect is not supposed to change number of targets
|
||||||
boolean changeOneTarget = sa.hasParam("ChangeSingleTarget"); // The only card known to replace targets with self is Spellskite
|
boolean changesOneTarget = sa.hasParam("ChangeSingleTarget"); // The only card known to replace targets with self is Spellskite
|
||||||
|
|
||||||
SpellAbilityStackInstance changingTgtSI = si;
|
SpellAbilityStackInstance changingTgtSI = si;
|
||||||
Player chooser = sa.getActivatingPlayer();
|
Player chooser = sa.getActivatingPlayer();
|
||||||
|
|
||||||
if( changeOneTarget ) {
|
if( changesOneTarget ) {
|
||||||
ITargetable newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa), null);
|
|
||||||
// 1. choose a target of target spell
|
// 1. choose a target of target spell
|
||||||
List<Pair<SpellAbilityStackInstance, ITargetable>> allTargets = new ArrayList<>();
|
List<Pair<SpellAbilityStackInstance, ITargetable>> allTargets = new ArrayList<>();
|
||||||
while(changingTgtSI != null) {
|
while(changingTgtSI != null) {
|
||||||
@@ -63,14 +62,15 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<SpellAbilityStackInstance, ITargetable> chosenTarget = chooser.getController().chooseTarget(sa, allTargets);
|
Pair<SpellAbilityStackInstance, ITargetable> chosenTarget = chooser.getController().chooseTarget(sa, allTargets);
|
||||||
// 2. replace with spellskite
|
// 2. prepare new target choices
|
||||||
SpellAbilityStackInstance replaceIn = chosenTarget.getKey();
|
SpellAbilityStackInstance replaceIn = chosenTarget.getKey();
|
||||||
ITargetable oldTarget = chosenTarget.getValue();
|
ITargetable oldTarget = chosenTarget.getValue();
|
||||||
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
|
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
|
||||||
TargetChoices newTargetBlock = oldTargetBlock.clone();
|
TargetChoices newTargetBlock = oldTargetBlock.clone();
|
||||||
newTargetBlock.remove(oldTarget);
|
newTargetBlock.remove(oldTarget);
|
||||||
replaceIn.updateTarget(newTargetBlock);
|
replaceIn.updateTarget(newTargetBlock);
|
||||||
// 3. test if replacing is correct.
|
// 3. test if updated choices would be correct.
|
||||||
|
ITargetable newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa), null);
|
||||||
if(replaceIn.getSpellAbility().canTarget(newTarget)) {
|
if(replaceIn.getSpellAbility().canTarget(newTarget)) {
|
||||||
newTargetBlock.add(newTarget);
|
newTargetBlock.add(newTarget);
|
||||||
replaceIn.updateTarget(newTargetBlock);
|
replaceIn.updateTarget(newTargetBlock);
|
||||||
|
|||||||
Reference in New Issue
Block a user