mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Fixed issue with AI retargeting for Optional triggers
- SpellAbilities will now (again) stay on the stack until they are finished resolving, allowing ChangeTarget spells to redirect Counterspells to themselves
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package forge.card.trigger;
|
package forge.card.trigger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -16,6 +15,7 @@ import forge.card.spellability.ISpellAbility;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.spellability.SpellAbilityRestriction;
|
import forge.card.spellability.SpellAbilityRestriction;
|
||||||
import forge.card.spellability.Target;
|
import forge.card.spellability.Target;
|
||||||
|
import forge.card.spellability.TargetChoices;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.ai.ComputerUtil;
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
@@ -352,10 +352,7 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
|||||||
public void resolve() {
|
public void resolve() {
|
||||||
final GameState game = Singletons.getModel().getGame();
|
final GameState game = Singletons.getModel().getGame();
|
||||||
if (!(regtrig instanceof TriggerAlways)) {
|
if (!(regtrig instanceof TriggerAlways)) {
|
||||||
// State triggers
|
// State triggers don't have "Intervening If"
|
||||||
// don't do the whole
|
|
||||||
// "Intervening If"
|
|
||||||
// thing.
|
|
||||||
if (!regtrig.requirementsCheck()) {
|
if (!regtrig.requirementsCheck()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -390,20 +387,23 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
|||||||
//TODO: The only card with an optional delayed trigger is Shirei, Shizo's Caretaker,
|
//TODO: The only card with an optional delayed trigger is Shirei, Shizo's Caretaker,
|
||||||
// needs to be expanded when a more difficult cards comes up
|
// needs to be expanded when a more difficult cards comes up
|
||||||
} else {
|
} else {
|
||||||
ArrayList<Object> tgts = null;
|
// Store/replace target choices more properly to get this SA cleared.
|
||||||
// make sure the targets won't change
|
Target tgt = sa.getTarget();
|
||||||
if (sa.getTarget() != null && sa.getTarget().getTargetChoices() != null) {
|
TargetChoices tc = null;
|
||||||
tgts = new ArrayList<Object>(sa.getTarget().getTargetChoices().getTargets());
|
boolean storeChoices = tgt != null && tgt.getTargetChoices() != null;
|
||||||
|
|
||||||
|
if (storeChoices) {
|
||||||
|
tc = tgt.getTargetChoices();
|
||||||
|
tgt.resetTargets();
|
||||||
}
|
}
|
||||||
// This isn't quite right, but better than canPlayAI
|
// There is no way this doTrigger here will have the same target as stored above
|
||||||
|
// So it's possible it's making a different decision here than will actually happen
|
||||||
if (!sa.doTrigger(this.isMandatory(), (AIPlayer) decider)) {
|
if (!sa.doTrigger(this.isMandatory(), (AIPlayer) decider)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sa.getTarget() != null && sa.getTarget().getTargetChoices() != null) {
|
if (storeChoices) {
|
||||||
for (Object tgt : tgts) {
|
tgt.resetTargets();
|
||||||
sa.getTarget().getTargetChoices().clear();
|
tgt.setTargetChoices(tc);
|
||||||
sa.getTarget().getTargetChoices().addTarget(tgt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -594,8 +594,8 @@ public class MagicStack extends MyObservable {
|
|||||||
|
|
||||||
// The SpellAbility isn't removed from the Stack until it finishes resolving
|
// The SpellAbility isn't removed from the Stack until it finishes resolving
|
||||||
// temporarily reverted removing SAs after resolution
|
// temporarily reverted removing SAs after resolution
|
||||||
//final SpellAbility sa = this.top();
|
final SpellAbility sa = this.top();
|
||||||
final SpellAbility sa = this.pop();
|
//final SpellAbility sa = this.pop();
|
||||||
|
|
||||||
// ActivePlayer gains priority first after Resolve
|
// ActivePlayer gains priority first after Resolve
|
||||||
game.getPhaseHandler().resetPriority();
|
game.getPhaseHandler().resetPriority();
|
||||||
@@ -727,7 +727,7 @@ public class MagicStack extends MyObservable {
|
|||||||
this.removeCardFromStack(sa, fizzle);
|
this.removeCardFromStack(sa, fizzle);
|
||||||
// SpellAbility is removed from the stack here
|
// SpellAbility is removed from the stack here
|
||||||
// temporarily removed removing SA after resolution
|
// temporarily removed removing SA after resolution
|
||||||
//this.remove(sa);
|
this.remove(sa);
|
||||||
|
|
||||||
// After SA resolves we have to do a handful of things
|
// After SA resolves we have to do a handful of things
|
||||||
this.setResolving(false);
|
this.setResolving(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user