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

@@ -56,10 +56,10 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
if (sa.hasParam("ChangeSingleTarget")) {
// 1. choose a target of target spell
List<Pair<SpellAbilityStackInstance, GameObject>> allTargets = new ArrayList<>();
while(changingTgtSI != null) {
while (changingTgtSI != null) {
SpellAbility changedSa = changingTgtSI.getSpellAbility(true);
if (changedSa.usesTargeting()) {
for(GameObject it : changedSa.getTargets())
for (GameObject it : changedSa.getTargets())
allTargets.add(ImmutablePair.of(changingTgtSI, it));
}
changingTgtSI = changingTgtSI.getSubInstance();
@@ -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,9 +91,8 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
}
replaceIn.updateTarget(newTargetBlock, sa.getHostCard());
}
}
else {
while(changingTgtSI != null) {
} else {
while (changingTgtSI != null) {
SpellAbility changingTgtSA = changingTgtSI.getSpellAbility(true);
if (changingTgtSA.usesTargeting()) {
// random target and DefinedMagnet works on single targets
@@ -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

View File

@@ -2,5 +2,5 @@ Name:Bond of Flourishing
ManaCost:1 G
Types:Sorcery
A:SP$ Dig | Cost$ 1 G | DigNum$ 3 | ChangeNum$ 1 | Optional$ True | ChangeValid$ Permanent | DestinationZone$ Hand | DestinationZone2$ Library | LibraryPosition$ -1 | RestRandomOrder$ True | SubAbility$ GainLife | SpellDescription$ Look at the top three cards of your library. You may reveal a permanent card from among them and put it into your hand. Put the rest on the bottom of your library in any order. You gain 3 life.
SVar:GainLife:DB$GainLife | LifeAmount$ 3
SVar:GainLife:DB$ GainLife | LifeAmount$ 3
Oracle:Look at the top three cards of your library. You may reveal a permanent card from among them and put it into your hand. Put the rest on the bottom of your library in any order. You gain 3 life.

View File

@@ -2,5 +2,5 @@ Name:Bond of Passion
ManaCost:4 R R
Types:Sorcery
A:SP$ GainControl | Cost$ 4 R R | ValidTgts$ Creature | TgtPrompt$ Select target creature. | LoseControl$ EOT | Untap$ True | AddKWs$ Haste | SubAbility$ DBDamage | SpellDescription$ Gain control of target creature until end of turn. Untap that creature. It gains haste until end of turn. CARDNAME deals 2 damage to any target.
SVar:DBDamage:DB$DealDamage | ValidTgts$ Creature,Player,Planeswalker | NumDmg$ 2 | TargetUnique$ True | TgtPrompt$ Select any target.
SVar:DBDamage:DB$ DealDamage | ValidTgts$ Creature,Player,Planeswalker | NumDmg$ 2 | TargetUnique$ True | TgtPrompt$ Select any target.
Oracle:Gain control of target creature until end of turn. Untap that creature. It gains haste until end of turn. Bond of Passion deals 2 damage to any other target.