- CheckStyle.

This commit is contained in:
Chris
2012-02-25 19:46:03 +00:00
parent 8e4de8d41a
commit 930e85d2a5
20 changed files with 48 additions and 54 deletions

View File

@@ -2326,8 +2326,8 @@ public class AbilityFactory {
} }
// give Shroud to targeted creatures // give Shroud to targeted creatures
if (saviourApi.equals("Pump") && tgt == null && saviourParams.containsKey("KW") if (saviourApi.equals("Pump") && tgt == null && saviourParams.containsKey("KW")
&& (saviourParams.get("KW").endsWith("Shroud") && (saviourParams.get("KW").endsWith("Shroud")
|| saviourParams.get("KW").endsWith("Hexproof"))) { || saviourParams.get("KW").endsWith("Hexproof"))) {
continue; continue;
} }
@@ -2372,8 +2372,8 @@ public class AbilityFactory {
} }
// give Shroud to targeted creatures // give Shroud to targeted creatures
if (saviourApi.equals("Pump") && tgt == null && saviourParams.containsKey("KW") if (saviourApi.equals("Pump") && tgt == null && saviourParams.containsKey("KW")
&& (saviourParams.get("KW").endsWith("Shroud") && (saviourParams.get("KW").endsWith("Shroud")
|| saviourParams.get("KW").endsWith("Hexproof"))) { || saviourParams.get("KW").endsWith("Hexproof"))) {
continue; continue;
} }
@@ -2394,15 +2394,15 @@ public class AbilityFactory {
} }
// Exiling => bounce/shroud // Exiling => bounce/shroud
else if ((threatApi.equals("ChangeZone") || threatApi.equals("ChangeZoneAll")) else if ((threatApi.equals("ChangeZone") || threatApi.equals("ChangeZoneAll"))
&& (saviourApi.equals("ChangeZone") || saviourApi.equals("Pump")) && (saviourApi.equals("ChangeZone") || saviourApi.equals("Pump"))
&& threatParams.containsKey("Destination") && threatParams.containsKey("Destination")
&& threatParams.get("Destination").equals("Exile")) { && threatParams.get("Destination").equals("Exile")) {
for (final Object o : objects) { for (final Object o : objects) {
if (o instanceof Card) { if (o instanceof Card) {
final Card c = (Card) o; final Card c = (Card) o;
// give Shroud to targeted creatures // give Shroud to targeted creatures
if (saviourApi.equals("Pump") && tgt == null && saviourParams.containsKey("KW") if (saviourApi.equals("Pump") && tgt == null && saviourParams.containsKey("KW")
&& (saviourParams.get("KW").endsWith("Shroud") && (saviourParams.get("KW").endsWith("Shroud")
|| saviourParams.get("KW").endsWith("Hexproof"))) { || saviourParams.get("KW").endsWith("Hexproof"))) {
continue; continue;
} }

View File

@@ -538,7 +538,7 @@ public class AbilityFactoryPump {
if (!mandatory if (!mandatory
&& !sa.isTrigger() && !sa.isTrigger()
&& AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) && AllZone.getPhaseHandler().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)
&& !(this.abilityFactory.isCurse() && (defense < 0)) && !(this.abilityFactory.isCurse() && (defense < 0))
&& !this.containsCombatRelevantKeyword(this.keywords)) { && !this.containsCombatRelevantKeyword(this.keywords)) {
return false; return false;
} }

View File

@@ -47,7 +47,7 @@ public class CardCollections {
this.cube = new StorageImmediatelySerialized<Deck>(new DeckSerializer(new File(file, "cube"))); this.cube = new StorageImmediatelySerialized<Deck>(new DeckSerializer(new File(file, "cube")));
System.out.printf("Read decks: %d constructed, %d sealed, %d draft, %d cubes.%n", constructed.getCount(), sealed.getCount(), draft.getCount(), cube.getCount()); System.out.printf("Read decks: %d constructed, %d sealed, %d draft, %d cubes.%n", constructed.getCount(), sealed.getCount(), draft.getCount(), cube.getCount());
// remove this after most people have been switched to new layout // remove this after most people have been switched to new layout
final OldDeckParser oldParser = new OldDeckParser(file, this.constructed, this.draft, this.sealed, this.cube); final OldDeckParser oldParser = new OldDeckParser(file, this.constructed, this.draft, this.sealed, this.cube);
oldParser.tryParse(); oldParser.tryParse();

View File

@@ -271,7 +271,7 @@ public class Deck extends DeckBase implements Serializable {
out.addAll(Deck.writeCardPool(this.getSideboard())); out.addAll(Deck.writeCardPool(this.getSideboard()));
return out; return out;
} }
public final static Lambda1<String, Deck> FN_NAME_SELECTOR = new Lambda1<String, Deck>() { public final static Lambda1<String, Deck> FN_NAME_SELECTOR = new Lambda1<String, Deck>() {
@Override @Override
public String apply(Deck arg1) { public String apply(Deck arg1) {

View File

@@ -111,7 +111,7 @@ public class DeckGroup extends DeckBase {
protected DeckBase newInstance(final String name0) { protected DeckBase newInstance(final String name0) {
return new DeckGroup(name0); return new DeckGroup(name0);
} }
public final static Lambda1<String, DeckGroup> FN_NAME_SELECTOR = new Lambda1<String, DeckGroup>() { public final static Lambda1<String, DeckGroup> FN_NAME_SELECTOR = new Lambda1<String, DeckGroup>() {
@Override @Override
public String apply(DeckGroup arg1) { public String apply(DeckGroup arg1) {

View File

@@ -128,7 +128,7 @@ public class DeckGroupSerializer extends StorageReaderFolder<DeckGroup> implemen
final File testSubject = new File(dir, name); final File testSubject = new File(dir, name);
final boolean isVisibleFolder = testSubject.isDirectory() && !testSubject.isHidden(); final boolean isVisibleFolder = testSubject.isDirectory() && !testSubject.isHidden();
final boolean hasGoodName = StringUtils.isNotEmpty(name) && !name.startsWith("."); final boolean hasGoodName = StringUtils.isNotEmpty(name) && !name.startsWith(".");
final File fileHumanDeck = new File(testSubject, DeckGroupSerializer.this.humanDeckFile); final File fileHumanDeck = new File(testSubject, DeckGroupSerializer.this.humanDeckFile);
return isVisibleFolder && hasGoodName && fileHumanDeck.exists(); return isVisibleFolder && hasGoodName && fileHumanDeck.exists();
} }
}; };

View File

@@ -119,12 +119,12 @@ public final class GameFormat {
public String toString() { public String toString() {
return this.name + " (format)"; return this.name + " (format)";
} }
public static final Lambda1<String,GameFormat> FN_GET_NAME = new Lambda1<String, GameFormat>() { public static final Lambda1<String, GameFormat> FN_GET_NAME = new Lambda1<String, GameFormat>() {
@Override @Override
public String apply(GameFormat arg1) { public String apply(GameFormat arg1) {
return arg1.getName(); return arg1.getName();
} }
}; };
} }

View File

@@ -126,7 +126,7 @@ public final class BoosterDraft implements IBoosterDraft {
} }
} else { } else {
final UnOpenedProduct product1 = new UnOpenedProduct(Singletons.getModel().getBoosters().get(sets[0])); final UnOpenedProduct product1 = new UnOpenedProduct(Singletons.getModel().getBoosters().get(sets[0]));
for (int i = 0; i < nPacks; i++) { for (int i = 0; i < nPacks; i++) {
this.product.add(product1); this.product.add(product1);
} }

View File

@@ -106,10 +106,10 @@ public class SealedDeck {
final String[] pp = p.toString().split("/"); final String[] pp = p.toString().split("/");
for (int i = 0; i < nPacks; i++) { for (int i = 0; i < nPacks; i++) {
this.product.add(new UnOpenedProduct(Singletons.getModel().getBoosters().get(pp[i]))); this.product.add(new UnOpenedProduct(Singletons.getModel().getBoosters().get(pp[i])));
} }
} else { } else {
final UnOpenedProduct product1 = new UnOpenedProduct(Singletons.getModel().getBoosters().get(sets[0])); final UnOpenedProduct product1 = new UnOpenedProduct(Singletons.getModel().getBoosters().get(sets[0]));
for (int i = 0; i < nPacks; i++) { for (int i = 0; i < nPacks; i++) {
this.product.add(product1); this.product.add(product1);
} }

View File

@@ -99,9 +99,6 @@ public class BoosterPack extends OpenablePack {
return myCards; return myCards;
} }
@Override @Override
public final String getType() { public final String getType() {
return "Booster Pack"; return "Booster Pack";
@@ -119,7 +116,7 @@ public class BoosterPack extends OpenablePack {
*/ */
@Override @Override
public final Object clone() { public final Object clone() {
return new BoosterPack(name, contents); return new BoosterPack(name, contents);
} }

View File

@@ -134,12 +134,12 @@ public class PreconDeck implements InventoryItemFromSet {
public final String getDescription() { public final String getDescription() {
return this.description; return this.description;
} }
public final static Lambda1<String, PreconDeck> FN_NAME_SELECTOR = new Lambda1<String, PreconDeck>() { public final static Lambda1<String, PreconDeck> FN_NAME_SELECTOR = new Lambda1<String, PreconDeck>() {
@Override @Override
public String apply(PreconDeck arg1) { public String apply(PreconDeck arg1) {
return arg1.getName(); return arg1.getName();
} }
}; };
} }

View File

@@ -88,7 +88,7 @@ public enum FModel {
private final IStorageView<BoosterData> boosters; private final IStorageView<BoosterData> boosters;
private final IStorageView<BoosterData> tournaments; private final IStorageView<BoosterData> tournaments;
private final StorageView<CardBlock> blocks; private final StorageView<CardBlock> blocks;
// have to implement lazy initialization - at the moment of FModel.ctor() // have to implement lazy initialization - at the moment of FModel.ctor()
// CardDb is not ready yet. // CardDb is not ready yet.
private CardCollections decks; private CardCollections decks;
@@ -132,14 +132,13 @@ public enum FModel {
this.matchState = new FMatchState(); this.matchState = new FMatchState();
this.questPreferences = new QuestPreferences(); this.questPreferences = new QuestPreferences();
this.questEventManager = new QuestEventManager(); this.questEventManager = new QuestEventManager();
this.editions = new EditionCollection(); this.editions = new EditionCollection();
this.formats = new FormatCollection("res/blockdata/formats.txt"); this.formats = new FormatCollection("res/blockdata/formats.txt");
this.boosters = new StorageView<BoosterData>(new BoosterData.Reader("res/blockdata/boosters.txt")); this.boosters = new StorageView<BoosterData>(new BoosterData.Reader("res/blockdata/boosters.txt"));
this.tournaments = new StorageView<BoosterData>(new BoosterData.Reader("res/blockdata/starters.txt")); this.tournaments = new StorageView<BoosterData>(new BoosterData.Reader("res/blockdata/starters.txt"));
this.blocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/blocks.txt", editions)); this.blocks = new StorageView<CardBlock>(new CardBlock.Reader("res/blockdata/blocks.txt", editions));
// TODO this single setting from preferences should not be here, or, // TODO this single setting from preferences should not be here, or,
// it should be here with all the other settings at the same time. // it should be here with all the other settings at the same time.
// Unfortunately, they're tied up in legacy code in the Display // Unfortunately, they're tied up in legacy code in the Display

View File

@@ -306,8 +306,8 @@ public class QuestDataIO {
writer.addAttribute("s", booster.getEdition()); writer.addAttribute("s", booster.getEdition());
writer.addAttribute("n", count.toString()); writer.addAttribute("n", count.toString());
writer.endNode(); writer.endNode();
} }
protected void write(final PreconDeck deck, final Integer count, final HierarchicalStreamWriter writer) { protected void write(final PreconDeck deck, final Integer count, final HierarchicalStreamWriter writer) {
writer.startNode("precon"); writer.startNode("precon");
writer.addAttribute("name", deck.getName()); writer.addAttribute("name", deck.getName());
@@ -327,7 +327,7 @@ public class QuestDataIO {
} else if (item instanceof BoosterPack) { } else if (item instanceof BoosterPack) {
this.write((BoosterPack) item, count, writer); this.write((BoosterPack) item, count, writer);
} else if (item instanceof TournamentPack) { } else if (item instanceof TournamentPack) {
this.write((TournamentPack) item, count, writer); this.write((TournamentPack) item, count, writer);
} else if (item instanceof PreconDeck) { } else if (item instanceof PreconDeck) {
this.write((PreconDeck) item, count, writer); this.write((PreconDeck) item, count, writer);
} }
@@ -351,7 +351,7 @@ public class QuestDataIO {
} else if ("booster".equals(nodename)) { } else if ("booster".equals(nodename)) {
result.add(this.readBooster(reader), cnt); result.add(this.readBooster(reader), cnt);
} else if ("tpack".equals(nodename)) { } else if ("tpack".equals(nodename)) {
result.add(this.readTournamentPack(reader), cnt); result.add(this.readTournamentPack(reader), cnt);
} else if ("precon".equals(nodename)) { } else if ("precon".equals(nodename)) {
final PreconDeck toAdd = this.readPreconDeck(reader); final PreconDeck toAdd = this.readPreconDeck(reader);
if (null != toAdd) { if (null != toAdd) {
@@ -384,7 +384,7 @@ public class QuestDataIO {
BoosterData bd = Singletons.getModel().getTournamentPacks().get(set); BoosterData bd = Singletons.getModel().getTournamentPacks().get(set);
return new TournamentPack(ed.getName(), bd); return new TournamentPack(ed.getName(), bd);
} }
protected CardPrinted readCardPrinted(final HierarchicalStreamReader reader) { protected CardPrinted readCardPrinted(final HierarchicalStreamReader reader) {
final String name = reader.getAttribute("c"); final String name = reader.getAttribute("c");
final String set = reader.getAttribute("s"); final String set = reader.getAttribute("s");

View File

@@ -209,7 +209,6 @@ public final class QuestUtilCards {
} }
} }
/** /**
* Buy precon deck. * Buy precon deck.
* *
@@ -357,9 +356,9 @@ public final class QuestUtilCards {
*/ */
public void generateTournamentsInShop(final int count) { public void generateTournamentsInShop(final int count) {
Predicate<CardEdition> hasTournament = CardEdition.Predicates.HAS_TOURNAMENT_PACK; Predicate<CardEdition> hasTournament = CardEdition.Predicates.HAS_TOURNAMENT_PACK;
this.q.getShopList().addAllFlat( hasTournament.random(Singletons.getModel().getEditions(), count, TournamentPack.FN_FROM_SET)); this.q.getShopList().addAllFlat(hasTournament.random(Singletons.getModel().getEditions(), count, TournamentPack.FN_FROM_SET));
} }
/** /**
* Generate precons in shop. * Generate precons in shop.
* *

View File

@@ -159,7 +159,7 @@ public class FileSection {
final Map<String, List<String>> result = new HashMap<String, List<String>>(); final Map<String, List<String>> result = new HashMap<String, List<String>>();
String currentSection = ""; String currentSection = "";
List<String> currentList = null; List<String> currentList = null;
for (final String s : source) { for (final String s : source) {
final String st = s.trim(); final String st = s.trim();
if (st.length() == 0) { if (st.length() == 0) {
@@ -173,7 +173,7 @@ public class FileSection {
} }
result.put(currentSection, currentList); result.put(currentSection, currentList);
} }
final String newSection = st.substring(1, st.length() - 1); final String newSection = st.substring(1, st.length() - 1);
currentSection = newSection; currentSection = newSection;
currentList = null; currentList = null;
@@ -184,7 +184,7 @@ public class FileSection {
currentList.add(st); currentList.add(st);
} }
} }
// save final block // save final block
if ((currentList != null) && (currentList.size() > 0)) { if ((currentList != null) && (currentList.size() > 0)) {
final Object oldVal = result.get(currentSection); final Object oldVal = result.get(currentSection);
@@ -193,7 +193,7 @@ public class FileSection {
} }
result.put(currentSection, currentList); result.put(currentSection, currentList);
} }
return result; return result;
} }

View File

@@ -33,6 +33,6 @@ public interface IItemReader<T> {
*/ */
Map<String, T> readAll(); Map<String, T> readAll();
// T read(File file); // T read(File file);
String getItemKey(T item); String getItemKey(T item);
} }

View File

@@ -42,8 +42,8 @@ public interface IStorageView<T> extends Iterable<T> {
* @return a ArrayList<String> * @return a ArrayList<String>
*/ */
Collection<String> getNames(); Collection<String> getNames();
boolean contains(final String name); boolean contains(final String name);
int getCount(); int getCount();
} }

View File

@@ -36,19 +36,18 @@ import org.apache.commons.lang3.StringUtils;
public abstract class StorageReaderFile<T> implements IItemReader<T> { public abstract class StorageReaderFile<T> implements IItemReader<T> {
private final File file; private final File file;
private final Lambda1<String,T> keySelector; private final Lambda1<String, T> keySelector;
/** /**
* Instantiates a new storage reader file. * Instantiates a new storage reader file.
* *
* @param file0 the file0 * @param file0 the file0
*/ */
public StorageReaderFile(final String pathname, Lambda1<String,T> keySelector0) { public StorageReaderFile(final String pathname, Lambda1<String, T> keySelector0) {
this(new File(pathname), keySelector0); this(new File(pathname), keySelector0);
} }
public StorageReaderFile(final File file0, Lambda1<String, T> keySelector0) {
public StorageReaderFile(final File file0, Lambda1<String,T> keySelector0) {
this.file = file0; this.file = file0;
keySelector = keySelector0; keySelector = keySelector0;
} }
@@ -94,7 +93,7 @@ public abstract class StorageReaderFile<T> implements IItemReader<T> {
protected boolean lineContainsObject(final String line) { protected boolean lineContainsObject(final String line) {
return !StringUtils.isBlank(line) && !line.trim().startsWith("#"); return !StringUtils.isBlank(line) && !line.trim().startsWith("#");
} }
@Override @Override
public String getItemKey(T item) { public String getItemKey(T item) {
return keySelector.apply(item); return keySelector.apply(item);

View File

@@ -45,7 +45,7 @@ import forge.error.ErrorViewer;
public abstract class StorageReaderFolder<T> implements IItemReader<T> { public abstract class StorageReaderFolder<T> implements IItemReader<T> {
private final File directory; private final File directory;
private final Lambda1<String,T> keySelector; private final Lambda1<String, T> keySelector;
/** /**
* Gets the directory. * Gets the directory.
@@ -61,7 +61,7 @@ public abstract class StorageReaderFolder<T> implements IItemReader<T> {
* *
* @param deckDir0 the deck dir0 * @param deckDir0 the deck dir0
*/ */
public StorageReaderFolder(final File deckDir0, Lambda1<String,T> keySelector0) { public StorageReaderFolder(final File deckDir0, Lambda1<String, T> keySelector0) {
this.directory = deckDir0; this.directory = deckDir0;
keySelector = keySelector0; keySelector = keySelector0;
@@ -143,7 +143,7 @@ public abstract class StorageReaderFolder<T> implements IItemReader<T> {
* @return FilenameFilter to pick only relevant objects for deserialization * @return FilenameFilter to pick only relevant objects for deserialization
*/ */
protected abstract FilenameFilter getFileFilter(); protected abstract FilenameFilter getFileFilter();
public String getItemKey(T item) { public String getItemKey(T item) {
return keySelector.apply(item); return keySelector.apply(item);
} }

View File

@@ -97,9 +97,9 @@ public class StorageView<T> implements Iterable<T>, IStorageView<T> {
public boolean contains(String name) { public boolean contains(String name) {
return this.map.containsKey(name); return this.map.containsKey(name);
} }
@Override @Override
public int getCount() { public int getCount() {
return this.map.size(); return this.map.size();
} }
} }