def invention_chance_admin_display(self): chance = formulas.calc_invention_chance( self.base_invention_chance, self.encryption_skill_lvl, self.science1_skill_lvl, self.science2_skill_lvl, DECRYPTOR_ATTRIBUTES[self.me_mod][0], ) return "%d%%" % int(chance * 100.0)
def resolve(blueprint): """ Resolve which decryptor and how many invention runs must be used to invent the given blueprint If no decryptor is required, return None as the decryptor typeID """ if blueprint.parent_blueprint is None: raise InventionError( "Blueprint %s has no parent_blueprint and cannot be invented.", blueprint.blueprintTypeID ) decryptor_group = constants.INTERFACES_DECRYPTOR_MAPPING[blueprint.parent_blueprint.dataInterfaceID] if InventionPolicy.objects.filter(item_id=blueprint.product.typeID): policy = InventionPolicy.objects.get(item_id=blueprint.product.typeID) elif InventionPolicy.objects.filter(item_group_id=blueprint.product.groupID): policy = InventionPolicy.objects.get(item_group_id=blueprint.product.groupID) else: # no specific policy defined for this blueprint, # fallback to the default policy (modules) policy = InventionPolicy.objects.get(item_group_id=-1) decriptorTypeID = None runs_mod = 0 chance_mod = 1.0 me = -4 # base ME for invented BPCs without decryptor pe = -4 # base PE for invented BPCs without decryptor for typeID, _chance, _me, _pe, _runs, _ in constants.DECRYPTOR_INFO[decryptor_group]: if policy.me_mod == _me: decriptorTypeID = typeID me += _me pe += _pe chance_mod = _chance runs_mod = _runs break runs_per_bp = formulas.invented_bpc_runs( blueprint.parent_blueprint.maxProductionLimit, blueprint.parent_blueprint.maxProductionLimit, blueprint.maxProductionLimit, runs_mod, ) chance = formulas.calc_invention_chance( policy.base_invention_chance, policy.encryption_skill_lvl, policy.science1_skill_lvl, policy.science2_skill_lvl, chance_mod, ) attempts = int(math.ceil(1.0 / chance)) return runs_per_bp, me, pe, decriptorTypeID, attempts
def resolve(blueprint): """ Resolve which decryptor and how many invention runs must be used to invent the given blueprint If no decryptor is required, return None as the decryptor typeID """ if blueprint.parent_blueprint is None: raise InventionError( 'Blueprint %s has no parent_blueprint and cannot be invented.', blueprint.blueprintTypeID) if InventionPolicy.objects.filter(item_id=blueprint.product.typeID): policy = InventionPolicy.objects.get( item_id=blueprint.product.typeID) elif InventionPolicy.objects.filter( item_group_id=blueprint.product.groupID): policy = InventionPolicy.objects.get( item_group_id=blueprint.product.groupID) else: # no specific policy defined for this blueprint, # fallback to the default policy (modules) policy = InventionPolicy.objects.get(item_group_id=-1) decriptorTypeID = None runs_mod = 0 chance_mod = 1.0 me = -2 # base ME for invented BPCs without decryptor pe = -4 # base PE for invented BPCs without decryptor for typeID, _chance, _me, _pe, _runs, _ in constants.DECRYPTOR_INFO: if policy.me_mod == _me: decriptorTypeID = typeID me += _me pe += _pe chance_mod = _chance runs_mod = _runs break runs_per_bp = formulas.invented_bpc_runs( blueprint.parent_blueprint.maxProductionLimit, blueprint.parent_blueprint.maxProductionLimit, blueprint.maxProductionLimit, runs_mod) chance = formulas.calc_invention_chance( blueprint.parent_blueprint.inventionBaseChance, policy.encryption_skill_lvl, policy.science1_skill_lvl, policy.science2_skill_lvl, chance_mod) attempts = int(math.ceil(1.0 / chance)) return runs_per_bp, me, pe, decriptorTypeID, attempts