mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Improved AI anticipating abilities granting Deathtouch.
This commit is contained in:
@@ -1587,8 +1587,7 @@ public class ComputerUtilCombat {
|
|||||||
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, defender, combat, withoutAbilities);
|
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, defender, combat, withoutAbilities);
|
||||||
|
|
||||||
if (defender.hasKeyword("Double Strike")) {
|
if (defender.hasKeyword("Double Strike")) {
|
||||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
if (defenderDamage > 0 && (canGainKeyword(defender, "Deathtouch") || attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (defenderDamage >= attackerLife) {
|
if (defenderDamage >= attackerLife) {
|
||||||
@@ -1601,8 +1600,7 @@ public class ComputerUtilCombat {
|
|||||||
if (attackerDamage >= defenderLife) {
|
if (attackerDamage >= defenderLife) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
if (attackerDamage > 0 && (canGainKeyword(attacker, "Deathtouch") || defender.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1620,14 +1618,12 @@ public class ComputerUtilCombat {
|
|||||||
if (attackerDamage >= defenderLife) {
|
if (attackerDamage >= defenderLife) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
if (attackerDamage > 0 && (canGainKeyword(attacker, "Deathtouch") || defender.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
if (defenderDamage > 0 && (canGainKeyword(defender, "Deathtouch") || attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1744,8 +1740,7 @@ public class ComputerUtilCombat {
|
|||||||
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, defender, combat, withoutAbilities);
|
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, defender, combat, withoutAbilities);
|
||||||
|
|
||||||
if (attacker.hasKeyword("Double Strike")) {
|
if (attacker.hasKeyword("Double Strike")) {
|
||||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
if (attackerDamage > 0 && (canGainKeyword(attacker, "Deathtouch") || defender.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (attackerDamage >= defenderLife) {
|
if (attackerDamage >= defenderLife) {
|
||||||
@@ -1758,8 +1753,7 @@ public class ComputerUtilCombat {
|
|||||||
if (defenderDamage >= attackerLife) {
|
if (defenderDamage >= attackerLife) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
if (defenderDamage > 0 && (canGainKeyword(defender, "Deathtouch") || attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1771,19 +1765,17 @@ public class ComputerUtilCombat {
|
|||||||
else { // no double strike for attacker
|
else { // no double strike for attacker
|
||||||
// Defender may kill the attacker before he can deal any damage
|
// Defender may kill the attacker before he can deal any damage
|
||||||
if (dealsFirstStrikeDamage(defender, withoutAbilities) && !attacker.hasKeyword("Indestructible")
|
if (dealsFirstStrikeDamage(defender, withoutAbilities) && !attacker.hasKeyword("Indestructible")
|
||||||
&& !attacker.hasKeyword("First Strike")) {
|
&& !dealsFirstStrikeDamage(attacker, withoutAbilities)) {
|
||||||
|
|
||||||
if (defenderDamage >= attackerLife) {
|
if (defenderDamage >= attackerLife) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (defenderDamage > 0 && (defender.hasKeyword("Deathtouch")
|
if (defenderDamage > 0 && (canGainKeyword(defender, "Deathtouch") || attacker.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| attacker.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attackerDamage > 0 && (attacker.hasKeyword("Deathtouch")
|
if (attackerDamage > 0 && (canGainKeyword(attacker, "Deathtouch") || defender.hasSVar("DestroyWhenDamaged"))) {
|
||||||
|| defender.hasSVar("DestroyWhenDamaged"))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2103,6 +2095,16 @@ public class ComputerUtilCombat {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final static boolean canGainKeyword(final Card combatant, final String keyword) {
|
||||||
|
if (combatant.hasKeyword(keyword)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> keywords = new ArrayList<String>();
|
||||||
|
keywords.add(keyword);
|
||||||
|
return canGainKeyword(combatant, keywords);
|
||||||
|
}
|
||||||
|
|
||||||
public final static boolean canGainKeyword(final Card combatant, final List<String> keywords) {
|
public final static boolean canGainKeyword(final Card combatant, final List<String> keywords) {
|
||||||
for (SpellAbility ability : combatant.getAllSpellAbilities()) {
|
for (SpellAbility ability : combatant.getAllSpellAbilities()) {
|
||||||
if (!(ability instanceof AbilityActivated) || ability.getPayCosts() == null) {
|
if (!(ability instanceof AbilityActivated) || ability.getPayCosts() == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user