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 @Override
public PaymentDecision visit(final CostEnlist cost) { public PaymentDecision visit(final CostEnlist cost) {
// currently unused CardCollection choices = cost.getCardsForEnlisting(player, source, ability);
return null; CardLists.sortByPowerDesc(choices);
return PaymentDecision.card(choices.getFirst());
} }
@Override @Override

View File

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

View File

@@ -101,7 +101,7 @@ public class CostEnlist extends CostPartWithTrigger {
return visitor.visit(this); 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); return CardLists.getValidCards(active.getCardsIn(ZoneType.Battlefield), "Creature.notattacking+untapped+!sick", active, source, paySA);
} }