use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class MKMFileWantListExport method exportStock.
@Override
public void exportStock(List<MagicCardStock> stock, File f) throws IOException {
MagicDeck d = new MagicDeck();
d.setName(f.getName());
for (MagicCardStock mcs : stock) {
d.getMap().put(mcs.getMagicCard(), mcs.getQte());
}
export(d, f);
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class MKMFileWantListExport method importDeck.
@Override
public MagicDeck importDeck(File f) throws IOException {
try (BufferedReader read = new BufferedReader(new FileReader(f))) {
MagicDeck deck = new MagicDeck();
deck.setName(f.getName().substring(0, f.getName().indexOf('.')));
String line = read.readLine();
while (line != null) {
int qte = Integer.parseInt(line.substring(0, line.indexOf(' ')));
String name = line.substring(line.indexOf(' '), line.indexOf('('));
deck.getMap().put(MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", name.trim(), null, true).get(0), qte);
line = read.readLine();
}
return deck;
}
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class MTGDesktopCompanionExport method exportStock.
@Override
public void exportStock(List<MagicCardStock> stock, File f) throws IOException {
MagicDeck d = new MagicDeck();
d.setName(f.getName());
for (MagicCardStock mcs : stock) {
d.getMap().put(mcs.getMagicCard(), mcs.getQte());
}
export(d, f);
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class MTGODeckExport method exportStock.
@Override
public void exportStock(List<MagicCardStock> stock, File f) throws IOException {
MagicDeck d = new MagicDeck();
d.setName(f.getName());
for (MagicCardStock mcs : stock) {
d.getMap().put(mcs.getMagicCard(), mcs.getQte());
}
export(d, f);
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class MTGODeckExport method importDeck.
@Override
public MagicDeck importDeck(File f) throws IOException {
try (BufferedReader read = new BufferedReader(new FileReader(f))) {
MagicDeck deck = new MagicDeck();
deck.setName(f.getName().substring(0, f.getName().indexOf('.')));
String line = read.readLine();
while (line != null) {
if (!line.startsWith("//") && line.length() > 0) {
int sep = line.indexOf(' ');
String name = line.substring(sep, line.length()).trim();
String qte = line.substring(0, sep).trim();
if (line.startsWith("SB: ")) {
line = line.replaceAll("SB: ", "");
sep = line.indexOf(' ');
name = line.substring(sep, line.length()).trim();
qte = line.substring(0, sep).trim();
List<MagicCard> list = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", name, null, true);
deck.getMapSideBoard().put(list.get(0), Integer.parseInt(qte));
} else {
List<MagicCard> list = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", name, null, true);
deck.getMap().put(list.get(0), Integer.parseInt(qte));
}
}
line = read.readLine();
}
return deck;
}
}
Aggregations