Skip to content

Commit c57a325

Browse files
Blackvipe99claude
andauthored
AI: don't reveal own top card when a conditional draw can't pay off
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent f3960f3 commit c57a325

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ protected AiAbilityDecision checkApiLogic(Player aiPlayer, SpellAbility sa) {
4848
return new AiAbilityDecision(0, AiPlayDecision.CantPlayAi);
4949
}
5050

51+
// if the AI may already look at its own top card (e.g. Iron Lad, Diverging Destiny),
52+
// don't activate when a sub-ability conditioned on the revealed card can't pay off
53+
if (libraryOwner == aiPlayer && !sa.isTrigger() && sa.hasParam("RememberRevealed")
54+
&& "1".equals(sa.getParamOrDefault("PeekAmount", "1"))) {
55+
final Card topCard = aiPlayer.getCardsIn(ZoneType.Library).getFirst();
56+
if (topCard.mayPlayerLook(aiPlayer)) {
57+
for (AbilitySub sub = sa.getSubAbility(); sub != null; sub = sub.getSubAbility()) {
58+
if ("Remembered".equals(sub.getParam("ConditionDefined")) && sub.hasParam("ConditionPresent")
59+
&& !topCard.isValid(sub.getParam("ConditionPresent").split(","), aiPlayer, sa.getHostCard(), sa)) {
60+
return new AiAbilityDecision(0, AiPlayDecision.CantPlayAi);
61+
}
62+
}
63+
}
64+
}
65+
5166
if ("X".equals(sa.getParam("PeekAmount")) && sa.getSVar("X").equals("Count$xPaid")) {
5267
int xPay = ComputerUtilCost.setMaxXValue(sa, aiPlayer, sa.isTrigger());
5368
if (xPay == 0) {

forge-gui/res/cardsfolder/i/iron_lad_diverging_destiny.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PT:2/2
55
K:Flying
66
K:Vigilance
77
S:Mode$ Continuous | Affected$ Card.TopLibrary+YouCtrl | AffectedZone$ Library | MayLookAt$ You | Description$ You may look at the top card of your library any time.
8-
A:AB$ PeekAndReveal | Cost$ T | NoPeek$ True | RememberRevealed$ True | SubAbility$ DBDraw | SpellDescription$ Reveal the top card of your library. If it's an artifact card, draw a card.
8+
A:AB$ PeekAndReveal | Cost$ T | NoPeek$ True | RememberRevealed$ True | AILogic$ Main2 | SubAbility$ DBDraw | SpellDescription$ Reveal the top card of your library. If it's an artifact card, draw a card.
99
SVar:DBDraw:DB$ Draw | ConditionDefined$ Remembered | ConditionPresent$ Artifact | SubAbility$ DBCleanup
1010
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
1111
Oracle:Flying, vigilance\nYou may look at the top card of your library any time.\n{T}: Reveal the top card of your library. If it's an artifact card, draw a card.

0 commit comments

Comments
 (0)