();
+ *
+ * // if the mana ability is not avaiable move to the next one
+ * m.setActivatingPlayer(player); if (!m.canPlay()) { return colors; }
+ *
+ * if (!colors.contains(Constant.Color.BLACK) && m.isBasic() &&
+ * m.mana().equals("B")) { colors.add(Constant.Color.BLACK); } if
+ * (!colors.contains(Constant.Color.WHITE) && m.isBasic() &&
+ * m.mana().equals("W")) { colors.add(Constant.Color.WHITE); } if
+ * (!colors.contains(Constant.Color.GREEN) && m.isBasic() &&
+ * m.mana().equals("G")) { colors.add(Constant.Color.GREEN); } if
+ * (!colors.contains(Constant.Color.RED) && m.isBasic() &&
+ * m.mana().equals("R")) { colors.add(Constant.Color.RED); } if
+ * (!colors.contains(Constant.Color.BLUE) && m.isBasic() &&
+ * m.mana().equals("U")) { colors.add(Constant.Color.BLUE); } if
+ * (!colors.contains(Constant.Color.COLORLESS) && m.isBasic() &&
+ * m.mana().equals("1")) { colors.add(Constant.Color.COLORLESS); }
+ *
+ * return colors; }
+ */
/**
*
@@ -1094,58 +1087,43 @@ public class ComputerUtil {
* @return a {@link java.util.ArrayList} object.
* @since 1.0.15
*/
- /*public static ArrayList sortForNeeded(final ManaCost cost, final ArrayList manaAbilities,
- final Player player) {
-
- ArrayList colors;
-
- final ArrayList colorsNeededToAvoidNegativeEffect = cost.getManaNeededToAvoidNegativeEffect();
-
- final ArrayList res = new ArrayList();
-
- final ManaCost onlyColored = new ManaCost(cost.toString());
-
- onlyColored.removeColorlessMana();
-
- for (final AbilityMana am : manaAbilities) {
- colors = ComputerUtil.getProduceableColors(am, player);
- for (int j = 0; j < colors.size(); j++) {
- if (onlyColored.isNeeded(colors.get(j))) {
- res.add(am);
- break;
- }
- for (final String col : colorsNeededToAvoidNegativeEffect) {
- if (col.equalsIgnoreCase(colors.get(j))
- || CardUtil.getShortColor(col).equalsIgnoreCase(colors.get(j))) {
- res.add(am);
- }
- }
- }
- }
-
- for (final AbilityMana am : manaAbilities) {
-
- if (res.contains(am)) {
- break;
- }
-
- colors = ComputerUtil.getProduceableColors(am, player);
- for (int j = 0; j < colors.size(); j++) {
- if (cost.isNeeded(colors.get(j))) {
- res.add(am);
- break;
- }
- for (final String col : colorsNeededToAvoidNegativeEffect) {
- if (col.equalsIgnoreCase(colors.get(j))
- || CardUtil.getShortColor(col).equalsIgnoreCase(colors.get(j))) {
- res.add(am);
- }
- }
- }
- }
-
- return res;
- }*/
+ /*
+ * public static ArrayList sortForNeeded(final ManaCost cost,
+ * final ArrayList manaAbilities, final Player player) {
+ *
+ * ArrayList colors;
+ *
+ * final ArrayList colorsNeededToAvoidNegativeEffect =
+ * cost.getManaNeededToAvoidNegativeEffect();
+ *
+ * final ArrayList res = new ArrayList();
+ *
+ * final ManaCost onlyColored = new ManaCost(cost.toString());
+ *
+ * onlyColored.removeColorlessMana();
+ *
+ * for (final AbilityMana am : manaAbilities) { colors =
+ * ComputerUtil.getProduceableColors(am, player); for (int j = 0; j <
+ * colors.size(); j++) { if (onlyColored.isNeeded(colors.get(j))) {
+ * res.add(am); break; } for (final String col :
+ * colorsNeededToAvoidNegativeEffect) { if
+ * (col.equalsIgnoreCase(colors.get(j)) ||
+ * CardUtil.getShortColor(col).equalsIgnoreCase(colors.get(j))) {
+ * res.add(am); } } } }
+ *
+ * for (final AbilityMana am : manaAbilities) {
+ *
+ * if (res.contains(am)) { break; }
+ *
+ * colors = ComputerUtil.getProduceableColors(am, player); for (int j = 0; j
+ * < colors.size(); j++) { if (cost.isNeeded(colors.get(j))) { res.add(am);
+ * break; } for (final String col : colorsNeededToAvoidNegativeEffect) { if
+ * (col.equalsIgnoreCase(colors.get(j)) ||
+ * CardUtil.getShortColor(col).equalsIgnoreCase(colors.get(j))) {
+ * res.add(am); } } } }
+ *
+ * return res; }
+ */
/**
*
@@ -1942,9 +1920,11 @@ public class ComputerUtil {
/**
* Contains useful keyword.
- *
- * @param keywords the keywords
- * @param card the card
+ *
+ * @param keywords
+ * the keywords
+ * @param card
+ * the card
* @return true, if successful
*/
public static boolean containsUsefulKeyword(final ArrayList keywords, final Card card) {
@@ -1958,62 +1938,56 @@ public class ComputerUtil {
/**
* Checks if is useful keyword.
- *
- * @param keyword the keyword
- * @param card the card
+ *
+ * @param keyword
+ * the keyword
+ * @param card
+ * the card
* @return true, if is useful keyword
*/
public static boolean isUsefulKeyword(final String keyword, final Card card) {
- PhaseHandler ph = AllZone.getPhaseHandler();
- Player computer = AllZone.getComputerPlayer();
- Player human = AllZone.getHumanPlayer();
+ final PhaseHandler ph = AllZone.getPhaseHandler();
+ final Player computer = AllZone.getComputerPlayer();
+ final Player human = AllZone.getHumanPlayer();
final boolean evasive = (keyword.endsWith("Flying") || keyword.endsWith("Horsemanship")
- || keyword.endsWith("Unblockable") || keyword.endsWith("Fear")
- || keyword.endsWith("Intimidate"));
+ || keyword.endsWith("Unblockable") || keyword.endsWith("Fear") || keyword.endsWith("Intimidate"));
if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) {
return false;
}
// give evasive keywords to creatures that can attack
if (evasive) {
if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
- || ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
- || (card.getNetCombatDamage() <= 0)
- || AllZoneUtil.getCreaturesInPlay(human).size() < 1) {
+ || ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)
+ || (card.getNetCombatDamage() <= 0) || (AllZoneUtil.getCreaturesInPlay(human).size() < 1)) {
return false;
}
} else if (keyword.equals("Defender") || keyword.endsWith("CARDNAME can't attack.")) {
- if (card.getController().isComputer()
- || ph.isPlayerTurn(computer)
- || !CombatUtil.canAttack(card) || (card.getNetCombatDamage() <= 0)) {
+ if (card.getController().isComputer() || ph.isPlayerTurn(computer) || !CombatUtil.canAttack(card)
+ || (card.getNetCombatDamage() <= 0)) {
return false;
}
} else if (keyword.endsWith("CARDNAME can't block.")) {
- if (card.getController().isComputer() || ph.isPlayerTurn(human)
- || !CombatUtil.canBlock(card)) {
+ if (card.getController().isComputer() || ph.isPlayerTurn(human) || !CombatUtil.canBlock(card)) {
return false;
}
} else if (keyword.endsWith("This card doesn't untap during your next untap step.")) {
- if (ph.isBefore(Constant.Phase.MAIN2) || card.isUntapped()
- || ph.isPlayerTurn(human)) {
+ if (ph.isBefore(Constant.Phase.MAIN2) || card.isUntapped() || ph.isPlayerTurn(human)) {
return false;
}
} else if (keyword.endsWith("CARDNAME attacks each turn if able.")) {
- if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
- || !CombatUtil.canBeBlocked(card)) {
+ if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card) || !CombatUtil.canBeBlocked(card)) {
return false;
}
} else if (keyword.endsWith("Shroud")) {
- //TODO: check stack for spells and abilities
+ // TODO: check stack for spells and abilities
return false;
} else if (keyword.startsWith("Rampage")) {
- if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card)
- || !CombatUtil.canBeBlocked(card)
- || AllZoneUtil.getCreaturesInPlay(human).size() < 2) {
+ if (ph.isPlayerTurn(human) || !CombatUtil.canAttack(card) || !CombatUtil.canBeBlocked(card)
+ || (AllZoneUtil.getCreaturesInPlay(human).size() < 2)) {
return false;
}
- } else if (keyword.endsWith("Haste")) {
- if (!card.hasSickness() || ph.isPlayerTurn(human)
- || !CombatUtil.canAttackNextTurn(card) || card.isTapped()
+ } else if (keyword.endsWith("Haste")) {
+ if (!card.hasSickness() || ph.isPlayerTurn(human) || !CombatUtil.canAttackNextTurn(card) || card.isTapped()
|| card.hasKeyword("CARDNAME can attack as though it had haste.")
|| ph.isAfter(Constant.Phase.COMBAT_DECLARE_ATTACKERS)) {
return false;
diff --git a/src/main/java/forge/card/BoosterGenerator.java b/src/main/java/forge/card/BoosterGenerator.java
index 509bc29080b..47d25e98381 100644
--- a/src/main/java/forge/card/BoosterGenerator.java
+++ b/src/main/java/forge/card/BoosterGenerator.java
@@ -243,6 +243,15 @@ public class BoosterGenerator {
return temp;
}
+ /**
+ * Gets the booster pack.
+ *
+ * @param numbers the numbers
+ * @param nRareSlots the n rare slots
+ * @param nDoubls the n doubls
+ * @param nAnyCard the n any card
+ * @return the booster pack
+ */
public final List getBoosterPack(final Map numbers,
final int nRareSlots, final int nDoubls, final int nAnyCard) {
return getBoosterPack(numbers.get(CardRarity.Common), numbers.get(CardRarity.Uncommon), nRareSlots,
diff --git a/src/main/java/forge/card/CardEdition.java b/src/main/java/forge/card/CardEdition.java
index ab5ea7bcb79..8c12a86dc4d 100644
--- a/src/main/java/forge/card/CardEdition.java
+++ b/src/main/java/forge/card/CardEdition.java
@@ -17,9 +17,9 @@
*/
package forge.card;
-import forge.game.GameFormat;
import net.slightlymagic.braids.util.lambda.Lambda1;
import net.slightlymagic.maxmtg.Predicate;
+import forge.game.GameFormat;
/**
*
@@ -66,7 +66,8 @@ public final class CardEdition implements Comparable { // immutable
* @param booster
* the booster
*/
- public CardEdition(final int index, final String name, final String code, final String code2, final BoosterData booster) {
+ public CardEdition(final int index, final String name, final String code, final String code2,
+ final BoosterData booster) {
this.code = code;
this.code2 = code2;
this.index = index;
@@ -321,7 +322,7 @@ public final class CardEdition implements Comparable { // immutable
/**
* Gets the total.
- *
+ *
* @return the total
*/
public final int getTotal() {
@@ -346,15 +347,19 @@ public final class CardEdition implements Comparable { // immutable
/** The Constant canMakeBooster. */
public static final Predicate CAN_MAKE_BOOSTER = new CanMakeBooster();
-
private static class CanMakeBooster extends Predicate {
@Override
public boolean isTrue(final CardEdition subject) {
return subject.canGenerateBooster();
}
}
-
+ /**
+ * Checks if is legal in format.
+ *
+ * @param format the format
+ * @return the predicate
+ */
public final static Predicate isLegalInFormat(final GameFormat format) {
return new LegalInFormat(format);
}
diff --git a/src/main/java/forge/card/EditionUtils.java b/src/main/java/forge/card/EditionUtils.java
index d4182e8368a..3ff0987bdd9 100644
--- a/src/main/java/forge/card/EditionUtils.java
+++ b/src/main/java/forge/card/EditionUtils.java
@@ -41,13 +41,21 @@ public final class EditionUtils {
private final List allSets;
+ /**
+ * Gets the all sets.
+ *
+ * @return the all sets
+ */
public final List getAllSets() {
- return allSets;
+ return this.allSets;
}
+ /**
+ * Instantiates a new edition utils.
+ */
public EditionUtils() {
- allSets = loadSetData(loadBoosterData());
- allBlocks = loadBlockData();
+ this.allSets = this.loadSetData(this.loadBoosterData());
+ this.allBlocks = this.loadBlockData();
}
/** Constant setData. */
@@ -60,7 +68,7 @@ public final class EditionUtils {
* @return the blocks
*/
public List getBlocks() {
- return allBlocks;
+ return this.allBlocks;
}
/**
@@ -71,7 +79,7 @@ public final class EditionUtils {
* @return the sets the by code
*/
public CardEdition getEditionByCode(final String code) {
- return setsByCode.get(code);
+ return this.setsByCode.get(code);
}
/**
@@ -82,7 +90,7 @@ public final class EditionUtils {
* @return the sets the by code or throw
*/
public CardEdition getEditionByCodeOrThrow(final String code) {
- final CardEdition set = setsByCode.get(code);
+ final CardEdition set = this.setsByCode.get(code);
if (null == set) {
throw new RuntimeException(String.format("Edition with code '%s' not found", code));
}
@@ -98,7 +106,7 @@ public final class EditionUtils {
* @return the code2 by code
*/
public String getCode2ByCode(final String code) {
- final CardEdition set = setsByCode.get(code);
+ final CardEdition set = this.setsByCode.get(code);
return set == null ? "" : set.getCode2();
}
@@ -146,26 +154,24 @@ public final class EditionUtils {
private List loadSetData(final Map boosters) {
final ArrayList fData = FileUtil.readFile("res/blockdata/setdata.txt");
-
-
final List allSets = new ArrayList();
for (final String s : fData) {
if (StringUtils.isBlank(s)) {
continue;
}
- FileSection section = FileSection.parse(s, ":", "|");
- String code = section.get("code3");
- int index = section.getInt("index", -1);
- String code2 = section.get("code2");
- String name = section.get("name");
- String alias = section.get("alias");
+ final FileSection section = FileSection.parse(s, ":", "|");
+ final String code = section.get("code3");
+ final int index = section.getInt("index", -1);
+ final String code2 = section.get("code2");
+ final String name = section.get("name");
+ final String alias = section.get("alias");
final CardEdition set = new CardEdition(index, name, code, code2, boosters.get(code));
- //boosters.remove(code);
- setsByCode.put(code, set);
+ // boosters.remove(code);
+ this.setsByCode.put(code, set);
if (alias != null) {
- setsByCode.put(alias, set);
+ this.setsByCode.put(alias, set);
}
allSets.add(set);
}
@@ -199,9 +205,9 @@ public final class EditionUtils {
} else if ("index".equals(key)) {
index = Integer.parseInt(kv[1]);
} else if ("set0".equals(key) || "set1".equals(key) || "set2".equals(key)) {
- sets.add(getEditionByCodeOrThrow(kv[1]));
+ sets.add(this.getEditionByCodeOrThrow(kv[1]));
} else if ("landsetcode".equals(key)) {
- landSet = getEditionByCodeOrThrow(kv[1]);
+ landSet = this.getEditionByCodeOrThrow(kv[1]);
} else if ("draftpacks".equals(key)) {
draftBoosters = Integer.parseInt(kv[1]);
} else if ("sealedpacks".equals(key)) {
diff --git a/src/main/java/forge/card/FormatUtils.java b/src/main/java/forge/card/FormatUtils.java
index 29601703902..59cc47b19ce 100644
--- a/src/main/java/forge/card/FormatUtils.java
+++ b/src/main/java/forge/card/FormatUtils.java
@@ -1,3 +1,20 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Nate
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package forge.card;
import java.util.ArrayList;
@@ -12,6 +29,9 @@ import org.apache.commons.lang3.StringUtils;
import forge.game.GameFormat;
import forge.util.FileUtil;
+/**
+ * The Class FormatUtils.
+ */
public final class FormatUtils {
private final Map formats = new TreeMap(String.CASE_INSENSITIVE_ORDER);
@@ -53,6 +73,9 @@ public final class FormatUtils {
return formats.values();
}
+ /**
+ * Instantiates a new format utils.
+ */
public FormatUtils() {
final List fData = FileUtil.readFile("res/blockdata/formats.txt");
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactory.java b/src/main/java/forge/card/abilityfactory/AbilityFactory.java
index 4ebc6f4e4db..2dacd9a8b3b 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactory.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactory.java
@@ -68,7 +68,7 @@ public class AbilityFactory {
*
*
* @param af
- * a AbilityFactory object.
+ * a AbilityFactory object.
*/
public AbilityFactory(final AbilityFactory af) {
this.abCost = af.getAbCost();
@@ -100,11 +100,12 @@ public class AbilityFactory {
*
* setHostCard.
*
+ *
* @param host
* a Card object.
*
*/
- public final void setHostCard(Card host) {
+ public final void setHostCard(final Card host) {
this.hostC = host;
}
@@ -212,10 +213,11 @@ public class AbilityFactory {
*
* Setter for the field abTgt.
*
+ *
* @param target
* a target object.
*/
- public final void setAbTgt(Target target) {
+ public final void setAbTgt(final Target target) {
this.abTgt = target;
}
@@ -1487,7 +1489,7 @@ public class AbilityFactory {
/**
*
- * isInstantSpeed. To be used for mana abilities like Lion's Eye Diamond
+ * isInstantSpeed. To be used for mana abilities like Lion's Eye Diamond
*
*
* @param sa
@@ -1552,7 +1554,7 @@ public class AbilityFactory {
// Add whole Remembered list to handlePaid
final CardList list = new CardList();
if (card.getRemembered().isEmpty()) {
- Card newCard = AllZoneUtil.getCardState(card);
+ final Card newCard = AllZoneUtil.getCardState(card);
for (final Object o : newCard.getRemembered()) {
if (o instanceof Card) {
list.add(AllZoneUtil.getCardState((Card) o));
@@ -1692,7 +1694,7 @@ public class AbilityFactory {
// isn't made yet
return 0;
}
- //cost hasn't been paid yet
+ // cost hasn't been paid yet
if (amount.startsWith("Cost")) {
return 0;
}
@@ -1729,12 +1731,15 @@ public class AbilityFactory {
if (defined.equals("Self")) {
c = hostCard;
}
-
+
// The Wretched
else if (defined.equals("TriggeredBlocker.blocking")) {
final SpellAbility root = sa.getRootSpellAbility();
final Object crd = root.getTriggeringObject("Blocker");
- if (AllZoneUtil.getCardState((Card) crd).isBlocking()); {
+ if (AllZoneUtil.getCardState((Card) crd).isBlocking()) {
+ ;
+ }
+ {
c = AllZoneUtil.getCardState((Card) crd);
}
}
@@ -1749,10 +1754,9 @@ public class AbilityFactory {
else if (defined.equals("Enchanted")) {
c = hostCard.getEnchantingCard();
- if (c == null
- && AbilityFactory.findRootAbility(sa) != null
- && AbilityFactory.findRootAbility(sa).getPaidList("Sacrificed") != null
- && !AbilityFactory.findRootAbility(sa).getPaidList("Sacrificed").isEmpty()) {
+ if ((c == null) && (AbilityFactory.findRootAbility(sa) != null)
+ && (AbilityFactory.findRootAbility(sa).getPaidList("Sacrificed") != null)
+ && !AbilityFactory.findRootAbility(sa).getPaidList("Sacrificed").isEmpty()) {
c = AbilityFactory.findRootAbility(sa).getPaidList("Sacrificed").get(0).getEnchantingCard();
}
}
@@ -1796,7 +1800,7 @@ public class AbilityFactory {
}
} else if (defined.equals("Remembered")) {
if (hostCard.getRemembered().isEmpty()) {
- Card newCard = AllZoneUtil.getCardState(hostCard);
+ final Card newCard = AllZoneUtil.getCardState(hostCard);
for (final Object o : newCard.getRemembered()) {
if (o instanceof Card) {
cards.add(AllZoneUtil.getCardState((Card) o));
@@ -1915,7 +1919,7 @@ public class AbilityFactory {
}
for (final SpellAbility s : sas) {
final Player p = s.getActivatingPlayer();
- //final Player p = s.getSourceCard().getController();
+ // final Player p = s.getSourceCard().getController();
if (!players.contains(p)) {
players.add(p);
}
@@ -2569,8 +2573,7 @@ public class AbilityFactory {
};
if (payer.isHuman()) {
- GameActionUtil.payCostDuringAbilityResolve(source + "\r\n", source, unlessCost, paidCommand,
- unpaidCommand);
+ GameActionUtil.payCostDuringAbilityResolve(source + "\r\n", source, unlessCost, paidCommand, unpaidCommand);
} else {
if (ComputerUtil.canPayCost(ability) && CostUtil.checkLifeCost(cost, source, 4)) {
ComputerUtil.playNoStack(ability); // Unless cost was payed - no
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
index b18f50f15fe..f4b289f1e5f 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java
@@ -208,8 +208,8 @@ public final class AbilityFactoryChangeZone {
* @return a boolean.
*/
public static boolean isKnown(final String origin) {
- return (origin.equals("Graveyard") || origin.equals("Exile") || origin.equals("Battlefield") || origin
- .equals("Stack") || origin.equals("Ante"));
+ return (origin.equals("Graveyard") || origin.equals("Exile") || origin.equals("Battlefield")
+ || origin.equals("Stack") || origin.equals("Ante"));
}
/**
@@ -315,9 +315,9 @@ public final class AbilityFactoryChangeZone {
return false;
}
- return changeZoneTriggerAINoCost(af, sa, mandatory);
+ return AbilityFactoryChangeZone.changeZoneTriggerAINoCost(af, sa, mandatory);
}
-
+
/**
*
* changeZoneTriggerAINoCost.
@@ -331,7 +331,8 @@ public final class AbilityFactoryChangeZone {
* a boolean.
* @return a boolean.
*/
- private static boolean changeZoneTriggerAINoCost(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
+ private static boolean changeZoneTriggerAINoCost(final AbilityFactory af, final SpellAbility sa,
+ final boolean mandatory) {
final HashMap params = af.getMapParams();
String origin = "";
if (params.containsKey("Origin")) {
@@ -457,7 +458,7 @@ public final class AbilityFactoryChangeZone {
if ((tgt != null) && tgt.canTgtPlayer()) {
if (af.isCurse() && sa.canTarget(AllZone.getHumanPlayer())) {
tgt.addTarget(AllZone.getHumanPlayer());
- } else if (!af.isCurse() && sa.canTarget(AllZone.getComputerPlayer())){
+ } else if (!af.isCurse() && sa.canTarget(AllZone.getComputerPlayer())) {
tgt.addTarget(AllZone.getComputerPlayer());
}
pDefined = tgt.getTargetPlayers();
@@ -526,7 +527,7 @@ public final class AbilityFactoryChangeZone {
if ((tgt != null) && tgt.canTgtPlayer()) {
if (af.isCurse() && sa.canTarget(AllZone.getHumanPlayer())) {
tgt.addTarget(AllZone.getHumanPlayer());
- } else if (!af.isCurse() && sa.canTarget(AllZone.getComputerPlayer())){
+ } else if (!af.isCurse() && sa.canTarget(AllZone.getComputerPlayer())) {
tgt.addTarget(AllZone.getComputerPlayer());
} else {
return false;
@@ -670,8 +671,7 @@ public final class AbilityFactoryChangeZone {
if (params.containsKey("ExileFaceDown")) {
sb.append(" face down");
}
- }
- else if (destination.equals("Ante")) {
+ } else if (destination.equals("Ante")) {
sb.append("Add the top card of your library to the ante");
}
sb.append(".");
@@ -848,14 +848,14 @@ public final class AbilityFactoryChangeZone {
}
}
- int changeNum = params.containsKey("ChangeNum") ? AbilityFactory.calculateAmount(card,
- params.get("ChangeNum"), sa) : 1;
+ int changeNum = params.containsKey("ChangeNum") ? AbilityFactory.calculateAmount(card, params.get("ChangeNum"),
+ sa) : 1;
CardList fetchList;
if (defined) {
fetchList = new CardList(AbilityFactory.getDefinedCards(card, params.get("Defined"), sa));
if (!params.containsKey("ChangeNum")) {
- changeNum = fetchList.size();
+ changeNum = fetchList.size();
}
} else if (!origin.contains(Zone.Library) && !origin.contains(Zone.Hand)) {
fetchList = AllZoneUtil.getCardsIn(origin);
@@ -866,7 +866,8 @@ public final class AbilityFactoryChangeZone {
if (!defined) {
if (origin.contains(Zone.Library) && !defined) { // Look at whole
// library before
- // moving onto choosing
+ // moving onto
+ // choosing
// a card{
GuiUtils.getChoiceOptional(af.getHostCard().getName() + " - Looking at Library",
player.getCardsIn(Zone.Library).toArray());
@@ -874,8 +875,8 @@ public final class AbilityFactoryChangeZone {
// Look at opponents hand before moving onto choosing a card
if (origin.contains(Zone.Hand) && player.isComputer()) {
- GuiUtils.getChoiceOptional(af.getHostCard().getName() + " - Looking at Opponent's Hand",
- player.getCardsIn(Zone.Hand).toArray());
+ GuiUtils.getChoiceOptional(af.getHostCard().getName() + " - Looking at Opponent's Hand", player
+ .getCardsIn(Zone.Hand).toArray());
}
fetchList = AbilityFactory.filterListByType(fetchList, params.get("ChangeType"), sa);
}
@@ -929,12 +930,14 @@ public final class AbilityFactoryChangeZone {
}
if (params.containsKey("AttachedTo")) {
- ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("AttachedTo"), sa);
+ final ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(),
+ params.get("AttachedTo"), sa);
if (!list.isEmpty()) {
- Card attachedTo = list.get(0);
+ final Card attachedTo = list.get(0);
if (c.isEnchanting()) {
// If this Card is already Enchanting something
- // Need to unenchant it, then clear out the commands
+ // Need to unenchant it, then clear out the
+ // commands
final GameEntity oldEnchanted = c.getEnchanting();
c.removeEnchanting(oldEnchanted);
c.clearEnchantCommand();
@@ -1020,14 +1023,14 @@ public final class AbilityFactoryChangeZone {
type = "Card";
}
- int changeNum = params.containsKey("ChangeNum") ? AbilityFactory.calculateAmount(card,
- params.get("ChangeNum"), sa) : 1;
+ int changeNum = params.containsKey("ChangeNum") ? AbilityFactory.calculateAmount(card, params.get("ChangeNum"),
+ sa) : 1;
CardList fetchList;
if (defined) {
fetchList = new CardList(AbilityFactory.getDefinedCards(card, params.get("Defined"), sa));
if (!params.containsKey("ChangeNum")) {
- changeNum = fetchList.size();
+ changeNum = fetchList.size();
}
} else if (!origin.contains(Zone.Library) && !origin.contains(Zone.Hand)) {
fetchList = AllZoneUtil.getCardsIn(origin);
@@ -1113,9 +1116,10 @@ public final class AbilityFactoryChangeZone {
}
if (params.containsKey("AttachedTo")) {
- ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("AttachedTo"), sa);
+ final ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(),
+ params.get("AttachedTo"), sa);
if (!list.isEmpty()) {
- Card attachedTo = list.get(0);
+ final Card attachedTo = list.get(0);
if (c.isEnchanting()) {
// If this Card is already Enchanting something
// Need to unenchant it, then clear out the commands
@@ -1521,7 +1525,8 @@ public final class AbilityFactoryChangeZone {
if (origin.equals(Zone.Battlefield)
&& destination.equals(Zone.Exile)
&& (subAPI.equals("DelayedTrigger") || (subAPI.equals("ChangeZone") && subAffected.equals("Remembered")))
- && !(AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || sa.isAbility())) {
+ && !(AllZone.getPhaseHandler().is(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || sa
+ .isAbility())) {
return false;
}
@@ -1704,9 +1709,10 @@ public final class AbilityFactoryChangeZone {
if (sa.getTarget() == null) {
// Just in case of Defined cases
if (!mandatory && params.containsKey("AttachedTo")) {
- ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("AttachedTo"), sa);
+ final ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(),
+ params.get("AttachedTo"), sa);
if (!list.isEmpty()) {
- Card attachedTo = list.get(0);
+ final Card attachedTo = list.get(0);
// This code is for the Dragon auras
if (attachedTo.getController().isHuman()) {
return false;
@@ -1932,12 +1938,15 @@ public final class AbilityFactoryChangeZone {
tgtC.addController(af.getHostCard());
}
if (params.containsKey("AttachedTo")) {
- ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("AttachedTo"), sa);
+ final ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(),
+ params.get("AttachedTo"), sa);
if (!list.isEmpty()) {
- Card attachedTo = list.get(0);
+ final Card attachedTo = list.get(0);
if (tgtC.isEnchanting()) {
- // If this Card is already Enchanting something
- // Need to unenchant it, then clear out the commands
+ // If this Card is already Enchanting
+ // something
+ // Need to unenchant it, then clear out the
+ // commands
final GameEntity oldEnchanted = tgtC.getEnchanting();
tgtC.removeEnchanting(oldEnchanted);
tgtC.clearEnchantCommand();
@@ -1955,7 +1964,8 @@ public final class AbilityFactoryChangeZone {
}
}
- movedCard = Singletons.getModel().getGameAction().moveTo(tgtC.getController().getZone(destination), tgtC);
+ movedCard = Singletons.getModel().getGameAction()
+ .moveTo(tgtC.getController().getZone(destination), tgtC);
if (params.containsKey("Ninjutsu") || params.containsKey("Attacking")) {
AllZone.getCombat().addAttacker(tgtC);
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
index 9e1fbf278c3..6e0ab5909f0 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java
@@ -2240,21 +2240,28 @@ public final class AbilityFactoryReveal {
}
}
+ /**
+ * Gets the revealed list.
+ *
+ * @param player the player
+ * @param valid the valid
+ * @param max the max
+ * @return the revealed list
+ */
public static CardList getRevealedList(final Player player, final CardList valid, final int max) {
final CardList chosen = new CardList();
final int validamount = Math.min(valid.size(), max);
-
for (int i = 0; i < validamount; i++) {
if (player.isHuman()) {
final Object o = GuiUtils.getChoiceOptional("Choose card(s) to reveal", valid.toArray());
- if (o != null) {
- chosen.add((Card) o);
- valid.remove((Card) o);
- } else {
- break;
- }
- } else { //Computer
+ if (o != null) {
+ chosen.add((Card) o);
+ valid.remove((Card) o);
+ } else {
+ break;
+ }
+ } else { // Computer
chosen.add(valid.get(0));
valid.remove(valid.get(0));
}
diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java
index 2c00e3d9f9e..82e3a1845f8 100644
--- a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java
+++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java
@@ -468,7 +468,7 @@ public class AbilityFactorySacrifice {
card.addRemembered(toSac);
}
}
- } else if (valid.equals("TriggeredCard")) {
+ } else if (valid.equals("TriggeredCard")) {
final Card equipee = (Card) sa.getTriggeringObject("Card");
if (tgts.contains(card.getController()) && AllZoneUtil.isCardInPlay(equipee)) {
Singletons.getModel().getGameAction().sacrifice(equipee);
@@ -549,7 +549,7 @@ public class AbilityFactorySacrifice {
*/
private static CardList sacrificeHuman(final Player p, final int amount, final String valid, final SpellAbility sa,
final boolean destroy, final boolean optional) {
- CardList saccedList = new CardList();
+ final CardList saccedList = new CardList();
CardList list = p.getCardsIn(Zone.Battlefield);
list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java
index b15aa3e6e1e..1adab9643c8 100644
--- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java
+++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java
@@ -592,7 +592,7 @@ public class CardFactoryUtil {
value -= 20; // not used atm
}
- for (SpellAbility sa : c.getSpellAbilities()) {
+ for (final SpellAbility sa : c.getSpellAbilities()) {
if (sa.isAbility()) {
value += 10;
}
@@ -1339,7 +1339,8 @@ public class CardFactoryUtil {
// An animated artifact equipmemt can't equip a creature
@Override
public boolean canPlay() {
- return super.canPlay() && !sourceCard.isCreature() && PhaseHandler.canCastSorcery(sourceCard.getController());
+ return super.canPlay() && !sourceCard.isCreature()
+ && PhaseHandler.canCastSorcery(sourceCard.getController());
}
@Override
@@ -1359,8 +1360,8 @@ public class CardFactoryUtil {
@Override
public boolean addCard(final Card c) {
return c.isCreature()
- && (CombatUtil.canAttack(c) || (CombatUtil.canAttackNextTurn(c) && AllZone.getPhaseHandler()
- .is(Constant.Phase.MAIN2)))
+ && (CombatUtil.canAttack(c) || (CombatUtil.canAttackNextTurn(c) && AllZone
+ .getPhaseHandler().is(Constant.Phase.MAIN2)))
&& (((c.getNetDefense() + tough) > 0) || sourceCard.getName().equals("Skullclamp"));
}
});
@@ -1763,7 +1764,8 @@ public class CardFactoryUtil {
@Override
public void selectCard(final Card card, final PlayerZone zone) {
if (targeted && !card.canBeTargetedBy(spell)) {
- Singletons.getControl().getControlMatch().showMessage("Cannot target this card (Shroud? Protection?).");
+ Singletons.getControl().getControlMatch()
+ .showMessage("Cannot target this card (Shroud? Protection?).");
} else if (choices.contains(card)) {
spell.setTargetCard(card);
if (spell.getManaCost().equals("0") || free) {
@@ -1879,56 +1881,36 @@ public class CardFactoryUtil {
* @return input
*/
/*
- public static Input inputDiscardRecall(final int numCards, final Card recall, final SpellAbility sa) {
- final Input target = new Input() {
- private static final long serialVersionUID = 1942999595292561944L;
- private int n = 0;
-
- @Override
- public void showMessage() {
- if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) {
- this.stop();
- }
-
- Singletons.getControl().getControlMatch().showMessage("Select a card to discard");
- ButtonUtil.disableAll();
- }
-
- @Override
- public void selectCard(final Card card, final PlayerZone zone) {
- if (zone.is(Constant.Zone.Hand)) {
- card.getController().discard(card, sa);
- this.n++;
-
- // in case no more cards in hand
- if ((this.n == numCards) || (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0)) {
- this.done();
- } else {
- this.showMessage();
- }
- }
- }
-
- void done() {
- Singletons.getControl().getControlMatch().showMessage("Returning cards to hand.");
- Singletons.getModel().getGameAction().exile(recall);
- final CardList grave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard);
- for (int i = 1; i <= this.n; i++) {
- final String title = "Return card from grave to hand";
- final Object o = GuiUtils.getChoice(title, grave.toArray());
- if (o == null) {
- break;
- }
- final Card toHand = (Card) o;
- grave.remove(toHand);
- Singletons.getModel().getGameAction().moveToHand(toHand);
- }
- this.stop();
- }
- };
- return target;
- } // input_discardRecall()
- */
+ * public static Input inputDiscardRecall(final int numCards, final Card
+ * recall, final SpellAbility sa) { final Input target = new Input() {
+ * private static final long serialVersionUID = 1942999595292561944L;
+ * private int n = 0;
+ *
+ * @Override public void showMessage() { if
+ * (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { this.stop();
+ * }
+ *
+ * Singletons.getControl().getControlMatch().showMessage(
+ * "Select a card to discard"); ButtonUtil.disableAll(); }
+ *
+ * @Override public void selectCard(final Card card, final PlayerZone zone)
+ * { if (zone.is(Constant.Zone.Hand)) { card.getController().discard(card,
+ * sa); this.n++;
+ *
+ * // in case no more cards in hand if ((this.n == numCards) ||
+ * (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0)) { this.done();
+ * } else { this.showMessage(); } } }
+ *
+ * void done() { Singletons.getControl().getControlMatch().showMessage(
+ * "Returning cards to hand.");
+ * Singletons.getModel().getGameAction().exile(recall); final CardList grave
+ * = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); for (int i = 1; i
+ * <= this.n; i++) { final String title = "Return card from grave to hand";
+ * final Object o = GuiUtils.getChoice(title, grave.toArray()); if (o ==
+ * null) { break; } final Card toHand = (Card) o; grave.remove(toHand);
+ * Singletons.getModel().getGameAction().moveToHand(toHand); } this.stop();
+ * } }; return target; } // input_discardRecall()
+ */
/**
*
@@ -2384,7 +2366,8 @@ public class CardFactoryUtil {
// returns the number of equipments named "e" card c is equipped by
/**
*
- * Gets the number of equipments with a given name that a given card is equipped by.
+ * Gets the number of equipments with a given name that a given card is
+ * equipped by.
*
*
* @param card
@@ -2421,14 +2404,14 @@ public class CardFactoryUtil {
* @return a {@link forge.CardList} object.
*/
public static CardList getExternalZoneActivationCards(final Player activator) {
- CardList cl = new CardList();
- Player opponent = activator.getOpponent();
+ final CardList cl = new CardList();
+ final Player opponent = activator.getOpponent();
- cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Graveyard), activator));
- cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Exile), activator));
- cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Library), activator));
- cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Command), activator));
- cl.addAll(getActivateablesFromZone(opponent.getZone(Constant.Zone.Exile), activator));
+ cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Graveyard), activator));
+ cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Exile), activator));
+ cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Library), activator));
+ cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Command), activator));
+ cl.addAll(CardFactoryUtil.getActivateablesFromZone(opponent.getZone(Constant.Zone.Exile), activator));
return cl;
}
@@ -2448,7 +2431,7 @@ public class CardFactoryUtil {
CardList cl = new CardList(zone.getCards());
- //Only check the top card of the library
+ // Only check the top card of the library
if (zone.is(Constant.Zone.Library) && !cl.isEmpty()) {
cl = new CardList(cl.get(0));
}
@@ -2463,9 +2446,9 @@ public class CardFactoryUtil {
}
}
- if (c.isLand() && (c.hasKeyword("May be played")
- || c.hasKeyword("May be played by your opponent")
- || c.hasKeyword("May be played without paying its mana cost"))) {
+ if (c.isLand()
+ && (c.hasKeyword("May be played") || c.hasKeyword("May be played by your opponent") || c
+ .hasKeyword("May be played without paying its mana cost"))) {
return true;
}
@@ -2476,11 +2459,10 @@ public class CardFactoryUtil {
}
if (sa.isSpell()
- && (c.hasKeyword("May be played")
- || c.hasKeyword("May be played by your Opponent")
- || c.hasKeyword("May be played without paying its mana cost")
- || (c.hasStartOfKeyword("Flashback") && zone
- .is(Zone.Graveyard))) && restrictZone.equals(Zone.Hand)) {
+ && (c.hasKeyword("May be played") || c.hasKeyword("May be played by your Opponent")
+ || c.hasKeyword("May be played without paying its mana cost") || (c
+ .hasStartOfKeyword("Flashback") && zone.is(Zone.Graveyard)))
+ && restrictZone.equals(Zone.Hand)) {
return true;
}
}
@@ -2714,7 +2696,7 @@ public class CardFactoryUtil {
if (l[0].startsWith("SVar$")) {
final String sVar = l[0].replace("SVar$", "");
- return CardFactoryUtil.doXMath(xCount(c, c.getSVar(sVar)), m, c);
+ return CardFactoryUtil.doXMath(CardFactoryUtil.xCount(c, c.getSVar(sVar)), m, c);
}
// Manapool
@@ -2761,7 +2743,7 @@ public class CardFactoryUtil {
}
return highest;
}
-
+
if (l[0].contains("HighestCMCRemembered")) {
final CardList list = new CardList();
int highest = 0;
@@ -2932,13 +2914,13 @@ public class CardFactoryUtil {
// Count$YourTypeDamageThisTurn Type
if (sq[0].contains("OppTypeDamageThisTurn")) {
- String[] type = sq[0].split(" ");
+ final String[] type = sq[0].split(" ");
return CardFactoryUtil.doXMath(c.getController().getOpponent().getAssignedDamage(type[1]), m, c);
}
// Count$YourTypeDamageThisTurn Type
if (sq[0].contains("YourTypeDamageThisTurn")) {
- String[] type = sq[0].split(" ");
+ final String[] type = sq[0].split(" ");
return CardFactoryUtil.doXMath(c.getController().getAssignedDamage(type[1]), m, c);
}
@@ -3013,8 +2995,8 @@ public class CardFactoryUtil {
// Count$wasCastFrom..
if (sq[0].startsWith("wasCastFrom")) {
- String strZone = sq[0].substring(11);
- Zone realZone = Zone.smartValueOf(strZone);
+ final String strZone = sq[0].substring(11);
+ final Zone realZone = Zone.smartValueOf(strZone);
if (c.getCastFrom() == realZone) {
return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c);
} else {
@@ -3679,8 +3661,8 @@ public class CardFactoryUtil {
/**
*
- * Get the total cost to pay for an attacker c, due to cards like Propaganda,
- * Ghostly Prison, Collective Restraint, ...
+ * Get the total cost to pay for an attacker c, due to cards like
+ * Propaganda, Ghostly Prison, Collective Restraint, ...
*
*
* @param c
@@ -3812,7 +3794,7 @@ public class CardFactoryUtil {
for (final String kw : intrinsicKeywords) {
if (kw.startsWith("HIDDEN")) {
temp.addExtrinsicKeyword(kw);
- //extrinsic keywords won't survive the copyStats treatment
+ // extrinsic keywords won't survive the copyStats treatment
} else {
temp.addIntrinsicKeyword(kw);
}
@@ -4105,8 +4087,8 @@ public class CardFactoryUtil {
* "When CARDNAME becomes the target of a spell or ability, return CARDNAME to its owner's hand."
* ) ) { // || (c.isCreature() && AllZoneUtil.isCardInPlay("Cowardice"))
* SpellAbility ability = new Ability(c, "0") { public void resolve() {
- * Singletons.getModel().getGameAction().moveToHand(c); } }; StringBuilder sb = new
- * StringBuilder();
+ * Singletons.getModel().getGameAction().moveToHand(c); } }; StringBuilder
+ * sb = new StringBuilder();
* sb.append(c).append(" - return CARDNAME to its owner's hand.");
* ability.setStackDescription(sb.toString());
*
@@ -4115,15 +4097,15 @@ public class CardFactoryUtil {
* ) || AllZoneUtil.isCardInPlay("Horobi, Death's Wail")) {
*
* SpellAbility ability = new Ability(c, "0") { public void resolve() {
- * Singletons.getModel().getGameAction().destroy(c); } }; StringBuilder sb = new
- * StringBuilder(); sb.append(c).append(" - destroy CARDNAME.");
+ * Singletons.getModel().getGameAction().destroy(c); } }; StringBuilder sb =
+ * new StringBuilder(); sb.append(c).append(" - destroy CARDNAME.");
* ability.setStackDescription(sb.toString());
*
* AllZone.getStack().add(ability); } if (c.hasKeyword(
* "When CARDNAME becomes the target of a spell or ability, sacrifice it."))
* { SpellAbility ability = new Ability(c, "0") { public void resolve() {
- * Singletons.getModel().getGameAction().sacrifice(c); } }; StringBuilder sb = new
- * StringBuilder(); sb.append(c).append(" - sacrifice CARDNAME.");
+ * Singletons.getModel().getGameAction().sacrifice(c); } }; StringBuilder sb
+ * = new StringBuilder(); sb.append(c).append(" - sacrifice CARDNAME.");
* ability.setStackDescription(sb.toString());
*
* AllZone.getStack().add(ability); }
@@ -4157,12 +4139,12 @@ public class CardFactoryUtil {
* if(action[0].startsWith("exile")) {
* Singletons.getModel().getGameAction().exile(target); } else
* if(action[0].startsWith("destroy")) { if(noRegen) {
- * Singletons.getModel().getGameAction().destroyNoRegeneration(target); } else {
- * Singletons.getModel().getGameAction().destroy(target); } } else
+ * Singletons.getModel().getGameAction().destroyNoRegeneration(target); }
+ * else { Singletons.getModel().getGameAction().destroy(target); } } else
* if(action[0].startsWith("sacrifice")) {
- * Singletons.getModel().getGameAction().sacrifice(target); } else { throw new
- * IllegalArgumentException("There is a problem in the keyword " + keyword +
- * "for card \"" + c.getName() + "\""); } } };
+ * Singletons.getModel().getGameAction().sacrifice(target); } else { throw
+ * new IllegalArgumentException("There is a problem in the keyword " +
+ * keyword + "for card \"" + c.getName() + "\""); } } };
*
* saTrigger.setStackDescription(stackDesc);
*
@@ -4756,7 +4738,8 @@ public class CardFactoryUtil {
AllZone.getStack().add(haunterDiesWork);
this.stop();
} else {
- Singletons.getControl().getControlMatch().showMessage("Cannot target this card (Shroud? Protection?).");
+ Singletons.getControl().getControlMatch()
+ .showMessage("Cannot target this card (Shroud? Protection?).");
}
}
};
diff --git a/src/main/java/forge/card/spellability/SpellAbility.java b/src/main/java/forge/card/spellability/SpellAbility.java
index 155269a526c..758b1250522 100644
--- a/src/main/java/forge/card/spellability/SpellAbility.java
+++ b/src/main/java/forge/card/spellability/SpellAbility.java
@@ -991,7 +991,7 @@ public abstract class SpellAbility {
/**
* Gets the replacing objects.
- *
+ *
* @return the replacing objects
*/
public HashMap getReplacingObjects() {
@@ -1000,8 +1000,9 @@ public abstract class SpellAbility {
/**
* Sets the all replacing objects.
- *
- * @param replacedObjects the replaced objects
+ *
+ * @param replacedObjects
+ * the replaced objects
*/
public void setAllReplacingObjects(final HashMap replacedObjects) {
this.replacingObjects = replacedObjects;
@@ -1009,9 +1010,11 @@ public abstract class SpellAbility {
/**
* Sets the replacing object.
- *
- * @param type the type
- * @param o the o
+ *
+ * @param type
+ * the type
+ * @param o
+ * the o
*/
public void setReplacingObject(final String type, final Object o) {
this.replacingObjects.put(type, o);
@@ -1019,19 +1022,21 @@ public abstract class SpellAbility {
/**
* Gets the replacing object.
- *
- * @param type the type
+ *
+ * @param type
+ * the type
* @return the replacing object
*/
public Object getReplacingObject(final String type) {
- Object res = this.replacingObjects.get(type);
+ final Object res = this.replacingObjects.get(type);
return res;
}
/**
* Checks for replacing object.
- *
- * @param type the type
+ *
+ * @param type
+ * the type
* @return true, if successful
*/
public boolean hasReplacingObject(final String type) {
@@ -1602,7 +1607,7 @@ public abstract class SpellAbility {
return res;
}
-
+
/**
*
* canTarget.
@@ -1613,7 +1618,7 @@ public abstract class SpellAbility {
* @return a boolean.
*/
public final boolean canTarget(final GameEntity entity) {
- if (entity.isValid(this.getTarget().getValidTgts(), this.getActivatingPlayer(), this.getSourceCard())
+ if (entity.isValid(this.getTarget().getValidTgts(), this.getActivatingPlayer(), this.getSourceCard())
&& entity.canBeTargetedBy(this)) {
return true;
}
diff --git a/src/main/java/forge/control/home/ControlUtilities.java b/src/main/java/forge/control/home/ControlUtilities.java
index cf11fa1d6c7..cf934ec2c8b 100644
--- a/src/main/java/forge/control/home/ControlUtilities.java
+++ b/src/main/java/forge/control/home/ControlUtilities.java
@@ -1,3 +1,20 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Nate
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package forge.control.home;
import java.awt.event.MouseAdapter;
@@ -25,54 +42,73 @@ import forge.properties.NewConstants.Lang;
import forge.view.home.ViewUtilities;
import forge.view.toolbox.FSkin;
-/**
+/**
* Controls logic and listeners for Utilities panel of the home screen.
- *
+ *
*/
public class ControlUtilities {
- private ViewUtilities view;
+ private final ViewUtilities view;
private final MouseListener madLicensing;
- private final Command cmdDeckEditor, cmdPicDownload, cmdSetDownload,
- cmdQuestImages, cmdReportBug, cmdImportPictures, cmdHowToPlay, cmdDownloadPrices;
+ private final Command cmdDeckEditor, cmdPicDownload, cmdSetDownload, cmdQuestImages, cmdReportBug,
+ cmdImportPictures, cmdHowToPlay, cmdDownloadPrices;
/**
*
* Controls logic and listeners for Utilities panel of the home screen.
*
- * @param v0 ViewUtilities
+ * @param v0
+ * ViewUtilities
*/
@SuppressWarnings("serial")
- public ControlUtilities(ViewUtilities v0) {
+ public ControlUtilities(final ViewUtilities v0) {
this.view = v0;
- madLicensing = new MouseAdapter() {
+ this.madLicensing = new MouseAdapter() {
@Override
- public void mouseClicked(MouseEvent e) {
- view.showLicensing();
+ public void mouseClicked(final MouseEvent e) {
+ ControlUtilities.this.view.showLicensing();
}
+
@Override
- public void mouseEntered(MouseEvent e) {
- view.getLblLicensing().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
+ public void mouseEntered(final MouseEvent e) {
+ ControlUtilities.this.view.getLblLicensing().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
}
+
@Override
- public void mouseExited(MouseEvent e) {
- view.getLblLicensing().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
+ public void mouseExited(final MouseEvent e) {
+ ControlUtilities.this.view.getLblLicensing().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
}
};
- cmdDeckEditor = new Command() { @Override
- public void execute() { showDeckEditor(GameType.Constructed, null); } };
+ this.cmdDeckEditor = new Command() {
+ @Override
+ public void execute() {
+ ControlUtilities.this.showDeckEditor(GameType.Constructed, null);
+ }
+ };
- cmdPicDownload = new Command() { @Override
- public void execute() { doDownloadPics(); } };
+ this.cmdPicDownload = new Command() {
+ @Override
+ public void execute() {
+ ControlUtilities.this.doDownloadPics();
+ }
+ };
- cmdSetDownload = new Command() { @Override
- public void execute() { doDownloadSetPics(); } };
+ this.cmdSetDownload = new Command() {
+ @Override
+ public void execute() {
+ ControlUtilities.this.doDownloadSetPics();
+ }
+ };
- cmdQuestImages = new Command() { @Override
- public void execute() { doDownloadQuestImages(); } };
+ this.cmdQuestImages = new Command() {
+ @Override
+ public void execute() {
+ ControlUtilities.this.doDownloadQuestImages();
+ }
+ };
- cmdReportBug = new Command() {
+ this.cmdReportBug = new Command() {
@Override
public void execute() {
final BugzReporter br = new BugzReporter();
@@ -80,7 +116,7 @@ public class ControlUtilities {
}
};
- cmdImportPictures = new Command() {
+ this.cmdImportPictures = new Command() {
@Override
public void execute() {
final GuiImportPicture ip = new GuiImportPicture(null);
@@ -88,7 +124,7 @@ public class ControlUtilities {
}
};
- cmdHowToPlay = new Command() {
+ this.cmdHowToPlay = new Command() {
@Override
public void execute() {
final String text = ForgeProps.getLocalized(Lang.HowTo.MESSAGE);
@@ -104,7 +140,7 @@ public class ControlUtilities {
}
};
- cmdDownloadPrices = new Command() {
+ this.cmdDownloadPrices = new Command() {
@Override
public void execute() {
final GuiDownloadPrices gdp = new GuiDownloadPrices();
@@ -112,27 +148,33 @@ public class ControlUtilities {
}
};
- addListeners();
+ this.addListeners();
}
- /** @return ViewUtilities */
+ /**
+ * Gets the view.
+ *
+ * @return ViewUtilities
+ */
public ViewUtilities getView() {
- return view;
+ return this.view;
}
- /** */
+ /**
+ * Adds the listeners.
+ */
public void addListeners() {
- this.view.getBtnDownloadPics().setCommand(cmdPicDownload);
- this.view.getBtnDownloadSetPics().setCommand(cmdSetDownload);
- this.view.getBtnDownloadQuestImages().setCommand(cmdQuestImages);
- this.view.getBtnReportBug().setCommand(cmdReportBug);
- this.view.getBtnImportPictures().setCommand(cmdImportPictures);
- this.view.getBtnHowToPlay().setCommand(cmdHowToPlay);
- this.view.getBtnDownloadPrices().setCommand(cmdDownloadPrices);
- this.view.getBtnDeckEditor().setCommand(cmdDeckEditor);
+ this.view.getBtnDownloadPics().setCommand(this.cmdPicDownload);
+ this.view.getBtnDownloadSetPics().setCommand(this.cmdSetDownload);
+ this.view.getBtnDownloadQuestImages().setCommand(this.cmdQuestImages);
+ this.view.getBtnReportBug().setCommand(this.cmdReportBug);
+ this.view.getBtnImportPictures().setCommand(this.cmdImportPictures);
+ this.view.getBtnHowToPlay().setCommand(this.cmdHowToPlay);
+ this.view.getBtnDownloadPrices().setCommand(this.cmdDownloadPrices);
+ this.view.getBtnDeckEditor().setCommand(this.cmdDeckEditor);
- this.view.getLblLicensing().removeMouseListener(madLicensing);
- this.view.getLblLicensing().addMouseListener(madLicensing);
+ this.view.getLblLicensing().removeMouseListener(this.madLicensing);
+ this.view.getLblLicensing().addMouseListener(this.madLicensing);
}
private void doDownloadPics() {
@@ -148,11 +190,14 @@ public class ControlUtilities {
}
/**
+ * Show deck editor.
+ *
+ * @param the generic type
* @param gt0 GameType
* @param d0 Deck
*/
@SuppressWarnings("unchecked")
- public void showDeckEditor(GameType gt0, T d0) {
+ public void showDeckEditor(final GameType gt0, final T d0) {
DeckEditorBase, T> editor = null;
if (gt0 == GameType.Constructed) {
@@ -163,14 +208,13 @@ public class ControlUtilities {
editor = (DeckEditorBase, T>) new DeckEditorLimited(Singletons.getModel().getDecks().getSealed());
}
-
final Command exit = new Command() {
private static final long serialVersionUID = -9133358399503226853L;
@Override
public void execute() {
Singletons.getControl().getControlHome().getControlConstructed().updateDeckLists();
- //view.getParentView().getControlSealed().updateDeckLists();
+ // view.getParentView().getControlSealed().updateDeckLists();
}
};
diff --git a/src/main/java/forge/deck/CardCollections.java b/src/main/java/forge/deck/CardCollections.java
index 83a5d3dec9e..c05d2f8744e 100644
--- a/src/main/java/forge/deck/CardCollections.java
+++ b/src/main/java/forge/deck/CardCollections.java
@@ -1,17 +1,33 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Nate
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package forge.deck;
import java.io.File;
-import forge.deck.io.DeckSerializer;
import forge.deck.io.DeckGroupSerializer;
+import forge.deck.io.DeckSerializer;
import forge.deck.io.OldDeckParser;
import forge.util.FolderMap;
import forge.util.IFolderMap;
-
-/**
- * Holds editable maps of decks saved to disk.
- * Adding or removing items to(from) such map turns into immediate file update
+/**
+ * Holds editable maps of decks saved to disk. Adding or removing items to(from)
+ * such map turns into immediate file update
*/
public class CardCollections {
private final IFolderMap constructed;
@@ -21,35 +37,54 @@ public class CardCollections {
/**
* TODO: Write javadoc for Constructor.
- * @param file
+ *
+ * @param file the file
*/
- public CardCollections(File file) {
- constructed = new FolderMap(new DeckSerializer(new File(file, "constructed")));
- draft = new FolderMap(new DeckGroupSerializer(new File(file, "draft")));
- sealed = new FolderMap(new DeckGroupSerializer(new File(file, "sealed")));
- cube = new FolderMap(new DeckSerializer(new File(file, "cube")));
+ public CardCollections(final File file) {
+ this.constructed = new FolderMap(new DeckSerializer(new File(file, "constructed")));
+ this.draft = new FolderMap(new DeckGroupSerializer(new File(file, "draft")));
+ this.sealed = new FolderMap(new DeckGroupSerializer(new File(file, "sealed")));
+ this.cube = new FolderMap(new DeckSerializer(new File(file, "cube")));
// remove this after most people have been switched to new layout
- OldDeckParser oldParser = new OldDeckParser(file, constructed, draft, sealed, cube);
+ final OldDeckParser oldParser = new OldDeckParser(file, this.constructed, this.draft, this.sealed, this.cube);
oldParser.tryParse();
}
+ /**
+ * Gets the constructed.
+ *
+ * @return the constructed
+ */
public final IFolderMap getConstructed() {
- return constructed;
+ return this.constructed;
}
+ /**
+ * Gets the draft.
+ *
+ * @return the draft
+ */
public final IFolderMap getDraft() {
- return draft;
+ return this.draft;
}
+ /**
+ * Gets the cubes.
+ *
+ * @return the cubes
+ */
public final IFolderMap getCubes() {
- return cube;
+ return this.cube;
}
+ /**
+ * Gets the sealed.
+ *
+ * @return the sealed
+ */
public IFolderMap getSealed() {
- return sealed;
+ return this.sealed;
}
-
-
}
diff --git a/src/main/java/forge/deck/Deck.java b/src/main/java/forge/deck/Deck.java
index 48ab734b928..af2ef2ad6e5 100644
--- a/src/main/java/forge/deck/Deck.java
+++ b/src/main/java/forge/deck/Deck.java
@@ -66,9 +66,16 @@ public class Deck extends DeckBase implements Serializable, IHasName {
* Decks have their named finalled.
*
*/
- public Deck() { this(""); }
+ public Deck() {
+ this("");
+ }
- public Deck(String name0) {
+ /**
+ * Instantiates a new deck.
+ *
+ * @param name0 the name0
+ */
+ public Deck(final String name0) {
super(name0);
this.main = new DeckSection();
this.sideboard = new DeckSection();
@@ -92,7 +99,6 @@ public class Deck extends DeckBase implements Serializable, IHasName {
return this.getName();
}
-
/**
*
* Getter for the field main.
@@ -115,53 +121,79 @@ public class Deck extends DeckBase implements Serializable, IHasName {
return this.sideboard;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.item.CardCollectionBase#getCardPool()
*/
@Override
public ItemPoolView getCardPool() {
- return main;
+ return this.main;
}
- protected void cloneFieldsTo(DeckBase clone) {
+ /* (non-Javadoc)
+ * @see forge.deck.DeckBase#cloneFieldsTo(forge.deck.DeckBase)
+ */
+ @Override
+ protected void cloneFieldsTo(final DeckBase clone) {
super.cloneFieldsTo(clone);
- Deck result = (Deck) clone;
+ final Deck result = (Deck) clone;
result.main.addAll(this.main);
result.sideboard.addAll(this.sideboard);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.deck.DeckBase#newInstance(java.lang.String)
*/
@Override
- protected DeckBase newInstance(String name0) {
+ protected DeckBase newInstance(final String name0) {
return new Deck(name0);
}
-
+ /**
+ * From file.
+ *
+ * @param deckFile the deck file
+ * @return the deck
+ */
public static Deck fromFile(final File deckFile) {
- return fromSections(SectionUtil.parseSections(FileUtil.readFile(deckFile)));
+ return Deck.fromSections(SectionUtil.parseSections(FileUtil.readFile(deckFile)));
}
- public static Deck fromSections(Map> sections) {
- return fromSections(sections, false);
+ /**
+ * From sections.
+ *
+ * @param sections the sections
+ * @return the deck
+ */
+ public static Deck fromSections(final Map> sections) {
+ return Deck.fromSections(sections, false);
}
-
- public static Deck fromSections(Map> sections, boolean canThrowExtendedErrors) {
- if (sections == null || sections.isEmpty()) {
+
+ /**
+ * From sections.
+ *
+ * @param sections the sections
+ * @param canThrowExtendedErrors the can throw extended errors
+ * @return the deck
+ */
+ public static Deck fromSections(final Map> sections, final boolean canThrowExtendedErrors) {
+ if ((sections == null) || sections.isEmpty()) {
return null;
}
- DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections, canThrowExtendedErrors);
+ final DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections, canThrowExtendedErrors);
if (dh == null) {
- return null;
+ return null;
}
final Deck d = new Deck(dh.getName());
d.setComment(dh.getComment());
- d.getMain().set(readCardList(sections.get("main")));
- d.getSideboard().set(readCardList(sections.get("sideboard")));
+ d.getMain().set(Deck.readCardList(sections.get("main")));
+ d.getSideboard().set(Deck.readCardList(sections.get("sideboard")));
return d;
}
@@ -213,37 +245,29 @@ public class Deck extends DeckBase implements Serializable, IHasName {
return out;
}
-
-
/**
*
* writeDeck.
*
- *
- * @param d
- * a {@link forge.deck.Deck} object.
- * @param out
- * a {@link java.io.BufferedWriter} object.
- * @throws java.io.IOException
- * if any.
+ *
+ * @return the list
*/
public List save() {
-
final List out = new ArrayList();
out.add(String.format("[metadata]"));
- out.add(String.format("%s=%s", DeckFileHeader.NAME, getName().replaceAll("\n", "")));
+ out.add(String.format("%s=%s", DeckFileHeader.NAME, this.getName().replaceAll("\n", "")));
// these are optional
- if (getComment() != null) {
- out.add(String.format("%s=%s", DeckFileHeader.COMMENT, getComment().replaceAll("\n", "")));
+ if (this.getComment() != null) {
+ out.add(String.format("%s=%s", DeckFileHeader.COMMENT, this.getComment().replaceAll("\n", "")));
}
out.add(String.format("%s", "[main]"));
- out.addAll(writeCardPool(getMain()));
+ out.addAll(Deck.writeCardPool(this.getMain()));
out.add(String.format("%s", "[sideboard]"));
- out.addAll(writeCardPool(getSideboard()));
+ out.addAll(Deck.writeCardPool(this.getSideboard()));
return out;
}
}
diff --git a/src/main/java/forge/deck/DeckBase.java b/src/main/java/forge/deck/DeckBase.java
index d3d61495a73..98db1e45c19 100644
--- a/src/main/java/forge/deck/DeckBase.java
+++ b/src/main/java/forge/deck/DeckBase.java
@@ -1,13 +1,31 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Nate
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package forge.deck;
import java.io.Serializable;
+
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
import forge.util.IHasName;
-/**
+/**
* TODO: Write javadoc for this type.
- *
+ *
*/
public abstract class DeckBase implements IHasName, Serializable, Comparable {
private static final long serialVersionUID = -7538150536939660052L;
@@ -16,10 +34,18 @@ public abstract class DeckBase implements IHasName, Serializable, Comparable getCardPool();
+ /**
+ * Sets the comment.
+ *
+ * @param comment the new comment
+ */
public void setComment(final String comment) {
this.comment = comment;
}
@@ -57,20 +96,42 @@ public abstract class DeckBase implements IHasName, Serializable, Comparable.
+ */
package forge.deck;
import java.util.ArrayList;
@@ -7,51 +24,90 @@ import forge.item.CardPrinted;
import forge.item.ItemPoolView;
import forge.util.IHasName;
-
-/**
+/**
* TODO: Write javadoc for this type.
- *
+ *
*/
public class DeckGroup extends DeckBase implements IHasName {
- public DeckGroup(String name0) {
+ /**
+ * Instantiates a new deck group.
+ *
+ * @param name0 the name0
+ */
+ public DeckGroup(final String name0) {
super(name0);
}
private static final long serialVersionUID = -1628725522049635829L;
private Deck humanDeck;
- private List aiDecks = new ArrayList();
+ private final List aiDecks = new ArrayList();
+ /**
+ * Gets the human deck.
+ *
+ * @return the human deck
+ */
public final Deck getHumanDeck() {
- return humanDeck;
+ return this.humanDeck;
}
- public final List getAiDecks() {
- return aiDecks;
- }
- public final void setHumanDeck(Deck humanDeck) { this.humanDeck = humanDeck; }
- public final void addAiDeck(Deck aiDeck) {
+ /**
+ * Gets the ai decks.
+ *
+ * @return the ai decks
+ */
+ public final List getAiDecks() {
+ return this.aiDecks;
+ }
+
+ /**
+ * Sets the human deck.
+ *
+ * @param humanDeck the new human deck
+ */
+ public final void setHumanDeck(final Deck humanDeck) {
+ this.humanDeck = humanDeck;
+ }
+
+ /**
+ * Adds the ai deck.
+ *
+ * @param aiDeck the ai deck
+ */
+ public final void addAiDeck(final Deck aiDeck) {
if (aiDeck == null) {
return;
}
this.aiDecks.add(aiDeck);
}
+ /* (non-Javadoc)
+ * @see forge.deck.DeckBase#getCardPool()
+ */
@Override
public ItemPoolView getCardPool() {
- return getHumanDeck().getMain();
+ return this.getHumanDeck().getMain();
}
- public void addAiDecks(Deck[] computer) {
- for (int i = 0; i < computer.length; i++) {
- aiDecks.add(computer[i]);
+ /**
+ * Adds the ai decks.
+ *
+ * @param computer the computer
+ */
+ public void addAiDecks(final Deck[] computer) {
+ for (final Deck element : computer) {
+ this.aiDecks.add(element);
}
}
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see forge.deck.DeckBase#newInstance(java.lang.String)
*/
@Override
- protected DeckBase newInstance(String name0) {
+ protected DeckBase newInstance(final String name0) {
return new DeckGroup(name0);
}
diff --git a/src/main/java/forge/deck/DeckRecognizer.java b/src/main/java/forge/deck/DeckRecognizer.java
index d71a19a9b63..b441ffbd245 100644
--- a/src/main/java/forge/deck/DeckRecognizer.java
+++ b/src/main/java/forge/deck/DeckRecognizer.java
@@ -198,7 +198,7 @@ public class DeckRecognizer {
if (CardDb.instance().isCardSupported(name)) {
return Token.knownCard(CardDb.instance().getCard(name, true), n);
}
-
+
// TODO: recognize format: http://topdeck.ru/forum/index.php?showtopic=12711
//final Matcher foundEditionName = READ_SEPARATED_EDITION.matcher(name);
diff --git a/src/main/java/forge/deck/DeckSection.java b/src/main/java/forge/deck/DeckSection.java
index 661e0e98ddd..e6eb3e41081 100644
--- a/src/main/java/forge/deck/DeckSection.java
+++ b/src/main/java/forge/deck/DeckSection.java
@@ -38,15 +38,21 @@ public class DeckSection extends ItemPool {
super(CardPrinted.class);
}
- public DeckSection(Iterable> cards) {
+ /**
+ * Instantiates a new deck section.
+ *
+ * @param cards the cards
+ */
+ public DeckSection(final Iterable> cards) {
this();
- addAll(cards);
+ this.addAll(cards);
}
/**
* Sets the.
- *
- * @param cardNames the card names
+ *
+ * @param cardNames
+ * the card names
*/
public void set(final Iterable cardNames) {
this.clear();
@@ -55,8 +61,9 @@ public class DeckSection extends ItemPool {
/**
* Adds the.
- *
- * @param card the card
+ *
+ * @param card
+ * the card
*/
public void add(final Card card) {
this.add(CardDb.instance().getCard(card));
@@ -64,9 +71,11 @@ public class DeckSection extends ItemPool {
/**
* Adds the.
- *
- * @param cardName the card name
- * @param setCode the set code
+ *
+ * @param cardName
+ * the card name
+ * @param setCode
+ * the set code
*/
public void add(final String cardName, final String setCode) {
this.add(CardDb.instance().getCard(cardName, setCode));
@@ -77,15 +86,17 @@ public class DeckSection extends ItemPool {
*
* @param cardName the card name
* @param setCode the set code
+ * @param amount the amount
*/
- public void add(final String cardName, final String setCode, int amount) {
+ public void add(final String cardName, final String setCode, final int amount) {
this.add(CardDb.instance().getCard(cardName, setCode), amount);
}
/**
* Adds the.
- *
- * @param cardList the card list
+ *
+ * @param cardList
+ * the card list
*/
public void add(final CardList cardList) {
for (final Card c : cardList) {
@@ -95,9 +106,10 @@ public class DeckSection extends ItemPool {
/**
* TODO: Write javadoc for this method.
- * @param string
+ *
+ * @param cardName the card name
*/
- public void add(String cardName) {
+ public void add(final String cardName) {
this.add(CardDb.instance().getCard(cardName));
}
diff --git a/src/main/java/forge/deck/io/DeckGroupSerializer.java b/src/main/java/forge/deck/io/DeckGroupSerializer.java
index fd0383835a1..6ba2eca51b5 100644
--- a/src/main/java/forge/deck/io/DeckGroupSerializer.java
+++ b/src/main/java/forge/deck/io/DeckGroupSerializer.java
@@ -26,8 +26,8 @@ import org.apache.commons.lang3.StringUtils;
import forge.deck.Deck;
import forge.deck.DeckGroup;
import forge.util.FileUtil;
-import forge.util.StorageReaderFolder;
import forge.util.IItemSerializer;
+import forge.util.StorageReaderFolder;
/**
* TODO: Write javadoc for this type.
@@ -36,42 +36,49 @@ import forge.util.IItemSerializer;
public class DeckGroupSerializer extends StorageReaderFolder implements IItemSerializer {
private final String HUMAN_DECK_FILE = "human.dck";
-
- public DeckGroupSerializer(File deckDir0) {
+ /**
+ * Instantiates a new deck group serializer.
+ *
+ * @param deckDir0 the deck dir0
+ */
+ public DeckGroupSerializer(final File deckDir0) {
super(deckDir0);
}
+ /** The Constant MAX_DRAFT_PLAYERS. */
public final static int MAX_DRAFT_PLAYERS = 8;
/**
- *
* Write draft Decks.
- *
- * @param drafts
- * a Deck[]
+ *
+ * @param unit the unit
*/
@Override
- public void save(DeckGroup unit) {
- final File f = makeFileFor(unit);
+ public void save(final DeckGroup unit) {
+ final File f = this.makeFileFor(unit);
f.mkdir();
- FileUtil.writeFile(new File(f, HUMAN_DECK_FILE), unit.getHumanDeck().save());
- List aiDecks = unit.getAiDecks();
+ FileUtil.writeFile(new File(f, this.HUMAN_DECK_FILE), unit.getHumanDeck().save());
+ final List aiDecks = unit.getAiDecks();
for (int i = 1; i <= aiDecks.size(); i++) {
FileUtil.writeFile(new File(f, "ai-" + i + ".dck"), aiDecks.get(i - 1).save());
}
}
- protected final DeckGroup read(File file) {
+ /* (non-Javadoc)
+ * @see forge.util.StorageReaderFolder#read(java.io.File)
+ */
+ @Override
+ protected final DeckGroup read(final File file) {
- Deck human = Deck.fromFile(new File(file, HUMAN_DECK_FILE));
+ final Deck human = Deck.fromFile(new File(file, this.HUMAN_DECK_FILE));
if (null == human) {
return null;
}
final DeckGroup d = new DeckGroup(human.getName());
d.setHumanDeck(human);
- for (int i = 1; i < MAX_DRAFT_PLAYERS; i++) {
- File theFile = new File(file, "ai-" + i + ".dck");
+ for (int i = 1; i < DeckGroupSerializer.MAX_DRAFT_PLAYERS; i++) {
+ final File theFile = new File(file, "ai-" + i + ".dck");
if (!theFile.exists()) {
break;
}
@@ -81,25 +88,35 @@ public class DeckGroupSerializer extends StorageReaderFolder implemen
return d;
}
-
- /* (non-Javadoc)
- * @see forge.deck.IDeckSerializer#erase(forge.item.CardCollectionBase, java.io.File)
+ /*
+ * (non-Javadoc)
+ *
+ * @see forge.deck.IDeckSerializer#erase(forge.item.CardCollectionBase,
+ * java.io.File)
*/
@Override
- public void erase(DeckGroup unit) {
- File dir = makeFileFor(unit);
+ public void erase(final DeckGroup unit) {
+ final File dir = this.makeFileFor(unit);
final File[] files = dir.listFiles();
- for (File f : files) {
+ for (final File f : files) {
f.delete();
}
dir.delete();
}
+ /**
+ * Make file for.
+ *
+ * @param decks the decks
+ * @return the file
+ */
public File makeFileFor(final DeckGroup decks) {
- return new File(getDirectory(), decks.getBestFileName());
+ return new File(this.getDirectory(), decks.getBestFileName());
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.deck.io.DeckSerializerBase#getFileFilter()
*/
@Override
@@ -107,10 +124,11 @@ public class DeckGroupSerializer extends StorageReaderFolder implemen
return new FilenameFilter() {
@Override
- public boolean accept(File dir, String name) {
- boolean isVisibleFolder = dir.isDirectory() && !dir.isHidden();
- boolean hasGoodName = StringUtils.isNotEmpty(name) && !name.startsWith(".");
- return isVisibleFolder && hasGoodName && new File(dir, HUMAN_DECK_FILE).exists();
+ public boolean accept(final File dir, final String name) {
+ final boolean isVisibleFolder = dir.isDirectory() && !dir.isHidden();
+ final boolean hasGoodName = StringUtils.isNotEmpty(name) && !name.startsWith(".");
+ return isVisibleFolder && hasGoodName
+ && new File(dir, DeckGroupSerializer.this.HUMAN_DECK_FILE).exists();
}
};
}
diff --git a/src/main/java/forge/deck/io/DeckSerializer.java b/src/main/java/forge/deck/io/DeckSerializer.java
index b72a6e89672..c806b5aa81a 100644
--- a/src/main/java/forge/deck/io/DeckSerializer.java
+++ b/src/main/java/forge/deck/io/DeckSerializer.java
@@ -39,9 +39,9 @@ import forge.item.CardPrinted;
import forge.util.FileSection;
import forge.util.FileSectionManual;
import forge.util.FileUtil;
+import forge.util.IItemSerializer;
import forge.util.SectionUtil;
import forge.util.StorageReaderFolder;
-import forge.util.IItemSerializer;
import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;
@@ -53,11 +53,15 @@ import freemarker.template.TemplateException;
*/
public class DeckSerializer extends StorageReaderFolder implements IItemSerializer {
- public DeckSerializer(File deckDir0) {
+ /**
+ * Instantiates a new deck serializer.
+ *
+ * @param deckDir0 the deck dir0
+ */
+ public DeckSerializer(final File deckDir0) {
super(deckDir0);
}
-
/** Constant DCKFileFilter. */
public static final FilenameFilter DCK_FILE_FILTER = new FilenameFilter() {
@Override
@@ -90,7 +94,6 @@ public class DeckSerializer extends StorageReaderFolder implements IItemSe
}
};
-
/**
*
* writeDeck.
@@ -203,72 +206,85 @@ public class DeckSerializer extends StorageReaderFolder implements IItemSe
}
}
-
- /* (non-Javadoc)
- * @see forge.deck.IDeckSerializer#save(forge.item.CardCollectionBase, java.io.File)
+ /*
+ * (non-Javadoc)
+ *
+ * @see forge.deck.IDeckSerializer#save(forge.item.CardCollectionBase,
+ * java.io.File)
*/
@Override
- public void save(Deck unit) {
- FileUtil.writeFile(makeFileFor(unit), unit.save());
+ public void save(final Deck unit) {
+ FileUtil.writeFile(this.makeFileFor(unit), unit.save());
}
- /* (non-Javadoc)
- * @see forge.deck.IDeckSerializer#erase(forge.item.CardCollectionBase, java.io.File)
+ /*
+ * (non-Javadoc)
+ *
+ * @see forge.deck.IDeckSerializer#erase(forge.item.CardCollectionBase,
+ * java.io.File)
*/
@Override
- public void erase(Deck unit) {
- makeFileFor(unit).delete();
+ public void erase(final Deck unit) {
+ this.makeFileFor(unit).delete();
}
/**
- *
* Make file name.
- *
- * @param deckName
- * a String
- * @param deckType
- * a GameType
+ *
+ * @param deck the deck
* @return a File
*/
public File makeFileFor(final Deck deck) {
- return new File(getDirectory(), deck.getBestFileName() + ".dck");
+ return new File(this.getDirectory(), deck.getBestFileName() + ".dck");
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.deck.io.DeckSerializerBase#read(java.io.File)
*/
@Override
- protected Deck read(File file) {
- Map> sections = SectionUtil.parseSections(FileUtil.readFile(file));
+ protected Deck read(final File file) {
+ final Map> sections = SectionUtil.parseSections(FileUtil.readFile(file));
return Deck.fromSections(sections, true);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.deck.io.DeckSerializerBase#getFileFilter()
*/
@Override
protected FilenameFilter getFileFilter() {
- return DCK_FILE_FILTER;
+ return DeckSerializer.DCK_FILE_FILTER;
}
- public static DeckFileHeader readDeckMetadata(final Map> map, boolean canThrow) {
- if (map == null) { return null; }
- List metadata = map.get("metadata");
- if (metadata != null) {
+ /**
+ * Read deck metadata.
+ *
+ * @param map the map
+ * @param canThrow the can throw
+ * @return the deck file header
+ */
+ public static DeckFileHeader readDeckMetadata(final Map> map, final boolean canThrow) {
+ if (map == null) {
+ return null;
+ }
+ final List metadata = map.get("metadata");
+ if (metadata != null) {
return new DeckFileHeader(FileSection.parse(metadata, "="));
- }
- List general = map.get("general");
- if ( general != null )
- {
- if ( canThrow ) {
+ }
+ final List general = map.get("general");
+ if (general != null) {
+ if (canThrow) {
throw new OldDeckFileFormatException();
}
- FileSectionManual fs = new FileSectionManual();
+ final FileSectionManual fs = new FileSectionManual();
fs.put(DeckFileHeader.NAME, StringUtils.join(map.get(""), " "));
fs.put(DeckFileHeader.DECK_TYPE, StringUtils.join(general, " "));
return new DeckFileHeader(fs);
}
-
+
return null;
}
diff --git a/src/main/java/forge/deck/io/OldDeckParser.java b/src/main/java/forge/deck/io/OldDeckParser.java
index cc700d8b2dc..8390f1fba3b 100644
--- a/src/main/java/forge/deck/io/OldDeckParser.java
+++ b/src/main/java/forge/deck/io/OldDeckParser.java
@@ -1,3 +1,20 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Nate
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package forge.deck.io;
import java.io.File;
@@ -20,9 +37,9 @@ import forge.util.FileUtil;
import forge.util.IFolderMap;
import forge.util.SectionUtil;
-/**
+/**
* TODO: Write javadoc for this type.
- *
+ *
*/
public class OldDeckParser {
@@ -36,35 +53,65 @@ public class OldDeckParser {
/**
* TODO: Write javadoc for Constructor.
- * @param file
- * @param constructed2
- * @param draft2
- * @param sealed2
- * @param cube2
+ *
+ * @param file the file
+ * @param constructed2 the constructed2
+ * @param draft2 the draft2
+ * @param sealed2 the sealed2
+ * @param cube2 the cube2
*/
- public OldDeckParser(File file, IFolderMap constructed2, IFolderMap draft2,
- IFolderMap sealed2, IFolderMap cube2) {
- deckDir = file;
- sealed = sealed2;
- constructed = constructed2;
- cube = cube2;
- draft = draft2;
+ public OldDeckParser(final File file, final IFolderMap constructed2, final IFolderMap draft2,
+ final IFolderMap sealed2, final IFolderMap cube2) {
+ this.deckDir = file;
+ this.sealed = sealed2;
+ this.constructed = constructed2;
+ this.cube = cube2;
+ this.draft = draft2;
}
+ /**
+ * Gets the sealed.
+ *
+ * @return the sealed
+ */
protected final IFolderMap getSealed() {
- return sealed;
+ return this.sealed;
}
+
+ /**
+ * Gets the constructed.
+ *
+ * @return the constructed
+ */
protected final IFolderMap getConstructed() {
- return constructed;
+ return this.constructed;
}
+
+ /**
+ * Gets the draft.
+ *
+ * @return the draft
+ */
protected final IFolderMap getDraft() {
- return draft;
+ return this.draft;
}
+
+ /**
+ * Gets the cube.
+ *
+ * @return the cube
+ */
protected final IFolderMap getCube() {
- return cube;
+ return this.cube;
}
+
+ /**
+ * Gets the deck dir.
+ *
+ * @return the deck dir
+ */
protected final File getDeckDir() {
- return deckDir;
+ return this.deckDir;
}
private final IFolderMap sealed;
@@ -72,23 +119,24 @@ public class OldDeckParser {
private final IFolderMap draft;
private final IFolderMap cube;
private final File deckDir;
+
/**
* TODO: Write javadoc for this method.
*/
public void tryParse() {
- convertConstructedAndSealed();
- convertDrafts();
+ this.convertConstructedAndSealed();
+ this.convertDrafts();
}
private void convertDrafts() {
- for (File f : deckDir.listFiles(bdkFileFilter)) {
+ for (final File f : this.deckDir.listFiles(OldDeckParser.bdkFileFilter)) {
boolean gotError = false;
- Deck human = Deck.fromFile(new File(f, "0.dck"));
+ final Deck human = Deck.fromFile(new File(f, "0.dck"));
final DeckGroup d = new DeckGroup(human.getName());
d.setHumanDeck(human);
for (int i = 1; i < DeckGroupSerializer.MAX_DRAFT_PLAYERS; i++) {
- Deck nextAi = Deck.fromFile(new File(f, i + ".dck"));
+ final Deck nextAi = Deck.fromFile(new File(f, i + ".dck"));
if (nextAi == null) {
gotError = true;
break;
@@ -98,14 +146,15 @@ public class OldDeckParser {
boolean mayDelete = !gotError;
if (!gotError) {
- draft.add(d);
+ this.draft.add(d);
} else {
- String msg = String.format("Draft '%s' lacked some decks.%n%nShould it be deleted?");
- mayDelete = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Draft loading error", JOptionPane.YES_NO_OPTION);
+ final String msg = String.format("Draft '%s' lacked some decks.%n%nShould it be deleted?");
+ mayDelete = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Draft loading error",
+ JOptionPane.YES_NO_OPTION);
}
if (mayDelete) {
- for (File f1 : f.listFiles()) {
+ for (final File f1 : f.listFiles()) {
f1.delete();
}
f.delete();
@@ -115,102 +164,114 @@ public class OldDeckParser {
}
private void convertConstructedAndSealed() {
- boolean allowDeleteUnsupportedConstructed = false;
- Map>> sealedDecks = new TreeMap>>(String.CASE_INSENSITIVE_ORDER);
+ boolean allowDeleteUnsupportedConstructed = false;
+ final Map>> sealedDecks = new TreeMap>>(
+ String.CASE_INSENSITIVE_ORDER);
- for (File f : deckDir.listFiles(DeckSerializer.DCK_FILE_FILTER)) {
- boolean importedOk = false;
+ for (final File f : this.deckDir.listFiles(DeckSerializer.DCK_FILE_FILTER)) {
+ boolean importedOk = false;
- List fileLines = FileUtil.readFile(f);
- Map> sections = SectionUtil.parseSections(fileLines);
- DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections, false);
- String name = dh.getName();
+ final List fileLines = FileUtil.readFile(f);
+ final Map> sections = SectionUtil.parseSections(fileLines);
+ final DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections, false);
+ String name = dh.getName();
- if (dh.isCustomPool()) {
- try {
- cube.add(Deck.fromSections(sections));
- importedOk = true;
- } catch (NoSuchElementException ex) {
- if (!allowDeleteUnsupportedConstructed) {
- String msg = String.format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?", name, ex.getMessage());
- allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
- }
- }
- if (importedOk || allowDeleteUnsupportedConstructed) {
- f.delete();
- }
- continue;
- }
+ if (dh.isCustomPool()) {
+ try {
+ this.cube.add(Deck.fromSections(sections));
+ importedOk = true;
+ } catch (final NoSuchElementException ex) {
+ if (!allowDeleteUnsupportedConstructed) {
+ final String msg = String
+ .format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
+ name, ex.getMessage());
+ allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
+ null, msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
+ }
+ }
+ if (importedOk || allowDeleteUnsupportedConstructed) {
+ f.delete();
+ }
+ continue;
+ }
- switch(dh.getDeckType()) {
- case Constructed:
- try {
- constructed.add(Deck.fromSections(sections));
- importedOk = true;
- } catch (NoSuchElementException ex) {
- if (!allowDeleteUnsupportedConstructed) {
- String msg = String.format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?", name, ex.getMessage());
- allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
- }
- }
- if (importedOk || allowDeleteUnsupportedConstructed) {
- f.delete();
- }
- break;
+ switch (dh.getDeckType()) {
+ case Constructed:
+ try {
+ this.constructed.add(Deck.fromSections(sections));
+ importedOk = true;
+ } catch (final NoSuchElementException ex) {
+ if (!allowDeleteUnsupportedConstructed) {
+ final String msg = String
+ .format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
+ name, ex.getMessage());
+ allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(
+ null, msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
+ }
+ }
+ if (importedOk || allowDeleteUnsupportedConstructed) {
+ f.delete();
+ }
+ break;
- case Sealed:
- boolean isAi = dh.getPlayerType() == PlayerType.COMPUTER;
- name = name.startsWith("AI_") ? name.replace("AI_", "") : name;
+ case Sealed:
+ final boolean isAi = dh.getPlayerType() == PlayerType.COMPUTER;
+ name = name.startsWith("AI_") ? name.replace("AI_", "") : name;
- Pair> stored = sealedDecks.get(name);
- if (null == stored) {
- stored = ImmutablePair.of(new DeckGroup(name), MutablePair.of((File) null, (File) null));
- }
+ Pair> stored = sealedDecks.get(name);
+ if (null == stored) {
+ stored = ImmutablePair.of(new DeckGroup(name), MutablePair.of((File) null, (File) null));
+ }
- Deck deck = Deck.fromSections(sections);
- if (isAi) {
- stored.getLeft().addAiDeck(deck);
- stored.getRight().setRight(f);
- } else {
- stored.getLeft().setHumanDeck(deck);
- stored.getRight().setLeft(f);
- }
+ final Deck deck = Deck.fromSections(sections);
+ if (isAi) {
+ stored.getLeft().addAiDeck(deck);
+ stored.getRight().setRight(f);
+ } else {
+ stored.getLeft().setHumanDeck(deck);
+ stored.getRight().setLeft(f);
+ }
- if (stored.getLeft().getHumanDeck() != null && !stored.getLeft().getAiDecks().isEmpty()) {
- // have both parts of sealed deck, may convert
- sealed.add(stored.getLeft());
- stored.getRight().getLeft().delete();
- stored.getRight().getRight().delete();
+ if ((stored.getLeft().getHumanDeck() != null) && !stored.getLeft().getAiDecks().isEmpty()) {
+ // have both parts of sealed deck, may convert
+ this.sealed.add(stored.getLeft());
+ stored.getRight().getLeft().delete();
+ stored.getRight().getRight().delete();
- // there stay only orphans
- sealedDecks.remove(name);
- } else {
- sealedDecks.put(name, stored);
- }
- break;
- }
- }
+ // there stay only orphans
+ sealedDecks.remove(name);
+ } else {
+ sealedDecks.put(name, stored);
+ }
+ break;
+ }
+ }
- // advise to kill orphaned decks
- if (!sealedDecks.isEmpty()) {
- StringBuilder sb = new StringBuilder();
- for (Pair> s : sealedDecks.values()) {
- String missingPart = s.getRight().getLeft() == null ? "human" : "computer";
- sb.append(String.format("Sealed deck '%s' has no matching '%s' deck.%n", s.getKey().getName(), missingPart));
- }
- sb.append(System.getProperty("line.separator"));
- sb.append("May Forge delete these decks?");
- int response = JOptionPane.showConfirmDialog(null, sb.toString(), "Some of your sealed decks are orphaned", JOptionPane.YES_NO_OPTION);
- if (response == JOptionPane.YES_OPTION) {
- for (Pair> s : sealedDecks.values()) {
- if (s.getRight().getLeft() != null) { s.getRight().getLeft().delete(); }
- if (s.getRight().getRight() != null) { s.getRight().getRight().delete(); }
- }
- }
- }
+ // advise to kill orphaned decks
+ if (!sealedDecks.isEmpty()) {
+ final StringBuilder sb = new StringBuilder();
+ for (final Pair> s : sealedDecks.values()) {
+ final String missingPart = s.getRight().getLeft() == null ? "human" : "computer";
+ sb.append(String.format("Sealed deck '%s' has no matching '%s' deck.%n", s.getKey().getName(),
+ missingPart));
+ }
+ sb.append(System.getProperty("line.separator"));
+ sb.append("May Forge delete these decks?");
+ final int response = JOptionPane.showConfirmDialog(null, sb.toString(),
+ "Some of your sealed decks are orphaned", JOptionPane.YES_NO_OPTION);
+ if (response == JOptionPane.YES_OPTION) {
+ for (final Pair> s : sealedDecks.values()) {
+ if (s.getRight().getLeft() != null) {
+ s.getRight().getLeft().delete();
+ }
+ if (s.getRight().getRight() != null) {
+ s.getRight().getRight().delete();
+ }
+ }
+ }
+ }
}
-
/**
* @return the deckDir
*/
diff --git a/src/main/java/forge/game/GameType.java b/src/main/java/forge/game/GameType.java
index e2b7a4c6dd5..1a3e5c80029 100644
--- a/src/main/java/forge/game/GameType.java
+++ b/src/main/java/forge/game/GameType.java
@@ -56,9 +56,9 @@ public enum GameType {
/**
* Smart value of.
- *
- * @param value
- * the value
+ *
+ * @param value the value
+ * @param defaultValue the default value
* @return the game type
*/
public static GameType smartValueOf(final String value, GameType defaultValue) {
diff --git a/src/main/java/forge/game/limited/CustomLimited.java b/src/main/java/forge/game/limited/CustomLimited.java
index f45fd149642..3e8c661925a 100644
--- a/src/main/java/forge/game/limited/CustomLimited.java
+++ b/src/main/java/forge/game/limited/CustomLimited.java
@@ -43,9 +43,10 @@ public class CustomLimited extends DeckBase {
/**
* TODO: Write javadoc for Constructor.
- * @param name0
+ *
+ * @param name0 the name0
*/
- public CustomLimited(String name0) {
+ public CustomLimited(final String name0) {
super(name0);
}
@@ -60,7 +61,6 @@ public class CustomLimited extends DeckBase {
/** The Num cards. */
private int numCards = 15;
-
private final Map numRarity = new EnumMap(CardRarity.class);
/** The Num packs. */
@@ -83,14 +83,14 @@ public class CustomLimited extends DeckBase {
/**
* Parses the.
- *
- * @param dfData
- * the df data
+ *
+ * @param dfData the df data
+ * @param cubes the cubes
* @return the custom limited
*/
- public static CustomLimited parse(final List dfData, IFolderMapView cubes) {
+ public static CustomLimited parse(final List dfData, final IFolderMapView cubes) {
- FileSection data = FileSection.parse(dfData, ":");
+ final FileSection data = FileSection.parse(dfData, ":");
final CustomLimited cd = new CustomLimited(data.get("Name"));
cd.setIgnoreRarity(data.getBoolean("IgnoreRarity"));
@@ -107,9 +107,10 @@ public class CustomLimited extends DeckBase {
cd.numPacks = data.getInt("NumPacks");
- String deckName = data.get("DeckFile");
- Deck deckCube = cubes.get(deckName);
- cd.cardPool = deckCube == null ? ItemPool.createFrom(CardDb.instance().getAllUniqueCards(), CardPrinted.class) : deckCube.getMain();
+ final String deckName = data.get("DeckFile");
+ final Deck deckCube = cubes.get(deckName);
+ cd.cardPool = deckCube == null ? ItemPool.createFrom(CardDb.instance().getAllUniqueCards(), CardPrinted.class)
+ : deckCube.getMain();
return cd;
}
@@ -209,30 +210,33 @@ public class CustomLimited extends DeckBase {
this.landSetCode = landSetCodeIn;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.item.CardCollectionBase#getCardPool()
*/
@Override
public ItemPoolView getCardPool() {
- return cardPool;
+ return this.cardPool;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.deck.DeckBase#getInstance(java.lang.String)
*/
@Override
- protected DeckBase newInstance(String name0) {
+ protected DeckBase newInstance(final String name0) {
return new CustomLimited(name0);
}
/**
* TODO: Write javadoc for this method.
- * @return
+ *
+ * @return the numbers by rarity
*/
public Map getNumbersByRarity() {
- return numRarity;
+ return this.numRarity;
}
-
-
}
diff --git a/src/main/java/forge/gui/deckeditor/DeckController.java b/src/main/java/forge/gui/deckeditor/DeckController.java
index 104acfe6dd9..5bf9c145e15 100644
--- a/src/main/java/forge/gui/deckeditor/DeckController.java
+++ b/src/main/java/forge/gui/deckeditor/DeckController.java
@@ -1,7 +1,25 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Nate
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package forge.gui.deckeditor;
import java.awt.Component;
import java.util.ArrayList;
+
import net.slightlymagic.braids.util.lambda.Lambda0;
import org.apache.commons.lang3.StringUtils;
@@ -9,9 +27,10 @@ import org.apache.commons.lang3.StringUtils;
import forge.deck.DeckBase;
import forge.util.IFolderMap;
-/**
+/**
* TODO: Write javadoc for this type.
*
+ * @param the generic type
*/
public class DeckController implements IDeckController {
@@ -22,184 +41,219 @@ public class DeckController implements IDeckController {
private final DeckEditorBase, T> view;
private final Lambda0 newModelCreator;
- public DeckController(IFolderMap folder0, DeckEditorBase, T> view0, Lambda0 newModelCreator0)
- {
- folder = folder0;
- view = view0;
- model = null;
- saved = true;
- modelInStore = false;
- newModelCreator = newModelCreator0;
+ /**
+ * Instantiates a new deck controller.
+ *
+ * @param folder0 the folder0
+ * @param view0 the view0
+ * @param newModelCreator0 the new model creator0
+ */
+ public DeckController(final IFolderMap folder0, final DeckEditorBase, T> view0,
+ final Lambda0 newModelCreator0) {
+ this.folder = folder0;
+ this.view = view0;
+ this.model = null;
+ this.saved = true;
+ this.modelInStore = false;
+ this.newModelCreator = newModelCreator0;
}
/**
+ * Gets the model.
+ *
* @return the document
*/
+ @Override
public T getModel() {
- return model;
+ return this.model;
}
-
/**
- * @param document0 the document to set
+ * Sets the model.
+ *
+ * @param document the new model
*/
- public void setModel(T document) {
- setModel(document, false);
+ @Override
+ public void setModel(final T document) {
+ this.setModel(document, false);
}
- public void setModel(T document, boolean isStored) {
- modelInStore = isStored;
+ /**
+ * Sets the model.
+ *
+ * @param document the document
+ * @param isStored the is stored
+ */
+ public void setModel(final T document, final boolean isStored) {
+ this.modelInStore = isStored;
this.model = document;
- view.updateView();
- saved = true; // unless set to false in notify
- if (!isModelInSyncWithFolder()) {
- notifyModelChanged();
+ this.view.updateView();
+ this.saved = true; // unless set to false in notify
+ if (!this.isModelInSyncWithFolder()) {
+ this.notifyModelChanged();
}
}
private boolean isModelInSyncWithFolder() {
- T modelStored = folder.get(model.getName());
+ final T modelStored = this.folder.get(this.model.getName());
// checks presence in dictionary only.
- if (modelStored == model) {
+ if (modelStored == this.model) {
return true;
}
if (null == modelStored) {
return false;
}
- return modelStored.equals(model);
+ return modelStored.equals(this.model);
}
-
/**
+ * Gets the view.
+ *
* @return the view
*/
+ @Override
public DeckEditorBase, T> getView() {
- return view;
+ return this.view;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#notifyModelChanged()
*/
@Override
public void notifyModelChanged() {
- saved = false;
- //view.setTitle();
+ this.saved = false;
+ // view.setTitle();
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#getOwnerWindow()
*/
@Override
public Component getOwnerWindow() {
- return getView();
+ return this.getView();
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#getSavedModelNames()
*/
@Override
public ArrayList getSavedNames() {
- return new ArrayList(folder.getNames());
+ return new ArrayList(this.folder.getNames());
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#load(java.lang.String)
*/
@Override
- public void load(String name) {
- setModel(folder.get(name), true);
+ public void load(final String name) {
+ this.setModel(this.folder.get(name), true);
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#save()
*/
@Override
public void save() {
- folder.add(model);
- saved = true;
- modelInStore = true;
+ this.folder.add(this.model);
+ this.saved = true;
+ this.modelInStore = true;
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#rename(java.lang.String)
*/
@SuppressWarnings("unchecked")
@Override
- public void saveAs(String name0) {
- setModel((T) model.copyTo(name0), false);
- save();
+ public void saveAs(final String name0) {
+ this.setModel((T) this.model.copyTo(name0), false);
+ this.save();
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#isSaved()
*/
@Override
public boolean isSaved() {
- return saved;
+ return this.saved;
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#delete()
*/
@Override
public void delete() {
- if (StringUtils.isNotBlank(model.getName())) {
- folder.delete(model.getName());
+ if (StringUtils.isNotBlank(this.model.getName())) {
+ this.folder.delete(this.model.getName());
}
- modelInStore = false;
- newModel();
+ this.modelInStore = false;
+ this.newModel();
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#isGoodName(java.lang.String)
*/
@Override
- public boolean fileExists(String deckName) {
- return !folder.isUnique(deckName);
+ public boolean fileExists(final String deckName) {
+ return !this.folder.isUnique(deckName);
}
-
- @Override
- public boolean isGoodName(String deckName) {
- return StringUtils.isNotBlank(deckName) && folder.isUnique(deckName);
- }
-
-
/* (non-Javadoc)
+ * @see forge.gui.deckeditor.IDeckController#isGoodName(java.lang.String)
+ */
+ @Override
+ public boolean isGoodName(final String deckName) {
+ return StringUtils.isNotBlank(deckName) && this.folder.isUnique(deckName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#importDeck(forge.deck.Deck)
*/
@Override
- public void importDeck(T newDeck) {
- setModel(newDeck);
+ public void importDeck(final T newDeck) {
+ this.setModel(newDeck);
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#isModelInStore()
*/
@Override
public boolean isModelInStore() {
- return modelInStore;
+ return this.modelInStore;
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.IDeckController#newModel()
*/
@Override
public void newModel() {
- model = newModelCreator.apply();
- saved = true;
- view.updateView();
+ this.model = this.newModelCreator.apply();
+ this.saved = true;
+ this.view.updateView();
}
}
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorBase.java b/src/main/java/forge/gui/deckeditor/DeckEditorBase.java
index 3d72d53eff1..a3b8e545126 100644
--- a/src/main/java/forge/gui/deckeditor/DeckEditorBase.java
+++ b/src/main/java/forge/gui/deckeditor/DeckEditorBase.java
@@ -39,6 +39,9 @@ import forge.item.ItemPoolView;
/**
* The Class DeckEditorBase.
+ *
+ * @param the generic type
+ * @param the generic type
*/
public abstract class DeckEditorBase extends JFrame {
private static final long serialVersionUID = -401223933343539977L;
@@ -78,6 +81,11 @@ public abstract class DeckEditorBase extends JF
*
* @see forge.gui.deckeditor.DeckDisplay#getTop()
*/
+ /**
+ * Gets the top.
+ *
+ * @return the top
+ */
public final ItemPoolView getTop() {
return this.getTopTableWithCards().getCards();
}
@@ -88,11 +96,20 @@ public abstract class DeckEditorBase extends JF
*
* @see forge.gui.deckeditor.DeckDisplay#getBottom()
*/
+ /**
+ * Gets the bottom.
+ *
+ * @return the bottom
+ */
public final ItemPoolView getBottom() {
return this.getBottomTableWithCards().getCards();
}
-
+ /**
+ * Gets the controller.
+ *
+ * @return the controller
+ */
public abstract IDeckController getController();
// THIS IS HERE FOR OVERLOADING!!!1
@@ -105,7 +122,13 @@ public abstract class DeckEditorBase extends JF
*/
protected abstract Predicate buildFilter();
+ /**
+ * Show.
+ *
+ * @param exitCommand the exit command
+ */
public abstract void show(final Command exitCommand);
+
/**
* Analysis button_action performed.
*
@@ -126,17 +149,17 @@ public abstract class DeckEditorBase extends JF
}
}
-
/*
* (non-Javadoc)
*
* @see forge.gui.deckeditor.DeckDisplay#setItems(forge.item.ItemPoolView,
* forge.item.ItemPoolView, forge.game.GameType)
*/
+ /**
+ * Update view.
+ */
public abstract void updateView();
-
-
/**
* Update display.
*/
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorConstructed.java b/src/main/java/forge/gui/deckeditor/DeckEditorConstructed.java
index 1dfd49f4a22..7cb4827c1d7 100644
--- a/src/main/java/forge/gui/deckeditor/DeckEditorConstructed.java
+++ b/src/main/java/forge/gui/deckeditor/DeckEditorConstructed.java
@@ -76,12 +76,14 @@ public final class DeckEditorConstructed extends DeckEditorBase controller;
+
/**
* Show.
*
* @param exitCommand
* the exit command
*/
+ @Override
public void show(final Command exitCommand) {
final Command exit = new Command() {
private static final long serialVersionUID = 5210924838133689758L;
@@ -93,13 +95,15 @@ public final class DeckEditorConstructed extends DeckEditorBase> columns = new ArrayList>();
- columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET));
- columns.add(new TableColumnInfo("Name", 175, PresetColumns.FN_NAME_COMPARE, PresetColumns.FN_NAME_GET));
- columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET));
- columns.add(new TableColumnInfo("Color", 60, PresetColumns.FN_COLOR_COMPARE, PresetColumns.FN_COLOR_GET));
- columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE, PresetColumns.FN_TYPE_GET));
- columns.add(new TableColumnInfo("Stats", 60, PresetColumns.FN_STATS_COMPARE, PresetColumns.FN_STATS_GET));
- columns.add(new TableColumnInfo("R", 25, PresetColumns.FN_RARITY_COMPARE, PresetColumns.FN_RARITY_GET));
- columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET));
- columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE, PresetColumns.FN_AI_STATUS_GET));
+ columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE,
+ PresetColumns.FN_QTY_GET));
+ columns.add(new TableColumnInfo("Name", 175, PresetColumns.FN_NAME_COMPARE,
+ PresetColumns.FN_NAME_GET));
+ columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE,
+ PresetColumns.FN_COST_GET));
+ columns.add(new TableColumnInfo("Color", 60, PresetColumns.FN_COLOR_COMPARE,
+ PresetColumns.FN_COLOR_GET));
+ columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE,
+ PresetColumns.FN_TYPE_GET));
+ columns.add(new TableColumnInfo("Stats", 60, PresetColumns.FN_STATS_COMPARE,
+ PresetColumns.FN_STATS_GET));
+ columns.add(new TableColumnInfo("R", 25, PresetColumns.FN_RARITY_COMPARE,
+ PresetColumns.FN_RARITY_GET));
+ columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE,
+ PresetColumns.FN_SET_GET));
+ columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE,
+ PresetColumns.FN_AI_STATUS_GET));
columns.get(2).setCellRenderer(new ManaCostRenderer());
this.getTopTableWithCards().setup(columns, this.getCardView());
@@ -136,9 +149,7 @@ public final class DeckEditorConstructed extends DeckEditorBase newCreator = new Lambda0() { @Override public Deck apply() { return new Deck(); } };
- controller = new DeckController(Singletons.getModel().getDecks().getConstructed(), this, newCreator);
+ final Lambda0 newCreator = new Lambda0() {
+ @Override
+ public Deck apply() {
+ return new Deck();
+ }
+ };
+ this.controller = new DeckController(Singletons.getModel().getDecks().getConstructed(), this, newCreator);
}
private void jbInit() {
@@ -206,7 +222,7 @@ public final class DeckEditorConstructed extends DeckEditorBase getController() {
- return controller;
+ return this.controller;
}
}
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorLimited.java b/src/main/java/forge/gui/deckeditor/DeckEditorLimited.java
index 1edcdeffd3d..23088abc8ab 100644
--- a/src/main/java/forge/gui/deckeditor/DeckEditorLimited.java
+++ b/src/main/java/forge/gui/deckeditor/DeckEditorLimited.java
@@ -80,6 +80,7 @@ public final class DeckEditorLimited extends DeckEditorBase> columns = new ArrayList>();
- columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET));
- columns.add(new TableColumnInfo("Name", 175, PresetColumns.FN_NAME_COMPARE, PresetColumns.FN_NAME_GET));
- columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET));
- columns.add(new TableColumnInfo("Color", 60, PresetColumns.FN_COLOR_COMPARE, PresetColumns.FN_COLOR_GET));
- columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE, PresetColumns.FN_TYPE_GET));
- columns.add(new TableColumnInfo("Stats", 60, PresetColumns.FN_STATS_COMPARE, PresetColumns.FN_STATS_GET));
- columns.add(new TableColumnInfo("R", 25, PresetColumns.FN_RARITY_COMPARE, PresetColumns.FN_RARITY_GET));
- columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET));
- columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE, PresetColumns.FN_AI_STATUS_GET));
+ columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE,
+ PresetColumns.FN_QTY_GET));
+ columns.add(new TableColumnInfo("Name", 175, PresetColumns.FN_NAME_COMPARE,
+ PresetColumns.FN_NAME_GET));
+ columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE,
+ PresetColumns.FN_COST_GET));
+ columns.add(new TableColumnInfo("Color", 60, PresetColumns.FN_COLOR_COMPARE,
+ PresetColumns.FN_COLOR_GET));
+ columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE,
+ PresetColumns.FN_TYPE_GET));
+ columns.add(new TableColumnInfo("Stats", 60, PresetColumns.FN_STATS_COMPARE,
+ PresetColumns.FN_STATS_GET));
+ columns.add(new TableColumnInfo("R", 25, PresetColumns.FN_RARITY_COMPARE,
+ PresetColumns.FN_RARITY_GET));
+ columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE,
+ PresetColumns.FN_SET_GET));
+ columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE,
+ PresetColumns.FN_AI_STATUS_GET));
columns.get(2).setCellRenderer(new ManaCostRenderer());
this.getTopTableWithCards().setup(columns, this.getCardView());
@@ -135,11 +145,10 @@ public final class DeckEditorLimited extends DeckEditorBase deckMap) {
+ public DeckEditorLimited(final IFolderMap deckMap) {
try {
this.setFilterBoxes(new FilterCheckBoxes(true));
this.setTopTableWithCards(new TableView("Avaliable Cards", true, true, CardPrinted.class));
@@ -152,8 +161,13 @@ public final class DeckEditorLimited extends DeckEditorBase newCreator = new Lambda0() { @Override public DeckGroup apply() { return new DeckGroup(""); } };
- controller = new DeckController(deckMap, this, newCreator);
+ final Lambda0 newCreator = new Lambda0() {
+ @Override
+ public DeckGroup apply() {
+ return new DeckGroup("");
+ }
+ };
+ this.controller = new DeckController(deckMap, this, newCreator);
}
private void jbInit() {
@@ -197,7 +211,7 @@ public final class DeckEditorLimited extends DeckEditorBase getController() {
- return controller;
+ return this.controller;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.DeckEditorBase#updateView()
*/
@Override
public void updateView() {
- getTopTableWithCards().setDeck(getSelectedDeck(controller.getModel()).getSideboard());
- getBottomTableWithCards().setDeck(getSelectedDeck(controller.getModel()).getMain());
+ this.getTopTableWithCards().setDeck(this.getSelectedDeck(this.controller.getModel()).getSideboard());
+ this.getBottomTableWithCards().setDeck(this.getSelectedDeck(this.controller.getModel()).getMain());
}
-
-
}
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java b/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
index 2e752ce2bda..c975b2b9f28 100644
--- a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
+++ b/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
@@ -27,6 +27,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
+
import javax.swing.JButton;
import javax.swing.JCheckBox;
@@ -82,6 +83,7 @@ public final class DeckEditorQuest extends DeckEditorBase {
* @param exitCommand
* the exit command
*/
+ @Override
public void show(final Command exitCommand) {
final Command exit = new Command() {
private static final long serialVersionUID = -7428793574300520612L;
@@ -101,10 +103,13 @@ public final class DeckEditorQuest extends DeckEditorBase {
// do not change this!!!!
this.addWindowListener(new WindowAdapter() {
@Override
- public void windowClosing(final WindowEvent ev) { menu.close(); }
+ public void windowClosing(final WindowEvent ev) {
+ menu.close();
+ }
});
- Deck deck = Constant.Runtime.HUMAN_DECK[0] == null ? null : this.questData.getMyDecks().get(Constant.Runtime.HUMAN_DECK[0].getName());
+ Deck deck = Constant.Runtime.HUMAN_DECK[0] == null ? null : this.questData.getMyDecks().get(
+ Constant.Runtime.HUMAN_DECK[0].getName());
if (deck == null) {
deck = new Deck();
@@ -112,7 +117,6 @@ public final class DeckEditorQuest extends DeckEditorBase {
// tell Gui_Quest_DeckEditor the name of the deck
-
this.getController().setModel(deck);
// this affects the card pool
@@ -156,7 +160,8 @@ public final class DeckEditorQuest extends DeckEditorBase {
this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay());
- // Window is too tall, lower height to min size used by constructed mode deck editor
+ // Window is too tall, lower height to min size used by constructed mode
+ // deck editor
// this.setSize(1024, 768);
this.setSize(1024, 740);
GuiUtils.centerFrame(this);
@@ -188,8 +193,13 @@ public final class DeckEditorQuest extends DeckEditorBase {
ErrorViewer.showError(ex);
}
- Lambda0 newCreator = new Lambda0() { @Override public Deck apply() { return new Deck(); } };
- controller = new DeckController(questData2.getMyDecks(), this, newCreator);
+ final Lambda0 newCreator = new Lambda0() {
+ @Override
+ public Deck apply() {
+ return new Deck();
+ }
+ };
+ this.controller = new DeckController(questData2.getMyDecks(), this, newCreator);
}
private void jbInit() throws Exception {
@@ -255,7 +265,8 @@ public final class DeckEditorQuest extends DeckEditorBase {
/**
* Color filtering
*/
- // Raise the color filtering boxes to top of window and move to the left.
+ // Raise the color filtering boxes to top of window and move to the
+ // left.
this.getFilterBoxes().getWhite().setBounds(17, 10, 67, 20);
this.getFilterBoxes().getBlue().setBounds(94, 10, 60, 20);
this.getFilterBoxes().getBlack().setBounds(162, 10, 65, 20);
@@ -350,28 +361,32 @@ public final class DeckEditorQuest extends DeckEditorBase {
this.questData.getCards().getCardpool().add(card);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.DeckEditorBase#getController()
*/
@Override
public IDeckController getController() {
- return controller;
+ return this.controller;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.DeckEditorBase#updateView()
*/
@Override
public void updateView() {
- Deck deck = controller.getModel();
+ final Deck deck = this.controller.getModel();
final ItemPool cardpool = new ItemPool(CardPrinted.class);
cardpool.addAll(this.questData.getCards().getCardpool());
// remove bottom cards that are in the deck from the card pool
cardpool.removeAll(deck.getMain());
// show cards, makes this user friendly
- getTopTableWithCards().setDeck(cardpool);
- getBottomTableWithCards().setDeck(deck.getMain());
+ this.getTopTableWithCards().setDeck(cardpool);
+ this.getBottomTableWithCards().setDeck(deck.getMain());
}
}
diff --git a/src/main/java/forge/gui/deckeditor/DraftingProcess.java b/src/main/java/forge/gui/deckeditor/DraftingProcess.java
index 93deef6b9cc..b712c6da69c 100644
--- a/src/main/java/forge/gui/deckeditor/DraftingProcess.java
+++ b/src/main/java/forge/gui/deckeditor/DraftingProcess.java
@@ -331,7 +331,10 @@ public class DraftingProcess extends DeckEditorBase {
// DeckManager deckManager = new
// DeckManager(ForgeProps.getFile(NEW_DECKS));
- Singletons.getModel().getDecks().getDraft().add(finishedDraft); // write file right here
+ Singletons.getModel().getDecks().getDraft().add(finishedDraft); // write
+ // file
+ // right
+ // here
// close and open next screen
this.dispose();
@@ -350,7 +353,9 @@ public class DraftingProcess extends DeckEditorBase {
return Predicate.getTrue(CardPrinted.class);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.DeckEditorBase#getController()
*/
@Override
@@ -358,18 +363,22 @@ public class DraftingProcess extends DeckEditorBase {
return null;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.DeckEditorBase#updateView()
*/
@Override
public void updateView() {
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see forge.gui.deckeditor.DeckEditorBase#show(forge.Command)
*/
@Override
- public void show(Command exitCommand) {
+ public void show(final Command exitCommand) {
this.setup();
this.showChoices(this.boosterDraft.nextChoice());
this.getBottomTableWithCards().setDeck((Iterable) null);
diff --git a/src/main/java/forge/gui/deckeditor/IDeckController.java b/src/main/java/forge/gui/deckeditor/IDeckController.java
index 3aa437043b1..d9d55f49aa8 100644
--- a/src/main/java/forge/gui/deckeditor/IDeckController.java
+++ b/src/main/java/forge/gui/deckeditor/IDeckController.java
@@ -1,54 +1,146 @@
+/*
+ * Forge: Play Magic: the Gathering.
+ * Copyright (C) 2011 Nate
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package forge.gui.deckeditor;
import java.awt.Component;
import java.util.List;
-/**
+/**
* TODO: Write javadoc for this type.
*
+ * @param the generic type
*/
public interface IDeckController {
+ /**
+ * New model.
+ */
void newModel();
+
+ /**
+ * Sets the model.
+ *
+ * @param model the new model
+ */
void setModel(T model);
+
+ /**
+ * Gets the model.
+ *
+ * @return the model
+ */
T getModel();
- /** Call this anytime model becomes different from the saved on disk state.*/
+
+ /** Call this anytime model becomes different from the saved on disk state. */
void notifyModelChanged();
+
+ /**
+ * Gets the owner window.
+ *
+ * @return the owner window
+ */
Component getOwnerWindow();
+
+ /**
+ * Gets the view.
+ *
+ * @return the view
+ */
DeckEditorBase, T> getView();
- /** Gets names of saved models in folder / questData. */
+
+ /**
+ * Gets names of saved models in folder / questData.
+ *
+ * @return the saved names
+ */
List getSavedNames();
+
+ /**
+ * Load.
+ *
+ * @param name the name
+ */
void load(String name);
+
+ /**
+ * Save.
+ */
void save();
+
+ /**
+ * Save as.
+ *
+ * @param name0 the name0
+ */
void saveAs(String name0);
+
+ /**
+ * Checks if is saved.
+ *
+ * @return true, if is saved
+ */
boolean isSaved();
+
+ /**
+ * Delete.
+ */
void delete();
- /** Returns true if no object exists with that name. */
+
+ /**
+ * Returns true if no object exists with that name.
+ *
+ * @param deckName the deck name
+ * @return true, if is good name
+ */
boolean isGoodName(String deckName);
- /** Import in quest adds add cards to pool, unlike constructed. */
+
+ /**
+ * Import in quest adds add cards to pool, unlike constructed.
+ *
+ * @param newDeck the new deck
+ */
void importDeck(T newDeck);
- /** Tells if this deck was already saved to disk / questData. */
+
+ /**
+ * Tells if this deck was already saved to disk / questData.
+ *
+ * @return true, if is model in store
+ */
boolean isModelInStore();
+
/**
* TODO: Write javadoc for this method.
- * @param deckName
- * @return
+ *
+ * @param deckName the deck name
+ * @return true, if successful
*/
boolean fileExists(String deckName);
/*
- // IMPORT DECK CODE
- this.questData.addDeck(newDeck);
-
- final ItemPool cardpool = ItemPool.createFrom(this.questData.getCards().getCardpool(),
- CardPrinted.class);
- final ItemPool decklist = new ItemPool(CardPrinted.class);
- for (final Entry s : newDeck.getMain()) {
- final CardPrinted cp = s.getKey();
- decklist.add(cp, s.getValue());
- cardpool.add(cp, s.getValue());
- this.questData.getCards().getCardpool().add(cp, s.getValue());
- }
- this.controller.showItems(cardpool, decklist);
+ * // IMPORT DECK CODE this.questData.addDeck(newDeck);
+ *
+ * final ItemPool cardpool =
+ * ItemPool.createFrom(this.questData.getCards().getCardpool(),
+ * CardPrinted.class); final ItemPool decklist = new
+ * ItemPool(CardPrinted.class); for (final Entry s : newDeck.getMain()) { final CardPrinted cp = s.getKey();
+ * decklist.add(cp, s.getValue()); cardpool.add(cp, s.getValue());
+ * this.questData.getCards().getCardpool().add(cp, s.getValue()); }
+ * this.controller.showItems(cardpool, decklist);
*/
}
diff --git a/src/main/java/forge/gui/deckeditor/MenuBase.java b/src/main/java/forge/gui/deckeditor/MenuBase.java
index 4e50ae122e6..1d90d5708d3 100644
--- a/src/main/java/forge/gui/deckeditor/MenuBase.java
+++ b/src/main/java/forge/gui/deckeditor/MenuBase.java
@@ -38,7 +38,8 @@ import forge.gui.GuiUtils;
*
* Gui_DeckEditor_Menu class.
*
- *
+ *
+ * @param the generic type
* @author Forge
* @version $Id: DeckEditorCommonMenu.java 13590 2012-01-27 20:46:27Z Max mtg $
*/
@@ -49,15 +50,10 @@ public class MenuBase extends JMenuBar {
private final IDeckController controller;
/**
- *
* Menu for Deck Editor.
- *
- * @param inDisplay
- * a DeckDisplay
- * @param dckManager
- * a DeckManager
- * @param exit
- * a Command
+ *
+ * @param ctrl the ctrl
+ * @param exit a Command
*/
public MenuBase(final IDeckController ctrl, final Command exit) {
this.controller = ctrl;
@@ -66,13 +62,21 @@ public class MenuBase extends JMenuBar {
this.setupMenu();
}
+ /**
+ * Gets the controller.
+ *
+ * @return the controller
+ */
protected final IDeckController getController() {
- return controller;
+ return this.controller;
}
+ /**
+ * Setup menu.
+ */
protected void setupMenu() {
- this.add(getDefaultFileMenu());
- this.add(getSortMenu());
+ this.add(this.getDefaultFileMenu());
+ this.add(this.getSortMenu());
}
/**
@@ -89,6 +93,11 @@ public class MenuBase extends JMenuBar {
this.controller.newModel();
}
+ /**
+ * Gets the user input open deck.
+ *
+ * @return the user input open deck
+ */
protected final String getUserInputOpenDeck() {
final List choices = this.controller.getSavedNames();
if (choices.isEmpty()) {
@@ -102,15 +111,25 @@ public class MenuBase extends JMenuBar {
// deck.setName(currentDeckName);
+ /**
+ * Open.
+ */
protected final void open() {
- if (!this.canLeaveCurrentDeck()) { return; }
+ if (!this.canLeaveCurrentDeck()) {
+ return;
+ }
final String name = this.getUserInputOpenDeck();
- if (StringUtils.isBlank(name)) { return; }
- controller.load(name);
+ if (StringUtils.isBlank(name)) {
+ return;
+ }
+ this.controller.load(name);
}
+ /**
+ * Save.
+ */
protected final void save() {
- if (StringUtils.isBlank(controller.getModel().getName())) {
+ if (StringUtils.isBlank(this.controller.getModel().getName())) {
this.saveAs();
return;
}
@@ -118,19 +137,24 @@ public class MenuBase extends JMenuBar {
this.controller.save();
}
+ /**
+ * Save as.
+ */
protected final void saveAs() {
final String name = this.getDeckNameFromDialog();
if (StringUtils.isBlank(name)) {
- final int n = JOptionPane.showConfirmDialog(null, "This name is incorrect. Enter another one?", "Cannot save", JOptionPane.YES_NO_OPTION);
+ final int n = JOptionPane.showConfirmDialog(null, "This name is incorrect. Enter another one?",
+ "Cannot save", JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.NO_OPTION) {
return;
}
}
- if (controller.fileExists(name)) {
- final int m = JOptionPane.showConfirmDialog(null, "There is already saved an item named '" + name + "'. Would you like to overwrite it?", "Confirm overwrite", JOptionPane.YES_NO_OPTION);
+ if (this.controller.fileExists(name)) {
+ final int m = JOptionPane.showConfirmDialog(null, "There is already saved an item named '" + name
+ + "'. Would you like to overwrite it?", "Confirm overwrite", JOptionPane.YES_NO_OPTION);
if (m == JOptionPane.NO_OPTION) {
return;
@@ -140,13 +164,16 @@ public class MenuBase extends JMenuBar {
this.controller.saveAs(name);
}
+ /**
+ * Delete.
+ */
protected final void delete() {
- if (!controller.isModelInStore()) {
+ if (!this.controller.isModelInStore()) {
return;
}
- final int n = JOptionPane.showConfirmDialog(null, "Do you want to delete this deck " + controller.getModel().getName()
- + " ?", "Delete", JOptionPane.YES_NO_OPTION);
+ final int n = JOptionPane.showConfirmDialog(null, "Do you want to delete this deck "
+ + this.controller.getModel().getName() + " ?", "Delete", JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.NO_OPTION) {
return;
@@ -166,8 +193,13 @@ public class MenuBase extends JMenuBar {
this.exitCommand.execute();
}
+ /**
+ * Can leave current deck.
+ *
+ * @return true, if successful
+ */
protected final boolean canLeaveCurrentDeck() {
- if (controller.isSaved()) {
+ if (this.controller.isSaved()) {
return true;
}
final String message = String.format("Do you wish to save changes you made to your current deck '%s'?",
@@ -182,12 +214,10 @@ public class MenuBase extends JMenuBar {
return true;
}
- save();
+ this.save();
return true;
}
-
-
/**
*
* getUserInput_GetDeckName.
@@ -203,7 +233,7 @@ public class MenuBase extends JMenuBar {
}
final String deckName = o.toString();
- final boolean isGoodName = controller.isGoodName(deckName);
+ final boolean isGoodName = this.controller.isGoodName(deckName);
if (isGoodName) {
return deckName;
@@ -213,6 +243,11 @@ public class MenuBase extends JMenuBar {
return this.getDeckNameFromDialog();
}
+ /**
+ * Gets the default file menu.
+ *
+ * @return the default file menu
+ */
protected JMenu getDefaultFileMenu() {
final JMenu fileMenu = new JMenu("Deck");
@@ -317,7 +352,12 @@ public class MenuBase extends JMenuBar {
return fileMenu;
}
- protected void appendCloseMenuItemTo(JMenu fileMenu) {
+ /**
+ * Append close menu item to.
+ *
+ * @param fileMenu the file menu
+ */
+ protected void appendCloseMenuItemTo(final JMenu fileMenu) {
final JMenuItem close = new JMenuItem("Close");
fileMenu.addSeparator();
fileMenu.add(close);
@@ -344,6 +384,8 @@ public class MenuBase