- Expanded isUsefulKeyword.

This commit is contained in:
Sloth
2012-02-23 11:58:19 +00:00
parent a93a4f4806
commit e519bbe0c4
2 changed files with 33 additions and 20 deletions

View File

@@ -1964,35 +1964,58 @@ public class ComputerUtil {
* @return true, if is useful keyword * @return true, if is useful keyword
*/ */
public static boolean isUsefulKeyword(final String keyword, final Card card) { public static boolean isUsefulKeyword(final String keyword, final Card card) {
PhaseHandler ph = AllZone.getPhaseHandler();
Player computer = AllZone.getComputerPlayer();
Player human = AllZone.getHumanPlayer();
final boolean evasive = (keyword.endsWith("Flying") || keyword.endsWith("Horsemanship")
|| keyword.endsWith("Unblockable") || keyword.endsWith("Fear")
|| keyword.endsWith("Intimidate"));
if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) { if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) {
return false; return false;
} }
if (keyword.equals("Defender") || keyword.endsWith("CARDNAME can't attack.")) { // give evasive keywords to creatures that can attack
if (evasive) {
if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
|| (card.getNetCombatDamage() <= 0)
|| AllZoneUtil.getCreaturesInPlay(human).size() < 1) {
return false;
}
} else if (keyword.equals("Defender") || keyword.endsWith("CARDNAME can't attack.")) {
if (card.getController().isComputer() if (card.getController().isComputer()
|| AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || ph.isPlayerTurn(computer)
|| !CombatUtil.canAttack(card) || (card.getNetCombatDamage() <= 0)) { || !CombatUtil.canAttack(card) || (card.getNetCombatDamage() <= 0)) {
return false; return false;
} }
} else if (keyword.contains("CARDNAME can't block.")) { } else if (keyword.endsWith("CARDNAME can't block.")) {
if (card.getController().isComputer() || AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer()) if (card.getController().isComputer() || ph.isPlayerTurn(human)
|| !CombatUtil.canBlock(card)) { || !CombatUtil.canBlock(card)) {
return false; return false;
} }
} else if (keyword.endsWith("This card doesn't untap during your next untap step.")) { } else if (keyword.endsWith("This card doesn't untap during your next untap step.")) {
if (AllZone.getPhaseHandler().isBefore(Constant.Phase.MAIN2) if (ph.isBefore(Constant.Phase.MAIN2) || card.isUntapped()
|| AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer())) { || ph.isPlayerTurn(human)) {
return false; return false;
} }
} else if (keyword.endsWith("CARDNAME attacks each turn if able.")) { } else if (keyword.endsWith("CARDNAME attacks each turn if able.")) {
if (AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || !CombatUtil.canAttack(card) if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
|| !CombatUtil.canBeBlocked(card)) { || !CombatUtil.canBeBlocked(card)) {
return false; return false;
} }
} else if (keyword.endsWith("Haste")) { } else if (keyword.endsWith("Shroud")) {
if (!card.hasSickness() || AllZone.getPhaseHandler().isPlayerTurn(AllZone.getHumanPlayer()) //TODO: check stack for spells and abilities
return false;
} else if (keyword.startsWith("Rampage")) {
if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
|| !CombatUtil.canBeBlocked(card)
|| AllZoneUtil.getCreaturesInPlay(human).size() < 2) {
return false;
}
} else if (keyword.endsWith("Haste")) {
if (!card.hasSickness() || ph.isPlayerTurn(human)
|| !CombatUtil.canAttackNextTurn(card) || card.isTapped() || !CombatUtil.canAttackNextTurn(card) || card.isTapped()
|| card.hasKeyword("CARDNAME can attack as though it had haste.") || card.hasKeyword("CARDNAME can attack as though it had haste.")
|| AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) { || ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
return false; return false;
} }
} }

View File

@@ -260,9 +260,6 @@ public class AbilityFactoryPump {
*/ */
private CardList getPumpCreatures(final int defense, final int attack, final SpellAbility sa) { private CardList getPumpCreatures(final int defense, final int attack, final SpellAbility sa) {
final boolean evasive = (this.keywords.contains("Flying") || this.keywords.contains("Horsemanship")
|| this.keywords.contains("HIDDEN Unblockable") || this.keywords.contains("Fear") || this.keywords
.contains("Intimidate"));
final ArrayList<String> keywords = this.keywords; final ArrayList<String> keywords = this.keywords;
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
@@ -281,13 +278,6 @@ public class AbilityFactoryPump {
return false; return false;
} }
// give evasive keywords to creatures that can attack
if (evasive && AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) && CombatUtil.canAttack(c)
&& AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
&& (c.getNetCombatDamage() > 0)) {
return true;
}
// will the creature attack (only relevant for sorcery speed)? // will the creature attack (only relevant for sorcery speed)?
if (CardFactoryUtil.doesCreatureAttackAI(c) if (CardFactoryUtil.doesCreatureAttackAI(c)
&& AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS) && AllZone.getPhaseHandler().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)