- Fix crash related to ChangeTargets and SA/subSAs without a target. SubAbilities can now have their targets changed

This commit is contained in:
Sol
2013-05-10 23:03:42 +00:00
parent ad5cecdbc5
commit ba644b69fc
3 changed files with 14 additions and 3 deletions

View File

@@ -3,7 +3,8 @@ ManaCost:3 R
Types:Instant Types:Instant
A:SP$ ChooseType | Cost$ 3 R | Defined$ You | Type$ Card | SubAbility$ DBReveal | SpellDescription$ Choose a card type. Target opponent reveals his or her hand. Blood Oath deals 3 damage to that player for each card of the chosen type revealed this way. A:SP$ ChooseType | Cost$ 3 R | Defined$ You | Type$ Card | SubAbility$ DBReveal | SpellDescription$ Choose a card type. Target opponent reveals his or her hand. Blood Oath deals 3 damage to that player for each card of the chosen type revealed this way.
SVar:DBReveal:DB$ RevealHand | RememberRevealed$ True | ValidTgts$ Opponent | TgtPrompt$ Select target opponent to reveal their hand | SubAbility$ DBDamage SVar:DBReveal:DB$ RevealHand | RememberRevealed$ True | ValidTgts$ Opponent | TgtPrompt$ Select target opponent to reveal their hand | SubAbility$ DBDamage
SVar:DBDamage:DB$ DealDamage | Defined$ Targeted | NumDmg$ X | References$ X,Y SVar:DBDamage:DB$ DealDamage | Defined$ Targeted | NumDmg$ X | References$ X,Y | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:SVar$Y/Times.3 SVar:X:SVar$Y/Times.3
SVar:Y:Remembered$Valid Card.ChosenType SVar:Y:Remembered$Valid Card.ChosenType
SVar:RemAIDeck:True SVar:RemAIDeck:True

View File

@@ -28,8 +28,15 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
// If there isn't a Stack Instance, there isn't really a target // If there isn't a Stack Instance, there isn't really a target
continue; continue;
} }
// Update targets, with a potential new target
si.updateTarget(sa.getActivatingPlayer().getController().chooseTargets(tgtSA)); SpellAbilityStackInstance changingTgtSI = si;
while(changingTgtSI != null) {
// Update targets, with a potential new target
SpellAbility changingTgtSA = changingTgtSI.getSpellAbility();
changingTgtSI.updateTarget(sa.getActivatingPlayer().getController().chooseTargets(changingTgtSA));
changingTgtSI = changingTgtSI.getSubInstace();
}
if (remember) { if (remember) {
sa.getSourceCard().addRemembered(tgtSA.getSourceCard()); sa.getSourceCard().addRemembered(tgtSA.getSourceCard());
} }

View File

@@ -416,6 +416,9 @@ public class PlayerControllerHuman extends PlayerController {
*/ */
@Override @Override
public Target chooseTargets(SpellAbility ability) { public Target chooseTargets(SpellAbility ability) {
if (ability.getTarget() == null) {
return null;
}
Target oldTarget = new Target(ability.getTarget()); Target oldTarget = new Target(ability.getTarget());
TargetSelection select = new TargetSelection(ability); TargetSelection select = new TargetSelection(ability);
ability.getTarget().resetTargets(); ability.getTarget().resetTargets();