use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class PDFExport 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 WebsiteImportExport method importStock.
@Override
public List<MagicCardStock> importStock(File f) throws IOException {
MagicDeck d = importDeck(f);
List<MagicCardStock> ret = new ArrayList<>();
for (MagicCard mc : d.getMap().keySet()) {
MagicCardStock stock = new MagicCardStock();
stock.setMagicCard(mc);
stock.setQte(d.getMap().get(mc));
stock.setUpdate(true);
stock.setIdstock(-1);
ret.add(stock);
}
return ret;
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class XMageDeckExport 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("NAME:")) {
if (!line.startsWith("SB:")) {
MagicEdition ed = new MagicEdition();
ed.setId(line.substring(line.indexOf('[') + 1, line.indexOf(':')));
String cardName = line.substring(line.indexOf(']') + 1, line.length()).trim();
int qte = Integer.parseInt(line.substring(0, line.indexOf('[')).trim());
MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", cardName, ed, true).get(0);
deck.getMap().put(mc, qte);
} else {
line = line.replace("SB:", "").trim();
MagicEdition ed = new MagicEdition();
ed.setId(line.substring(line.indexOf('[') + 1, line.indexOf(':')));
String cardName = line.substring(line.indexOf(']') + 1, line.length()).trim();
int qte = Integer.parseInt(line.substring(0, line.indexOf('[')).trim());
MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", cardName, ed, true).get(0);
deck.getMap().put(mc, qte);
}
} else {
deck.setName(line.replaceAll("NAME: ", ""));
}
line = read.readLine();
}
return deck;
}
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class XMageDeckExport 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 AbstractCardExport method export.
@Override
public void export(List<MagicCard> cards, File f) throws IOException {
MagicDeck d = new MagicDeck();
d.setName("export " + getName() + " cards");
d.setDescription(getName() + " export to " + f.getName());
d.setDateCreation(new Date());
int i = 0;
for (MagicCard mc : cards) {
d.add(mc);
setChanged();
notifyObservers(i++);
}
export(d, f);
}
Aggregations