use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class CSVExport method importStock.
@Override
public List<MagicCardStock> importStock(File f) throws IOException {
try (BufferedReader read = new BufferedReader(new FileReader(f))) {
List<MagicCardStock> stock = new ArrayList<>();
String line = read.readLine();
line = read.readLine();
while (line != null) {
String[] part = line.split(";");
MagicCardStock mcs = new MagicCardStock();
MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", part[1], null, true).get(0);
for (MagicEdition ed : mc.getEditions()) if (ed.getSet().equals(part[2])) {
mc.getEditions().add(0, ed);
break;
}
mcs.setMagicCard(mc);
mcs.setLanguage(part[3]);
mcs.setQte(Integer.parseInt(part[4]));
mcs.setCondition(EnumCondition.valueOf(part[5]));
mcs.setFoil(Boolean.valueOf(part[6]));
mcs.setAltered(Boolean.valueOf(part[7]));
mcs.setSigned(Boolean.valueOf(part[8]));
mcs.setMagicCollection(new MagicCollection(part[9]));
mcs.setPrice(Double.valueOf(part[10]));
try {
mcs.setComment(part[11]);
} catch (ArrayIndexOutOfBoundsException aioob) {
mcs.setComment("");
}
mcs.setIdstock(-1);
mcs.setUpdate(true);
stock.add(mcs);
line = read.readLine();
}
return stock;
}
}
use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.
the class ScryFallPicturesProvider method getPicture.
@Override
public BufferedImage getPicture(MagicCard mc, MagicEdition ed) throws IOException {
MagicEdition selected = ed;
if (ed == null)
selected = mc.getEditions().get(0);
if (MTGControler.getInstance().getEnabledCache().getPic(mc, selected) != null) {
logger.trace("cached " + mc + "(" + selected + ") found");
return resizeCard(MTGControler.getInstance().getEnabledCache().getPic(mc, selected), newW, newH);
}
URL url = generateLink(mc, selected, false);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("User-Agent", getString("USER_AGENT"));
connection.connect();
logger.debug("load pics " + connection.getURL().toString());
try {
BufferedImage bufferedImage = ImageIO.read(connection.getInputStream());
if (bufferedImage != null)
MTGControler.getInstance().getEnabledCache().put(bufferedImage, mc, selected);
return resizeCard(bufferedImage, newW, newH);
} catch (Exception e) {
logger.error(e);
return getBackPicture();
}
}
Aggregations