mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- 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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user