mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
*Made AI at least semiconscious of blocking commanders
This commit is contained in:
@@ -41,6 +41,7 @@ import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameType;
|
||||
import forge.game.GlobalRuleChange;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
@@ -287,6 +288,30 @@ public class ComputerUtilCombat {
|
||||
|
||||
return ai.getPoisonCounters() + poison;
|
||||
}
|
||||
|
||||
public static List<Card> getLifeThreateningCommanders(final Player ai, final Combat combat) {
|
||||
List<Card> res = new ArrayList<Card>();
|
||||
|
||||
if(ai.getGame().getType() == GameType.Commander) {
|
||||
for(Card c : combat.getAttackers()) {
|
||||
if(c.isCommander()) {
|
||||
int cmdDmg = ai.getCommanderDamage().containsKey(c) ? ai.getCommanderDamage().get(c) : 0;
|
||||
|
||||
if(c.hasKeyword("Trample")) {
|
||||
for(Card blocker : combat.getBlockers(c)) {
|
||||
cmdDmg -= blocker.getCurrentToughness();
|
||||
}
|
||||
}
|
||||
|
||||
if(cmdDmg >= 21) {
|
||||
res.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Checks if the life of the attacked Player/Planeswalker is in danger
|
||||
/**
|
||||
@@ -376,6 +401,8 @@ public class ComputerUtilCombat {
|
||||
if (ai.cantLose()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<Card> deadlyCommanders = ComputerUtilCombat.getLifeThreateningCommanders(ai, combat);
|
||||
|
||||
// check for creatures that must be blocked
|
||||
final List<Card> attackers = combat.getAttackersOf(ai);
|
||||
@@ -385,7 +412,7 @@ public class ComputerUtilCombat {
|
||||
final List<Card> blockers = combat.getBlockers(attacker);
|
||||
|
||||
if (blockers.size() == 0) {
|
||||
if (!attacker.getSVar("MustBeBlocked").equals("")) {
|
||||
if (!attacker.getSVar("MustBeBlocked").equals("") || deadlyCommanders.contains(attacker)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user