- CheckStyle.

This commit is contained in:
Chris
2012-02-18 21:51:58 +00:00
parent aeb44f00f0
commit 7e1868bbb8

View File

@@ -81,10 +81,8 @@ public class OldDeckParser {
convertDrafts();
}
private void convertDrafts()
{
for( File f : deckDir.listFiles(bdkFileFilter))
{
private void convertDrafts() {
for (File f : deckDir.listFiles(bdkFileFilter)) {
boolean gotError = false;
Deck human = Deck.fromFile(new File(f, "0.dck"));
final DeckSet d = new DeckSet(human.getName());
@@ -109,28 +107,29 @@ public class OldDeckParser {
}
if (mayDelete) {
for( File f1 : f.listFiles() )
for (File f1 : f.listFiles()) {
f1.delete();
}
f.delete();
}
}
}
private void convertConstructedAndSealed()
{
private void convertConstructedAndSealed() {
boolean allowDeleteUnsupportedConstructed = false;
Map<String, Pair<DeckSet, MutablePair<File, File>>> sealedDecks = new TreeMap<String, Pair<DeckSet, MutablePair<File, File>>>(String.CASE_INSENSITIVE_ORDER);
for( File f : deckDir.listFiles(DeckSerializer.DCK_FILE_FILTER))
{
for (File f : deckDir.listFiles(DeckSerializer.DCK_FILE_FILTER)) {
boolean importedOk = false;
List<String> fileLines = FileUtil.readFile(f);
Map<String, List<String>> sections = SectionUtil.parseSections(fileLines);
DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
String name = dh.getName();
if ( dh.isCustomPool() ) { continue; }
if (dh.isCustomPool()) {
continue;
}
switch(dh.getDeckType()) {
case Constructed:
@@ -143,8 +142,9 @@ public class OldDeckParser {
allowDeleteUnsupportedConstructed = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Problem converting decks", JOptionPane.YES_NO_OPTION);
}
}
if( importedOk || allowDeleteUnsupportedConstructed )
if (importedOk || allowDeleteUnsupportedConstructed) {
f.delete();
}
break;
case Sealed:
@@ -152,8 +152,9 @@ public class OldDeckParser {
name = name.startsWith("AI_") ? name.replace("AI_", "") : name;
Pair<DeckSet, MutablePair<File, File>> stored = sealedDecks.get(name);
if( null == stored )
if (null == stored) {
stored = ImmutablePair.of(new DeckSet(name), MutablePair.of((File) null, (File) null));
}
Deck deck = Deck.fromLines(fileLines);
if (isAi) {
@@ -172,15 +173,15 @@ public class OldDeckParser {
// there stay only orphans
sealedDecks.remove(name);
} else
} else {
sealedDecks.put(name, stored);
}
break;
}
}
// advise to kill orphaned decks
if( !sealedDecks.isEmpty() )
{
if (!sealedDecks.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (Pair<DeckSet, MutablePair<File, File>> s : sealedDecks.values()) {
String missingPart = s.getRight().getLeft() == null ? "human" : "computer";
@@ -189,8 +190,7 @@ public class OldDeckParser {
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 )
{
if (response == JOptionPane.YES_OPTION) {
for (Pair<DeckSet, MutablePair<File, File>> s : sealedDecks.values()) {
if (s.getRight().getLeft() != null) { s.getRight().getLeft().delete(); }
if (s.getRight().getRight() != null) { s.getRight().getRight().delete(); }