Add basic AI

This commit is contained in:
tool4EvEr
2023-01-25 22:47:13 +01:00
parent 29debff0ce
commit 616309c22f
3 changed files with 11 additions and 6 deletions

View File

@@ -240,8 +240,9 @@ public class AiCostDecision extends CostDecisionMakerBase {
@Override
public PaymentDecision visit(final CostEnlist cost) {
// currently unused
return null;
CardCollection choices = cost.getCardsForEnlisting(player, source, ability);
CardLists.sortByPowerDesc(choices);
return PaymentDecision.card(choices.getFirst());
}
@Override

View File

@@ -43,6 +43,7 @@ import forge.game.card.CardView;
import forge.game.card.CounterType;
import forge.game.combat.Combat;
import forge.game.cost.Cost;
import forge.game.cost.CostEnlist;
import forge.game.cost.CostPart;
import forge.game.cost.CostPartMana;
import forge.game.keyword.KeywordInterface;
@@ -340,9 +341,12 @@ public class PlayerControllerAi extends PlayerController {
@Override
public List<Card> enlistAttackers(List<Card> attackers) {
// not able yet
// TODO get best creature that can't attack and check for lethal with it
return Lists.newArrayList();
CardCollection cards = CostEnlist.getCardsForEnlisting(brains.getPlayer(), null, null);
ComputerUtilCard.sortByEvaluateCreature(new CardCollection(attackers));
// do not enlist more than available payment choices
attackers = attackers.subList(0, cards.size());
// TODO check if not needed as defender
return attackers;
}
@Override

View File

@@ -101,7 +101,7 @@ public class CostEnlist extends CostPartWithTrigger {
return visitor.visit(this);
}
public CardCollection getCardsForEnlisting(Player active, Card source, SpellAbility paySA) {
public static CardCollection getCardsForEnlisting(Player active, Card source, SpellAbility paySA) {
return CardLists.getValidCards(active.getCardsIn(ZoneType.Battlefield), "Creature.notattacking+untapped+!sick", active, source, paySA);
}