checkstyle

This commit is contained in:
jendave
2011-10-31 06:36:35 +00:00
parent 8d61edf4fe
commit b187e3193c
36 changed files with 2098 additions and 2180 deletions

View File

@@ -275,7 +275,7 @@ public class AIPlayer extends Player {
public final void sacrificePermanent(final String prompt, final CardList choices) { public final void sacrificePermanent(final String prompt, final CardList choices) {
if (choices.size() > 0) { if (choices.size() > 0) {
// TODO - this could probably use better AI // TODO - this could probably use better AI
Card c = CardFactoryUtil.AI_getWorstPermanent(choices, false, false, false, false); Card c = CardFactoryUtil.getWorstPermanentAI(choices, false, false, false, false);
AllZone.getGameAction().sacrificeDestroy(c); AllZone.getGameAction().sacrificeDestroy(c);
} }
} }

View File

@@ -2198,7 +2198,7 @@ public class CombatUtil {
} }
}); });
if (enchantments.size() > 0) { if (enchantments.size() > 0) {
Card card = CardFactoryUtil.AI_getBestEnchantment(enchantments, c, false); Card card = CardFactoryUtil.getBestEnchantmentAI(enchantments, c, false);
AllZone.getGameAction().moveToPlay(card); AllZone.getGameAction().moveToPlay(card);
c.getController().shuffle(); c.getController().shuffle();
} }
@@ -2277,7 +2277,7 @@ public class CombatUtil {
card.setCreatureAttackedThisCombat(true); card.setCreatureAttackedThisCombat(true);
} }
} else if (c.getController().isComputer()) { } else if (c.getController().isComputer()) {
Card card = CardFactoryUtil.AI_getBestCreature(soldiers); Card card = CardFactoryUtil.getBestCreatureAI(soldiers);
if (card != null) { if (card != null) {
AllZone.getGameAction().moveToPlay(card); AllZone.getGameAction().moveToPlay(card);
@@ -2568,7 +2568,7 @@ public class CombatUtil {
enchantment = ((Card) check); enchantment = ((Card) check);
} }
} else { } else {
enchantment = CardFactoryUtil.AI_getBestEnchantment(enchantments, attacker, false); enchantment = CardFactoryUtil.getBestEnchantmentAI(enchantments, attacker, false);
} }
if (enchantment != null && AllZoneUtil.isCardInPlay(attacker)) { if (enchantment != null && AllZoneUtil.isCardInPlay(attacker)) {
GameAction.changeZone(AllZone.getZoneOf(enchantment), GameAction.changeZone(AllZone.getZoneOf(enchantment),

View File

@@ -1490,7 +1490,7 @@ public class ComputerUtil {
Card c; Card c;
if (list.getNotType("Creature").size() == 0) { if (list.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getWorstCreature(list); c = CardFactoryUtil.getWorstCreatureAI(list);
} else if (list.getNotType("Land").size() == 0) { } else if (list.getNotType("Land").size() == 0) {
c = CardFactoryUtil.getWorstLand(AllZone.getComputerPlayer()); c = CardFactoryUtil.getWorstLand(AllZone.getComputerPlayer());
} else { } else {

View File

@@ -316,9 +316,9 @@ public class ComputerUtil_Block2 {
// destroyed // destroyed
killingBlockers = getKillingBlockers(attacker, safeBlockers, combat); killingBlockers = getKillingBlockers(attacker, safeBlockers, combat);
if (killingBlockers.size() > 0) { if (killingBlockers.size() > 0) {
blocker = CardFactoryUtil.AI_getWorstCreature(killingBlockers); blocker = CardFactoryUtil.getWorstCreatureAI(killingBlockers);
} else { } else {
blocker = CardFactoryUtil.AI_getWorstCreature(safeBlockers); blocker = CardFactoryUtil.getWorstCreatureAI(safeBlockers);
getBlockedButUnkilled().add(attacker); getBlockedButUnkilled().add(attacker);
} }
} // no safe blockers } // no safe blockers
@@ -327,7 +327,7 @@ public class ComputerUtil_Block2 {
if (killingBlockers.size() > 0) { if (killingBlockers.size() > 0) {
// 3.Blockers that can destroy the attacker and are worth // 3.Blockers that can destroy the attacker and are worth
// less // less
Card worst = CardFactoryUtil.AI_getWorstCreature(killingBlockers); Card worst = CardFactoryUtil.getWorstCreatureAI(killingBlockers);
if (CardFactoryUtil.evaluateCreature(worst) + getDiff() < CardFactoryUtil if (CardFactoryUtil.evaluateCreature(worst) + getDiff() < CardFactoryUtil
.evaluateCreature(attacker)) { .evaluateCreature(attacker)) {
@@ -428,7 +428,7 @@ public class ComputerUtil_Block2 {
return combat; return combat;
} }
Card leader = CardFactoryUtil.AI_getBestCreature(usableBlockers); Card leader = CardFactoryUtil.getBestCreatureAI(usableBlockers);
blockGang.add(leader); blockGang.add(leader);
usableBlockers.remove(leader); usableBlockers.remove(leader);
absorbedDamage = leader.getEnoughDamageToKill(attacker.getNetCombatDamage(), attacker, true); absorbedDamage = leader.getEnoughDamageToKill(attacker.getNetCombatDamage(), attacker, true);
@@ -485,7 +485,7 @@ public class ComputerUtil_Block2 {
killingBlockers = getKillingBlockers(attacker, getPossibleBlockers(attacker, getBlockersLeft(), combat), killingBlockers = getKillingBlockers(attacker, getPossibleBlockers(attacker, getBlockersLeft(), combat),
combat); combat);
if (killingBlockers.size() > 0 && CombatUtil.lifeInDanger(combat)) { if (killingBlockers.size() > 0 && CombatUtil.lifeInDanger(combat)) {
Card blocker = CardFactoryUtil.AI_getWorstCreature(killingBlockers); Card blocker = CardFactoryUtil.getWorstCreatureAI(killingBlockers);
combat.addBlocker(attacker, blocker); combat.addBlocker(attacker, blocker);
currentAttackers.remove(attacker); currentAttackers.remove(attacker);
getBlockersLeft().remove(blocker); getBlockersLeft().remove(blocker);
@@ -513,7 +513,7 @@ public class ComputerUtil_Block2 {
for (Card attacker : getAttackersLeft()) { for (Card attacker : getAttackersLeft()) {
chumpBlockers = getPossibleBlockers(attacker, getBlockersLeft(), combat); chumpBlockers = getPossibleBlockers(attacker, getBlockersLeft(), combat);
if (chumpBlockers.size() > 0 && CombatUtil.lifeInDanger(combat)) { if (chumpBlockers.size() > 0 && CombatUtil.lifeInDanger(combat)) {
Card blocker = CardFactoryUtil.AI_getWorstCreature(chumpBlockers); Card blocker = CardFactoryUtil.getWorstCreatureAI(chumpBlockers);
combat.addBlocker(attacker, blocker); combat.addBlocker(attacker, blocker);
currentAttackers.remove(attacker); currentAttackers.remove(attacker);
getBlockedButUnkilled().add(attacker); getBlockedButUnkilled().add(attacker);

View File

@@ -2013,7 +2013,7 @@ public class GameAction {
} }
} }
if (chosen == null) { if (chosen == null) {
chosen = CardFactoryUtil.AI_getWorstCreature(grave); chosen = CardFactoryUtil.getWorstCreatureAI(grave);
} }
if (chosen == null) { if (chosen == null) {

View File

@@ -918,9 +918,9 @@ public class MagicStack extends MyObservable {
// AI choosing what to haunt // AI choosing what to haunt
final CardList oppCreats = creats.getController(AllZone.getHumanPlayer()); final CardList oppCreats = creats.getController(AllZone.getHumanPlayer());
if (oppCreats.size() != 0) { if (oppCreats.size() != 0) {
haunterDiesWork.setTargetCard(CardFactoryUtil.AI_getWorstCreature(oppCreats)); haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats));
} else { } else {
haunterDiesWork.setTargetCard(CardFactoryUtil.AI_getWorstCreature(creats)); haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(creats));
} }
this.add(haunterDiesWork); this.add(haunterDiesWork);
} }

View File

@@ -270,7 +270,7 @@ public class PhaseUtil {
} }
}); });
if (artList.size() > 0) { if (artList.size() > 0) {
CardFactoryUtil.AI_getBestArtifact(artList).untap(); CardFactoryUtil.getBestArtifactAI(artList).untap();
} }
} else { } else {
Input target = new Input() { Input target = new Input() {

View File

@@ -537,7 +537,7 @@ public class Upkeep implements java.io.Serializable {
if (indestruct.size() > 0) { if (indestruct.size() > 0) {
AllZone.getGameAction().destroyNoRegeneration(indestruct.get(0)); AllZone.getGameAction().destroyNoRegeneration(indestruct.get(0));
} else { } else {
final Card target = CardFactoryUtil.AI_getWorstCreature(targets); final Card target = CardFactoryUtil.getWorstCreatureAI(targets);
if (null == target) { if (null == target) {
// must be nothing valid to destroy // must be nothing valid to destroy
} else { } else {
@@ -625,7 +625,7 @@ public class Upkeep implements java.io.Serializable {
} // selectCard() } // selectCard()
}); // Input }); // Input
} else { // computer } else { // computer
final Card target = CardFactoryUtil.AI_getCheapestPermanent(artifacts, c, false); final Card target = CardFactoryUtil.getCheapestPermanentAI(artifacts, c, false);
if (null == target) { if (null == target) {
this.tapAndDamage(player); this.tapAndDamage(player);
} else { } else {
@@ -683,7 +683,7 @@ public class Upkeep implements java.io.Serializable {
PlayerUtil.input_sacrificePermanent(creatures, c.getName() PlayerUtil.input_sacrificePermanent(creatures, c.getName()
+ " - Select a creature to sacrifice.")); + " - Select a creature to sacrifice."));
} else { // computer } else { // computer
final Card target = CardFactoryUtil.AI_getWorstCreature(creatures); final Card target = CardFactoryUtil.getWorstCreatureAI(creatures);
AllZone.getGameAction().sacrifice(target); AllZone.getGameAction().sacrifice(target);
} }
} // resolve } // resolve
@@ -748,7 +748,7 @@ public class Upkeep implements java.io.Serializable {
final int power = creatures.get(0).getNetAttack(); final int power = creatures.get(0).getNetAttack();
if (player.isHuman()) { if (player.isHuman()) {
AllZone.getInputControl().setInput( AllZone.getInputControl().setInput(
CardFactoryUtil.input_destroyNoRegeneration(this.getLowestPowerList(creatures), CardFactoryUtil.inputDestroyNoRegeneration(this.getLowestPowerList(creatures),
"Select creature with power: " + power + " to sacrifice.")); "Select creature with power: " + power + " to sacrifice."));
} else { // computer } else { // computer
final Card compyTarget = this.getCompyCardToDestroy(creatures); final Card compyTarget = this.getCompyCardToDestroy(creatures);
@@ -827,7 +827,7 @@ public class Upkeep implements java.io.Serializable {
+ " - Select a land to sacrifice.")); + " - Select a land to sacrifice."));
} }
} else { } else {
final Card target = CardFactoryUtil.AI_getBestLand(playerLand); final Card target = CardFactoryUtil.getBestLandAI(playerLand);
AllZone.getGameAction().sacrifice(target); AllZone.getGameAction().sacrifice(target);
} }
@@ -2587,7 +2587,7 @@ public class Upkeep implements java.io.Serializable {
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
if (player.isComputer()) { if (player.isComputer()) {
final Card toTap = CardFactoryUtil.AI_getWorstPermanent(list, false, false, false, false); final Card toTap = CardFactoryUtil.getWorstPermanentAI(list, false, false, false, false);
if (null != toTap) { if (null != toTap) {
toTap.tap(); toTap.tap();
list.remove(toTap); list.remove(toTap);

View File

@@ -320,7 +320,7 @@ public class AbilityFactory_Attach {
return null; return null;
} }
return CardFactoryUtil.AI_getWorstPermanent(list, true, true, true, false); return CardFactoryUtil.getWorstPermanentAI(list, true, true, true, false);
} }
/** /**
@@ -337,7 +337,7 @@ public class AbilityFactory_Attach {
return null; return null;
} }
return CardFactoryUtil.AI_getBest(list); return CardFactoryUtil.getBestAI(list);
} }
/** /**
@@ -391,7 +391,7 @@ public class AbilityFactory_Attach {
} }
final Card c = CardFactoryUtil.AI_getBest(list); final Card c = CardFactoryUtil.getBestAI(list);
// If Mandatory (brought directly into play without casting) gotta // If Mandatory (brought directly into play without casting) gotta
// choose something // choose something
@@ -441,7 +441,7 @@ public class AbilityFactory_Attach {
} }
}); });
return CardFactoryUtil.AI_getBest(magnetList); return CardFactoryUtil.getBestAI(magnetList);
} }
int totToughness = 0; int totToughness = 0;
@@ -536,11 +536,11 @@ public class AbilityFactory_Attach {
return !c.isCreature() || CombatUtil.canAttack(c); return !c.isCreature() || CombatUtil.canAttack(c);
} }
}); });
c = CardFactoryUtil.AI_getBest(prefList); c = CardFactoryUtil.getBestAI(prefList);
} else { } else {
// If we grant abilities, we may want to put it on something Weak? // If we grant abilities, we may want to put it on something Weak?
// Possibly more defensive? // Possibly more defensive?
c = CardFactoryUtil.AI_getWorstPermanent(prefList, false, false, false, false); c = CardFactoryUtil.getWorstPermanentAI(prefList, false, false, false, false);
} }
if (c == null) { if (c == null) {
@@ -628,7 +628,7 @@ public class AbilityFactory_Attach {
if ((prefList == null) || (prefList.size() == 0)) { if ((prefList == null) || (prefList.size() == 0)) {
prefList = new CardList(list); prefList = new CardList(list);
} else { } else {
c = CardFactoryUtil.AI_getBest(prefList); c = CardFactoryUtil.getBestAI(prefList);
if (c != null) { if (c != null) {
return c; return c;
} }
@@ -648,7 +648,7 @@ public class AbilityFactory_Attach {
} }
} }
c = CardFactoryUtil.AI_getBest(prefList); c = CardFactoryUtil.getBestAI(prefList);
if (c == null) { if (c == null) {
return AbilityFactory_Attach.chooseLessPreferred(mandatory, list); return AbilityFactory_Attach.chooseLessPreferred(mandatory, list);
@@ -686,7 +686,7 @@ public class AbilityFactory_Attach {
list = list.getNotType(type); // Filter out Basic Lands that have the list = list.getNotType(type); // Filter out Basic Lands that have the
// same type as the changing type // same type as the changing type
final Card c = CardFactoryUtil.AI_getBest(list); final Card c = CardFactoryUtil.getBestAI(list);
// TODO Port over some of the existing code, but rewrite most of it. // TODO Port over some of the existing code, but rewrite most of it.
// Ultimately, these spells need to be used to reduce mana base of a // Ultimately, these spells need to be used to reduce mana base of a
@@ -748,7 +748,7 @@ public class AbilityFactory_Attach {
} }
}); });
final Card c = CardFactoryUtil.AI_getBest(prefList); final Card c = CardFactoryUtil.getBestAI(prefList);
if (c == null) { if (c == null) {
return AbilityFactory_Attach.chooseLessPreferred(mandatory, list); return AbilityFactory_Attach.chooseLessPreferred(mandatory, list);

View File

@@ -942,19 +942,19 @@ public final class AbilityFactory_ChangeZone {
} else if (AbilityFactory_ChangeZone.areAllBasics(type)) { } else if (AbilityFactory_ChangeZone.areAllBasics(type)) {
c = AbilityFactory_ChangeZone.basicManaFixing(fetchList, type); c = AbilityFactory_ChangeZone.basicManaFixing(fetchList, type);
} else if (fetchList.getNotType("Creature").size() == 0) { } else if (fetchList.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getBestCreature(fetchList); // if only c = CardFactoryUtil.getBestCreatureAI(fetchList); // if only
// creatures // creatures
// take the // take the
// best // best
} else if (Zone.Battlefield.equals(destination) || Zone.Graveyard.equals(destination)) { } else if (Zone.Battlefield.equals(destination) || Zone.Graveyard.equals(destination)) {
c = CardFactoryUtil.AI_getMostExpensivePermanent(fetchList, af.getHostCard(), false); c = CardFactoryUtil.getMostExpensivePermanentAI(fetchList, af.getHostCard(), false);
} else if (Zone.Exile.equals(destination)) { } else if (Zone.Exile.equals(destination)) {
// Exiling your own stuff, if Exiling opponents stuff choose // Exiling your own stuff, if Exiling opponents stuff choose
// best // best
if (destZone.getPlayer().isHuman()) { if (destZone.getPlayer().isHuman()) {
c = CardFactoryUtil.AI_getMostExpensivePermanent(fetchList, af.getHostCard(), false); c = CardFactoryUtil.getMostExpensivePermanentAI(fetchList, af.getHostCard(), false);
} else { } else {
c = CardFactoryUtil.AI_getCheapestPermanent(fetchList, af.getHostCard(), false); c = CardFactoryUtil.getCheapestPermanentAI(fetchList, af.getHostCard(), false);
} }
} else { } else {
// Don't fetch another tutor with the same name // Don't fetch another tutor with the same name
@@ -1318,7 +1318,7 @@ public final class AbilityFactory_ChangeZone {
if (!threatenedTargets.isEmpty()) { if (!threatenedTargets.isEmpty()) {
// Choose "best" of the remaining to save // Choose "best" of the remaining to save
tgt.addTarget(CardFactoryUtil.AI_getBestCreature(threatenedTargets)); tgt.addTarget(CardFactoryUtil.getBestCreatureAI(threatenedTargets));
return true; return true;
} }
} }
@@ -1357,7 +1357,7 @@ public final class AbilityFactory_ChangeZone {
}); });
if (!aiPermanents.isEmpty()) { if (!aiPermanents.isEmpty()) {
// Choose "best" of the remaining to save // Choose "best" of the remaining to save
tgt.addTarget(CardFactoryUtil.AI_getBest(aiPermanents)); tgt.addTarget(CardFactoryUtil.getBestAI(aiPermanents));
return true; return true;
} }
} }
@@ -1400,15 +1400,15 @@ public final class AbilityFactory_ChangeZone {
Card choice = null; Card choice = null;
if (!list.isEmpty()) { if (!list.isEmpty()) {
final Card mostExpensive = CardFactoryUtil.AI_getMostExpensivePermanent(list, af.getHostCard(), false); final Card mostExpensive = CardFactoryUtil.getMostExpensivePermanentAI(list, af.getHostCard(), false);
if (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield)) { if (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield)) {
if (mostExpensive.isCreature()) { if (mostExpensive.isCreature()) {
// if a creature is most expensive take the best one // if a creature is most expensive take the best one
if (destination.equals(Zone.Exile)) { if (destination.equals(Zone.Exile)) {
// If Exiling things, don't give bonus to Tokens // If Exiling things, don't give bonus to Tokens
choice = CardFactoryUtil.AI_getBestCreature(list); choice = CardFactoryUtil.getBestCreatureAI(list);
} else { } else {
choice = CardFactoryUtil.AI_getBestCreatureToBounce(list); choice = CardFactoryUtil.getBestCreatureToBounceAI(list);
} }
} else { } else {
choice = mostExpensive; choice = mostExpensive;
@@ -1495,12 +1495,12 @@ public final class AbilityFactory_ChangeZone {
Card choice = null; Card choice = null;
if (!list.isEmpty()) { if (!list.isEmpty()) {
if (CardFactoryUtil.AI_getMostExpensivePermanent(list, af.getHostCard(), false).isCreature() if (CardFactoryUtil.getMostExpensivePermanentAI(list, af.getHostCard(), false).isCreature()
&& (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield))) { && (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield))) {
// if a creature is most expensive take the best // if a creature is most expensive take the best
choice = CardFactoryUtil.AI_getBestCreatureToBounce(list); choice = CardFactoryUtil.getBestCreatureToBounceAI(list);
} else if (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield)) { } else if (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield)) {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(list, af.getHostCard(), false); choice = CardFactoryUtil.getMostExpensivePermanentAI(list, af.getHostCard(), false);
} else { } else {
// TODO AI needs more improvement to it's retrieval (reuse // TODO AI needs more improvement to it's retrieval (reuse
// some code from spReturn here) // some code from spReturn here)

View File

@@ -954,11 +954,11 @@ public final class AbilityFactory_Combat {
} }
}); });
if (!list.isEmpty()) { if (!list.isEmpty()) {
final Card blocker = CardFactoryUtil.AI_getBestCreature(list); final Card blocker = CardFactoryUtil.getBestCreatureAI(list);
if (blocker == null) { if (blocker == null) {
return false; return false;
} }
abTgt.addTarget(CardFactoryUtil.AI_getBestCreature(list)); abTgt.addTarget(CardFactoryUtil.getBestCreatureAI(list));
chance = true; // TODO change this to true, once the human input chance = true; // TODO change this to true, once the human input
// takes mustblocks into account // takes mustblocks into account
} }

View File

@@ -277,9 +277,9 @@ public final class AbilityFactory_Copy {
Card choice; Card choice;
if (list.filter(CardListFilter.CREATURES).size() > 0) { if (list.filter(CardListFilter.CREATURES).size() > 0) {
choice = CardFactoryUtil.AI_getBestCreature(list); choice = CardFactoryUtil.getBestCreatureAI(list);
} else { } else {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(list, source, true); choice = CardFactoryUtil.getMostExpensivePermanentAI(list, source, true);
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left

View File

@@ -533,7 +533,7 @@ public class AbilityFactory_Counters {
else { else {
if (type.equals("M1M1")) { if (type.equals("M1M1")) {
choice = CardFactoryUtil.AI_getWorstCreature(list); choice = CardFactoryUtil.getWorstCreatureAI(list);
} else { } else {
choice = CardFactoryUtil.getRandomCard(list); choice = CardFactoryUtil.getRandomCard(list);
} }
@@ -545,7 +545,7 @@ public class AbilityFactory_Counters {
else { else {
if (type.equals("P1P1")) { if (type.equals("P1P1")) {
choice = CardFactoryUtil.AI_getWorstCreature(list); choice = CardFactoryUtil.getWorstCreatureAI(list);
} else { } else {
choice = CardFactoryUtil.getRandomCard(list); choice = CardFactoryUtil.getRandomCard(list);
} }
@@ -589,9 +589,9 @@ public class AbilityFactory_Counters {
} }
}); });
if (killable.size() > 0) { if (killable.size() > 0) {
choice = CardFactoryUtil.AI_getBestCreature(killable); choice = CardFactoryUtil.getBestCreatureAI(killable);
} else { } else {
choice = CardFactoryUtil.AI_getBestCreature(list); choice = CardFactoryUtil.getBestCreatureAI(list);
} }
} else { } else {
// improve random choice here // improve random choice here
@@ -614,7 +614,7 @@ public class AbilityFactory_Counters {
private static Card chooseBoonTarget(final CardList list, final String type) { private static Card chooseBoonTarget(final CardList list, final String type) {
Card choice; Card choice;
if (type.equals("P1P1")) { if (type.equals("P1P1")) {
choice = CardFactoryUtil.AI_getBestCreature(list); choice = CardFactoryUtil.getBestCreatureAI(list);
} else if (type.equals("DIVINITY")) { } else if (type.equals("DIVINITY")) {
final CardList boon = list.filter(new CardListFilter() { final CardList boon = list.filter(new CardListFilter() {
@Override @Override
@@ -622,7 +622,7 @@ public class AbilityFactory_Counters {
return c.getCounters(Counters.DIVINITY) == 0; return c.getCounters(Counters.DIVINITY) == 0;
} }
}); });
choice = CardFactoryUtil.AI_getMostExpensivePermanent(boon, null, false); choice = CardFactoryUtil.getMostExpensivePermanentAI(boon, null, false);
} else { } else {
// The AI really should put counters on cards that can use it. // The AI really should put counters on cards that can use it.
// Charge counters on things with Charge abilities, etc. Expand // Charge counters on things with Charge abilities, etc. Expand

View File

@@ -459,7 +459,7 @@ public class AbilityFactory_DealDamage {
Card targetCard; Card targetCard;
if (pl.isHuman() && (killables.size() > 0)) { if (pl.isHuman() && (killables.size() > 0)) {
targetCard = CardFactoryUtil.AI_getBestCreature(killables); targetCard = CardFactoryUtil.getBestCreatureAI(killables);
return targetCard; return targetCard;
} }
@@ -470,9 +470,9 @@ public class AbilityFactory_DealDamage {
if (hPlay.size() > 0) { if (hPlay.size() > 0) {
if (pl.isHuman()) { if (pl.isHuman()) {
targetCard = CardFactoryUtil.AI_getBestCreature(hPlay); targetCard = CardFactoryUtil.getBestCreatureAI(hPlay);
} else { } else {
targetCard = CardFactoryUtil.AI_getWorstCreature(hPlay); targetCard = CardFactoryUtil.getWorstCreatureAI(hPlay);
} }
return targetCard; return targetCard;

View File

@@ -377,7 +377,7 @@ public final class AbilityFactory_Debuff {
} }
} }
t = CardFactoryUtil.AI_getBestCreature(list); t = CardFactoryUtil.getBestCreatureAI(list);
tgt.addTarget(t); tgt.addTarget(t);
list.remove(t); list.remove(t);
} }
@@ -456,9 +456,9 @@ public final class AbilityFactory_Debuff {
Card c; Card c;
if (pref.getNotType("Creature").size() == 0) { if (pref.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getBestCreature(pref); c = CardFactoryUtil.getBestCreatureAI(pref);
} else { } else {
c = CardFactoryUtil.AI_getMostExpensivePermanent(pref, source, true); c = CardFactoryUtil.getMostExpensivePermanentAI(pref, source, true);
} }
pref.remove(c); pref.remove(c);
@@ -475,9 +475,9 @@ public final class AbilityFactory_Debuff {
// keyword // keyword
Card c; Card c;
if (forced.getNotType("Creature").size() == 0) { if (forced.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getWorstCreature(forced); c = CardFactoryUtil.getWorstCreatureAI(forced);
} else { } else {
c = CardFactoryUtil.AI_getCheapestPermanent(forced, source, true); c = CardFactoryUtil.getCheapestPermanentAI(forced, source, true);
} }
forced.remove(c); forced.remove(c);

View File

@@ -226,7 +226,7 @@ public class AbilityFactory_Destroy {
Card choice = null; Card choice = null;
if (list.getNotType("Creature").size() == 0) { if (list.getNotType("Creature").size() == 0) {
choice = CardFactoryUtil.AI_getBestCreature(list); // if the choice = CardFactoryUtil.getBestCreatureAI(list); // if the
// targets // targets
// are // are
// only // only
@@ -235,7 +235,7 @@ public class AbilityFactory_Destroy {
// the // the
// best // best
} else { } else {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(list, af.getHostCard(), true); choice = CardFactoryUtil.getMostExpensivePermanentAI(list, af.getHostCard(), true);
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
@@ -335,11 +335,11 @@ public class AbilityFactory_Destroy {
} else { } else {
Card c; Card c;
if (preferred.getNotType("Creature").size() == 0) { if (preferred.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getBestCreature(preferred); c = CardFactoryUtil.getBestCreatureAI(preferred);
} else if (preferred.getNotType("Land").size() == 0) { } else if (preferred.getNotType("Land").size() == 0) {
c = CardFactoryUtil.AI_getBestLand(preferred); c = CardFactoryUtil.getBestLandAI(preferred);
} else { } else {
c = CardFactoryUtil.AI_getMostExpensivePermanent(preferred, source, false); c = CardFactoryUtil.getMostExpensivePermanentAI(preferred, source, false);
} }
tgt.addTarget(c); tgt.addTarget(c);
preferred.remove(c); preferred.remove(c);
@@ -352,9 +352,9 @@ public class AbilityFactory_Destroy {
} else { } else {
Card c; Card c;
if (list.getNotType("Creature").size() == 0) { if (list.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getWorstCreature(list); c = CardFactoryUtil.getWorstCreatureAI(list);
} else { } else {
c = CardFactoryUtil.AI_getCheapestPermanent(list, source, false); c = CardFactoryUtil.getCheapestPermanentAI(list, source, false);
} }
tgt.addTarget(c); tgt.addTarget(c);
list.remove(c); list.remove(c);

View File

@@ -328,15 +328,15 @@ public class AbilityFactory_GainControl {
} }
if (hasCreature) { if (hasCreature) {
t = CardFactoryUtil.AI_getBestCreature(list); t = CardFactoryUtil.getBestCreatureAI(list);
} else if (hasArtifact) { } else if (hasArtifact) {
t = CardFactoryUtil.AI_getBestArtifact(list); t = CardFactoryUtil.getBestArtifactAI(list);
} else if (hasLand) { } else if (hasLand) {
t = CardFactoryUtil.AI_getBestLand(list); t = CardFactoryUtil.getBestLandAI(list);
} else if (hasEnchantment) { } else if (hasEnchantment) {
t = CardFactoryUtil.AI_getBestEnchantment(list, sa.getSourceCard(), true); t = CardFactoryUtil.getBestEnchantmentAI(list, sa.getSourceCard(), true);
} else { } else {
t = CardFactoryUtil.AI_getMostExpensivePermanent(list, sa.getSourceCard(), true); t = CardFactoryUtil.getMostExpensivePermanentAI(list, sa.getSourceCard(), true);
} }
tgt.addTarget(t); tgt.addTarget(t);

View File

@@ -375,14 +375,14 @@ public class AbilityFactory_PermanentState {
} }
if (untapList.getNotType("Creature").size() == 0) { if (untapList.getNotType("Creature").size() == 0) {
choice = CardFactoryUtil.AI_getBestCreature(untapList); // if choice = CardFactoryUtil.getBestCreatureAI(untapList); // if
// only // only
// creatures // creatures
// take // take
// the // the
// best // best
} else { } else {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(untapList, af.getHostCard(), false); choice = CardFactoryUtil.getMostExpensivePermanentAI(untapList, af.getHostCard(), false);
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
@@ -495,13 +495,13 @@ public class AbilityFactory_PermanentState {
} }
if (tapList.getNotType("Creature").size() == 0) { if (tapList.getNotType("Creature").size() == 0) {
choice = CardFactoryUtil.AI_getBestCreature(tapList); // if only choice = CardFactoryUtil.getBestCreatureAI(tapList); // if only
// creatures // creatures
// take // take
// the // the
// best // best
} else { } else {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(tapList, af.getHostCard(), false); choice = CardFactoryUtil.getMostExpensivePermanentAI(tapList, af.getHostCard(), false);
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
@@ -579,7 +579,7 @@ public class AbilityFactory_PermanentState {
for (final Player p : definedPlayers) { for (final Player p : definedPlayers) {
if (p.isHuman()) { if (p.isHuman()) {
AllZone.getInputControl().setInput(CardFactoryUtil.input_UntapUpToNType(num, valid)); AllZone.getInputControl().setInput(CardFactoryUtil.inputUntapUpToNType(num, valid));
} else { } else {
CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
list = list.getType(valid); list = list.getType(valid);
@@ -589,7 +589,7 @@ public class AbilityFactory_PermanentState {
while ((list.size() != 0) && (count < num)) { while ((list.size() != 0) && (count < num)) {
for (int i = 0; (i < list.size()) && (count < num); i++) { for (int i = 0; (i < list.size()) && (count < num); i++) {
final Card c = CardFactoryUtil.AI_getBestLand(list); final Card c = CardFactoryUtil.getBestLandAI(list);
c.untap(); c.untap();
list.remove(c); list.remove(c);
count++; count++;
@@ -944,13 +944,13 @@ public class AbilityFactory_PermanentState {
} }
if (tapList.getNotType("Creature").size() == 0) { if (tapList.getNotType("Creature").size() == 0) {
choice = CardFactoryUtil.AI_getBestCreature(tapList); // if only choice = CardFactoryUtil.getBestCreatureAI(tapList); // if only
// creatures // creatures
// take // take
// the // the
// best // best
} else { } else {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(tapList, af.getHostCard(), false); choice = CardFactoryUtil.getMostExpensivePermanentAI(tapList, af.getHostCard(), false);
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left
@@ -1064,13 +1064,13 @@ public class AbilityFactory_PermanentState {
} }
if (tapList.getNotType("Creature").size() == 0) { if (tapList.getNotType("Creature").size() == 0) {
choice = CardFactoryUtil.AI_getBestCreature(tapList); // if only choice = CardFactoryUtil.getBestCreatureAI(tapList); // if only
// creatures // creatures
// take // take
// the // the
// best // best
} else { } else {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(tapList, af.getHostCard(), false); choice = CardFactoryUtil.getMostExpensivePermanentAI(tapList, af.getHostCard(), false);
} }
if (choice == null) { // can't find anything left if (choice == null) { // can't find anything left

View File

@@ -313,7 +313,7 @@ public class AbilityFactory_PreventDamage {
if (!threatenedTargets.isEmpty()) { if (!threatenedTargets.isEmpty()) {
// Choose "best" of the remaining to save // Choose "best" of the remaining to save
tgt.addTarget(CardFactoryUtil.AI_getBestCreature(threatenedTargets)); tgt.addTarget(CardFactoryUtil.getBestCreatureAI(threatenedTargets));
chance = true; chance = true;
} }
@@ -439,7 +439,7 @@ public class AbilityFactory_PreventDamage {
return true; return true;
} }
tgt.addTarget(CardFactoryUtil.AI_getCheapestPermanent(targetables, hostCard, true)); tgt.addTarget(CardFactoryUtil.getCheapestPermanentAI(targetables, hostCard, true));
return true; return true;
} }

View File

@@ -214,7 +214,7 @@ public final class AbilityFactory_Protection {
} }
// will the creature attack (only relevant for sorcery speed)? // will the creature attack (only relevant for sorcery speed)?
if (CardFactoryUtil.AI_doesCreatureAttack(c) if (CardFactoryUtil.doesCreatureAttackAI(c)
&& AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS) && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
&& AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) { && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
return true; return true;
@@ -387,7 +387,7 @@ public final class AbilityFactory_Protection {
} }
} }
t = CardFactoryUtil.AI_getBestCreature(list); t = CardFactoryUtil.getBestCreatureAI(list);
tgt.addTarget(t); tgt.addTarget(t);
list.remove(t); list.remove(t);
} }
@@ -453,9 +453,9 @@ public final class AbilityFactory_Protection {
Card c; Card c;
if (pref.getNotType("Creature").size() == 0) { if (pref.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getBestCreature(pref); c = CardFactoryUtil.getBestCreatureAI(pref);
} else { } else {
c = CardFactoryUtil.AI_getMostExpensivePermanent(pref, source, true); c = CardFactoryUtil.getMostExpensivePermanentAI(pref, source, true);
} }
pref.remove(c); pref.remove(c);
@@ -470,9 +470,9 @@ public final class AbilityFactory_Protection {
Card c; Card c;
if (pref2.getNotType("Creature").size() == 0) { if (pref2.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getBestCreature(pref2); c = CardFactoryUtil.getBestCreatureAI(pref2);
} else { } else {
c = CardFactoryUtil.AI_getMostExpensivePermanent(pref2, source, true); c = CardFactoryUtil.getMostExpensivePermanentAI(pref2, source, true);
} }
pref2.remove(c); pref2.remove(c);
@@ -487,9 +487,9 @@ public final class AbilityFactory_Protection {
Card c; Card c;
if (forced.getNotType("Creature").size() == 0) { if (forced.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getWorstCreature(forced); c = CardFactoryUtil.getWorstCreatureAI(forced);
} else { } else {
c = CardFactoryUtil.AI_getCheapestPermanent(forced, source, true); c = CardFactoryUtil.getCheapestPermanentAI(forced, source, true);
} }
forced.remove(c); forced.remove(c);

View File

@@ -274,7 +274,7 @@ public class AbilityFactory_Pump {
} }
// will the creature attack (only relevant for sorcery speed)? // will the creature attack (only relevant for sorcery speed)?
if (CardFactoryUtil.AI_doesCreatureAttack(c) if (CardFactoryUtil.doesCreatureAttackAI(c)
&& AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS) && AllZone.getPhase().isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS)
&& AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) { && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) {
return true; return true;
@@ -496,7 +496,7 @@ public class AbilityFactory_Pump {
} else if (this.hostCard.equals(card)) { } else if (this.hostCard.equals(card)) {
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
if (r.nextFloat() <= Math.pow(.6667, activations)) { if (r.nextFloat() <= Math.pow(.6667, activations)) {
return CardFactoryUtil.AI_doesCreatureAttack(card) && !sa.getPayCosts().getTap(); return CardFactoryUtil.doesCreatureAttackAI(card) && !sa.getPayCosts().getTap();
} }
} else { } else {
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
@@ -580,7 +580,7 @@ public class AbilityFactory_Pump {
} }
} }
t = CardFactoryUtil.AI_getBestCreature(list); t = CardFactoryUtil.getBestCreatureAI(list);
tgt.addTarget(t); tgt.addTarget(t);
list.remove(t); list.remove(t);
} }
@@ -635,9 +635,9 @@ public class AbilityFactory_Pump {
Card c; Card c;
if (pref.getNotType("Creature").size() == 0) { if (pref.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getBestCreature(pref); c = CardFactoryUtil.getBestCreatureAI(pref);
} else { } else {
c = CardFactoryUtil.AI_getMostExpensivePermanent(pref, source, true); c = CardFactoryUtil.getMostExpensivePermanentAI(pref, source, true);
} }
pref.remove(c); pref.remove(c);
@@ -652,9 +652,9 @@ public class AbilityFactory_Pump {
Card c; Card c;
if (forced.getNotType("Creature").size() == 0) { if (forced.getNotType("Creature").size() == 0) {
c = CardFactoryUtil.AI_getWorstCreature(forced); c = CardFactoryUtil.getWorstCreatureAI(forced);
} else { } else {
c = CardFactoryUtil.AI_getCheapestPermanent(forced, source, true); c = CardFactoryUtil.getCheapestPermanentAI(forced, source, true);
} }
forced.remove(c); forced.remove(c);

View File

@@ -293,7 +293,7 @@ public class AbilityFactory_Regenerate {
if (!threatenedTargets.isEmpty()) { if (!threatenedTargets.isEmpty()) {
// Choose "best" of the remaining to regenerate // Choose "best" of the remaining to regenerate
tgt.addTarget(CardFactoryUtil.AI_getBestCreature(threatenedTargets)); tgt.addTarget(CardFactoryUtil.getBestCreatureAI(threatenedTargets));
chance = true; chance = true;
} }
} else { } else {
@@ -424,7 +424,7 @@ public class AbilityFactory_Regenerate {
} }
} }
tgt.addTarget(CardFactoryUtil.AI_getCheapestPermanent(targetables, hostCard, true)); tgt.addTarget(CardFactoryUtil.getCheapestPermanentAI(targetables, hostCard, true));
return true; return true;
} }

View File

@@ -1078,7 +1078,6 @@ public class AbilityFactory_ZoneAffecting {
private static void discardResolve(final AbilityFactory af, final SpellAbility sa) { private static void discardResolve(final AbilityFactory af, final SpellAbility sa) {
final Card source = sa.getSourceCard(); final Card source = sa.getSourceCard();
final HashMap<String, String> params = af.getMapParams(); final HashMap<String, String> params = af.getMapParams();
final String mode = params.get("Mode"); final String mode = params.get("Mode");
ArrayList<Player> tgtPlayers; ArrayList<Player> tgtPlayers;
@@ -1138,7 +1137,6 @@ public class AbilityFactory_ZoneAffecting {
} }
final CardList dPChHand = dPHand.getValidCards(valid.split(","), source.getController(), source); final CardList dPChHand = dPHand.getValidCards(valid.split(","), source.getController(), source);
// Reveal cards that will be discarded? // Reveal cards that will be discarded?
for (final Card c : dPChHand) { for (final Card c : dPChHand) {
p.discard(c, sa); p.discard(c, sa);
@@ -1172,9 +1170,9 @@ public class AbilityFactory_ZoneAffecting {
if (params.containsKey("DiscardValid")) { if (params.containsKey("DiscardValid")) {
final String dValid = params.get("DiscardValid"); final String dValid = params.get("DiscardValid");
if (dValid.contains("Creature") && !dValid.contains("nonCreature")) { if (dValid.contains("Creature") && !dValid.contains("nonCreature")) {
final Card c = CardFactoryUtil.AI_getBestCreature(dPChHand); final Card c = CardFactoryUtil.getBestCreatureAI(dPChHand);
if (c != null) { if (c != null) {
dChoices.add(CardFactoryUtil.AI_getBestCreature(dPChHand)); dChoices.add(CardFactoryUtil.getBestCreatureAI(dPChHand));
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,7 @@ public interface CardFactoryInterface extends Iterable<Card> {
* *
* @return an Iterator that does NOT support the remove method * @return an Iterator that does NOT support the remove method
*/ */
@Override
Iterator<Card> iterator(); Iterator<Card> iterator();
/** /**

View File

@@ -76,7 +76,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getMostExpensivePermanent(final CardList list, final Card spell, final boolean targeted) { public static Card getMostExpensivePermanentAI(final CardList list, final Card spell, final boolean targeted) {
CardList all = list; CardList all = list;
if (targeted) { if (targeted) {
all = all.filter(new CardListFilter() { all = all.filter(new CardListFilter() {
@@ -87,7 +87,7 @@ public class CardFactoryUtil {
}); });
} }
return CardFactoryUtil.AI_getMostExpensivePermanent(all); return CardFactoryUtil.getMostExpensivePermanentAI(all);
} }
/** /**
@@ -97,7 +97,7 @@ public class CardFactoryUtil {
* the all * the all
* @return the card * @return the card
*/ */
public static Card AI_getMostExpensivePermanent(final CardList all) { public static Card getMostExpensivePermanentAI(final CardList all) {
if (all.size() == 0) { if (all.size() == 0) {
return null; return null;
} }
@@ -137,14 +137,14 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getCheapestCreature(CardList list, final Card spell, final boolean targeted) { public static Card getCheapestCreatureAI(CardList list, final Card spell, final boolean targeted) {
list = list.filter(new CardListFilter() { list = list.filter(new CardListFilter() {
@Override @Override
public boolean addCard(final Card c) { public boolean addCard(final Card c) {
return c.isCreature(); return c.isCreature();
} }
}); });
return CardFactoryUtil.AI_getCheapestPermanent(list, spell, targeted); return CardFactoryUtil.getCheapestPermanentAI(list, spell, targeted);
} }
/** /**
@@ -160,7 +160,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getCheapestPermanent(final CardList list, final Card spell, final boolean targeted) { public static Card getCheapestPermanentAI(final CardList list, final Card spell, final boolean targeted) {
CardList all = list; CardList all = list;
if (targeted) { if (targeted) {
all = all.filter(new CardListFilter() { all = all.filter(new CardListFilter() {
@@ -198,7 +198,7 @@ public class CardFactoryUtil {
* a {@link forge.CardList} object. * a {@link forge.CardList} object.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getBestLand(final CardList list) { public static Card getBestLandAI(final CardList list) {
final CardList land = list.getType("Land"); final CardList land = list.getType("Land");
if (!(land.size() > 0)) { if (!(land.size() > 0)) {
return null; return null;
@@ -266,7 +266,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getBestEnchantment(final CardList list, final Card spell, final boolean targeted) { public static Card getBestEnchantmentAI(final CardList list, final Card spell, final boolean targeted) {
CardList all = list; CardList all = list;
all = all.getType("Enchantment"); all = all.getType("Enchantment");
if (targeted) { if (targeted) {
@@ -309,7 +309,7 @@ public class CardFactoryUtil {
* a {@link forge.CardList} object. * a {@link forge.CardList} object.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getBestArtifact(final CardList list) { public static Card getBestArtifactAI(final CardList list) {
CardList all = list; CardList all = list;
all = all.getType("Artifact"); all = all.getType("Artifact");
if (all.size() == 0) { if (all.size() == 0) {
@@ -344,7 +344,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList AI_getHumanArtifact(final Card spell, final boolean targeted) { public static CardList getHumanArtifactAI(final Card spell, final boolean targeted) {
CardList artifact = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); CardList artifact = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
artifact = artifact.getType("Artifact"); artifact = artifact.getType("Artifact");
if (targeted) { if (targeted) {
@@ -367,7 +367,7 @@ public class CardFactoryUtil {
* a {@link forge.Card} object. * a {@link forge.Card} object.
* @return a boolean. * @return a boolean.
*/ */
public static boolean AI_doesCreatureAttack(final Card card) { public static boolean doesCreatureAttackAI(final Card card) {
final Combat combat = ComputerUtil.getAttackers(); final Combat combat = ComputerUtil.getAttackers();
final Card[] att = combat.getAttackers(); final Card[] att = combat.getAttackers();
for (final Card element : att) { for (final Card element : att) {
@@ -626,20 +626,20 @@ public class CardFactoryUtil {
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getBest(final CardList list) { public static Card getBestAI(final CardList list) {
// Get Best will filter by appropriate getBest list if ALL of the list // Get Best will filter by appropriate getBest list if ALL of the list
// is of that type // is of that type
if (list.getNotType("Creature").size() == 0) { if (list.getNotType("Creature").size() == 0) {
return CardFactoryUtil.AI_getBestCreature(list); return CardFactoryUtil.getBestCreatureAI(list);
} }
if (list.getNotType("Land").size() == 0) { if (list.getNotType("Land").size() == 0) {
return CardFactoryUtil.AI_getBestLand(list); return CardFactoryUtil.getBestLandAI(list);
} }
// TODO - Once we get an EvaluatePermanent this should call // TODO - Once we get an EvaluatePermanent this should call
// getBestPermanent() // getBestPermanent()
return CardFactoryUtil.AI_getMostExpensivePermanent(list); return CardFactoryUtil.getMostExpensivePermanentAI(list);
} }
/** /**
@@ -649,7 +649,7 @@ public class CardFactoryUtil {
* the list * the list
* @return the card * @return the card
*/ */
public static Card AI_getBestCreature(final CardList list) { public static Card getBestCreatureAI(final CardList list) {
CardList all = list; CardList all = list;
all = all.getType("Creature"); all = all.getType("Creature");
Card biggest = null; Card biggest = null;
@@ -676,7 +676,7 @@ public class CardFactoryUtil {
* a {@link forge.CardList} object. * a {@link forge.CardList} object.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getBestCreatureToBounce(final CardList list) { public static Card getBestCreatureToBounceAI(final CardList list) {
final int tokenBonus = 40; final int tokenBonus = 40;
CardList all = list; CardList all = list;
all = all.getType("Creature"); all = all.getType("Creature");
@@ -714,7 +714,7 @@ public class CardFactoryUtil {
* a {@link forge.CardList} object. * a {@link forge.CardList} object.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getWorstCreature(final CardList list) { public static Card getWorstCreatureAI(final CardList list) {
CardList all = list; CardList all = list;
all = all.getType("Creature"); all = all.getType("Creature");
// get smallest creature // get smallest creature
@@ -749,18 +749,18 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card AI_getWorstPermanent(final CardList list, final boolean biasEnch, final boolean biasLand, public static Card getWorstPermanentAI(final CardList list, final boolean biasEnch, final boolean biasLand,
final boolean biasArt, final boolean biasCreature) { final boolean biasArt, final boolean biasCreature) {
if (list.size() == 0) { if (list.size() == 0) {
return null; return null;
} }
if (biasEnch && (list.getType("Enchantment").size() > 0)) { if (biasEnch && (list.getType("Enchantment").size() > 0)) {
return CardFactoryUtil.AI_getCheapestPermanent(list.getType("Enchantment"), null, false); return CardFactoryUtil.getCheapestPermanentAI(list.getType("Enchantment"), null, false);
} }
if (biasArt && (list.getType("Artifact").size() > 0)) { if (biasArt && (list.getType("Artifact").size() > 0)) {
return CardFactoryUtil.AI_getCheapestPermanent(list.getType("Artifact"), null, false); return CardFactoryUtil.getCheapestPermanentAI(list.getType("Artifact"), null, false);
} }
if (biasLand && (list.getType("Land").size() > 0)) { if (biasLand && (list.getType("Land").size() > 0)) {
@@ -768,7 +768,7 @@ public class CardFactoryUtil {
} }
if (biasCreature && (list.getType("Creature").size() > 0)) { if (biasCreature && (list.getType("Creature").size() > 0)) {
return CardFactoryUtil.AI_getWorstCreature(list.getType("Creature")); return CardFactoryUtil.getWorstCreatureAI(list.getType("Creature"));
} }
if (list.getType("Land").size() > 6) { if (list.getType("Land").size() > 6) {
@@ -776,7 +776,7 @@ public class CardFactoryUtil {
} }
if ((list.getType("Artifact").size() > 0) || (list.getType("Enchantment").size() > 0)) { if ((list.getType("Artifact").size() > 0) || (list.getType("Enchantment").size() > 0)) {
return CardFactoryUtil.AI_getCheapestPermanent(list.filter(new CardListFilter() { return CardFactoryUtil.getCheapestPermanentAI(list.filter(new CardListFilter() {
@Override @Override
public boolean addCard(final Card c) { public boolean addCard(final Card c) {
return c.isArtifact() || c.isEnchantment(); return c.isArtifact() || c.isEnchantment();
@@ -785,12 +785,12 @@ public class CardFactoryUtil {
} }
if (list.getType("Creature").size() > 0) { if (list.getType("Creature").size() > 0) {
return CardFactoryUtil.AI_getWorstCreature(list.getType("Creature")); return CardFactoryUtil.getWorstCreatureAI(list.getType("Creature"));
} }
// Planeswalkers fall through to here, lands will fall through if there // Planeswalkers fall through to here, lands will fall through if there
// aren't very many // aren't very many
return CardFactoryUtil.AI_getCheapestPermanent(list, null, false); return CardFactoryUtil.getCheapestPermanentAI(list, null, false);
} }
/** /**
@@ -806,7 +806,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input input_Spell(final SpellAbility spell, final CardList choices, final boolean free) { public static Input inputSpell(final SpellAbility spell, final CardList choices, final boolean free) {
final Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = 2781418414287281005L; private static final long serialVersionUID = 2781418414287281005L;
@@ -860,7 +860,7 @@ public class CardFactoryUtil {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input input_destroyNoRegeneration(final CardList choices, final String message) { public static Input inputDestroyNoRegeneration(final CardList choices, final String message) {
final Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = -6637588517573573232L; private static final long serialVersionUID = -6637588517573573232L;
@@ -1058,7 +1058,7 @@ public class CardFactoryUtil {
final int attack = a; final int attack = a;
final int defense = d; final int defense = d;
final String origManaCost = orgManaCost; final String origManaCost = orgManaCost;
final Ability_Activated morph_up = new Ability_Activated(sourceCard, cost, null) { final Ability_Activated morphUp = new Ability_Activated(sourceCard, cost, null) {
private static final long serialVersionUID = -3663857013937085953L; private static final long serialVersionUID = -3663857013937085953L;
@Override @Override
@@ -1098,13 +1098,13 @@ public class CardFactoryUtil {
sb.append(" -"); sb.append(" -");
} }
sb.append(" ").append(costDesc).append(" (Turn this face up any time for its morph cost.)"); sb.append(" ").append(costDesc).append(" (Turn this face up any time for its morph cost.)");
morph_up.setDescription(sb.toString()); morphUp.setDescription(sb.toString());
final StringBuilder sbStack = new StringBuilder(); final StringBuilder sbStack = new StringBuilder();
sbStack.append(sourceCard.getName()).append(" - turn this card face up."); sbStack.append(sourceCard.getName()).append(" - turn this card face up.");
morph_up.setStackDescription(sbStack.toString()); morphUp.setStackDescription(sbStack.toString());
return morph_up; return morphUp;
} }
/** /**
@@ -1347,8 +1347,7 @@ public class CardFactoryUtil {
* a int. * a int.
* @return a {@link forge.card.spellability.SpellAbility} object. * @return a {@link forge.card.spellability.SpellAbility} object.
*/ */
public static SpellAbility abilitySuspend(final Card sourceCard, final String suspendCost, public static SpellAbility abilitySuspend(final Card sourceCard, final String suspendCost, final int suspendCounters) {
final int suspendCounters) {
// be careful with Suspend ability, it will not hit the stack // be careful with Suspend ability, it will not hit the stack
final SpellAbility suspend = new Ability_Static(sourceCard, suspendCost) { final SpellAbility suspend = new Ability_Static(sourceCard, suspendCost) {
@Override @Override
@@ -1406,7 +1405,7 @@ public class CardFactoryUtil {
* a {@link forge.card.cost.Cost} object. * a {@link forge.card.cost.Cost} object.
* @return a {@link forge.card.spellability.SpellAbility} object. * @return a {@link forge.card.spellability.SpellAbility} object.
*/ */
public static SpellAbility eqPump_Equip(final Card sourceCard, final int power, final int tough, public static SpellAbility eqPumpEquip(final Card sourceCard, final int power, final int tough,
final String[] extrinsicKeywords, final Cost abCost) { final String[] extrinsicKeywords, final Cost abCost) {
final Target target = new Target(sourceCard, "Select target creature you control", final Target target = new Target(sourceCard, "Select target creature you control",
"Creature.YouCtrl".split(",")); "Creature.YouCtrl".split(","));
@@ -1443,7 +1442,7 @@ public class CardFactoryUtil {
@Override @Override
public void chooseTargetAI() { public void chooseTargetAI() {
final Card target = CardFactoryUtil.AI_getBestCreature(this.getCreature()); final Card target = CardFactoryUtil.getBestCreatureAI(this.getCreature());
this.setTargetCard(target); this.setTargetCard(target);
} }
@@ -1524,7 +1523,7 @@ public class CardFactoryUtil {
* a {@link forge.card.cost.Cost} object. * a {@link forge.card.cost.Cost} object.
* @return a {@link forge.Command} object. * @return a {@link forge.Command} object.
*/ */
public static Command eqPump_onEquip(final Card sourceCard, final int power, final int tough, public static Command eqPumpOnEquip(final Card sourceCard, final int power, final int tough,
final String[] extrinsicKeywords, final Cost abCost) { final String[] extrinsicKeywords, final Cost abCost) {
final Command onEquip = new Command() { final Command onEquip = new Command() {
@@ -1569,7 +1568,7 @@ public class CardFactoryUtil {
* a {@link forge.card.cost.Cost} object. * a {@link forge.card.cost.Cost} object.
* @return a {@link forge.Command} object. * @return a {@link forge.Command} object.
*/ */
public static Command eqPump_unEquip(final Card sourceCard, final int power, final int tough, public static Command eqPumpUnEquip(final Card sourceCard, final int power, final int tough,
final String[] extrinsicKeywords, final Cost abCost) { final String[] extrinsicKeywords, final Cost abCost) {
final Command onUnEquip = new Command() { final Command onUnEquip = new Command() {
@@ -1653,7 +1652,7 @@ public class CardFactoryUtil {
public static Command fading(final Card sourceCard, final int power) { public static Command fading(final Card sourceCard, final int power) {
final Command fade = new Command() { final Command fade = new Command() {
private static final long serialVersionUID = 431920157968451817L; private static final long serialVersionUID = 431920157968451817L;
public boolean firstTime = true; private boolean firstTime = true;
@Override @Override
public void execute() { public void execute() {
@@ -1682,7 +1681,7 @@ public class CardFactoryUtil {
public static Command vanishing(final Card sourceCard, final int power) { public static Command vanishing(final Card sourceCard, final int power) {
final Command age = new Command() { final Command age = new Command() {
private static final long serialVersionUID = 431920157968451817L; private static final long serialVersionUID = 431920157968451817L;
public boolean firstTime = true; private boolean firstTime = true;
@Override @Override
public void execute() { public void execute() {
@@ -1810,9 +1809,9 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input input_targetSpecific(final SpellAbility spell, final CardList choices, final String message, public static Input inputTargetSpecific(final SpellAbility spell, final CardList choices, final String message,
final boolean targeted, final boolean free) { final boolean targeted, final boolean free) {
return CardFactoryUtil.input_targetSpecific(spell, choices, message, Command.BLANK, targeted, free); return CardFactoryUtil.inputTargetSpecific(spell, choices, message, Command.BLANK, targeted, free);
} }
// CardList choices are the only cards the user can successful select // CardList choices are the only cards the user can successful select
@@ -1835,7 +1834,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input input_targetSpecific(final SpellAbility spell, final CardList choices, final String message, public static Input inputTargetSpecific(final SpellAbility spell, final CardList choices, final String message,
final Command paid, final boolean targeted, final boolean free) { final Command paid, final boolean targeted, final boolean free) {
final Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = -1779224307654698954L; private static final long serialVersionUID = -1779224307654698954L;
@@ -1892,7 +1891,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input input_targetChampionSac(final Card crd, final SpellAbility spell, final CardList choices, public static Input inputTargetChampionSac(final Card crd, final SpellAbility spell, final CardList choices,
final String message, final boolean targeted, final boolean free) { final String message, final boolean targeted, final boolean free) {
final Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = -3320425330743678663L; private static final long serialVersionUID = -3320425330743678663L;
@@ -1942,7 +1941,7 @@ public class CardFactoryUtil {
* a {@link forge.card.spellability.SpellAbility} object. * a {@link forge.card.spellability.SpellAbility} object.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input input_equipCreature(final SpellAbility equip) { public static Input inputEquipCreature(final SpellAbility equip) {
final Input runtime = new Input() { final Input runtime = new Input() {
private static final long serialVersionUID = 2029801495067540196L; private static final long serialVersionUID = 2029801495067540196L;
@@ -1951,7 +1950,7 @@ public class CardFactoryUtil {
// get all creatures you control // get all creatures you control
final CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); final CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
this.stopSetNext(CardFactoryUtil.input_targetSpecific(equip, list, "Select target creature to equip", this.stopSetNext(CardFactoryUtil.inputTargetSpecific(equip, list, "Select target creature to equip",
true, false)); true, false));
} }
}; // Input }; // Input
@@ -1969,10 +1968,10 @@ public class CardFactoryUtil {
* a {@link forge.card.spellability.SpellAbility} object. * a {@link forge.card.spellability.SpellAbility} object.
* @return input * @return input
*/ */
public static Input input_discardRecall(final int numCards, final Card recall, final SpellAbility sa) { public static Input inputDiscardRecall(final int numCards, final Card recall, final SpellAbility sa) {
final Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = 1942999595292561944L; private static final long serialVersionUID = 1942999595292561944L;
int n = 0; private int n = 0;
@Override @Override
public void showMessage() { public void showMessage() {
@@ -2032,7 +2031,7 @@ public class CardFactoryUtil {
* a {@link forge.Command} object. * a {@link forge.Command} object.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input MasteroftheWildHunt_input_targetCreature(final SpellAbility spell, final CardList choices, public static Input masterOfTheWildHuntInputTargetCreature(final SpellAbility spell, final CardList choices,
final Command paid) { final Command paid) {
final Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = -1779224307654698954L; private static final long serialVersionUID = -1779224307654698954L;
@@ -2116,7 +2115,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList AI_getHumanCreature(final Card spell, final boolean targeted) { public static CardList getHumanCreatureAI(final Card spell, final boolean targeted) {
CardList creature = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); CardList creature = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
if (targeted) { if (targeted) {
creature = creature.getTargetableCards(spell); creature = creature.getTargetableCards(spell);
@@ -2137,7 +2136,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList AI_getHumanCreature(final String keyword, final Card spell, final boolean targeted) { public static CardList getHumanCreatureAI(final String keyword, final Card spell, final boolean targeted) {
CardList creature = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); CardList creature = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
creature = creature.filter(new CardListFilter() { creature = creature.filter(new CardListFilter() {
@Override @Override
@@ -2165,7 +2164,7 @@ public class CardFactoryUtil {
* a boolean. * a boolean.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList AI_getHumanCreature(final int toughness, final Card spell, final boolean targeted) { public static CardList getHumanCreatureAI(final int toughness, final Card spell, final boolean targeted) {
CardList creature = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); CardList creature = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
creature = creature.filter(new CardListFilter() { creature = creature.filter(new CardListFilter() {
@Override @Override
@@ -2187,7 +2186,7 @@ public class CardFactoryUtil {
* *
* @return a {@link forge.CommandArgs} object. * @return a {@link forge.CommandArgs} object.
*/ */
public static CommandArgs AI_targetHuman() { public static CommandArgs targetHumanAI() {
return new CommandArgs() { return new CommandArgs() {
private static final long serialVersionUID = 8406907523134006697L; private static final long serialVersionUID = 8406907523134006697L;
@@ -3236,81 +3235,81 @@ public class CardFactoryUtil {
// if a card was ever written to count two different zones, // if a card was ever written to count two different zones,
// make sure they don't get added twice. // make sure they don't get added twice.
boolean MF = false, MY = false, MH = false; boolean mf = false, my = false, mh = false;
boolean OF = false, OY = false, OH = false; boolean of = false, oy = false, oh = false;
if (sq[0].contains("YouCtrl")) { if (sq[0].contains("YouCtrl")) {
if (!MF) { if (!mf) {
someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); someCards.addAll(cardController.getCardsIn(Zone.Battlefield));
MF = true; mf = true;
} }
} }
if (sq[0].contains("InYourYard")) { if (sq[0].contains("InYourYard")) {
if (!MY) { if (!my) {
someCards.addAll(cardController.getCardsIn(Zone.Graveyard)); someCards.addAll(cardController.getCardsIn(Zone.Graveyard));
MY = true; my = true;
} }
} }
if (sq[0].contains("InYourLibrary")) { if (sq[0].contains("InYourLibrary")) {
if (!MY) { if (!my) {
someCards.addAll(cardController.getCardsIn(Zone.Library)); someCards.addAll(cardController.getCardsIn(Zone.Library));
MY = true; my = true;
} }
} }
if (sq[0].contains("InYourHand")) { if (sq[0].contains("InYourHand")) {
if (!MH) { if (!mh) {
someCards.addAll(cardController.getCardsIn(Zone.Hand)); someCards.addAll(cardController.getCardsIn(Zone.Hand));
MH = true; mh = true;
} }
} }
if (sq[0].contains("OppCtrl")) { if (sq[0].contains("OppCtrl")) {
if (!OF) { if (!of) {
someCards.addAll(oppController.getCardsIn(Zone.Battlefield)); someCards.addAll(oppController.getCardsIn(Zone.Battlefield));
OF = true; of = true;
} }
} }
if (sq[0].contains("InOppYard")) { if (sq[0].contains("InOppYard")) {
if (!OY) { if (!oy) {
someCards.addAll(oppController.getCardsIn(Zone.Graveyard)); someCards.addAll(oppController.getCardsIn(Zone.Graveyard));
OY = true; oy = true;
} }
} }
if (sq[0].contains("InOppHand")) { if (sq[0].contains("InOppHand")) {
if (!OH) { if (!oh) {
someCards.addAll(oppController.getCardsIn(Zone.Hand)); someCards.addAll(oppController.getCardsIn(Zone.Hand));
OH = true; oh = true;
} }
} }
if (sq[0].contains("OnBattlefield")) { if (sq[0].contains("OnBattlefield")) {
if (!MF) { if (!mf) {
someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); someCards.addAll(cardController.getCardsIn(Zone.Battlefield));
} }
if (!OF) { if (!of) {
someCards.addAll(oppController.getCardsIn(Zone.Battlefield)); someCards.addAll(oppController.getCardsIn(Zone.Battlefield));
} }
} }
if (sq[0].contains("InAllYards")) { if (sq[0].contains("InAllYards")) {
if (!MY) { if (!my) {
someCards.addAll(cardController.getCardsIn(Zone.Graveyard)); someCards.addAll(cardController.getCardsIn(Zone.Graveyard));
} }
if (!OY) { if (!oy) {
someCards.addAll(oppController.getCardsIn(Zone.Graveyard)); someCards.addAll(oppController.getCardsIn(Zone.Graveyard));
} }
} }
if (sq[0].contains("InAllHands")) { if (sq[0].contains("InAllHands")) {
if (!MH) { if (!mh) {
someCards.addAll(cardController.getCardsIn(Zone.Hand)); someCards.addAll(cardController.getCardsIn(Zone.Hand));
} }
if (!OH) { if (!oh) {
someCards.addAll(oppController.getCardsIn(Zone.Hand)); someCards.addAll(oppController.getCardsIn(Zone.Hand));
} }
} }
@@ -3552,12 +3551,12 @@ public class CardFactoryUtil {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public static Input input_UntapUpToNType(final int n, final String type) { public static Input inputUntapUpToNType(final int n, final String type) {
final Input untap = new Input() { final Input untap = new Input() {
private static final long serialVersionUID = -2167059918040912025L; private static final long serialVersionUID = -2167059918040912025L;
int stop = n; private int stop = n;
int count = 0; private int count = 0;
@Override @Override
public void showMessage() { public void showMessage() {
@@ -3939,8 +3938,7 @@ public class CardFactoryUtil {
final Card c = ability.getSourceCard(); final Card c = ability.getSourceCard();
if ((target != null) && c.getText().contains("deals X damage to target") if ((target != null) && c.getText().contains("deals X damage to target") && !c.getName().equals("Death Grasp")) {
&& !c.getName().equals("Death Grasp")) {
neededDamage = target.getNetDefense() - target.getDamage(); neededDamage = target.getNetDefense() - target.getDamage();
} }
@@ -4285,31 +4283,31 @@ public class CardFactoryUtil {
/** /**
* Copy characteristics. * Copy characteristics.
* *
* @param From * @param from
* the from * the from
* @param To * @param to
* the to * the to
*/ */
public static void copyCharacteristics(final Card From, final Card To) { public static void copyCharacteristics(final Card from, final Card to) {
To.setBaseAttack(From.getBaseAttack()); to.setBaseAttack(from.getBaseAttack());
To.setBaseDefense(From.getBaseDefense()); to.setBaseDefense(from.getBaseDefense());
To.setBaseLoyalty(From.getBaseLoyalty()); to.setBaseLoyalty(from.getBaseLoyalty());
To.setBaseAttackString(From.getBaseAttackString()); to.setBaseAttackString(from.getBaseAttackString());
To.setBaseDefenseString(From.getBaseDefenseString()); to.setBaseDefenseString(from.getBaseDefenseString());
To.setIntrinsicKeyword(From.getIntrinsicKeyword()); to.setIntrinsicKeyword(from.getIntrinsicKeyword());
To.setName(From.getName()); to.setName(from.getName());
To.setType(From.getCharacteristics().getType()); to.setType(from.getCharacteristics().getType());
To.setText(From.getSpellText()); to.setText(from.getSpellText());
To.setManaCost(From.getManaCost()); to.setManaCost(from.getManaCost());
To.setColor(From.getColor()); to.setColor(from.getColor());
To.setSVars(From.getSVars()); to.setSVars(from.getSVars());
To.setSets(From.getSets()); to.setSets(from.getSets());
To.setIntrinsicAbilities(From.getIntrinsicAbilities()); to.setIntrinsicAbilities(from.getIntrinsicAbilities());
To.setImageName(From.getImageName()); to.setImageName(from.getImageName());
To.setImageFilename(From.getImageFilename()); to.setImageFilename(from.getImageFilename());
To.setTriggers(From.getTriggers()); to.setTriggers(from.getTriggers());
To.setStaticAbilityStrings(From.getStaticAbilityStrings()); to.setStaticAbilityStrings(from.getStaticAbilityStrings());
} }
@@ -4772,14 +4770,14 @@ public class CardFactoryUtil {
+ "ValidCard$ Card.Self | Static$ True | Secondary$ True | TriggerDescription$ Blank", + "ValidCard$ Card.Self | Static$ True | Secondary$ True | TriggerDescription$ Blank",
card, true); card, true);
final Ability haunterDies_Work = new Ability(card, "0") { final Ability haunterDiesWork = new Ability(card, "0") {
@Override @Override
public void resolve() { public void resolve() {
this.getTargetCard().addHauntedBy(card); this.getTargetCard().addHauntedBy(card);
AllZone.getGameAction().exile(card); AllZone.getGameAction().exile(card);
} }
}; };
haunterDies_Work.setDescription(hauntDescription); haunterDiesWork.setDescription(hauntDescription);
final Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = 1981791992623774490L; private static final long serialVersionUID = 1981791992623774490L;
@@ -4796,8 +4794,8 @@ public class CardFactoryUtil {
return; return;
} }
if (CardFactoryUtil.canTarget(card, c)) { if (CardFactoryUtil.canTarget(card, c)) {
haunterDies_Work.setTargetCard(c); haunterDiesWork.setTargetCard(c);
AllZone.getStack().add(haunterDies_Work); AllZone.getStack().add(haunterDiesWork);
this.stop(); this.stop();
} else { } else {
AllZone.getDisplay().showMessage("Cannot target this card (Shroud? Protection?)."); AllZone.getDisplay().showMessage("Cannot target this card (Shroud? Protection?).");
@@ -4805,7 +4803,7 @@ public class CardFactoryUtil {
} }
}; };
final Ability haunterDies_Setup = new Ability(card, "0") { final Ability haunterDiesSetup = new Ability(card, "0") {
@Override @Override
public void resolve() { public void resolve() {
final CardList creats = AllZoneUtil.getCreaturesInPlay(); final CardList creats = AllZoneUtil.getCreaturesInPlay();
@@ -4827,16 +4825,16 @@ public class CardFactoryUtil {
// AI choosing what to haunt // AI choosing what to haunt
final CardList oppCreats = creats.getController(AllZone.getHumanPlayer()); final CardList oppCreats = creats.getController(AllZone.getHumanPlayer());
if (oppCreats.size() != 0) { if (oppCreats.size() != 0) {
haunterDies_Work.setTargetCard(CardFactoryUtil.AI_getWorstCreature(oppCreats)); haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats));
} else { } else {
haunterDies_Work.setTargetCard(CardFactoryUtil.AI_getWorstCreature(creats)); haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(creats));
} }
AllZone.getStack().add(haunterDies_Work); AllZone.getStack().add(haunterDiesWork);
} }
} }
}; };
haunterDies.setOverridingAbility(haunterDies_Setup); haunterDies.setOverridingAbility(haunterDiesSetup);
// Second, create the trigger that runs when the haunted creature // Second, create the trigger that runs when the haunted creature
// dies // dies
@@ -4928,8 +4926,8 @@ public class CardFactoryUtil {
final Trigger copyTrigger = forge.card.trigger.TriggerHandler.parseTrigger( final Trigger copyTrigger = forge.card.trigger.TriggerHandler.parseTrigger(
"Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerDescription$ " "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerDescription$ "
+ "At the beginning of each of your upkeeps, copy " + "At the beginning of each of your upkeeps, copy " + card.toString()
+ card.toString() + " except for its epic ability.", card, false); + " except for its epic ability.", card, false);
copyTrigger.setOverridingAbility(origSA); copyTrigger.setOverridingAbility(origSA);
@@ -5283,7 +5281,7 @@ public class CardFactoryUtil {
} }
}); });
if (choices.size() != 0) { if (choices.size() != 0) {
ability.setTargetCard(CardFactoryUtil.AI_getBestCreature(choices)); ability.setTargetCard(CardFactoryUtil.getBestCreatureAI(choices));
if (ability.getTargetCard() != null) { if (ability.getTargetCard() != null) {
ability.setStackDescription("Put " + card.getCounters(Counters.P1P1) ability.setStackDescription("Put " + card.getCounters(Counters.P1P1)

View File

@@ -45,7 +45,7 @@ class CardFactory_Auras {
* @return a int. * @return a int.
*/ */
public static final int shouldCycle(final Card c) { public static final int shouldCycle(final Card c) {
ArrayList<String> a = c.getKeyword(); final ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++) { for (int i = 0; i < a.size(); i++) {
if (a.get(i).toString().startsWith("Cycling")) { if (a.get(i).toString().startsWith("Cycling")) {
return i; return i;
@@ -81,16 +81,16 @@ class CardFactory_Auras {
if (!super.canPlayAI()) { if (!super.canPlayAI()) {
return false; return false;
} }
String[] landTypes = new String[] { "Plains", "Island", "Swamp", "Mountain", "Forest" }; final String[] landTypes = new String[] { "Plains", "Island", "Swamp", "Mountain", "Forest" };
HashMap<String, Integer> humanLandCount = new HashMap<String, Integer>(); final HashMap<String, Integer> humanLandCount = new HashMap<String, Integer>();
CardList humanlands = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); final CardList humanlands = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer());
for (int i = 0; i < landTypes.length; i++) { for (final String landType : landTypes) {
humanLandCount.put(landTypes[i], 0); humanLandCount.put(landType, 0);
} }
for (Card c : humanlands) { for (final Card c : humanlands) {
for (String singleType : c.getType()) { for (final String singleType : c.getType()) {
if (CardUtil.isABasicLandType(singleType)) { if (CardUtil.isABasicLandType(singleType)) {
humanLandCount.put(singleType, humanLandCount.get(singleType) + 1); humanLandCount.put(singleType, humanLandCount.get(singleType) + 1);
} }
@@ -100,7 +100,7 @@ class CardFactory_Auras {
int minAt = 0; int minAt = 0;
int minVal = Integer.MAX_VALUE; int minVal = Integer.MAX_VALUE;
for (int i = 0; i < landTypes.length; i++) { for (int i = 0; i < landTypes.length; i++) {
if (getTargetCard().isType(landTypes[i])) { if (this.getTargetCard().isType(landTypes[i])) {
continue; continue;
} }
@@ -118,7 +118,7 @@ class CardFactory_Auras {
if (list.isEmpty()) { if (list.isEmpty()) {
return false; return false;
} }
setTargetCard(list.get(0)); this.setTargetCard(list.get(0));
return true; return true;
} // canPlayAI() } // canPlayAI()
@@ -131,7 +131,7 @@ class CardFactory_Auras {
} }
AllZone.getGameAction().moveToPlay(card); AllZone.getGameAction().moveToPlay(card);
Card c = getTargetCard(); final Card c = this.getTargetCard();
if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) {
card.enchantEntity(c); card.enchantEntity(c);
@@ -149,14 +149,15 @@ class CardFactory_Auras {
spell.setDescription("Enchanted land is an Island."); spell.setDescription("Enchanted land is an Island.");
} }
Command onEnchant = new Command() { final Command onEnchant = new Command() {
private static final long serialVersionUID = 3528675112863241126L; private static final long serialVersionUID = 3528675112863241126L;
@Override
public void execute() { public void execute() {
if (card.isEnchanting()) { if (card.isEnchanting()) {
Card crd = card.getEnchantingCard(); final Card crd = card.getEnchantingCard();
ArrayList<Card> seas = crd.getEnchantedBy(); final ArrayList<Card> seas = crd.getEnchantedBy();
int count = 0; int count = 0;
for (int i = 0; i < seas.size(); i++) { for (int i = 0; i < seas.size(); i++) {
if (seas.get(i).getName().equals(card.getName())) { if (seas.get(i).getName().equals(card.getName())) {
@@ -180,22 +181,23 @@ class CardFactory_Auras {
otherSeas = seas.get(i); otherSeas = seas.get(i);
} }
} }
SpellAbility[] abilities = otherSeas.getSpellAbility(); final SpellAbility[] abilities = otherSeas.getSpellAbility();
for (int i = 0; i < abilities.length; i++) { for (final SpellAbility abilitie : abilities) {
card.addSpellAbility(abilities[i]); card.addSpellAbility(abilitie);
} }
} }
} }
} // execute() } // execute()
}; // Command }; // Command
Command onUnEnchant = new Command() { final Command onUnEnchant = new Command() {
private static final long serialVersionUID = -202144631191180334L; private static final long serialVersionUID = -202144631191180334L;
@Override
public void execute() { public void execute() {
if (card.isEnchanting()) { if (card.isEnchanting()) {
Card crd = card.getEnchantingCard(); final Card crd = card.getEnchantingCard();
ArrayList<Card> seas = crd.getEnchantedBy(); final ArrayList<Card> seas = crd.getEnchantedBy();
int count = 0; int count = 0;
for (int i = 0; i < seas.size(); i++) { for (int i = 0; i < seas.size(); i++) {
if (seas.get(i).getName().equals(card.getName())) { if (seas.get(i).getName().equals(card.getName())) {
@@ -208,33 +210,34 @@ class CardFactory_Auras {
crd.removeType("Basic"); crd.removeType("Basic");
crd.removeType("Snow"); crd.removeType("Snow");
crd.removeType("Legendary"); crd.removeType("Legendary");
SpellAbility[] cardAbilities = crd.getSpellAbility(); final SpellAbility[] cardAbilities = crd.getSpellAbility();
for (int i = 0; i < cardAbilities.length; i++) { for (final SpellAbility cardAbilitie : cardAbilities) {
if (cardAbilities[i].isIntrinsic()) { if (cardAbilitie.isIntrinsic()) {
crd.removeSpellAbility(cardAbilities[i]); crd.removeSpellAbility(cardAbilitie);
} }
} }
Card c = AllZone.getCardFactory().copyCard(crd); final Card c = AllZone.getCardFactory().copyCard(crd);
ArrayList<String> types = c.getType(); final ArrayList<String> types = c.getType();
SpellAbility[] abilities = card.getSpellAbility(); final SpellAbility[] abilities = card.getSpellAbility();
for (int i = 0; i < types.size(); i++) { for (int i = 0; i < types.size(); i++) {
crd.addType(types.get(i)); crd.addType(types.get(i));
} }
for (int i = 0; i < abilities.length; i++) { for (final SpellAbility abilitie : abilities) {
crd.addSpellAbility(abilities[i]); crd.addSpellAbility(abilitie);
} }
} }
} }
} // execute() } // execute()
}; // Command }; // Command
Command onLeavesPlay = new Command() { final Command onLeavesPlay = new Command() {
private static final long serialVersionUID = -45433022112460839L; private static final long serialVersionUID = -45433022112460839L;
@Override
public void execute() { public void execute() {
if (card.isEnchanting()) { if (card.isEnchanting()) {
Card crd = card.getEnchantingCard(); final Card crd = card.getEnchantingCard();
card.unEnchantEntity(crd); card.unEnchantEntity(crd);
} }
} }
@@ -244,14 +247,15 @@ class CardFactory_Auras {
card.addUnEnchantCommand(onUnEnchant); card.addUnEnchantCommand(onUnEnchant);
card.addLeavesPlayCommand(onLeavesPlay); card.addLeavesPlayCommand(onLeavesPlay);
Input runtime = new Input() { final Input runtime = new Input() {
private static final long serialVersionUID = -62372711146079880L; private static final long serialVersionUID = -62372711146079880L;
@Override @Override
public void showMessage() { public void showMessage() {
CardList land = AllZoneUtil.getLandsInPlay(); final CardList land = AllZoneUtil.getLandsInPlay();
stopSetNext(CardFactoryUtil.input_targetSpecific(spell, land, "Select target land", true, false)); this.stopSetNext(CardFactoryUtil.inputTargetSpecific(spell, land, "Select target land", true,
false));
} }
}; };
spell.setBeforePayMana(runtime); spell.setBeforePayMana(runtime);
@@ -259,8 +263,8 @@ class CardFactory_Auras {
// *************** START *********** START ************************** // *************** START *********** START **************************
else if (cardName.equals("Earthbind")) { else if (cardName.equals("Earthbind")) {
Cost cost = new Cost(card.getManaCost(), cardName, false); final Cost cost = new Cost(card.getManaCost(), cardName, false);
Target tgt = new Target(card, "C"); final Target tgt = new Target(card, "C");
final SpellAbility spell = new Spell_Permanent(card, cost, tgt) { final SpellAbility spell = new Spell_Permanent(card, cost, tgt) {
private static final long serialVersionUID = 142389375702113977L; private static final long serialVersionUID = 142389375702113977L;
@@ -273,9 +277,10 @@ class CardFactory_Auras {
return false; return false;
} }
CardListFilter f = new CardListFilter() { final CardListFilter f = new CardListFilter() {
@Override
public final boolean addCard(final Card c) { public final boolean addCard(final Card c) {
return c.getNetDefense() - c.getDamage() <= 2; return (c.getNetDefense() - c.getDamage()) <= 2;
} }
}; };
if (!list.filter(f).isEmpty()) { if (!list.filter(f).isEmpty()) {
@@ -285,7 +290,7 @@ class CardFactory_Auras {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (CardFactoryUtil.canTarget(card, list.get(i))) { if (CardFactoryUtil.canTarget(card, list.get(i))) {
setTargetCard(list.get(i)); this.setTargetCard(list.get(i));
return super.canPlayAI(); return super.canPlayAI();
} }
} }
@@ -296,11 +301,11 @@ class CardFactory_Auras {
public void resolve() { public void resolve() {
AllZone.getGameAction().moveToPlay(card); AllZone.getGameAction().moveToPlay(card);
Card c = getTargetCard(); final Card c = this.getTargetCard();
if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) {
card.enchantEntity(c); card.enchantEntity(c);
Log.debug("Enchanted: " + getTargetCard()); Log.debug("Enchanted: " + this.getTargetCard());
} }
} // resolve() } // resolve()
}; // SpellAbility }; // SpellAbility
@@ -308,13 +313,14 @@ class CardFactory_Auras {
card.addSpellAbility(spell); card.addSpellAbility(spell);
final boolean[] badTarget = { true }; final boolean[] badTarget = { true };
Command onEnchant = new Command() { final Command onEnchant = new Command() {
private static final long serialVersionUID = -5302506578307993978L; private static final long serialVersionUID = -5302506578307993978L;
@Override
public void execute() { public void execute() {
if (card.isEnchanting()) { if (card.isEnchanting()) {
Card crd = card.getEnchantingCard(); final Card crd = card.getEnchantingCard();
if (crd.hasKeyword("Flying")) { if (crd.hasKeyword("Flying")) {
badTarget[0] = false; badTarget[0] = false;
crd.addDamage(2, card); crd.addDamage(2, card);
@@ -327,25 +333,27 @@ class CardFactory_Auras {
} // execute() } // execute()
}; // Command }; // Command
Command onUnEnchant = new Command() { final Command onUnEnchant = new Command() {
private static final long serialVersionUID = -6908757692588823391L; private static final long serialVersionUID = -6908757692588823391L;
@Override
public void execute() { public void execute() {
if (card.isEnchanting() && !badTarget[0]) { if (card.isEnchanting() && !badTarget[0]) {
Card crd = card.getEnchantingCard(); final Card crd = card.getEnchantingCard();
crd.addIntrinsicKeyword("Flying"); crd.addIntrinsicKeyword("Flying");
} }
} // execute() } // execute()
}; // Command }; // Command
Command onLeavesPlay = new Command() { final Command onLeavesPlay = new Command() {
private static final long serialVersionUID = -7833240882415702940L; private static final long serialVersionUID = -7833240882415702940L;
@Override
public void execute() { public void execute() {
if (card.isEnchanting()) { if (card.isEnchanting()) {
Card crd = card.getEnchantingCard(); final Card crd = card.getEnchantingCard();
card.unEnchantEntity(crd); card.unEnchantEntity(crd);
} }
} }
@@ -358,8 +366,8 @@ class CardFactory_Auras {
// *************** START *********** START ************************** // *************** START *********** START **************************
else if (cardName.equals("Guilty Conscience")) { else if (cardName.equals("Guilty Conscience")) {
Cost cost = new Cost(card.getManaCost(), cardName, false); final Cost cost = new Cost(card.getManaCost(), cardName, false);
Target tgt = new Target(card, "C"); final Target tgt = new Target(card, "C");
final SpellAbility spell = new Spell_Permanent(card, cost, tgt) { final SpellAbility spell = new Spell_Permanent(card, cost, tgt) {
private static final long serialVersionUID = 1169151960692309514L; private static final long serialVersionUID = 1169151960692309514L;
@@ -367,13 +375,13 @@ class CardFactory_Auras {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList stuffy = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Stuffy Doll"); final CardList stuffy = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Stuffy Doll");
if (stuffy.size() > 0) { if (stuffy.size() > 0) {
setTargetCard(stuffy.get(0)); this.setTargetCard(stuffy.get(0));
return true; return true;
} else { } else {
CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); final CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
if (list.isEmpty()) { if (list.isEmpty()) {
return false; return false;
@@ -386,8 +394,8 @@ class CardFactory_Auras {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (CardFactoryUtil.canTarget(card, list.get(i)) if (CardFactoryUtil.canTarget(card, list.get(i))
&& (list.get(i).getNetAttack() >= list.get(i).getNetDefense()) && (list.get(i).getNetAttack() >= list.get(i).getNetDefense())
&& list.get(i).getNetAttack() >= 3) { && (list.get(i).getNetAttack() >= 3)) {
setTargetCard(list.get(i)); this.setTargetCard(list.get(i));
return super.canPlayAI(); return super.canPlayAI();
} }
} }
@@ -398,9 +406,9 @@ class CardFactory_Auras {
@Override @Override
public void resolve() { public void resolve() {
Card aura = AllZone.getGameAction().moveToPlay(card); final Card aura = AllZone.getGameAction().moveToPlay(card);
Card c = getTargetCard(); final Card c = this.getTargetCard();
if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(aura, c)) { if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(aura, c)) {
aura.enchantEntity(c); aura.enchantEntity(c);
@@ -425,15 +433,17 @@ class CardFactory_Auras {
return AllZoneUtil.getCardsIn(Zone.Graveyard).filter(CardListFilter.CREATURES); return AllZoneUtil.getCardsIn(Zone.Graveyard).filter(CardListFilter.CREATURES);
} }
@Override
public boolean canPlay() { public boolean canPlay() {
return super.canPlay() && getCreturesInGrave().size() != 0; return super.canPlay() && (this.getCreturesInGrave().size() != 0);
} }
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
CardList cList = getCreturesInGrave(); CardList cList = this.getCreturesInGrave();
// AI will only target something that will stick in play. // AI will only target something that will stick in play.
cList = cList.filter(new CardListFilter() { cList = cList.filter(new CardListFilter() {
@Override
public final boolean addCard(final Card crd) { public final boolean addCard(final Card crd) {
return CardFactoryUtil.canTarget(card, crd) return CardFactoryUtil.canTarget(card, crd)
&& !CardFactoryUtil.hasProtectionFrom(card, crd); && !CardFactoryUtil.hasProtectionFrom(card, crd);
@@ -443,16 +453,16 @@ class CardFactory_Auras {
return false; return false;
} }
Card c = CardFactoryUtil.AI_getBestCreature(cList); final Card c = CardFactoryUtil.getBestCreatureAI(cList);
setTargetCard(c); this.setTargetCard(c);
boolean playable = 2 < c.getNetAttack() && 2 < c.getNetDefense() && super.canPlayAI(); final boolean playable = (2 < c.getNetAttack()) && (2 < c.getNetDefense()) && super.canPlayAI();
return playable; return playable;
} // canPlayAI } // canPlayAI
@Override @Override
public void resolve() { public void resolve() {
targetC[0] = getTargetCard(); targetC[0] = this.getTargetCard();
super.resolve(); super.resolve();
} }
@@ -460,29 +470,27 @@ class CardFactory_Auras {
// Target AbCost and Restriction are set here to get this working as // Target AbCost and Restriction are set here to get this working as
// expected // expected
Target tgt = new Target(card, "Select a creature in a graveyard", "Creature".split(",")); final Target tgt = new Target(card, "Select a creature in a graveyard", "Creature".split(","));
tgt.setZone(Constant.Zone.Graveyard); tgt.setZone(Constant.Zone.Graveyard);
animate.setTarget(tgt); animate.setTarget(tgt);
Cost cost = new Cost("1 B", cardName, false); final Cost cost = new Cost("1 B", cardName, false);
animate.setPayCosts(cost); animate.setPayCosts(cost);
animate.getRestrictions().setZone(Constant.Zone.Hand); animate.getRestrictions().setZone(Constant.Zone.Hand);
final Ability attach = new Ability(card, "0") { final Ability attach = new Ability(card, "0") {
private static final long serialVersionUID = 222308932796127795L;
@Override @Override
public void resolve() { public void resolve() {
PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield);
// Animate Dead got destroyed before its ability resolved // Animate Dead got destroyed before its ability resolved
if (!play.contains(card)) { if (!play.contains(card)) {
return; return;
} }
Card animated = targetC[0]; final Card animated = targetC[0];
PlayerZone grave = AllZone.getZoneOf(animated); final PlayerZone grave = AllZone.getZoneOf(animated);
if (!grave.is(Constant.Zone.Graveyard)) { if (!grave.is(Constant.Zone.Graveyard)) {
// Animated Creature got removed before ability resolved // Animated Creature got removed before ability resolved
@@ -513,6 +521,7 @@ class CardFactory_Auras {
final Command attachCmd = new Command() { final Command attachCmd = new Command() {
private static final long serialVersionUID = 3595188622377350327L; private static final long serialVersionUID = 3595188622377350327L;
@Override
public void execute() { public void execute() {
AllZone.getStack().addSimultaneousStackEntry(attach); AllZone.getStack().addSimultaneousStackEntry(attach);
@@ -523,9 +532,9 @@ class CardFactory_Auras {
@Override @Override
public void resolve() { public void resolve() {
Card c = targetC[0]; final Card c = targetC[0];
PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield);
if (play.contains(c)) { if (play.contains(c)) {
AllZone.getGameAction().sacrifice(c); AllZone.getGameAction().sacrifice(c);
@@ -536,10 +545,11 @@ class CardFactory_Auras {
final Command detachCmd = new Command() { final Command detachCmd = new Command() {
private static final long serialVersionUID = 2425333033834543422L; private static final long serialVersionUID = 2425333033834543422L;
@Override
public void execute() { public void execute() {
Card c = targetC[0]; final Card c = targetC[0];
PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield);
if (play.contains(c)) { if (play.contains(c)) {
AllZone.getStack().addSimultaneousStackEntry(detach); AllZone.getStack().addSimultaneousStackEntry(detach);
@@ -559,12 +569,12 @@ class CardFactory_Auras {
// *************** START *********** START ************************** // *************** START *********** START **************************
else if (CardFactoryUtil.hasKeyword(card, "enchant") != -1) { else if (CardFactoryUtil.hasKeyword(card, "enchant") != -1) {
int n = CardFactoryUtil.hasKeyword(card, "enchant"); final int n = CardFactoryUtil.hasKeyword(card, "enchant");
if (n != -1) { if (n != -1) {
String parse = card.getKeyword().get(n).toString(); final String parse = card.getKeyword().get(n).toString();
String[] k = parse.split(":"); final String[] k = parse.split(":");
SpellAbility sa = card.getSpellAbility()[0]; final SpellAbility sa = card.getSpellAbility()[0];
sa.setIsMultiKicker(true); sa.setIsMultiKicker(true);
sa.setMultiKickerManaCost(k[1]); sa.setMultiKickerManaCost(k[1]);
} }

View File

@@ -164,7 +164,7 @@ class CardFactory_Equipment {
} // execute() } // execute()
}; // Command }; // Command
equip.setBeforePayMana(CardFactoryUtil.input_equipCreature(equip)); equip.setBeforePayMana(CardFactoryUtil.inputEquipCreature(equip));
equip.getRestrictions().setSorcerySpeed(true); equip.getRestrictions().setSorcerySpeed(true);
equip.setDescription("Equip: 0"); equip.setDescription("Equip: 0");
@@ -215,7 +215,7 @@ class CardFactory_Equipment {
// not changed // not changed
@Override @Override
public void chooseTargetAI() { public void chooseTargetAI() {
final Card target = CardFactoryUtil.AI_getBestCreature(this.getCreature()); final Card target = CardFactoryUtil.getBestCreatureAI(this.getCreature());
this.setTargetCard(target); this.setTargetCard(target);
} }
@@ -225,7 +225,7 @@ class CardFactory_Equipment {
list = list.filter(new CardListFilter() { list = list.filter(new CardListFilter() {
@Override @Override
public boolean addCard(final Card c) { public boolean addCard(final Card c) {
return CardFactoryUtil.AI_doesCreatureAttack(c) && CardFactoryUtil.canTarget(card, c) return CardFactoryUtil.doesCreatureAttackAI(c) && CardFactoryUtil.canTarget(card, c)
&& (!c.hasKeyword("Defender")); && (!c.hasKeyword("Defender"));
} }
}); });
@@ -273,7 +273,7 @@ class CardFactory_Equipment {
} // execute() } // execute()
}; // Command }; // Command
equip.setBeforePayMana(CardFactoryUtil.input_equipCreature(equip)); equip.setBeforePayMana(CardFactoryUtil.inputEquipCreature(equip));
equip.setDescription("Equip: 4"); equip.setDescription("Equip: 4");
card.addSpellAbility(equip); card.addSpellAbility(equip);
@@ -330,8 +330,7 @@ class CardFactory_Equipment {
@Override @Override
public void selectCard(final Card c, final PlayerZone z) { public void selectCard(final Card c, final PlayerZone z) {
if (z.is(Constant.Zone.Battlefield, card.getController()) && c.isCreature() if (z.is(Constant.Zone.Battlefield, card.getController()) && c.isCreature()
&& CardFactoryUtil.canTarget(card, c)) && CardFactoryUtil.canTarget(card, c)) {
{
card.equipCard(c); card.equipCard(c);
this.stop(); this.stop();
} }
@@ -413,9 +412,9 @@ class CardFactory_Equipment {
} }
} }
card.addSpellAbility(CardFactoryUtil.eqPump_Equip(card, power, tough, extrinsicKeywords, abCost)); card.addSpellAbility(CardFactoryUtil.eqPumpEquip(card, power, tough, extrinsicKeywords, abCost));
card.addEquipCommand(CardFactoryUtil.eqPump_onEquip(card, power, tough, extrinsicKeywords, abCost)); card.addEquipCommand(CardFactoryUtil.eqPumpOnEquip(card, power, tough, extrinsicKeywords, abCost));
card.addUnEquipCommand(CardFactoryUtil.eqPump_unEquip(card, power, tough, extrinsicKeywords, abCost)); card.addUnEquipCommand(CardFactoryUtil.eqPumpUnEquip(card, power, tough, extrinsicKeywords, abCost));
} }
} // eqPump (was VanillaEquipment) } // eqPump (was VanillaEquipment)

View File

@@ -273,7 +273,7 @@ public class CardFactory_Instants {
CardList getCreature() { CardList getCreature() {
final CardList out = new CardList(); final CardList out = new CardList();
final CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); final CardList list = CardFactoryUtil.getHumanCreatureAI("Flying", card, true);
list.shuffle(); list.shuffle();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
@@ -284,9 +284,9 @@ public class CardFactory_Instants {
// in case human player only has a few creatures in play, // in case human player only has a few creatures in play,
// target anything // target anything
if (out.isEmpty() && (0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size()) if (out.isEmpty() && (0 < CardFactoryUtil.getHumanCreatureAI(2, card, true).size())
&& (3 > CardFactoryUtil.AI_getHumanCreature(card, true).size())) { && (3 > CardFactoryUtil.getHumanCreatureAI(card, true).size())) {
out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true)); out.addAll(CardFactoryUtil.getHumanCreatureAI(2, card, true));
CardListUtil.sortFlying(out); CardListUtil.sortFlying(out);
} }
return out; return out;
@@ -365,7 +365,7 @@ public class CardFactory_Instants {
} }
}; };
spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); spell.setChooseTargetAI(CardFactoryUtil.targetHumanAI());
card.addSpellAbility(spell); card.addSpellAbility(spell);
@@ -379,14 +379,14 @@ public class CardFactory_Instants {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
final CardList human = CardFactoryUtil.AI_getHumanCreature(card, true); final CardList human = CardFactoryUtil.getHumanCreatureAI(card, true);
return (4 < AllZone.getPhase().getTurn()) && (0 < human.size()); return (4 < AllZone.getPhase().getTurn()) && (0 < human.size());
} }
@Override @Override
public void chooseTargetAI() { public void chooseTargetAI() {
final CardList human = CardFactoryUtil.AI_getHumanCreature(card, true); final CardList human = CardFactoryUtil.getHumanCreatureAI(card, true);
this.setTargetCard(CardFactoryUtil.AI_getBestCreature(human)); this.setTargetCard(CardFactoryUtil.getBestCreatureAI(human));
} }
@Override @Override
@@ -441,8 +441,7 @@ public class CardFactory_Instants {
@Override @Override
public void selectCard(final Card card, final PlayerZone zone) { public void selectCard(final Card card, final PlayerZone zone) {
if (!card.isLand() && zone.is(Constant.Zone.Battlefield) if (!card.isLand() && zone.is(Constant.Zone.Battlefield) && CardFactoryUtil.canTarget(spell, card)) {
&& CardFactoryUtil.canTarget(spell, card)) {
spell.setTargetCard(card); spell.setTargetCard(card);
if (this.isFree()) { if (this.isFree()) {
this.setFree(false); this.setFree(false);
@@ -523,21 +522,21 @@ public class CardFactory_Instants {
final CardList selectedCards = new CardList(); final CardList selectedCards = new CardList();
// pick best creature // pick best creature
Card c = CardFactoryUtil.AI_getBestCreature(list); Card c = CardFactoryUtil.getBestCreatureAI(list);
if (c == null) { if (c == null) {
c = list.get(0); c = list.get(0);
} }
list.remove(c); list.remove(c);
selectedCards.add(c); selectedCards.add(c);
c = CardFactoryUtil.AI_getBestCreature(list); c = CardFactoryUtil.getBestCreatureAI(list);
if (c == null) { if (c == null) {
c = list.get(0); c = list.get(0);
} }
list.remove(c); list.remove(c);
selectedCards.add(c); selectedCards.add(c);
c = CardFactoryUtil.AI_getBestCreature(list); c = CardFactoryUtil.getBestCreatureAI(list);
if (c == null) { if (c == null) {
c = list.get(0); c = list.get(0);
} }
@@ -867,8 +866,8 @@ public class CardFactory_Instants {
else if (cardName.equals("Telling Time")) { else if (cardName.equals("Telling Time")) {
final SpellAbility spell = new Spell(card) { final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 2626878556107707854L; private static final long serialVersionUID = 2626878556107707854L;
private String[] prompt = new String[] { "Put a card into your hand", "Put a card on top of library", private final String[] prompt = new String[] { "Put a card into your hand",
"Put a card on bottom of library" }; "Put a card on top of library", "Put a card on bottom of library" };
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
@@ -958,7 +957,7 @@ public class CardFactory_Instants {
final Cost abCost = new Cost("1 R", cardName, false); final Cost abCost = new Cost("1 R", cardName, false);
final SpellAbility spell = new Spell(card, abCost, new Target(card, "TgtC")) { final SpellAbility spell = new Spell(card, abCost, new Target(card, "TgtC")) {
private static final long serialVersionUID = -3069135027502686218L; private static final long serialVersionUID = -3069135027502686218L;
private int damage = 3; private final int damage = 3;
@Override @Override
public void chooseTargetAI() { public void chooseTargetAI() {
@@ -972,10 +971,10 @@ public class CardFactory_Instants {
}); });
final CardList infect = creatures.getKeyword("Infect"); final CardList infect = creatures.getKeyword("Infect");
if (infect.size() > 0) { if (infect.size() > 0) {
final Card c = CardFactoryUtil.AI_getBestCreature(infect); final Card c = CardFactoryUtil.getBestCreatureAI(infect);
this.setTargetCard(c); this.setTargetCard(c);
} else { } else {
final Card c = CardFactoryUtil.AI_getBestCreature(creatures); final Card c = CardFactoryUtil.getBestCreatureAI(creatures);
this.setTargetCard(c); this.setTargetCard(c);
} }

View File

@@ -63,11 +63,12 @@ class CardFactory_Lands {
card.addComesIntoPlayCommand(new Command() { card.addComesIntoPlayCommand(new Command() {
private static final long serialVersionUID = 7352127748114888255L; private static final long serialVersionUID = 7352127748114888255L;
@Override
public void execute() { public void execute() {
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
humanExecute(); this.humanExecute();
} else { } else {
computerExecute(); this.computerExecute();
} }
} }
@@ -81,27 +82,27 @@ class CardFactory_Lands {
if (pay) { if (pay) {
AllZone.getComputerPlayer().loseLife(2, card); AllZone.getComputerPlayer().loseLife(2, card);
} else { } else {
tapCard(); this.tapCard();
} }
} }
public void humanExecute() { public void humanExecute() {
int life = card.getController().getLife(); final int life = card.getController().getLife();
if (2 < life) { if (2 < life) {
StringBuilder question = new StringBuilder(); final StringBuilder question = new StringBuilder();
question.append("Pay 2 life? If you don't, ").append(card.getName()); question.append("Pay 2 life? If you don't, ").append(card.getName());
question.append(" enters the battlefield tapped."); question.append(" enters the battlefield tapped.");
if (GameActionUtil.showYesNoDialog(card, question.toString())) { if (GameActionUtil.showYesNoDialog(card, question.toString())) {
AllZone.getHumanPlayer().loseLife(2, card); AllZone.getHumanPlayer().loseLife(2, card);
} else { } else {
tapCard(); this.tapCard();
} }
} // if } // if
else { else {
tapCard(); this.tapCard();
} }
} // execute() } // execute()
@@ -127,7 +128,7 @@ class CardFactory_Lands {
} }
} }
if (card.getCounters(Counters.ICE) > 0 && AllZoneUtil.isCardInPlay(card) && super.canPlay()) { if ((card.getCounters(Counters.ICE) > 0) && AllZoneUtil.isCardInPlay(card) && super.canPlay()) {
return true; return true;
} else { } else {
return false; return false;
@@ -136,7 +137,7 @@ class CardFactory_Lands {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
String phase = AllZone.getPhase().getPhase(); final String phase = AllZone.getPhase().getPhase();
return phase.equals(Constant.Phase.MAIN2) && super.canPlayAI(); return phase.equals(Constant.Phase.MAIN2) && super.canPlayAI();
} }
@@ -156,12 +157,12 @@ class CardFactory_Lands {
// TODO - this should probably be a state effect // TODO - this should probably be a state effect
@Override @Override
public boolean canPlay() { public boolean canPlay() {
return card.getCounters(Counters.ICE) == 0 && AllZoneUtil.isCardInPlay(card) && super.canPlay(); return (card.getCounters(Counters.ICE) == 0) && AllZoneUtil.isCardInPlay(card) && super.canPlay();
} }
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
return canPlay() && super.canPlayAI(); return this.canPlay() && super.canPlayAI();
} }
@Override @Override
@@ -175,12 +176,14 @@ class CardFactory_Lands {
} }
}; };
// ability.setDescription("Dark Depths enters the battlefield with // ability.setDescription("Dark Depths enters the battlefield with
//ten ice counters on it.\r\n\r\n3: Remove an ice counter from Dark Depths. // ten ice counters on it.\r\n\r\n3: Remove an ice counter from Dark
// Depths.
// \r\n\r\nWhen Dark Depths has no ice counters on it, sacrifice it. // \r\n\r\nWhen Dark Depths has no ice counters on it, sacrifice it.
//If you do, put an indestructible legendary 20/20 black Avatar creature token // If you do, put an indestructible legendary 20/20 black Avatar
// creature token
// with flying named Marit Lage onto the battlefield."); // with flying named Marit Lage onto the battlefield.");
ability.setDescription("3: remove an Ice Counter."); ability.setDescription("3: remove an Ice Counter.");
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(card.getName()).append(" - remove an ice counter."); sb.append(card.getName()).append(" - remove an ice counter.");
ability.setStackDescription(sb.toString()); ability.setStackDescription(sb.toString());
@@ -195,17 +198,18 @@ class CardFactory_Lands {
final CardListFilter targets = new CardListFilter() { final CardListFilter targets = new CardListFilter() {
@Override
public boolean addCard(final Card c) { public boolean addCard(final Card c) {
return AllZoneUtil.isCardInPlay(c) && c.isCreature() return AllZoneUtil.isCardInPlay(c) && c.isCreature()
&& c.getTurnInZone() == AllZone.getPhase().getTurn(); && (c.getTurnInZone() == AllZone.getPhase().getTurn());
} }
}; };
Cost abCost = new Cost("G U T", cardName, true); final Cost abCost = new Cost("G U T", cardName, true);
Ability_Activated ability = new Ability_Activated(card, abCost, null) { final Ability_Activated ability = new Ability_Activated(card, abCost, null) {
private static final long serialVersionUID = 1416258136308898492L; private static final long serialVersionUID = 1416258136308898492L;
private CardList inPlay = new CardList(); private final CardList inPlay = new CardList();
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
@@ -213,16 +217,16 @@ class CardFactory_Lands {
.getPlayerTurn().isComputer())) { .getPlayerTurn().isComputer())) {
return false; return false;
} }
inPlay.clear(); this.inPlay.clear();
inPlay.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); this.inPlay.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield));
return (inPlay.filter(targets).size() > 1) && super.canPlayAI(); return (this.inPlay.filter(targets).size() > 1) && super.canPlayAI();
} }
@Override @Override
public void resolve() { public void resolve() {
inPlay.clear(); this.inPlay.clear();
inPlay.addAll(AllZoneUtil.getCardsIn(Zone.Battlefield)); this.inPlay.addAll(AllZoneUtil.getCardsIn(Zone.Battlefield));
for (Card targ : inPlay.filter(targets)) { for (final Card targ : this.inPlay.filter(targets)) {
targ.addCounter(Counters.P1P1, 1); targ.addCounter(Counters.P1P1, 1);
} }
} }
@@ -247,23 +251,27 @@ class CardFactory_Lands {
private final Player player = card.getController(); private final Player player = card.getController();
@Override
public void execute() { public void execute() {
if (player.isHuman()) { if (this.player.isHuman()) {
final int[] paid = { 0 }; final int[] paid = { 0 };
Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = -7835834281866473546L; private static final long serialVersionUID = -7835834281866473546L;
@Override
public void showMessage() { public void showMessage() {
AllZone.getDisplay().showMessage(cardName + " - Select an untapped land to sacrifice"); AllZone.getDisplay().showMessage(cardName + " - Select an untapped land to sacrifice");
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
} }
@Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
stop(); this.stop();
} }
@Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) {
AllZone.getGameAction().sacrifice(c); AllZone.getGameAction().sacrifice(c);
@@ -272,7 +280,7 @@ class CardFactory_Lands {
AllZone.getDisplay().showMessage( AllZone.getDisplay().showMessage(
cardName + " - Select an untapped land to sacrifice"); cardName + " - Select an untapped land to sacrifice");
} else { } else {
stop(); this.stop();
} }
} }
} // selectCard() } // selectCard()
@@ -316,10 +324,12 @@ class CardFactory_Lands {
private static final long serialVersionUID = 6175830918425915833L; private static final long serialVersionUID = 6175830918425915833L;
private final Player player = card.getController(); private final Player player = card.getController();
@Override
public void execute() { public void execute() {
final CardList land = player.getCardsIn(Zone.Battlefield).getValidCards(type[0], player, card); final CardList land = this.player.getCardsIn(Zone.Battlefield).getValidCards(type[0], this.player,
card);
if (player.isComputer()) { if (this.player.isComputer()) {
if (land.size() > 0) { if (land.size() > 0) {
CardList tappedLand = new CardList(land.toArray()); CardList tappedLand = new CardList(land.toArray());
tappedLand = tappedLand.filter(CardListFilter.TAPPED); tappedLand = tappedLand.filter(CardListFilter.TAPPED);
@@ -334,24 +344,27 @@ class CardFactory_Lands {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
} }
} else { // this is the human resolution } else { // this is the human resolution
Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = 6653677835621129465L; private static final long serialVersionUID = 6653677835621129465L;
@Override
public void showMessage() { public void showMessage() {
AllZone.getDisplay().showMessage( AllZone.getDisplay().showMessage(
cardName + " - Select one " + type[0] + " to sacrifice"); cardName + " - Select one " + type[0] + " to sacrifice");
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
} }
@Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
stop(); this.stop();
} }
@Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Zone.Battlefield) && land.contains(c)) { if (c.isLand() && zone.is(Zone.Battlefield) && land.contains(c)) {
AllZone.getGameAction().sacrifice(c); AllZone.getGameAction().sacrifice(c);
stop(); this.stop();
} }
} // selectCard() } // selectCard()
}; // Input }; // Input
@@ -369,13 +382,14 @@ class CardFactory_Lands {
final Command comesIntoPlay = new Command() { final Command comesIntoPlay = new Command() {
private static final long serialVersionUID = 685604326470832887L; private static final long serialVersionUID = 685604326470832887L;
@Override
public void execute() { public void execute() {
final Player player = card.getController(); final Player player = card.getController();
CardList land = player.getCardsIn(Zone.Battlefield, "Sheltered Valley"); final CardList land = player.getCardsIn(Zone.Battlefield, "Sheltered Valley");
land.remove(card); land.remove(card);
if (land.size() > 0) { if (land.size() > 0) {
for (Card c : land) { for (final Card c : land) {
AllZone.getGameAction().sacrifice(c); AllZone.getGameAction().sacrifice(c);
} }
} }
@@ -391,15 +405,16 @@ class CardFactory_Lands {
private static final long serialVersionUID = 6175830918425915833L; private static final long serialVersionUID = 6175830918425915833L;
private final Player player = card.getController(); private final Player player = card.getController();
@Override
public void execute() { public void execute() {
CardList plains = AllZoneUtil.getPlayerLandsInPlay(card.getController()); CardList plains = AllZoneUtil.getPlayerLandsInPlay(card.getController());
plains = plains.filter(CardListFilter.UNTAPPED); plains = plains.filter(CardListFilter.UNTAPPED);
if (player.isComputer()) { if (this.player.isComputer()) {
if (plains.size() > 1) { if (plains.size() > 1) {
CardList tappedPlains = new CardList(plains.toArray()); CardList tappedPlains = new CardList(plains.toArray());
tappedPlains = tappedPlains.getType("Basic"); tappedPlains = tappedPlains.getType("Basic");
for (Card c : tappedPlains) { for (final Card c : tappedPlains) {
AllZone.getGameAction().sacrifice(c); AllZone.getGameAction().sacrifice(c);
} }
for (int i = 0; i < tappedPlains.size(); i++) { for (int i = 0; i < tappedPlains.size(); i++) {
@@ -417,20 +432,23 @@ class CardFactory_Lands {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
return; return;
} }
Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = 6653677835621129465L; private static final long serialVersionUID = 6653677835621129465L;
@Override
public void showMessage() { public void showMessage() {
AllZone.getDisplay().showMessage( AllZone.getDisplay().showMessage(
"Scorched Ruins - Select an untapped land to sacrifice"); "Scorched Ruins - Select an untapped land to sacrifice");
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
} }
@Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
stop(); this.stop();
} }
@Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) {
AllZone.getGameAction().sacrifice(c); AllZone.getGameAction().sacrifice(c);
@@ -439,7 +457,7 @@ class CardFactory_Lands {
AllZone.getDisplay().showMessage( AllZone.getDisplay().showMessage(
"Scorched Ruins - Select an untapped land to sacrifice"); "Scorched Ruins - Select an untapped land to sacrifice");
} else { } else {
stop(); this.stop();
} }
} }
} // selectCard() } // selectCard()
@@ -487,11 +505,12 @@ class CardFactory_Lands {
card.addComesIntoPlayCommand(new Command() { card.addComesIntoPlayCommand(new Command() {
private static final long serialVersionUID = -5646344170306812481L; private static final long serialVersionUID = -5646344170306812481L;
@Override
public void execute() { public void execute() {
if (card.getController().isHuman()) { if (card.getController().isHuman()) {
humanExecute(); this.humanExecute();
} else { } else {
computerExecute(); this.computerExecute();
} }
} }
@@ -499,7 +518,7 @@ class CardFactory_Lands {
CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
hand = hand.getType(type); hand = hand.getType(type);
if (hand.size() > 0) { if (hand.size() > 0) {
revealCard(hand.get(0)); this.revealCard(hand.get(0));
} else { } else {
card.tap(); card.tap();
} }
@@ -520,14 +539,14 @@ class CardFactory_Lands {
if (zone.is(Constant.Zone.Hand) && c.isType(type)) { if (zone.is(Constant.Zone.Hand) && c.isType(type)) {
JOptionPane.showMessageDialog(null, "Revealed card: " + c.getName(), card.getName(), JOptionPane.showMessageDialog(null, "Revealed card: " + c.getName(), card.getName(),
JOptionPane.PLAIN_MESSAGE); JOptionPane.PLAIN_MESSAGE);
stop(); this.stop();
} }
} }
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
card.tap(); card.tap();
stop(); this.stop();
} }
}); });
} // execute() } // execute()
@@ -576,7 +595,7 @@ class CardFactory_Lands {
final String primary = pTemp; final String primary = pTemp;
final String secondary = sTemp; final String secondary = sTemp;
StringBuilder description = new StringBuilder(); final StringBuilder description = new StringBuilder();
description.append("1, Remove X storage counters from ").append(cardName); description.append("1, Remove X storage counters from ").append(cardName);
description.append(": Add X mana in any combination of ").append(primary); description.append(": Add X mana in any combination of ").append(primary);
description.append(" and/or ").append(secondary).append(" to your mana pool."); description.append(" and/or ").append(secondary).append(" to your mana pool.");
@@ -594,15 +613,13 @@ class CardFactory_Lands {
abMana.setUndoable(false); abMana.setUndoable(false);
final Ability addMana = new Ability(card, "1", description.toString()) { final Ability addMana = new Ability(card, "1", description.toString()) {
private static final long serialVersionUID = 7177960799748450242L;
// @Override // @Override
public String mana() { public String mana() {
StringBuilder mana = new StringBuilder(); final StringBuilder mana = new StringBuilder();
for (int i = 0; i < split[0]; i++) { for (int i = 0; i < split[0]; i++) {
mana.append(primary).append(" "); mana.append(primary).append(" ");
} }
for (int j = 0; j < num[0] - split[0]; j++) { for (int j = 0; j < (num[0] - split[0]); j++) {
mana.append(secondary).append(" "); mana.append(secondary).append(" ");
} }
return mana.toString().trim(); return mana.toString().trim();
@@ -616,43 +633,42 @@ class CardFactory_Lands {
@Override @Override
public void resolve() { public void resolve() {
abMana.setUndoable(false); abMana.setUndoable(false);
abMana.produceMana(mana(), card.getController()); abMana.produceMana(this.mana(), card.getController());
} }
}; };
Input runtime = new Input() { final Input runtime = new Input() {
private static final long serialVersionUID = -8808673510875540608L; private static final long serialVersionUID = -8808673510875540608L;
@Override @Override
public void showMessage() { public void showMessage() {
num[0] = card.getCounters(Counters.STORAGE); num[0] = card.getCounters(Counters.STORAGE);
String[] choices = new String[num[0] + 1]; final String[] choices = new String[num[0] + 1];
for (int j = 0; j <= num[0]; j++) { for (int j = 0; j <= num[0]; j++) {
choices[j] = "" + j; choices[j] = "" + j;
} }
String answer = (String) (GuiUtils.getChoiceOptional("Storage counters to remove", choices)); final String answer = (GuiUtils.getChoiceOptional("Storage counters to remove", choices));
if (answer == null) { if (answer == null) {
stop(); this.stop();
return; return;
} }
num[0] = Integer.parseInt(answer); num[0] = Integer.parseInt(answer);
String splitNum = (String) (GuiUtils.getChoiceOptional( final String splitNum = (GuiUtils.getChoiceOptional("Number of " + primary + " to add", choices));
"Number of " + primary + " to add", choices));
if (splitNum == null) { if (splitNum == null) {
stop(); this.stop();
return; return;
} }
split[0] = Integer.parseInt(splitNum); split[0] = Integer.parseInt(splitNum);
if (num[0] > 0 || split[0] > 0) { if ((num[0] > 0) || (split[0] > 0)) {
card.subtractCounter(Counters.STORAGE, num[0]); card.subtractCounter(Counters.STORAGE, num[0]);
stop(); this.stop();
AllZone.getStack().add(addMana); AllZone.getStack().add(addMana);
return; return;
} }
stop(); this.stop();
} }
}; };
addMana.setDescription(description.toString()); addMana.setDescription(description.toString());
@@ -668,6 +684,7 @@ class CardFactory_Lands {
final Command comesIntoPlay = new Command() { final Command comesIntoPlay = new Command() {
private static final long serialVersionUID = 7813334062721799674L; private static final long serialVersionUID = 7813334062721799674L;
@Override
public void execute() { public void execute() {
final Player player = card.getController(); final Player player = card.getController();
CardList land = AllZoneUtil.getPlayerLandsInPlay(player); CardList land = AllZoneUtil.getPlayerLandsInPlay(player);
@@ -686,25 +703,28 @@ class CardFactory_Lands {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
} }
} else { // this is the human resolution } else { // this is the human resolution
Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = 7944127258985401036L; private static final long serialVersionUID = 7944127258985401036L;
@Override
public void showMessage() { public void showMessage() {
AllZone.getDisplay().showMessage( AllZone.getDisplay().showMessage(
cardName + " - Select one non-Lair land to return to your hand"); cardName + " - Select one non-Lair land to return to your hand");
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
} }
@Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
stop(); this.stop();
} }
@Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (c.isLand() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) if (c.isLand() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer())
&& !c.isType("Lair")) { && !c.isType("Lair")) {
AllZone.getGameAction().moveToHand(c); AllZone.getGameAction().moveToHand(c);
stop(); this.stop();
} }
} // selectCard() } // selectCard()
}; // Input }; // Input
@@ -742,30 +762,33 @@ class CardFactory_Lands {
if (player.isComputer()) { if (player.isComputer()) {
if (land.size() > 0) { if (land.size() > 0) {
Card c = CardFactoryUtil.getWorstLand(land); final Card c = CardFactoryUtil.getWorstLand(land);
AllZone.getGameAction().moveToHand(c); AllZone.getGameAction().moveToHand(c);
} else { } else {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
} }
} else { // this is the human resolution } else { // this is the human resolution
Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = -7886610643693087790L; private static final long serialVersionUID = -7886610643693087790L;
@Override
public void showMessage() { public void showMessage() {
AllZone.getDisplay().showMessage( AllZone.getDisplay().showMessage(
card + " - Select one untapped " + type[0] + " to return"); card + " - Select one untapped " + type[0] + " to return");
ButtonUtil.enableOnlyCancel(); ButtonUtil.enableOnlyCancel();
} }
@Override
public void selectButtonCancel() { public void selectButtonCancel() {
AllZone.getGameAction().sacrifice(card); AllZone.getGameAction().sacrifice(card);
stop(); this.stop();
} }
@Override
public void selectCard(final Card c, final PlayerZone zone) { public void selectCard(final Card c, final PlayerZone zone) {
if (zone.is(Constant.Zone.Battlefield) && land.contains(c)) { if (zone.is(Constant.Zone.Battlefield) && land.contains(c)) {
AllZone.getGameAction().moveToHand(c); AllZone.getGameAction().moveToHand(c);
stop(); this.stop();
} }
} // selectCard() } // selectCard()
}; // Input }; // Input
@@ -774,12 +797,12 @@ class CardFactory_Lands {
} }
}; };
sacOrNo.setStackDescription("When CARDNAME enters the battlefield, " sacOrNo.setStackDescription("When CARDNAME enters the battlefield, "
+ "sacrifice it unless you return an untapped " + "sacrifice it unless you return an untapped " + type[0] + " you control to its owner's hand.");
+ type[0] + " you control to its owner's hand.");
final Command comesIntoPlay = new Command() { final Command comesIntoPlay = new Command() {
private static final long serialVersionUID = -5777499632266148456L; private static final long serialVersionUID = -5777499632266148456L;
@Override
public void execute() { public void execute() {
AllZone.getStack().addSimultaneousStackEntry(sacOrNo); AllZone.getStack().addSimultaneousStackEntry(sacOrNo);
} }

View File

@@ -12,6 +12,7 @@ import forge.card.CardRules;
import forge.error.ErrorViewer; import forge.error.ErrorViewer;
import forge.item.CardDb; import forge.item.CardDb;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants;
/** /**
* <p> * <p>
@@ -56,16 +57,16 @@ public class PreloadingCardFactory extends AbstractCardFactory {
super(file); super(file);
try { try {
readCards(file); this.readCards(file);
// initialize CardList allCards // initialize CardList allCards
Iterator<String> it = getMap().keySet().iterator(); final Iterator<String> it = this.getMap().keySet().iterator();
Card c; Card c;
while (it.hasNext()) { while (it.hasNext()) {
c = getCard(it.next().toString(), AllZone.getHumanPlayer()); c = this.getCard(it.next().toString(), AllZone.getHumanPlayer());
getAllCards().add(c); this.getAllCards().add(c);
} }
} catch (Exception ex) { } catch (final Exception ex) {
ErrorViewer.showError(ex); ErrorViewer.showError(ex);
} }
} // constructor } // constructor
@@ -79,10 +80,11 @@ public class PreloadingCardFactory extends AbstractCardFactory {
* a {@link java.io.File} object. * a {@link java.io.File} object.
*/ */
protected final void readCards(final File file) { protected final void readCards(final File file) {
getMap().clear(); this.getMap().clear();
List<CardRules> listCardRules = new ArrayList<CardRules>(); final List<CardRules> listCardRules = new ArrayList<CardRules>();
CardReader read = new CardReader(ForgeProps.getFile(CARDSFOLDER), getMap(), listCardRules); final CardReader read = new CardReader(ForgeProps.getFile(NewConstants.CARDSFOLDER), this.getMap(),
listCardRules);
// this fills in our map of card names to Card instances. // this fills in our map of card names to Card instances.
read.run(); read.run();

View File

@@ -201,9 +201,9 @@ public class CostPutCounter extends CostPartWithList {
Card card = null; Card card = null;
if (type.equals("Creature.YouCtrl")) { if (type.equals("Creature.YouCtrl")) {
card = CardFactoryUtil.AI_getWorstCreature(typeList); card = CardFactoryUtil.getWorstCreatureAI(typeList);
} else { } else {
card = CardFactoryUtil.AI_getWorstPermanent(typeList, false, false, false, false); card = CardFactoryUtil.getWorstPermanentAI(typeList, false, false, false, false);
} }
addToList(card); addToList(card);
} }

View File

@@ -43,7 +43,7 @@ public class Spell_Permanent extends Spell {
public void showMessage() { public void showMessage() {
CardList choice = (CardList) championGetCreature.execute(); CardList choice = (CardList) championGetCreature.execute();
stopSetNext(CardFactoryUtil.input_targetChampionSac(getSourceCard(), championAbilityComes, choice, stopSetNext(CardFactoryUtil.inputTargetChampionSac(getSourceCard(), championAbilityComes, choice,
"Select another " + championValidDesc + " you control to exile", false, false)); "Select another " + championValidDesc + " you control to exile", false, false));
ButtonUtil.disableAll(); // target this card means: sacrifice this ButtonUtil.disableAll(); // target this card means: sacrifice this
// card // card