mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Merge branch 'changetargets' into 'master'
ChangeTargets: Fix same choices See merge request core-developers/forge!5174
This commit is contained in:
@@ -56,10 +56,10 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
if (sa.hasParam("ChangeSingleTarget")) {
|
if (sa.hasParam("ChangeSingleTarget")) {
|
||||||
// 1. choose a target of target spell
|
// 1. choose a target of target spell
|
||||||
List<Pair<SpellAbilityStackInstance, GameObject>> allTargets = new ArrayList<>();
|
List<Pair<SpellAbilityStackInstance, GameObject>> allTargets = new ArrayList<>();
|
||||||
while(changingTgtSI != null) {
|
while (changingTgtSI != null) {
|
||||||
SpellAbility changedSa = changingTgtSI.getSpellAbility(true);
|
SpellAbility changedSa = changingTgtSI.getSpellAbility(true);
|
||||||
if (changedSa.usesTargeting()) {
|
if (changedSa.usesTargeting()) {
|
||||||
for(GameObject it : changedSa.getTargets())
|
for (GameObject it : changedSa.getTargets())
|
||||||
allTargets.add(ImmutablePair.of(changingTgtSI, it));
|
allTargets.add(ImmutablePair.of(changingTgtSI, it));
|
||||||
}
|
}
|
||||||
changingTgtSI = changingTgtSI.getSubInstance();
|
changingTgtSI = changingTgtSI.getSubInstance();
|
||||||
@@ -76,12 +76,14 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
GameObject oldTarget = chosenTarget.getValue();
|
GameObject oldTarget = chosenTarget.getValue();
|
||||||
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
|
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
|
||||||
TargetChoices newTargetBlock = oldTargetBlock.clone();
|
TargetChoices newTargetBlock = oldTargetBlock.clone();
|
||||||
// gets the divied value from old target
|
// gets the divided value from old target
|
||||||
Integer div = oldTargetBlock.getDividedValue(oldTarget);
|
Integer div = oldTargetBlock.getDividedValue(oldTarget);
|
||||||
// 3. test if updated choices would be correct.
|
// 3. test if updated choices would be correct.
|
||||||
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null);
|
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null);
|
||||||
|
|
||||||
if (replaceIn.getSpellAbility(true).canTarget(newTarget)) {
|
// CR 115.3. The same target can’t 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.remove(oldTarget);
|
||||||
newTargetBlock.add(newTarget);
|
newTargetBlock.add(newTarget);
|
||||||
if (div != null) {
|
if (div != null) {
|
||||||
@@ -89,9 +91,8 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
replaceIn.updateTarget(newTargetBlock, sa.getHostCard());
|
replaceIn.updateTarget(newTargetBlock, sa.getHostCard());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
while (changingTgtSI != null) {
|
||||||
while(changingTgtSI != null) {
|
|
||||||
SpellAbility changingTgtSA = changingTgtSI.getSpellAbility(true);
|
SpellAbility changingTgtSA = changingTgtSI.getSpellAbility(true);
|
||||||
if (changingTgtSA.usesTargeting()) {
|
if (changingTgtSA.usesTargeting()) {
|
||||||
// random target and DefinedMagnet works on single targets
|
// random target and DefinedMagnet works on single targets
|
||||||
@@ -126,8 +127,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
changingTgtSA.addDividedAllocation(newTarget, div);
|
changingTgtSA.addDividedAllocation(newTarget, div);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Update targets, with a potential new target
|
// Update targets, with a potential new target
|
||||||
Predicate<GameObject> filter = sa.hasParam("TargetRestriction") ? GameObjectPredicates.restriction(sa.getParam("TargetRestriction").split(","), activator, sa.getHostCard(), sa) : null;
|
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
|
// TODO Creature.Other might not work yet as it should
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ Name:Bond of Flourishing
|
|||||||
ManaCost:1 G
|
ManaCost:1 G
|
||||||
Types:Sorcery
|
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.
|
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.
|
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.
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ Name:Bond of Passion
|
|||||||
ManaCost:4 R R
|
ManaCost:4 R R
|
||||||
Types:Sorcery
|
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.
|
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.
|
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user