Search in sources :

Example 1 with DeckExporter

use of mage.cards.decks.exporter.DeckExporter in project mage by magefree.

the class MtgArenaDeckExporterTest method writeDeck.

@Test
public void writeDeck() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DeckCardLists deck = new DeckCardLists();
    deck.getCards().add(new DeckCardInfo("Forest", "1", "RNA", 2));
    deck.getCards().add(new DeckCardInfo("Plains", "2", "RNA", 3));
    // must combine
    deck.getCards().add(new DeckCardInfo("Plains", "2", "RNA", 5));
    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));
    // must combine
    deck.getSideboard().add(new DeckCardInfo("Island", "1", "RNA", 5));
    deck.getSideboard().add(new DeckCardInfo("Mountain", "2", "RNA", 3));
    DeckExporter exporter = new MtgArenaDeckExporter();
    exporter.writeDeck(baos, deck);
    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(), baos.toString());
}
Also used : DeckCardLists(mage.cards.decks.DeckCardLists) MtgArenaDeckExporter(mage.cards.decks.exporter.MtgArenaDeckExporter) DeckExporter(mage.cards.decks.exporter.DeckExporter) DeckCardInfo(mage.cards.decks.DeckCardInfo) MtgArenaDeckExporter(mage.cards.decks.exporter.MtgArenaDeckExporter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 2 with DeckExporter

use of mage.cards.decks.exporter.DeckExporter in project mage by magefree.

the class DeckExportClipboardDialog method onRefreshData.

private void onRefreshData() {
    int formatIndex = comboFormats.getSelectedIndex();
    if (formatIndex < 0 || formatIndex >= formats.size()) {
        return;
    }
    DeckExporter exporter = formats.get(formatIndex).getExporter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    exporter.writeDeck(baos, deck.getDeckCardLists());
    editData.setText(baos.toString());
    editData.setCaretPosition(0);
}
Also used : DeckExporter(mage.cards.decks.exporter.DeckExporter) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DeckExporter (mage.cards.decks.exporter.DeckExporter)2 DeckCardInfo (mage.cards.decks.DeckCardInfo)1 DeckCardLists (mage.cards.decks.DeckCardLists)1 MtgArenaDeckExporter (mage.cards.decks.exporter.MtgArenaDeckExporter)1 Test (org.junit.Test)1