diff --git a/src/main/java/forge/AIPlayer.java b/src/main/java/forge/AIPlayer.java index a13ea2435e9..33f559249ea 100644 --- a/src/main/java/forge/AIPlayer.java +++ b/src/main/java/forge/AIPlayer.java @@ -275,7 +275,7 @@ public class AIPlayer extends Player { public final void sacrificePermanent(final String prompt, final CardList choices) { if (choices.size() > 0) { // 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); } } diff --git a/src/main/java/forge/CombatUtil.java b/src/main/java/forge/CombatUtil.java index c80a86c043c..685ccbaefb3 100644 --- a/src/main/java/forge/CombatUtil.java +++ b/src/main/java/forge/CombatUtil.java @@ -2198,7 +2198,7 @@ public class CombatUtil { } }); if (enchantments.size() > 0) { - Card card = CardFactoryUtil.AI_getBestEnchantment(enchantments, c, false); + Card card = CardFactoryUtil.getBestEnchantmentAI(enchantments, c, false); AllZone.getGameAction().moveToPlay(card); c.getController().shuffle(); } @@ -2277,7 +2277,7 @@ public class CombatUtil { card.setCreatureAttackedThisCombat(true); } } else if (c.getController().isComputer()) { - Card card = CardFactoryUtil.AI_getBestCreature(soldiers); + Card card = CardFactoryUtil.getBestCreatureAI(soldiers); if (card != null) { AllZone.getGameAction().moveToPlay(card); @@ -2568,7 +2568,7 @@ public class CombatUtil { enchantment = ((Card) check); } } else { - enchantment = CardFactoryUtil.AI_getBestEnchantment(enchantments, attacker, false); + enchantment = CardFactoryUtil.getBestEnchantmentAI(enchantments, attacker, false); } if (enchantment != null && AllZoneUtil.isCardInPlay(attacker)) { GameAction.changeZone(AllZone.getZoneOf(enchantment), diff --git a/src/main/java/forge/ComputerUtil.java b/src/main/java/forge/ComputerUtil.java index 9ff4ffab312..85fc221ac91 100644 --- a/src/main/java/forge/ComputerUtil.java +++ b/src/main/java/forge/ComputerUtil.java @@ -1490,7 +1490,7 @@ public class ComputerUtil { Card c; if (list.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getWorstCreature(list); + c = CardFactoryUtil.getWorstCreatureAI(list); } else if (list.getNotType("Land").size() == 0) { c = CardFactoryUtil.getWorstLand(AllZone.getComputerPlayer()); } else { diff --git a/src/main/java/forge/ComputerUtil_Block2.java b/src/main/java/forge/ComputerUtil_Block2.java index 2b51731c5bc..4fac8f736ed 100644 --- a/src/main/java/forge/ComputerUtil_Block2.java +++ b/src/main/java/forge/ComputerUtil_Block2.java @@ -316,9 +316,9 @@ public class ComputerUtil_Block2 { // destroyed killingBlockers = getKillingBlockers(attacker, safeBlockers, combat); if (killingBlockers.size() > 0) { - blocker = CardFactoryUtil.AI_getWorstCreature(killingBlockers); + blocker = CardFactoryUtil.getWorstCreatureAI(killingBlockers); } else { - blocker = CardFactoryUtil.AI_getWorstCreature(safeBlockers); + blocker = CardFactoryUtil.getWorstCreatureAI(safeBlockers); getBlockedButUnkilled().add(attacker); } } // no safe blockers @@ -327,7 +327,7 @@ public class ComputerUtil_Block2 { if (killingBlockers.size() > 0) { // 3.Blockers that can destroy the attacker and are worth // less - Card worst = CardFactoryUtil.AI_getWorstCreature(killingBlockers); + Card worst = CardFactoryUtil.getWorstCreatureAI(killingBlockers); if (CardFactoryUtil.evaluateCreature(worst) + getDiff() < CardFactoryUtil .evaluateCreature(attacker)) { @@ -428,7 +428,7 @@ public class ComputerUtil_Block2 { return combat; } - Card leader = CardFactoryUtil.AI_getBestCreature(usableBlockers); + Card leader = CardFactoryUtil.getBestCreatureAI(usableBlockers); blockGang.add(leader); usableBlockers.remove(leader); absorbedDamage = leader.getEnoughDamageToKill(attacker.getNetCombatDamage(), attacker, true); @@ -485,7 +485,7 @@ public class ComputerUtil_Block2 { killingBlockers = getKillingBlockers(attacker, getPossibleBlockers(attacker, getBlockersLeft(), combat), combat); if (killingBlockers.size() > 0 && CombatUtil.lifeInDanger(combat)) { - Card blocker = CardFactoryUtil.AI_getWorstCreature(killingBlockers); + Card blocker = CardFactoryUtil.getWorstCreatureAI(killingBlockers); combat.addBlocker(attacker, blocker); currentAttackers.remove(attacker); getBlockersLeft().remove(blocker); @@ -513,7 +513,7 @@ public class ComputerUtil_Block2 { for (Card attacker : getAttackersLeft()) { chumpBlockers = getPossibleBlockers(attacker, getBlockersLeft(), combat); if (chumpBlockers.size() > 0 && CombatUtil.lifeInDanger(combat)) { - Card blocker = CardFactoryUtil.AI_getWorstCreature(chumpBlockers); + Card blocker = CardFactoryUtil.getWorstCreatureAI(chumpBlockers); combat.addBlocker(attacker, blocker); currentAttackers.remove(attacker); getBlockedButUnkilled().add(attacker); diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index 961707c3702..cea8808730b 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -2013,7 +2013,7 @@ public class GameAction { } } if (chosen == null) { - chosen = CardFactoryUtil.AI_getWorstCreature(grave); + chosen = CardFactoryUtil.getWorstCreatureAI(grave); } if (chosen == null) { diff --git a/src/main/java/forge/MagicStack.java b/src/main/java/forge/MagicStack.java index f6b3aadf1c3..acf12fec547 100644 --- a/src/main/java/forge/MagicStack.java +++ b/src/main/java/forge/MagicStack.java @@ -918,9 +918,9 @@ public class MagicStack extends MyObservable { // AI choosing what to haunt final CardList oppCreats = creats.getController(AllZone.getHumanPlayer()); if (oppCreats.size() != 0) { - haunterDiesWork.setTargetCard(CardFactoryUtil.AI_getWorstCreature(oppCreats)); + haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats)); } else { - haunterDiesWork.setTargetCard(CardFactoryUtil.AI_getWorstCreature(creats)); + haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(creats)); } this.add(haunterDiesWork); } diff --git a/src/main/java/forge/PhaseUtil.java b/src/main/java/forge/PhaseUtil.java index 8db7dd57cd3..6dced87b273 100644 --- a/src/main/java/forge/PhaseUtil.java +++ b/src/main/java/forge/PhaseUtil.java @@ -270,7 +270,7 @@ public class PhaseUtil { } }); if (artList.size() > 0) { - CardFactoryUtil.AI_getBestArtifact(artList).untap(); + CardFactoryUtil.getBestArtifactAI(artList).untap(); } } else { Input target = new Input() { diff --git a/src/main/java/forge/Upkeep.java b/src/main/java/forge/Upkeep.java index 3bb3bc2f7bd..ff0df3595f0 100644 --- a/src/main/java/forge/Upkeep.java +++ b/src/main/java/forge/Upkeep.java @@ -537,7 +537,7 @@ public class Upkeep implements java.io.Serializable { if (indestruct.size() > 0) { AllZone.getGameAction().destroyNoRegeneration(indestruct.get(0)); } else { - final Card target = CardFactoryUtil.AI_getWorstCreature(targets); + final Card target = CardFactoryUtil.getWorstCreatureAI(targets); if (null == target) { // must be nothing valid to destroy } else { @@ -625,7 +625,7 @@ public class Upkeep implements java.io.Serializable { } // selectCard() }); // Input } else { // computer - final Card target = CardFactoryUtil.AI_getCheapestPermanent(artifacts, c, false); + final Card target = CardFactoryUtil.getCheapestPermanentAI(artifacts, c, false); if (null == target) { this.tapAndDamage(player); } else { @@ -683,7 +683,7 @@ public class Upkeep implements java.io.Serializable { PlayerUtil.input_sacrificePermanent(creatures, c.getName() + " - Select a creature to sacrifice.")); } else { // computer - final Card target = CardFactoryUtil.AI_getWorstCreature(creatures); + final Card target = CardFactoryUtil.getWorstCreatureAI(creatures); AllZone.getGameAction().sacrifice(target); } } // resolve @@ -748,7 +748,7 @@ public class Upkeep implements java.io.Serializable { final int power = creatures.get(0).getNetAttack(); if (player.isHuman()) { AllZone.getInputControl().setInput( - CardFactoryUtil.input_destroyNoRegeneration(this.getLowestPowerList(creatures), + CardFactoryUtil.inputDestroyNoRegeneration(this.getLowestPowerList(creatures), "Select creature with power: " + power + " to sacrifice.")); } else { // computer final Card compyTarget = this.getCompyCardToDestroy(creatures); @@ -827,7 +827,7 @@ public class Upkeep implements java.io.Serializable { + " - Select a land to sacrifice.")); } } else { - final Card target = CardFactoryUtil.AI_getBestLand(playerLand); + final Card target = CardFactoryUtil.getBestLandAI(playerLand); AllZone.getGameAction().sacrifice(target); } @@ -2587,7 +2587,7 @@ public class Upkeep implements java.io.Serializable { for (int i = 0; i < num; i++) { 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) { toTap.tap(); list.remove(toTap); diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Attach.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Attach.java index a8eb8e0c296..36e3b1c3662 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Attach.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Attach.java @@ -320,7 +320,7 @@ public class AbilityFactory_Attach { 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 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 // choose something @@ -441,7 +441,7 @@ public class AbilityFactory_Attach { } }); - return CardFactoryUtil.AI_getBest(magnetList); + return CardFactoryUtil.getBestAI(magnetList); } int totToughness = 0; @@ -536,11 +536,11 @@ public class AbilityFactory_Attach { return !c.isCreature() || CombatUtil.canAttack(c); } }); - c = CardFactoryUtil.AI_getBest(prefList); + c = CardFactoryUtil.getBestAI(prefList); } else { // If we grant abilities, we may want to put it on something Weak? // Possibly more defensive? - c = CardFactoryUtil.AI_getWorstPermanent(prefList, false, false, false, false); + c = CardFactoryUtil.getWorstPermanentAI(prefList, false, false, false, false); } if (c == null) { @@ -628,7 +628,7 @@ public class AbilityFactory_Attach { if ((prefList == null) || (prefList.size() == 0)) { prefList = new CardList(list); } else { - c = CardFactoryUtil.AI_getBest(prefList); + c = CardFactoryUtil.getBestAI(prefList); if (c != null) { return c; } @@ -648,7 +648,7 @@ public class AbilityFactory_Attach { } } - c = CardFactoryUtil.AI_getBest(prefList); + c = CardFactoryUtil.getBestAI(prefList); if (c == null) { 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 // 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. // 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) { return AbilityFactory_Attach.chooseLessPreferred(mandatory, list); diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java index 7ada4c742c8..b2943fb66da 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java @@ -942,19 +942,19 @@ public final class AbilityFactory_ChangeZone { } else if (AbilityFactory_ChangeZone.areAllBasics(type)) { c = AbilityFactory_ChangeZone.basicManaFixing(fetchList, type); } else if (fetchList.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getBestCreature(fetchList); // if only + c = CardFactoryUtil.getBestCreatureAI(fetchList); // if only // creatures // take the // best } 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)) { // Exiling your own stuff, if Exiling opponents stuff choose // best if (destZone.getPlayer().isHuman()) { - c = CardFactoryUtil.AI_getMostExpensivePermanent(fetchList, af.getHostCard(), false); + c = CardFactoryUtil.getMostExpensivePermanentAI(fetchList, af.getHostCard(), false); } else { - c = CardFactoryUtil.AI_getCheapestPermanent(fetchList, af.getHostCard(), false); + c = CardFactoryUtil.getCheapestPermanentAI(fetchList, af.getHostCard(), false); } } else { // Don't fetch another tutor with the same name @@ -1318,7 +1318,7 @@ public final class AbilityFactory_ChangeZone { if (!threatenedTargets.isEmpty()) { // Choose "best" of the remaining to save - tgt.addTarget(CardFactoryUtil.AI_getBestCreature(threatenedTargets)); + tgt.addTarget(CardFactoryUtil.getBestCreatureAI(threatenedTargets)); return true; } } @@ -1357,7 +1357,7 @@ public final class AbilityFactory_ChangeZone { }); if (!aiPermanents.isEmpty()) { // Choose "best" of the remaining to save - tgt.addTarget(CardFactoryUtil.AI_getBest(aiPermanents)); + tgt.addTarget(CardFactoryUtil.getBestAI(aiPermanents)); return true; } } @@ -1400,15 +1400,15 @@ public final class AbilityFactory_ChangeZone { Card choice = null; 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 (mostExpensive.isCreature()) { // if a creature is most expensive take the best one if (destination.equals(Zone.Exile)) { // If Exiling things, don't give bonus to Tokens - choice = CardFactoryUtil.AI_getBestCreature(list); + choice = CardFactoryUtil.getBestCreatureAI(list); } else { - choice = CardFactoryUtil.AI_getBestCreatureToBounce(list); + choice = CardFactoryUtil.getBestCreatureToBounceAI(list); } } else { choice = mostExpensive; @@ -1495,12 +1495,12 @@ public final class AbilityFactory_ChangeZone { Card choice = null; 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))) { // 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)) { - choice = CardFactoryUtil.AI_getMostExpensivePermanent(list, af.getHostCard(), false); + choice = CardFactoryUtil.getMostExpensivePermanentAI(list, af.getHostCard(), false); } else { // TODO AI needs more improvement to it's retrieval (reuse // some code from spReturn here) diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Combat.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Combat.java index cfc12a92c79..8f113610139 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Combat.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Combat.java @@ -954,11 +954,11 @@ public final class AbilityFactory_Combat { } }); if (!list.isEmpty()) { - final Card blocker = CardFactoryUtil.AI_getBestCreature(list); + final Card blocker = CardFactoryUtil.getBestCreatureAI(list); if (blocker == null) { return false; } - abTgt.addTarget(CardFactoryUtil.AI_getBestCreature(list)); + abTgt.addTarget(CardFactoryUtil.getBestCreatureAI(list)); chance = true; // TODO change this to true, once the human input // takes mustblocks into account } diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Copy.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Copy.java index 1057e229ed8..baf3b5472a0 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Copy.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Copy.java @@ -277,9 +277,9 @@ public final class AbilityFactory_Copy { Card choice; if (list.filter(CardListFilter.CREATURES).size() > 0) { - choice = CardFactoryUtil.AI_getBestCreature(list); + choice = CardFactoryUtil.getBestCreatureAI(list); } else { - choice = CardFactoryUtil.AI_getMostExpensivePermanent(list, source, true); + choice = CardFactoryUtil.getMostExpensivePermanentAI(list, source, true); } if (choice == null) { // can't find anything left diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Counters.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Counters.java index a18b35e6f61..45045c6e5f3 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Counters.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Counters.java @@ -533,7 +533,7 @@ public class AbilityFactory_Counters { else { if (type.equals("M1M1")) { - choice = CardFactoryUtil.AI_getWorstCreature(list); + choice = CardFactoryUtil.getWorstCreatureAI(list); } else { choice = CardFactoryUtil.getRandomCard(list); } @@ -545,7 +545,7 @@ public class AbilityFactory_Counters { else { if (type.equals("P1P1")) { - choice = CardFactoryUtil.AI_getWorstCreature(list); + choice = CardFactoryUtil.getWorstCreatureAI(list); } else { choice = CardFactoryUtil.getRandomCard(list); } @@ -589,9 +589,9 @@ public class AbilityFactory_Counters { } }); if (killable.size() > 0) { - choice = CardFactoryUtil.AI_getBestCreature(killable); + choice = CardFactoryUtil.getBestCreatureAI(killable); } else { - choice = CardFactoryUtil.AI_getBestCreature(list); + choice = CardFactoryUtil.getBestCreatureAI(list); } } else { // improve random choice here @@ -614,7 +614,7 @@ public class AbilityFactory_Counters { private static Card chooseBoonTarget(final CardList list, final String type) { Card choice; if (type.equals("P1P1")) { - choice = CardFactoryUtil.AI_getBestCreature(list); + choice = CardFactoryUtil.getBestCreatureAI(list); } else if (type.equals("DIVINITY")) { final CardList boon = list.filter(new CardListFilter() { @Override @@ -622,7 +622,7 @@ public class AbilityFactory_Counters { return c.getCounters(Counters.DIVINITY) == 0; } }); - choice = CardFactoryUtil.AI_getMostExpensivePermanent(boon, null, false); + choice = CardFactoryUtil.getMostExpensivePermanentAI(boon, null, false); } else { // The AI really should put counters on cards that can use it. // Charge counters on things with Charge abilities, etc. Expand diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_DealDamage.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_DealDamage.java index 12de1e4cfce..c83c2d68c7a 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_DealDamage.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_DealDamage.java @@ -459,7 +459,7 @@ public class AbilityFactory_DealDamage { Card targetCard; if (pl.isHuman() && (killables.size() > 0)) { - targetCard = CardFactoryUtil.AI_getBestCreature(killables); + targetCard = CardFactoryUtil.getBestCreatureAI(killables); return targetCard; } @@ -470,9 +470,9 @@ public class AbilityFactory_DealDamage { if (hPlay.size() > 0) { if (pl.isHuman()) { - targetCard = CardFactoryUtil.AI_getBestCreature(hPlay); + targetCard = CardFactoryUtil.getBestCreatureAI(hPlay); } else { - targetCard = CardFactoryUtil.AI_getWorstCreature(hPlay); + targetCard = CardFactoryUtil.getWorstCreatureAI(hPlay); } return targetCard; diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Debuff.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Debuff.java index 30f20c9b816..f7ef5feb49e 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Debuff.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Debuff.java @@ -377,7 +377,7 @@ public final class AbilityFactory_Debuff { } } - t = CardFactoryUtil.AI_getBestCreature(list); + t = CardFactoryUtil.getBestCreatureAI(list); tgt.addTarget(t); list.remove(t); } @@ -456,9 +456,9 @@ public final class AbilityFactory_Debuff { Card c; if (pref.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getBestCreature(pref); + c = CardFactoryUtil.getBestCreatureAI(pref); } else { - c = CardFactoryUtil.AI_getMostExpensivePermanent(pref, source, true); + c = CardFactoryUtil.getMostExpensivePermanentAI(pref, source, true); } pref.remove(c); @@ -475,9 +475,9 @@ public final class AbilityFactory_Debuff { // keyword Card c; if (forced.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getWorstCreature(forced); + c = CardFactoryUtil.getWorstCreatureAI(forced); } else { - c = CardFactoryUtil.AI_getCheapestPermanent(forced, source, true); + c = CardFactoryUtil.getCheapestPermanentAI(forced, source, true); } forced.remove(c); diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Destroy.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Destroy.java index c9e92fb4c11..038d270cfc5 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Destroy.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Destroy.java @@ -226,7 +226,7 @@ public class AbilityFactory_Destroy { Card choice = null; if (list.getNotType("Creature").size() == 0) { - choice = CardFactoryUtil.AI_getBestCreature(list); // if the + choice = CardFactoryUtil.getBestCreatureAI(list); // if the // targets // are // only @@ -235,7 +235,7 @@ public class AbilityFactory_Destroy { // the // best } else { - choice = CardFactoryUtil.AI_getMostExpensivePermanent(list, af.getHostCard(), true); + choice = CardFactoryUtil.getMostExpensivePermanentAI(list, af.getHostCard(), true); } if (choice == null) { // can't find anything left @@ -335,11 +335,11 @@ public class AbilityFactory_Destroy { } else { Card c; if (preferred.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getBestCreature(preferred); + c = CardFactoryUtil.getBestCreatureAI(preferred); } else if (preferred.getNotType("Land").size() == 0) { - c = CardFactoryUtil.AI_getBestLand(preferred); + c = CardFactoryUtil.getBestLandAI(preferred); } else { - c = CardFactoryUtil.AI_getMostExpensivePermanent(preferred, source, false); + c = CardFactoryUtil.getMostExpensivePermanentAI(preferred, source, false); } tgt.addTarget(c); preferred.remove(c); @@ -352,9 +352,9 @@ public class AbilityFactory_Destroy { } else { Card c; if (list.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getWorstCreature(list); + c = CardFactoryUtil.getWorstCreatureAI(list); } else { - c = CardFactoryUtil.AI_getCheapestPermanent(list, source, false); + c = CardFactoryUtil.getCheapestPermanentAI(list, source, false); } tgt.addTarget(c); list.remove(c); diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_GainControl.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_GainControl.java index 3f336d64271..3f47c292157 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_GainControl.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_GainControl.java @@ -328,15 +328,15 @@ public class AbilityFactory_GainControl { } if (hasCreature) { - t = CardFactoryUtil.AI_getBestCreature(list); + t = CardFactoryUtil.getBestCreatureAI(list); } else if (hasArtifact) { - t = CardFactoryUtil.AI_getBestArtifact(list); + t = CardFactoryUtil.getBestArtifactAI(list); } else if (hasLand) { - t = CardFactoryUtil.AI_getBestLand(list); + t = CardFactoryUtil.getBestLandAI(list); } else if (hasEnchantment) { - t = CardFactoryUtil.AI_getBestEnchantment(list, sa.getSourceCard(), true); + t = CardFactoryUtil.getBestEnchantmentAI(list, sa.getSourceCard(), true); } else { - t = CardFactoryUtil.AI_getMostExpensivePermanent(list, sa.getSourceCard(), true); + t = CardFactoryUtil.getMostExpensivePermanentAI(list, sa.getSourceCard(), true); } tgt.addTarget(t); diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_PermanentState.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_PermanentState.java index d6c46b55bac..8e8381436c1 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_PermanentState.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_PermanentState.java @@ -375,14 +375,14 @@ public class AbilityFactory_PermanentState { } if (untapList.getNotType("Creature").size() == 0) { - choice = CardFactoryUtil.AI_getBestCreature(untapList); // if + choice = CardFactoryUtil.getBestCreatureAI(untapList); // if // only // creatures // take // the // best } else { - choice = CardFactoryUtil.AI_getMostExpensivePermanent(untapList, af.getHostCard(), false); + choice = CardFactoryUtil.getMostExpensivePermanentAI(untapList, af.getHostCard(), false); } if (choice == null) { // can't find anything left @@ -495,13 +495,13 @@ public class AbilityFactory_PermanentState { } if (tapList.getNotType("Creature").size() == 0) { - choice = CardFactoryUtil.AI_getBestCreature(tapList); // if only + choice = CardFactoryUtil.getBestCreatureAI(tapList); // if only // creatures // take // the // best } else { - choice = CardFactoryUtil.AI_getMostExpensivePermanent(tapList, af.getHostCard(), false); + choice = CardFactoryUtil.getMostExpensivePermanentAI(tapList, af.getHostCard(), false); } if (choice == null) { // can't find anything left @@ -579,7 +579,7 @@ public class AbilityFactory_PermanentState { for (final Player p : definedPlayers) { if (p.isHuman()) { - AllZone.getInputControl().setInput(CardFactoryUtil.input_UntapUpToNType(num, valid)); + AllZone.getInputControl().setInput(CardFactoryUtil.inputUntapUpToNType(num, valid)); } else { CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); list = list.getType(valid); @@ -589,7 +589,7 @@ public class AbilityFactory_PermanentState { while ((list.size() != 0) && (count < num)) { 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(); list.remove(c); count++; @@ -944,13 +944,13 @@ public class AbilityFactory_PermanentState { } if (tapList.getNotType("Creature").size() == 0) { - choice = CardFactoryUtil.AI_getBestCreature(tapList); // if only + choice = CardFactoryUtil.getBestCreatureAI(tapList); // if only // creatures // take // the // best } else { - choice = CardFactoryUtil.AI_getMostExpensivePermanent(tapList, af.getHostCard(), false); + choice = CardFactoryUtil.getMostExpensivePermanentAI(tapList, af.getHostCard(), false); } if (choice == null) { // can't find anything left @@ -1064,13 +1064,13 @@ public class AbilityFactory_PermanentState { } if (tapList.getNotType("Creature").size() == 0) { - choice = CardFactoryUtil.AI_getBestCreature(tapList); // if only + choice = CardFactoryUtil.getBestCreatureAI(tapList); // if only // creatures // take // the // best } else { - choice = CardFactoryUtil.AI_getMostExpensivePermanent(tapList, af.getHostCard(), false); + choice = CardFactoryUtil.getMostExpensivePermanentAI(tapList, af.getHostCard(), false); } if (choice == null) { // can't find anything left diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_PreventDamage.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_PreventDamage.java index 241e10be278..deac06a72d1 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_PreventDamage.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_PreventDamage.java @@ -313,7 +313,7 @@ public class AbilityFactory_PreventDamage { if (!threatenedTargets.isEmpty()) { // Choose "best" of the remaining to save - tgt.addTarget(CardFactoryUtil.AI_getBestCreature(threatenedTargets)); + tgt.addTarget(CardFactoryUtil.getBestCreatureAI(threatenedTargets)); chance = true; } @@ -439,7 +439,7 @@ public class AbilityFactory_PreventDamage { return true; } - tgt.addTarget(CardFactoryUtil.AI_getCheapestPermanent(targetables, hostCard, true)); + tgt.addTarget(CardFactoryUtil.getCheapestPermanentAI(targetables, hostCard, true)); return true; } diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Protection.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Protection.java index 3582ed58ab3..e9636d6f5f6 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Protection.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Protection.java @@ -214,7 +214,7 @@ public final class AbilityFactory_Protection { } // 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().isPlayerTurn(AllZone.getComputerPlayer())) { return true; @@ -387,7 +387,7 @@ public final class AbilityFactory_Protection { } } - t = CardFactoryUtil.AI_getBestCreature(list); + t = CardFactoryUtil.getBestCreatureAI(list); tgt.addTarget(t); list.remove(t); } @@ -453,9 +453,9 @@ public final class AbilityFactory_Protection { Card c; if (pref.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getBestCreature(pref); + c = CardFactoryUtil.getBestCreatureAI(pref); } else { - c = CardFactoryUtil.AI_getMostExpensivePermanent(pref, source, true); + c = CardFactoryUtil.getMostExpensivePermanentAI(pref, source, true); } pref.remove(c); @@ -470,9 +470,9 @@ public final class AbilityFactory_Protection { Card c; if (pref2.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getBestCreature(pref2); + c = CardFactoryUtil.getBestCreatureAI(pref2); } else { - c = CardFactoryUtil.AI_getMostExpensivePermanent(pref2, source, true); + c = CardFactoryUtil.getMostExpensivePermanentAI(pref2, source, true); } pref2.remove(c); @@ -487,9 +487,9 @@ public final class AbilityFactory_Protection { Card c; if (forced.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getWorstCreature(forced); + c = CardFactoryUtil.getWorstCreatureAI(forced); } else { - c = CardFactoryUtil.AI_getCheapestPermanent(forced, source, true); + c = CardFactoryUtil.getCheapestPermanentAI(forced, source, true); } forced.remove(c); diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Pump.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Pump.java index 86cd7c454d3..ef1bb0857a4 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Pump.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Pump.java @@ -274,7 +274,7 @@ public class AbilityFactory_Pump { } // 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().isPlayerTurn(AllZone.getComputerPlayer())) { return true; @@ -496,7 +496,7 @@ public class AbilityFactory_Pump { } else if (this.hostCard.equals(card)) { final Random r = MyRandom.getRandom(); if (r.nextFloat() <= Math.pow(.6667, activations)) { - return CardFactoryUtil.AI_doesCreatureAttack(card) && !sa.getPayCosts().getTap(); + return CardFactoryUtil.doesCreatureAttackAI(card) && !sa.getPayCosts().getTap(); } } else { 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); list.remove(t); } @@ -635,9 +635,9 @@ public class AbilityFactory_Pump { Card c; if (pref.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getBestCreature(pref); + c = CardFactoryUtil.getBestCreatureAI(pref); } else { - c = CardFactoryUtil.AI_getMostExpensivePermanent(pref, source, true); + c = CardFactoryUtil.getMostExpensivePermanentAI(pref, source, true); } pref.remove(c); @@ -652,9 +652,9 @@ public class AbilityFactory_Pump { Card c; if (forced.getNotType("Creature").size() == 0) { - c = CardFactoryUtil.AI_getWorstCreature(forced); + c = CardFactoryUtil.getWorstCreatureAI(forced); } else { - c = CardFactoryUtil.AI_getCheapestPermanent(forced, source, true); + c = CardFactoryUtil.getCheapestPermanentAI(forced, source, true); } forced.remove(c); diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Regenerate.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Regenerate.java index 7783c9e4b05..3cd1017e79e 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Regenerate.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Regenerate.java @@ -293,7 +293,7 @@ public class AbilityFactory_Regenerate { if (!threatenedTargets.isEmpty()) { // Choose "best" of the remaining to regenerate - tgt.addTarget(CardFactoryUtil.AI_getBestCreature(threatenedTargets)); + tgt.addTarget(CardFactoryUtil.getBestCreatureAI(threatenedTargets)); chance = true; } } 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; } diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_ZoneAffecting.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_ZoneAffecting.java index 38ea7a414c4..7a7c53754f7 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_ZoneAffecting.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_ZoneAffecting.java @@ -1078,7 +1078,6 @@ public class AbilityFactory_ZoneAffecting { private static void discardResolve(final AbilityFactory af, final SpellAbility sa) { final Card source = sa.getSourceCard(); final HashMap params = af.getMapParams(); - final String mode = params.get("Mode"); ArrayList tgtPlayers; @@ -1138,7 +1137,6 @@ public class AbilityFactory_ZoneAffecting { } final CardList dPChHand = dPHand.getValidCards(valid.split(","), source.getController(), source); - // Reveal cards that will be discarded? for (final Card c : dPChHand) { p.discard(c, sa); @@ -1172,9 +1170,9 @@ public class AbilityFactory_ZoneAffecting { if (params.containsKey("DiscardValid")) { final String dValid = params.get("DiscardValid"); if (dValid.contains("Creature") && !dValid.contains("nonCreature")) { - final Card c = CardFactoryUtil.AI_getBestCreature(dPChHand); + final Card c = CardFactoryUtil.getBestCreatureAI(dPChHand); if (c != null) { - dChoices.add(CardFactoryUtil.AI_getBestCreature(dPChHand)); + dChoices.add(CardFactoryUtil.getBestCreatureAI(dPChHand)); } } } diff --git a/src/main/java/forge/card/cardFactory/AbstractCardFactory.java b/src/main/java/forge/card/cardFactory/AbstractCardFactory.java index 58ac00e3188..38bead403cc 100644 --- a/src/main/java/forge/card/cardFactory/AbstractCardFactory.java +++ b/src/main/java/forge/card/cardFactory/AbstractCardFactory.java @@ -75,15 +75,15 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn * * To get a full-fledged card, see allCards field or the iterator method. */ - private Map map = new TreeMap(); + private final Map map = new TreeMap(); /** This is a special list of cards, with all abilities attached. */ - private CardList allCards = new CardList(); + private final CardList allCards = new CardList(); private Set removedCardList; - private Card blankCard = new Card(); // new code + private final Card blankCard = new Card(); // new code - private CardList copiedList = new CardList(); + private final CardList copiedList = new CardList(); /** *

@@ -94,7 +94,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn * a {@link java.io.File} object. */ protected AbstractCardFactory(final File file) { - SpellAbility spell = new SpellAbility(SpellAbility.Spell, blankCard) { + final SpellAbility spell = new SpellAbility(SpellAbility.Spell, this.blankCard) { // neither computer nor human play can play this card @Override public boolean canPlay() { @@ -105,16 +105,16 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn public void resolve() { } }; - blankCard.addSpellAbility(spell); + this.blankCard.addSpellAbility(spell); spell.setManaCost("1"); - blankCard.setName("Removed Card"); + this.blankCard.setName("Removed Card"); // owner and controller will be wrong sometimes // but I don't think it will matter // theoretically blankCard will go to the wrong graveyard - blankCard.setOwner(AllZone.getHumanPlayer()); + this.blankCard.setOwner(AllZone.getHumanPlayer()); - removedCardList = new TreeSet(FileUtil.readFile(ForgeProps.getFile(REMOVED))); + this.removedCardList = new TreeSet(FileUtil.readFile(ForgeProps.getFile(NewConstants.REMOVED))); } // constructor @@ -124,7 +124,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn * @return allCards */ protected final CardList getAllCards() { - return allCards; + return this.allCards; } // getAllCards() /** @@ -133,7 +133,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn * @return map */ protected final Map getMap() { - return map; + return this.map; } /** @@ -144,7 +144,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn */ @Override public Iterator iterator() { - return new ImmutableIterableFrom(allCards); + return new ImmutableIterableFrom(this.allCards); } /** @@ -157,7 +157,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn */ @Override public final int size() { - return allCards.size(); + return this.allCards.size(); } /** @@ -171,7 +171,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn */ @Override public final Card copyCard(final Card in) { - Card out = getCard(in.getName(), in.getOwner()); + final Card out = this.getCard(in.getName(), in.getOwner()); out.setUniqueNumber(in.getUniqueNumber()); CardFactoryUtil.copyCharacteristics(in, out); @@ -189,7 +189,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn out.setEnchantedBy(in.getEnchantedBy()); out.setEnchanting(in.getEnchanting()); out.setClones(in.getClones()); - for (Object o : in.getRemembered()) { + for (final Object o : in.getRemembered()) { out.addRemembered(o); } @@ -209,14 +209,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public final Card copyCardintoNew(final Card in) { - Card out = CardFactoryUtil.copyStats(in); + final Card out = CardFactoryUtil.copyStats(in); out.setOwner(in.getOwner()); - CardList all = new CardList(getAllCards()); + final CardList all = new CardList(this.getAllCards()); CardList tokens = AllZoneUtil.getCardsIn(Zone.Battlefield); tokens = tokens.filter(CardListFilter.TOKEN); all.addAll(tokens); out.setCopiedSpell(true); - copiedList.add(out); + this.copiedList.add(out); return out; } @@ -239,14 +239,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn public final void copySpellontoStack(final Card source, final Card original, final SpellAbility sa, final boolean bCopyDetails) { if (sa.getPayCosts() == null) { - copySpellontoStack(source, source, bCopyDetails); + this.copySpellontoStack(source, source, bCopyDetails); return; } - Card c = AllZone.getCardFactory().copyCard(original); + final Card c = AllZone.getCardFactory().copyCard(original); c.addController(source.getController()); c.setCopiedSpell(true); - SpellAbility copySA = sa.copy(); + final SpellAbility copySA = sa.copy(); copySA.setSourceCard(c); if (bCopyDetails) { @@ -282,7 +282,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn */ @Override public final void copySpellontoStack(final Card source, final Card original, final boolean bCopyDetails) { - SpellAbility[] sas = original.getSpellAbility(); + final SpellAbility[] sas = original.getSpellAbility(); SpellAbility sa = null; for (int i = 0; i < sas.length; i++) { if (original.getAbilityUsed() == i) { @@ -291,7 +291,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } if (sa == null) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Couldn't find matching SpellAbility to copy Source: ").append(source); sb.append(" Spell to Copy: ").append(source); System.out.println(sb.toString()); @@ -299,21 +299,21 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } if (sa.getPayCosts() != null) { - copySpellontoStack(source, original, sa, bCopyDetails); + this.copySpellontoStack(source, original, sa, bCopyDetails); return; } - Card c = AllZone.getCardFactory().copyCardintoNew(original); + final Card c = AllZone.getCardFactory().copyCardintoNew(original); SpellAbility copySA = null; - for (SpellAbility s : c.getSpellAbility()) { + for (final SpellAbility s : c.getSpellAbility()) { if (s.equals(sa)) { copySA = s; } } if (copySA == null) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Couldn't find matching SpellAbility to copy Source: ").append(source); sb.append(" Spell to Copy: ").append(source); System.out.println(sb.toString()); @@ -374,11 +374,11 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn */ @Override public final Card getCard(final String cardName, final Player owner) { - if (removedCardList.contains(cardName) || cardName.equals(blankCard.getName())) { - return blankCard; + if (this.removedCardList.contains(cardName) || cardName.equals(this.blankCard.getName())) { + return this.blankCard; } - return getCard2(cardName, owner); + return this.getCard2(cardName, owner); } /** @@ -393,23 +393,23 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn */ @Override public final CardList getRandomCombinationWithoutRepetition(final int numCards) { - Set intSelections = new TreeSet(); + final Set intSelections = new TreeSet(); - if (numCards >= size()) { + if (numCards >= this.size()) { throw new IllegalArgumentException("numCards (" + numCards + ") is larger than the size of the card database."); - } else if (numCards >= size() / 4) { + } else if (numCards >= (this.size() / 4)) { throw new IllegalArgumentException("numCards (" + numCards + ") is too large for this algorithm; it will take too long to complete."); } while (intSelections.size() < numCards) { - intSelections.add((int) (Math.random() * size())); + intSelections.add((int) (Math.random() * this.size())); } - CardList result = new CardList(numCards); - for (Integer index : intSelections) { - result.add(allCards.get(index)); + final CardList result = new CardList(numCards); + for (final Integer index : intSelections) { + result.add(this.allCards.get(index)); } return result; @@ -424,25 +424,25 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn protected final void addAbilityFactoryAbilities(final Card card) { // ************************************************** // AbilityFactory cards - ArrayList ia = card.getIntrinsicAbilities(); + final ArrayList ia = card.getIntrinsicAbilities(); if (ia.size() > 0) { for (int i = 0; i < ia.size(); i++) { - AbilityFactory af = new AbilityFactory(); + final AbilityFactory af = new AbilityFactory(); // System.out.println(cardName); - SpellAbility sa = af.getAbility(ia.get(i), card); + final SpellAbility sa = af.getAbility(ia.get(i), card); card.addSpellAbility(sa); - String bbCost = card.getSVar("Buyback"); + final String bbCost = card.getSVar("Buyback"); if (!bbCost.equals("")) { - SpellAbility bbSA = sa.copy(); - String newCost = CardUtil.addManaCosts(card.getManaCost(), bbCost); + final SpellAbility bbSA = sa.copy(); + final String newCost = CardUtil.addManaCosts(card.getManaCost(), bbCost); if (bbSA.getPayCosts() != null) { bbSA.setPayCosts(new Cost(newCost, sa.getSourceCard().getName(), false)); // create // new // abCost } - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Buyback ").append(bbCost).append(" (You may pay an additional ").append(bbCost); sb.append(" as you cast this spell. If you do, put this card into your hand as it resolves.)"); bbSA.setDescription(sb.toString()); @@ -468,7 +468,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn */ protected Card getCard2(final String cardName, final Player owner) { // o should be Card object - Object o = map.get(cardName); + final Object o = this.map.get(cardName); if (o == null) { throw new RuntimeException("CardFactory : getCard() invalid card name - " + cardName); } @@ -488,7 +488,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn CardFactoryUtil.parseKeywords(card, cardName); - addAbilityFactoryAbilities(card); + this.addAbilityFactoryAbilities(card); // register static abilities ArrayList stAbs = card.getStaticAbilityStrings(); @@ -500,7 +500,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn if (card.hasAlternateState()) { card.changeState(); - addAbilityFactoryAbilities(card); + this.addAbilityFactoryAbilities(card); stAbs = card.getStaticAbilityStrings(); if (stAbs.size() > 0) { for (int i = 0; i < stAbs.size(); i++) { @@ -532,7 +532,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn if (card2 != null) { return CardFactoryUtil.postFactoryKeywords(card2); } else if (cardName.equals("Bridge from Below")) { - SpellAbility spell = new Spell_Permanent(card) { + final SpellAbility spell = new Spell_Permanent(card) { private static final long serialVersionUID = 7254358703158629514L; @Override @@ -567,7 +567,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn imageName = "B 1 1 Thrull"; color = "B"; } else if (player.isHuman()) { - Object q = GuiUtils.getChoiceOptional("Select type of creature", choices); + final Object q = GuiUtils.getChoiceOptional("Select type of creature", choices); if (q != null) { if (q.equals("Citizen")) { type = "Citizen"; @@ -599,7 +599,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn final String col = color; // card.setChosenType(input[0]); - Cost a1Cost = new Cost("3 T", cardName, true); + final Cost a1Cost = new Cost("3 T", cardName, true); final Ability_Activated a1 = new Ability_Activated(card, a1Cost, null) { private static final long serialVersionUID = -2114111483117171609L; @@ -611,7 +611,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append(" - ").append(card.getController()); sb.append(" puts a 1/1 ").append(t).append(" token onto the battlefield"); a1.setStackDescription(sb.toString()); @@ -619,12 +619,13 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn card.addSpellAbility(a1); } }; // ability - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 7202704600935499188L; + @Override public void execute() { ability.setStackDescription("As Sarpadian Empires, Vol. VII enters the battlefield, " - + "choose white Citizen, blue Camarid, black Thrull, red Goblin, or green Saproling."); + + "choose white Citizen, blue Camarid, black Thrull, red Goblin, or green Saproling."); AllZone.getStack().addSimultaneousStackEntry(ability); @@ -654,13 +655,13 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public boolean canPlay() { - CardList grave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); - CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); - return (grave.getType("Creature").size() > 1 || aiGrave.getType("Creature").size() > 1) + final CardList grave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); + final CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); + return ((grave.getType("Creature").size() > 1) || (aiGrave.getType("Creature").size() > 1)) && super.canPlay(); } }; - Input soilTarget = new Input() { + final Input soilTarget = new Input() { private boolean once = false; private static final long serialVersionUID = 8243511353958609599L; @@ -672,9 +673,9 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn grave = grave.getType("Creature"); aiGrave = aiGrave.getType("Creature"); - if (once || (grave.size() < 2 && aiGrave.size() < 2)) { - once = false; - stop(); + if (this.once || ((grave.size() < 2) && (aiGrave.size() < 2))) { + this.once = false; + this.stop(); } else { CardList chooseGrave; if (grave.size() < 2) { @@ -686,10 +687,10 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn chooseGrave.addAll(grave); } - Object o = GuiUtils.getChoice("Choose first creature to exile", chooseGrave.toArray()); + final Object o = GuiUtils.getChoice("Choose first creature to exile", chooseGrave.toArray()); if (o != null) { CardList newGrave; - Card c = (Card) o; + final Card c = (Card) o; if (c.getOwner().isHuman()) { newGrave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); } else { @@ -699,27 +700,27 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn newGrave = newGrave.getType("Creature"); newGrave.remove(c); - Object o2 = GuiUtils.getChoice("Choose second creature to exile", newGrave.toArray()); + final Object o2 = GuiUtils.getChoice("Choose second creature to exile", newGrave.toArray()); if (o2 != null) { - Card c2 = (Card) o2; + final Card c2 = (Card) o2; newGrave.remove(c2); AllZone.getGameAction().exile(c); AllZone.getGameAction().exile(c2); - once = true; + this.once = true; AllZone.getStack().addSimultaneousStackEntry(nightSoil); } } } - stop(); + this.stop(); } }; nightSoil.setDescription("1, Exile two creature cards from a single graveyard: " + "Put a 1/1 green Saproling creature token onto the battlefield."); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getController()).append(" puts a 1/1 green Saproling creature token onto the battlefield."); nightSoil.setStackDescription(sb.toString()); @@ -732,16 +733,16 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn final Ability ability1 = new Ability(card, "0") { @Override public void resolve() { - PlayerZone hand = AllZone.getHumanPlayer().getZone(Constant.Zone.Hand); + final PlayerZone hand = AllZone.getHumanPlayer().getZone(Constant.Zone.Hand); if (hand.size() == 0) { return; } - CardList creatures = new CardList(); + final CardList creatures = new CardList(); for (int i = 0; i < hand.size(); i++) { - if (hand.get(i).isCreature() && CardUtil.getConvertedManaCost(hand.get(i).getManaCost()) <= 3) { + if (hand.get(i).isCreature() && (CardUtil.getConvertedManaCost(hand.get(i).getManaCost()) <= 3)) { creatures.add(hand.get(i)); } } @@ -750,9 +751,9 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn return; } - Object o = GuiUtils.getChoiceOptional("Select target creature to play", creatures.toArray()); + final Object o = GuiUtils.getChoiceOptional("Select target creature to play", creatures.toArray()); if (o != null) { - Card c = (Card) o; + final Card c = (Card) o; AllZone.getStack().add(c.getSpellPermanent()); } @@ -780,31 +781,31 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Volrath's Dungeon")) { - Cost dungeonCost = new Cost("Discard<1/Card>", cardName, true); - Target dungeonTgt = new Target(card, card + " - Select target player", "Player".split(",")); + final Cost dungeonCost = new Cost("Discard<1/Card>", cardName, true); + final Target dungeonTgt = new Target(card, card + " - Select target player", "Player".split(",")); final SpellAbility dungeon = new Ability_Activated(card, dungeonCost, dungeonTgt) { private static final long serialVersionUID = 334033015590321821L; @Override public void chooseTargetAI() { - setTargetPlayer(AllZone.getHumanPlayer()); + this.setTargetPlayer(AllZone.getHumanPlayer()); } @Override public void resolve() { - Player target = getTargetPlayer(); - CardList targetHand = target.getCardsIn(Zone.Hand); + final Player target = this.getTargetPlayer(); + final CardList targetHand = target.getCardsIn(Zone.Hand); if (targetHand.size() == 0) { return; } if (target.isHuman()) { - Object discard = GuiUtils.getChoice("Select Card to place on top of library.", + final Object discard = GuiUtils.getChoice("Select Card to place on top of library.", targetHand.toArray()); - Card card = (Card) discard; + final Card card = (Card) discard; AllZone.getGameAction().moveToLibrary(card); } else if (target.isComputer()) { AllZone.getComputerPlayer().handToLibrary(1, "Top"); @@ -819,7 +820,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn }; // SpellAbility dungeon - Cost bailCost = new Cost("PayLife<5>", cardName, true); + final Cost bailCost = new Cost("PayLife<5>", cardName, true); final SpellAbility bail = new Ability_Activated(card, bailCost, null) { private static final long serialVersionUID = -8990402917139817175L; @@ -835,7 +836,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public boolean canPlayAI() { - return card.getController().isHuman() && AllZone.getComputerPlayer().getLife() >= 9 + return card.getController().isHuman() && (AllZone.getComputerPlayer().getLife() >= 9) && super.canPlay() && !AllZone.getComputerPlayer().getZone(Zone.Hand).isEmpty(); } @@ -872,10 +873,10 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn public void selectCard(final Card c, final PlayerZone zone) { if (zone.is(Constant.Zone.Hand) && c.isLand()) { AllZone.getHumanPlayer().discard(c, null); - stop(); + this.stop(); } else if (c.equals(card)) { AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } } }; // Input @@ -892,6 +893,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } else { CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (c.isLand()); } @@ -900,18 +902,19 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } // else } // resolve() }; // SpellAbility - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = -7679939432259603542L; + @Override public void execute() { ability.setStackDescription("If Mox Diamond would enter the battlefield, you may " - + "discard a land card instead. If you do, put Mox Diamond onto the battlefield. " + + "discard a land card instead. If you do, put Mox Diamond onto the battlefield. " + "If you don't, put it into its owner's graveyard."); AllZone.getStack().addSimultaneousStackEntry(ability); } }; - SpellAbility spell = new Spell_Permanent(card) { + final SpellAbility spell = new Spell_Permanent(card) { private static final long serialVersionUID = -1818766848857998431L; // could never get the AI to work correctly @@ -926,11 +929,12 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn CardList list = card.getController().getCardsIn(Zone.Hand); list.remove(card); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (c.isLand()); } }); - return list.size() != 0 && super.canPlay(); + return (list.size() != 0) && super.canPlay(); } // canPlay() }; card.addComesIntoPlayCommand(intoPlay); @@ -950,8 +954,8 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public boolean canPlayAI() { - CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); - CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); // only play standstill if comp controls more creatures than // human @@ -964,14 +968,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Goblin Charbelcher")) { - Cost abCost = new Cost("3 T", cardName, true); + final Cost abCost = new Cost("3 T", cardName, true); final Ability_Activated ability = new Ability_Activated(card, abCost, new Target(card, "TgtCP")) { private static final long serialVersionUID = -840041589720758423L; @Override public void resolve() { - CardList topOfLibrary = card.getController().getCardsIn(Zone.Library); - CardList revealed = new CardList(); + final CardList topOfLibrary = card.getController().getCardsIn(Zone.Library); + final CardList revealed = new CardList(); if (topOfLibrary.size() == 0) { return; @@ -984,7 +988,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn while (c == null) { revealed.add(topOfLibrary.get(count)); crd = topOfLibrary.get(count++); - if (crd.isLand() || count == topOfLibrary.size()) { + if (crd.isLand() || (count == topOfLibrary.size())) { c = crd; damage = count; if (crd.isLand()) { @@ -998,28 +1002,28 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } // while GuiUtils.getChoiceOptional("Revealed cards:", revealed.toArray()); - if (getTargetCard() != null) { - if (AllZoneUtil.isCardInPlay(getTargetCard()) - && CardFactoryUtil.canTarget(card, getTargetCard())) { - getTargetCard().addDamage(damage, card); + if (this.getTargetCard() != null) { + if (AllZoneUtil.isCardInPlay(this.getTargetCard()) + && CardFactoryUtil.canTarget(card, this.getTargetCard())) { + this.getTargetCard().addDamage(damage, card); } } else { - getTargetPlayer().addDamage(damage, card); + this.getTargetPlayer().addDamage(damage, card); } } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(abCost); sb.append("Reveal cards from the top of your library until you reveal a land card. " - + "Goblin Charbelcher deals damage equal "); + + "Goblin Charbelcher deals damage equal "); sb.append("to the number of nonland cards revealed this way to target creature or player. " - + "If the revealed land card was a Mountain, "); + + "If the revealed land card was a Mountain, "); sb.append("Goblin Charbelcher deals double that damage instead. Put the revealed cards on " - + "the bottom of your library in any order."); + + "the bottom of your library in any order."); ability.setDescription(sb.toString()); - ability.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + ability.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); card.addSpellAbility(ability); } // *************** END ************ END ************************** @@ -1032,25 +1036,25 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn * next turn's upkeep. */ - Cost abCost = new Cost("1 T Sac<1/CARDNAME>", cardName, true); - Target target = new Target(card, "Select target player", new String[] { "Player" }); + final Cost abCost = new Cost("1 T Sac<1/CARDNAME>", cardName, true); + final Target target = new Target(card, "Select target player", new String[] { "Player" }); final Ability_Activated ability = new Ability_Activated(card, abCost, target) { private static final long serialVersionUID = -6711849408085138636L; @Override public boolean canPlayAI() { - return getComputerLands().size() >= 4; + return this.getComputerLands().size() >= 4; } @Override public void chooseTargetAI() { - setTargetPlayer(AllZone.getComputerPlayer()); + this.setTargetPlayer(AllZone.getComputerPlayer()); } // chooseTargetAI() @Override public void resolve() { final int limit = 4; // at most, this can target 4 cards - final Player player = getTargetPlayer(); + final Player player = this.getTargetPlayer(); CardList lands = player.getCardsIn(Zone.Graveyard); lands = lands.filter(CardListFilter.BASIC_LANDS); @@ -1071,18 +1075,18 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn if (i == 4) { title = "Put fourth from top of library: "; } - Object o = GuiUtils.getChoiceOptional(title, lands.toArray()); + final Object o = GuiUtils.getChoiceOptional(title, lands.toArray()); if (o == null) { break; } - Card c1 = (Card) o; + final Card c1 = (Card) o; lands.remove(c1); // remove from the display list AllZone.getGameAction().moveToLibrary(c1, i - 1); } } else { // Computer // based on current AI, computer should always target // himself. - CardList list = getComputerLands(); + final CardList list = this.getComputerLands(); int max = list.size(); if (max > limit) { max = limit; @@ -1097,7 +1101,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } private CardList getComputerLands() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); + final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); return list.getType("Basic"); } }; // ability @@ -1111,14 +1115,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Grindstone")) { - Target target = new Target(card, "Select target player", new String[] { "Player" }); - Cost abCost = new Cost("3 T", cardName, true); - Ability_Activated ab1 = new Ability_Activated(card, abCost, target) { + final Target target = new Target(card, "Select target player", new String[] { "Player" }); + final Cost abCost = new Cost("3 T", cardName, true); + final Ability_Activated ab1 = new Ability_Activated(card, abCost, target) { private static final long serialVersionUID = -6281219446216L; @Override public boolean canPlayAI() { - CardList libList = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + final CardList libList = AllZone.getHumanPlayer().getCardsIn(Zone.Library); // CardList list = // AllZoneUtil.getCardsInPlay("Painter's Servant"); return libList.size() > 0; // && list.size() > 0; @@ -1126,18 +1130,18 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public void resolve() { - Player target = getTargetPlayer(); - CardList library = getTargetPlayer().getCardsIn(Zone.Library); + final Player target = this.getTargetPlayer(); + final CardList library = this.getTargetPlayer().getCardsIn(Zone.Library); boolean loop = true; - CardList grinding = new CardList(); + final CardList grinding = new CardList(); do { grinding.clear(); for (int i = 0; i < 2; i++) { // Move current grinding to a different list if (library.size() > 0) { - Card c = library.get(0); + final Card c = library.get(0); grinding.add(c); library.remove(c); } else { @@ -1154,7 +1158,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } while (loop); } }; - ab1.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + ab1.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); ab1.setDescription(abCost + "Put the top two cards of target player's library into that player's graveyard. " + "If both cards share a color, repeat this process."); @@ -1166,6 +1170,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn final Command comesIntoPlay = new Command() { private static final long serialVersionUID = 4245563898487609274L; + @Override public void execute() { card.addCounter(Counters.CHARGE, card.getMultiKickerMagnitude()); card.setMultiKickerMagnitude(0); @@ -1177,7 +1182,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Barl's Cage")) { final String[] tgts = { "Creature" }; - Target target = new Target(card, "Select target creature.", tgts, "1", "1"); + final Target target = new Target(card, "Select target creature.", tgts, "1", "1"); final Cost cost = new Cost("3", card.getName(), true); @@ -1186,11 +1191,11 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public boolean canPlayAI() { - Card c = getCreature(); + final Card c = this.getCreature(); if (c == null) { return false; } else { - setTargetCard(c); + this.setTargetCard(c); return true; } } // canPlayAI() @@ -1204,12 +1209,12 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn return null; } - return CardFactoryUtil.AI_getBestCreature(tappedCreatures); + return CardFactoryUtil.getBestCreatureAI(tappedCreatures); } @Override public void resolve() { - Card target = getTargetCard(); + final Card target = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(target) && CardFactoryUtil.canTarget(card, target)) { target.addExtrinsicKeyword("This card doesn't untap during your next untap step."); } // is card in play? @@ -1226,14 +1231,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn public void resolve() { String cardName = ""; if (card.getController().isHuman()) { - List cards = new ArrayList(); - for (CardPrinted c : CardDb.instance().getAllUniqueCards()) { + final List cards = new ArrayList(); + for (final CardPrinted c : CardDb.instance().getAllUniqueCards()) { cards.add(c.getName()); } Collections.sort(cards); // use standard forge's list selection dialog - ListChooser c = new ListChooser( + final ListChooser c = new ListChooser( "Name a card to disable activation of its non-mana abilities", 1, 1, cards); c.show(); // still missing a listener to display the card preview @@ -1247,20 +1252,22 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } }; // ability ability.setStackDescription("As Pithing Needle enters the battlefield, name a card."); - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 2266471224097876143L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry(ability); } }; - Command leavesPlay = new Command() { + final Command leavesPlay = new Command() { private static final long serialVersionUID = 7079781778752377760L; + @Override public void execute() { card.setSVar("Pithing Target", ""); } @@ -1272,20 +1279,21 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Phyrexian Processor")) { - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 5634360316643996274L; + @Override public void execute() { - Player player = card.getController(); + final Player player = card.getController(); int lifeToPay = 0; if (player.isHuman()) { - int num = card.getController().getLife(); - String[] choices = new String[num + 1]; + final int num = card.getController().getLife(); + final String[] choices = new String[num + 1]; for (int j = 0; j <= num; j++) { choices[j] = "" + j; } - String answer = (String) (GuiUtils.getChoiceOptional("Life to pay:", choices)); + final String answer = (GuiUtils.getChoiceOptional("Life to pay:", choices)); lifeToPay = Integer.parseInt(answer); } else { // not implemented for Compy @@ -1302,7 +1310,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Scroll Rack")) { - Cost abCost = new Cost("1 T", cardName, true); + final Cost abCost = new Cost("1 T", cardName, true); final Ability_Activated ability = new Ability_Activated(card, abCost, null) { private static final long serialVersionUID = -5588587187720068547L; @@ -1312,41 +1320,41 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn if (card.getController().isHuman()) { AllZone.getInputControl().setInput(new Input() { private static final long serialVersionUID = -2305549394512889450L; - private CardList exiled = new CardList(); + private final CardList exiled = new CardList(); @Override public void showMessage() { AllZone.getDisplay().showMessage( - card.getName() + " - Exile cards from hand. Currently, " + exiled.size() + card.getName() + " - Exile cards from hand. Currently, " + this.exiled.size() + " selected. (Press OK when done.)"); ButtonUtil.enableOnlyOK(); } @Override public void selectButtonOK() { - done(); + this.done(); } @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand, AllZone.getHumanPlayer()) && !exiled.contains(c)) { - exiled.add(c); - showMessage(); + if (zone.is(Constant.Zone.Hand, AllZone.getHumanPlayer()) && !this.exiled.contains(c)) { + this.exiled.add(c); + this.showMessage(); } } public void done() { // exile those cards - for (Card c : exiled) { + for (final Card c : this.exiled) { AllZone.getGameAction().exile(c); } // Put that many cards from the top of your // library into your hand. // Ruling: This is not a draw... - PlayerZone lib = AllZone.getHumanPlayer().getZone(Constant.Zone.Library); + final PlayerZone lib = AllZone.getHumanPlayer().getZone(Constant.Zone.Library); int numCards = 0; - while (lib.size() > 0 && numCards < exiled.size()) { + while ((lib.size() > 0) && (numCards < this.exiled.size())) { AllZone.getGameAction().moveToHand(lib.get(0)); numCards++; } @@ -1356,15 +1364,15 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // Then look at the exiled cards and put them on // top of your library in any order. - while (exiled.size() > 0) { - Object o = GuiUtils.getChoice("Put a card on top of your library.", - exiled.toArray()); - Card c1 = (Card) o; + while (this.exiled.size() > 0) { + final Object o = GuiUtils.getChoice("Put a card on top of your library.", + this.exiled.toArray()); + final Card c1 = (Card) o; AllZone.getGameAction().moveToLibrary(c1); - exiled.remove(c1); + this.exiled.remove(c1); } - stop(); + this.stop(); } }); } @@ -1375,8 +1383,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn return false; } }; // ability - ability.setDescription(abCost - + "Exile any number of cards from your hand face down. Put that many cards " + ability.setDescription(abCost + "Exile any number of cards from your hand face down. Put that many cards " + "from the top of your library into your hand. Then look at the exiled cards " + "and put them on top of your library in any order."); ability.setStackDescription(cardName + " - exile any number of cards from your hand."); @@ -1390,19 +1397,19 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn * it's the named card, Cursed Scroll deals 2 damage to target * creature or player. */ - Cost abCost = new Cost("3 T", cardName, true); + final Cost abCost = new Cost("3 T", cardName, true); final Ability_Activated ability = new Ability_Activated(card, abCost, new Target(card, "TgtCP")) { private static final long serialVersionUID = 7550743617522146304L; @Override public void resolve() { - Player player = card.getController(); + final Player player = card.getController(); String input = ""; if (player.isHuman()) { input = JOptionPane.showInputDialog(null, "Name a card.", card.getName(), JOptionPane.QUESTION_MESSAGE); } else { - CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); if (!hand.isEmpty()) { hand.shuffle(); input = hand.get(0).getName(); @@ -1410,17 +1417,17 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } // reveal a card at random, and damage if it matches - CardList hand = card.getController().getCardsIn(Zone.Hand); + final CardList hand = card.getController().getCardsIn(Zone.Hand); if (!hand.isEmpty()) { hand.shuffle(); - Card c = hand.get(0); + final Card c = hand.get(0); JOptionPane.showMessageDialog(null, "Revealed card:\n" + c.getName(), card.getName(), JOptionPane.PLAIN_MESSAGE); if (input.equals(c.getName())) { - if (null != getTargetCard()) { - getTargetCard().addDamage(2, card); - } else if (null != getTargetPlayer()) { - getTargetPlayer().addDamage(2, card); + if (null != this.getTargetCard()) { + this.getTargetCard().addDamage(2, card); + } else if (null != this.getTargetPlayer()) { + this.getTargetPlayer().addDamage(2, card); } } } else { @@ -1435,7 +1442,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } }; - StringBuilder sbStack = new StringBuilder(); + final StringBuilder sbStack = new StringBuilder(); sbStack.append(card).append(" - Name a card."); ability.setStackDescription(sbStack.toString()); @@ -1443,7 +1450,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn + "Name a card. Reveal a card at random from your hand. If it's the named card, " + "CARDNAME deals 2 damage to target creature or player."); - ability.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + ability.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); card.addSpellAbility(ability); } // *************** END ************ END ************************** @@ -1462,14 +1469,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public boolean canPlay() { - PlayerZone lib = card.getController().getZone(Constant.Zone.Library); - return super.canPlay() && (lib.size() > 0 && lib.get(0).equals(topCard[0])); + final PlayerZone lib = card.getController().getZone(Constant.Zone.Library); + return super.canPlay() && ((lib.size() > 0) && lib.get(0).equals(topCard[0])); } @Override public void resolve() { - Card freeCard = topCard[0]; - Player player = card.getController(); + final Card freeCard = topCard[0]; + final Player player = card.getController(); if (freeCard != null) { if (freeCard.isLand()) { if (player.canPlayLand()) { @@ -1497,13 +1504,13 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn freeCast.setDescription("Play the previously revealed top card of your library for free."); freeCast.setStackDescription(cardName + " - play card without paying its mana cost."); - Cost abCost = new Cost("5 T", cardName, true); + final Cost abCost = new Cost("5 T", cardName, true); final Ability_Activated ability = new Ability_Activated(card, abCost, null) { private static final long serialVersionUID = -7328518969488588777L; @Override public void resolve() { - PlayerZone lib = card.getController().getZone(Constant.Zone.Library); + final PlayerZone lib = card.getController().getZone(Constant.Zone.Library); if (lib.size() > 0) { // shuffle your library @@ -1519,6 +1526,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn AllZone.getEndOfTurn().addUntil(new Command() { private static final long serialVersionUID = -2860753262177388046L; + @Override public void execute() { card.removeSpellAbility(freeCast); card.removeExtrinsicKeyword("Play with the top card of your library revealed."); @@ -1533,14 +1541,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } }; - StringBuilder sbStack = new StringBuilder(); + final StringBuilder sbStack = new StringBuilder(); sbStack.append(card).append(" - Shuffle your library, then reveal the top card."); ability.setStackDescription(sbStack.toString()); - StringBuilder sbDesc = new StringBuilder(); + final StringBuilder sbDesc = new StringBuilder(); sbDesc.append("Shuffle your library, then reveal the top card. "); sbDesc.append("Until end of turn, for as long as that card remains on top of your library, " - + "play with the top card of your library revealed "); + + "play with the top card of your library revealed "); sbDesc.append("and you may play that card without paying its mana cost. "); sbDesc.append("(If it has X in its mana cost, X is 0.)"); ability.setDescription(abCost + sbDesc.toString()); @@ -1553,17 +1561,18 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn final SpellAbility loseAllLife = new Ability(card, "0") { @Override public void resolve() { - int life = card.getController().getLife(); + final int life = card.getController().getLife(); card.getController().loseLife(life, card); } }; - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 1337794055075168785L; + @Override public void execute() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName).append(" - ").append(card.getController()); sb.append(" loses life equal to his or her life total."); loseAllLife.setStackDescription(sb.toString()); @@ -1580,12 +1589,13 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } }; - Command toGrave = new Command() { + final Command toGrave = new Command() { private static final long serialVersionUID = 5863295714122376047L; + @Override public void execute() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName).append(" - ").append(card.getController()); sb.append("loses the game."); loseGame.setStackDescription(sb.toString()); @@ -1602,7 +1612,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Triangle of War")) { - Target t2 = new Target(card, "Select target creature an opponent controls", + final Target t2 = new Target(card, "Select target creature an opponent controls", "Creature.YouDontCtrl".split(",")); final Ability_Sub sub = new Ability_Sub(card, t2) { private static final long serialVersionUID = -572849470457911366L; @@ -1614,12 +1624,12 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public void resolve() { - Card myc = this.getParent().getTargetCard(); - Card oppc = getTargetCard(); + final Card myc = this.getParent().getTargetCard(); + final Card oppc = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(myc) && AllZoneUtil.isCardInPlay(oppc)) { if (CardFactoryUtil.canTarget(card, myc) && CardFactoryUtil.canTarget(card, oppc)) { - int myPower = myc.getNetAttack(); - int oppPower = oppc.getNetAttack(); + final int myPower = myc.getNetAttack(); + final int oppPower = oppc.getNetAttack(); myc.addDamage(oppPower, oppc); oppc.addDamage(myPower, myc); } @@ -1632,8 +1642,8 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } }; - Cost abCost = new Cost("2 Sac<1/CARDNAME>", cardName, true); - Target t1 = new Target(card, "Select target creature you control", "Creature.YouCtrl".split(",")); + final Cost abCost = new Cost("2 Sac<1/CARDNAME>", cardName, true); + final Target t1 = new Target(card, "Select target creature you control", "Creature.YouCtrl".split(",")); final Ability_Activated ability = new Ability_Activated(card, abCost, t1) { private static final long serialVersionUID = 2312243293988795896L; @@ -1664,10 +1674,11 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn final Command leaves = new Command() { private static final long serialVersionUID = 6212378498863558380L; + @Override public void execute() { - Card orig = cfact.getCard(card.getName(), card.getController()); - PlayerZone dest = AllZone.getZoneOf(card.getCurrentlyCloningCard()); + final Card orig = cfact.getCard(card.getName(), card.getController()); + final PlayerZone dest = AllZone.getZoneOf(card.getCurrentlyCloningCard()); AllZone.getGameAction().moveTo(dest, orig); dest.remove(card.getCurrentlyCloningCard()); @@ -1679,16 +1690,16 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public boolean canPlayAI() { - CardList arts = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.ARTIFACTS); + final CardList arts = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.ARTIFACTS); return !arts.isEmpty(); } @Override public void resolve() { if (card.getController().isComputer()) { - CardList arts = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.ARTIFACTS); + final CardList arts = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.ARTIFACTS); if (!arts.isEmpty()) { - copyTarget[0] = CardFactoryUtil.AI_getBestArtifact(arts); + copyTarget[0] = CardFactoryUtil.getBestArtifactAI(arts); } } @@ -1704,7 +1715,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn cloned[0].setCurSetCode(copyTarget[0].getCurSetCode()); cloned[0].setImageFilename(copyTarget[0].getImageFilename()); - for (SpellAbility sa : copyTarget[0].getSpellAbilities()) { + for (final SpellAbility sa : copyTarget[0].getSpellAbilities()) { cloned[0].addSpellAbility(sa); } @@ -1714,7 +1725,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } }; // SpellAbility - Input runtime = new Input() { + final Input runtime = new Input() { private static final long serialVersionUID = 8117808324791871452L; @Override @@ -1725,14 +1736,14 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override public void selectCard(final Card c, final PlayerZone z) { if (z.is(Constant.Zone.Battlefield) && c.isArtifact()) { copyTarget[0] = c; - stopSetNext(new Input_PayManaCost(copy)); + this.stopSetNext(new Input_PayManaCost(copy)); } } }; @@ -1746,14 +1757,12 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn // *************** START *********** START ************************** else if (cardName.equals("Sylvan Library")) { - final Trigger drawStepTrigger = forge.card.trigger.TriggerHandler - .parseTrigger( - "Mode$ Phase | Phase$ Draw | ValidPlayer$ You | OptionalDecider$ You | " - + "TriggerZones$ Battlefield | Secondary$ True | TriggerDescription$ At the beginning of " - + "your draw step, you may draw two additional cards. If you do, choose two " - + "cards in your hand drawn this turn. For each of those cards, " - + "pay 4 life or put the card on top of your library.", - card, true); + final Trigger drawStepTrigger = forge.card.trigger.TriggerHandler.parseTrigger( + "Mode$ Phase | Phase$ Draw | ValidPlayer$ You | OptionalDecider$ You | " + + "TriggerZones$ Battlefield | Secondary$ True | TriggerDescription$ At the beginning of " + + "your draw step, you may draw two additional cards. If you do, choose two " + + "cards in your hand drawn this turn. For each of those cards, " + + "pay 4 life or put the card on top of your library.", card, true); final Ability ability = new Ability(card, "") { @Override public void resolve() { @@ -1769,7 +1778,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public void showMessage() { if (AllZone.getHumanPlayer().getZone(Constant.Zone.Hand).size() == 0) { - stop(); + this.stop(); } AllZone.getDisplay().showMessage(prompt); ButtonUtil.disableAll(); @@ -1778,14 +1787,13 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn @Override public void selectCard(final Card card, final PlayerZone zone) { if (zone.is(Constant.Zone.Hand) && card.getDrawnThisTurn()) { - if (player.canPayLife(4) && GameActionUtil - .showYesNoDialog(card, cardQuestion)) { + if (player.canPayLife(4) && GameActionUtil.showYesNoDialog(card, cardQuestion)) { player.payLife(4, card); // card stays in hand } else { AllZone.getGameAction().moveToLibrary(card); } - stop(); + this.stop(); } } }); // end Input @@ -1796,9 +1804,9 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn } // resolve }; // Ability - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("At the beginning of your draw step, you may draw two additional cards. " - + "If you do, choose two cards in your hand drawn this turn. For each of those cards, " + + "If you do, choose two cards in your hand drawn this turn. For each of those cards, " + "pay 4 life or put the card on top of your library."); ability.setStackDescription(sb.toString()); diff --git a/src/main/java/forge/card/cardFactory/CardFactoryInterface.java b/src/main/java/forge/card/cardFactory/CardFactoryInterface.java index d094674ae81..10b273b53dc 100644 --- a/src/main/java/forge/card/cardFactory/CardFactoryInterface.java +++ b/src/main/java/forge/card/cardFactory/CardFactoryInterface.java @@ -18,6 +18,7 @@ public interface CardFactoryInterface extends Iterable { * * @return an Iterator that does NOT support the remove method */ + @Override Iterator iterator(); /** diff --git a/src/main/java/forge/card/cardFactory/CardFactoryUtil.java b/src/main/java/forge/card/cardFactory/CardFactoryUtil.java index 00933e3dd52..c0a6e9e47e5 100644 --- a/src/main/java/forge/card/cardFactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardFactory/CardFactoryUtil.java @@ -76,7 +76,7 @@ public class CardFactoryUtil { * a boolean. * @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; if (targeted) { 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 * @return the card */ - public static Card AI_getMostExpensivePermanent(final CardList all) { + public static Card getMostExpensivePermanentAI(final CardList all) { if (all.size() == 0) { return null; } @@ -137,14 +137,14 @@ public class CardFactoryUtil { * a boolean. * @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() { @Override public boolean addCard(final Card c) { 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. * @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; if (targeted) { all = all.filter(new CardListFilter() { @@ -198,7 +198,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} 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"); if (!(land.size() > 0)) { return null; @@ -266,7 +266,7 @@ public class CardFactoryUtil { * a boolean. * @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; all = all.getType("Enchantment"); if (targeted) { @@ -309,7 +309,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} 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; all = all.getType("Artifact"); if (all.size() == 0) { @@ -344,7 +344,7 @@ public class CardFactoryUtil { * a boolean. * @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); artifact = artifact.getType("Artifact"); if (targeted) { @@ -367,7 +367,7 @@ public class CardFactoryUtil { * a {@link forge.Card} object. * @return a boolean. */ - public static boolean AI_doesCreatureAttack(final Card card) { + public static boolean doesCreatureAttackAI(final Card card) { final Combat combat = ComputerUtil.getAttackers(); final Card[] att = combat.getAttackers(); for (final Card element : att) { @@ -626,20 +626,20 @@ public class CardFactoryUtil { * @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 // is of that type if (list.getNotType("Creature").size() == 0) { - return CardFactoryUtil.AI_getBestCreature(list); + return CardFactoryUtil.getBestCreatureAI(list); } if (list.getNotType("Land").size() == 0) { - return CardFactoryUtil.AI_getBestLand(list); + return CardFactoryUtil.getBestLandAI(list); } // TODO - Once we get an EvaluatePermanent this should call // getBestPermanent() - return CardFactoryUtil.AI_getMostExpensivePermanent(list); + return CardFactoryUtil.getMostExpensivePermanentAI(list); } /** @@ -649,7 +649,7 @@ public class CardFactoryUtil { * the list * @return the card */ - public static Card AI_getBestCreature(final CardList list) { + public static Card getBestCreatureAI(final CardList list) { CardList all = list; all = all.getType("Creature"); Card biggest = null; @@ -676,7 +676,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} 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; CardList all = list; all = all.getType("Creature"); @@ -714,7 +714,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} 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; all = all.getType("Creature"); // get smallest creature @@ -749,18 +749,18 @@ public class CardFactoryUtil { * a boolean. * @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) { if (list.size() == 0) { return null; } 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)) { - return CardFactoryUtil.AI_getCheapestPermanent(list.getType("Artifact"), null, false); + return CardFactoryUtil.getCheapestPermanentAI(list.getType("Artifact"), null, false); } if (biasLand && (list.getType("Land").size() > 0)) { @@ -768,7 +768,7 @@ public class CardFactoryUtil { } 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) { @@ -776,7 +776,7 @@ public class CardFactoryUtil { } 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 public boolean addCard(final Card c) { return c.isArtifact() || c.isEnchantment(); @@ -785,12 +785,12 @@ public class CardFactoryUtil { } 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 // 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. * @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() { private static final long serialVersionUID = 2781418414287281005L; @@ -860,7 +860,7 @@ public class CardFactoryUtil { * a {@link java.lang.String} 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() { private static final long serialVersionUID = -6637588517573573232L; @@ -1058,7 +1058,7 @@ public class CardFactoryUtil { final int attack = a; final int defense = d; 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; @Override @@ -1098,13 +1098,13 @@ public class CardFactoryUtil { sb.append(" -"); } 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(); 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. * @return a {@link forge.card.spellability.SpellAbility} object. */ - public static SpellAbility abilitySuspend(final Card sourceCard, final String suspendCost, - final int suspendCounters) { + public static SpellAbility abilitySuspend(final Card sourceCard, final String suspendCost, final int suspendCounters) { // be careful with Suspend ability, it will not hit the stack final SpellAbility suspend = new Ability_Static(sourceCard, suspendCost) { @Override @@ -1406,7 +1405,7 @@ public class CardFactoryUtil { * a {@link forge.card.cost.Cost} 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 Target target = new Target(sourceCard, "Select target creature you control", "Creature.YouCtrl".split(",")); @@ -1443,7 +1442,7 @@ public class CardFactoryUtil { @Override public void chooseTargetAI() { - final Card target = CardFactoryUtil.AI_getBestCreature(this.getCreature()); + final Card target = CardFactoryUtil.getBestCreatureAI(this.getCreature()); this.setTargetCard(target); } @@ -1524,7 +1523,7 @@ public class CardFactoryUtil { * a {@link forge.card.cost.Cost} 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 Command onEquip = new Command() { @@ -1569,7 +1568,7 @@ public class CardFactoryUtil { * a {@link forge.card.cost.Cost} 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 Command onUnEquip = new Command() { @@ -1653,7 +1652,7 @@ public class CardFactoryUtil { public static Command fading(final Card sourceCard, final int power) { final Command fade = new Command() { private static final long serialVersionUID = 431920157968451817L; - public boolean firstTime = true; + private boolean firstTime = true; @Override public void execute() { @@ -1682,7 +1681,7 @@ public class CardFactoryUtil { public static Command vanishing(final Card sourceCard, final int power) { final Command age = new Command() { private static final long serialVersionUID = 431920157968451817L; - public boolean firstTime = true; + private boolean firstTime = true; @Override public void execute() { @@ -1810,9 +1809,9 @@ public class CardFactoryUtil { * a boolean. * @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) { - 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 @@ -1835,7 +1834,7 @@ public class CardFactoryUtil { * a boolean. * @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 Input target = new Input() { private static final long serialVersionUID = -1779224307654698954L; @@ -1892,7 +1891,7 @@ public class CardFactoryUtil { * a boolean. * @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 Input target = new Input() { private static final long serialVersionUID = -3320425330743678663L; @@ -1942,7 +1941,7 @@ public class CardFactoryUtil { * a {@link forge.card.spellability.SpellAbility} 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() { private static final long serialVersionUID = 2029801495067540196L; @@ -1951,7 +1950,7 @@ public class CardFactoryUtil { // get all creatures you control 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)); } }; // Input @@ -1969,10 +1968,10 @@ public class CardFactoryUtil { * a {@link forge.card.spellability.SpellAbility} object. * @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() { private static final long serialVersionUID = 1942999595292561944L; - int n = 0; + private int n = 0; @Override public void showMessage() { @@ -2032,7 +2031,7 @@ public class CardFactoryUtil { * a {@link forge.Command} 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 Input target = new Input() { private static final long serialVersionUID = -1779224307654698954L; @@ -2116,7 +2115,7 @@ public class CardFactoryUtil { * a boolean. * @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()); if (targeted) { creature = creature.getTargetableCards(spell); @@ -2137,7 +2136,7 @@ public class CardFactoryUtil { * a boolean. * @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); creature = creature.filter(new CardListFilter() { @Override @@ -2165,7 +2164,7 @@ public class CardFactoryUtil { * a boolean. * @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); creature = creature.filter(new CardListFilter() { @Override @@ -2187,7 +2186,7 @@ public class CardFactoryUtil { * * @return a {@link forge.CommandArgs} object. */ - public static CommandArgs AI_targetHuman() { + public static CommandArgs targetHumanAI() { return new CommandArgs() { private static final long serialVersionUID = 8406907523134006697L; @@ -2530,7 +2529,7 @@ public class CardFactoryUtil { if (target == null) { return false; } - + return target.hasProtectionFrom(card); } @@ -2943,10 +2942,10 @@ public class CardFactoryUtil { n++; } } - System.out.println("N is equal to" +n); + System.out.println("N is equal to" + n); return CardFactoryUtil.doXMath(n, m, c); } - + // Count$OpponentDom if (sq[0].contains("OpponentDom")) { someCards.addAll(cardController.getOpponent().getCardsIn(Zone.Battlefield)); @@ -2957,7 +2956,7 @@ public class CardFactoryUtil { n++; } } - System.out.println("Opp N is equal to" +n); + System.out.println("Opp N is equal to" + n); return CardFactoryUtil.doXMath(n, m, c); } @@ -3236,81 +3235,81 @@ public class CardFactoryUtil { // if a card was ever written to count two different zones, // make sure they don't get added twice. - boolean MF = false, MY = false, MH = false; - boolean OF = false, OY = false, OH = false; + boolean mf = false, my = false, mh = false; + boolean of = false, oy = false, oh = false; if (sq[0].contains("YouCtrl")) { - if (!MF) { + if (!mf) { someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); - MF = true; + mf = true; } } if (sq[0].contains("InYourYard")) { - if (!MY) { + if (!my) { someCards.addAll(cardController.getCardsIn(Zone.Graveyard)); - MY = true; + my = true; } } if (sq[0].contains("InYourLibrary")) { - if (!MY) { + if (!my) { someCards.addAll(cardController.getCardsIn(Zone.Library)); - MY = true; + my = true; } } if (sq[0].contains("InYourHand")) { - if (!MH) { + if (!mh) { someCards.addAll(cardController.getCardsIn(Zone.Hand)); - MH = true; + mh = true; } } if (sq[0].contains("OppCtrl")) { - if (!OF) { + if (!of) { someCards.addAll(oppController.getCardsIn(Zone.Battlefield)); - OF = true; + of = true; } } if (sq[0].contains("InOppYard")) { - if (!OY) { + if (!oy) { someCards.addAll(oppController.getCardsIn(Zone.Graveyard)); - OY = true; + oy = true; } } if (sq[0].contains("InOppHand")) { - if (!OH) { + if (!oh) { someCards.addAll(oppController.getCardsIn(Zone.Hand)); - OH = true; + oh = true; } } if (sq[0].contains("OnBattlefield")) { - if (!MF) { + if (!mf) { someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); } - if (!OF) { + if (!of) { someCards.addAll(oppController.getCardsIn(Zone.Battlefield)); } } if (sq[0].contains("InAllYards")) { - if (!MY) { + if (!my) { someCards.addAll(cardController.getCardsIn(Zone.Graveyard)); } - if (!OY) { + if (!oy) { someCards.addAll(oppController.getCardsIn(Zone.Graveyard)); } } if (sq[0].contains("InAllHands")) { - if (!MH) { + if (!mh) { someCards.addAll(cardController.getCardsIn(Zone.Hand)); } - if (!OH) { + if (!oh) { someCards.addAll(oppController.getCardsIn(Zone.Hand)); } } @@ -3552,12 +3551,12 @@ public class CardFactoryUtil { * a {@link java.lang.String} 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() { private static final long serialVersionUID = -2167059918040912025L; - int stop = n; - int count = 0; + private int stop = n; + private int count = 0; @Override public void showMessage() { @@ -3939,8 +3938,7 @@ public class CardFactoryUtil { final Card c = ability.getSourceCard(); - if ((target != null) && c.getText().contains("deals X damage to target") - && !c.getName().equals("Death Grasp")) { + if ((target != null) && c.getText().contains("deals X damage to target") && !c.getName().equals("Death Grasp")) { neededDamage = target.getNetDefense() - target.getDamage(); } @@ -4285,31 +4283,31 @@ public class CardFactoryUtil { /** * Copy characteristics. * - * @param From + * @param from * the from - * @param To + * @param to * the to */ - public static void copyCharacteristics(final Card From, final Card To) { - To.setBaseAttack(From.getBaseAttack()); - To.setBaseDefense(From.getBaseDefense()); - To.setBaseLoyalty(From.getBaseLoyalty()); - To.setBaseAttackString(From.getBaseAttackString()); - To.setBaseDefenseString(From.getBaseDefenseString()); - To.setIntrinsicKeyword(From.getIntrinsicKeyword()); - To.setName(From.getName()); - To.setType(From.getCharacteristics().getType()); - To.setText(From.getSpellText()); - To.setManaCost(From.getManaCost()); - To.setColor(From.getColor()); - To.setSVars(From.getSVars()); - To.setSets(From.getSets()); - To.setIntrinsicAbilities(From.getIntrinsicAbilities()); + public static void copyCharacteristics(final Card from, final Card to) { + to.setBaseAttack(from.getBaseAttack()); + to.setBaseDefense(from.getBaseDefense()); + to.setBaseLoyalty(from.getBaseLoyalty()); + to.setBaseAttackString(from.getBaseAttackString()); + to.setBaseDefenseString(from.getBaseDefenseString()); + to.setIntrinsicKeyword(from.getIntrinsicKeyword()); + to.setName(from.getName()); + to.setType(from.getCharacteristics().getType()); + to.setText(from.getSpellText()); + to.setManaCost(from.getManaCost()); + to.setColor(from.getColor()); + to.setSVars(from.getSVars()); + to.setSets(from.getSets()); + to.setIntrinsicAbilities(from.getIntrinsicAbilities()); - To.setImageName(From.getImageName()); - To.setImageFilename(From.getImageFilename()); - To.setTriggers(From.getTriggers()); - To.setStaticAbilityStrings(From.getStaticAbilityStrings()); + to.setImageName(from.getImageName()); + to.setImageFilename(from.getImageFilename()); + to.setTriggers(from.getTriggers()); + to.setStaticAbilityStrings(from.getStaticAbilityStrings()); } @@ -4772,14 +4770,14 @@ public class CardFactoryUtil { + "ValidCard$ Card.Self | Static$ True | Secondary$ True | TriggerDescription$ Blank", card, true); - final Ability haunterDies_Work = new Ability(card, "0") { + final Ability haunterDiesWork = new Ability(card, "0") { @Override public void resolve() { this.getTargetCard().addHauntedBy(card); AllZone.getGameAction().exile(card); } }; - haunterDies_Work.setDescription(hauntDescription); + haunterDiesWork.setDescription(hauntDescription); final Input target = new Input() { private static final long serialVersionUID = 1981791992623774490L; @@ -4796,8 +4794,8 @@ public class CardFactoryUtil { return; } if (CardFactoryUtil.canTarget(card, c)) { - haunterDies_Work.setTargetCard(c); - AllZone.getStack().add(haunterDies_Work); + haunterDiesWork.setTargetCard(c); + AllZone.getStack().add(haunterDiesWork); this.stop(); } else { 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 public void resolve() { final CardList creats = AllZoneUtil.getCreaturesInPlay(); @@ -4827,16 +4825,16 @@ public class CardFactoryUtil { // AI choosing what to haunt final CardList oppCreats = creats.getController(AllZone.getHumanPlayer()); if (oppCreats.size() != 0) { - haunterDies_Work.setTargetCard(CardFactoryUtil.AI_getWorstCreature(oppCreats)); + haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats)); } 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 // dies @@ -4924,12 +4922,12 @@ public class CardFactoryUtil { eff.setImmutable(true); eff.addStaticAbility("Mode$ CantBeCast | ValidCard$ Card | Caster$ You " - + "| Description$ For the rest of the game, you can't cast spells."); + + "| Description$ For the rest of the game, you can't cast spells."); final Trigger copyTrigger = forge.card.trigger.TriggerHandler.parseTrigger( "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerDescription$ " - + "At the beginning of each of your upkeeps, copy " - + card.toString() + " except for its epic ability.", card, false); + + "At the beginning of each of your upkeeps, copy " + card.toString() + + " except for its epic ability.", card, false); copyTrigger.setOverridingAbility(origSA); @@ -5283,7 +5281,7 @@ public class CardFactoryUtil { } }); if (choices.size() != 0) { - ability.setTargetCard(CardFactoryUtil.AI_getBestCreature(choices)); + ability.setTargetCard(CardFactoryUtil.getBestCreatureAI(choices)); if (ability.getTargetCard() != null) { ability.setStackDescription("Put " + card.getCounters(Counters.P1P1) @@ -5313,15 +5311,15 @@ public class CardFactoryUtil { final int m = Integer.parseInt(parse.substring(6)); final String abStr = "AB$ MoveCounter | Cost$ 0 | Source$ Self | " - + "Defined$ TriggeredCard | CounterType$ P1P1 | CounterNum$ 1"; + + "Defined$ TriggeredCard | CounterType$ P1P1 | CounterNum$ 1"; card.setSVar("GraftTrig", abStr); String trigStr = "Mode$ ChangesZone | ValidCard$ Creature.Other | " - + "Origin$ Any | Destination$ Battlefield"; + + "Origin$ Any | Destination$ Battlefield"; trigStr += " | TriggerZones$ Battlefield | OptionalDecider$ You | " - + "Execute$ GraftTrig | TriggerDescription$ "; + + "Execute$ GraftTrig | TriggerDescription$ "; trigStr += "Whenever another creature enters the battlefield, you " - + "may move a +1/+1 counter from this creature onto it."; + + "may move a +1/+1 counter from this creature onto it."; final Trigger myTrigger = TriggerHandler.parseTrigger(trigStr, card, true); card.addTrigger(myTrigger); diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Auras.java b/src/main/java/forge/card/cardFactory/CardFactory_Auras.java index 9f80fedcfac..f773841dd85 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Auras.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Auras.java @@ -45,7 +45,7 @@ class CardFactory_Auras { * @return a int. */ public static final int shouldCycle(final Card c) { - ArrayList a = c.getKeyword(); + final ArrayList a = c.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith("Cycling")) { return i; @@ -81,16 +81,16 @@ class CardFactory_Auras { if (!super.canPlayAI()) { return false; } - String[] landTypes = new String[] { "Plains", "Island", "Swamp", "Mountain", "Forest" }; - HashMap humanLandCount = new HashMap(); - CardList humanlands = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + final String[] landTypes = new String[] { "Plains", "Island", "Swamp", "Mountain", "Forest" }; + final HashMap humanLandCount = new HashMap(); + final CardList humanlands = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); - for (int i = 0; i < landTypes.length; i++) { - humanLandCount.put(landTypes[i], 0); + for (final String landType : landTypes) { + humanLandCount.put(landType, 0); } - for (Card c : humanlands) { - for (String singleType : c.getType()) { + for (final Card c : humanlands) { + for (final String singleType : c.getType()) { if (CardUtil.isABasicLandType(singleType)) { humanLandCount.put(singleType, humanLandCount.get(singleType) + 1); } @@ -100,7 +100,7 @@ class CardFactory_Auras { int minAt = 0; int minVal = Integer.MAX_VALUE; for (int i = 0; i < landTypes.length; i++) { - if (getTargetCard().isType(landTypes[i])) { + if (this.getTargetCard().isType(landTypes[i])) { continue; } @@ -118,7 +118,7 @@ class CardFactory_Auras { if (list.isEmpty()) { return false; } - setTargetCard(list.get(0)); + this.setTargetCard(list.get(0)); return true; } // canPlayAI() @@ -131,7 +131,7 @@ class CardFactory_Auras { } AllZone.getGameAction().moveToPlay(card); - Card c = getTargetCard(); + final Card c = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { card.enchantEntity(c); @@ -149,14 +149,15 @@ class CardFactory_Auras { spell.setDescription("Enchanted land is an Island."); } - Command onEnchant = new Command() { + final Command onEnchant = new Command() { private static final long serialVersionUID = 3528675112863241126L; + @Override public void execute() { if (card.isEnchanting()) { - Card crd = card.getEnchantingCard(); - ArrayList seas = crd.getEnchantedBy(); + final Card crd = card.getEnchantingCard(); + final ArrayList seas = crd.getEnchantedBy(); int count = 0; for (int i = 0; i < seas.size(); i++) { if (seas.get(i).getName().equals(card.getName())) { @@ -180,22 +181,23 @@ class CardFactory_Auras { otherSeas = seas.get(i); } } - SpellAbility[] abilities = otherSeas.getSpellAbility(); - for (int i = 0; i < abilities.length; i++) { - card.addSpellAbility(abilities[i]); + final SpellAbility[] abilities = otherSeas.getSpellAbility(); + for (final SpellAbility abilitie : abilities) { + card.addSpellAbility(abilitie); } } } } // execute() }; // Command - Command onUnEnchant = new Command() { + final Command onUnEnchant = new Command() { private static final long serialVersionUID = -202144631191180334L; + @Override public void execute() { if (card.isEnchanting()) { - Card crd = card.getEnchantingCard(); - ArrayList seas = crd.getEnchantedBy(); + final Card crd = card.getEnchantingCard(); + final ArrayList seas = crd.getEnchantedBy(); int count = 0; for (int i = 0; i < seas.size(); i++) { if (seas.get(i).getName().equals(card.getName())) { @@ -208,33 +210,34 @@ class CardFactory_Auras { crd.removeType("Basic"); crd.removeType("Snow"); crd.removeType("Legendary"); - SpellAbility[] cardAbilities = crd.getSpellAbility(); - for (int i = 0; i < cardAbilities.length; i++) { - if (cardAbilities[i].isIntrinsic()) { - crd.removeSpellAbility(cardAbilities[i]); + final SpellAbility[] cardAbilities = crd.getSpellAbility(); + for (final SpellAbility cardAbilitie : cardAbilities) { + if (cardAbilitie.isIntrinsic()) { + crd.removeSpellAbility(cardAbilitie); } } - Card c = AllZone.getCardFactory().copyCard(crd); - ArrayList types = c.getType(); - SpellAbility[] abilities = card.getSpellAbility(); + final Card c = AllZone.getCardFactory().copyCard(crd); + final ArrayList types = c.getType(); + final SpellAbility[] abilities = card.getSpellAbility(); for (int i = 0; i < types.size(); i++) { crd.addType(types.get(i)); } - for (int i = 0; i < abilities.length; i++) { - crd.addSpellAbility(abilities[i]); + for (final SpellAbility abilitie : abilities) { + crd.addSpellAbility(abilitie); } } } } // execute() }; // Command - Command onLeavesPlay = new Command() { + final Command onLeavesPlay = new Command() { private static final long serialVersionUID = -45433022112460839L; + @Override public void execute() { if (card.isEnchanting()) { - Card crd = card.getEnchantingCard(); + final Card crd = card.getEnchantingCard(); card.unEnchantEntity(crd); } } @@ -244,14 +247,15 @@ class CardFactory_Auras { card.addUnEnchantCommand(onUnEnchant); card.addLeavesPlayCommand(onLeavesPlay); - Input runtime = new Input() { + final Input runtime = new Input() { private static final long serialVersionUID = -62372711146079880L; @Override public void showMessage() { - CardList land = AllZoneUtil.getLandsInPlay(); - stopSetNext(CardFactoryUtil.input_targetSpecific(spell, land, "Select target land", true, false)); + final CardList land = AllZoneUtil.getLandsInPlay(); + this.stopSetNext(CardFactoryUtil.inputTargetSpecific(spell, land, "Select target land", true, + false)); } }; spell.setBeforePayMana(runtime); @@ -259,8 +263,8 @@ class CardFactory_Auras { // *************** START *********** START ************************** else if (cardName.equals("Earthbind")) { - Cost cost = new Cost(card.getManaCost(), cardName, false); - Target tgt = new Target(card, "C"); + final Cost cost = new Cost(card.getManaCost(), cardName, false); + final Target tgt = new Target(card, "C"); final SpellAbility spell = new Spell_Permanent(card, cost, tgt) { private static final long serialVersionUID = 142389375702113977L; @@ -273,9 +277,10 @@ class CardFactory_Auras { return false; } - CardListFilter f = new CardListFilter() { + final CardListFilter f = new CardListFilter() { + @Override public final boolean addCard(final Card c) { - return c.getNetDefense() - c.getDamage() <= 2; + return (c.getNetDefense() - c.getDamage()) <= 2; } }; if (!list.filter(f).isEmpty()) { @@ -285,7 +290,7 @@ class CardFactory_Auras { for (int i = 0; i < list.size(); i++) { if (CardFactoryUtil.canTarget(card, list.get(i))) { - setTargetCard(list.get(i)); + this.setTargetCard(list.get(i)); return super.canPlayAI(); } } @@ -296,11 +301,11 @@ class CardFactory_Auras { public void resolve() { AllZone.getGameAction().moveToPlay(card); - Card c = getTargetCard(); + final Card c = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { card.enchantEntity(c); - Log.debug("Enchanted: " + getTargetCard()); + Log.debug("Enchanted: " + this.getTargetCard()); } } // resolve() }; // SpellAbility @@ -308,13 +313,14 @@ class CardFactory_Auras { card.addSpellAbility(spell); final boolean[] badTarget = { true }; - Command onEnchant = new Command() { + final Command onEnchant = new Command() { private static final long serialVersionUID = -5302506578307993978L; + @Override public void execute() { if (card.isEnchanting()) { - Card crd = card.getEnchantingCard(); + final Card crd = card.getEnchantingCard(); if (crd.hasKeyword("Flying")) { badTarget[0] = false; crd.addDamage(2, card); @@ -327,25 +333,27 @@ class CardFactory_Auras { } // execute() }; // Command - Command onUnEnchant = new Command() { + final Command onUnEnchant = new Command() { private static final long serialVersionUID = -6908757692588823391L; + @Override public void execute() { if (card.isEnchanting() && !badTarget[0]) { - Card crd = card.getEnchantingCard(); + final Card crd = card.getEnchantingCard(); crd.addIntrinsicKeyword("Flying"); } } // execute() }; // Command - Command onLeavesPlay = new Command() { + final Command onLeavesPlay = new Command() { private static final long serialVersionUID = -7833240882415702940L; + @Override public void execute() { if (card.isEnchanting()) { - Card crd = card.getEnchantingCard(); + final Card crd = card.getEnchantingCard(); card.unEnchantEntity(crd); } } @@ -358,8 +366,8 @@ class CardFactory_Auras { // *************** START *********** START ************************** else if (cardName.equals("Guilty Conscience")) { - Cost cost = new Cost(card.getManaCost(), cardName, false); - Target tgt = new Target(card, "C"); + final Cost cost = new Cost(card.getManaCost(), cardName, false); + final Target tgt = new Target(card, "C"); final SpellAbility spell = new Spell_Permanent(card, cost, tgt) { private static final long serialVersionUID = 1169151960692309514L; @@ -367,13 +375,13 @@ class CardFactory_Auras { @Override 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) { - setTargetCard(stuffy.get(0)); + this.setTargetCard(stuffy.get(0)); return true; } else { - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); if (list.isEmpty()) { return false; @@ -386,8 +394,8 @@ class CardFactory_Auras { for (int i = 0; i < list.size(); i++) { if (CardFactoryUtil.canTarget(card, list.get(i)) && (list.get(i).getNetAttack() >= list.get(i).getNetDefense()) - && list.get(i).getNetAttack() >= 3) { - setTargetCard(list.get(i)); + && (list.get(i).getNetAttack() >= 3)) { + this.setTargetCard(list.get(i)); return super.canPlayAI(); } } @@ -398,9 +406,9 @@ class CardFactory_Auras { @Override 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)) { aura.enchantEntity(c); @@ -425,15 +433,17 @@ class CardFactory_Auras { return AllZoneUtil.getCardsIn(Zone.Graveyard).filter(CardListFilter.CREATURES); } + @Override public boolean canPlay() { - return super.canPlay() && getCreturesInGrave().size() != 0; + return super.canPlay() && (this.getCreturesInGrave().size() != 0); } @Override public boolean canPlayAI() { - CardList cList = getCreturesInGrave(); + CardList cList = this.getCreturesInGrave(); // AI will only target something that will stick in play. cList = cList.filter(new CardListFilter() { + @Override public final boolean addCard(final Card crd) { return CardFactoryUtil.canTarget(card, crd) && !CardFactoryUtil.hasProtectionFrom(card, crd); @@ -443,16 +453,16 @@ class CardFactory_Auras { return false; } - Card c = CardFactoryUtil.AI_getBestCreature(cList); + final Card c = CardFactoryUtil.getBestCreatureAI(cList); - setTargetCard(c); - boolean playable = 2 < c.getNetAttack() && 2 < c.getNetDefense() && super.canPlayAI(); + this.setTargetCard(c); + final boolean playable = (2 < c.getNetAttack()) && (2 < c.getNetDefense()) && super.canPlayAI(); return playable; } // canPlayAI @Override public void resolve() { - targetC[0] = getTargetCard(); + targetC[0] = this.getTargetCard(); super.resolve(); } @@ -460,29 +470,27 @@ class CardFactory_Auras { // Target AbCost and Restriction are set here to get this working as // 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); animate.setTarget(tgt); - Cost cost = new Cost("1 B", cardName, false); + final Cost cost = new Cost("1 B", cardName, false); animate.setPayCosts(cost); animate.getRestrictions().setZone(Constant.Zone.Hand); final Ability attach = new Ability(card, "0") { - private static final long serialVersionUID = 222308932796127795L; - @Override 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 if (!play.contains(card)) { return; } - Card animated = targetC[0]; - PlayerZone grave = AllZone.getZoneOf(animated); + final Card animated = targetC[0]; + final PlayerZone grave = AllZone.getZoneOf(animated); if (!grave.is(Constant.Zone.Graveyard)) { // Animated Creature got removed before ability resolved @@ -513,6 +521,7 @@ class CardFactory_Auras { final Command attachCmd = new Command() { private static final long serialVersionUID = 3595188622377350327L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry(attach); @@ -523,9 +532,9 @@ class CardFactory_Auras { @Override 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)) { AllZone.getGameAction().sacrifice(c); @@ -536,10 +545,11 @@ class CardFactory_Auras { final Command detachCmd = new Command() { private static final long serialVersionUID = 2425333033834543422L; + @Override 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)) { AllZone.getStack().addSimultaneousStackEntry(detach); @@ -559,12 +569,12 @@ class CardFactory_Auras { // *************** START *********** START ************************** else if (CardFactoryUtil.hasKeyword(card, "enchant") != -1) { - int n = CardFactoryUtil.hasKeyword(card, "enchant"); + final int n = CardFactoryUtil.hasKeyword(card, "enchant"); if (n != -1) { - String parse = card.getKeyword().get(n).toString(); - String[] k = parse.split(":"); + final String parse = card.getKeyword().get(n).toString(); + final String[] k = parse.split(":"); - SpellAbility sa = card.getSpellAbility()[0]; + final SpellAbility sa = card.getSpellAbility()[0]; sa.setIsMultiKicker(true); sa.setMultiKickerManaCost(k[1]); } diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java b/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java index b3a807f87e2..93e457af92e 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java @@ -64,7 +64,7 @@ public class CardFactory_Creatures { * @return a int. */ private static int hasKeyword(final Card c, final String k) { - ArrayList a = c.getKeyword(); + final ArrayList a = c.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith(k)) { return i; @@ -84,7 +84,7 @@ public class CardFactory_Creatures { * @return a int. */ public static int shouldCycle(final Card c) { - ArrayList a = c.getKeyword(); + final ArrayList a = c.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith("Cycling")) { return i; @@ -104,7 +104,7 @@ public class CardFactory_Creatures { * @return a int. */ public static int shouldTypeCycle(final Card c) { - ArrayList a = c.getKeyword(); + final ArrayList a = c.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith("TypeCycling")) { return i; @@ -124,7 +124,7 @@ public class CardFactory_Creatures { * @return a int. */ public static int shouldTransmute(final Card c) { - ArrayList a = c.getKeyword(); + final ArrayList a = c.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith("Transmute")) { return i; @@ -144,7 +144,7 @@ public class CardFactory_Creatures { * @return a int. */ public static int shouldSoulshift(final Card c) { - ArrayList a = c.getKeyword(); + final ArrayList a = c.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith("Soulshift")) { return i; @@ -171,12 +171,12 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** if (cardName.equals("Force of Savagery")) { - SpellAbility spell = new Spell_Permanent(card) { + final SpellAbility spell = new Spell_Permanent(card) { private static final long serialVersionUID = 1603238129819160467L; @Override public boolean canPlayAI() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); return list.containsName("Glorious Anthem") || list.containsName("Gaea's Anthem"); } @@ -190,20 +190,20 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** else if (cardName.equals("Gilder Bairn")) { - Cost abCost = new Cost("2 GU Untap", cardName, true); - Target tgt = new Target(card, "Select target permanent.", new String[] { "Permanent" }); + final Cost abCost = new Cost("2 GU Untap", cardName, true); + final Target tgt = new Target(card, "Select target permanent.", new String[] { "Permanent" }); final Ability_Activated a1 = new Ability_Activated(card, abCost, tgt) { private static final long serialVersionUID = -1847685865277129366L; @Override public void resolve() { - Card c = getTargetCard(); + final Card c = this.getTargetCard(); if (c.sumAllCounters() == 0) { return; } else if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { // zerker clean up: - for (Counters c1 : Counters.values()) { + for (final Counters c1 : Counters.values()) { if (c.getCounters(c1) > 0) { c.addCounter(c1, c.getCounters(c1)); } @@ -215,20 +215,22 @@ public class CardFactory_Creatures { public void chooseTargetAI() { CardList perms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); perms = perms.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - return c.sumAllCounters() > 0 && CardFactoryUtil.canTarget(card, c); + return (c.sumAllCounters() > 0) && CardFactoryUtil.canTarget(card, c); } }); perms.shuffle(); - setTargetCard(perms.get(0)); // TODO improve this. + this.setTargetCard(perms.get(0)); // TODO improve this. } @Override public boolean canPlayAI() { CardList perms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); perms = perms.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - return c.sumAllCounters() > 0 && CardFactoryUtil.canTarget(card, c); + return (c.sumAllCounters() > 0) && CardFactoryUtil.canTarget(card, c); } }); return perms.size() > 0; @@ -248,7 +250,7 @@ public class CardFactory_Creatures { @Override public void resolve() { String choice = ""; - String[] choices = { "3/3", "2/2 with flying", "1/6 with defender" }; + final String[] choices = { "3/3", "2/2 with flying", "1/6 with defender" }; if (card.getController().isHuman()) { choice = GuiUtils.getChoice("Choose one", choices); @@ -270,11 +272,12 @@ public class CardFactory_Creatures { } // resolve() }; // SpellAbility - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 8957338395786245312L; + @Override public void execute() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append(" - choose: 3/3, 2/2 flying, 1/6 defender"); ability.setStackDescription(sb.toString()); @@ -300,14 +303,14 @@ public class CardFactory_Creatures { public void selectCard(final Card c, final PlayerZone zone) { if (zone.is(Constant.Zone.Hand) && !c.isCreature()) { c.getController().discard(c, null); - stop(); + this.stop(); } } @Override public void selectButtonCancel() { AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } }; // Input @@ -323,6 +326,7 @@ public class CardFactory_Creatures { } else { CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (!c.isCreature()); } @@ -332,11 +336,12 @@ public class CardFactory_Creatures { } // resolve() }; // SpellAbility - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 9202753910259054021L; + @Override public void execute() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getController()) .append(" sacrifices Drekavac unless he discards a noncreature card"); ability.setStackDescription(sb.toString()); @@ -346,7 +351,7 @@ public class CardFactory_Creatures { } }; - SpellAbility spell = new Spell_Permanent(card) { + final SpellAbility spell = new Spell_Permanent(card) { private static final long serialVersionUID = -2940969025405788931L; // could never get the AI to work correctly @@ -361,6 +366,7 @@ public class CardFactory_Creatures { CardList list = card.getController().getCardsIn(Zone.Hand); list.remove(card); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (!c.isCreature()); } @@ -401,7 +407,7 @@ public class CardFactory_Creatures { @Override public void resolve() { - CardList hand = card.getController().getCardsIn(Zone.Hand); + final CardList hand = card.getController().getCardsIn(Zone.Hand); if (hand.size() == 0) { AllZone.getGameAction().sacrifice(card); } else { @@ -410,11 +416,12 @@ public class CardFactory_Creatures { } }; // SpellAbility - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 4986114285467649619L; + @Override public void execute() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getController()).append(" - discards at random or sacrifices ").append(cardName); ability.setStackDescription(sb.toString()); @@ -439,10 +446,11 @@ public class CardFactory_Creatures { }; ability.setStackDescription("When Sleeper Agent enters the battlefield, " - + "target opponent gains control of it."); - Command intoPlay = new Command() { + + "target opponent gains control of it."); + final Command intoPlay = new Command() { private static final long serialVersionUID = -3934471871041458847L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry(ability); @@ -455,9 +463,11 @@ public class CardFactory_Creatures { else if (cardName.equals("Phylactery Lich")) { final CommandReturn getArt = new CommandReturn() { // get target card, may be null + @Override public Object execute() { CardList art = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); art = art.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isArtifact(); } @@ -465,6 +475,7 @@ public class CardFactory_Creatures { CardList list = new CardList(art.toArray()); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.getIntrinsicKeyword().contains("Indestructible"); } @@ -484,7 +495,7 @@ public class CardFactory_Creatures { final SpellAbility ability = new Ability(card, "0") { @Override public void resolve() { - Card c = getTargetCard(); + final Card c = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(c) && c.isArtifact()) { c.addCounter(Counters.PHYLACTERY, 1); @@ -492,11 +503,12 @@ public class CardFactory_Creatures { } } // resolve() }; // SpellAbility - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = -1601957445498569156L; + @Override public void execute() { - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = -806140334868210520L; @@ -512,20 +524,21 @@ public class CardFactory_Creatures { && card.getController().isHuman()) { ability.setTargetCard(card); AllZone.getStack().add(ability); - stop(); + this.stop(); } } }; // Input target if (card.getController().isHuman()) { - CardList artifacts = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield).getType("Artifact"); + final CardList artifacts = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield) + .getType("Artifact"); if (artifacts.size() != 0) { AllZone.getInputControl().setInput(target); } } else { // computer - Object o = getArt.execute(); + final Object o = getArt.execute(); // should never happen, but just in case if (o != null) { ability.setTargetCard((Card) o); @@ -544,8 +557,8 @@ public class CardFactory_Creatures { @Override public boolean canPlayAI() { - Object o = getArt.execute(); - return (o != null) && AllZone.getZoneOf(getSourceCard()).is(Constant.Zone.Hand); + final Object o = getArt.execute(); + return (o != null) && AllZone.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand); } }); card.addComesIntoPlayCommand(intoPlay); @@ -558,7 +571,7 @@ public class CardFactory_Creatures { @Override public void resolve() { // TODO - this needs to be targeted - Player opp = card.getController().getOpponent(); + final Player opp = card.getController().getOpponent(); CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); list = list.getValidCards("Card.Other+YouCtrl".split(","), card.getController(), card); @@ -568,11 +581,12 @@ public class CardFactory_Creatures { } // resolve() }; // SpellAbility - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = -453410206437839334L; + @Override public void execute() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getController().getOpponent()); sb.append(" gains control of all other permanents you control"); ability.setStackDescription(sb.toString()); @@ -588,8 +602,6 @@ public class CardFactory_Creatures { else if (cardName.equals("Jhoira of the Ghitu")) { final Stack chosen = new Stack(); final SpellAbility ability = new Ability(card, "2") { - private static final long serialVersionUID = 4414609319033894302L; - @Override public boolean canPlay() { CardList possible = card.getController().getCardsIn(Zone.Hand); @@ -597,13 +609,14 @@ public class CardFactory_Creatures { return !possible.isEmpty() && super.canPlay(); } + @Override public boolean canPlayAI() { return false; } @Override public void resolve() { - Card c = chosen.pop(); + final Card c = chosen.pop(); c.addCounter(Counters.TIME, 4); c.setSuspend(true); } @@ -625,7 +638,7 @@ public class CardFactory_Creatures { chosen.push(c); ability.setStackDescription(card.toString() + " - Suspending " + c.toString()); AllZone.getStack().add(ability); - stop(); + this.stop(); } } }); @@ -639,8 +652,6 @@ public class CardFactory_Creatures { final int[] index = new int[1]; final Ability ability = new Ability(card, "") { - private static final long serialVersionUID = -3075569295823682336L; - @Override public boolean canPlayAI() { return false; @@ -648,12 +659,12 @@ public class CardFactory_Creatures { @Override public void resolve() { - Card crd0 = target[0]; - Card crd1 = target[1]; + final Card crd0 = target[0]; + final Card crd1 = target[1]; - if (crd0 != null && crd1 != null) { - Player p0 = crd0.getController(); - Player p1 = crd1.getController(); + if ((crd0 != null) && (crd1 != null)) { + final Player p0 = crd0.getController(); + final Player p1 = crd1.getController(); crd0.addController(p1); crd1.addController(p0); // AllZone.getGameAction().changeController(new @@ -682,18 +693,18 @@ public class CardFactory_Creatures { @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override public void selectCard(final Card c, final PlayerZone zone) { // must target creature you control - if (index[0] == 0 && !c.getController().equals(card.getController())) { + if ((index[0] == 0) && !c.getController().equals(card.getController())) { return; } // must target creature you don't control - if (index[0] == 1 && c.getController().equals(card.getController())) { + if ((index[0] == 1) && c.getController().equals(card.getController())) { return; } @@ -701,19 +712,20 @@ public class CardFactory_Creatures { // System.out.println("c is: " +c); target[index[0]] = c; index[0]++; - showMessage(); + this.showMessage(); if (index[0] == target.length) { AllZone.getStack().add(ability); - stop(); + this.stop(); } } } // selectCard() }; // Input - Command comesIntoPlay = new Command() { + final Command comesIntoPlay = new Command() { private static final long serialVersionUID = 6513203926272187582L; + @Override public void execute() { index[0] = 0; if (card.getController().isHuman()) { @@ -722,7 +734,7 @@ public class CardFactory_Creatures { } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName).append( " - Exchange control of target land you control and target land an opponent controls."); ability.setStackDescription(sb.toString()); @@ -739,6 +751,7 @@ public class CardFactory_Creatures { final Command destroy = new Command() { private static final long serialVersionUID = -2433442359225521472L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry( @@ -746,12 +759,12 @@ public class CardFactory_Creatures { + " from graveyard to the battlefield") { @Override public void resolve() { - PlayerZone grave = AllZone.getZoneOf(target[0]); + final PlayerZone grave = AllZone.getZoneOf(target[0]); // checks to see if card is still in the // graveyard - if (grave != null && grave.contains(target[0])) { - PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); + if ((grave != null) && grave.contains(target[0])) { + final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); target[0].addController(card.getController()); AllZone.getGameAction().moveTo(play, target[0]); } @@ -763,21 +776,22 @@ public class CardFactory_Creatures { final Command untilEOT = new Command() { private static final long serialVersionUID = 2777978927867867610L; + @Override public void execute() { // resets the Card destroy Command target[0].removeDestroyCommand(destroy); } }; - Cost abCost = new Cost("T", cardName, true); - Target tgt = new Target(card, "Target creature other than " + cardName, "Creature.Other".split(",")); + final Cost abCost = new Cost("T", cardName, true); + final Target tgt = new Target(card, "Target creature other than " + cardName, "Creature.Other".split(",")); final Ability_Activated ability = new Ability_Activated(card, abCost, tgt) { private static final long serialVersionUID = -8454685126878522607L; @Override public void resolve() { - if (AllZoneUtil.isCardInPlay(getTargetCard())) { - target[0] = getTargetCard(); + if (AllZoneUtil.isCardInPlay(this.getTargetCard())) { + target[0] = this.getTargetCard(); if (!target[0].isToken()) { // not necessary, but will // help speed up stack @@ -796,7 +810,7 @@ public class CardFactory_Creatures { card.addSpellAbility(ability); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("tap: When target creature other than Adarkar Valkyrie is put into a "); sb.append("graveyard this turn, return that card to the battlefield under your control."); ability.setDescription(sb.toString()); @@ -807,19 +821,20 @@ public class CardFactory_Creatures { final long[] timeStamp = new long[1]; final String[] color = new String[1]; - Command comesIntoPlay = new Command() { + final Command comesIntoPlay = new Command() { private static final long serialVersionUID = 333134223161L; + @Override public void execute() { if (card.getController().isHuman()) { - String[] colors = Constant.Color.ONLY_COLORS; + final String[] colors = Constant.Color.ONLY_COLORS; - Object o = GuiUtils.getChoice("Choose color", colors); + final Object o = GuiUtils.getChoice("Choose color", colors); color[0] = (String) o; } else { // AI chooses the color that appears in the keywords of // the most cards in its deck, hand and on battlefield - CardList list = new CardList(); + final CardList list = new CardList(); list.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Library)); list.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Hand)); list.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); @@ -827,30 +842,31 @@ public class CardFactory_Creatures { color[0] = Constant.Color.WHITE; int max = list.getKeywordsContain(color[0]).size(); - String[] colors = { Constant.Color.BLUE, Constant.Color.BLACK, Constant.Color.RED, + final String[] colors = { Constant.Color.BLUE, Constant.Color.BLACK, Constant.Color.RED, Constant.Color.GREEN }; - for (String c : colors) { - int cmp = list.getKeywordsContain(c).size(); + for (final String c : colors) { + final int cmp = list.getKeywordsContain(c).size(); if (cmp > max) { max = cmp; color[0] = c; } } } - ArrayList colors = new ArrayList(); + final ArrayList colors = new ArrayList(); colors.add(color[0]); card.setChosenColor(colors); - String s = CardUtil.getShortColor(color[0]); + final String s = CardUtil.getShortColor(color[0]); timeStamp[0] = AllZone.getColorChanger().addColorChanges(s, card, true, true); } }; // Command - Command leavesBattlefield = new Command() { + final Command leavesBattlefield = new Command() { private static final long serialVersionUID = 2559212590399132459L; + @Override public void execute() { - String s = CardUtil.getShortColor(color[0]); + final String s = CardUtil.getShortColor(color[0]); AllZone.getColorChanger().removeColorChanges(s, card, true, timeStamp[0]); } }; @@ -865,13 +881,14 @@ public class CardFactory_Creatures { final Ability ability = new Ability(card, "0") { @Override public void resolve() { - CardList cl = CardFactoryUtil.makeToken("Stangg Twin", "RG 3 4 Stangg Twin", card.getController(), - "R G", new String[] { "Legendary", "Creature", "Human", "Warrior" }, 3, 4, - new String[] { "" }); + final CardList cl = CardFactoryUtil.makeToken("Stangg Twin", "RG 3 4 Stangg Twin", + card.getController(), "R G", new String[] { "Legendary", "Creature", "Human", "Warrior" }, + 3, 4, new String[] { "" }); cl.get(0).addLeavesPlayCommand(new Command() { private static final long serialVersionUID = 3367390368512271319L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(card)) { AllZone.getGameAction().sacrifice(card); @@ -887,6 +904,7 @@ public class CardFactory_Creatures { card.addComesIntoPlayCommand(new Command() { private static final long serialVersionUID = 6667896040611028600L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry(ability); @@ -896,8 +914,9 @@ public class CardFactory_Creatures { card.addLeavesPlayCommand(new Command() { private static final long serialVersionUID = 1786900359843939456L; + @Override public void execute() { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Stangg Twin"); + final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Stangg Twin"); if (list.size() == 1) { AllZone.getGameAction().exile(list.get(0)); @@ -913,31 +932,31 @@ public class CardFactory_Creatures { public void resolve() { Card c = null; if (card.getController().isHuman()) { - Object o = GuiUtils.getChoiceOptional("Select Elemental", getCreatures()); + final Object o = GuiUtils.getChoiceOptional("Select Elemental", this.getCreatures()); c = (Card) o; } else { - c = getAIElemental(); + c = this.getAIElemental(); } if (card.getController().getZone(Zone.Graveyard).contains(c)) { - PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield); + final PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield); AllZone.getGameAction().moveTo(play, c); } } // resolve() @Override public boolean canPlay() { - return getCreatures().size() != 0 && AllZoneUtil.isCardInPlay(card) && super.canPlay(); + return (this.getCreatures().size() != 0) && AllZoneUtil.isCardInPlay(card) && super.canPlay(); } public CardList getCreatures() { - CardList creatures = card.getController().getCardsIn(Zone.Graveyard).getType("Elemental"); + final CardList creatures = card.getController().getCardsIn(Zone.Graveyard).getType("Elemental"); return creatures; } public Card getAIElemental() { - CardList c = getCreatures(); + final CardList c = this.getCreatures(); Card biggest = c.get(0); for (int i = 0; i < c.size(); i++) { if (biggest.getNetAttack() < c.get(i).getNetAttack()) { @@ -951,16 +970,16 @@ public class CardFactory_Creatures { card.addSpellAbility(ability); ability.setDescription("W U B R G: You may play target Elemental card from " - + "your graveyard without paying its mana cost."); + + "your graveyard without paying its mana cost."); ability.setStackDescription("Horde of Notions - play Elemental card from " - + "graveyard without paying its mana cost."); + + "graveyard without paying its mana cost."); ability.setBeforePayMana(new Input_PayManaCost(ability)); } // *************** END ************ END ************************** // *************** START *********** START ************************** else if (cardName.equals("Rhys the Redeemed")) { - Cost abCost = new Cost("4 GW GW T", card.getName(), true); + final Cost abCost = new Cost("4 GW GW T", card.getName(), true); final Ability_Activated copyTokens1 = new Ability_Activated(card, abCost, null) { private static final long serialVersionUID = 6297992502069547478L; @@ -984,7 +1003,7 @@ public class CardFactory_Creatures { card.addSpellAbility(copyTokens1); copyTokens1.setDescription(abCost + "For each creature token you control, " + "put a token that's a copy of that creature onto the battlefield."); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append( " - For each creature token you control, " + "put a token that's a copy of that creature onto the battlefield."); @@ -1000,14 +1019,14 @@ public class CardFactory_Creatures { public void resolve() { int lifeGain = 0; if (card.getController().isHuman()) { - String[] choices = { "white", "blue", "black", "red", "green" }; - Object o = GuiUtils.getChoiceOptional("Select Color: ", choices); + final String[] choices = { "white", "blue", "black", "red", "green" }; + final Object o = GuiUtils.getChoiceOptional("Select Color: ", choices); Log.debug("Treva, the Renewer", "Color:" + o); lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor((String) o); } else { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); - String color = CardFactoryUtil.getMostProminentColor(list); + final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final String color = CardFactoryUtil.getMostProminentColor(list); lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor(color); } @@ -1023,7 +1042,7 @@ public class CardFactory_Creatures { // card.clearSpellAbility(); card.addSpellAbility(ability2); - StringBuilder sb2 = new StringBuilder(); + final StringBuilder sb2 = new StringBuilder(); sb2.append(card.getName()).append(" - ").append(player); sb2.append(" gains life equal to permanents of the chosen color."); ability2.setStackDescription(sb2.toString()); @@ -1034,14 +1053,14 @@ public class CardFactory_Creatures { final SpellAbility ability1 = new Ability(card, "0") { @Override public void resolve() { - Player player = card.getController(); - PlayerZone lib = player.getZone(Constant.Zone.Library); + final Player player = card.getController(); + final PlayerZone lib = player.getZone(Constant.Zone.Library); if (lib.size() < 1) { return; } - CardList cl = new CardList(); + final CardList cl = new CardList(); cl.add(lib.get(0)); GuiUtils.getChoiceOptional("Top card", cl.toArray()); @@ -1053,7 +1072,7 @@ public class CardFactory_Creatures { } }; // SpellAbility - StringBuilder sb1 = new StringBuilder(); + final StringBuilder sb1 = new StringBuilder(); sb1.append(card.getName()).append(" - look at top card of library."); ability1.setStackDescription(sb1.toString()); @@ -1075,6 +1094,7 @@ public class CardFactory_Creatures { wolves = wolves.getType("Wolf"); wolves = wolves.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isUntapped() && c.isCreature(); } @@ -1093,9 +1113,10 @@ public class CardFactory_Creatures { CardList targetables = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); targetables = targetables.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return CardFactoryUtil.canTarget(card, c) && c.isCreature() - && c.getNetDefense() <= totalPower; + && (c.getNetDefense() <= totalPower); } }); @@ -1103,8 +1124,8 @@ public class CardFactory_Creatures { return false; } - getTarget().resetTargets(); - setTargetCard(CardFactoryUtil.AI_getBestCreature(targetables)); + this.getTarget().resetTargets(); + this.setTargetCard(CardFactoryUtil.getBestCreatureAI(targetables)); return true; } @@ -1115,12 +1136,13 @@ public class CardFactory_Creatures { wolves = wolves.getType("Wolf"); wolves = wolves.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isUntapped() && c.isCreature(); } }); - final Card target = getTargetCard(); + final Card target = this.getTargetCard(); if (wolves.size() == 0) { return; @@ -1130,7 +1152,7 @@ public class CardFactory_Creatures { return; } - for (Card c : wolves) { + for (final Card c : wolves) { c.tap(); target.addDamage(c.getNetAttack(), c); } @@ -1139,10 +1161,11 @@ public class CardFactory_Creatures { // spread damage for (int x = 0; x < target.getNetAttack(); x++) { AllZone.getInputControl().setInput( - CardFactoryUtil.MasteroftheWildHunt_input_targetCreature(this, wolves, + CardFactoryUtil.masterOfTheWildHuntInputTargetCreature(this, wolves, new Command() { private static final long serialVersionUID = -328305150127775L; + @Override public void execute() { getTargetCard().addDamage(1, target); AllZone.getGameAction().checkStateEffects(); @@ -1150,7 +1173,8 @@ public class CardFactory_Creatures { })); } } else { // AI Choose spread Damage - CardList damageableWolves = wolves.filter(new CardListFilter() { + final CardList damageableWolves = wolves.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (c.predictDamage(target.getNetAttack(), target, false) > 0); } @@ -1163,6 +1187,7 @@ public class CardFactory_Creatures { } CardList wolvesLeft = damageableWolves.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return !c.hasKeyword("Indestructible"); } @@ -1170,24 +1195,26 @@ public class CardFactory_Creatures { for (int i = 0; i < target.getNetAttack(); i++) { wolvesLeft = wolvesLeft.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - return c.getKillDamage() > 0 - && (c.getKillDamage() <= target.getNetAttack() || target + return (c.getKillDamage() > 0) + && ((c.getKillDamage() <= target.getNetAttack()) || target .hasKeyword("Deathtouch")); } }); // Kill Wolves that can be killed first if (wolvesLeft.size() > 0) { - Card best = CardFactoryUtil.AI_getBestCreature(wolvesLeft); + final Card best = CardFactoryUtil.getBestCreatureAI(wolvesLeft); best.addDamage(1, target); - if (best.getKillDamage() <= 0 || target.hasKeyword("Deathtouch")) { + if ((best.getKillDamage() <= 0) || target.hasKeyword("Deathtouch")) { wolvesLeft.remove(best); } } else { // Add -1/-1s to Random Indestructibles if (target.hasKeyword("Infect") || target.hasKeyword("Wither")) { - CardList indestructibles = damageableWolves.filter(new CardListFilter() { + final CardList indestructibles = damageableWolves.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.hasKeyword("Indestructible"); } @@ -1208,7 +1235,7 @@ public class CardFactory_Creatures { } // resolve() }; // SpellAbility - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Tap: Tap all untapped Wolf creatures you control. Each Wolf tapped "); sb.append("this way deals damage equal to its power to target creature. That creature deals "); sb.append("damage equal to its power divided as its controller chooses among any number of those Wolves."); @@ -1222,14 +1249,14 @@ public class CardFactory_Creatures { || cardName.equals("Feral Hydra") || cardName.equals("Krakilin") || cardName.equals("Ivy Elemental") || cardName.equals("Lightning Serpent")) { - SpellAbility spell = new Spell_Permanent(card) { + final SpellAbility spell = new Spell_Permanent(card) { private static final long serialVersionUID = 7708945715867177172L; @Override public boolean canPlayAI() { return super.canPlay() - && 4 <= ComputerUtil.getAvailableMana().size() - - CardUtil.getConvertedManaCost(card.getManaCost()); + && (4 <= (ComputerUtil.getAvailableMana().size() - CardUtil.getConvertedManaCost(card + .getManaCost()))); } }; card.clearFirstSpell(); @@ -1238,18 +1265,18 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** else if (cardName.equals("Apocalypse Hydra")) { - SpellAbility spell = new Spell_Permanent(card) { + final SpellAbility spell = new Spell_Permanent(card) { private static final long serialVersionUID = -11489323313L; @Override public boolean canPlayAI() { - return super.canPlay() && 5 <= ComputerUtil.getAvailableMana().size() - 2; + return super.canPlay() && (5 <= (ComputerUtil.getAvailableMana().size() - 2)); } @Override public void resolve() { int xCounters = card.getXManaCostPaid(); - Card c = AllZone.getGameAction().moveToPlay(getSourceCard()); + final Card c = AllZone.getGameAction().moveToPlay(this.getSourceCard()); if (xCounters >= 5) { xCounters = 2 * xCounters; @@ -1265,39 +1292,40 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** else if (cardName.equals("Molten Hydra")) { - Target target = new Target(card, "TgtCP"); - Cost abCost = new Cost("T", cardName, true); + final Target target = new Target(card, "TgtCP"); + final Cost abCost = new Cost("T", cardName, true); final Ability_Activated ability2 = new Ability_Activated(card, abCost, target) { private static final long serialVersionUID = 2626619319289064289L; @Override public boolean canPlay() { - return card.getCounters(Counters.P1P1) > 0 && super.canPlay(); + return (card.getCounters(Counters.P1P1) > 0) && super.canPlay(); } @Override public boolean canPlayAI() { - return getCreature().size() != 0; + return this.getCreature().size() != 0; } @Override public void chooseTargetAI() { if (AllZone.getHumanPlayer().getLife() < card.getCounters(Counters.P1P1)) { - setTargetPlayer(AllZone.getHumanPlayer()); + this.setTargetPlayer(AllZone.getHumanPlayer()); } else { - CardList list = getCreature(); + final CardList list = this.getCreature(); list.shuffle(); - setTargetCard(list.get(0)); + this.setTargetCard(list.get(0)); } } // chooseTargetAI() CardList getCreature() { // toughness of 1 - CardList list = CardFactoryUtil.AI_getHumanCreature(card.getCounters(Counters.P1P1), card, true); + CardList list = CardFactoryUtil.getHumanCreatureAI(card.getCounters(Counters.P1P1), card, true); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - int total = card.getCounters(Counters.P1P1); + final int total = card.getCounters(Counters.P1P1); return (total >= c.getKillDamage()); } }); @@ -1306,14 +1334,14 @@ public class CardFactory_Creatures { @Override public void resolve() { - int total = card.getCounters(Counters.P1P1); - if (getTargetCard() != null) { - if (AllZoneUtil.isCardInPlay(getTargetCard()) - && CardFactoryUtil.canTarget(card, getTargetCard())) { - getTargetCard().addDamage(total, card); + final int total = card.getCounters(Counters.P1P1); + if (this.getTargetCard() != null) { + if (AllZoneUtil.isCardInPlay(this.getTargetCard()) + && CardFactoryUtil.canTarget(card, this.getTargetCard())) { + this.getTargetCard().addDamage(total, card); } } else { - getTargetPlayer().addDamage(total, card); + this.getTargetPlayer().addDamage(total, card); } card.subtractCounter(Counters.P1P1, total); } // resolve() @@ -1321,7 +1349,7 @@ public class CardFactory_Creatures { card.addSpellAbility(ability2); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(abCost + "Remove all +1/+1 counters from " + cardName + ": " + cardName); sb.append(" deals damage to target creature or player equal to the " + "number of +1/+1 counters removed this way."); @@ -1339,7 +1367,7 @@ public class CardFactory_Creatures { public void resolve() { if (card.getController().isHuman()) { - StringBuilder question = new StringBuilder(); + final StringBuilder question = new StringBuilder(); if (card.getName().equals("Academy Rector")) { question.append("Exile ").append(card.getName()).append(" and place "); } else { @@ -1355,7 +1383,7 @@ public class CardFactory_Creatures { list = list.getType("Enchantment"); if (list.size() > 0) { - Object objectSelected = GuiUtils.getChoiceOptional("Choose an enchantment", + final Object objectSelected = GuiUtils.getChoiceOptional("Choose an enchantment", list.toArray()); if (objectSelected != null) { @@ -1365,8 +1393,8 @@ public class CardFactory_Creatures { if (c.isAura()) { - String[] enchantThisType = { "" }; - String[] message = { "" }; + final String[] enchantThisType = { "" }; + final String[] message = { "" }; // The type following "Enchant" maybe // upercase or lowercase, cardsfolder @@ -1379,7 +1407,7 @@ public class CardFactory_Creatures { message[0] = "Select a creature without flying"; } else if (c.hasKeyword("Enchant creature with converted mana cost 2 or less") || c.hasKeyword("Enchant Creature with " - + "converted mana cost 2 or less")) { + + "converted mana cost 2 or less")) { enchantThisType[0] = "Creature.cmcLE2"; message[0] = "Select a creature with converted mana cost 2 or less"; } else if (c.hasKeyword("Enchant red or green creature")) { @@ -1388,8 +1416,7 @@ public class CardFactory_Creatures { } else if (c.hasKeyword("Enchant tapped creature")) { enchantThisType[0] = "Creature.tapped"; message[0] = "Select a tapped creature"; - } else if (c.hasKeyword("Enchant creature") - || c.hasKeyword("Enchant Creature")) { + } else if (c.hasKeyword("Enchant creature") || c.hasKeyword("Enchant Creature")) { enchantThisType[0] = "Creature"; message[0] = "Select a creature"; } else if (c.hasKeyword("Enchant wall") || c.hasKeyword("Enchant Wall")) { @@ -1402,8 +1429,7 @@ public class CardFactory_Creatures { } else if (c.hasKeyword("Enchant land") || c.hasKeyword("Enchant Land")) { enchantThisType[0] = "Land"; message[0] = "Select a land"; - } else if (c.hasKeyword("Enchant artifact") - || c.hasKeyword("Enchant Artifact")) { + } else if (c.hasKeyword("Enchant artifact") || c.hasKeyword("Enchant Artifact")) { enchantThisType[0] = "Artifact"; message[0] = "Select an artifact"; } else if (c.hasKeyword("Enchant enchantment") @@ -1412,13 +1438,13 @@ public class CardFactory_Creatures { message[0] = "Select an enchantment"; } - CardList allCards = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allCards = AllZoneUtil.getCardsIn(Zone.Battlefield); // Make sure that we were able to match // the selected aura with our list of // criteria - if (enchantThisType[0] != "" && message[0] != "") { + if ((enchantThisType[0] != "") && (message[0] != "")) { final CardList choices = allCards.getValidCards(enchantThisType[0], card.getController(), card); @@ -1435,7 +1461,7 @@ public class CardFactory_Creatures { @Override public void selectButtonOK() { - stop(); + this.stop(); } @Override @@ -1444,7 +1470,7 @@ public class CardFactory_Creatures { if (AllZoneUtil.isCardInPlay(card)) { c.enchantEntity(card); - stop(); + this.stop(); } } } // selectCard() @@ -1465,13 +1491,14 @@ public class CardFactory_Creatures { else { CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Library); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isEnchantment() && !c.isAura(); } }); if (list.size() > 0) { - Card c = CardFactoryUtil.AI_getBestEnchantment(list, card, false); + final Card c = CardFactoryUtil.getBestEnchantmentAI(list, card, false); AllZone.getGameAction().moveToPlay(c); if (card.getName().equals("Academy Rector")) { @@ -1483,7 +1510,7 @@ public class CardFactory_Creatures { } // resolve() }; // ability - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); if (card.getName().equals("Academy Rector")) { sb.append("Academy Rector - ").append(card.getController()); sb.append(" may exile this card and place an enchantment from his library onto the battlefield."); @@ -1496,9 +1523,10 @@ public class CardFactory_Creatures { final Command destroy = new Command() { private static final long serialVersionUID = -4352349741511065318L; + @Override public void execute() { - if (card.getName().equals("Lost Auramancers") && card.getCounters(Counters.TIME) <= 0) { + if (card.getName().equals("Lost Auramancers") && (card.getCounters(Counters.TIME) <= 0)) { AllZone.getStack().addSimultaneousStackEntry(ability); } else if (card.getName().equals("Academy Rector")) { @@ -1517,6 +1545,7 @@ public class CardFactory_Creatures { final Command destroy = new Command() { private static final long serialVersionUID = -4352349741511065318L; + @Override public void execute() { if (card.getCounters(Counters.TIME) <= 0) { CardFactoryUtil.makeToken("Insect", "G 6 1 Insect", card.getController(), "G", new String[] { @@ -1533,7 +1562,7 @@ public class CardFactory_Creatures { final SpellAbility ability = new Ability(card, "0") { @Override public void resolve() { - card.addCounter(Counters.P1P1, countKithkin()); + card.addCounter(Counters.P1P1, this.countKithkin()); // System.out.println("all counters: " // +card.sumAllCounters()); } // resolve() @@ -1542,6 +1571,7 @@ public class CardFactory_Creatures { CardList kithkin = card.getController().getCardsIn(Zone.Battlefield); kithkin = kithkin.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (c.isType("Kithkin")) && !c.equals(card); } @@ -1551,9 +1581,10 @@ public class CardFactory_Creatures { } }; - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = -7067218066522935060L; + @Override public void execute() { ability.setStackDescription("Kinsbaile Borderguard enters " + "the battlefield with a +1/+1 counter on it for each other Kithkin you control."); @@ -1566,7 +1597,7 @@ public class CardFactory_Creatures { @Override public void resolve() { for (int i = 0; i < card.sumAllCounters(); i++) { - makeToken(); + this.makeToken(); } } // resolve() @@ -1576,9 +1607,10 @@ public class CardFactory_Creatures { } }; - Command destroy = new Command() { + final Command destroy = new Command() { private static final long serialVersionUID = 304026662487997331L; + @Override public void execute() { ability2.setStackDescription("When Kinsbaile Borderguard " + "is put into a graveyard from play, put a 1/1 white " @@ -1616,7 +1648,7 @@ public class CardFactory_Creatures { kicker.setAdditionalManaCost("2 G"); kicker.setDescription("Kicker 2 G"); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append(" - Creature 5/5 (Kicked)"); kicker.setStackDescription(sb.toString()); @@ -1632,9 +1664,10 @@ public class CardFactory_Creatures { } }; - Command commandComes = new Command() { + final Command commandComes = new Command() { private static final long serialVersionUID = -2622859088591798773L; + @Override public void execute() { if (card.isKicked()) { ability.setStackDescription("Kavu Titan gets 3 +1/+1 counters and gains trample."); @@ -1658,7 +1691,7 @@ public class CardFactory_Creatures { card.setMultiKickerMagnitude(0); } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName); sb.append(" enters the battlefield with a +1/+1 counter on it for each time it was kicked."); ability.setStackDescription(sb.toString()); @@ -1666,6 +1699,7 @@ public class CardFactory_Creatures { final Command comesIntoPlay = new Command() { private static final long serialVersionUID = 4245563898487609274L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry(ability); @@ -1681,7 +1715,7 @@ public class CardFactory_Creatures { * permanent. */ - Cost cost = new Cost("Sac<1/CARDNAME>", cardName, true); + final Cost cost = new Cost("Sac<1/CARDNAME>", cardName, true); final Target tgt = new Target(card, "Select a permanent", "Permanent".split(",")); final SpellAbility ability = new Ability_Activated(card, cost, tgt) { private static final long serialVersionUID = -5084369399105353155L; @@ -1692,6 +1726,7 @@ public class CardFactory_Creatures { // Dark Depths: CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Dark Depths"); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card crd) { return crd.getCounters(Counters.ICE) >= 3; } @@ -1705,8 +1740,9 @@ public class CardFactory_Creatures { // Get rid of Planeswalkers: list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card crd) { - return crd.isPlaneswalker() && crd.getCounters(Counters.LOYALTY) >= 5; + return crd.isPlaneswalker() && (crd.getCounters(Counters.LOYALTY) >= 5); } }); @@ -1720,8 +1756,8 @@ public class CardFactory_Creatures { @Override public void resolve() { - final Card c = getTargetCard(); - for (Counters counter : Counters.values()) { + final Card c = this.getTargetCard(); + for (final Counters counter : Counters.values()) { if (c.getCounters(counter) > 0) { c.setCounter(counter, 0, false); } @@ -1737,14 +1773,17 @@ public class CardFactory_Creatures { final int[] sumPower = new int[1]; final int[] sumToughness = new int[1]; - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = -75234586897814L; + @Override public void execute() { - int intermSumPower, intermSumToughness; - intermSumPower = intermSumToughness = 0; + int intermSumPower = 0; + int intermSumToughness = 0; + //intermSumPower = intermSumToughness = 0; CardList creats = card.getController().getCardsIn(Zone.Graveyard); creats = creats.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isCreature() && !c.equals(card); } @@ -1752,7 +1791,7 @@ public class CardFactory_Creatures { if (card.getController().isHuman()) { if (creats.size() > 0) { - List selection = GuiUtils.getChoicesOptional("Select creatures to sacrifice", + final List selection = GuiUtils.getChoicesOptional("Select creatures to sacrifice", creats.toArray()); numCreatures[0] = selection.size(); @@ -1767,8 +1806,8 @@ public class CardFactory_Creatures { else { int count = 0; for (int i = 0; i < creats.size(); i++) { - Card c = creats.get(i); - if (c.getNetAttack() <= 2 && c.getNetDefense() <= 3) { + final Card c = creats.get(i); + if ((c.getNetAttack() <= 2) && (c.getNetDefense() <= 3)) { intermSumPower += c.getBaseAttack(); intermSumToughness += c.getBaseDefense(); AllZone.getGameAction().exile(c); @@ -1815,8 +1854,8 @@ public class CardFactory_Creatures { final SpellAbility ability = new Ability(card, "0") { @Override public void resolve() { - Player player = card.getController(); - Player opp = player.getOpponent(); + final Player player = card.getController(); + final Player opp = player.getOpponent(); int max = 0; CardList play = opp.getCardsIn(Zone.Battlefield); play = play.filter(CardListFilter.NON_TOKEN); @@ -1827,17 +1866,17 @@ public class CardFactory_Creatures { grave = grave.filter(CardListFilter.WHITE); max += grave.size(); - String[] life = new String[max + 1]; + final String[] life = new String[max + 1]; for (int i = 0; i <= max; i++) { life[i] = String.valueOf(i); } - Object o = GuiUtils.getChoice("Nameless Race - pay X life", life); - String answer = (String) o; + final Object o = GuiUtils.getChoice("Nameless Race - pay X life", life); + final String answer = (String) o; int loseLife = 0; try { loseLife = Integer.parseInt(answer.trim()); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { System.out.println(card.getName() + " - NumberFormatException: " + nfe.getMessage()); } @@ -1848,16 +1887,17 @@ public class CardFactory_Creatures { } // resolve() }; // SpellAbility - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 931101364538995898L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry(ability); } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName).append(" - pay any amount of life."); ability.setStackDescription(sb.toString()); @@ -1881,56 +1921,56 @@ public class CardFactory_Creatures { public void resolve() { AllZone.getInputControl().setInput(new Input() { private static final long serialVersionUID = 6150236529653275947L; - private CardList revealed = new CardList(); + private final CardList revealed = new CardList(); @Override public void showMessage() { // in case hand is empty, don't do anything if (card.getController().getCardsIn(Zone.Hand).size() == 0) { - stop(); + this.stop(); } AllZone.getDisplay().showMessage( - card.getName() + " - Reveal an artifact. Revealed " + revealed.size() + card.getName() + " - Reveal an artifact. Revealed " + this.revealed.size() + " so far. Click OK when done."); ButtonUtil.enableOnlyOK(); } @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand) && c.isArtifact() && !revealed.contains(c)) { - revealed.add(c); + if (zone.is(Constant.Zone.Hand) && c.isArtifact() && !this.revealed.contains(c)) { + this.revealed.add(c); // in case no more cards in hand to reveal - if (revealed.size() == card.getController().getCardsIn(Zone.Hand).size()) { - done(); + if (this.revealed.size() == card.getController().getCardsIn(Zone.Hand).size()) { + this.done(); } else { - showMessage(); + this.showMessage(); } } } @Override public void selectButtonOK() { - done(); + this.done(); } void done() { - StringBuilder sb = new StringBuilder(); - for (Card reveal : revealed) { + final StringBuilder sb = new StringBuilder(); + for (final Card reveal : this.revealed) { sb.append(reveal.getName() + "\n"); } JOptionPane.showMessageDialog(null, "Revealed Cards:\n" + sb.toString(), card.getName(), JOptionPane.PLAIN_MESSAGE); // adding mana - Ability_Mana abMana = new Ability_Mana(card, "0", "1", 2 * revealed.size()) { + final Ability_Mana abMana = new Ability_Mana(card, "0", "1", 2 * this.revealed.size()) { private static final long serialVersionUID = -2182129023960978132L; }; abMana.setUndoable(false); abMana.produceMana(); - stop(); + this.stop(); } }); } // resolve() @@ -1944,7 +1984,7 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** else if (cardName.equals("Phyrexian Scuta")) { - Cost abCost = new Cost("3 B PayLife<3>", cardName, false); + final Cost abCost = new Cost("3 B PayLife<3>", cardName, false); final SpellAbility kicker = new Spell(card, abCost, null) { private static final long serialVersionUID = -6420757044982294960L; @@ -1957,7 +1997,7 @@ public class CardFactory_Creatures { @Override public boolean canPlay() { - return super.canPlay() && card.getController().getLife() >= 3; + return super.canPlay() && (card.getController().getLife() >= 3); } }; @@ -1965,7 +2005,7 @@ public class CardFactory_Creatures { kicker.setManaCost("3 B"); kicker.setDescription("Kicker - Pay 3 life."); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append(" - Creature 3/3 (Kicked)"); kicker.setStackDescription(sb.toString()); @@ -1978,10 +2018,10 @@ public class CardFactory_Creatures { final SpellAbility ability = new Ability(card, "0") { @Override public void resolve() { - Player p = getTargetPlayer(); + final Player p = this.getTargetPlayer(); if (p.canTarget(this)) { p.setSkipNextUntap(true); - for (Card c : targetPerms) { + for (final Card c : targetPerms) { if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { c.tap(); } @@ -1997,7 +2037,7 @@ public class CardFactory_Creatures { @Override public void showMessage() { if (targetPerms.size() == 5) { - done(); + this.done(); } AllZone.getDisplay().showMessage( "Select up to 5 target permanents. Selected (" + targetPerms.size() @@ -2007,19 +2047,19 @@ public class CardFactory_Creatures { @Override public void selectButtonOK() { - done(); + this.done(); } private void done() { // here, we add the ability to the stack since it's // triggered. - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append( " - tap up to 5 permanents target player controls. " + "Target player skips his or her next untap step."); ability.setStackDescription(sb.toString()); AllZone.getStack().add(ability); - stop(); + this.stop(); } @Override @@ -2029,7 +2069,7 @@ public class CardFactory_Creatures { targetPerms.add(c); } } - showMessage(); + this.showMessage(); } }; // Input @@ -2046,27 +2086,28 @@ public class CardFactory_Creatures { public void selectPlayer(final Player p) { if (p.canTarget(ability)) { ability.setTargetPlayer(p); - stopSetNext(targetInput); + this.stopSetNext(targetInput); } } @Override public void selectButtonCancel() { - stop(); + this.stop(); } }; - Command destroy = new Command() { + final Command destroy = new Command() { private static final long serialVersionUID = -3868616119471172026L; + @Override public void execute() { - Player player = card.getController(); - CardList list = CardFactoryUtil.AI_getHumanCreature(card, true); + final Player player = card.getController(); + final CardList list = CardFactoryUtil.getHumanCreatureAI(card, true); if (player.isHuman()) { AllZone.getInputControl().setInput(playerInput); } else if (list.size() != 0) { - Card target = CardFactoryUtil.AI_getBestCreature(list); + final Card target = CardFactoryUtil.getBestCreatureAI(list); ability.setTargetCard(target); AllZone.getStack().addSimultaneousStackEntry(ability); @@ -2086,7 +2127,7 @@ public class CardFactory_Creatures { @Override public void resolve() { if (player.isHuman()) { - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = 2698036349873486664L; @Override @@ -2101,14 +2142,14 @@ public class CardFactory_Creatures { @Override public void selectButtonOK() { - done(); + this.done(); } @Override public void selectButtonCancel() { toSac.clear(); AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } @Override @@ -2117,19 +2158,19 @@ public class CardFactory_Creatures { && !toSac.contains(c)) { toSac.add(c); } - showMessage(); + this.showMessage(); } // selectCard() private void done() { if (getTotalPower() >= 12) { - for (Card sac : toSac) { + for (final Card sac : toSac) { AllZone.getGameAction().sacrifice(sac); } } else { AllZone.getGameAction().sacrifice(card); } toSac.clear(); - stop(); + this.stop(); } }; // Input AllZone.getInputControl().setInput(target); @@ -2138,7 +2179,7 @@ public class CardFactory_Creatures { private int getTotalPower() { int sum = 0; - for (Card c : toSac) { + for (final Card c : toSac) { sum += c.getNetAttack(); } return sum; @@ -2148,6 +2189,7 @@ public class CardFactory_Creatures { final Command comesIntoPlay = new Command() { private static final long serialVersionUID = 7680692311339496770L; + @Override public void execute() { sacOrSac.setStackDescription("When " + cardName + " enters the battlefield, sacrifice it unless you " @@ -2172,10 +2214,11 @@ public class CardFactory_Creatures { final Command leaves = new Command() { private static final long serialVersionUID = 8590474793502538215L; + @Override public void execute() { - Card orig = cfact.getCard(card.getName(), card.getController()); - PlayerZone dest = AllZone.getZoneOf(card.getCurrentlyCloningCard()); + final Card orig = cfact.getCard(card.getName(), card.getController()); + final PlayerZone dest = AllZone.getZoneOf(card.getCurrentlyCloningCard()); AllZone.getGameAction().moveTo(dest, orig); dest.remove(card.getCurrentlyCloningCard()); @@ -2188,14 +2231,14 @@ public class CardFactory_Creatures { @Override public void resolve() { if (card.getController().isComputer()) { - CardList creatures = AllZoneUtil.getCreaturesInPlay(); + final CardList creatures = AllZoneUtil.getCreaturesInPlay(); if (!creatures.isEmpty()) { - copyTarget[0] = CardFactoryUtil.AI_getBestCreature(creatures); + copyTarget[0] = CardFactoryUtil.getBestCreatureAI(creatures); } } if (copyTarget[0] != null) { - boolean wasInAlt = copyTarget[0].isInAlternateState(); + final boolean wasInAlt = copyTarget[0].isInAlternateState(); /* * This cannot just be copyStats with an addSpellAbility * loop from copyTarget[0]. Unless we get a @@ -2212,7 +2255,7 @@ public class CardFactory_Creatures { cloned[0].setImageFilename(copyTarget[0].getImageFilename()); copyTarget[0].changeState(); } - } catch (RuntimeException re) { + } catch (final RuntimeException re) { // the copyTarget was not found in CardFactory cloned[0] = CardFactoryUtil.copyStats(copyTarget[0]); } @@ -2257,10 +2300,10 @@ public class CardFactory_Creatures { cloned[0].setBaseDefense(7); cloned[0].setBaseAttack(7); } else if (cardName.equals("Phantasmal Image")) { - StringBuilder trigScript = new StringBuilder( + final StringBuilder trigScript = new StringBuilder( "Mode$ BecomesTarget | ValidTarget$ Card.Self | " + "TriggerZones$ Battlefield | Execute$ "); - StringBuilder svarName = new StringBuilder("TrigSac"); + final StringBuilder svarName = new StringBuilder("TrigSac"); // Couple of hoops to jump through to make sure no // svar is overwritten. int iter = 0; @@ -2287,7 +2330,7 @@ public class CardFactory_Creatures { } }; // SpellAbility - Input runtime = new Input() { + final Input runtime = new Input() { private static final long serialVersionUID = 7615038074569687330L; @Override @@ -2303,7 +2346,7 @@ public class CardFactory_Creatures { @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override @@ -2314,25 +2357,25 @@ public class CardFactory_Creatures { return; } copyTarget[0] = c; - stopSetNext(new Input_PayManaCost(copy)); + this.stopSetNext(new Input_PayManaCost(copy)); } } }; - Input graveyardRuntime = new Input() { + final Input graveyardRuntime = new Input() { private static final long serialVersionUID = 6950318443268022876L; @Override public void showMessage() { - String message = "Select a creature in a graveyard"; - CardList choices = AllZoneUtil.getCardsIn(Zone.Graveyard); - Object o = GuiUtils.getChoiceOptional(message, choices.toArray()); + final String message = "Select a creature in a graveyard"; + final CardList choices = AllZoneUtil.getCardsIn(Zone.Graveyard); + final Object o = GuiUtils.getChoiceOptional(message, choices.toArray()); if (null == o) { - stop(); + this.stop(); } else { - Card c = (Card) o; + final Card c = (Card) o; copyTarget[0] = c; - stopSetNext(new Input_PayManaCost(copy)); + this.stopSetNext(new Input_PayManaCost(copy)); } } }; @@ -2357,23 +2400,23 @@ public class CardFactory_Creatures { * name revealed this way. Activate this ability only during your * turn. */ - Cost abCost = new Cost("X T", cardName, true); - Target target = new Target(card, "Select target opponent", "Opponent".split(",")); - Ability_Activated discard = new Ability_Activated(card, abCost, target) { + final Cost abCost = new Cost("X T", cardName, true); + final Target target = new Target(card, "Select target opponent", "Opponent".split(",")); + final Ability_Activated discard = new Ability_Activated(card, abCost, target) { private static final long serialVersionUID = 4839778470534392198L; @Override public void resolve() { // name a card - String choice = JOptionPane.showInputDialog(null, "Name a card", cardName, + final String choice = JOptionPane.showInputDialog(null, "Name a card", cardName, JOptionPane.QUESTION_MESSAGE); - CardList hand = getTargetPlayer().getCardsIn(Zone.Hand); + final CardList hand = this.getTargetPlayer().getCardsIn(Zone.Hand); int numCards = card.getXManaCostPaid(); numCards = Math.min(hand.size(), numCards); - CardList revealed = new CardList(); + final CardList revealed = new CardList(); for (int i = 0; i < numCards; i++) { - Card random = CardUtil.getRandom(hand.toArray()); + final Card random = CardUtil.getRandom(hand.toArray()); revealed.add(random); hand.remove(random); } @@ -2383,7 +2426,7 @@ public class CardFactory_Creatures { GuiUtils.getChoice("Revealed at random", new String[] { "Nothing to reveal" }); } - for (Card c : revealed) { + for (final Card c : revealed) { if (c.getName().equals(choice)) { c.getController().discard(c, this); } @@ -2398,14 +2441,14 @@ public class CardFactory_Creatures { discard.getRestrictions().setPlayerTurn(true); - StringBuilder sbDesc = new StringBuilder(); + final StringBuilder sbDesc = new StringBuilder(); sbDesc.append(abCost).append( "Name a card. Target opponent reveals X cards at random from his or her hand. "); sbDesc.append("Then that player discards all cards with that name revealed this way. "); sbDesc.append("Activate this ability only during your turn."); discard.setDescription(sbDesc.toString()); - StringBuilder sbStack = new StringBuilder(); + final StringBuilder sbStack = new StringBuilder(); sbStack.append(cardName).append(" - name a card."); discard.setStackDescription(sbStack.toString()); @@ -2415,7 +2458,7 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** else if (cardName.equals("Brass Squire")) { - Target t2 = new Target(card, "Select target creature you control", "Creature.YouCtrl".split(",")); + final Target t2 = new Target(card, "Select target creature you control", "Creature.YouCtrl".split(",")); final Ability_Sub sub = new Ability_Sub(card, t2) { private static final long serialVersionUID = -8926850792424930054L; @@ -2426,18 +2469,18 @@ public class CardFactory_Creatures { @Override public void resolve() { - Card equipment = this.getParent().getTargetCard(); - Card creature = getTargetCard(); + final Card equipment = this.getParent().getTargetCard(); + final Card creature = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(equipment) && AllZoneUtil.isCardInPlay(creature)) { if (CardFactoryUtil.canTarget(card, equipment) && CardFactoryUtil.canTarget(card, creature)) { if (equipment.isEquipping()) { - Card equipped = equipment.getEquipping().get(0); + final Card equipped = equipment.getEquipping().get(0); if (!equipped.equals(creature)) { equipment.unEquipCard(equipped); equipment.equipCard(creature); } } else { - equipment.equipCard(getTargetCard()); + equipment.equipCard(this.getTargetCard()); } } } @@ -2449,8 +2492,8 @@ public class CardFactory_Creatures { } }; - Cost abCost = new Cost("T", cardName, true); - Target t1 = new Target(card, "Select target equipment you control", "Equipment.YouCtrl".split(",")); + final Cost abCost = new Cost("T", cardName, true); + final Target t1 = new Target(card, "Select target equipment you control", "Equipment.YouCtrl".split(",")); final Ability_Activated ability = new Ability_Activated(card, abCost, t1) { private static final long serialVersionUID = 3818559481920103914L; @@ -2472,7 +2515,7 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** else if (cardName.equals("Gore Vassal")) { - Cost abCost = new Cost("Sac<1/CARDNAME>", cardName, true); + final Cost abCost = new Cost("Sac<1/CARDNAME>", cardName, true); final Ability_Activated ability = new Ability_Activated(card, abCost, new Target(card, "TgtC")) { private static final long serialVersionUID = 3689290210743241201L; @@ -2483,7 +2526,7 @@ public class CardFactory_Creatures { @Override public void resolve() { - final Card target = getTargetCard(); + final Card target = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(target) && CardFactoryUtil.canTarget(card, target)) { target.addCounter(Counters.M1M1, 1); @@ -2492,6 +2535,7 @@ public class CardFactory_Creatures { AllZone.getEndOfTurn().addUntil(new Command() { private static final long serialVersionUID = -3332692040606224591L; + @Override public void execute() { target.resetShield(); } @@ -2505,7 +2549,7 @@ public class CardFactory_Creatures { ability.setDescription(abCost + "Put a -1/-1 counter on target creature. " + "Then if that creature's toughness is 1 or greater, regenerate it."); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName).append(" put a -1/-1 counter on target creature."); ability.setStackDescription(sb.toString()); } // *************** END ************ END ************************** @@ -2514,33 +2558,35 @@ public class CardFactory_Creatures { else if (cardName.equals("Awakener Druid")) { final long[] timeStamp = { 0 }; - Trigger myTrig = TriggerHandler.parseTrigger( + final Trigger myTrig = TriggerHandler.parseTrigger( "Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | " + "ValidCard$ Card.Self | TriggerDescription$ " + "When CARDNAME enters the battlefield, target Forest " + "becomes a 4/5 green Treefolk creature for as long as CARDNAME is on the " + "battlefield. It's still a land.", card, true); - Target myTarget = new Target(card, "Choose target forest.", "Land.Forest".split(","), "1", "1"); + final Target myTarget = new Target(card, "Choose target forest.", "Land.Forest".split(","), "1", "1"); final SpellAbility awaken = new Ability(card, "0") { @Override public void resolve() { - if (!AllZone.getZoneOf(card).is(Zone.Battlefield) || getTarget().getTargetCards().size() == 0) { + if (!AllZone.getZoneOf(card).is(Zone.Battlefield) + || (this.getTarget().getTargetCards().size() == 0)) { return; } - final Card c = getTarget().getTargetCards().get(0); - String[] types = { "Creature", "Treefolk" }; - String[] keywords = {}; + final Card c = this.getTarget().getTargetCards().get(0); + final String[] types = { "Creature", "Treefolk" }; + final String[] keywords = {}; timeStamp[0] = CardFactoryUtil.activateManland(c, 4, 5, types, keywords, "G"); final Command onleave = new Command() { private static final long serialVersionUID = -6004932214386L; - private long stamp = timeStamp[0]; - private Card tgt = c; + private final long stamp = timeStamp[0]; + private final Card tgt = c; + @Override public void execute() { - String[] types = { "Creature", "Treefolk" }; - String[] keywords = { "" }; - CardFactoryUtil.revertManland(tgt, types, keywords, "G", stamp); + final String[] types = { "Creature", "Treefolk" }; + final String[] keywords = { "" }; + CardFactoryUtil.revertManland(this.tgt, types, keywords, "G", this.stamp); } }; card.addLeavesPlayCommand(onleave); @@ -2562,31 +2608,33 @@ public class CardFactory_Creatures { theCost = "UR"; } else { // if (cardName.equals("Spin Engine")) { theCost = "R"; - } - - SpellAbility finalAb = new Ability_Activated(card, new Cost(theCost,cardName,true), new Target(card,"Select target creature.","Creature")) { + } + + final SpellAbility finalAb = new Ability_Activated(card, new Cost(theCost, cardName, true), new Target( + card, "Select target creature.", "Creature")) { private static final long serialVersionUID = 2391351140880148283L; - + @Override public void resolve() { - StringBuilder keywordBuilder = new StringBuilder("HIDDEN CARDNAME can't block "); + final StringBuilder keywordBuilder = new StringBuilder("HIDDEN CARDNAME can't block "); keywordBuilder.append(this.getSourceCard().toString()); - AbilityFactory createAb = new AbilityFactory(); - StringBuilder abilityBuilder = new StringBuilder("AB$Pump | Cost$ "); + final AbilityFactory createAb = new AbilityFactory(); + final StringBuilder abilityBuilder = new StringBuilder("AB$Pump | Cost$ "); abilityBuilder.append(theCost); abilityBuilder.append(" | Tgt$ TgtC | IsCurse$ True | KW$ "); abilityBuilder.append(keywordBuilder.toString()); abilityBuilder.append(" | SpellDescription$ Target creature can't block CARDNAME this turn."); - SpellAbility myAb = createAb.getAbility(abilityBuilder.toString(), card); + final SpellAbility myAb = createAb.getAbility(abilityBuilder.toString(), card); - myAb.getTarget().setTargetChoices(chosenTarget.getTargetChoices()); + myAb.getTarget().setTargetChoices(this.chosenTarget.getTargetChoices()); myAb.resolve(); } - + @Override public String getStackDescription() { - return getSourceCard().toString() + " - Target creature can't block " + getSourceCard().getName() +" this turn."; + return this.getSourceCard().toString() + " - Target creature can't block " + + this.getSourceCard().getName() + " this turn."; } }; @@ -2595,7 +2643,7 @@ public class CardFactory_Creatures { // *************** START *********** START ************************** else if (cardName.equals("Krovikan Sorcerer")) { - Cost abCost = new Cost("T Discard<1/Card.Black>", cardName, true); + final Cost abCost = new Cost("T Discard<1/Card.Black>", cardName, true); final Ability_Activated ability = new Ability_Activated(card, abCost, null) { private static final long serialVersionUID = 3689290210743241201L; @@ -2616,7 +2664,7 @@ public class CardFactory_Creatures { @Override public void showMessage() { if (n.isEmpty()) { - stop(); + this.stop(); } AllZone.getDisplay().showMessage(card + " - discard one of the cards drawn."); ButtonUtil.disableAll(); @@ -2626,7 +2674,7 @@ public class CardFactory_Creatures { public void selectCard(final Card c, final PlayerZone zone) { if (zone.is(Constant.Zone.Hand) && n.contains(c)) { player.discard(c, null); - stop(); + this.stop(); } } }); // end Input @@ -2637,7 +2685,7 @@ public class CardFactory_Creatures { card.addSpellAbility(ability); ability.setDescription("Tap, Discard a black card: " + "Draw two cards, then discard one of them."); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card).append(" - Draw two cards, then discard one of them."); ability.setStackDescription(sb.toString()); } // *************** END ************ END ************************** @@ -2646,29 +2694,32 @@ public class CardFactory_Creatures { // end of card specific code // *************************************************** - if (hasKeyword(card, "Level up") != -1 && hasKeyword(card, "maxLevel") != -1) { - int n = hasKeyword(card, "Level up"); - int m = hasKeyword(card, "maxLevel"); + if ((CardFactory_Creatures.hasKeyword(card, "Level up") != -1) + && (CardFactory_Creatures.hasKeyword(card, "maxLevel") != -1)) { + final int n = CardFactory_Creatures.hasKeyword(card, "Level up"); + final int m = CardFactory_Creatures.hasKeyword(card, "maxLevel"); if (n != -1) { - String parse = card.getKeyword().get(n).toString(); - String parseMax = card.getKeyword().get(m).toString(); + final String parse = card.getKeyword().get(n).toString(); + final String parseMax = card.getKeyword().get(m).toString(); card.removeIntrinsicKeyword(parse); card.removeIntrinsicKeyword(parseMax); - String[] k = parse.split(":"); + final String[] k = parse.split(":"); final String manacost = k[1]; - String[] l = parseMax.split(":"); + final String[] l = parseMax.split(":"); final int maxLevel = Integer.parseInt(l[1]); final SpellAbility levelUp = new Ability_Activated(card, manacost) { private static final long serialVersionUID = 3998280279949548652L; + @Override public void resolve() { card.addCounter(Counters.LEVEL, 1); } + @Override public boolean canPlayAI() { // Todo: Improve Level up code return card.getCounters(Counters.LEVEL) < maxLevel; @@ -2678,12 +2729,12 @@ public class CardFactory_Creatures { levelUp.getRestrictions().setSorcerySpeed(true); card.addSpellAbility(levelUp); - StringBuilder sbDesc = new StringBuilder(); + final StringBuilder sbDesc = new StringBuilder(); sbDesc.append("Level up ").append(manacost).append(" (").append(manacost); sbDesc.append(": Put a level counter on this. Level up only as a sorcery.)"); levelUp.setDescription(sbDesc.toString()); - StringBuilder sbStack = new StringBuilder(); + final StringBuilder sbStack = new StringBuilder(); sbStack.append(card).append(" - put a level counter on this."); levelUp.setStackDescription(sbStack.toString()); diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Equipment.java b/src/main/java/forge/card/cardFactory/CardFactory_Equipment.java index c42e1679fe1..7f8c557eb78 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Equipment.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Equipment.java @@ -164,7 +164,7 @@ class CardFactory_Equipment { } // execute() }; // Command - equip.setBeforePayMana(CardFactoryUtil.input_equipCreature(equip)); + equip.setBeforePayMana(CardFactoryUtil.inputEquipCreature(equip)); equip.getRestrictions().setSorcerySpeed(true); equip.setDescription("Equip: 0"); @@ -215,7 +215,7 @@ class CardFactory_Equipment { // not changed @Override public void chooseTargetAI() { - final Card target = CardFactoryUtil.AI_getBestCreature(this.getCreature()); + final Card target = CardFactoryUtil.getBestCreatureAI(this.getCreature()); this.setTargetCard(target); } @@ -225,7 +225,7 @@ class CardFactory_Equipment { list = list.filter(new CardListFilter() { @Override 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")); } }); @@ -273,7 +273,7 @@ class CardFactory_Equipment { } // execute() }; // Command - equip.setBeforePayMana(CardFactoryUtil.input_equipCreature(equip)); + equip.setBeforePayMana(CardFactoryUtil.inputEquipCreature(equip)); equip.setDescription("Equip: 4"); card.addSpellAbility(equip); @@ -330,8 +330,7 @@ class CardFactory_Equipment { @Override public void selectCard(final Card c, final PlayerZone z) { if (z.is(Constant.Zone.Battlefield, card.getController()) && c.isCreature() - && CardFactoryUtil.canTarget(card, c)) - { + && CardFactoryUtil.canTarget(card, c)) { card.equipCard(c); this.stop(); } @@ -413,9 +412,9 @@ class CardFactory_Equipment { } } - card.addSpellAbility(CardFactoryUtil.eqPump_Equip(card, power, tough, extrinsicKeywords, abCost)); - card.addEquipCommand(CardFactoryUtil.eqPump_onEquip(card, power, tough, extrinsicKeywords, abCost)); - card.addUnEquipCommand(CardFactoryUtil.eqPump_unEquip(card, power, tough, extrinsicKeywords, abCost)); + card.addSpellAbility(CardFactoryUtil.eqPumpEquip(card, power, tough, extrinsicKeywords, abCost)); + card.addEquipCommand(CardFactoryUtil.eqPumpOnEquip(card, power, tough, extrinsicKeywords, abCost)); + card.addUnEquipCommand(CardFactoryUtil.eqPumpUnEquip(card, power, tough, extrinsicKeywords, abCost)); } } // eqPump (was VanillaEquipment) diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Instants.java b/src/main/java/forge/card/cardFactory/CardFactory_Instants.java index 447b740d6dc..8d04cf4b2d9 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Instants.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Instants.java @@ -273,7 +273,7 @@ public class CardFactory_Instants { CardList getCreature() { final CardList out = new CardList(); - final CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); + final CardList list = CardFactoryUtil.getHumanCreatureAI("Flying", card, true); list.shuffle(); 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, // target anything - if (out.isEmpty() && (0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size()) - && (3 > CardFactoryUtil.AI_getHumanCreature(card, true).size())) { - out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true)); + if (out.isEmpty() && (0 < CardFactoryUtil.getHumanCreatureAI(2, card, true).size()) + && (3 > CardFactoryUtil.getHumanCreatureAI(card, true).size())) { + out.addAll(CardFactoryUtil.getHumanCreatureAI(2, card, true)); CardListUtil.sortFlying(out); } return out; @@ -365,7 +365,7 @@ public class CardFactory_Instants { } }; - spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + spell.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); card.addSpellAbility(spell); @@ -379,14 +379,14 @@ public class CardFactory_Instants { @Override 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()); } @Override public void chooseTargetAI() { - final CardList human = CardFactoryUtil.AI_getHumanCreature(card, true); - this.setTargetCard(CardFactoryUtil.AI_getBestCreature(human)); + final CardList human = CardFactoryUtil.getHumanCreatureAI(card, true); + this.setTargetCard(CardFactoryUtil.getBestCreatureAI(human)); } @Override @@ -441,8 +441,7 @@ public class CardFactory_Instants { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (!card.isLand() && zone.is(Constant.Zone.Battlefield) - && CardFactoryUtil.canTarget(spell, card)) { + if (!card.isLand() && zone.is(Constant.Zone.Battlefield) && CardFactoryUtil.canTarget(spell, card)) { spell.setTargetCard(card); if (this.isFree()) { this.setFree(false); @@ -523,21 +522,21 @@ public class CardFactory_Instants { final CardList selectedCards = new CardList(); // pick best creature - Card c = CardFactoryUtil.AI_getBestCreature(list); + Card c = CardFactoryUtil.getBestCreatureAI(list); if (c == null) { c = list.get(0); } list.remove(c); selectedCards.add(c); - c = CardFactoryUtil.AI_getBestCreature(list); + c = CardFactoryUtil.getBestCreatureAI(list); if (c == null) { c = list.get(0); } list.remove(c); selectedCards.add(c); - c = CardFactoryUtil.AI_getBestCreature(list); + c = CardFactoryUtil.getBestCreatureAI(list); if (c == null) { c = list.get(0); } @@ -867,8 +866,8 @@ public class CardFactory_Instants { else if (cardName.equals("Telling Time")) { final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = 2626878556107707854L; - private String[] prompt = new String[] { "Put a card into your hand", "Put a card on top of library", - "Put a card on bottom of library" }; + private final String[] prompt = new String[] { "Put a card into your hand", + "Put a card on top of library", "Put a card on bottom of library" }; @Override public boolean canPlayAI() { @@ -958,7 +957,7 @@ public class CardFactory_Instants { final Cost abCost = new Cost("1 R", cardName, false); final SpellAbility spell = new Spell(card, abCost, new Target(card, "TgtC")) { private static final long serialVersionUID = -3069135027502686218L; - private int damage = 3; + private final int damage = 3; @Override public void chooseTargetAI() { @@ -972,10 +971,10 @@ public class CardFactory_Instants { }); final CardList infect = creatures.getKeyword("Infect"); if (infect.size() > 0) { - final Card c = CardFactoryUtil.AI_getBestCreature(infect); + final Card c = CardFactoryUtil.getBestCreatureAI(infect); this.setTargetCard(c); } else { - final Card c = CardFactoryUtil.AI_getBestCreature(creatures); + final Card c = CardFactoryUtil.getBestCreatureAI(creatures); this.setTargetCard(c); } @@ -1102,7 +1101,7 @@ public class CardFactory_Instants { }; spell.setSubAbility(sub); spell.setDescription("Target creature you control deals damage " - + "equal to its power to target creature with flying."); + + "equal to its power to target creature with flying."); spell.setStackDescription(card + " - Creature you control deals damage equal to its power to creature with flying."); diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Lands.java b/src/main/java/forge/card/cardFactory/CardFactory_Lands.java index d67e8794974..660b9860f74 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Lands.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Lands.java @@ -63,11 +63,12 @@ class CardFactory_Lands { card.addComesIntoPlayCommand(new Command() { private static final long serialVersionUID = 7352127748114888255L; + @Override public void execute() { if (card.getController().isHuman()) { - humanExecute(); + this.humanExecute(); } else { - computerExecute(); + this.computerExecute(); } } @@ -81,27 +82,27 @@ class CardFactory_Lands { if (pay) { AllZone.getComputerPlayer().loseLife(2, card); } else { - tapCard(); + this.tapCard(); } } public void humanExecute() { - int life = card.getController().getLife(); + final int life = card.getController().getLife(); 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(" enters the battlefield tapped."); if (GameActionUtil.showYesNoDialog(card, question.toString())) { AllZone.getHumanPlayer().loseLife(2, card); } else { - tapCard(); + this.tapCard(); } } // if else { - tapCard(); + this.tapCard(); } } // 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; } else { return false; @@ -136,7 +137,7 @@ class CardFactory_Lands { @Override public boolean canPlayAI() { - String phase = AllZone.getPhase().getPhase(); + final String phase = AllZone.getPhase().getPhase(); return phase.equals(Constant.Phase.MAIN2) && super.canPlayAI(); } @@ -156,12 +157,12 @@ class CardFactory_Lands { // TODO - this should probably be a state effect @Override 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 public boolean canPlayAI() { - return canPlay() && super.canPlayAI(); + return this.canPlay() && super.canPlayAI(); } @Override @@ -175,12 +176,14 @@ class CardFactory_Lands { } }; // ability.setDescription("Dark Depths enters the battlefield with - //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. - //If you do, put an indestructible legendary 20/20 black Avatar creature token - //with flying named Marit Lage onto the battlefield."); + // 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. + // If you do, put an indestructible legendary 20/20 black Avatar + // creature token + // with flying named Marit Lage onto the battlefield."); 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."); ability.setStackDescription(sb.toString()); @@ -195,17 +198,18 @@ class CardFactory_Lands { final CardListFilter targets = new CardListFilter() { + @Override public boolean addCard(final Card c) { 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); - Ability_Activated ability = new Ability_Activated(card, abCost, null) { + final Cost abCost = new Cost("G U T", cardName, true); + final Ability_Activated ability = new Ability_Activated(card, abCost, null) { private static final long serialVersionUID = 1416258136308898492L; - private CardList inPlay = new CardList(); + private final CardList inPlay = new CardList(); @Override public boolean canPlayAI() { @@ -213,16 +217,16 @@ class CardFactory_Lands { .getPlayerTurn().isComputer())) { return false; } - inPlay.clear(); - inPlay.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); - return (inPlay.filter(targets).size() > 1) && super.canPlayAI(); + this.inPlay.clear(); + this.inPlay.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); + return (this.inPlay.filter(targets).size() > 1) && super.canPlayAI(); } @Override public void resolve() { - inPlay.clear(); - inPlay.addAll(AllZoneUtil.getCardsIn(Zone.Battlefield)); - for (Card targ : inPlay.filter(targets)) { + this.inPlay.clear(); + this.inPlay.addAll(AllZoneUtil.getCardsIn(Zone.Battlefield)); + for (final Card targ : this.inPlay.filter(targets)) { targ.addCounter(Counters.P1P1, 1); } } @@ -247,23 +251,27 @@ class CardFactory_Lands { private final Player player = card.getController(); + @Override public void execute() { - if (player.isHuman()) { + if (this.player.isHuman()) { final int[] paid = { 0 }; - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = -7835834281866473546L; + @Override public void showMessage() { AllZone.getDisplay().showMessage(cardName + " - Select an untapped land to sacrifice"); ButtonUtil.enableOnlyCancel(); } + @Override public void selectButtonCancel() { AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } + @Override public void selectCard(final Card c, final PlayerZone zone) { if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { AllZone.getGameAction().sacrifice(c); @@ -272,7 +280,7 @@ class CardFactory_Lands { AllZone.getDisplay().showMessage( cardName + " - Select an untapped land to sacrifice"); } else { - stop(); + this.stop(); } } } // selectCard() @@ -316,10 +324,12 @@ class CardFactory_Lands { private static final long serialVersionUID = 6175830918425915833L; private final Player player = card.getController(); + @Override 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) { CardList tappedLand = new CardList(land.toArray()); tappedLand = tappedLand.filter(CardListFilter.TAPPED); @@ -334,24 +344,27 @@ class CardFactory_Lands { AllZone.getGameAction().sacrifice(card); } } else { // this is the human resolution - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = 6653677835621129465L; + @Override public void showMessage() { AllZone.getDisplay().showMessage( cardName + " - Select one " + type[0] + " to sacrifice"); ButtonUtil.enableOnlyCancel(); } + @Override public void selectButtonCancel() { AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } + @Override public void selectCard(final Card c, final PlayerZone zone) { if (c.isLand() && zone.is(Zone.Battlefield) && land.contains(c)) { AllZone.getGameAction().sacrifice(c); - stop(); + this.stop(); } } // selectCard() }; // Input @@ -369,13 +382,14 @@ class CardFactory_Lands { final Command comesIntoPlay = new Command() { private static final long serialVersionUID = 685604326470832887L; + @Override public void execute() { 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); if (land.size() > 0) { - for (Card c : land) { + for (final Card c : land) { AllZone.getGameAction().sacrifice(c); } } @@ -391,15 +405,16 @@ class CardFactory_Lands { private static final long serialVersionUID = 6175830918425915833L; private final Player player = card.getController(); + @Override public void execute() { CardList plains = AllZoneUtil.getPlayerLandsInPlay(card.getController()); plains = plains.filter(CardListFilter.UNTAPPED); - if (player.isComputer()) { + if (this.player.isComputer()) { if (plains.size() > 1) { CardList tappedPlains = new CardList(plains.toArray()); tappedPlains = tappedPlains.getType("Basic"); - for (Card c : tappedPlains) { + for (final Card c : tappedPlains) { AllZone.getGameAction().sacrifice(c); } for (int i = 0; i < tappedPlains.size(); i++) { @@ -417,20 +432,23 @@ class CardFactory_Lands { AllZone.getGameAction().sacrifice(card); return; } - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = 6653677835621129465L; + @Override public void showMessage() { AllZone.getDisplay().showMessage( "Scorched Ruins - Select an untapped land to sacrifice"); ButtonUtil.enableOnlyCancel(); } + @Override public void selectButtonCancel() { AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } + @Override public void selectCard(final Card c, final PlayerZone zone) { if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { AllZone.getGameAction().sacrifice(c); @@ -439,7 +457,7 @@ class CardFactory_Lands { AllZone.getDisplay().showMessage( "Scorched Ruins - Select an untapped land to sacrifice"); } else { - stop(); + this.stop(); } } } // selectCard() @@ -487,11 +505,12 @@ class CardFactory_Lands { card.addComesIntoPlayCommand(new Command() { private static final long serialVersionUID = -5646344170306812481L; + @Override public void execute() { if (card.getController().isHuman()) { - humanExecute(); + this.humanExecute(); } else { - computerExecute(); + this.computerExecute(); } } @@ -499,7 +518,7 @@ class CardFactory_Lands { CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); hand = hand.getType(type); if (hand.size() > 0) { - revealCard(hand.get(0)); + this.revealCard(hand.get(0)); } else { card.tap(); } @@ -520,14 +539,14 @@ class CardFactory_Lands { if (zone.is(Constant.Zone.Hand) && c.isType(type)) { JOptionPane.showMessageDialog(null, "Revealed card: " + c.getName(), card.getName(), JOptionPane.PLAIN_MESSAGE); - stop(); + this.stop(); } } @Override public void selectButtonCancel() { card.tap(); - stop(); + this.stop(); } }); } // execute() @@ -576,7 +595,7 @@ class CardFactory_Lands { final String primary = pTemp; 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(": Add X mana in any combination of ").append(primary); description.append(" and/or ").append(secondary).append(" to your mana pool."); @@ -594,15 +613,13 @@ class CardFactory_Lands { abMana.setUndoable(false); final Ability addMana = new Ability(card, "1", description.toString()) { - private static final long serialVersionUID = 7177960799748450242L; - // @Override public String mana() { - StringBuilder mana = new StringBuilder(); + final StringBuilder mana = new StringBuilder(); for (int i = 0; i < split[0]; i++) { 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(" "); } return mana.toString().trim(); @@ -616,43 +633,42 @@ class CardFactory_Lands { @Override public void resolve() { 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; @Override public void showMessage() { 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++) { 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) { - stop(); + this.stop(); return; } num[0] = Integer.parseInt(answer); - String splitNum = (String) (GuiUtils.getChoiceOptional( - "Number of " + primary + " to add", choices)); + final String splitNum = (GuiUtils.getChoiceOptional("Number of " + primary + " to add", choices)); if (splitNum == null) { - stop(); + this.stop(); return; } 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]); - stop(); + this.stop(); AllZone.getStack().add(addMana); return; } - stop(); + this.stop(); } }; addMana.setDescription(description.toString()); @@ -668,6 +684,7 @@ class CardFactory_Lands { final Command comesIntoPlay = new Command() { private static final long serialVersionUID = 7813334062721799674L; + @Override public void execute() { final Player player = card.getController(); CardList land = AllZoneUtil.getPlayerLandsInPlay(player); @@ -686,25 +703,28 @@ class CardFactory_Lands { AllZone.getGameAction().sacrifice(card); } } else { // this is the human resolution - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = 7944127258985401036L; + @Override public void showMessage() { AllZone.getDisplay().showMessage( cardName + " - Select one non-Lair land to return to your hand"); ButtonUtil.enableOnlyCancel(); } + @Override public void selectButtonCancel() { AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } + @Override public void selectCard(final Card c, final PlayerZone zone) { if (c.isLand() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) && !c.isType("Lair")) { AllZone.getGameAction().moveToHand(c); - stop(); + this.stop(); } } // selectCard() }; // Input @@ -742,30 +762,33 @@ class CardFactory_Lands { if (player.isComputer()) { if (land.size() > 0) { - Card c = CardFactoryUtil.getWorstLand(land); + final Card c = CardFactoryUtil.getWorstLand(land); AllZone.getGameAction().moveToHand(c); } else { AllZone.getGameAction().sacrifice(card); } } else { // this is the human resolution - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = -7886610643693087790L; + @Override public void showMessage() { AllZone.getDisplay().showMessage( card + " - Select one untapped " + type[0] + " to return"); ButtonUtil.enableOnlyCancel(); } + @Override public void selectButtonCancel() { AllZone.getGameAction().sacrifice(card); - stop(); + this.stop(); } + @Override public void selectCard(final Card c, final PlayerZone zone) { if (zone.is(Constant.Zone.Battlefield) && land.contains(c)) { AllZone.getGameAction().moveToHand(c); - stop(); + this.stop(); } } // selectCard() }; // Input @@ -774,12 +797,12 @@ class CardFactory_Lands { } }; sacOrNo.setStackDescription("When CARDNAME enters the battlefield, " - + "sacrifice it unless you return an untapped " - + type[0] + " you control to its owner's hand."); + + "sacrifice it unless you return an untapped " + type[0] + " you control to its owner's hand."); final Command comesIntoPlay = new Command() { private static final long serialVersionUID = -5777499632266148456L; + @Override public void execute() { AllZone.getStack().addSimultaneousStackEntry(sacOrNo); } diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Planeswalkers.java b/src/main/java/forge/card/cardFactory/CardFactory_Planeswalkers.java index f4a3aeb21bc..d883d143154 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Planeswalkers.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Planeswalkers.java @@ -56,606 +56,462 @@ public class CardFactory_Planeswalkers { } /* - // *************** START *********** START ************************** - if (cardName.equals("Elspeth, Knight-Errant")) { - // computer only plays ability 1 and 3, put 1/1 Soldier in play and - // make everything indestructible - final int[] turn = new int[1]; - turn[0] = -1; - - // ability2: target creature gets +3/+3 and flying until EOT - final Target target2 = new Target(card, "TgtC"); - final Cost cost2 = new Cost("AddCounter<1/LOYALTY>", cardName, true); - final SpellAbility ability2 = new Ability_Activated(card, cost2, target2) { - private static final long serialVersionUID = 6624768423224398603L; - - @Override - public void resolve() { - turn[0] = AllZone.getPhase().getTurn(); - final Card c = this.getTargetCard(); - - final Command eot = new Command() { - private static final long serialVersionUID = 94488363210770877L; - - @Override - public void execute() { - if (AllZoneUtil.isCardInPlay(c)) { - c.addTempAttackBoost(-3); - c.addTempDefenseBoost(-3); - c.removeExtrinsicKeyword("Flying"); - } - } // execute() - }; // Command - if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { - c.addTempAttackBoost(3); - c.addTempDefenseBoost(3); - c.addExtrinsicKeyword("Flying"); - - AllZone.getEndOfTurn().addUntil(eot); - } - } // resolve() - - @Override - public boolean canPlayAI() { - return false; - } - - @Override - public boolean canPlay() { - - return (0 < card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - - } // canPlay() - }; // SpellAbility ability2 - - // ability3 - final Cost cost3 = new Cost("SubCounter<8/LOYALTY>", cardName, true); - final SpellAbility ability3 = new Ability_Activated(card, cost3, null) { - private static final long serialVersionUID = -830373718591602944L; - - @Override - public void resolve() { - turn[0] = AllZone.getPhase().getTurn(); - - final Card emblem = new Card(); - // should we even name this permanent? - // emblem.setName("Elspeth Emblem"); - emblem.addIntrinsicKeyword("Indestructible"); - emblem.addIntrinsicKeyword("Shroud"); - emblem.addIntrinsicKeyword("Artifacts, creatures, enchantments, " - + "and lands you control are indestructible."); - emblem.setImmutable(true); - emblem.addType("Emblem"); - emblem.addController(card.getController()); - emblem.setOwner(card.getController()); - - AllZone.getGameAction().moveToPlay(emblem); - - // AllZone.getGameAction().checkStateEffects(); - AllZone.getStaticEffects().rePopulateStateBasedList(); - for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { - final Command com = GameActionUtil.commands.get(effect); - com.execute(); - } - } - - @Override - public boolean canPlay() { - return (8 <= card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } // canPlay() - - @Override - public boolean canPlayAI() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); - list = list.filter(new CardListFilter() { - @Override - public boolean addCard(final Card c) { - return c.isEmblem() - && c.hasKeyword("Artifacts, creatures, enchantments, " - + "and lands you control are indestructible."); - } - }); - return (list.size() == 0) && (card.getCounters(Counters.LOYALTY) > 8); - } - }; - - // ability 1: create white 1/1 token - final Cost cost1 = new Cost("AddCounter<1/LOYALTY>", cardName, true); - final SpellAbility ability1 = new Ability_Activated(card, cost1, null) { - private static final long serialVersionUID = -6766888113766637596L; - - @Override - public void resolve() { - turn[0] = AllZone.getPhase().getTurn(); - - CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card.getController(), "W", new String[] { - "Creature", "Soldier" }, 1, 1, new String[] { "" }); - } - - @Override - public boolean canPlayAI() { - if (ability3.canPlay() && ability3.canPlayAI()) { - return false; - } else { - return true; - } - } - - @Override - public boolean canPlay() { - return (0 < card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } // canPlay() - }; // SpellAbility ability1 - - ability1.setDescription("+1: Put a 1/1 white Soldier creature token onto the battlefield."); - ability1.setStackDescription(card + " - put a 1/1 white Soldier creature token onto the battlefield."); - card.addSpellAbility(ability1); - - ability2.setDescription("+1: Target creature gets +3/+3 and gains flying until end of turn."); - ability2.setStackDescription(card + " - creature gets +3/+3 and gains flying until EOT."); - - card.addSpellAbility(ability2); - - ability3.setDescription("-8: You get an emblem with \"Artifacts, " - + "creatures, enchantments, and lands you control are indestructible.\""); - ability3.setStackDescription(card + " - You get an emblem with \"Artifacts, creatures, enchantments, " - + "and lands you control are indestructible.\""); - card.addSpellAbility(ability3); - - card.setSVars(card.getSVars()); - card.setSets(card.getSets()); - - return card; - } - // *************** END ************ END ************************** - - - - // *************** START *********** START ************************** - if (cardName.equals("Ajani Goldmane")) { - // computer only plays ability 1 and 3, gain life and put X/X token - // onto battlefield - final int[] turn = new int[1]; - turn[0] = -1; - - // ability2: Put a +1/+1 counter on each creature you control. Those - // creatures gain vigilance until end of turn. - final SpellAbility ability2 = new Ability(card, "0") { - private final Command untilEOT = new Command() { - private static final long serialVersionUID = -5436621445704076988L; - - @Override - public void execute() { - final Player player = card.getController(); - final CardList creatures = AllZoneUtil.getCreaturesInPlay(player); - - for (int i = 0; i < creatures.size(); i++) { - final Card card = creatures.get(i); - card.removeExtrinsicKeyword("Vigilance"); - } - } - }; - - @Override - public void resolve() { - card.subtractCounter(Counters.LOYALTY, 1); - turn[0] = AllZone.getPhase().getTurn(); - - final Player player = card.getController(); - final CardList creatures = AllZoneUtil.getCreaturesInPlay(player); - - for (int i = 0; i < creatures.size(); i++) { - final Card card = creatures.get(i); - card.addCounter(Counters.P1P1, 1); - card.addExtrinsicKeyword("Vigilance"); - } - - AllZone.getEndOfTurn().addUntil(this.untilEOT); - } - - @Override - public boolean canPlayAI() { - return false; - } - - @Override - public boolean canPlay() { - - return (0 < card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - - } // canPlay() - }; // SpellAbility ability2 - - ability2.setBeforePayMana(new Input() { - private static final long serialVersionUID = 6373573398967821630L; - private int check = -1; - - @Override - public void showMessage() { - if (this.check != AllZone.getPhase().getTurn()) { - this.check = AllZone.getPhase().getTurn(); - turn[0] = AllZone.getPhase().getTurn(); - AllZone.getStack().add(ability2); - } - this.stop(); - } // showMessage() - }); - - // ability3 - final SpellAbility ability3 = new Ability(card, "0") { - @Override - public void resolve() { - card.subtractCounter(Counters.LOYALTY, 6); - turn[0] = AllZone.getPhase().getTurn(); - - // Create token - final int n = card.getController().getLife(); - CardFactoryUtil.makeToken("Avatar", "W N N Avatar", card.getController(), "W", new String[] { - "Creature", "Avatar" }, n, n, - new String[] { "This creature's power and toughness are each equal to your life total" }); - } - - @Override - public boolean canPlay() { - return (6 <= card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } // canPlay() - - @Override - public boolean canPlayAI() { - // may be it's better to put only if you have less than 5 - // life - return true; - } - }; - ability3.setBeforePayMana(new Input() { - private static final long serialVersionUID = 7530960428366291386L; - - private int check = -1; - - @Override - public void showMessage() { - if (this.check != AllZone.getPhase().getTurn()) { - this.check = AllZone.getPhase().getTurn(); - turn[0] = AllZone.getPhase().getTurn(); - AllZone.getStack().add(ability3); - } - this.stop(); - } // showMessage() - }); - - // ability 1: gain 2 life - final SpellAbility ability1 = new Ability(card, "0") { - @Override - public void resolve() { - card.addCounterFromNonEffect(Counters.LOYALTY, 1); - turn[0] = AllZone.getPhase().getTurn(); - - card.getController().gainLife(2, card); - Log.debug("Ajani Goldmane", "current phase: " + AllZone.getPhase().getPhase()); - } - - @Override - public boolean canPlayAI() { - if (ability3.canPlay() && ability3.canPlayAI()) { - return false; - } else { - return true; - } - } - - @Override - public boolean canPlay() { - return (0 < card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } // canPlay() - }; // SpellAbility ability1 - - ability1.setBeforePayMana(new Input() { - private static final long serialVersionUID = -7969603493514210825L; - - private int check = -1; - - @Override - public void showMessage() { - if (this.check != AllZone.getPhase().getTurn()) { - this.check = AllZone.getPhase().getTurn(); - turn[0] = AllZone.getPhase().getTurn(); - AllZone.getStack().add(ability1); - } - this.stop(); - } // showMessage() - }); - - ability1.setDescription("+1: You gain 2 life."); - final StringBuilder stack1 = new StringBuilder(); - stack1.append("Ajani Goldmane - ").append(card.getController()).append(" gains 2 life"); - ability1.setStackDescription(stack1.toString()); - // ability1.setStackDescription("Ajani Goldmane - " + - // card.getController() + " gains 2 life"); - card.addSpellAbility(ability1); - - ability2.setDescription("-1: Put a +1/+1 counter on each creature you control. " - + " Those creatures gain vigilance until end of turn."); - ability2.setStackDescription("Ajani Goldmane - Put a +1/+1 counter on each " - + "creature you control. They get vigilance."); - card.addSpellAbility(ability2); - - ability3.setDescription("-6: Put a white Avatar creature token onto the battlefield. " - + "It has \"This creature's power and toughness are each equal to your life total.\""); - ability3.setStackDescription("Ajani Goldmane - Put a X/X white Avatar creature " - + "token onto the battlefield."); - card.addSpellAbility(ability3); - - card.setSVars(card.getSVars()); - card.setSets(card.getSets()); - - return card; - } - // *************** END ************ END ************************** - - - // *************** START *********** START ************************** - else if (cardName.equals("Chandra Nalaar")) { - // computer only plays ability 1 and 3, discard and return creature - // from graveyard to play - final int[] turn = new int[1]; - turn[0] = -1; - - // ability 1 - final SpellAbility ability1 = new Ability(card, "0") { - @Override - public void resolve() { - card.addCounterFromNonEffect(Counters.LOYALTY, 1); - turn[0] = AllZone.getPhase().getTurn(); - - if (this.getTargetCard() != null) { - if (AllZoneUtil.isCardInPlay(this.getTargetCard()) - && CardFactoryUtil.canTarget(card, this.getTargetCard())) { - final Card c = this.getTargetCard(); - c.addDamage(1, card); - } - } else { - this.getTargetPlayer().addDamage(1, card); - } - } - - @Override - public boolean canPlay() { - for (int i = 0; i < AllZone.getStack().size(); i++) { - if (AllZone.getStack().peekInstance(i).getSourceCard().equals(card)) { - return false; - } - } - - return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } - - @Override - public boolean canPlayAI() { - this.setTargetPlayer(AllZone.getHumanPlayer()); - this.setStackDescription("Chandra Nalaar - deals 1 damage to " + AllZone.getHumanPlayer()); - return card.getCounters(Counters.LOYALTY) < 8; - } - }; // SpellAbility ability1 - - final Input target1 = new Input() { - private static final long serialVersionUID = 5263705146686766284L; - - @Override - public void showMessage() { - AllZone.getDisplay().showMessage("Select target Player or Planeswalker"); - ButtonUtil.enableOnlyCancel(); - } - - @Override - public void selectButtonCancel() { - this.stop(); - } - - @Override - public void selectCard(final Card card, final PlayerZone zone) { - if (card.isPlaneswalker() && zone.is(Constant.Zone.Battlefield) - && CardFactoryUtil.canTarget(card, card)) { - ability1.setTargetCard(card); - // stopSetNext(new Input_PayManaCost(ability1)); - AllZone.getStack().add(ability1); - this.stop(); - } - } // selectCard() - - @Override - public void selectPlayer(final Player player) { - ability1.setTargetPlayer(player); - // stopSetNext(new Input_PayManaCost(ability1)); - AllZone.getStack().add(ability1); - this.stop(); - } - }; - ability1.setBeforePayMana(target1); - ability1.setDescription("+1: Chandra Nalaar deals 1 damage to target player."); - card.addSpellAbility(ability1); - // end ability1 - - // ability 2 - final int[] damage2 = new int[1]; - - final SpellAbility ability2 = new Ability(card, "0") { - @Override - public void resolve() { - turn[0] = AllZone.getPhase().getTurn(); - - card.subtractCounter(Counters.LOYALTY, damage2[0]); - this.getTargetCard().addDamage(damage2[0], card); - - damage2[0] = 0; - } // resolve() - - @Override - public boolean canPlay() { - for (int i = 0; i < AllZone.getStack().size(); i++) { - if (AllZone.getStack().peekInstance(i).getSourceCard().equals(card)) { - return false; - } - } - - return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } - - @Override - public boolean canPlayAI() { - return false; - } - }; // SpellAbility ability2 - - final Input target2 = new Input() { - private static final long serialVersionUID = -2160464080456452897L; - - @Override - public void showMessage() { - AllZone.getDisplay().showMessage("Select target creature"); - ButtonUtil.enableOnlyCancel(); - } - - @Override - public void selectButtonCancel() { - this.stop(); - } - - @Override - public void selectCard(final Card c, final PlayerZone zone) { - if (!CardFactoryUtil.canTarget(card, c)) { - AllZone.getDisplay().showMessage("Cannot target this card (Shroud? Protection?)."); - } else if (c.isCreature()) { - turn[0] = AllZone.getPhase().getTurn(); - - damage2[0] = this.getDamage(); - - ability2.setTargetCard(c); - ability2.setStackDescription("Chandra Nalaar - deals damage to " + c); - - AllZone.getStack().add(ability2); - this.stop(); - } - } // selectCard() - - int getDamage() { - final int size = card.getCounters(Counters.LOYALTY); - final Object[] choice = new Object[size]; - - for (int i = 0; i < choice.length; i++) { - choice[i] = Integer.valueOf(i + 1); - } - - final Integer damage = (Integer) GuiUtils.getChoice("Select X", choice); - return damage.intValue(); - } - }; // Input target - ability2.setBeforePayMana(target2); - ability2.setDescription("-X: Chandra Nalaar deals X damage to target creature."); - card.addSpellAbility(ability2); - // end ability2 - - // ability 3 - final SpellAbility ability3 = new Ability(card, "0") { - @Override - public void resolve() { - card.subtractCounter(Counters.LOYALTY, 8); - turn[0] = AllZone.getPhase().getTurn(); - - this.getTargetPlayer().addDamage(10, card); - - final CardList list = AllZoneUtil.getCreaturesInPlay(this.getTargetPlayer()); - - for (int i = 0; i < list.size(); i++) { - list.get(i).addDamage(10, card); - } - } // resolve() - - @Override - public boolean canPlay() { - for (int i = 0; i < AllZone.getStack().size(); i++) { - if (AllZone.getStack().peekInstance(i).getSourceCard().equals(card)) { - return false; - } - } - - return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && (7 < card.getCounters(Counters.LOYALTY)) - && Phase.canCastSorcery(card.getController()); - } - - @Override - public boolean canPlayAI() { - this.setTargetPlayer(AllZone.getHumanPlayer()); - final StringBuilder sb = new StringBuilder(); - sb.append("Chandra Nalaar - deals 10 damage to ").append(AllZone.getHumanPlayer()); - sb.append(" and each creature he or she controls."); - this.setStackDescription(sb.toString()); - // setStackDescription("Chandra Nalaar - deals 10 damage to " - // + AllZone.getHumanPlayer() - // + " and each creature he or she controls."); - return true; - } - }; // SpellAbility ability3 - - final Input target3 = new Input() { - private static final long serialVersionUID = -3014450919506364666L; - - @Override - public void showMessage() { - AllZone.getDisplay().showMessage("Select target player"); - ButtonUtil.enableOnlyCancel(); - } - - @Override - public void selectButtonCancel() { - this.stop(); - } - - @Override - public void selectPlayer(final Player player) { - turn[0] = AllZone.getPhase().getTurn(); - - ability3.setTargetPlayer(player); - - final StringBuilder stack3 = new StringBuilder(); - stack3.append("Chandra Nalaar - deals 10 damage to ").append(player); - stack3.append(" and each creature he or she controls."); - ability3.setStackDescription(stack3.toString()); - // ability3.setStackDescription("Chandra Nalaar - deals 10 damage to " - // + player - // + " and each creature he or she controls."); - - AllZone.getStack().add(ability3); - this.stop(); - } - }; // Input target - ability3.setBeforePayMana(target3); - ability3.setDescription("-8: Chandra Nalaar deals 10 damage to target " - + "player and each creature he or she controls."); - card.addSpellAbility(ability3); - // end ability3 - - card.setSVars(card.getSVars()); - card.setSets(card.getSets()); - - return card; - } - // *************** END ************ END ************************** -*/ + * // *************** START *********** START ************************** + * if (cardName.equals("Elspeth, Knight-Errant")) { // computer only + * plays ability 1 and 3, put 1/1 Soldier in play and // make everything + * indestructible final int[] turn = new int[1]; turn[0] = -1; + * + * // ability2: target creature gets +3/+3 and flying until EOT final + * Target target2 = new Target(card, "TgtC"); final Cost cost2 = new + * Cost("AddCounter<1/LOYALTY>", cardName, true); final SpellAbility + * ability2 = new Ability_Activated(card, cost2, target2) { private + * static final long serialVersionUID = 6624768423224398603L; + * + * @Override public void resolve() { turn[0] = + * AllZone.getPhase().getTurn(); final Card c = this.getTargetCard(); + * + * final Command eot = new Command() { private static final long + * serialVersionUID = 94488363210770877L; + * + * @Override public void execute() { if (AllZoneUtil.isCardInPlay(c)) { + * c.addTempAttackBoost(-3); c.addTempDefenseBoost(-3); + * c.removeExtrinsicKeyword("Flying"); } } // execute() }; // Command if + * (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { + * c.addTempAttackBoost(3); c.addTempDefenseBoost(3); + * c.addExtrinsicKeyword("Flying"); + * + * AllZone.getEndOfTurn().addUntil(eot); } } // resolve() + * + * @Override public boolean canPlayAI() { return false; } + * + * @Override public boolean canPlay() { + * + * return (0 < card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); + * + * } // canPlay() }; // SpellAbility ability2 + * + * // ability3 final Cost cost3 = new Cost("SubCounter<8/LOYALTY>", + * cardName, true); final SpellAbility ability3 = new + * Ability_Activated(card, cost3, null) { private static final long + * serialVersionUID = -830373718591602944L; + * + * @Override public void resolve() { turn[0] = + * AllZone.getPhase().getTurn(); + * + * final Card emblem = new Card(); // should we even name this + * permanent? // emblem.setName("Elspeth Emblem"); + * emblem.addIntrinsicKeyword("Indestructible"); + * emblem.addIntrinsicKeyword("Shroud"); + * emblem.addIntrinsicKeyword("Artifacts, creatures, enchantments, " + + * "and lands you control are indestructible."); + * emblem.setImmutable(true); emblem.addType("Emblem"); + * emblem.addController(card.getController()); + * emblem.setOwner(card.getController()); + * + * AllZone.getGameAction().moveToPlay(emblem); + * + * // AllZone.getGameAction().checkStateEffects(); + * AllZone.getStaticEffects().rePopulateStateBasedList(); for (final + * String effect : + * AllZone.getStaticEffects().getStateBasedMap().keySet()) { final + * Command com = GameActionUtil.commands.get(effect); com.execute(); } } + * + * @Override public boolean canPlay() { return (8 <= + * card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } // canPlay() + * + * @Override public boolean canPlayAI() { CardList list = + * AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); list = + * list.filter(new CardListFilter() { + * + * @Override public boolean addCard(final Card c) { return c.isEmblem() + * && c.hasKeyword("Artifacts, creatures, enchantments, " + + * "and lands you control are indestructible."); } }); return + * (list.size() == 0) && (card.getCounters(Counters.LOYALTY) > 8); } }; + * + * // ability 1: create white 1/1 token final Cost cost1 = new + * Cost("AddCounter<1/LOYALTY>", cardName, true); final SpellAbility + * ability1 = new Ability_Activated(card, cost1, null) { private static + * final long serialVersionUID = -6766888113766637596L; + * + * @Override public void resolve() { turn[0] = + * AllZone.getPhase().getTurn(); + * + * CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", + * card.getController(), "W", new String[] { "Creature", "Soldier" }, 1, + * 1, new String[] { "" }); } + * + * @Override public boolean canPlayAI() { if (ability3.canPlay() && + * ability3.canPlayAI()) { return false; } else { return true; } } + * + * @Override public boolean canPlay() { return (0 < + * card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } // canPlay() }; // + * SpellAbility ability1 + * + * ability1.setDescription( + * "+1: Put a 1/1 white Soldier creature token onto the battlefield."); + * ability1.setStackDescription(card + + * " - put a 1/1 white Soldier creature token onto the battlefield."); + * card.addSpellAbility(ability1); + * + * ability2.setDescription( + * "+1: Target creature gets +3/+3 and gains flying until end of turn." + * ); ability2.setStackDescription(card + + * " - creature gets +3/+3 and gains flying until EOT."); + * + * card.addSpellAbility(ability2); + * + * ability3.setDescription("-8: You get an emblem with \"Artifacts, " + + * "creatures, enchantments, and lands you control are indestructible.\"" + * ); ability3.setStackDescription(card + + * " - You get an emblem with \"Artifacts, creatures, enchantments, " + + * "and lands you control are indestructible.\""); + * card.addSpellAbility(ability3); + * + * card.setSVars(card.getSVars()); card.setSets(card.getSets()); + * + * return card; } // *************** END ************ END + * ************************** + * + * + * + * // *************** START *********** START ************************** + * if (cardName.equals("Ajani Goldmane")) { // computer only plays + * ability 1 and 3, gain life and put X/X token // onto battlefield + * final int[] turn = new int[1]; turn[0] = -1; + * + * // ability2: Put a +1/+1 counter on each creature you control. Those + * // creatures gain vigilance until end of turn. final SpellAbility + * ability2 = new Ability(card, "0") { private final Command untilEOT = + * new Command() { private static final long serialVersionUID = + * -5436621445704076988L; + * + * @Override public void execute() { final Player player = + * card.getController(); final CardList creatures = + * AllZoneUtil.getCreaturesInPlay(player); + * + * for (int i = 0; i < creatures.size(); i++) { final Card card = + * creatures.get(i); card.removeExtrinsicKeyword("Vigilance"); } } }; + * + * @Override public void resolve() { + * card.subtractCounter(Counters.LOYALTY, 1); turn[0] = + * AllZone.getPhase().getTurn(); + * + * final Player player = card.getController(); final CardList creatures + * = AllZoneUtil.getCreaturesInPlay(player); + * + * for (int i = 0; i < creatures.size(); i++) { final Card card = + * creatures.get(i); card.addCounter(Counters.P1P1, 1); + * card.addExtrinsicKeyword("Vigilance"); } + * + * AllZone.getEndOfTurn().addUntil(this.untilEOT); } + * + * @Override public boolean canPlayAI() { return false; } + * + * @Override public boolean canPlay() { + * + * return (0 < card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); + * + * } // canPlay() }; // SpellAbility ability2 + * + * ability2.setBeforePayMana(new Input() { private static final long + * serialVersionUID = 6373573398967821630L; private int check = -1; + * + * @Override public void showMessage() { if (this.check != + * AllZone.getPhase().getTurn()) { this.check = + * AllZone.getPhase().getTurn(); turn[0] = AllZone.getPhase().getTurn(); + * AllZone.getStack().add(ability2); } this.stop(); } // showMessage() + * }); + * + * // ability3 final SpellAbility ability3 = new Ability(card, "0") { + * + * @Override public void resolve() { + * card.subtractCounter(Counters.LOYALTY, 6); turn[0] = + * AllZone.getPhase().getTurn(); + * + * // Create token final int n = card.getController().getLife(); + * CardFactoryUtil.makeToken("Avatar", "W N N Avatar", + * card.getController(), "W", new String[] { "Creature", "Avatar" }, n, + * n, new String[] { + * "This creature's power and toughness are each equal to your life total" + * }); } + * + * @Override public boolean canPlay() { return (6 <= + * card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } // canPlay() + * + * @Override public boolean canPlayAI() { // may be it's better to put + * only if you have less than 5 // life return true; } }; + * ability3.setBeforePayMana(new Input() { private static final long + * serialVersionUID = 7530960428366291386L; + * + * private int check = -1; + * + * @Override public void showMessage() { if (this.check != + * AllZone.getPhase().getTurn()) { this.check = + * AllZone.getPhase().getTurn(); turn[0] = AllZone.getPhase().getTurn(); + * AllZone.getStack().add(ability3); } this.stop(); } // showMessage() + * }); + * + * // ability 1: gain 2 life final SpellAbility ability1 = new + * Ability(card, "0") { + * + * @Override public void resolve() { + * card.addCounterFromNonEffect(Counters.LOYALTY, 1); turn[0] = + * AllZone.getPhase().getTurn(); + * + * card.getController().gainLife(2, card); Log.debug("Ajani Goldmane", + * "current phase: " + AllZone.getPhase().getPhase()); } + * + * @Override public boolean canPlayAI() { if (ability3.canPlay() && + * ability3.canPlayAI()) { return false; } else { return true; } } + * + * @Override public boolean canPlay() { return (0 < + * card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } // canPlay() }; // + * SpellAbility ability1 + * + * ability1.setBeforePayMana(new Input() { private static final long + * serialVersionUID = -7969603493514210825L; + * + * private int check = -1; + * + * @Override public void showMessage() { if (this.check != + * AllZone.getPhase().getTurn()) { this.check = + * AllZone.getPhase().getTurn(); turn[0] = AllZone.getPhase().getTurn(); + * AllZone.getStack().add(ability1); } this.stop(); } // showMessage() + * }); + * + * ability1.setDescription("+1: You gain 2 life."); final StringBuilder + * stack1 = new StringBuilder(); + * stack1.append("Ajani Goldmane - ").append + * (card.getController()).append(" gains 2 life"); + * ability1.setStackDescription(stack1.toString()); // + * ability1.setStackDescription("Ajani Goldmane - " + // + * card.getController() + " gains 2 life"); + * card.addSpellAbility(ability1); + * + * ability2.setDescription( + * "-1: Put a +1/+1 counter on each creature you control. " + + * " Those creatures gain vigilance until end of turn."); + * ability2.setStackDescription + * ("Ajani Goldmane - Put a +1/+1 counter on each " + + * "creature you control. They get vigilance."); + * card.addSpellAbility(ability2); + * + * ability3.setDescription( + * "-6: Put a white Avatar creature token onto the battlefield. " + + * "It has \"This creature's power and toughness are each equal to your life total.\"" + * ); ability3.setStackDescription( + * "Ajani Goldmane - Put a X/X white Avatar creature " + + * "token onto the battlefield."); card.addSpellAbility(ability3); + * + * card.setSVars(card.getSVars()); card.setSets(card.getSets()); + * + * return card; } // *************** END ************ END + * ************************** + * + * + * // *************** START *********** START ************************** + * else if (cardName.equals("Chandra Nalaar")) { // computer only plays + * ability 1 and 3, discard and return creature // from graveyard to + * play final int[] turn = new int[1]; turn[0] = -1; + * + * // ability 1 final SpellAbility ability1 = new Ability(card, "0") { + * + * @Override public void resolve() { + * card.addCounterFromNonEffect(Counters.LOYALTY, 1); turn[0] = + * AllZone.getPhase().getTurn(); + * + * if (this.getTargetCard() != null) { if + * (AllZoneUtil.isCardInPlay(this.getTargetCard()) && + * CardFactoryUtil.canTarget(card, this.getTargetCard())) { final Card c + * = this.getTargetCard(); c.addDamage(1, card); } } else { + * this.getTargetPlayer().addDamage(1, card); } } + * + * @Override public boolean canPlay() { for (int i = 0; i < + * AllZone.getStack().size(); i++) { if + * (AllZone.getStack().peekInstance(i).getSourceCard().equals(card)) { + * return false; } } + * + * return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && + * (turn[0] != AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } + * + * @Override public boolean canPlayAI() { + * this.setTargetPlayer(AllZone.getHumanPlayer()); + * this.setStackDescription("Chandra Nalaar - deals 1 damage to " + + * AllZone.getHumanPlayer()); return card.getCounters(Counters.LOYALTY) + * < 8; } }; // SpellAbility ability1 + * + * final Input target1 = new Input() { private static final long + * serialVersionUID = 5263705146686766284L; + * + * @Override public void showMessage() { + * AllZone.getDisplay().showMessage + * ("Select target Player or Planeswalker"); + * ButtonUtil.enableOnlyCancel(); } + * + * @Override public void selectButtonCancel() { this.stop(); } + * + * @Override public void selectCard(final Card card, final PlayerZone + * zone) { if (card.isPlaneswalker() && + * zone.is(Constant.Zone.Battlefield) && CardFactoryUtil.canTarget(card, + * card)) { ability1.setTargetCard(card); // stopSetNext(new + * Input_PayManaCost(ability1)); AllZone.getStack().add(ability1); + * this.stop(); } } // selectCard() + * + * @Override public void selectPlayer(final Player player) { + * ability1.setTargetPlayer(player); // stopSetNext(new + * Input_PayManaCost(ability1)); AllZone.getStack().add(ability1); + * this.stop(); } }; ability1.setBeforePayMana(target1); + * ability1.setDescription + * ("+1: Chandra Nalaar deals 1 damage to target player."); + * card.addSpellAbility(ability1); // end ability1 + * + * // ability 2 final int[] damage2 = new int[1]; + * + * final SpellAbility ability2 = new Ability(card, "0") { + * + * @Override public void resolve() { turn[0] = + * AllZone.getPhase().getTurn(); + * + * card.subtractCounter(Counters.LOYALTY, damage2[0]); + * this.getTargetCard().addDamage(damage2[0], card); + * + * damage2[0] = 0; } // resolve() + * + * @Override public boolean canPlay() { for (int i = 0; i < + * AllZone.getStack().size(); i++) { if + * (AllZone.getStack().peekInstance(i).getSourceCard().equals(card)) { + * return false; } } + * + * return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && + * (turn[0] != AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } + * + * @Override public boolean canPlayAI() { return false; } }; // + * SpellAbility ability2 + * + * final Input target2 = new Input() { private static final long + * serialVersionUID = -2160464080456452897L; + * + * @Override public void showMessage() { + * AllZone.getDisplay().showMessage("Select target creature"); + * ButtonUtil.enableOnlyCancel(); } + * + * @Override public void selectButtonCancel() { this.stop(); } + * + * @Override public void selectCard(final Card c, final PlayerZone zone) + * { if (!CardFactoryUtil.canTarget(card, c)) { + * AllZone.getDisplay().showMessage + * ("Cannot target this card (Shroud? Protection?)."); } else if + * (c.isCreature()) { turn[0] = AllZone.getPhase().getTurn(); + * + * damage2[0] = this.getDamage(); + * + * ability2.setTargetCard(c); + * ability2.setStackDescription("Chandra Nalaar - deals damage to " + + * c); + * + * AllZone.getStack().add(ability2); this.stop(); } } // selectCard() + * + * int getDamage() { final int size = + * card.getCounters(Counters.LOYALTY); final Object[] choice = new + * Object[size]; + * + * for (int i = 0; i < choice.length; i++) { choice[i] = + * Integer.valueOf(i + 1); } + * + * final Integer damage = (Integer) GuiUtils.getChoice("Select X", + * choice); return damage.intValue(); } }; // Input target + * ability2.setBeforePayMana(target2); ability2.setDescription( + * "-X: Chandra Nalaar deals X damage to target creature."); + * card.addSpellAbility(ability2); // end ability2 + * + * // ability 3 final SpellAbility ability3 = new Ability(card, "0") { + * + * @Override public void resolve() { + * card.subtractCounter(Counters.LOYALTY, 8); turn[0] = + * AllZone.getPhase().getTurn(); + * + * this.getTargetPlayer().addDamage(10, card); + * + * final CardList list = + * AllZoneUtil.getCreaturesInPlay(this.getTargetPlayer()); + * + * for (int i = 0; i < list.size(); i++) { list.get(i).addDamage(10, + * card); } } // resolve() + * + * @Override public boolean canPlay() { for (int i = 0; i < + * AllZone.getStack().size(); i++) { if + * (AllZone.getStack().peekInstance(i).getSourceCard().equals(card)) { + * return false; } } + * + * return AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && + * (turn[0] != AllZone.getPhase().getTurn()) && (7 < + * card.getCounters(Counters.LOYALTY)) && + * Phase.canCastSorcery(card.getController()); } + * + * @Override public boolean canPlayAI() { + * this.setTargetPlayer(AllZone.getHumanPlayer()); final StringBuilder + * sb = new StringBuilder(); + * sb.append("Chandra Nalaar - deals 10 damage to " + * ).append(AllZone.getHumanPlayer()); + * sb.append(" and each creature he or she controls."); + * this.setStackDescription(sb.toString()); // + * setStackDescription("Chandra Nalaar - deals 10 damage to " // + + * AllZone.getHumanPlayer() // + + * " and each creature he or she controls."); return true; } }; // + * SpellAbility ability3 + * + * final Input target3 = new Input() { private static final long + * serialVersionUID = -3014450919506364666L; + * + * @Override public void showMessage() { + * AllZone.getDisplay().showMessage("Select target player"); + * ButtonUtil.enableOnlyCancel(); } + * + * @Override public void selectButtonCancel() { this.stop(); } + * + * @Override public void selectPlayer(final Player player) { turn[0] = + * AllZone.getPhase().getTurn(); + * + * ability3.setTargetPlayer(player); + * + * final StringBuilder stack3 = new StringBuilder(); + * stack3.append("Chandra Nalaar - deals 10 damage to ").append(player); + * stack3.append(" and each creature he or she controls."); + * ability3.setStackDescription(stack3.toString()); // + * ability3.setStackDescription("Chandra Nalaar - deals 10 damage to " + * // + player // + " and each creature he or she controls."); + * + * AllZone.getStack().add(ability3); this.stop(); } }; // Input target + * ability3.setBeforePayMana(target3); + * ability3.setDescription("-8: Chandra Nalaar deals 10 damage to target " + * + "player and each creature he or she controls."); + * card.addSpellAbility(ability3); // end ability3 + * + * card.setSVars(card.getSVars()); card.setSets(card.getSets()); + * + * return card; } // *************** END ************ END + * ************************** + */ // *************** START *********** START ************************** else if (cardName.equals("Tezzeret the Seeker")) { final int[] turn = new int[1]; @@ -793,11 +649,11 @@ public class CardFactory_Planeswalkers { } }; // SpellAbility ability2 ability2.setDescription("-X: Search your library for an artifact card with " - + "converted mana cost X or less and put it onto the battlefield. Then shuffle your library."); + + "converted mana cost X or less and put it onto the battlefield. Then shuffle your library."); final StringBuilder stack2 = new StringBuilder(); stack2.append(card.getName()); stack2.append(" - Search your library for an artifact card with converted " - + "mana cost X or less and put it onto the battlefield. Then shuffle your library."); + + "mana cost X or less and put it onto the battlefield. Then shuffle your library."); ability2.setStackDescription(stack2.toString()); card.addSpellAbility(ability2); @@ -967,14 +823,14 @@ public class CardFactory_Planeswalkers { } // canPlay() }; ability1.setDescription("+2: Look at the top card of target player's library. " - + "You may put that card on the bottom of that player's library."); + + "You may put that card on the bottom of that player's library."); final StringBuilder stack1 = new StringBuilder(); - stack1.append(card.getName()) - .append(" - Look at the top card of target player's library. " - + "You may put that card on the bottom of that player's library."); + stack1.append(card.getName()).append( + " - Look at the top card of target player's library. " + + "You may put that card on the bottom of that player's library."); ability1.setStackDescription(stack1.toString()); - ability1.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + ability1.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); card.addSpellAbility(ability1); final Ability ability2 = new Ability(card, "0") { @@ -1027,7 +883,7 @@ public class CardFactory_Planeswalkers { } // canPlay() }; ability2.setDescription("0: Draw three cards, then put two cards from your " - + "hand on top of your library in any order."); + + "hand on top of your library in any order."); final StringBuilder stack2 = new StringBuilder(); stack2.append(card.getName()).append( " - Draw three cards, then put two cards from your hand on top of your library in any order."); @@ -1109,13 +965,13 @@ public class CardFactory_Planeswalkers { } }; ability4.setDescription("-12: Exile all cards from target player's library, then that " - + "player shuffles his or her hand into his or her library."); + + "player shuffles his or her hand into his or her library."); final StringBuilder stack4 = new StringBuilder(); - stack4.append(card.getName()) - .append(" - Exile all cards from target player's library, then that player " - + "shuffles his or her hand into his or her library."); + stack4.append(card.getName()).append( + " - Exile all cards from target player's library, then that player " + + "shuffles his or her hand into his or her library."); ability4.setStackDescription(stack4.toString()); - ability4.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + ability4.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); card.addSpellAbility(ability4); card.setSVars(card.getSVars()); @@ -1177,7 +1033,7 @@ public class CardFactory_Planeswalkers { } // canPlay() }; ability1.setDescription("0: Reveal the top card of your library and put it " - + "into your hand. Sarkhan the Mad deals damage to himself equal to that card's converted mana cost."); + + "into your hand. Sarkhan the Mad deals damage to himself equal to that card's converted mana cost."); final StringBuilder stack1 = new StringBuilder(); stack1.append(card.getName()).append(" - Reveal top card and do damage."); ability1.setStackDescription(stack1.toString()); @@ -1229,11 +1085,11 @@ public class CardFactory_Planeswalkers { return !(c.isToken() && c.isType("Dragon")); } }); - this.setTargetCard(CardFactoryUtil.AI_getCheapestCreature(cards, card, true)); + this.setTargetCard(CardFactoryUtil.getCheapestCreatureAI(cards, card, true)); Log.debug( "Sarkhan the Mad", "Sarkhan the Mad caused sacrifice of: " - + CardFactoryUtil.AI_getCheapestCreature(cards, card, true)); + + CardFactoryUtil.getCheapestCreatureAI(cards, card, true)); } @Override @@ -1244,7 +1100,7 @@ public class CardFactory_Planeswalkers { } // canPlay() }; ability2.setDescription("-2: Target creature's controller sacrifices it, " - + "then that player puts a 5/5 red Dragon creature token with flying onto the battlefield."); + + "then that player puts a 5/5 red Dragon creature token with flying onto the battlefield."); // ability3 /* @@ -1287,7 +1143,7 @@ public class CardFactory_Planeswalkers { } // canPlay() }; ability3.setDescription("-4: Each Dragon creature you control " - + "deals damage equal to its power to target player."); + + "deals damage equal to its power to target player."); card.addSpellAbility(ability1); card.addSpellAbility(ability2); @@ -1300,239 +1156,192 @@ public class CardFactory_Planeswalkers { } // *************** END ************ END ************************** /* - // *************** START *********** START ************************** - else if (cardName.equals("Koth of the Hammer")) { - // computer only plays ability 1 and 3, put 1/1 Soldier in play and - // make everything indestructible - final int[] turn = new int[1]; - turn[0] = -1; - - // ability2: add R for each mountain - final SpellAbility ability2 = new Ability(card, "0") { - - @Override - public void resolve() { - - card.subtractCounter(Counters.LOYALTY, 2); - - turn[0] = AllZone.getPhase().getTurn(); - - CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); - list = list.filter(new CardListFilter() { - @Override - public boolean addCard(final Card crd) { - return crd.isType("Mountain"); - } - }); - - final Ability_Mana abMana = new Ability_Mana(card, "0", "R", list.size()) { - private static final long serialVersionUID = -2182129023960978132L; - }; - abMana.setUndoable(false); - abMana.produceMana(); - - } // resolve() - - @Override - public boolean canPlayAI() { - return false; - } - - @Override - public boolean canPlay() { - - return (0 < card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - - } // canPlay() - }; // SpellAbility ability2 - - // ability3 - final SpellAbility ability3 = new Ability(card, "0") { - @Override - public void resolve() { - card.subtractCounter(Counters.LOYALTY, 5); - turn[0] = AllZone.getPhase().getTurn(); - - final Card emblem = new Card(); - - emblem.addIntrinsicKeyword("Indestructible"); - emblem.addIntrinsicKeyword("Shroud"); - emblem.addIntrinsicKeyword("Mountains you control have 'tap: This land deals " - + "1 damage to target creature or player.'"); - emblem.setImmutable(true); - emblem.addType("Emblem"); - emblem.addController(card.getController()); - emblem.setOwner(card.getOwner()); - - // TODO Emblems live in the command zone - AllZone.getGameAction().moveToPlay(emblem); - - // AllZone.getGameAction().checkStateEffects(); - AllZone.getStaticEffects().rePopulateStateBasedList(); - for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { - final Command com = GameActionUtil.commands.get(effect); - com.execute(); - } - } - - @Override - public boolean canPlay() { - return (5 <= card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } // canPlay() - - @Override - public boolean canPlayAI() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); - list = list.filter(new CardListFilter() { - @Override - public boolean addCard(final Card c) { - return c.isEmblem() - && c.hasKeyword("Mountains you control have 'tap: This land " - + "deals 1 damage to target creature or player.'"); - } - }); - return (list.size() == 0) && (card.getCounters(Counters.LOYALTY) > 5); - } - }; - ability3.setBeforePayMana(new Input() { - private static final long serialVersionUID = -2054686425541429389L; - - private int check = -1; - - @Override - public void showMessage() { - if (this.check != AllZone.getPhase().getTurn()) { - this.check = AllZone.getPhase().getTurn(); - turn[0] = AllZone.getPhase().getTurn(); - AllZone.getStack().add(ability3); - } - this.stop(); - } // showMessage() - }); - - // ability 1: make 4/4 out of mountain - final SpellAbility ability1 = new Ability(card, "0") { - @Override - public void resolve() { - card.addCounterFromNonEffect(Counters.LOYALTY, 1); - turn[0] = AllZone.getPhase().getTurn(); - - final Card[] card = new Card[1]; - card[0] = this.getTargetCard(); - - final int[] oldAttack = new int[1]; - final int[] oldDefense = new int[1]; - - oldAttack[0] = card[0].getBaseAttack(); - oldDefense[0] = card[0].getBaseDefense(); - - if (card[0].isType("Mountain")) { - card[0].untap(); - - card[0].setBaseAttack(4); - card[0].setBaseDefense(4); - card[0].addType("Creature"); - card[0].addType("Elemental"); - - // EOT - final Command untilEOT = new Command() { - - private static final long serialVersionUID = 6426615528873039915L; - - @Override - public void execute() { - card[0].setBaseAttack(oldAttack[0]); - card[0].setBaseDefense(oldDefense[0]); - - card[0].removeType("Creature"); - card[0].removeType("Elemental"); - } - }; - AllZone.getEndOfTurn().addUntil(untilEOT); - } - } - - @Override - public boolean canPlayAI() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); - list = list.filter(new CardListFilter() { - @Override - public boolean addCard(final Card crd) { - return crd.isEmblem() - && crd.hasKeyword("Mountains you control have 'tap: " - + "This land deals 1 damage to target creature or player.'"); - } - }); - - CardList mountains = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); - mountains = mountains.filter(new CardListFilter() { - @Override - public boolean addCard(final Card crd) { - return crd.isType("Mountain") && CardFactoryUtil.canTarget(card, crd); - } - }); - CardListUtil.sortByTapped(mountains); - - if (mountains.size() == 0) { - return false; - } - - if (ability3.canPlay() && ability3.canPlayAI() && (list.size() == 0)) { - return false; - } else { - this.setTargetCard(mountains.get(0)); - return true; - } - } - - @Override - public boolean canPlay() { - return (0 < card.getCounters(Counters.LOYALTY)) - && AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) - && (turn[0] != AllZone.getPhase().getTurn()) && Phase.canCastSorcery(card.getController()); - } // canPlay() - }; // SpellAbility ability1 - - final Input runtime = new Input() { - private static final long serialVersionUID = -7823269301012427007L; - - @Override - public void showMessage() { - final CardList lands = card.getController().getCardsIn(Zone.Battlefield).getType("Mountain"); - - this.stopSetNext(CardFactoryUtil.input_targetSpecific(ability1, lands, "Select target Mountain", - true, false)); - } // showMessage() - }; // Input - - ability1.setBeforePayMana(runtime); - - ability1.setDescription("+1: Untap target Mountain. It becomes a 4/4 red " - + "Elemental creature until end of turn. It's still a land."); - // ability1.setStackDescription(""); - card.addSpellAbility(ability1); - - ability2.setDescription("-2: Add R to your mana pool for each Mountain you control."); - ability2.setStackDescription("Koth of the Hammer - Add R to your mana pool for each Mountain you control."); - card.addSpellAbility(ability2); - - ability3.setDescription("-5: You get an emblem with \"Mountains you control " - + "have 'tap: This land deals 1 damage to target creature or player.'\""); - ability3.setStackDescription("Koth of the Hammer - You get an emblem with \"Mountains " - + "you control have 'tap: This land deals 1 damage to target creature or player.'\""); - card.addSpellAbility(ability3); - - card.setSVars(card.getSVars()); - card.setSets(card.getSets()); - - return card; - } - // *************** END ************ END ************************** - */ + * // *************** START *********** START ************************** + * else if (cardName.equals("Koth of the Hammer")) { // computer only + * plays ability 1 and 3, put 1/1 Soldier in play and // make everything + * indestructible final int[] turn = new int[1]; turn[0] = -1; + * + * // ability2: add R for each mountain final SpellAbility ability2 = + * new Ability(card, "0") { + * + * @Override public void resolve() { + * + * card.subtractCounter(Counters.LOYALTY, 2); + * + * turn[0] = AllZone.getPhase().getTurn(); + * + * CardList list = + * AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); list = + * list.filter(new CardListFilter() { + * + * @Override public boolean addCard(final Card crd) { return + * crd.isType("Mountain"); } }); + * + * final Ability_Mana abMana = new Ability_Mana(card, "0", "R", + * list.size()) { private static final long serialVersionUID = + * -2182129023960978132L; }; abMana.setUndoable(false); + * abMana.produceMana(); + * + * } // resolve() + * + * @Override public boolean canPlayAI() { return false; } + * + * @Override public boolean canPlay() { + * + * return (0 < card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); + * + * } // canPlay() }; // SpellAbility ability2 + * + * // ability3 final SpellAbility ability3 = new Ability(card, "0") { + * + * @Override public void resolve() { + * card.subtractCounter(Counters.LOYALTY, 5); turn[0] = + * AllZone.getPhase().getTurn(); + * + * final Card emblem = new Card(); + * + * emblem.addIntrinsicKeyword("Indestructible"); + * emblem.addIntrinsicKeyword("Shroud"); emblem.addIntrinsicKeyword( + * "Mountains you control have 'tap: This land deals " + + * "1 damage to target creature or player.'"); + * emblem.setImmutable(true); emblem.addType("Emblem"); + * emblem.addController(card.getController()); + * emblem.setOwner(card.getOwner()); + * + * // TODO Emblems live in the command zone + * AllZone.getGameAction().moveToPlay(emblem); + * + * // AllZone.getGameAction().checkStateEffects(); + * AllZone.getStaticEffects().rePopulateStateBasedList(); for (final + * String effect : + * AllZone.getStaticEffects().getStateBasedMap().keySet()) { final + * Command com = GameActionUtil.commands.get(effect); com.execute(); } } + * + * @Override public boolean canPlay() { return (5 <= + * card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } // canPlay() + * + * @Override public boolean canPlayAI() { CardList list = + * AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); list = + * list.filter(new CardListFilter() { + * + * @Override public boolean addCard(final Card c) { return c.isEmblem() + * && c.hasKeyword("Mountains you control have 'tap: This land " + + * "deals 1 damage to target creature or player.'"); } }); return + * (list.size() == 0) && (card.getCounters(Counters.LOYALTY) > 5); } }; + * ability3.setBeforePayMana(new Input() { private static final long + * serialVersionUID = -2054686425541429389L; + * + * private int check = -1; + * + * @Override public void showMessage() { if (this.check != + * AllZone.getPhase().getTurn()) { this.check = + * AllZone.getPhase().getTurn(); turn[0] = AllZone.getPhase().getTurn(); + * AllZone.getStack().add(ability3); } this.stop(); } // showMessage() + * }); + * + * // ability 1: make 4/4 out of mountain final SpellAbility ability1 = + * new Ability(card, "0") { + * + * @Override public void resolve() { + * card.addCounterFromNonEffect(Counters.LOYALTY, 1); turn[0] = + * AllZone.getPhase().getTurn(); + * + * final Card[] card = new Card[1]; card[0] = this.getTargetCard(); + * + * final int[] oldAttack = new int[1]; final int[] oldDefense = new + * int[1]; + * + * oldAttack[0] = card[0].getBaseAttack(); oldDefense[0] = + * card[0].getBaseDefense(); + * + * if (card[0].isType("Mountain")) { card[0].untap(); + * + * card[0].setBaseAttack(4); card[0].setBaseDefense(4); + * card[0].addType("Creature"); card[0].addType("Elemental"); + * + * // EOT final Command untilEOT = new Command() { + * + * private static final long serialVersionUID = 6426615528873039915L; + * + * @Override public void execute() { + * card[0].setBaseAttack(oldAttack[0]); + * card[0].setBaseDefense(oldDefense[0]); + * + * card[0].removeType("Creature"); card[0].removeType("Elemental"); } }; + * AllZone.getEndOfTurn().addUntil(untilEOT); } } + * + * @Override public boolean canPlayAI() { CardList list = + * AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); list = + * list.filter(new CardListFilter() { + * + * @Override public boolean addCard(final Card crd) { return + * crd.isEmblem() && crd.hasKeyword("Mountains you control have 'tap: " + * + "This land deals 1 damage to target creature or player.'"); } }); + * + * CardList mountains = + * AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); mountains = + * mountains.filter(new CardListFilter() { + * + * @Override public boolean addCard(final Card crd) { return + * crd.isType("Mountain") && CardFactoryUtil.canTarget(card, crd); } }); + * CardListUtil.sortByTapped(mountains); + * + * if (mountains.size() == 0) { return false; } + * + * if (ability3.canPlay() && ability3.canPlayAI() && (list.size() == 0)) + * { return false; } else { this.setTargetCard(mountains.get(0)); return + * true; } } + * + * @Override public boolean canPlay() { return (0 < + * card.getCounters(Counters.LOYALTY)) && + * AllZone.getZoneOf(card).is(Constant.Zone.Battlefield) && (turn[0] != + * AllZone.getPhase().getTurn()) && + * Phase.canCastSorcery(card.getController()); } // canPlay() }; // + * SpellAbility ability1 + * + * final Input runtime = new Input() { private static final long + * serialVersionUID = -7823269301012427007L; + * + * @Override public void showMessage() { final CardList lands = + * card.getController + * ().getCardsIn(Zone.Battlefield).getType("Mountain"); + * + * this.stopSetNext(CardFactoryUtil.input_targetSpecific(ability1, + * lands, "Select target Mountain", true, false)); } // showMessage() }; + * // Input + * + * ability1.setBeforePayMana(runtime); + * + * ability1.setDescription( + * "+1: Untap target Mountain. It becomes a 4/4 red " + + * "Elemental creature until end of turn. It's still a land."); // + * ability1.setStackDescription(""); card.addSpellAbility(ability1); + * + * ability2.setDescription( + * "-2: Add R to your mana pool for each Mountain you control."); + * ability2.setStackDescription( + * "Koth of the Hammer - Add R to your mana pool for each Mountain you control." + * ); card.addSpellAbility(ability2); + * + * ability3.setDescription( + * "-5: You get an emblem with \"Mountains you control " + + * "have 'tap: This land deals 1 damage to target creature or player.'\"" + * ); ability3.setStackDescription( + * "Koth of the Hammer - You get an emblem with \"Mountains " + + * "you control have 'tap: This land deals 1 damage to target creature or player.'\"" + * ); card.addSpellAbility(ability3); + * + * card.setSVars(card.getSVars()); card.setSets(card.getSets()); + * + * return card; } // *************** END ************ END + * ************************** + */ return card; } diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java b/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java index 700f3a987c4..3a5b94a346e 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java @@ -76,12 +76,12 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Card crd0 = target[0]; - Card crd1 = target[1]; + final Card crd0 = target[0]; + final Card crd1 = target[1]; - if (crd0 != null && crd1 != null) { - Player p0 = crd0.getController(); - Player p1 = crd1.getController(); + if ((crd0 != null) && (crd1 != null)) { + final Player p0 = crd0.getController(); + final Player p1 = crd1.getController(); crd0.addController(p1); crd1.addController(p0); // AllZone.getGameAction().changeController(new @@ -110,47 +110,47 @@ public class CardFactory_Sorceries { @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override public void selectCard(final Card c, final PlayerZone zone) { // must target creature you control - if (index[0] == 0 && !c.getController().equals(card.getController())) { + if ((index[0] == 0) && !c.getController().equals(card.getController())) { return; } // must target creature you don't control - if (index[0] == 1 && c.getController().equals(card.getController())) { + if ((index[0] == 1) && c.getController().equals(card.getController())) { return; } if (c.isLand() && zone.is(Constant.Zone.Battlefield) && CardFactoryUtil.canTarget(card, c)) { target[index[0]] = c; index[0]++; - showMessage(); + this.showMessage(); if (index[0] == target.length) { if (this.isFree()) { this.setFree(false); AllZone.getStack().add(spell); - stop(); + this.stop(); } else { - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } } } } // selectCard() }; // Input - Input runtime = new Input() { + final Input runtime = new Input() { private static final long serialVersionUID = 4003351872990899418L; @Override public void showMessage() { index[0] = 0; - stopSetNext(input); + this.stopSetNext(input); } }; // Input @@ -161,28 +161,28 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Do or Die")) { // TODO Please please please, someone fix this card - Cost cost = new Cost("1 B", cardName, false); - Target tgt = new Target(card, "Select a Player", "Player"); + final Cost cost = new Cost("1 B", cardName, false); + final Target tgt = new Target(card, "Select a Player", "Player"); final SpellAbility spell = new Spell(card, cost, tgt) { private static final long serialVersionUID = 8241241003478388362L; @Override public boolean canPlayAI() { - return 4 <= CardFactoryUtil.AI_getHumanCreature(card, true).size(); + return 4 <= CardFactoryUtil.getHumanCreatureAI(card, true).size(); } @Override public void resolve() { - CardList list = AllZoneUtil.getCreaturesInPlay(getTargetPlayer()); + final CardList list = AllZoneUtil.getCreaturesInPlay(this.getTargetPlayer()); list.shuffle(); - for (int i = 0; i < list.size() / 2; i++) { + for (int i = 0; i < (list.size() / 2); i++) { AllZone.getGameAction().destroyNoRegeneration(list.get(i)); } } }; // SpellAbility - spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + spell.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); card.setSVar("PlayMain1", "TRUE"); card.addSpellAbility(spell); @@ -202,9 +202,10 @@ public class CardFactory_Sorceries { final Command untilEOT = new Command() { private static final long serialVersionUID = -5809548350739536763L; + @Override public void execute() { // int i = 0; - for (Card target : targets) { + for (final Card target : targets) { // if card isn't in play, do nothing if (!AllZoneUtil.isCardInPlay(target)) { continue; @@ -227,10 +228,10 @@ public class CardFactory_Sorceries { @Override public void resolve() { - CardList creatures = AllZoneUtil.getCreaturesInPlay(); + final CardList creatures = AllZoneUtil.getCreaturesInPlay(); newZone[0] = card.getController().getZone(Constant.Zone.Battlefield); - int i = 0; - for (Card target : creatures) { + final int i = 0; + for (final Card target : creatures) { if (AllZoneUtil.isCardInPlay(target)) { orig.add(i, AllZone.getZoneOf(target)); controllerEOT.add(i, target.getController()); @@ -250,8 +251,8 @@ public class CardFactory_Sorceries { @Override public boolean canPlayAI() { - CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - return creatures.size() > 0 && AllZone.getPhase().getPhase().equals(Constant.Phase.MAIN1); + final CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + return (creatures.size() > 0) && AllZone.getPhase().getPhase().equals(Constant.Phase.MAIN1); } // canPlayAI() }; // SpellAbility @@ -266,10 +267,10 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Player player = card.getController(); - PlayerZone play = player.getZone(Constant.Zone.Battlefield); - PlayerZone rfg = player.getZone(Constant.Zone.Exile); - Card[] attached = card.getAttachedCardsByMindsDesire(); + final Player player = card.getController(); + final PlayerZone play = player.getZone(Constant.Zone.Battlefield); + final PlayerZone rfg = player.getZone(Constant.Zone.Exile); + final Card[] attached = card.getAttachedCardsByMindsDesire(); rfg.remove(attached[0]); play.add(attached[0]); card.unattachCardByMindDesire(attached[0]); @@ -282,20 +283,20 @@ public class CardFactory_Sorceries { public void resolve() { Card target = null; Card c = null; - Player player = card.getController(); + final Player player = card.getController(); if (player.isHuman()) { - Card[] attached = getSourceCard().getAttachedCardsByMindsDesire(); - Card[] choices = new Card[attached.length]; + final Card[] attached = this.getSourceCard().getAttachedCardsByMindsDesire(); + final Card[] choices = new Card[attached.length]; boolean systemsGo = true; if (AllZone.getStack().size() > 0) { - CardList config = new CardList(); - for (int i = 0; i < attached.length; i++) { - if (attached[i].isInstant() || attached[i].hasKeyword("Flash")) { - config.add(attached[i]); + final CardList config = new CardList(); + for (final Card element : attached) { + if (element.isInstant() || element.hasKeyword("Flash")) { + config.add(element); } } for (int i = 0; i < config.size(); i++) { - Card crd = config.get(i); + final Card crd = config.get(i); choices[i] = crd; } if (config.size() == 0) { @@ -334,27 +335,27 @@ public class CardFactory_Sorceries { // flash // spell. - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(c.getName()).append(" - Copied from Mind's Desire"); playCreature.setStackDescription(sb.toString()); - Card[] reAttach = new Card[attached.length]; + final Card[] reAttach = new Card[attached.length]; reAttach[0] = c; int reAttachCount = 0; - for (int i = 0; i < attached.length; i++) { - if (attached[i] != target) { + for (final Card element : attached) { + if (element != target) { reAttachCount = reAttachCount + 1; - reAttach[reAttachCount] = attached[i]; + reAttach[reAttachCount] = element; } } // Clear Attached List - for (int i = 0; i < attached.length; i++) { - card.unattachCardByMindDesire(attached[i]); + for (final Card element : attached) { + card.unattachCardByMindDesire(element); } // Re-add - for (int i = 0; i < reAttach.length; i++) { - if (reAttach[i] != null) { - card.attachCardByMindsDesire(reAttach[i]); + for (final Card element : reAttach) { + if (element != null) { + card.attachCardByMindsDesire(element); } } target.addSpellAbility(playCreature); @@ -369,16 +370,13 @@ public class CardFactory_Sorceries { JOptionPane.INFORMATION_MESSAGE); } } else { - JOptionPane - .showMessageDialog( - null, - "You can only play an instant at this point in time, " - + "but none are attached to Mind's Desire.", - "", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(null, "You can only play an instant at this point in time, " + + "but none are attached to Mind's Desire.", "", JOptionPane.INFORMATION_MESSAGE); } } } + @Override public boolean canPlayAI() { return false; } @@ -386,12 +384,13 @@ public class CardFactory_Sorceries { }; freeCast.setStackDescription("Mind's Desire - play card without paying its mana cost."); - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = 920148510259054021L; + @Override public void execute() { - Player player = AllZone.getPhase().getPlayerTurn(); - PlayerZone play = player.getZone(Constant.Zone.Battlefield); + final Player player = AllZone.getPhase().getPlayerTurn(); + final PlayerZone play = player.getZone(Constant.Zone.Battlefield); Card mindsD = card; if (player.isHuman()) { card.getController().shuffle(); @@ -407,23 +406,24 @@ public class CardFactory_Sorceries { "Click Mind's Desire to see the available cards to play without paying its mana cost.", "", JOptionPane.INFORMATION_MESSAGE); } - CardList libList = player.getCardsIn(Zone.Library); + final CardList libList = player.getCardsIn(Zone.Library); Card c = null; if (libList.size() > 0) { c = libList.get(0); - PlayerZone rfg = player.getZone(Constant.Zone.Exile); + final PlayerZone rfg = player.getZone(Constant.Zone.Exile); AllZone.getGameAction().moveTo(rfg, c); mindsD.attachCardByMindsDesire(c); } final Card minds = card; // AllZone.getGameAction().exile(Minds); minds.setImmutable(true); - Command untilEOT = new Command() { + final Command untilEOT = new Command() { private static final long serialVersionUID = -28032591440730370L; + @Override public void execute() { - Player player = AllZone.getPhase().getPlayerTurn(); - PlayerZone play = player.getZone(Constant.Zone.Battlefield); + final Player player = AllZone.getPhase().getPlayerTurn(); + final PlayerZone play = player.getZone(Constant.Zone.Battlefield); play.remove(minds); } }; @@ -431,7 +431,7 @@ public class CardFactory_Sorceries { } }; - SpellAbility spell = new Spell_Permanent(card) { + final SpellAbility spell = new Spell_Permanent(card) { private static final long serialVersionUID = -2940969025405788931L; @Override @@ -459,9 +459,9 @@ public class CardFactory_Sorceries { Card choice = null; // check for no cards in hand on resolve - CardList lib = card.getController().getCardsIn(Zone.Library); - CardList cards = new CardList(); - CardList exiled = new CardList(); + final CardList lib = card.getController().getCardsIn(Zone.Library); + final CardList cards = new CardList(); + final CardList exiled = new CardList(); if (lib.size() == 0) { JOptionPane.showMessageDialog(null, "No more cards in library.", "", JOptionPane.INFORMATION_MESSAGE); @@ -478,8 +478,8 @@ public class CardFactory_Sorceries { exiled.add(lib.get(i)); AllZone.getGameAction().exile(lib.get(i)); } - CardList pile1 = new CardList(); - CardList pile2 = new CardList(); + final CardList pile1 = new CardList(); + final CardList pile2 = new CardList(); boolean stop = false; int pile1CMC = 0; int pile2CMC = 0; @@ -506,7 +506,7 @@ public class CardFactory_Sorceries { pile2CMC = pile2CMC + CardUtil.getConvertedManaCost(exiled.get(i)); } } - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("You have spilt the cards into the following piles" + "\r\n" + "\r\n"); sb.append("Pile 1: " + "\r\n"); for (int i = 0; i < pile1.size(); i++) { @@ -521,9 +521,9 @@ public class CardFactory_Sorceries { JOptionPane.showMessageDialog(null, "Computer chooses the Pile 1", "", JOptionPane.INFORMATION_MESSAGE); for (int i = 0; i < pile1.size(); i++) { - ArrayList choices = pile1.get(i).getBasicSpells(); + final ArrayList choices = pile1.get(i).getBasicSpells(); - for (SpellAbility sa : choices) { + for (final SpellAbility sa : choices) { if (sa.canPlayAI()) { ComputerUtil.playStackFree(sa); if (pile1.get(i).isPermanent()) { @@ -537,9 +537,9 @@ public class CardFactory_Sorceries { JOptionPane.showMessageDialog(null, "Computer chooses the Pile 2", "", JOptionPane.INFORMATION_MESSAGE); for (int i = 0; i < pile2.size(); i++) { - ArrayList choices = pile2.get(i).getBasicSpells(); + final ArrayList choices = pile2.get(i).getBasicSpells(); - for (SpellAbility sa : choices) { + for (final SpellAbility sa : choices) { if (sa.canPlayAI()) { ComputerUtil.playStackFree(sa); if (pile2.get(i).isPermanent()) { @@ -552,10 +552,10 @@ public class CardFactory_Sorceries { } } else { // Computer chooses (It picks the highest converted - // mana cost card and 1 random card.) + // mana cost card and 1 random card.) Card biggest = exiled.get(0); - for (Card c : exiled) { + for (final Card c : exiled) { if (CardUtil.getConvertedManaCost(biggest.getManaCost()) < CardUtil.getConvertedManaCost(c .getManaCost())) { biggest = c; @@ -565,7 +565,7 @@ public class CardFactory_Sorceries { pile1.add(biggest); cards.remove(biggest); if (cards.size() > 2) { - Card random = CardUtil.getRandom(cards.toArray()); + final Card random = CardUtil.getRandom(cards.toArray()); pile1.add(random); } for (int i = 0; i < count; i++) { @@ -573,7 +573,7 @@ public class CardFactory_Sorceries { pile2.add(exiled.get(i)); } } - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Choose a pile to add to your hand: " + "\r\n" + "\r\n"); sb.append("Pile 1: " + "\r\n"); for (int i = 0; i < pile1.size(); i++) { @@ -583,8 +583,8 @@ public class CardFactory_Sorceries { for (int i = 0; i < pile2.size(); i++) { sb.append(pile2.get(i).getName() + "\r\n"); } - Object[] possibleValues = {"Pile 1", "Pile 2"}; - Object q = JOptionPane.showOptionDialog(null, sb, "Brilliant Ultimatum", + final Object[] possibleValues = { "Pile 1", "Pile 2" }; + final Object q = JOptionPane.showOptionDialog(null, sb, "Brilliant Ultimatum", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]); @@ -595,15 +595,15 @@ public class CardFactory_Sorceries { chosen = pile2; } - int numChosen = chosen.size(); + final int numChosen = chosen.size(); for (int i = 0; i < numChosen; i++) { - Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", + final Object check = GuiUtils.getChoiceOptional("Select spells to play in reverse order: ", chosen.toArray()); if (check == null) { break; } - Card playing = (Card) check; + final Card playing = (Card) check; if (playing.isLand()) { if (card.getController().canPlayLand()) { card.getController().playLand(playing); @@ -624,7 +624,7 @@ public class CardFactory_Sorceries { @Override public boolean canPlayAI() { - CardList cards = AllZone.getComputerPlayer().getCardsIn(Zone.Library); + final CardList cards = AllZone.getComputerPlayer().getCardsIn(Zone.Library); return cards.size() >= 8; } }; // SpellAbility @@ -633,14 +633,14 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Cranial Extraction")) { - Cost cost = new Cost("3 B", cardName, false); - Target tgt = new Target(card, "Select a Player", "Player"); + final Cost cost = new Cost("3 B", cardName, false); + final Target tgt = new Target(card, "Select a Player", "Player"); final SpellAbility spell = new Spell(card, cost, tgt) { private static final long serialVersionUID = 8127696608769903507L; @Override public void resolve() { - Player target = getTargetPlayer(); + final Player target = this.getTargetPlayer(); String choice = null; // human chooses @@ -648,20 +648,21 @@ public class CardFactory_Sorceries { choice = JOptionPane.showInputDialog(null, "Name a nonland card", cardName, JOptionPane.QUESTION_MESSAGE); - CardList showLibrary = target.getCardsIn(Zone.Library); + final CardList showLibrary = target.getCardsIn(Zone.Library); GuiUtils.getChoiceOptional("Target Player's Library", showLibrary.toArray()); - CardList showHand = target.getCardsIn(Zone.Hand); + final CardList showHand = target.getCardsIn(Zone.Hand); GuiUtils.getChoiceOptional("Target Player's Hand", showHand.toArray()); } // if else { - // computer chooses + // computer chooses // the computer cheats by choosing a creature in the // human players library or hand - CardList all = target.getCardsIn(Zone.Hand); + final CardList all = target.getCardsIn(Zone.Hand); all.addAll(target.getCardsIn(Zone.Library)); - CardList four = all.filter(new CardListFilter() { + final CardList four = all.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.isLand()) { return false; @@ -677,12 +678,12 @@ public class CardFactory_Sorceries { } } // else - remove(choice, target); + this.remove(choice, target); target.shuffle(); } // resolve() void remove(final String name, final Player player) { - CardList all = player.getCardsIn(Zone.Hand); + final CardList all = player.getCardsIn(Zone.Hand); all.addAll(player.getCardsIn(Zone.Graveyard)); all.addAll(player.getCardsIn(Zone.Library)); @@ -702,7 +703,7 @@ public class CardFactory_Sorceries { return c.size() > 0; } }; // SpellAbility spell - spell.setChooseTargetAI(CardFactoryUtil.AI_targetHuman()); + spell.setChooseTargetAI(CardFactoryUtil.targetHumanAI()); card.addSpellAbility(spell); } // *************** END ************ END ************************** @@ -714,18 +715,18 @@ public class CardFactory_Sorceries { @Override public boolean canPlayAI() { - CardList c = getCreature(); + final CardList c = this.getCreature(); if (c.isEmpty()) { return false; } else { - setTargetCard(c.get(0)); + this.setTargetCard(c.get(0)); return true; } } // canPlayAI() CardList getCreature() { - CardList out = new CardList(); - CardList list = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); + final CardList out = new CardList(); + final CardList list = CardFactoryUtil.getHumanCreatureAI("Flying", card, true); list.shuffle(); for (int i = 0; i < list.size(); i++) { @@ -736,9 +737,9 @@ public class CardFactory_Sorceries { // in case human player only has a few creatures in play, // target anything - if (out.isEmpty() && 0 < CardFactoryUtil.AI_getHumanCreature(2, card, true).size() - && 3 > CardFactoryUtil.AI_getHumanCreature(card, true).size()) { - out.addAll(CardFactoryUtil.AI_getHumanCreature(2, card, true)); + if (out.isEmpty() && (0 < CardFactoryUtil.getHumanCreatureAI(2, card, true).size()) + && (3 > CardFactoryUtil.getHumanCreatureAI(card, true).size())) { + out.addAll(CardFactoryUtil.getHumanCreatureAI(2, card, true)); CardListUtil.sortFlying(out); } return out; @@ -746,18 +747,19 @@ public class CardFactory_Sorceries { @Override public void resolve() { - if (AllZoneUtil.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard())) { + if (AllZoneUtil.isCardInPlay(this.getTargetCard()) + && CardFactoryUtil.canTarget(card, this.getTargetCard())) { - AllZone.getGameAction().destroy(getTargetCard()); + AllZone.getGameAction().destroy(this.getTargetCard()); - if (!getTargetCard().isFaceDown()) { + if (!this.getTargetCard().isFaceDown()) { // get all creatures CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); - list = list.getName(getTargetCard().getName()); - list.remove(getTargetCard()); + list = list.getName(this.getTargetCard().getName()); + list.remove(this.getTargetCard()); - if (!getTargetCard().isFaceDown()) { + if (!this.getTargetCard().isFaceDown()) { for (int i = 0; i < list.size(); i++) { AllZone.getGameAction().destroy(list.get(i)); } @@ -769,7 +771,7 @@ public class CardFactory_Sorceries { card.addSpellAbility(spell); - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = -4947592326270275532L; @Override @@ -780,7 +782,7 @@ public class CardFactory_Sorceries { @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override @@ -790,9 +792,9 @@ public class CardFactory_Sorceries { if (this.isFree()) { this.setFree(false); AllZone.getStack().add(spell); - stop(); + this.stop(); } else { - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } } } @@ -803,45 +805,45 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Erratic Explosion")) { - Cost cost = new Cost(card.getManaCost(), cardName, false); - Target tgt = new Target(card, "CP"); + final Cost cost = new Cost(card.getManaCost(), cardName, false); + final Target tgt = new Target(card, "CP"); final SpellAbility spell = new Spell(card, cost, tgt) { private static final long serialVersionUID = -6003403347798646257L; - private int damage = 3; + private final int damage = 3; private Card check; @Override public boolean canPlayAI() { - if (AllZone.getHumanPlayer().getLife() <= damage) { + if (AllZone.getHumanPlayer().getLife() <= this.damage) { return true; } - check = getFlying(); - return check != null; + this.check = this.getFlying(); + return this.check != null; } @Override public void chooseTargetAI() { - if (AllZone.getHumanPlayer().getLife() <= damage) { - setTargetPlayer(AllZone.getHumanPlayer()); + if (AllZone.getHumanPlayer().getLife() <= this.damage) { + this.setTargetPlayer(AllZone.getHumanPlayer()); return; } - Card c = getFlying(); - if ((c == null) || (!check.equals(c))) { + final Card c = this.getFlying(); + if ((c == null) || (!this.check.equals(c))) { throw new RuntimeException(card + " error in chooseTargetAI() - Card c is " + c - + ", Card check is " + check); + + ", Card check is " + this.check); } - setTargetCard(c); + this.setTargetCard(c); } // chooseTargetAI() // uses "damage" variable Card getFlying() { - CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); + final CardList flying = CardFactoryUtil.getHumanCreatureAI("Flying", card, true); for (int i = 0; i < flying.size(); i++) { - if (flying.get(i).getNetDefense() <= damage) { + if (flying.get(i).getNetDefense() <= this.damage) { return flying.get(i); } } @@ -851,22 +853,21 @@ public class CardFactory_Sorceries { @Override public void resolve() { - int damage = getDamage(); + final int damage = this.getDamage(); - if (getTargetCard() != null) { - if (AllZoneUtil.isCardInPlay(getTargetCard()) - && CardFactoryUtil.canTarget(card, getTargetCard())) - { + if (this.getTargetCard() != null) { + if (AllZoneUtil.isCardInPlay(this.getTargetCard()) + && CardFactoryUtil.canTarget(card, this.getTargetCard())) { javax.swing.JOptionPane.showMessageDialog(null, "Erratic Explosion causes " + damage - + " to " + getTargetCard()); + + " to " + this.getTargetCard()); - Card c = getTargetCard(); + final Card c = this.getTargetCard(); c.addDamage(damage, card); } } else { javax.swing.JOptionPane.showMessageDialog(null, "Erratic Explosion causes " + damage + " to " - + getTargetPlayer()); - getTargetPlayer().addDamage(damage, card); + + this.getTargetPlayer()); + this.getTargetPlayer().addDamage(damage, card); } } @@ -880,7 +881,7 @@ public class CardFactory_Sorceries { return 0; } - Card card = notLand.get(0); + final Card card = notLand.get(0); return CardUtil.getConvertedManaCost(card.getSpellAbility()[0]); } }; // SpellAbility @@ -892,22 +893,22 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Martial Coup")) { - Cost cost = new Cost(card.getManaCost(), cardName, false); - SpellAbility spell = new Spell(card, cost, null) { + final Cost cost = new Cost(card.getManaCost(), cardName, false); + final SpellAbility spell = new Spell(card, cost, null) { private static final long serialVersionUID = -29101524966207L; @Override public void resolve() { - CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield); - int soldiers = card.getXManaCostPaid(); + final CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield); + final int soldiers = card.getXManaCostPaid(); for (int i = 0; i < soldiers; i++) { CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card.getController(), "W", new String[] { "Creature", "Soldier" }, 1, 1, new String[] { "" }); } if (soldiers >= 5) { for (int i = 0; i < all.size(); i++) { - Card c = all.get(i); + final Card c = all.get(i); if (c.isCreature()) { AllZone.getGameAction().destroy(c); } @@ -917,12 +918,12 @@ public class CardFactory_Sorceries { @Override public boolean canPlayAI() { - CardList human = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - CardList computer = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final CardList human = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final CardList computer = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); // the computer will at least destroy 2 more human creatures - return (computer.size() < human.size() - 1 || (AllZone.getComputerPlayer().getLife() < 7 && !human - .isEmpty())) && ComputerUtil.getAvailableMana().size() >= 7; + return ((computer.size() < (human.size() - 1)) || ((AllZone.getComputerPlayer().getLife() < 7) && !human + .isEmpty())) && (ComputerUtil.getAvailableMana().size() >= 7); } }; // SpellAbility @@ -931,7 +932,7 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Parallel Evolution")) { - SpellAbility spell = new Spell(card) { + final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = 3456160935845779623L; @Override @@ -956,9 +957,9 @@ public class CardFactory_Sorceries { }; // SpellAbility spell.setDescription("For each creature token on the battlefield, " - + "its controller puts a token that's a copy of that creature onto the battlefield."); + + "its controller puts a token that's a copy of that creature onto the battlefield."); spell.setStackDescription("Parallel Evolution - For each creature " - + "token on the battlefield, its controller puts a token that's a copy of " + + "token on the battlefield, its controller puts a token that's a copy of " + "that creature onto the battlefield."); card.setFlashback(true); @@ -995,10 +996,10 @@ public class CardFactory_Sorceries { // figure out which basic land types the computer has CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); - String[] basic = {"Forest", "Plains", "Mountain", "Island", "Swamp"}; + final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; - for (int i = 0; i < basic.length; i++) { - CardList cl = land.getType(basic[i]); + for (final String element : basic) { + final CardList cl = land.getType(element); if (!cl.isEmpty()) { // remove one land of this basic type from this list // the computer AI should really jump in here and @@ -1015,12 +1016,12 @@ public class CardFactory_Sorceries { // need to sacrifice the other non-basic land types land = land.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.getName().contains("Dryad Arbor")) { return true; } else if (!(c.isType("Forest") || c.isType("Plains") || c.isType("Mountain") - || c.isType("Island") || c.isType("Swamp"))) - { + || c.isType("Island") || c.isType("Swamp"))) { return true; } else { return false; @@ -1049,40 +1050,40 @@ public class CardFactory_Sorceries { // countBase[0] is the total number of basic land types the // human has // index[0] is the number to offset the index by - count = countBase[0] - index[0] - 1; // subtract by one - // since humanBasic is - // 0 indexed. - if (count < 0) { + this.count = countBase[0] - index[0] - 1; // subtract by one + // since humanBasic is + // 0 indexed. + if (this.count < 0) { // need to reset the variables in case they cancel this // spell and it stays in hand. humanBasic.clear(); countBase[0] = 0; index[0] = 0; - stop(); + this.stop(); } else { AllZone.getDisplay().showMessage( - "Select target " + humanBasic.get(count) + " land to not sacrifice"); + "Select target " + humanBasic.get(this.count) + " land to not sacrifice"); ButtonUtil.enableOnlyCancel(); } } @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override public void selectCard(final Card c, final PlayerZone zone) { if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() /* && c.getName().equals(humanBasic.get(count)) */ - && c.isType(humanBasic.get(count)) - /* && !saveList.contains(c) */) - { + && c.isType(humanBasic.get(this.count)) + /* && !saveList.contains(c) */) { // get all other basic[count] lands human player // controls and add them to target CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); - CardList cl = land.getType(humanBasic.get(count)); + CardList cl = land.getType(humanBasic.get(this.count)); cl = cl.filter(new CardListFilter() { + @Override public boolean addCard(final Card crd) { return !saveList.contains(crd); } @@ -1095,20 +1096,20 @@ public class CardFactory_Sorceries { target.addAll(cl); index[0]++; - showMessage(); + this.showMessage(); if (index[0] >= humanBasic.size()) { - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } // need to sacrifice the other non-basic land types land = land.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.getName().contains("Dryad Arbor")) { return true; } else if (!(c.isType("Forest") || c.isType("Plains") || c.isType("Mountain") - || c.isType("Island") || c.isType("Swamp"))) - { + || c.isType("Island") || c.isType("Swamp"))) { return true; } else { return false; @@ -1121,7 +1122,7 @@ public class CardFactory_Sorceries { } // selectCard() }; // Input - Input runtime = new Input() { + final Input runtime = new Input() { private static final long serialVersionUID = -122635387376995855L; @Override @@ -1129,24 +1130,24 @@ public class CardFactory_Sorceries { countBase[0] = 0; // figure out which basic land types the human has // put those in an set to use later - CardList land = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); - String[] basic = {"Forest", "Plains", "Mountain", "Island", "Swamp"}; + final CardList land = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; - for (int i = 0; i < basic.length; i++) { - CardList c = land.getType(basic[i]); + for (final String element : basic) { + final CardList c = land.getType(element); if (!c.isEmpty()) { - humanBasic.add(basic[i]); + humanBasic.add(element); countBase[0]++; } } if (countBase[0] == 0) { // human has no basic land, so don't prompt to select // one. - stop(); + this.stop(); } else { index[0] = 0; target.clear(); - stopSetNext(input); + this.stopSetNext(input); } } }; // Input @@ -1156,13 +1157,13 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Gerrard's Verdict")) { - SpellAbility spell = new Spell(card) { + final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = 4734024742326763385L; @Override public boolean canPlayAI() { - PlayerZone humanHand = AllZone.getHumanPlayer().getZone(Constant.Zone.Hand); + final PlayerZone humanHand = AllZone.getHumanPlayer().getZone(Constant.Zone.Hand); if (humanHand.size() >= 2) { return true; } else { @@ -1172,23 +1173,23 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Player player = card.getController(); + final Player player = card.getController(); if (player.isHuman()) { - humanResolve(); + this.humanResolve(); } else { - computerResolve(); + this.computerResolve(); } } public void humanResolve() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); list.shuffle(); if (list.size() == 0) { return; } - Card c1 = list.get(0); + final Card c1 = list.get(0); list.remove(c1); c1.getController().discard(c1, null); @@ -1196,7 +1197,7 @@ public class CardFactory_Sorceries { return; } - Card c2 = list.get(0); + final Card c2 = list.get(0); list.remove(c2); c2.getController().discard(c2, null); @@ -1212,13 +1213,13 @@ public class CardFactory_Sorceries { } // resolve() public void computerResolve() { - CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); + final CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); if (list.size() > 0) { - Object o = GuiUtils.getChoiceOptional("First card to discard", list.toArray()); + final Object o = GuiUtils.getChoiceOptional("First card to discard", list.toArray()); - Card c = (Card) o; + final Card c = (Card) o; list.remove(c); c.getController().discard(c, null); @@ -1228,9 +1229,9 @@ public class CardFactory_Sorceries { } if (list.size() > 0) { - Object o2 = GuiUtils.getChoiceOptional("Second card to discard", list.toArray()); + final Object o2 = GuiUtils.getChoiceOptional("Second card to discard", list.toArray()); - Card c2 = (Card) o2; + final Card c2 = (Card) o2; list.remove(c2); c2.getController().discard(c2, null); @@ -1247,32 +1248,32 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Mind Funeral")) { - Cost cost = new Cost("1 U B", cardName, false); - Target tgt = new Target(card, "Select a Player", "Player"); + final Cost cost = new Cost("1 U B", cardName, false); + final Target tgt = new Target(card, "Select a Player", "Player"); final SpellAbility spell = new Spell(card, cost, tgt) { private static final long serialVersionUID = 42470566751344693L; @Override public boolean canPlayAI() { - setTargetPlayer(AllZone.getHumanPlayer()); - CardList libList = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + this.setTargetPlayer(AllZone.getHumanPlayer()); + final CardList libList = AllZone.getHumanPlayer().getCardsIn(Zone.Library); return libList.size() > 0; } @Override public void resolve() { - Player player = getTargetPlayer(); + final Player player = this.getTargetPlayer(); - CardList libList = player.getCardsIn(Zone.Library); + final CardList libList = player.getCardsIn(Zone.Library); - int numLands = libList.getType("Land").size(); + final int numLands = libList.getType("Land").size(); int total = 0; if (numLands > 3) { // if only 3 or less lands in the deck // everything is going int landCount = 0; - for (Card c : libList) { + for (final Card c : libList) { total++; if (c.isLand()) { landCount++; @@ -1292,8 +1293,8 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Haunting Echoes")) { - Cost cost = new Cost("3 B B", cardName, false); - Target tgt = new Target(card, "Select a Player", "Player"); + final Cost cost = new Cost("3 B B", cardName, false); + final Target tgt = new Target(card, "Select a Player", "Player"); final SpellAbility spell = new Spell(card, cost, tgt) { private static final long serialVersionUID = 42470566751344693L; @@ -1302,31 +1303,32 @@ public class CardFactory_Sorceries { // Haunting Echoes shouldn't be cast if only basic land in // graveyard or library is empty CardList graveyard = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); - CardList library = AllZone.getHumanPlayer().getCardsIn(Zone.Library); - int graveCount = graveyard.size(); + final CardList library = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + final int graveCount = graveyard.size(); graveyard = graveyard.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isBasicLand(); } }); - setTargetPlayer(AllZone.getHumanPlayer()); + this.setTargetPlayer(AllZone.getHumanPlayer()); - return ((graveCount - graveyard.size() > 0) && library.size() > 0); + return (((graveCount - graveyard.size()) > 0) && (library.size() > 0)); } @Override public void resolve() { - Player player = getTargetPlayer(); + final Player player = this.getTargetPlayer(); CardList grave = player.getCardsIn(Zone.Graveyard); grave = grave.getNotType("Basic"); - CardList lib = player.getCardsIn(Zone.Library); + final CardList lib = player.getCardsIn(Zone.Library); - for (Card c : grave) { - CardList remLib = lib.getName(c.getName()); - for (Card rem : remLib) { + for (final Card c : grave) { + final CardList remLib = lib.getName(c.getName()); + for (final Card rem : remLib) { AllZone.getGameAction().exile(rem); lib.remove(rem); } @@ -1344,9 +1346,9 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Card c = getTargetCard(); + final Card c = this.getTargetCard(); - if (c != null && AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { + if ((c != null) && AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { // Donate should target both the player and the creature c.addController(card.getController().getOpponent()); /* @@ -1365,23 +1367,25 @@ public class CardFactory_Sorceries { @Override public boolean canPlayAI() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Illusions of Grandeur"); + final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, + "Illusions of Grandeur"); if (list.size() > 0) { - setTargetCard(list.get(0)); + this.setTargetCard(list.get(0)); return true; } return false; } }; - Input runtime = new Input() { + final Input runtime = new Input() { private static final long serialVersionUID = -7823269301012427007L; @Override public void showMessage() { CardList perms = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); perms = perms.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isPermanent() && !c.getName().equals("Mana Pool"); } @@ -1392,8 +1396,8 @@ public class CardFactory_Sorceries { free = true; } - stopSetNext(CardFactoryUtil.input_targetSpecific(spell, perms, "Select a permanent you control", - true, free)); + this.stopSetNext(CardFactoryUtil.inputTargetSpecific(spell, perms, + "Select a permanent you control", true, free)); } // showMessage() }; // Input @@ -1407,25 +1411,26 @@ public class CardFactory_Sorceries { final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = -5941893280103164961L; + @Override public void resolve() { // Lands: - CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); - CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); + final CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + final CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); if (compLand.size() > humLand.size()) { compLand.shuffle(); - for (int i = 0; i < compLand.size() - humLand.size(); i++) { + for (int i = 0; i < (compLand.size() - humLand.size()); i++) { AllZone.getGameAction().sacrifice(compLand.get(i)); } } else if (humLand.size() > compLand.size()) { - int diff = humLand.size() - compLand.size(); + final int diff = humLand.size() - compLand.size(); AllZone.getInputControl().setInput(PlayerUtil.input_sacrificePermanents(diff, "Land")); } // Hand - CardList humHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - CardList compHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); - int handDiff = Math.abs(humHand.size() - compHand.size()); + final CardList humHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); + final CardList compHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final int handDiff = Math.abs(humHand.size() - compHand.size()); if (compHand.size() > humHand.size()) { AllZone.getComputerPlayer().discard(handDiff, this, false); @@ -1434,35 +1439,36 @@ public class CardFactory_Sorceries { } // Creatures: - CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); if (compCreats.size() > humCreats.size()) { CardListUtil.sortAttackLowFirst(compCreats); CardListUtil.sortCMC(compCreats); compCreats.reverse(); - for (int i = 0; i < compCreats.size() - humCreats.size(); i++) { + for (int i = 0; i < (compCreats.size() - humCreats.size()); i++) { AllZone.getGameAction().sacrifice(compCreats.get(i)); } } else if (humCreats.size() > compCreats.size()) { - int diff = humCreats.size() - compCreats.size(); + final int diff = humCreats.size() - compCreats.size(); AllZone.getInputControl().setInput(PlayerUtil.input_sacrificePermanents(diff, "Creature")); } } + @Override public boolean canPlayAI() { int diff = 0; - CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); - CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); + final CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + final CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); diff += humLand.size() - compLand.size(); - CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); compCreats = compCreats.getType("Creature"); diff += 1.5 * (humCreats.size() - compCreats.size()); - CardList humHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - CardList compHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList humHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); + final CardList compHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); diff += 0.5 * (humHand.size() - compHand.size()); return diff > 2; @@ -1477,6 +1483,7 @@ public class CardFactory_Sorceries { final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = 5559004016728325736L; + @Override public boolean canPlayAI() { // The computer should only play this card if it has at // least @@ -1490,13 +1497,15 @@ public class CardFactory_Sorceries { return hand.size() > 0; } + @Override public void resolve() { final Player thePlayer = card.getController(); thePlayer.addMaxLandsToPlay(3); - Command untilEOT = new Command() { + final Command untilEOT = new Command() { private static final long serialVersionUID = 1665720009691293263L; + @Override public void execute() { thePlayer.addMaxLandsToPlay(-3); } @@ -1514,6 +1523,7 @@ public class CardFactory_Sorceries { final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = 8377957584738695517L; + @Override public boolean canPlayAI() { // The computer should only play this card if it has at // least @@ -1531,13 +1541,15 @@ public class CardFactory_Sorceries { } } + @Override public void resolve() { final Player thePlayer = card.getController(); thePlayer.addMaxLandsToPlay(1); - Command untilEOT = new Command() { + final Command untilEOT = new Command() { private static final long serialVersionUID = -2618916698575607634L; + @Override public void execute() { thePlayer.addMaxLandsToPlay(-1); } @@ -1557,6 +1569,7 @@ public class CardFactory_Sorceries { final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = -8303724057068847270L; + @Override public void resolve() { int times = 1; CardList cl; @@ -1565,14 +1578,14 @@ public class CardFactory_Sorceries { } for (int i = 0; i < times; i++) { cl = CardFactoryUtil.makeToken("Eldrazi Spawn", "C 0 1 Eldrazi Spawn", card.getController(), - "", new String[] {"Creature", "Eldrazi", "Spawn" }, 0, 1, new String[] {}); - for (Card crd : cl) { + "", new String[] { "Creature", "Eldrazi", "Spawn" }, 0, 1, new String[] {}); + for (final Card crd : cl) { crd.addSpellAbility(CardFactoryUtil.getEldraziSpawnAbility(crd)); } } } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName).append(" - ").append(card.getController()); sb.append(" puts one or three 0/1 Eldrazi Spawn creature tokens onto the battlefield."); spell.setStackDescription(sb.toString()); @@ -1589,45 +1602,45 @@ public class CardFactory_Sorceries { * to that creature or player. Put the nonland card into your hand * and the rest on the bottom of your library in any order. */ - Cost cost = new Cost(card.getManaCost(), cardName, false); - Target tgt = new Target(card, "CP"); + final Cost cost = new Cost(card.getManaCost(), cardName, false); + final Target tgt = new Target(card, "CP"); final SpellAbility spell = new Spell(card, cost, tgt) { private static final long serialVersionUID = -3234630801871872940L; - private int damage = 3; + private final int damage = 3; private Card check; @Override public boolean canPlayAI() { - if (AllZone.getHumanPlayer().getLife() <= damage) { + if (AllZone.getHumanPlayer().getLife() <= this.damage) { return true; } - check = getFlying(); - return check != null; + this.check = this.getFlying(); + return this.check != null; } @Override public void chooseTargetAI() { - if (AllZone.getHumanPlayer().getLife() <= damage) { - setTargetPlayer(AllZone.getHumanPlayer()); + if (AllZone.getHumanPlayer().getLife() <= this.damage) { + this.setTargetPlayer(AllZone.getHumanPlayer()); return; } - Card c = getFlying(); - if ((c == null) || (!check.equals(c))) { + final Card c = this.getFlying(); + if ((c == null) || (!this.check.equals(c))) { throw new RuntimeException(card + " error in chooseTargetAI() - Card c is " + c - + ", Card check is " + check); + + ", Card check is " + this.check); } - setTargetCard(c); + this.setTargetCard(c); } // chooseTargetAI() // uses "damage" variable Card getFlying() { - CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying", card, true); + final CardList flying = CardFactoryUtil.getHumanCreatureAI("Flying", card, true); for (int i = 0; i < flying.size(); i++) { - if (flying.get(i).getNetDefense() <= damage) { + if (flying.get(i).getNetDefense() <= this.damage) { return flying.get(i); } } @@ -1638,22 +1651,21 @@ public class CardFactory_Sorceries { @Override public void resolve() { - int damage = getDamage(); + final int damage = this.getDamage(); - if (getTargetCard() != null) { - if (AllZoneUtil.isCardInPlay(getTargetCard()) - && CardFactoryUtil.canTarget(card, getTargetCard())) - { + if (this.getTargetCard() != null) { + if (AllZoneUtil.isCardInPlay(this.getTargetCard()) + && CardFactoryUtil.canTarget(card, this.getTargetCard())) { javax.swing.JOptionPane.showMessageDialog(null, cardName + " causes " + damage + " to " - + getTargetCard()); + + this.getTargetCard()); - Card c = getTargetCard(); + final Card c = this.getTargetCard(); c.addDamage(damage, card); } } else { - javax.swing.JOptionPane.showMessageDialog(null, cardName + " causes " + damage + " to " - + getTargetPlayer()); - getTargetPlayer().addDamage(damage, card); + javax.swing.JOptionPane.showMessageDialog(null, + cardName + " causes " + damage + " to " + this.getTargetPlayer()); + this.getTargetPlayer().addDamage(damage, card); } // System.out.println("Library after: "+card.getController()).getCardsIn(Zone.Library); } @@ -1663,9 +1675,9 @@ public class CardFactory_Sorceries { * Reveal cards from the top of your library until you * reveal a nonland card. */ - CardList lib = card.getController().getCardsIn(Zone.Library); + final CardList lib = card.getController().getCardsIn(Zone.Library); Log.debug("Explosive Revelation", "Library before: " + lib); - CardList revealed = new CardList(); + final CardList revealed = new CardList(); if (lib.size() > 0) { int index = 0; Card top; @@ -1674,19 +1686,19 @@ public class CardFactory_Sorceries { // System.out.println("Got from top of library:"+top); index += 1; revealed.add(top); - } while (index < lib.size() && top.isLand()); + } while ((index < lib.size()) && top.isLand()); // Display the revealed cards GuiUtils.getChoice("Revealed cards:", revealed.toArray()); // non-land card into hand AllZone.getGameAction().moveToHand(revealed.get(revealed.size() - 1)); // put the rest of the cards on the bottom of library - for (int j = 0; j < revealed.size() - 1; j++) { + for (int j = 0; j < (revealed.size() - 1); j++) { AllZone.getGameAction().moveToBottomOfLibrary(revealed.get(j)); } // return the damage // System.out.println("Explosive Revelation does " - //+CardUtil.getConvertedManaCost(top)+" from: "+top); + // +CardUtil.getConvertedManaCost(top)+" from: "+top); return CardUtil.getConvertedManaCost(top); } return 0; @@ -1711,7 +1723,7 @@ public class CardFactory_Sorceries { @Override public boolean canPlayAI() { final int maxX = ComputerUtil.getAvailableMana().size() - 1; - int humanLife = AllZone.getHumanPlayer().getLife(); + final int humanLife = AllZone.getHumanPlayer().getLife(); if (maxX >= humanLife) { targetPlayers.add(AllZone.getHumanPlayer()); return true; @@ -1721,25 +1733,25 @@ public class CardFactory_Sorceries { @Override public void resolve() { - int damage = (card.getXManaCostPaid() - getNumTargets() + 1) / getNumTargets(); + final int damage = ((card.getXManaCostPaid() - this.getNumTargets()) + 1) / this.getNumTargets(); // add that much damage to each creature // DEBUG Log.debug("Fireball", "Fireball - damage to each target: " + damage); Log.debug("Fireball", "Fireball - card targets: "); - printCardTargets(); + this.printCardTargets(); Log.debug("Fireball", "Fireball - player targets: "); - printPlayerTargets(); + this.printPlayerTargets(); if (card.getController().isComputer()) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(cardName + " - Computer causes " + damage + " to:\n\n"); for (int i = 0; i < targets.size(); i++) { - Card target = targets.get(i); + final Card target = targets.get(i); if (AllZoneUtil.isCardInPlay(target) && CardFactoryUtil.canTarget(card, target)) { sb.append(target + "\n"); } } for (int i = 0; i < targetPlayers.size(); i++) { - Player p = targetPlayers.get(i); + final Player p = targetPlayers.get(i); if (p.canTarget(this)) { sb.append(p + "\n"); } @@ -1747,7 +1759,7 @@ public class CardFactory_Sorceries { javax.swing.JOptionPane.showMessageDialog(null, sb.toString()); } for (int i = 0; i < targets.size(); i++) { - Card target = targets.get(i); + final Card target = targets.get(i); if (AllZoneUtil.isCardInPlay(target) && CardFactoryUtil.canTarget(card, target)) { // DEBUG Log.debug("Fireball", "Fireball does " + damage + " to: " + target); @@ -1755,7 +1767,7 @@ public class CardFactory_Sorceries { } } for (int i = 0; i < targetPlayers.size(); i++) { - Player p = targetPlayers.get(i); + final Player p = targetPlayers.get(i); if (p.canTarget(this)) { // DEBUG Log.debug("Fireball", "Fireball does " + damage + " to: " + p); @@ -1766,8 +1778,8 @@ public class CardFactory_Sorceries { // DEBUG private void printCardTargets() { - StringBuilder sb = new StringBuilder("["); - for (Card target : targets) { + final StringBuilder sb = new StringBuilder("["); + for (final Card target : targets) { sb.append(target).append(","); } sb.append("]"); @@ -1776,8 +1788,8 @@ public class CardFactory_Sorceries { // DEBUG private void printPlayerTargets() { - StringBuilder sb = new StringBuilder("["); - for (Player p : targetPlayers) { + final StringBuilder sb = new StringBuilder("["); + for (final Player p : targetPlayers) { sb.append(p).append(","); } sb.append("]"); @@ -1799,7 +1811,7 @@ public class CardFactory_Sorceries { @Override public void showMessage() { AllZone.getDisplay().showMessage( - "Select target creatures and/or players. Currently, " + getNumTargets() + "Select target creatures and/or players. Currently, " + this.getNumTargets() + " targets. Click OK when done."); } @@ -1816,13 +1828,13 @@ public class CardFactory_Sorceries { public void selectButtonCancel() { targets.clear(); targetPlayers.clear(); - stop(); + this.stop(); } @Override public void selectButtonOK() { - spell.setStackDescription(cardName + " deals X damage to " + getNumTargets() + " target(s)."); - stopSetNext(new Input_PayManaCost(spell)); + spell.setStackDescription(cardName + " deals X damage to " + this.getNumTargets() + " target(s)."); + this.stopSetNext(new Input_PayManaCost(spell)); } @Override @@ -1838,7 +1850,7 @@ public class CardFactory_Sorceries { if (c.isCreature() && zone.is(Constant.Zone.Battlefield)) { targets.add(c); - showMessage(); + this.showMessage(); } } // selectCard() @@ -1853,7 +1865,7 @@ public class CardFactory_Sorceries { return; // cannot target the same player twice. } targetPlayers.add(player); - showMessage(); + this.showMessage(); } }; // Input @@ -1867,7 +1879,7 @@ public class CardFactory_Sorceries { * Discard X cards, then return a card from your graveyard to your * hand for each card discarded this way. Exile Recall. */ - Cost cost = new Cost(card.getManaCost(), cardName, false); + final Cost cost = new Cost(card.getManaCost(), cardName, false); final SpellAbility spell = new Spell(card, cost, null) { private static final long serialVersionUID = -3935814273439962834L; @@ -1883,12 +1895,12 @@ public class CardFactory_Sorceries { public void resolve() { int numCards = card.getXManaCostPaid(); final Player player = card.getController(); - int maxCards = player.getCardsIn(Zone.Hand).size(); + final int maxCards = player.getCardsIn(Zone.Hand).size(); if (numCards != 0) { numCards = Math.min(numCards, maxCards); if (player.isHuman()) { AllZone.getInputControl().setInput( - CardFactoryUtil.input_discardRecall(numCards, card, this)); + CardFactoryUtil.inputDiscardRecall(numCards, card, this)); } } /* @@ -1904,7 +1916,7 @@ public class CardFactory_Sorceries { } // resolve() }; // SpellAbility - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append(" - discard X cards and return X cards to your hand."); spell.setStackDescription(sb.toString()); @@ -1921,20 +1933,20 @@ public class CardFactory_Sorceries { /* * We want compy to have less cards in hand than the human */ - CardList humanHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - CardList computerHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); + final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); return computerHand.size() < humanHand.size(); } @Override public void resolve() { - CardList humanHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - CardList computerHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); + final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); - int num = Math.max(humanHand.size(), computerHand.size()); + final int num = Math.max(humanHand.size(), computerHand.size()); - discardDraw(AllZone.getHumanPlayer(), num); - discardDraw(AllZone.getComputerPlayer(), num); + this.discardDraw(AllZone.getHumanPlayer(), num); + this.discardDraw(AllZone.getComputerPlayer(), num); } // resolve() void discardDraw(final Player player, final int num) { @@ -1952,17 +1964,17 @@ public class CardFactory_Sorceries { @Override public void resolve() { - CardList threshold = card.getController().getCardsIn(Zone.Graveyard); - Card c = getTargetCard(); + final CardList threshold = card.getController().getCardsIn(Zone.Graveyard); + final Card c = this.getTargetCard(); if (threshold.size() >= 7) { if (card.getController().getZone(Zone.Graveyard).contains(c)) { - PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); + final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); AllZone.getGameAction().moveTo(play, c); } } else { if (card.getController().getZone(Zone.Graveyard).contains(c)) { - PlayerZone hand = card.getController().getZone(Constant.Zone.Hand); + final PlayerZone hand = card.getController().getZone(Constant.Zone.Hand); AllZone.getGameAction().moveTo(hand, c); } } @@ -1970,22 +1982,24 @@ public class CardFactory_Sorceries { @Override public boolean canPlay() { - return getCreatures().length != 0; + return this.getCreatures().length != 0; } + @Override public boolean canPlayAI() { - CardList check = card.getController().getCardsIn(Zone.Graveyard); - return getCreaturesAI().length != 0 || check.size() >= 7; + final CardList check = card.getController().getCardsIn(Zone.Graveyard); + return (this.getCreaturesAI().length != 0) || (check.size() >= 7); } public Card[] getCreatures() { - CardList creature = card.getController().getCardsIn(Zone.Graveyard).getType("Creature"); + final CardList creature = card.getController().getCardsIn(Zone.Graveyard).getType("Creature"); return creature.toArray(); } public Card[] getCreaturesAI() { CardList creature = card.getController().getCardsIn(Zone.Graveyard).getType("Creature"); creature = creature.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.getNetAttack() > 4; } @@ -1995,31 +2009,31 @@ public class CardFactory_Sorceries { @Override public void chooseTargetAI() { - Card[] c = getCreatures(); + final Card[] c = this.getCreatures(); Card biggest = c[0]; - for (int i = 0; i < c.length; i++) { - if (biggest.getNetAttack() < c[i].getNetAttack()) { - biggest = c[i]; + for (final Card element : c) { + if (biggest.getNetAttack() < element.getNetAttack()) { + biggest = element; } } - setTargetCard(biggest); + this.setTargetCard(biggest); } }; // SpellAbility card.addSpellAbility(spell); - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = -3717723884199321767L; @Override public void showMessage() { - CardList creature = card.getController().getCardsIn(Zone.Graveyard).getType("Creature"); - Object check = GuiUtils.getChoiceOptional("Select creature", creature); + final CardList creature = card.getController().getCardsIn(Zone.Graveyard).getType("Creature"); + final Object check = GuiUtils.getChoiceOptional("Select creature", creature); if (check != null) { spell.setTargetCard((Card) check); - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } else { - stop(); + this.stop(); } } // showMessage() }; // Input @@ -2059,11 +2073,11 @@ public class CardFactory_Sorceries { input[0] = ""; } - HashMap countInGraveyard = new HashMap(); - CardList allGrave = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Graveyard); + final HashMap countInGraveyard = new HashMap(); + final CardList allGrave = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Graveyard); allGrave.getType("Creature"); - for (Card c : allGrave) { - for (String type : c.getType()) { + for (final Card c : allGrave) { + for (final String type : c.getType()) { if (CardUtil.isACreatureType(type)) { if (countInGraveyard.containsKey(type)) { countInGraveyard.put(type, countInGraveyard.get(type) + 1); @@ -2075,7 +2089,7 @@ public class CardFactory_Sorceries { } String maxKey = ""; int maxCount = -1; - for (Entry entry : countInGraveyard.entrySet()) { + for (final Entry entry : countInGraveyard.entrySet()) { if (entry.getValue() > maxCount) { maxKey = entry.getKey(); maxCount = entry.getValue(); @@ -2090,7 +2104,7 @@ public class CardFactory_Sorceries { // Actually put everything on the battlefield CardList bidded = AllZoneUtil.getCardsIn(Constant.Zone.Graveyard); bidded = bidded.getType("Creature"); - for (Card c : bidded) { + for (final Card c : bidded) { if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) { AllZone.getGameAction().moveToPlay(c); } @@ -2099,7 +2113,7 @@ public class CardFactory_Sorceries { }; // SpellAbility card.addSpellAbility(spell); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(card.getName()).append(" - choose a creature type."); spell.setStackDescription(sb.toString()); } // *************** END ************ END ************************** @@ -2111,30 +2125,30 @@ public class CardFactory_Sorceries { * damage to that player. */ final Target tgt = new Target(card, "Select target player", "Player"); - Cost cost = new Cost("1 W W", cardName, false); - SpellAbility spell = new Spell(card, cost, tgt) { + final Cost cost = new Cost("1 W W", cardName, false); + final SpellAbility spell = new Spell(card, cost, tgt) { private static final long serialVersionUID = 8555498267738686288L; @Override public void resolve() { - Player p = tgt.getTargetPlayers().get(0); - int counters = p.getPoisonCounters(); + final Player p = tgt.getTargetPlayers().get(0); + final int counters = p.getPoisonCounters(); p.addDamage(counters, card); p.subtractPoisonCounters(counters); } // resolve() @Override public boolean canPlayAI() { - int humanPoison = AllZone.getHumanPlayer().getPoisonCounters(); - int compPoison = AllZone.getComputerPlayer().getPoisonCounters(); + final int humanPoison = AllZone.getHumanPlayer().getPoisonCounters(); + final int compPoison = AllZone.getComputerPlayer().getPoisonCounters(); if (AllZone.getHumanPlayer().getLife() <= humanPoison) { tgt.addTarget(AllZone.getHumanPlayer()); return true; } - if ((2 * (11 - compPoison) < AllZone.getComputerPlayer().getLife() || compPoison > 7) - && compPoison < AllZone.getComputerPlayer().getLife() - 2) { + if ((((2 * (11 - compPoison)) < AllZone.getComputerPlayer().getLife()) || (compPoison > 7)) + && (compPoison < (AllZone.getComputerPlayer().getLife() - 2))) { tgt.addTarget(AllZone.getComputerPlayer()); return true; } @@ -2154,20 +2168,20 @@ public class CardFactory_Sorceries { * graveyard. Then put the cards you revealed this way on the bottom * of your library in any order. */ - SpellAbility spell = new Spell(card) { + final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = 4475834103787262421L; @Override public void resolve() { - Player player = card.getController(); - Player opp = player.getOpponent(); - PlayerZone lib = card.getController().getZone(Constant.Zone.Library); + final Player player = card.getController(); + final Player opp = player.getOpponent(); + final PlayerZone lib = card.getController().getZone(Constant.Zone.Library); int maxCards = lib.size(); maxCards = Math.min(maxCards, 10); if (maxCards == 0) { return; } - CardList topCards = new CardList(); + final CardList topCards = new CardList(); // show top n cards: for (int j = 0; j < maxCards; j++) { topCards.add(lib.get(j)); @@ -2179,7 +2193,7 @@ public class CardFactory_Sorceries { opp.mill(num); // then, move revealed cards to bottom of library - for (Card c : topCards) { + for (final Card c : topCards) { AllZone.getGameAction().moveToBottomOfLibrary(c); } } // resolve() @@ -2204,14 +2218,14 @@ public class CardFactory_Sorceries { @Override public void resolve() { - discardDrawX(AllZone.getHumanPlayer()); - discardDrawX(AllZone.getComputerPlayer()); + this.discardDrawX(AllZone.getHumanPlayer()); + this.discardDrawX(AllZone.getComputerPlayer()); } // resolve() void discardDrawX(final Player player) { - CardList hand = player.getCardsIn(Zone.Hand); + final CardList hand = player.getCardsIn(Zone.Hand); - for (Card c : hand) { + for (final Card c : hand) { AllZone.getGameAction().moveToLibrary(c); } @@ -2248,10 +2262,10 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Player player = card.getController(); - Player opp = player.getOpponent(); - discardDraw(AllZone.getHumanPlayer()); - discardDraw(AllZone.getComputerPlayer()); + final Player player = card.getController(); + final Player opp = player.getOpponent(); + this.discardDraw(AllZone.getHumanPlayer()); + this.discardDraw(AllZone.getComputerPlayer()); if (player.hasMetalcraft()) { opp.addDamage(opp.getNumDrawnThisTurn(), card); @@ -2259,11 +2273,11 @@ public class CardFactory_Sorceries { } // resolve() void discardDraw(final Player player) { - CardList hand = player.getCardsIn(Zone.Hand); - int numDraw = hand.size(); + final CardList hand = player.getCardsIn(Zone.Hand); + final int numDraw = hand.size(); // move hand to library - for (Card c : hand) { + for (final Card c : hand) { AllZone.getGameAction().moveToLibrary(c); } @@ -2280,8 +2294,8 @@ public class CardFactory_Sorceries { public boolean canPlayAI() { CardList c = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); c = c.filter(CardListFilter.NON_LANDS); - return 2 >= c.size() - || (AllZone.getComputerPlayer().hasMetalcraft() && AllZone.getHumanPlayer().getLife() <= 3); + return (2 >= c.size()) + || (AllZone.getComputerPlayer().hasMetalcraft() && (AllZone.getHumanPlayer().getLife() <= 3)); } }; // SpellAbility @@ -2300,8 +2314,8 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Player player = card.getController(); - for (Card c : player.getCardsIn(Zone.Graveyard)) { + final Player player = card.getController(); + for (final Card c : player.getCardsIn(Zone.Graveyard)) { AllZone.getGameAction().moveToHand(c); } @@ -2328,7 +2342,7 @@ public class CardFactory_Sorceries { final String[] cardChoice = { "Target player loses X life", "Return target creature card with converted mana cost X " - + "or less from your graveyard to the battlefield", + + "or less from your graveyard to the battlefield", "Target creature gets -X/-X until end of turn", "Up to X target creatures gain fear until end of turn" }; @@ -2347,9 +2361,9 @@ public class CardFactory_Sorceries { for (int i = 0; i < card.getChoices().size(); i++) { if (card.getChoice(i).equals(cardChoice[0])) { if (ab0player[0] != null) { - setTargetPlayer(ab0player[0]); - if (getTargetPlayer().canTarget(this)) { - getTargetPlayer().addDamage(x[0], card); + this.setTargetPlayer(ab0player[0]); + if (this.getTargetPlayer().canTarget(this)) { + this.getTargetPlayer().addDamage(x[0], card); } } } @@ -2358,11 +2372,10 @@ public class CardFactory_Sorceries { // "Return target creature card with converted mana cost // X or less from your graveyard to the battlefield", if (userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) { - Card c = ab1card[0]; + final Card c = ab1card[0]; if (c != null) { if (card.getController().getZone(Zone.Graveyard).contains(c) - && CardFactoryUtil.canTarget(card, c)) - { + && CardFactoryUtil.canTarget(card, c)) { AllZone.getGameAction().moveToPlay(c); } } @@ -2380,6 +2393,7 @@ public class CardFactory_Sorceries { final Command untilEOT = new Command() { private static final long serialVersionUID = -6010783402521993651L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(c)) { c.addTempAttackBoost(-1 * boost); @@ -2396,7 +2410,7 @@ public class CardFactory_Sorceries { // "Up to X target creatures gain fear until end of turn" if (userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) { - ArrayList cs = new ArrayList(); + final ArrayList cs = new ArrayList(); cs.addAll(ab3cards); for (final Card c : cs) { if (AllZoneUtil.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { @@ -2404,6 +2418,7 @@ public class CardFactory_Sorceries { final Command untilEOT = new Command() { private static final long serialVersionUID = 986259855862338866L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(c)) { c.removeExtrinsicKeyword("Fear"); @@ -2425,8 +2440,9 @@ public class CardFactory_Sorceries { final Command setStackDescription = new Command() { private static final long serialVersionUID = 5840471361149632482L; + @Override public void execute() { - ArrayList a = new ArrayList(); + final ArrayList a = new ArrayList(); if (userChoice.contains(cardChoice[0]) || card.getChoices().contains(cardChoice[0])) { a.add(ab0player[0] + " loses X life"); } @@ -2440,7 +2456,7 @@ public class CardFactory_Sorceries { a.add("up to X target creatures gain Fear until end of turn"); } - String s = a.get(0) + ", " + a.get(1); + final String s = a.get(0) + ", " + a.get(1); spell.setStackDescription(card.getName() + " - " + s); } }; // Command @@ -2454,42 +2470,42 @@ public class CardFactory_Sorceries { @Override public void showMessage() { - if (count == 0) { - stop = x[0]; + if (this.count == 0) { + this.stop = x[0]; } AllZone.getDisplay().showMessage( - cardName + " - Select a target creature to gain Fear (up to " + (stop - count) + " more)"); + cardName + " - Select a target creature to gain Fear (up to " + (this.stop - this.count) + + " more)"); ButtonUtil.enableAll(); } @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override public void selectButtonOK() { - done(); + this.done(); } @Override public void selectCard(final Card c, final PlayerZone zone) { if (c.isCreature() && zone.is(Constant.Zone.Battlefield) && CardFactoryUtil.canTarget(card, c) - && !ab3cards.contains(c)) - { + && !ab3cards.contains(c)) { ab3cards.add(c); - count++; - if (count == stop) { - done(); + this.count++; + if (this.count == this.stop) { + this.done(); } else { - showMessage(); + this.showMessage(); } } } // selectCard() private void done() { setStackDescription.execute(); - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } }; @@ -2505,7 +2521,7 @@ public class CardFactory_Sorceries { @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override @@ -2520,10 +2536,10 @@ public class CardFactory_Sorceries { setStackDescription.execute(); if (userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) { - stopSetNext(targetXCreatures); + this.stopSetNext(targetXCreatures); } else { System.out.println("Input_PayManaCost for spell is getting: " + spell.getManaCost()); - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } } // if } // selectCard() @@ -2538,31 +2554,33 @@ public class CardFactory_Sorceries { CardList grave = card.getController().getCardsIn(Constant.Zone.Graveyard); grave = grave.filter(CardListFilter.CREATURES); grave = grave.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.getCMC() <= x[0]; } }); - Object check = GuiUtils.getChoiceOptional("Select target creature with CMC < X", grave.toArray()); + final Object check = GuiUtils.getChoiceOptional("Select target creature with CMC < X", + grave.toArray()); if (check != null) { - Card c = (Card) check; + final Card c = (Card) check; if (CardFactoryUtil.canTarget(card, c)) { ab1card[0] = c; } } else { - stop(); + this.stop(); } - done(); + this.done(); } // showMessage() public void done() { if (userChoice.contains(cardChoice[2]) || card.getChoices().contains(cardChoice[2])) { - stopSetNext(targetCreature); + this.stopSetNext(targetCreature); } else if (userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) { - stopSetNext(targetXCreatures); + this.stopSetNext(targetXCreatures); } else { - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } } }; // Input @@ -2579,7 +2597,7 @@ public class CardFactory_Sorceries { @Override public void selectButtonCancel() { - stop(); + this.stop(); } @Override @@ -2594,13 +2612,13 @@ public class CardFactory_Sorceries { setStackDescription.execute(); if (userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) { - stopSetNext(targetGraveCreature); + this.stopSetNext(targetGraveCreature); } else if (userChoice.contains(cardChoice[2]) || card.getChoices().contains(cardChoice[2])) { - stopSetNext(targetCreature); + this.stopSetNext(targetCreature); } else if (userChoice.contains(cardChoice[3]) || card.getChoices().contains(cardChoice[3])) { - stopSetNext(targetXCreatures); + this.stopSetNext(targetXCreatures); } else { - stopSetNext(new Input_PayManaCost(spell)); + this.stopSetNext(new Input_PayManaCost(spell)); } } } // selectPlayer() @@ -2614,43 +2632,43 @@ public class CardFactory_Sorceries { if (card.isCopiedSpell()) { x[0] = 0; if (userChoice.contains(cardChoice[0])) { - stopSetNext(targetPlayer); + this.stopSetNext(targetPlayer); } else if (userChoice.contains(cardChoice[1])) { - stopSetNext(targetGraveCreature); + this.stopSetNext(targetGraveCreature); } else if (userChoice.contains(cardChoice[2])) { - stopSetNext(targetCreature); + this.stopSetNext(targetCreature); } else if (userChoice.contains(cardChoice[3])) { - stopSetNext(targetXCreatures); + this.stopSetNext(targetXCreatures); } else { throw new RuntimeException( "Something in if(isCopiedSpell()) in Profane Command selection is FUBAR."); } } else { - ArrayList choices = new ArrayList(); + final ArrayList choices = new ArrayList(); for (int i = 0; i <= card.getController().getLife(); i++) { choices.add("" + i); } - Object o = GuiUtils.getChoice("Choose X", choices.toArray()); + final Object o = GuiUtils.getChoice("Choose X", choices.toArray()); // everything stops here if user cancelled if (o == null) { - stop(); + this.stop(); return; } - String answer = (String) o; + final String answer = (String) o; x[0] = Integer.parseInt(answer); spell.setManaCost(x[0] + " B B"); spell.setIsXCost(false); if (userChoice.contains(cardChoice[0])) { - stopSetNext(targetPlayer); + this.stopSetNext(targetPlayer); } else if (userChoice.contains(cardChoice[1])) { - stopSetNext(targetGraveCreature); + this.stopSetNext(targetGraveCreature); } else if (userChoice.contains(cardChoice[2])) { - stopSetNext(targetCreature); + this.stopSetNext(targetCreature); } else if (userChoice.contains(cardChoice[3])) { - stopSetNext(targetXCreatures); + this.stopSetNext(targetXCreatures); } else { throw new RuntimeException("Something in Profane Command selection is FUBAR."); } @@ -2658,20 +2676,20 @@ public class CardFactory_Sorceries { } // showMessage() }; // Input chooseX - Input chooseTwoInput = new Input() { + final Input chooseTwoInput = new Input() { private static final long serialVersionUID = 5625588008756700226L; @Override public void showMessage() { if (card.isCopiedSpell()) { if (userChoice.contains(cardChoice[0])) { - stopSetNext(targetPlayer); + this.stopSetNext(targetPlayer); } else if (userChoice.contains(cardChoice[1])) { - stopSetNext(targetGraveCreature); + this.stopSetNext(targetGraveCreature); } else if (userChoice.contains(cardChoice[2])) { - stopSetNext(targetCreature); + this.stopSetNext(targetCreature); } else if (userChoice.contains(cardChoice[3])) { - stopSetNext(targetXCreatures); + this.stopSetNext(targetXCreatures); } else { throw new RuntimeException( "Something in if(isCopiedSpell()) in Profane Command selection is FUBAR."); @@ -2686,10 +2704,10 @@ public class CardFactory_Sorceries { card.getChoiceTargets().clear(); userChoice.clear(); - ArrayList display = new ArrayList(); + final ArrayList display = new ArrayList(); // get all - CardList creatures = AllZoneUtil.getCreaturesInPlay(); + final CardList creatures = AllZoneUtil.getCreaturesInPlay(); CardList grave = card.getController().getCardsIn(Zone.Graveyard); grave = grave.filter(CardListFilter.CREATURES); @@ -2698,27 +2716,27 @@ public class CardFactory_Sorceries { } if (grave.size() > 0) { display.add("Return target creature card with converted mana " - + "cost X or less from your graveyard to the battlefield"); + + "cost X or less from your graveyard to the battlefield"); } if (creatures.size() > 0) { display.add("Target creature gets -X/-X until end of turn"); } display.add("Up to X target creatures gain fear until end of turn"); - ArrayList a = chooseTwo(display); + final ArrayList a = this.chooseTwo(display); // everything stops here if user cancelled if (a == null) { - stop(); + this.stop(); return; } userChoice.addAll(a); - stopSetNext(chooseX); + this.stopSetNext(chooseX); } } // showMessage() private ArrayList chooseTwo(final ArrayList choices) { - ArrayList out = new ArrayList(); + final ArrayList out = new ArrayList(); Object o = GuiUtils.getChoiceOptional("Choose Two", choices.toArray()); if (o == null) { return null; @@ -2745,8 +2763,8 @@ public class CardFactory_Sorceries { // *************** START *********** START ************************** else if (cardName.equals("Turn to Slag")) { - Cost abCost = new Cost("3 R R", cardName, false); - Target target = new Target(card, "Select target creature", "Creature".split(",")); + final Cost abCost = new Cost("3 R R", cardName, false); + final Target target = new Target(card, "Select target creature", "Creature".split(",")); final SpellAbility spell = new Spell(card, abCost, target) { private static final long serialVersionUID = 3848014348910653252L; @@ -2757,11 +2775,11 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Card tgt = getTargetCard(); + final Card tgt = this.getTargetCard(); if (AllZoneUtil.isCardInPlay(tgt) && CardFactoryUtil.canTarget(card, tgt)) { tgt.addDamage(5, card); - CardList equipment = new CardList(tgt.getEquippedBy()); - for (Card eq : equipment) { + final CardList equipment = new CardList(tgt.getEquippedBy()); + for (final Card eq : equipment) { AllZone.getGameAction().destroy(eq); } } @@ -2786,7 +2804,7 @@ public class CardFactory_Sorceries { * library. */ - Cost abCost = new Cost("U U", cardName, false); + final Cost abCost = new Cost("U U", cardName, false); final SpellAbility spell = new Spell(card, abCost, null) { private static final long serialVersionUID = -8497142072380944393L; @@ -2797,16 +2815,16 @@ public class CardFactory_Sorceries { @Override public void resolve() { - Player p = card.getController(); + final Player p = card.getController(); int baseCMC = -1; final Card[] newArtifact = new Card[1]; // Sacrifice an artifact CardList arts = p.getCardsIn(Constant.Zone.Battlefield); arts = arts.filter(CardListFilter.ARTIFACTS); - Object toSac = GuiUtils.getChoiceOptional("Sacrifice an artifact", arts.toArray()); + final Object toSac = GuiUtils.getChoiceOptional("Sacrifice an artifact", arts.toArray()); if (toSac != null) { - Card c = (Card) toSac; + final Card c = (Card) toSac; baseCMC = CardUtil.getConvertedManaCost(c); AllZone.getGameAction().sacrifice(c); } else { @@ -2814,32 +2832,34 @@ public class CardFactory_Sorceries { } // Search your library for an artifact - CardList lib = p.getCardsIn(Zone.Library); + final CardList lib = p.getCardsIn(Zone.Library); GuiUtils.getChoiceOptional("Looking at Library", lib.toArray()); - CardList libArts = lib.filter(CardListFilter.ARTIFACTS); - Object o = GuiUtils.getChoiceOptional("Search for artifact", libArts.toArray()); + final CardList libArts = lib.filter(CardListFilter.ARTIFACTS); + final Object o = GuiUtils.getChoiceOptional("Search for artifact", libArts.toArray()); if (o != null) { newArtifact[0] = (Card) o; } else { return; } - int newCMC = CardUtil.getConvertedManaCost(newArtifact[0]); + final int newCMC = CardUtil.getConvertedManaCost(newArtifact[0]); // if <= baseCMC, put it onto the battlefield if (newCMC <= baseCMC) { AllZone.getGameAction().moveToPlay(newArtifact[0]); } else { - String diffCost = String.valueOf(newCMC - baseCMC); + final String diffCost = String.valueOf(newCMC - baseCMC); AllZone.getInputControl().setInput(new Input_PayManaCost_Ability(diffCost, new Command() { private static final long serialVersionUID = -8729850321341068049L; + @Override public void execute() { AllZone.getGameAction().moveToPlay(newArtifact[0]); } }, new Command() { private static final long serialVersionUID = -246036834856971935L; + @Override public void execute() { AllZone.getGameAction().moveToGraveyard(newArtifact[0]); } diff --git a/src/main/java/forge/card/cardFactory/PreloadingCardFactory.java b/src/main/java/forge/card/cardFactory/PreloadingCardFactory.java index 1591861021c..fd9b50459dc 100644 --- a/src/main/java/forge/card/cardFactory/PreloadingCardFactory.java +++ b/src/main/java/forge/card/cardFactory/PreloadingCardFactory.java @@ -12,6 +12,7 @@ import forge.card.CardRules; import forge.error.ErrorViewer; import forge.item.CardDb; import forge.properties.ForgeProps; +import forge.properties.NewConstants; /** *

@@ -56,16 +57,16 @@ public class PreloadingCardFactory extends AbstractCardFactory { super(file); try { - readCards(file); + this.readCards(file); // initialize CardList allCards - Iterator it = getMap().keySet().iterator(); + final Iterator it = this.getMap().keySet().iterator(); Card c; while (it.hasNext()) { - c = getCard(it.next().toString(), AllZone.getHumanPlayer()); - getAllCards().add(c); + c = this.getCard(it.next().toString(), AllZone.getHumanPlayer()); + this.getAllCards().add(c); } - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); } } // constructor @@ -79,10 +80,11 @@ public class PreloadingCardFactory extends AbstractCardFactory { * a {@link java.io.File} object. */ protected final void readCards(final File file) { - getMap().clear(); + this.getMap().clear(); - List listCardRules = new ArrayList(); - CardReader read = new CardReader(ForgeProps.getFile(CARDSFOLDER), getMap(), listCardRules); + final List listCardRules = new ArrayList(); + final CardReader read = new CardReader(ForgeProps.getFile(NewConstants.CARDSFOLDER), this.getMap(), + listCardRules); // this fills in our map of card names to Card instances. read.run(); diff --git a/src/main/java/forge/card/cost/CostPutCounter.java b/src/main/java/forge/card/cost/CostPutCounter.java index f9a3529fed2..d7c3b56a24c 100644 --- a/src/main/java/forge/card/cost/CostPutCounter.java +++ b/src/main/java/forge/card/cost/CostPutCounter.java @@ -201,9 +201,9 @@ public class CostPutCounter extends CostPartWithList { Card card = null; if (type.equals("Creature.YouCtrl")) { - card = CardFactoryUtil.AI_getWorstCreature(typeList); + card = CardFactoryUtil.getWorstCreatureAI(typeList); } else { - card = CardFactoryUtil.AI_getWorstPermanent(typeList, false, false, false, false); + card = CardFactoryUtil.getWorstPermanentAI(typeList, false, false, false, false); } addToList(card); } diff --git a/src/main/java/forge/card/spellability/Spell_Permanent.java b/src/main/java/forge/card/spellability/Spell_Permanent.java index 91e522e11c7..2fdfc1be0b9 100644 --- a/src/main/java/forge/card/spellability/Spell_Permanent.java +++ b/src/main/java/forge/card/spellability/Spell_Permanent.java @@ -43,7 +43,7 @@ public class Spell_Permanent extends Spell { public void showMessage() { 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)); ButtonUtil.disableAll(); // target this card means: sacrifice this // card