From 0a2c81ad7b710dfc4f3ec88504bf273e2a2ca740 Mon Sep 17 00:00:00 2001 From: John Hitchings Date: Sat, 4 May 2019 14:08:27 -0700 Subject: [PATCH] DOM set codes get exported as DAR for MTGA. --- .../cards/decks/exporter/MtgArenaDeckExporter.java | 13 +++++++++---- .../decks/exporter/MtgArenaDeckExporterTest.java | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporter.java b/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporter.java index 220637ecff..68073ae2cc 100644 --- a/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporter.java +++ b/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporter.java @@ -1,5 +1,6 @@ package mage.cards.decks.exporter; +import com.google.common.collect.ImmutableMap; import mage.cards.decks.DeckCardInfo; import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckFileFilter; @@ -13,9 +14,11 @@ import java.util.*; */ public class MtgArenaDeckExporter extends DeckExporter { - private final String ext = "mtga"; - private final String description = "MTG Arena's deck format (*.mtga)"; - private final FileFilter fileFilter = new DeckFileFilter(ext, description); + private static final String ext = "mtga"; + private static final String description = "MTG Arena's deck format (*.mtga)"; + private static final FileFilter fileFilter = new DeckFileFilter(ext, description); + + private static final Map SET_CODE_REPLACEMENTS = ImmutableMap.of("DOM", "DAR"); @Override public void writeDeck(PrintWriter out, DeckCardLists deck) { @@ -33,7 +36,9 @@ public class MtgArenaDeckExporter extends DeckExporter { private List prepareCardsList(List sourceCards, Map amount, String prefix) { List res = new ArrayList<>(); for (DeckCardInfo card : sourceCards) { - String name = card.getCardName() + " (" + card.getSetCode().toUpperCase(Locale.ENGLISH) + ") " + card.getCardNum(); + String setCode = card.getSetCode().toUpperCase(Locale.ENGLISH); + setCode = SET_CODE_REPLACEMENTS.getOrDefault(setCode, setCode); + String name = card.getCardName() + " (" + setCode + ") " + card.getCardNum(); String code = prefix + name; int curAmount = amount.getOrDefault(code, 0); if (curAmount == 0) { diff --git a/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporterTest.java b/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporterTest.java index 773a0d19a3..af7666a45d 100644 --- a/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporterTest.java +++ b/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporterTest.java @@ -22,6 +22,7 @@ public class MtgArenaDeckExporterTest { deck.getCards().add(new DeckCardInfo("Plains", "2", "RNA", 3)); deck.getCards().add(new DeckCardInfo("Plains", "2", "RNA", 5)); // must combine deck.getCards().add(new DeckCardInfo("Mountain", "3", "RNA", 1)); + deck.getCards().add(new DeckCardInfo("Goblin Chainwhirler", "129", "DOM", 4)); deck.getSideboard().add(new DeckCardInfo("Island", "1", "RNA", 2)); deck.getSideboard().add(new DeckCardInfo("Island", "1", "RNA", 5)); // must combine deck.getSideboard().add(new DeckCardInfo("Mountain", "2", "RNA", 3)); @@ -30,6 +31,7 @@ public class MtgArenaDeckExporterTest { assertEquals("2 Forest (RNA) 1" + System.lineSeparator() + "8 Plains (RNA) 2" + System.lineSeparator() + "1 Mountain (RNA) 3" + System.lineSeparator() + + "4 Goblin Chainwhirler (DAR) 129" + System.lineSeparator() + System.lineSeparator() + "7 Island (RNA) 1" + System.lineSeparator() + "3 Mountain (RNA) 2" + System.lineSeparator(),