Skip to content

Commit

Permalink
- Add a function that can be used to build Convoke, Improvise, Delve …
Browse files Browse the repository at this point in the history
…functions for the AI (currently not hooked to anything)
  • Loading branch information
Agetian authored and Hanmac committed Feb 20, 2021
1 parent c75cab4 commit 4f77dfc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions forge-ai/src/main/java/forge/ai/ComputerUtilMana.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import forge.game.card.*;
import forge.game.combat.CombatUtil;
import forge.game.cost.*;
import forge.game.keyword.Keyword;
import forge.game.mana.Mana;
import forge.game.mana.ManaCostBeingPaid;
import forge.game.mana.ManaPool;
Expand Down Expand Up @@ -1806,6 +1807,34 @@ public static List<SpellAbility> getAIPlayableMana(Card c) {
return res;
}

// Convoke, Delve, Improvise
public static List<SpellAbility> getAIPlayableSpecialAbilities(Card card, Player ai, SpellAbility saPaidFor, ManaCostBeingPaid manaCost) {
List<SpellAbility> result = new ArrayList<>();
if (saPaidFor.isSpell()) {
Collection<SpellAbility> specialAbilities = Lists.newArrayList();
if (card.isInPlay() && card.isUntapped()) {
if (saPaidFor.getHostCard().hasKeyword(Keyword.CONVOKE) && card.isCreature()) {
specialAbilities.addAll(CardFactoryUtil.buildConvokeAbility(card, manaCost, saPaidFor));
}

if (saPaidFor.getHostCard().hasKeyword(Keyword.IMPROVISE) && card.isArtifact()) {
specialAbilities.add(CardFactoryUtil.buildImproviseAbility(card, manaCost, saPaidFor));
}
}
if (card.isInZone(ZoneType.Graveyard)) {
if (saPaidFor.getHostCard().hasKeyword(Keyword.DELVE)) {
specialAbilities.add(CardFactoryUtil.buildDelveAbility(card, manaCost, saPaidFor));
}
}
// set the activating player
for (final SpellAbility sa : specialAbilities) {
sa.setActivatingPlayer(ai);
result.add(sa);
}
}
return result;
}

private static void handleOfferingsAI(final SpellAbility sa, boolean test, boolean costIsPaid) {
if (sa.isOffering() && sa.getSacrificedAsOffering() != null) {
final Card offering = sa.getSacrificedAsOffering();
Expand Down

1 comment on commit 4f77dfc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[stale:convokeImproviseDelve]

@Agetian Your branch convokeImproviseDelve hasn't been updated in the last 90 days and is marked as stale. It will be removed in a 7 days.
If you want to keep this branch around, add new commits to this branch or protect it.

Please sign in to comment.