mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Code formatting and import fixes.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package forge.ai.ability;
|
package forge.ai.ability;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import forge.ai.AiController;
|
import forge.ai.AiController;
|
||||||
import forge.ai.AiProps;
|
import forge.ai.AiProps;
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Targeting
|
// Targeting
|
||||||
@@ -93,49 +92,49 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if ("Polymorph".equals(logic)) {
|
} else if ("Polymorph".equals(logic)) {
|
||||||
list = CardLists.getTargetableCards(ai.getCardsIn(ZoneType.Battlefield), sa);
|
list = CardLists.getTargetableCards(ai.getCardsIn(ZoneType.Battlefield), sa);
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Card c : list) {
|
for (Card c : list) {
|
||||||
if (c.hasKeyword("Indestructible")) {
|
if (c.hasKeyword("Indestructible")) {
|
||||||
sa.getTargets().add(c);
|
sa.getTargets().add(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Card worst = ComputerUtilCard.getWorstAI(list);
|
Card worst = ComputerUtilCard.getWorstAI(list);
|
||||||
if (worst.isCreature() && ComputerUtilCard.evaluateCreature(worst) >= 200) {
|
if (worst.isCreature() && ComputerUtilCard.evaluateCreature(worst) >= 200) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!worst.isCreature() && worst.getCMC() > 1) {
|
if (!worst.isCreature() && worst.getCMC() > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sa.getTargets().add(worst);
|
sa.getTargets().add(worst);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
list = CardLists.getTargetableCards(ai.getOpponents().getCardsIn(ZoneType.Battlefield), sa);
|
list = CardLists.getTargetableCards(ai.getOpponents().getCardsIn(ZoneType.Battlefield), sa);
|
||||||
if ("FatalPush".equals(logic)) {
|
if ("FatalPush".equals(logic)) {
|
||||||
final int cmcMax = ai.hasRevolt() ? 4 : 2;
|
final int cmcMax = ai.hasRevolt() ? 4 : 2;
|
||||||
list = CardLists.filter(list, CardPredicates.lessCMC(cmcMax));
|
list = CardLists.filter(list, CardPredicates.lessCMC(cmcMax));
|
||||||
}
|
}
|
||||||
if (sa.hasParam("AITgts")) {
|
if (sa.hasParam("AITgts")) {
|
||||||
if (sa.getParam("AITgts").equals("BetterThanSource")) {
|
if (sa.getParam("AITgts").equals("BetterThanSource")) {
|
||||||
if (source.isEnchanted()) {
|
if (source.isEnchanted()) {
|
||||||
if (source.getEnchantedBy(false).get(0).getController().equals(ai)) {
|
if (source.getEnchantedBy(false).get(0).getController().equals(ai)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final int value = ComputerUtilCard.evaluateCreature(source);
|
final int value = ComputerUtilCard.evaluateCreature(source);
|
||||||
list = CardLists.filter(list, new Predicate<Card>() {
|
list = CardLists.filter(list, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card c) {
|
public boolean apply(final Card c) {
|
||||||
return ComputerUtilCard.evaluateCreature(c) > value + 30;
|
return ComputerUtilCard.evaluateCreature(c) > value + 30;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), source);
|
list = CardLists.getValidCards(list, sa.getParam("AITgts"), sa.getActivatingPlayer(), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list = CardLists.getNotKeyword(list, "Indestructible");
|
list = CardLists.getNotKeyword(list, "Indestructible");
|
||||||
if (!SpellAbilityAi.playReusable(ai, sa)) {
|
if (!SpellAbilityAi.playReusable(ai, sa)) {
|
||||||
@@ -158,7 +157,7 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c.hasSVar("SacMe")) {
|
if (c.hasSVar("SacMe")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Check for undying
|
//Check for undying
|
||||||
return (!c.hasKeyword("Undying") || c.getCounters(CounterType.P1P1) > 0);
|
return (!c.hasKeyword("Undying") || c.getCounters(CounterType.P1P1) > 0);
|
||||||
@@ -203,7 +202,7 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
while (sa.getTargets().getNumTargeted() < maxTargets) {
|
while (sa.getTargets().getNumTargeted() < maxTargets) {
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||||
sa.resetTargets();
|
sa.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -228,15 +227,15 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
return true; // becomes Terminate
|
return true; // becomes Terminate
|
||||||
} else {
|
} else {
|
||||||
if (source.getGame().getPhaseHandler().getPhase()
|
if (source.getGame().getPhaseHandler().getPhase()
|
||||||
.isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS) || // prevent surprise combatant
|
.isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||||
ComputerUtilCard.evaluateCreature(choice) < 1.5
|
|| // prevent surprise combatant
|
||||||
* ComputerUtilCard.evaluateCreature(token)) {
|
ComputerUtilCard.evaluateCreature(choice) < 1.5
|
||||||
|
* ComputerUtilCard.evaluateCreature(token)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (CardLists.getNotType(list, "Land").isEmpty()) {
|
||||||
else if (CardLists.getNotType(list, "Land").isEmpty()) {
|
|
||||||
choice = ComputerUtilCard.getBestLandAI(list);
|
choice = ComputerUtilCard.getBestLandAI(list);
|
||||||
|
|
||||||
if ("LandForLand".equals(logic) || "GhostQuarter".equals(logic)) {
|
if ("LandForLand".equals(logic) || "GhostQuarter".equals(logic)) {
|
||||||
@@ -245,8 +244,7 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
choice = ComputerUtilCard.getMostExpensivePermanentAI(list, sa, true);
|
choice = ComputerUtilCard.getMostExpensivePermanentAI(list, sa, true);
|
||||||
}
|
}
|
||||||
//option to hold removal instead only applies for single targeted removal
|
//option to hold removal instead only applies for single targeted removal
|
||||||
@@ -258,7 +256,7 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
if (choice == null) { // can't find anything left
|
if (choice == null) { // can't find anything left
|
||||||
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
if ((sa.getTargets().getNumTargeted() < abTgt.getMinTargets(sa.getHostCard(), sa))
|
||||||
|| (sa.getTargets().getNumTargeted() == 0)) {
|
|| (sa.getTargets().getNumTargeted() == 0)) {
|
||||||
sa.resetTargets();
|
sa.resetTargets();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -271,7 +269,7 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
for (Card aura : choice.getEnchantedBy(false)) {
|
for (Card aura : choice.getEnchantedBy(false)) {
|
||||||
SpellAbility sp = aura.getFirstSpellAbility();
|
SpellAbility sp = aura.getFirstSpellAbility();
|
||||||
if (sp != null && "GainControl".equals(sp.getParam("AILogic"))
|
if (sp != null && "GainControl".equals(sp.getParam("AILogic"))
|
||||||
&& aura.getController() != ai && sa.canTarget(aura)) {
|
&& aura.getController() != ai && sa.canTarget(aura)) {
|
||||||
choice = aura;
|
choice = aura;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,20 +278,19 @@ public class DestroyAi extends SpellAbilityAi {
|
|||||||
list.remove(choice);
|
list.remove(choice);
|
||||||
sa.getTargets().add(choice);
|
sa.getTargets().add(choice);
|
||||||
}
|
}
|
||||||
}
|
} else if (sa.hasParam("Defined")) {
|
||||||
else if (sa.hasParam("Defined")) {
|
|
||||||
list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||||
if ("WillSkipTurn".equals(logic) && (sa.getHostCard().getController().equals(ai)
|
if ("WillSkipTurn".equals(logic) && (sa.getHostCard().getController().equals(ai)
|
||||||
|| ai.getCreaturesInPlay().size() < ai.getOpponent().getCreaturesInPlay().size()
|
|| ai.getCreaturesInPlay().size() < ai.getOpponent().getCreaturesInPlay().size()
|
||||||
|| !source.getGame().getPhaseHandler().isPlayerTurn(ai)
|
|| !source.getGame().getPhaseHandler().isPlayerTurn(ai)
|
||||||
|| ai.getLife() <= 5)) {
|
|| ai.getLife() <= 5)) {
|
||||||
// Basic ai logic for Lethal Vapors
|
// Basic ai logic for Lethal Vapors
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.isEmpty()
|
if (list.isEmpty()
|
||||||
|| !CardLists.filterControlledBy(list, ai).isEmpty()
|
|| !CardLists.filterControlledBy(list, ai).isEmpty()
|
||||||
|| CardLists.getNotKeyword(list, "Indestructible").isEmpty()) {
|
|| CardLists.getNotKeyword(list, "Indestructible").isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user