use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class MagicWorkStationDeckExport 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 MagicWorkStationDeckExport 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();
int ecart = 0;
while (line != null) {
line = line.trim();
if (!line.startsWith("//")) {
int qte = 0;
MagicCard mc = null;
if (line.startsWith("SB"))
deck.getMapSideBoard().put(mc, qte);
else
deck.getMap().put(mc, qte);
}
line = read.readLine();
}
return deck;
}
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class ManualImportExport 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 MkmOnlineExport method importDeck.
@Override
public MagicDeck importDeck(File f) throws IOException {
WantsService service = new WantsService();
MagicDeck d = new MagicDeck();
d.setName(f.getName());
Wantslist list = null;
for (Wantslist l : service.getWantList()) if (l.getName().equalsIgnoreCase(d.getName()))
list = l;
if (list == null)
throw new NullPointerException(getName() + " can't import deck for " + f.getName());
service.loadItems(list);
for (WantItem w : list.getItem()) {
try {
Product p = w.getProduct();
if (p.getEnName().contains("(Version "))
p.setEnName(p.getEnName().substring(0, p.getEnName().indexOf("(Version")));
d.getMap().put(MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", p.getEnName().trim(), null, true).get(0), w.getCount());
} catch (Exception e) {
logger.error("could not import " + w);
}
}
return d;
}
use of org.magic.api.beans.MagicDeck in project MtgDesktopCompanion by nicho92.
the class MkmOnlineExport method exportStock.
@Override
public void exportStock(List<MagicCardStock> stock, File f) throws IOException {
if (!getString("STOCK_USE").equals("true")) {
MagicDeck d = new MagicDeck();
d.setName(f.getName());
for (MagicCardStock mcs : stock) {
d.getMap().put(mcs.getMagicCard(), mcs.getQte());
}
export(d, f);
} else {
StockService serv = new StockService();
ProductServices prods = new ProductServices();
EnumMap<PRODUCT_ATTS, String> enumAtts = new EnumMap<>(PRODUCT_ATTS.class);
enumAtts.put(PRODUCT_ATTS.idGame, "1");
enumAtts.put(PRODUCT_ATTS.exact, "true");
List<Article> list = new ArrayList<>();
for (MagicCardStock mcs : stock) {
Product p = MagicCardMarketPricer2.getProductFromCard(mcs.getMagicCard(), prods.findProduct(mcs.getMagicCard().getName(), enumAtts));
Article a = new Article();
a.setAltered(mcs.isAltered());
a.setSigned(mcs.isSigned());
a.setCount(mcs.getQte());
a.setFoil(mcs.isFoil());
a.setPrice(mcs.getPrice());
a.setCondition(convert(mcs.getCondition()));
a.setLanguage(convertLang(mcs.getLanguage()));
a.setProduct(p);
a.setIdProduct(p.getIdProduct());
list.add(a);
}
serv.addArticles(list);
}
}
Aggregations