Skip to content

Commit ad51d74

Browse files
authored
AiPreference for SoulBond allowing Deadeye navigator to ignore tokens (#10473)
1 parent bbd9595 commit ad51d74

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

forge-ai/src/main/java/forge/ai/ability/BondAi.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import forge.game.card.Card;
2525
import forge.game.player.Player;
2626
import forge.game.spellability.SpellAbility;
27+
import org.apache.commons.lang3.StringUtils;
2728

2829
import java.util.Map;
30+
import java.util.stream.StreamSupport;
2931

3032
/**
3133
* <p>
@@ -54,7 +56,21 @@ protected AiAbilityDecision canPlay(Player aiPlayer, SpellAbility sa) {
5456

5557
@Override
5658
protected Card chooseSingleCard(Player ai, SpellAbility sa, Iterable<Card> options, boolean isOptional, Player targetedPlayer, Map<String, Object> params) {
57-
return ComputerUtilCard.getBestCreatureAI(options);
59+
final Card host = sa.getHostCard();
60+
Iterable<Card> candidates = options;
61+
if (host != null && host.hasSVar("AIPreference")) {
62+
String[] prefs = StringUtils.split(host.getSVar("AIPreference"), "$");
63+
if (prefs != null && prefs.length == 2 && "SoulBond".equals(prefs[0])) {
64+
String restriction = prefs[1];
65+
if (params.get("Partner") instanceof Card partner && !partner.isValid(restriction, ai, host, sa)) {
66+
return null;
67+
}
68+
candidates = StreamSupport.stream(options.spliterator(), false)
69+
.filter(c -> c.isValid(restriction, ai, host, sa))
70+
.toList();
71+
}
72+
}
73+
return ComputerUtilCard.getBestCreatureAI(candidates);
5874
}
5975

6076
@Override

forge-gui/res/cardsfolder/d/deadeye_navigator.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ K:Soulbond
66
S:Mode$ Continuous | Affected$ Creature.PairedWith,Card.Self+Paired | AddAbility$ DeadeyeFlicker | AddSVar$ DeadeyeReturn | Description$ As long as CARDNAME is paired with another creature, both creatures have "{1}{U}: Exile this creature, then return it to the battlefield under your control."
77
SVar:DeadeyeFlicker:AB$ ChangeZone | Cost$ 1 U | Defined$ Self | Origin$ Battlefield | Destination$ Exile | SubAbility$ DeadeyeReturn | RememberChanged$ True | ForgetOtherRemembered$ True | SpellDescription$ Exile this creature, then return it to the battlefield under your control.
88
SVar:DeadeyeReturn:DB$ ChangeZone | Defined$ Remembered | Origin$ All | Destination$ Battlefield | GainControl$ True
9+
SVar:AIPreference:SoulBond$Creature.!token
910
Oracle:Soulbond (You may pair this creature with another unpaired creature when either enters. They remain paired for as long as you control both of them.)\nAs long as Deadeye Navigator is paired with another creature, each of those creatures has "{1}{U}: Exile this creature, then return it to the battlefield under your control."

0 commit comments

Comments
 (0)