mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Added Volrath's Shapeshifter with rudimentary, simple AI support.
- Was tested in most typical circumstances, including cloning it. However, may not yet be perfect in some corner cases. Improvements are welcome.
This commit is contained in:
@@ -843,6 +843,10 @@ public class AiController {
|
||||
}
|
||||
}
|
||||
|
||||
if ("VolrathsShapeshifter".equals(sa.getParam("AILogic"))) {
|
||||
return SpecialCardAi.VolrathsShapeshifter.targetBestCreature(player, sa);
|
||||
}
|
||||
|
||||
// look for good discards
|
||||
while (count < min) {
|
||||
Card prefCard = null;
|
||||
|
||||
@@ -281,6 +281,7 @@ public class SpecialCardAi {
|
||||
}
|
||||
}
|
||||
|
||||
// Guilty Conscience
|
||||
public static class GuiltyConscience {
|
||||
public static Card getBestAttachTarget(final Player ai, SpellAbility sa, List<Card> list) {
|
||||
Card chosen = null;
|
||||
@@ -586,7 +587,40 @@ public class SpecialCardAi {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Volrath's Shapeshifter
|
||||
public static class VolrathsShapeshifter {
|
||||
public static boolean consider(Player ai, SpellAbility sa) {
|
||||
CardCollectionView aiGY = ai.getCardsIn(ZoneType.Graveyard);
|
||||
Card topGY = null;
|
||||
Card creatHand = ComputerUtilCard.getBestCreatureAI(ai.getCardsIn(ZoneType.Hand));
|
||||
|
||||
if (aiGY.size() > 0) {
|
||||
topGY = ai.getCardsIn(ZoneType.Graveyard).get(0);
|
||||
}
|
||||
|
||||
if ((topGY != null && !topGY.isCreature()) || creatHand != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static CardCollection targetBestCreature(Player ai, SpellAbility sa) {
|
||||
Card creatHand = ComputerUtilCard.getBestCreatureAI(ai.getCardsIn(ZoneType.Hand));
|
||||
if (creatHand != null) {
|
||||
CardCollection cc = new CardCollection();
|
||||
cc.add(creatHand);
|
||||
return cc;
|
||||
}
|
||||
|
||||
// Should ideally never get here
|
||||
System.err.println("Volrath's Shapeshifter AI: Could not find a discard target despite the previous confirmation to proceed!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Ugin, the Spirit Dragon
|
||||
public static class UginTheSpiritDragon {
|
||||
public static boolean considerPWAbilityPriority(Player ai, SpellAbility sa, ZoneType origin, CardCollectionView oppType, CardCollectionView computerType) {
|
||||
Card source = sa.getHostCard();
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilAbility;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.ai.*;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
@@ -27,6 +23,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
final Card source = sa.getHostCard();
|
||||
final String sourceName = ComputerUtilAbility.getAbilitySourceName(sa);
|
||||
final Cost abCost = sa.getPayCosts();
|
||||
final String aiLogic = sa.getParamOrDefault("AILogic", "");
|
||||
|
||||
if (abCost != null) {
|
||||
// AI currently disabled for these costs
|
||||
@@ -53,6 +50,10 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
return MyRandom.getRandom().nextFloat() < (1.0 / (1 + hand));
|
||||
}
|
||||
|
||||
if (aiLogic.equals("VolrathsShapeshifter")) {
|
||||
return SpecialCardAi.VolrathsShapeshifter.consider(ai, sa);
|
||||
}
|
||||
|
||||
final boolean humanHasHand = ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Hand).size() > 0;
|
||||
|
||||
if (tgt != null) {
|
||||
|
||||
Reference in New Issue
Block a user