mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
There was endless loop due to my refactoring
This commit is contained in:
@@ -45,34 +45,36 @@ public class ReadDraftRankings {
|
|||||||
|
|
||||||
final Map<String, Map<String, Integer>> map = new HashMap<String, Map<String, Integer>>();
|
final Map<String, Map<String, Integer>> map = new HashMap<String, Map<String, Integer>>();
|
||||||
for( String line : FileUtil.readFile(file)) {
|
for( String line : FileUtil.readFile(file)) {
|
||||||
|
|
||||||
// stop reading if end of file or blank line is read
|
// stop reading if end of file or blank line is read
|
||||||
while ((line != null) && (line.trim().length() != 0)) {
|
if(line == null || line.length() == 0) {
|
||||||
if (!line.startsWith(ReadDraftRankings.COMMENT)) {
|
break;
|
||||||
final String[] s = line.split("\\|");
|
}
|
||||||
final String rankStr = s[0].trim().substring(1);
|
|
||||||
final String name = s[1].trim().replaceAll("-", " ").replaceAll("[^A-Za-z ]", "");
|
|
||||||
// final String rarity = s[2].trim();
|
|
||||||
final String edition = s[3].trim();
|
|
||||||
|
|
||||||
try {
|
if (line.startsWith(ReadDraftRankings.COMMENT)) {
|
||||||
final int rank = Integer.parseInt(rankStr);
|
continue;
|
||||||
if (!map.containsKey(edition)) {
|
}
|
||||||
map.put(edition, new HashMap<String, Integer>());
|
final String[] s = line.split("\\|");
|
||||||
}
|
final String rankStr = s[0].trim().substring(1);
|
||||||
map.get(edition).put(name, rank);
|
final String name = s[1].trim().replaceAll("-", " ").replaceAll("[^A-Za-z ]", "");
|
||||||
if (setSizes.containsKey(edition)) {
|
// final String rarity = s[2].trim();
|
||||||
setSizes.put(edition, Math.max(setSizes.get(edition), rank));
|
final String edition = s[3].trim();
|
||||||
} else {
|
|
||||||
setSizes.put(edition, rank);
|
try {
|
||||||
}
|
final int rank = Integer.parseInt(rankStr);
|
||||||
} catch (NumberFormatException nfe) {
|
if (!map.containsKey(edition)) {
|
||||||
Log.warn("NumberFormatException: " + nfe.getMessage());
|
map.put(edition, new HashMap<String, Integer>());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // if
|
map.get(edition).put(name, rank);
|
||||||
|
if (setSizes.containsKey(edition)) {
|
||||||
|
setSizes.put(edition, Math.max(setSizes.get(edition), rank));
|
||||||
|
} else {
|
||||||
|
setSizes.put(edition, rank);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.warn("NumberFormatException: " + nfe.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
} // readFile()
|
} // readFile()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user