Fixed text deck import (empty lines);
-
package mage.cards.decks.importer;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
import mage.cards.decks.DeckCardInfo;
import mage.cards.decks.DeckCardLists;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
/**
- *
* @author BetaSteward_at_googlemail.com
*/
public class TxtDeckImporter extends PlainTextDeckImporter {
@@ -22,7 +21,7 @@ public class TxtDeckImporter extends PlainTextDeckImporter {
private boolean sideboard = false;
private boolean switchSideboardByEmptyLine = true; // all cards after first empty line will be sideboard (like mtgo format)
- private int nonEmptyLinesTotal = 0;
+ private boolean wasCardLines = false;
public TxtDeckImporter(boolean haveSideboardSection) {
if (haveSideboardSection) {
@@ -56,19 +55,17 @@ public class TxtDeckImporter extends PlainTextDeckImporter {
}
// switch sideboard by empty line
- if (switchSideboardByEmptyLine && line.isEmpty() && nonEmptyLinesTotal > 0) {
+ if (switchSideboardByEmptyLine && line.isEmpty() && wasCardLines) {
if (!sideboard) {
sideboard = true;
} else {
- sbMessage.append("Found empty line at ").append(lineCount).append(", but sideboard already used. Use //sideboard switcher OR one empty line to devide your cards.").append('\n');
+ sbMessage.append("Found empty line at ").append(lineCount).append(", but sideboard already used. Use //sideboard switcher OR use only one empty line to devide your cards.").append('\n');
}
// skip empty line
return;
}
- nonEmptyLinesTotal++;
-
// single line sideboard card from deckstats.net
// SB: 3 Carnage Tyrant
boolean singleLineSideBoard = false;
@@ -102,6 +99,9 @@ public class TxtDeckImporter extends PlainTextDeckImporter {
if (IGNORE_NAMES.contains(lineName) || IGNORE_NAMES.contains(lineNum)) {
return;
}
+
+ wasCardLines = true;
+
try {
int num = Integer.parseInt(lineNum.replaceAll("\\D+", ""));
if ((num < 0) || (num > 100)) {
