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,27 +292,25 @@ public class ComputerUtilCombat {
|
|||||||
public static List<Card> getLifeThreateningCommanders(final Player ai, final Combat combat) {
|
public static List<Card> getLifeThreateningCommanders(final Player ai, final Combat combat) {
|
||||||
List<Card> res = new ArrayList<Card>();
|
List<Card> res = new ArrayList<Card>();
|
||||||
|
|
||||||
if(ai.getGame().getType() == GameType.Commander) {
|
for(Card c : combat.getAttackers()) {
|
||||||
for(Card c : combat.getAttackers()) {
|
if(c.isCommander())
|
||||||
if(c.isCommander()) {
|
{
|
||||||
int cmdDmg = ai.getCommanderDamage().containsKey(c) ? ai.getCommanderDamage().get(c) : 0;
|
List<Card> blockers = combat.getBlockers(c);
|
||||||
|
int possibleCommanderDamage = c.getCurrentPower();
|
||||||
if(c.hasKeyword("Trample")) {
|
int currentCommanderDamage = ai.getCommanderDamage().containsKey(c) ? ai.getCommanderDamage().get(c) : 0;
|
||||||
for(Card blocker : combat.getBlockers(c)) {
|
if(blockers.size() > 0) {
|
||||||
cmdDmg -= blocker.getCurrentToughness();
|
if(c.getKeyword().contains("Trample")) {
|
||||||
|
for(Card b : blockers) {
|
||||||
|
possibleCommanderDamage -= b.getCurrentToughness();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
possibleCommanderDamage = 0;
|
||||||
if(combat.getBlockers(c).size() == 0)
|
|
||||||
{
|
|
||||||
cmdDmg += c.getCurrentPower();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(cmdDmg >= 21) {
|
|
||||||
res.add(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(possibleCommanderDamage + currentCommanderDamage >= 21)
|
||||||
|
res.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,35 +335,21 @@ public class ComputerUtilCombat {
|
|||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
|
final List<Card> threateningCommanders = getLifeThreateningCommanders(ai,combat);
|
||||||
|
|
||||||
for (final Card attacker : attackers) {
|
for (final Card attacker : attackers) {
|
||||||
|
|
||||||
final List<Card> blockers = combat.getBlockers(attacker);
|
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 (blockers.size() == 0) {
|
||||||
if (!attacker.getSVar("MustBeBlocked").equals("")) {
|
if (!attacker.getSVar("MustBeBlocked").equals("")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (threateningCommanders.contains(attacker)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) < Math.min(4, ai.getLife())
|
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) < Math.min(4, ai.getLife())
|
||||||
@@ -408,7 +392,7 @@ public class ComputerUtilCombat {
|
|||||||
return false;
|
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
|
// check for creatures that must be blocked
|
||||||
final List<Card> attackers = combat.getAttackersOf(ai);
|
final List<Card> attackers = combat.getAttackersOf(ai);
|
||||||
@@ -418,10 +402,13 @@ 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("") || deadlyCommanders.contains(attacker)) {
|
if (!attacker.getSVar("MustBeBlocked").equals("")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(threateningCommanders.contains(attacker)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) < 1 && !ai.cantLoseForZeroOrLessLife()) {
|
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) < 1 && !ai.cantLoseForZeroOrLessLife()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user