Search in sources :

Example 1 with Eblueprints

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());
    }
}
Also used : FileTools(fr.guiguilechat.jcelechat.model.FileTools) Blueprint(fr.guiguilechat.jcelechat.model.sde.industry.Blueprint) LoggerFactory(org.slf4j.LoggerFactory) Function(java.util.function.Function) InventionDecryptor(fr.guiguilechat.jcelechat.model.sde.industry.InventionDecryptor) Material(fr.guiguilechat.jcelechat.model.sde.load.fsd.EtypeMaterials.Material) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Eblueprints(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints) Map(java.util.Map) Asteroid(fr.guiguilechat.jcelechat.model.sde.types.Asteroid) Activity(fr.guiguilechat.jcelechat.model.sde.industry.Blueprint.Activity) MaterialReq(fr.guiguilechat.jcelechat.model.sde.industry.Blueprint.MaterialReq) CompressionTypeID(fr.guiguilechat.jcelechat.model.sde.attributes.CompressionTypeID) MaterialProd(fr.guiguilechat.jcelechat.model.sde.industry.Blueprint.MaterialProd) Logger(org.slf4j.Logger) EveType(fr.guiguilechat.jcelechat.model.sde.EveType) Set(java.util.Set) Collectors(java.util.stream.Collectors) TypeRef(fr.guiguilechat.jcelechat.model.sde.TypeRef) File(java.io.File) IndustryUsage(fr.guiguilechat.jcelechat.model.sde.industry.IndustryUsage) List(java.util.List) Stream(java.util.stream.Stream) TypeIndex(fr.guiguilechat.jcelechat.model.sde.TypeIndex) EtypeMaterials(fr.guiguilechat.jcelechat.model.sde.load.fsd.EtypeMaterials) Skill(fr.guiguilechat.jcelechat.model.sde.types.Skill) GenericDecryptor(fr.guiguilechat.jcelechat.model.sde.types.decryptors.GenericDecryptor) Entry(java.util.Map.Entry) EnpcCorporations(fr.guiguilechat.jcelechat.model.sde.load.fsd.EnpcCorporations) Collections(java.util.Collections) IndustryUsage(fr.guiguilechat.jcelechat.model.sde.industry.IndustryUsage) Blueprint(fr.guiguilechat.jcelechat.model.sde.industry.Blueprint) ArrayList(java.util.ArrayList) Material(fr.guiguilechat.jcelechat.model.sde.load.fsd.EtypeMaterials.Material) Blueprint(fr.guiguilechat.jcelechat.model.sde.industry.Blueprint) EveType(fr.guiguilechat.jcelechat.model.sde.EveType) Eblueprints(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints) Entry(java.util.Map.Entry) EtypeMaterials(fr.guiguilechat.jcelechat.model.sde.load.fsd.EtypeMaterials) HashSet(java.util.HashSet)

Example 2 with Eblueprints

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;
}
Also used : Eblueprints(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints) Material(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints.Material) ItemRef(fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer.ItemRef) LPOffer(fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer)

Aggregations

Eblueprints (fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints)2 FileTools (fr.guiguilechat.jcelechat.model.FileTools)1 EveType (fr.guiguilechat.jcelechat.model.sde.EveType)1 TypeIndex (fr.guiguilechat.jcelechat.model.sde.TypeIndex)1 TypeRef (fr.guiguilechat.jcelechat.model.sde.TypeRef)1 CompressionTypeID (fr.guiguilechat.jcelechat.model.sde.attributes.CompressionTypeID)1 Blueprint (fr.guiguilechat.jcelechat.model.sde.industry.Blueprint)1 Activity (fr.guiguilechat.jcelechat.model.sde.industry.Blueprint.Activity)1 MaterialProd (fr.guiguilechat.jcelechat.model.sde.industry.Blueprint.MaterialProd)1 MaterialReq (fr.guiguilechat.jcelechat.model.sde.industry.Blueprint.MaterialReq)1 IndustryUsage (fr.guiguilechat.jcelechat.model.sde.industry.IndustryUsage)1 InventionDecryptor (fr.guiguilechat.jcelechat.model.sde.industry.InventionDecryptor)1 Material (fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints.Material)1 EnpcCorporations (fr.guiguilechat.jcelechat.model.sde.load.fsd.EnpcCorporations)1 EtypeMaterials (fr.guiguilechat.jcelechat.model.sde.load.fsd.EtypeMaterials)1 Material (fr.guiguilechat.jcelechat.model.sde.load.fsd.EtypeMaterials.Material)1 LPOffer (fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer)1 ItemRef (fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer.ItemRef)1 Asteroid (fr.guiguilechat.jcelechat.model.sde.types.Asteroid)1 Skill (fr.guiguilechat.jcelechat.model.sde.types.Skill)1