mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Add basic AI
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user