use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class JsonExport method importStock.
@Override
public List<MagicCardStock> importStock(File f) throws IOException {
JsonReader reader = new JsonReader(new FileReader(f));
JsonArray root = new JsonParser().parse(reader).getAsJsonArray();
List<MagicCardStock> list = new ArrayList<>();
for (int i = 0; i < root.size(); i++) {
JsonObject line = root.get(i).getAsJsonObject();
MagicCardStock mc = new Gson().fromJson(line, MagicCardStock.class);
list.add(mc);
}
return list;
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class MkmOnlineExport method importStock.
@Override
public List<MagicCardStock> importStock(File f) throws IOException {
if (!getString("STOCK_USE").equals("true"))
return importFromDeck(importDeck(f));
StockService serv = new StockService();
List<Article> list = serv.getStock();
List<MagicCardStock> stock = new ArrayList<>();
for (Article a : list) {
MagicCardStock mcs = new MagicCardStock();
mcs.setUpdate(true);
mcs.setIdstock(-1);
mcs.setComment(a.getComments());
mcs.setLanguage(a.getLanguage().getLanguageName());
mcs.setQte(a.getCount());
mcs.setFoil(a.isFoil());
mcs.setSigned(a.isSigned());
mcs.setAltered(a.isAltered());
mcs.setPrice(a.getPrice());
MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", a.getProduct().getEnName(), null, true).get(0);
MagicCardMarketPricer2.selectEditionCard(mc, a.getProduct().getExpansionName());
mcs.setMagicCard(mc);
mcs.setCondition(convert(a.getCondition()));
stock.add(mcs);
}
return stock;
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class OCTGNDeckExport 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);
}
Aggregations