mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
*For some reason I thought the commander blocking hadn't been committed. Removing duplicate code.
This commit is contained in:
@@ -292,29 +292,27 @@ public class ComputerUtilCombat {
|
||||
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.isCommander())
|
||||
{
|
||||
List<Card> blockers = combat.getBlockers(c);
|
||||
int possibleCommanderDamage = c.getCurrentPower();
|
||||
int currentCommanderDamage = ai.getCommanderDamage().containsKey(c) ? ai.getCommanderDamage().get(c) : 0;
|
||||
if(blockers.size() > 0) {
|
||||
if(c.getKeyword().contains("Trample")) {
|
||||
for(Card b : blockers) {
|
||||
possibleCommanderDamage -= b.getCurrentToughness();
|
||||
}
|
||||
}
|
||||
else {
|
||||
possibleCommanderDamage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(c.hasKeyword("Trample")) {
|
||||
for(Card blocker : combat.getBlockers(c)) {
|
||||
cmdDmg -= blocker.getCurrentToughness();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(combat.getBlockers(c).size() == 0)
|
||||
{
|
||||
cmdDmg += c.getCurrentPower();
|
||||
}
|
||||
}
|
||||
if(cmdDmg >= 21) {
|
||||
if(possibleCommanderDamage + currentCommanderDamage >= 21)
|
||||
res.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -338,34 +336,20 @@ public class ComputerUtilCombat {
|
||||
// check for creatures that must be blocked
|
||||
final List<Card> attackers = combat.getAttackersOf(ai);
|
||||
|
||||
final List<Card> threateningCommanders = getLifeThreateningCommanders(ai,combat);
|
||||
|
||||
for (final Card attacker : attackers) {
|
||||
|
||||
final List<Card> blockers = combat.getBlockers(attacker);
|
||||
|
||||
if(attacker.isCommander())
|
||||
{
|
||||
int possibleCommanderDamage = attacker.getCurrentPower();
|
||||
int currentCommanderDamage = ai.getCommanderDamage().containsKey(attacker) ? ai.getCommanderDamage().get(attacker) : 0;
|
||||
if(blockers.size() > 0) {
|
||||
if(attacker.getKeyword().contains("Trample")) {
|
||||
for(Card b : blockers) {
|
||||
possibleCommanderDamage -= b.getCurrentToughness();
|
||||
}
|
||||
}
|
||||
else {
|
||||
possibleCommanderDamage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(possibleCommanderDamage + currentCommanderDamage >= 21)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (blockers.size() == 0) {
|
||||
if (!attacker.getSVar("MustBeBlocked").equals("")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (threateningCommanders.contains(attacker)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) < Math.min(4, ai.getLife())
|
||||
@@ -408,7 +392,7 @@ public class ComputerUtilCombat {
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<Card> deadlyCommanders = ComputerUtilCombat.getLifeThreateningCommanders(ai, combat);
|
||||
final List<Card> threateningCommanders = ComputerUtilCombat.getLifeThreateningCommanders(ai, combat);
|
||||
|
||||
// check for creatures that must be blocked
|
||||
final List<Card> attackers = combat.getAttackersOf(ai);
|
||||
@@ -418,10 +402,13 @@ public class ComputerUtilCombat {
|
||||
final List<Card> blockers = combat.getBlockers(attacker);
|
||||
|
||||
if (blockers.size() == 0) {
|
||||
if (!attacker.getSVar("MustBeBlocked").equals("") || deadlyCommanders.contains(attacker)) {
|
||||
if (!attacker.getSVar("MustBeBlocked").equals("")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(threateningCommanders.contains(attacker)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) < 1 && !ai.cantLoseForZeroOrLessLife()) {
|
||||
|
||||
Reference in New Issue
Block a user