From a2e2ed2a40097e760976aaafc2c3a43d9c4fce18 Mon Sep 17 00:00:00 2001 From: Alex Marcotte Date: Fri, 27 May 2016 14:23:45 -0400 Subject: [PATCH 1/2] Added missing rarity for EMA Winter Orb --- Mage.Sets/src/mage/sets/eternalmasters/WinterOrb.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mage.Sets/src/mage/sets/eternalmasters/WinterOrb.java b/Mage.Sets/src/mage/sets/eternalmasters/WinterOrb.java index b230cdff20..dceb86c162 100644 --- a/Mage.Sets/src/mage/sets/eternalmasters/WinterOrb.java +++ b/Mage.Sets/src/mage/sets/eternalmasters/WinterOrb.java @@ -27,9 +27,10 @@ */ package mage.sets.eternalmasters; -import java.util.UUID; import mage.constants.Rarity; +import java.util.UUID; + /** * * @author fireshoes @@ -40,7 +41,7 @@ public class WinterOrb extends mage.sets.limitedalpha.WinterOrb { super(ownerId); this.cardNumber = 234; this.expansionSetCode = "EMA"; - this.rarity = Rarity.; + this.rarity = Rarity.RARE; } public WinterOrb(final WinterOrb card) { From 283c9fa154bddb0c2cbd3aeeaa92de352cf74a8e Mon Sep 17 00:00:00 2001 From: Alex Marcotte Date: Mon, 30 May 2016 23:01:57 -0400 Subject: [PATCH 2/2] Text import will automatically start sideboard after a single blank line. Added a JUnit test for TxtDeckImporter. --- Mage.Tests/JustLands.txt | 6 +++ .../decks/importer/TxtDeckImporterTest.java | 43 +++++++++++++++++++ .../cards/decks/importer/TxtDeckImporter.java | 21 ++++----- 3 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 Mage.Tests/JustLands.txt create mode 100644 Mage.Tests/src/test/java/org/mage/test/decks/importer/TxtDeckImporterTest.java diff --git a/Mage.Tests/JustLands.txt b/Mage.Tests/JustLands.txt new file mode 100644 index 0000000000..9d668492ee --- /dev/null +++ b/Mage.Tests/JustLands.txt @@ -0,0 +1,6 @@ +1 Forest +1 Plains +1 Island + +1 Swamp +1 Mountain \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/decks/importer/TxtDeckImporterTest.java b/Mage.Tests/src/test/java/org/mage/test/decks/importer/TxtDeckImporterTest.java new file mode 100644 index 0000000000..aa351e47f8 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/decks/importer/TxtDeckImporterTest.java @@ -0,0 +1,43 @@ +package org.mage.test.decks.importer; + +import mage.cards.decks.DeckCardInfo; +import mage.cards.decks.DeckCardLists; +import mage.cards.decks.importer.TxtDeckImporter; +import mage.cards.repository.CardInfo; +import mage.cards.repository.CardRepository; +import org.junit.Assert; +import org.junit.Test; + +public class TxtDeckImporterTest { + + @Test + public void testImportWithBlankLineAboveSideboard() { + TxtDeckImporter importer = new TxtDeckImporter(); + + CardInfo card; + DeckCardLists deck = new DeckCardLists(); + + String[] cards = {"Plains", "Forest", "Island"}; + String[] sideboard = {"Swamp", "Mountain"}; + + for (String c : cards) { + card = CardRepository.instance.findPreferedCoreExpansionCard(c, true); + assert card != null; + deck.getCards().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getSetCode())); + } + + for (String s : sideboard) { + card = CardRepository.instance.findPreferedCoreExpansionCard(s, true); + assert card != null; + deck.getSideboard().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getSetCode())); + } + + Assert.assertEquals("Deck does not contain 3 cards, found " + deck.getCards().size(), 3, deck.getCards().size()); + Assert.assertEquals("Sideboard does not contain 2 cards, found " + deck.getSideboard().size(), 2, deck.getSideboard().size()); + + DeckCardLists imported = importer.importDeck("JustLands.txt"); + + Assert.assertEquals("Imported deck does not contain 3 cards, found " + imported.getCards().size(), 3, imported.getCards().size()); + Assert.assertEquals("Imported sideboard does not contain 2 cards, found " + imported.getSideboard().size(), 2, imported.getSideboard().size()); + } +} diff --git a/Mage/src/main/java/mage/cards/decks/importer/TxtDeckImporter.java b/Mage/src/main/java/mage/cards/decks/importer/TxtDeckImporter.java index 3f5cf742f0..59ace12525 100644 --- a/Mage/src/main/java/mage/cards/decks/importer/TxtDeckImporter.java +++ b/Mage/src/main/java/mage/cards/decks/importer/TxtDeckImporter.java @@ -27,14 +27,15 @@ */ package mage.cards.decks.importer; -import java.util.Arrays; -import java.util.HashSet; -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.Set; + /** * * @author BetaSteward_at_googlemail.com @@ -46,7 +47,7 @@ public class TxtDeckImporter extends DeckImporter { public static final Set IGNORE_NAMES = new HashSet<>(Arrays.asList(SET_VALUES)); private boolean sideboard = false; - private int emptyLinesInARow = 0; + private int nonEmptyLinesTotal = 0; @Override protected void readLine(String line, DeckCardLists deckList) { @@ -57,14 +58,14 @@ public class TxtDeckImporter extends DeckImporter { if (line.startsWith("//")) { return; } - if (line.length() == 0) { - emptyLinesInARow++; - if (emptyLinesInARow > 1) { - sideboard = true; - } + + // Start the sideboard on empty line that follows + // at least 1 non-empty line + if (line.length() == 0 && nonEmptyLinesTotal > 0) { + sideboard = true; return; } else { - emptyLinesInARow = 0; + nonEmptyLinesTotal++; } line = line.replace("\t", " "); // changing tabs to blanks as delimiter