mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38: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.TriggerHandler;
|
||||||
import forge.card.trigger.TriggerType;
|
import forge.card.trigger.TriggerType;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
|
import forge.game.GameType;
|
||||||
import forge.game.GlobalRuleChange;
|
import forge.game.GlobalRuleChange;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
import forge.game.combat.CombatUtil;
|
import forge.game.combat.CombatUtil;
|
||||||
@@ -288,6 +289,30 @@ public class ComputerUtilCombat {
|
|||||||
return ai.getPoisonCounters() + poison;
|
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
|
// Checks if the life of the attacked Player/Planeswalker is in danger
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -377,6 +402,8 @@ public class ComputerUtilCombat {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final List<Card> deadlyCommanders = ComputerUtilCombat.getLifeThreateningCommanders(ai, combat);
|
||||||
|
|
||||||
// check for creatures that must be blocked
|
// check for creatures that must be blocked
|
||||||
final List<Card> attackers = combat.getAttackersOf(ai);
|
final List<Card> attackers = combat.getAttackersOf(ai);
|
||||||
|
|
||||||
@@ -385,7 +412,7 @@ public class ComputerUtilCombat {
|
|||||||
final List<Card> blockers = combat.getBlockers(attacker);
|
final List<Card> blockers = combat.getBlockers(attacker);
|
||||||
|
|
||||||
if (blockers.size() == 0) {
|
if (blockers.size() == 0) {
|
||||||
if (!attacker.getSVar("MustBeBlocked").equals("")) {
|
if (!attacker.getSVar("MustBeBlocked").equals("") || deadlyCommanders.contains(attacker)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user