def cost(self, typename): """ Return the cost of this typename. """ invtype = InvType.from_typename(typename) val = (self.cost_blueprint(invtype) or self.cost_reaction(invtype) or self.cost_lpstore(invtype) or self.cost_purchase(invtype)) return val
def reaction_bag(self, invtype): result_runs = invtype.attribute('moonMiningAmount') output_qty, inputs = invtype.reacted_from() if inputs is None: return None bag = Bag() for reqtype, reqqty in inputs: bag[reqtype.typename] += (reqqty * reqtype.attribute('moonMiningAmount')) # Also add half a control tower worth of fuel ... tower = InvType.from_typename('Minmatar Control Tower') for (resourcetype, quantity, minsecuritylevel, factionid) in (tower.controltowerresources('Online') + tower.controltowerresources('Power') + tower.controltowerresources('CPU')): if minsecuritylevel is not None: continue bag[resourcetype.typename] = quantity * 0.5 bag *= 1.0 / (output_qty * result_runs) return bag
def update_pricelist(grd): set_last_update('pricelist', datetime.datetime.utcnow()) index = IndexCalculator() bposet = set() inventable = [] known = set() PriceList.objects.all().delete() mfglinecosts = get_mfglinecosts() for bpo in BlueprintOriginal.objects.all(): bposet.add(bpo.typeid) bptype = InvType(bpo.typeid, bpo.typename) product = bptype.product() if product is None: raise RuntimeError("Can't find product for BPO %s (%s)" % (bpo.typeid, bpo.typename)) productioncost = index.cost(product.typename) if productioncost is None or not productioncost > 0: continue safetymargin = get_safetymargin(product, mfglinecosts) PriceList.objects.create(typename=product.typename, typeid=product.typeid, productioncost=productioncost, safetymargin=safetymargin) known.add(product.typeid) # We lack the parts for the Anshar... if not (product.typename == 'Obelisk' or product.group().startswith("Rig ")): inventable.extend(bptype.invent_to()) for bpc in inventable: if bpc.typeid in bposet: continue product = bpc.product() productioncost = index.cost(product.typename) if productioncost is None or not productioncost > 0: continue safetymargin = get_safetymargin(product, mfglinecosts) PriceList.objects.create(typename=product.typename, typeid=product.typeid, productioncost=productioncost, safetymargin=safetymargin) known.add(product.typeid) for wmo in WantedMarketOrder.objects.filter(forcorp=True): if wmo.typeid in known: continue typename = get_typename(wmo.typeid) typeid = wmo.typeid product = InvType(typeid, typename) productioncost = index.cost(typename) if productioncost is None or not productioncost > 0: continue safetymargin = 1.02 # Broker's fee of 1% PriceList.objects.create(typename=typename, typeid=typeid, productioncost=productioncost, safetymargin=safetymargin) known.add(typeid) for bpname in SYNTH_BOOSTER_BPC: bptype = InvType.from_typename(bpname) product = bptype.product() if product.typeid in known: continue productioncost = index.cost(product.typename) if productioncost is None or not productioncost > 0: continue productioncost += 25000 # Per-run BPC cost as per Damian PriceList.objects.create(typename=product.typename, typeid=product.typeid, productioncost=productioncost, safetymargin=1.0) known.add(product.typeid)
def get_component_list(typename): mfglinecosts = get_mfglinecosts() invtype = InvType.from_typename(typename) # Blueprint bplist = blueprints(invtype) index = IndexCalculator() if len(bplist) > 0: result = [] for bp in bplist: c = Component() c.safetymargin = get_safetymargin(invtype, mfglinecosts) c.portionsize = invtype.portionsize() mats1 = index.get_bag_materials(bp.extra) c.add_section('Blueprint', sorted(mats1)) mats2 = index.get_bag_materials(build(bp)) c.add_section('Materials', sorted(mats2)) c.total = sum(price_total for (typename, qty, price_pu, price_total) in mats1 + mats2 ) * c.safetymargin * 1.0/c.portionsize result.append(c) return result # Reaction result_runs = invtype.attribute('moonMiningAmount') output_qty, inputs = invtype.reacted_from() if inputs is not None: c = Component() c.portionsize = int(output_qty * result_runs) bag = Bag() for reqtype, reqqty in inputs: bag[reqtype.typename] += (reqqty * reqtype.attribute('moonMiningAmount')) mats1 = index.get_bag_materials(bag) c.add_section('Reaction', sorted(mats1)) # Also add half a control tower worth of fuel ... bag = Bag() tower = InvType.from_typename('Minmatar Control Tower') for (resourcetype, quantity, minsecuritylevel, factionid) in (tower.controltowerresources('Online') + tower.controltowerresources('Power') + tower.controltowerresources('CPU')): if minsecuritylevel is not None: continue bag[resourcetype.typename] = quantity * 0.5 mats2 = index.get_bag_materials(bag) c.add_section('Tower Fuel (Half a Minmatar Large)', sorted(mats2)) c.total = sum(price_total for (typename, qty, price_pu, price_total) in mats1 + mats2 ) / float(c.portionsize) return [c] # Index price = index.materialcost(invtype.typename) if price is not None: c = Component() c.add_section('Material Index', [(invtype.typename, 1, price, price)]) c.total = price return [c] # Purchase price = index.cost_purchase(invtype) if price is not None: c = Component() c.add_section('Market Purchase', [(invtype.typename, 1, price, price)]) c.total = price return [c]