- Cleanup.

This commit is contained in:
Sloth
2014-10-24 14:52:59 +00:00
parent 8f90f65371
commit 00a756833d

View File

@@ -205,6 +205,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
for (Card attacker : attackers) { for (Card attacker : attackers) {
if (attacker.getCMC() < source.getCMC()) { if (attacker.getCMC() < source.getCMC()) {
lowerCMC = true; lowerCMC = true;
break;
} }
} }
if (!lowerCMC) { if (!lowerCMC) {
@@ -231,7 +232,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
Iterable<Player> pDefined = Lists.newArrayList(source.getController()); Iterable<Player> pDefined = Lists.newArrayList(source.getController());
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if ((tgt != null) && tgt.canTgtPlayer()) { if (tgt != null && tgt.canTgtPlayer()) {
boolean isCurse = sa.isCurse(); boolean isCurse = sa.isCurse();
if (isCurse && sa.canTarget(opponent)) { if (isCurse && sa.canTarget(opponent)) {
sa.getTargets().add(opponent); sa.getTargets().add(opponent);
@@ -280,6 +281,10 @@ public class ChangeZoneAi extends SpellAbilityAi {
list = CardLists.getValidCards(list, type, source.getController(), source); list = CardLists.getValidCards(list, type, source.getController(), source);
} }
if (!activateForCost && list.isEmpty()) {
return false;
}
String num = sa.getParam("ChangeNum"); String num = sa.getParam("ChangeNum");
if (num != null) { if (num != null) {
if (num.contains("X") && source.getSVar("X").equals("Count$xPaid")) { if (num.contains("X") && source.getSVar("X").equals("Count$xPaid")) {
@@ -289,10 +294,6 @@ public class ChangeZoneAi extends SpellAbilityAi {
source.setSVar("PayX", Integer.toString(xPay)); source.setSVar("PayX", Integer.toString(xPay));
} }
} }
if (!activateForCost && list.isEmpty()) {
return false;
}
} }
// don't use fetching to top of library/graveyard before main2 // don't use fetching to top of library/graveyard before main2
@@ -450,8 +451,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
int minSize = Integer.MAX_VALUE; int minSize = Integer.MAX_VALUE;
String minType = null; String minType = null;
for (int i = 0; i < basics.size(); i++) { for (String b : basics) {
final String b = basics.get(i);
final int num = CardLists.getType(combined, b).size(); final int num = CardLists.getType(combined, b).size();
if (num < minSize) { if (num < minSize) {
minType = b; minType = b;
@@ -574,7 +574,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
// non-targeted retrieval // non-targeted retrieval
final List<Card> retrieval = sa.knownDetermineDefined(sa.getParam("Defined")); final List<Card> retrieval = sa.knownDetermineDefined(sa.getParam("Defined"));
if ((retrieval == null) || retrieval.isEmpty()) { if (retrieval == null || retrieval.isEmpty()) {
return false; return false;
} }
@@ -608,6 +608,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
for (final Card c : retrieval) { for (final Card c : retrieval) {
if (objects.contains(c)) { if (objects.contains(c)) {
contains = true; contains = true;
break;
} }
} }
if (!contains) { if (!contains) {
@@ -621,12 +622,10 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN1)) { if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN1)) {
return false; return false;
} }
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && handSize > 1) {
&& handSize > 1) {
return false; return false;
} }
if (ai.getGame().getPhaseHandler().isPlayerTurn(ai) if (ai.getGame().getPhaseHandler().isPlayerTurn(ai) && handSize >= ai.getMaxHandSize()) {
&& handSize >= ai.getMaxHandSize()) {
return false; return false;
} }
} }
@@ -796,7 +795,8 @@ public class ChangeZoneAi extends SpellAbilityAi {
ComputerUtilCard.sortByEvaluateCreature(combatants); ComputerUtilCard.sortByEvaluateCreature(combatants);
for (final Card c : combatants) { for (final Card c : combatants) {
if (c.getShieldCount() == 0 && ComputerUtilCombat.combatantWouldBeDestroyed(ai, c, combat) && c.getOwner() == ai && !c.isToken()) { if (c.getShieldCount() == 0 && ComputerUtilCombat.combatantWouldBeDestroyed(ai, c, combat)
&& c.getOwner() == ai && !c.isToken()) {
sa.getTargets().add(c); sa.getTargets().add(c);
return true; return true;
} }
@@ -1058,7 +1058,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
if ((sa.getTargets().getNumTargeted() == 0) || (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa))) { if ((sa.getTargets().getNumTargeted() == 0) || sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
} else { } else {
@@ -1089,8 +1089,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
* a boolean. * a boolean.
* @return a boolean. * @return a boolean.
*/ */
private static boolean knownOriginTriggerAI(final Player ai, final SpellAbility sa, private static boolean knownOriginTriggerAI(final Player ai, final SpellAbility sa, final boolean mandatory) {
final boolean mandatory) {
if (sa.getTargetRestrictions() == null) { if (sa.getTargetRestrictions() == null) {
// Just in case of Defined cases // Just in case of Defined cases
@@ -1124,7 +1123,9 @@ public class ChangeZoneAi extends SpellAbilityAi {
fetchList.remove(source); fetchList.remove(source);
} }
} }
if (fetchList.isEmpty()) {
return null;
}
String type = sa.getParam("ChangeType"); String type = sa.getParam("ChangeType");
if (type == null) { if (type == null) {
type = "Card"; type = "Card";