use of fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints in project JCELechat by guiguilechat.
the class IndustryTranslater method translateBlueprints.
private static void translateBlueprints(LinkedHashMap<Integer, Blueprint> blueprints, LinkedHashMap<Integer, IndustryUsage> usages) {
// set of type ids that are seeded by NPCs
Set<Integer> seededItems = EnpcCorporations.load().values().stream().flatMap(crp -> crp.corporationTrades.keySet().stream()).collect(Collectors.toSet());
for (Entry<Integer, Eblueprints> e : Eblueprints.load().entrySet()) {
EveType type = TypeIndex.getType(e.getValue().blueprintTypeID);
if (type != null) {
if (type.published) {
Blueprint bp2 = makeBlueprint(e.getValue());
if (bp2.copying == null || bp2.invention == null || bp2.manufacturing == null || bp2.reaction == null || bp2.research_material == null || bp2.research_time == null) {
Set<String> missingActivities = new HashSet<>();
if (bp2.copying == null) {
missingActivities.add("copying");
}
if (bp2.invention == null) {
missingActivities.add("invention");
}
if (bp2.manufacturing == null) {
missingActivities.add("manufacturing");
}
if (bp2.reaction == null) {
missingActivities.add("reaction");
}
if (bp2.research_material == null) {
missingActivities.add("research_material");
}
if (bp2.research_time == null) {
missingActivities.add("research_time");
}
logger.debug("skipping bp " + bp2.name() + "(" + bp2.id + ")" + " for unresolved activities : " + missingActivities);
continue;
}
bp2.seeded = seededItems.contains(bp2.id);
blueprints.put(e.getValue().blueprintTypeID, bp2);
addUsages(bp2, usages);
} else {
logger.debug("skipping bp for unpublished " + type.name);
}
} else {
logger.debug("skipping unpublished bp id=" + e.getValue().blueprintTypeID);
}
}
for (Entry<Integer, EtypeMaterials> e : EtypeMaterials.load().entrySet()) {
EveType inputMat = TypeIndex.getType(e.getKey());
if (inputMat == null) {
logger.debug("can't find type id=" + e.getKey() + " that reprocess in " + e.getValue());
continue;
}
int portionSize = inputMat.portionSize;
IndustryUsage usage = usages.computeIfAbsent(e.getKey(), i -> new IndustryUsage());
for (Material mat : e.getValue().materials) {
EveType outputmat = TypeIndex.getType(mat.materialTypeID);
if (outputmat != null) {
usage.reprocessInto.put(mat.materialTypeID, 1.0 * mat.quantity / portionSize);
usages.computeIfAbsent(mat.materialTypeID, i -> new IndustryUsage()).reprocessedFrom.add(e.getKey());
} else {
logger.debug("can't find type id " + mat.materialTypeID + " reprocessed from " + inputMat.name);
}
}
}
// sort the usages by item name
ArrayList<Entry<Integer, IndustryUsage>> l = new ArrayList<>(usages.entrySet());
Collections.sort(l, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
usages.clear();
for (Entry<Integer, IndustryUsage> e : l) {
usages.put(e.getKey(), e.getValue());
}
}
use of fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints in project JCELechat by guiguilechat.
the class NPCsTranslater method makeOffer.
protected static LPOffer makeOffer(R_get_loyalty_stores_corporation_id_offers o) {
LinkedHashMap<Integer, Eblueprints> bps = Eblueprints.load();
LPOffer lpo = new LPOffer();
lpo.requirements.isk += o.isk_cost;
lpo.requirements.lp += o.lp_cost;
lpo.name = EtypeIDs.getName(o.type_id);
lpo.id = o.offer_id;
Stream.of(o.required_items).sorted(Comparator.comparing(req -> req.type_id)).forEach(ir -> {
ItemRef translated = new ItemRef();
translated.quantity = ir.quantity;
translated.id = ir.type_id;
lpo.requirements.items.add(translated);
});
Eblueprints bp = bps.get(o.type_id);
if (bp != null) {
// the lp offers a BPC
lpo.bpid = bp.blueprintTypeID;
lpo.bpruns = o.quantity;
for (Material m : bp.activities.manufacturing.materials) {
ItemRef translated = new ItemRef();
translated.quantity = m.quantity * o.quantity;
translated.id = m.typeID;
lpo.requirements.items.add(translated);
}
Material prod = bp.activities.manufacturing.products.get(0);
lpo.product.id = prod.typeID;
lpo.product.quantity = prod.quantity * o.quantity;
if (lpo.product.type() == null) {
logger.debug("discard offer " + o.offer_id + " as product type " + prod.typeID + " can't be loaded");
return null;
} else {
lpo.name = (o.quantity == 1 ? "" : "" + o.quantity + "* ") + lpo.product.name() + "(BPC)";
}
} else {
// the lp offers a non-bpc
lpo.product.quantity = o.quantity;
lpo.product.id = o.type_id;
if (lpo.product.type() == null) {
logger.debug("discard offer " + o.offer_id + " as product type " + o.type_id + " can't be loaded");
return null;
} else {
lpo.name = (o.quantity == 1 ? "" : "" + o.quantity + "* ") + lpo.product.name();
}
}
return lpo;
}
Aggregations