Search in sources :

Example 1 with ItemRef

use of fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer.ItemRef in project JCELechat by guiguilechat.

the class ShowDEDLPs method iplp.

public static double iplp(LPOffer offer, RegionalMarket market, int minlp) {
    if (offer.requirements.lp == 0) {
        return 0;
    }
    int nbOffers = Math.max(1, (int) Math.ceil(1.0 * minlp / offer.requirements.lp));
    double iskplp = market.getBO(offer.product.id, offer.product.quantity * nbOffers).get() / nbOffers - offer.requirements.isk;
    for (ItemRef it : offer.requirements.items) {
        iskplp -= market.getSO(it.id, it.quantity * nbOffers).get() / nbOffers;
    }
    iskplp /= offer.requirements.lp;
    return iskplp;
}
Also used : ItemRef(fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer.ItemRef)

Example 2 with ItemRef

use of fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer.ItemRef 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

ItemRef (fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer.ItemRef)2 Eblueprints (fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints)1 Material (fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints.Material)1 LPOffer (fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer)1