mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
GoadAi: improve targeting for triggers
This commit is contained in:
@@ -1318,7 +1318,6 @@ public class AiBlockController {
|
||||
}
|
||||
|
||||
int evalAtk = ComputerUtilCard.evaluateCreature(attacker, true, false);
|
||||
int evalBlk = ComputerUtilCard.evaluateCreature(blocker, true, false);
|
||||
boolean atkEmbalm = (attacker.hasStartOfKeyword("Embalm") || attacker.hasStartOfKeyword("Eternalize")) && !attacker.isToken();
|
||||
boolean blkEmbalm = (blocker.hasStartOfKeyword("Embalm") || blocker.hasStartOfKeyword("Eternalize")) && !blocker.isToken();
|
||||
|
||||
@@ -1327,10 +1326,13 @@ public class AiBlockController {
|
||||
chance = Math.max(0, chance - chanceModForEmbalm);
|
||||
}
|
||||
|
||||
if (blocker.isFaceDown() && !checkingOther && blocker.getState(CardStateName.Original).getType().isCreature()) {
|
||||
int evalBlk;
|
||||
if (blocker.isFaceDown() && blocker.getView().canFaceDownBeShownTo(ai.getView(), false) && blocker.getState(CardStateName.Original).getType().isCreature()) {
|
||||
// if the blocker is a face-down creature (e.g. cast via Morph, Manifest), evaluate it
|
||||
// in relation to the original state, not to the Morph state
|
||||
evalBlk = ComputerUtilCard.evaluateCreature(Card.fromPaperCard(blocker.getPaperCard(), ai), false, true);
|
||||
} else {
|
||||
evalBlk = ComputerUtilCard.evaluateCreature(blocker, true, false);
|
||||
}
|
||||
int chanceToSavePW = chanceToTradeDownToSaveWalker > 0 && evalAtk + 1 < evalBlk ? chanceToTradeDownToSaveWalker : chanceToTradeToSaveWalker;
|
||||
boolean powerParityOrHigher = blocker.getNetPower() <= attacker.getNetPower();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GoadAi extends SpellAbilityAi {
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
if (game.getPlayers().size() >= 2) {
|
||||
if (game.getPlayers().size() > 2) {
|
||||
// use this part only in multiplayer
|
||||
CardCollection betterList = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
@@ -79,10 +79,43 @@ public class GoadAi extends SpellAbilityAi {
|
||||
|
||||
// AI does not find a good creature to goad.
|
||||
// because if it would goad a creature it would attack AI.
|
||||
// AI might not have enough infomation to block it
|
||||
// AI might not have enough information to block it
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
if (checkApiLogic(ai, sa)) {
|
||||
return true;
|
||||
}
|
||||
if (!mandatory) {
|
||||
return false;
|
||||
}
|
||||
if (sa.usesTargeting()) {
|
||||
if (sa.getTargetRestrictions().canTgtPlayer()) {
|
||||
for (Player opp : ai.getOpponents()) {
|
||||
if (sa.canTarget(opp)) {
|
||||
sa.getTargets().add(opp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (sa.canTarget(ai)) {
|
||||
sa.getTargets().add(ai);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
List<Card> list = CardLists.getTargetableCards(ai.getGame().getCardsIn(ZoneType.Battlefield), sa);
|
||||
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
sa.getTargets().add(ComputerUtilCard.getWorstCreatureAI(list));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ public class CardView extends GameEntityView {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean canFaceDownBeShownTo(final PlayerView viewer, boolean skip) {
|
||||
public boolean canFaceDownBeShownTo(final PlayerView viewer, boolean skip) {
|
||||
if (!isFaceDown()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user