mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Improved isUsefulPumpKeyword.
This commit is contained in:
@@ -7,6 +7,7 @@ import forge.ai.ComputerUtil;
|
|||||||
import forge.ai.ComputerUtilCard;
|
import forge.ai.ComputerUtilCard;
|
||||||
import forge.ai.ComputerUtilCombat;
|
import forge.ai.ComputerUtilCombat;
|
||||||
import forge.ai.SpellAbilityAi;
|
import forge.ai.SpellAbilityAi;
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
@@ -166,9 +167,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean evasive = (keyword.endsWith("Unblockable") || keyword.endsWith("Fear")
|
final boolean evasive = (keyword.endsWith("Unblockable") || keyword.endsWith("Shadow") || keyword.startsWith("CantBeBlockedBy"));
|
||||||
|| keyword.endsWith("Intimidate") || keyword.endsWith("Shadow")
|
|
||||||
|| keyword.startsWith("CantBeBlockedBy"));
|
|
||||||
// give evasive keywords to creatures that can or do attack
|
// give evasive keywords to creatures that can or do attack
|
||||||
if (evasive) {
|
if (evasive) {
|
||||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||||
@@ -209,6 +208,22 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
|||||||
"Horsemanship").isEmpty()) {
|
"Horsemanship").isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (keyword.endsWith("Intimidate")) {
|
||||||
|
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||||
|
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||||
|
|| newPower <= 0
|
||||||
|
|| CardLists.getNotType(CardLists.filter(
|
||||||
|
opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact").isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (keyword.endsWith("Fear")) {
|
||||||
|
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||||
|
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||||
|
|| newPower <= 0
|
||||||
|
|| CardLists.getNotColor(CardLists.getNotType(CardLists.filter(
|
||||||
|
opp.getCreaturesInPlay(), CardPredicates.possibleBlockers(card)), "Artifact"), MagicColor.BLACK).isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else if (keyword.endsWith("Haste")) {
|
} else if (keyword.endsWith("Haste")) {
|
||||||
if (!card.hasSickness() || ph.isPlayerTurn(opp) || card.isTapped()
|
if (!card.hasSickness() || ph.isPlayerTurn(opp) || card.isTapped()
|
||||||
|| newPower <= 0
|
|| newPower <= 0
|
||||||
@@ -247,6 +262,9 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (keyword.equals("First Strike")) {
|
} else if (keyword.equals("First Strike")) {
|
||||||
|
if (card.hasKeyword("Double Strike")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (ph.isPlayerTurn(ai) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
if (ph.isPlayerTurn(ai) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||||
&& newPower > 0
|
&& newPower > 0
|
||||||
&& ph.getPhase().isBefore(PhaseType.COMBAT_DAMAGE)
|
&& ph.getPhase().isBefore(PhaseType.COMBAT_DAMAGE)
|
||||||
@@ -294,7 +312,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
|||||||
if (newPower <= 0) {
|
if (newPower <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (combat != null && combat.isBlocking(card)) {
|
if (combat != null && combat.isBlocking(card) && !card.hasKeyword("Wither")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((ph.isPlayerTurn(opp))
|
if ((ph.isPlayerTurn(opp))
|
||||||
@@ -303,12 +321,12 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (keyword.endsWith("Wither")) {
|
} else if (keyword.endsWith("Wither")) {
|
||||||
if (newPower <= 0) {
|
if (newPower <= 0 || card.hasKeyword("Infect")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return combat != null && ( combat.isBlocking(card) || (combat.isAttacking(card) && combat.isBlocked(card)) );
|
return combat != null && ( combat.isBlocking(card) || (combat.isAttacking(card) && combat.isBlocked(card)) );
|
||||||
} else if (keyword.equals("Lifelink")) {
|
} else if (keyword.equals("Lifelink")) {
|
||||||
if (newPower <= 0) {
|
if (newPower <= 0 || ai.canGainLife()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return combat != null && ( combat.isAttacking(card) || combat.isBlocking(card) );
|
return combat != null && ( combat.isAttacking(card) || combat.isBlocking(card) );
|
||||||
@@ -349,6 +367,10 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
|||||||
if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card)) {
|
if (!ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (keyword.equals("Persist")) {
|
||||||
|
if (card.getBaseDefense() <= 1 || card.hasKeyword("Undying")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else if (keyword.equals("Islandwalk")) {
|
} else if (keyword.equals("Islandwalk")) {
|
||||||
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
if (ph.isPlayerTurn(opp) || !(CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||||
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
|| ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)
|
||||||
|
|||||||
@@ -204,6 +204,14 @@ public class CardLists {
|
|||||||
return CardLists.filter(cardList, CardPredicates.isType(cardType));
|
return CardLists.filter(cardList, CardPredicates.isType(cardType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Card> getNotColor(Iterable<Card> cardList, byte color) {
|
||||||
|
return CardLists.filter(cardList, Predicates.not(CardPredicates.isColor(color)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Card> getColor(Iterable<Card> cardList, byte color) {
|
||||||
|
return CardLists.filter(cardList, CardPredicates.isColor(color));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new list of cards by applying a filter to this one.
|
* Create a new list of cards by applying a filter to this one.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user