From cffef2e479d923db4ed0d0aed987caccbe7ead17 Mon Sep 17 00:00:00 2001 From: Michael Kamensky Date: Fri, 19 Feb 2021 14:23:28 +0300 Subject: [PATCH 1/3] - A simple logic to enable Ultimate for Oko, the Trickster for the AI (to be improved). --- .../src/main/java/forge/ai/ability/AnimateAllAi.java | 10 ++++++++-- forge-gui/res/cardsfolder/o/oko_the_trickster.txt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java index 79770568fd3..a1b827ff5d6 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java @@ -8,12 +8,18 @@ public class AnimateAllAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { - return "Always".equals(sa.getParam("AILogic")); + String logic = sa.getParamOrDefault("AILogic", ""); + + if ("NeedsCreature".equals(logic)) { + return !aiPlayer.getCreaturesInPlay().isEmpty(); + } + + return "Always".equals(logic); } // end animateAllCanPlayAI() @Override protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) { - return mandatory; + return mandatory || canPlayAI(aiPlayer, sa); } } // end class AbilityFactoryAnimate diff --git a/forge-gui/res/cardsfolder/o/oko_the_trickster.txt b/forge-gui/res/cardsfolder/o/oko_the_trickster.txt index 704de78a3e1..cc645af1e10 100644 --- a/forge-gui/res/cardsfolder/o/oko_the_trickster.txt +++ b/forge-gui/res/cardsfolder/o/oko_the_trickster.txt @@ -5,6 +5,6 @@ Loyalty:4 A:AB$ PutCounter | Cost$ AddCounter<1/LOYALTY> | Planeswalker$ True | TargetMin$ 0 | TargetMax$ 1 | CounterType$ P1P1 | CounterNum$ 2 | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | SpellDescription$ Put two +1/+1 counters on up to one target creature you control. A:AB$ Clone | Cost$ AddCounter<0/LOYALTY> | ValidTgts$ Creature.YouCtrl | Planeswalker$ True | TgtPrompt$ Select target creature you control | Duration$ UntilEndOfTurn | SubAbility$ DBPrevent | StackDescription$ SpellDescription | SpellDescription$ Until end of turn, CARDNAME becomes a copy of target creature you control. Prevent all damage that would be dealt to him this turn. SVar:DBPrevent:DB$ Pump | Defined$ Self | KW$ Prevent all damage that would be dealt to CARDNAME. -A:AB$ AnimateAll | Cost$ SubCounter<7/LOYALTY> | Planeswalker$ True | Ultimate$ True | ValidCards$ Creature.YouCtrl | Power$ 10 | Toughness$ 10 | Keywords$ Trample | SpellDescription$ Until end of turn, each creature you control has base power and toughness 10/10 and gains trample. +A:AB$ AnimateAll | Cost$ SubCounter<7/LOYALTY> | Planeswalker$ True | Ultimate$ True | ValidCards$ Creature.YouCtrl | Power$ 10 | Toughness$ 10 | Keywords$ Trample | AILogic$ NeedsCreature | SpellDescription$ Until end of turn, each creature you control has base power and toughness 10/10 and gains trample. DeckHas:Ability$Counters Oracle:[+1]: Put two +1/+1 counters on up to one target creature you control.\n[0]: Until end of turn, Oko, the Trickster becomes a copy of target creature you control. Prevent all damage that would be dealt to him this turn.\n[−7]: Until end of turn, each creature you control has base power and toughness 10/10 and gains trample. From c519600629d3a85cf6915fcda7621d917c66ab3d Mon Sep 17 00:00:00 2001 From: Michael Kamensky Date: Fri, 19 Feb 2021 14:35:37 +0300 Subject: [PATCH 2/3] - A somewhat more generally applicable logic. --- .../src/main/java/forge/ai/ability/AnimateAllAi.java | 12 ++++++++++-- forge-gui/res/cardsfolder/o/oko_the_trickster.txt | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java index a1b827ff5d6..2724f8f2094 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java @@ -1,6 +1,9 @@ package forge.ai.ability; +import forge.ai.ComputerUtilCard; +import forge.ai.ComputerUtilCombat; import forge.ai.SpellAbilityAi; +import forge.game.card.Card; import forge.game.player.Player; import forge.game.spellability.SpellAbility; @@ -10,8 +13,13 @@ public class AnimateAllAi extends SpellAbilityAi { protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { String logic = sa.getParamOrDefault("AILogic", ""); - if ("NeedsCreature".equals(logic)) { - return !aiPlayer.getCreaturesInPlay().isEmpty(); + if ("CreatureAdvantage".equals(logic) && !aiPlayer.getCreaturesInPlay().isEmpty()) { + // TODO: improve this or implement a better logic for abilities like Oko, the Trickster ultimate + for (Card c : aiPlayer.getCreaturesInPlay()) { + if (ComputerUtilCard.doesCreatureAttackAI(aiPlayer, c)) { + return true; + } + } } return "Always".equals(logic); diff --git a/forge-gui/res/cardsfolder/o/oko_the_trickster.txt b/forge-gui/res/cardsfolder/o/oko_the_trickster.txt index cc645af1e10..f1a7c0d97fc 100644 --- a/forge-gui/res/cardsfolder/o/oko_the_trickster.txt +++ b/forge-gui/res/cardsfolder/o/oko_the_trickster.txt @@ -5,6 +5,6 @@ Loyalty:4 A:AB$ PutCounter | Cost$ AddCounter<1/LOYALTY> | Planeswalker$ True | TargetMin$ 0 | TargetMax$ 1 | CounterType$ P1P1 | CounterNum$ 2 | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | SpellDescription$ Put two +1/+1 counters on up to one target creature you control. A:AB$ Clone | Cost$ AddCounter<0/LOYALTY> | ValidTgts$ Creature.YouCtrl | Planeswalker$ True | TgtPrompt$ Select target creature you control | Duration$ UntilEndOfTurn | SubAbility$ DBPrevent | StackDescription$ SpellDescription | SpellDescription$ Until end of turn, CARDNAME becomes a copy of target creature you control. Prevent all damage that would be dealt to him this turn. SVar:DBPrevent:DB$ Pump | Defined$ Self | KW$ Prevent all damage that would be dealt to CARDNAME. -A:AB$ AnimateAll | Cost$ SubCounter<7/LOYALTY> | Planeswalker$ True | Ultimate$ True | ValidCards$ Creature.YouCtrl | Power$ 10 | Toughness$ 10 | Keywords$ Trample | AILogic$ NeedsCreature | SpellDescription$ Until end of turn, each creature you control has base power and toughness 10/10 and gains trample. +A:AB$ AnimateAll | Cost$ SubCounter<7/LOYALTY> | Planeswalker$ True | Ultimate$ True | ValidCards$ Creature.YouCtrl | Power$ 10 | Toughness$ 10 | Keywords$ Trample | AILogic$ CreatureAdvantage | SpellDescription$ Until end of turn, each creature you control has base power and toughness 10/10 and gains trample. DeckHas:Ability$Counters Oracle:[+1]: Put two +1/+1 counters on up to one target creature you control.\n[0]: Until end of turn, Oko, the Trickster becomes a copy of target creature you control. Prevent all damage that would be dealt to him this turn.\n[−7]: Until end of turn, each creature you control has base power and toughness 10/10 and gains trample. From b9c9357d94ae385a83e0facdb46208f0e13f4af4 Mon Sep 17 00:00:00 2001 From: Michael Kamensky Date: Fri, 19 Feb 2021 14:37:26 +0300 Subject: [PATCH 3/3] - Clean up imports. --- forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java | 1 - 1 file changed, 1 deletion(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java index 2724f8f2094..7bdc43f40ce 100644 --- a/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/AnimateAllAi.java @@ -1,7 +1,6 @@ package forge.ai.ability; import forge.ai.ComputerUtilCard; -import forge.ai.ComputerUtilCombat; import forge.ai.SpellAbilityAi; import forge.game.card.Card; import forge.game.player.Player;