Merge branch 'changetargets' into 'master'

ChangeTargets: Fix same choices

See merge request core-developers/forge!5174
This commit is contained in:
Michael Kamensky
2021-08-04 05:09:35 +00:00
3 changed files with 11 additions and 11 deletions

View File

@@ -76,12 +76,14 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
GameObject oldTarget = chosenTarget.getValue();
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
TargetChoices newTargetBlock = oldTargetBlock.clone();
// gets the divied value from old target
// gets the divided value from old target
Integer div = oldTargetBlock.getDividedValue(oldTarget);
// 3. test if updated choices would be correct.
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null);
if (replaceIn.getSpellAbility(true).canTarget(newTarget)) {
// CR 115.3. The same target cant be chosen multiple times for
// any one instance of the word “target” on a spell or ability.
if (!oldTargetBlock.contains(newTarget) && replaceIn.getSpellAbility(true).canTarget(newTarget)) {
newTargetBlock.remove(oldTarget);
newTargetBlock.add(newTarget);
if (div != null) {
@@ -89,8 +91,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
}
replaceIn.updateTarget(newTargetBlock, sa.getHostCard());
}
}
else {
} else {
while (changingTgtSI != null) {
SpellAbility changingTgtSA = changingTgtSI.getSpellAbility(true);
if (changingTgtSA.usesTargeting()) {
@@ -126,8 +127,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
changingTgtSA.addDividedAllocation(newTarget, div);
}
}
}
else {
} else {
// Update targets, with a potential new target
Predicate<GameObject> filter = sa.hasParam("TargetRestriction") ? GameObjectPredicates.restriction(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard(), sa) : null;
// TODO Creature.Other might not work yet as it should