- AI support for "deal damage equal to power". Tweak to sort "fight" list by card efficiency instead of power/cmc.

This commit is contained in:
excessum
2014-03-23 06:56:24 +00:00
parent 6e1c19f660
commit a7b8410f25
8 changed files with 53 additions and 40 deletions

View File

@@ -103,11 +103,11 @@ public class CountersPutAi extends SpellAbilityAi {
List<Card> aiCreatures = ai.getCreaturesInPlay();
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
aiCreatures = ComputerUtil.getSafeTargets(ai, sa, aiCreatures);
CardLists.sortByPowerDesc(aiCreatures);
ComputerUtilCard.sortByEvaluateCreature(aiCreatures);
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
humCreatures = CardLists.getTargetableCards(humCreatures, tgtFight);
CardLists.sortByCmcDesc(humCreatures);
ComputerUtilCard.sortByEvaluateCreature(humCreatures);
if (humCreatures.isEmpty() || aiCreatures.isEmpty()) {
return false;
}

View File

@@ -238,6 +238,13 @@ public class DamageDealAi extends DamageAiBase {
final boolean divided = sa.hasParam("DividedAsYouChoose");
final boolean oppTargetsChoice = sa.hasParam("TargetingPlayer");
if ("PowerDmg".equals(sa.getParam("AILogic"))) {
if (tgt.canTgtCreatureAndPlayer() && this.shouldTgtP(ai, sa, dmg, noPrevention)){
sa.resetTargets();
sa.getTargets().add(ai.getOpponent());
}
return true;
}
// target loop
sa.resetTargets();
TargetChoices tcs = sa.getTargets();

View File

@@ -126,13 +126,13 @@ public class EffectAi extends SpellAbilityAi {
} else if (logic.equals("Fight")) {
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
humCreatures = CardLists.getTargetableCards(humCreatures, sa);
CardLists.sortByCmcDesc(humCreatures);
ComputerUtilCard.sortByEvaluateCreature(humCreatures);
final AbilitySub tgtFight = sa.getSubAbility();
List<Card> aiCreatures = ai.getCreaturesInPlay();
aiCreatures = CardLists.getTargetableCards(aiCreatures, tgtFight);
aiCreatures = ComputerUtil.getSafeTargets(ai, tgtFight, aiCreatures);
CardLists.sortByPowerDesc(aiCreatures);
ComputerUtilCard.sortByEvaluateCreature(aiCreatures);
if (humCreatures.isEmpty() || aiCreatures.isEmpty()) {
return false;

View File

@@ -213,25 +213,38 @@ public class PumpAi extends PumpAiBase {
return false;
}
}
if (sa.getParam("AILogic").equals("Fight")) {
if (sa.getParam("AILogic").equals("Fight") || sa.getParam("AILogic").equals("PowerDmg")) {
final AbilitySub tgtFight = sa.getSubAbility();
List<Card> aiCreatures = ai.getCreaturesInPlay();
aiCreatures = CardLists.getTargetableCards(aiCreatures, sa);
aiCreatures = ComputerUtil.getSafeTargets(ai, sa, aiCreatures);
CardLists.sortByPowerDesc(aiCreatures);
ComputerUtilCard.sortByEvaluateCreature(aiCreatures);
//sort is suboptimal due to conflicting needs depending on game state:
// -deathtouch for deal damage
// -max power for damage to player
// -survivability for generic "fight"
// -no support for "heroic"
List<Card> humCreatures = ai.getOpponent().getCreaturesInPlay();
humCreatures = CardLists.getTargetableCards(humCreatures, tgtFight);
CardLists.sortByCmcDesc(humCreatures);
ComputerUtilCard.sortByEvaluateCreature(humCreatures);
if (humCreatures.isEmpty() || aiCreatures.isEmpty()) {
return false;
}
for (Card humanCreature : humCreatures) {
for (Card aiCreature : aiCreatures) {
if (FightAi.shouldFight(aiCreature, humanCreature, attack, defense)) {
sa.getTargets().add(aiCreature);
tgtFight.getTargets().add(humanCreature);
return true;
if (sa.getParam("AILogic").equals("PowerDmg")) {
if (FightAi.canKill(aiCreature, humanCreature, attack)) {
sa.getTargets().add(aiCreature);
tgtFight.getTargets().add(humanCreature);
return true;
}
} else {
if (FightAi.shouldFight(aiCreature, humanCreature, attack, defense)) {
sa.getTargets().add(aiCreature);
tgtFight.getTargets().add(humanCreature);
return true;
}
}
}
}