mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Some counter checks
This commit is contained in:
@@ -1741,6 +1741,10 @@ public class ComputerUtil {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c.getCounters(CounterEnumType.SHIELD) > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// already regenerated
|
||||
if (c.getShieldCount() > 0) {
|
||||
continue;
|
||||
@@ -1855,6 +1859,10 @@ public class ComputerUtil {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c.getCounters(CounterEnumType.SHIELD) > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// already regenerated
|
||||
if (c.getShieldCount() > 0) {
|
||||
continue;
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ComputerUtilCombat {
|
||||
// || (attacker.hasKeyword(Keyword.FADING) && attacker.getCounters(CounterEnumType.FADE) == 0)
|
||||
// || attacker.hasSVar("EndOfTurnLeavePlay"));
|
||||
// The creature won't untap next turn
|
||||
return !attacker.isTapped() || Untap.canUntap(attacker);
|
||||
return !attacker.isTapped() || (attacker.getCounters(CounterEnumType.STUN) == 0 && Untap.canUntap(attacker));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1628,9 +1628,8 @@ public class ComputerUtilCombat {
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean combatantCantBeDestroyed(Player ai, final Card combatant) {
|
||||
// either indestructible or may regenerate
|
||||
if (combatant.hasKeyword(Keyword.INDESTRUCTIBLE) || ComputerUtil.canRegenerate(ai, combatant)) {
|
||||
public static boolean combatantCantBeDestroyed(final Player ai, final Card combatant) {
|
||||
if (combatant.getCounters(CounterEnumType.SHIELD) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1639,6 +1638,11 @@ public class ComputerUtilCombat {
|
||||
return true;
|
||||
}
|
||||
|
||||
// either indestructible or may regenerate
|
||||
if (combatant.hasKeyword(Keyword.INDESTRUCTIBLE) || ComputerUtil.canRegenerate(ai, combatant)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2150,7 +2154,7 @@ public class ComputerUtilCombat {
|
||||
final boolean noPrevention) {
|
||||
final int killDamage = getDamageToKill(c, false);
|
||||
|
||||
if (c.hasKeyword(Keyword.INDESTRUCTIBLE) || c.getShieldCount() > 0) {
|
||||
if (c.hasKeyword(Keyword.INDESTRUCTIBLE) || c.getCounters(CounterEnumType.SHIELD) > 0 || (c.getShieldCount() > 0 && c.canBeShielded())) {
|
||||
if (!(source.hasKeyword(Keyword.WITHER) || source.hasKeyword(Keyword.INFECT))) {
|
||||
return maxDamage + 1;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import forge.ai.*;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -174,6 +175,8 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
list = ComputerUtilCard.prioritizeCreaturesWorthRemovingNow(ai, list, false);
|
||||
}
|
||||
if (!SpellAbilityAi.playReusable(ai, sa)) {
|
||||
list = CardLists.filter(list, Predicates.not(CardPredicates.hasCounter(CounterEnumType.SHIELD, 1)));
|
||||
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
@@ -196,7 +199,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
return false;
|
||||
}
|
||||
//Check for undying
|
||||
return (!c.hasKeyword(Keyword.UNDYING) || c.getCounters(CounterEnumType.P1P1) > 0);
|
||||
return !c.hasKeyword(Keyword.UNDYING) || c.getCounters(CounterEnumType.P1P1) > 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -333,6 +336,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
|
||||
CardCollection preferred = CardLists.getNotKeyword(list, Keyword.INDESTRUCTIBLE);
|
||||
preferred = CardLists.filterControlledBy(preferred, ai.getOpponents());
|
||||
preferred = CardLists.filter(preferred, Predicates.not(CardPredicates.hasCounter(CounterEnumType.SHIELD, 1)));
|
||||
if (CardLists.getNotType(preferred, "Creature").isEmpty()) {
|
||||
preferred = ComputerUtilCard.prioritizeCreaturesWorthRemovingNow(ai, preferred, false);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CounterEnumType;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.keyword.Keyword;
|
||||
@@ -21,7 +22,7 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
private static final Predicate<Card> predicate = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(final Card c) {
|
||||
return !(c.hasKeyword(Keyword.INDESTRUCTIBLE) || c.getSVar("SacMe").length() > 0);
|
||||
return !(c.hasKeyword(Keyword.INDESTRUCTIBLE) || c.getCounters(CounterEnumType.SHIELD) > 0 || c.hasSVar("SacMe"));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user