diff --git a/eve.db b/eve.db index ba539d66c..a63d57b6f 100644 Binary files a/eve.db and b/eve.db differ diff --git a/scripts/jsonToSql.py b/scripts/jsonToSql.py index 0e591401d..e700cdfcb 100755 --- a/scripts/jsonToSql.py +++ b/scripts/jsonToSql.py @@ -194,14 +194,16 @@ def main(db, json_path): if all(attrs1[aid] == attrs2[aid] for aid in attrs1): return 2 if all( - (attrs1[aid] <= attrs2[aid] and not attrHig[aid]) or - (attrs1[aid] >= attrs2[aid] and attrHig[aid]) + (attrs1[aid] <= attrs2[aid] and attrHig[aid] == 0) or + (attrs1[aid] >= attrs2[aid] and attrHig[aid] == 1) or + (attrs1[aid] == attrs2[aid] and attrHig[aid] == 2) for aid in attrs1 ): return 3 if all( - (attrs2[aid] <= attrs1[aid] and not attrHig[aid]) or - (attrs2[aid] >= attrs1[aid] and attrHig[aid]) + (attrs2[aid] <= attrs1[aid] and attrHig[aid] == 0) or + (attrs2[aid] >= attrs1[aid] and attrHig[aid] == 1) or + (attrs2[aid] == attrs1[aid] and attrHig[aid] == 2) for aid in attrs1 ): return 4 @@ -269,11 +271,36 @@ def main(db, json_path): # Format: {type ID: 0 if high is bad, 1 if high is good, 2 if neither} attrHig = {} for row in tables['dgmattribs']: - attrHig[row['attributeID']] = bool(row['highIsGood']) + attrHig[row['attributeID']] = 1 if row['highIsGood'] else 0 # As CCP data is not really consistent, do some overrides - attrHig[4] = False # mass - attrHig[151] = False # agilityBonus - attrHig[161] = False # volume + attrHig[4] = 0 # mass + # Sometimes high is positive, sometimes it's not (e.g. AB cycle bonus vs smartbomb cycle bonus) + attrHig[66] = 2 # durationBonus + # Sometimes high is positive, sometimes it's not (e.g. invuln cycle vs rep cycle) + attrHig[73] = 2 # duration + attrHig[151] = 0 # agilityBonus + attrHig[161] = 0 # volume + attrHig[293] = 0 # rofBonus + attrHig[310] = 0 # cpuNeedBonus + attrHig[312] = 0 # durationSkillBonus + attrHig[314] = 0 # capRechargeBonus + attrHig[317] = 0 # capNeedBonus + attrHig[319] = 0 # warpCapacitorNeedBonus + attrHig[323] = 0 # powerNeedBonus + attrHig[331] = 2 # implantness + attrHig[338] = 0 # rechargeratebonus + attrHig[440] = 0 # manufacturingTimeBonus + attrHig[441] = 0 # turretSpeeBonus + attrHig[452] = 0 # copySpeedBonus + attrHig[453] = 0 # blueprintmanufactureTimeBonus + attrHig[468] = 0 # mineralNeedResearchBonus + attrHig[780] = 0 # iceHarvestCycleBonus + attrHig[848] = 0 # aoeCloudSizeBonus + attrHig[927] = 0 # miningUpgradeCPUReductionBonus + attrHig[1087] = 2 # boosterness + attrHig[1125] = 0 # boosterChanceBonus + attrHig[1126] = 0 # boosterAttributeModifier + attrHig[1156] = 0 # maxScanDeviationModifier # Format: {group ID: category ID} groupCategories = {} for row in tables['evegroups']: diff --git a/service/price.py b/service/price.py index 8595cef26..c4b9a3cc9 100644 --- a/service/price.py +++ b/service/price.py @@ -204,44 +204,44 @@ class Price: def findCheaperReplacements(self, items, callback, includeBetter, fetchTimeout=10): sMkt = Market.getInstance() - potential = {} # All possible item replacements + replacementsAll = {} # All possible item replacements for item in items: - if item in potential: + if item in replacementsAll: continue itemRepls = sMkt.getReplacements(item, includeBetter) if itemRepls: - potential[item] = itemRepls - itemsToFetch = {i for i in chain(potential.keys(), *potential.values())} + replacementsAll[item] = itemRepls + itemsToFetch = {i for i in chain(replacementsAll.keys(), *replacementsAll.values())} - def cb(requests): + def makeCheapMapCb(requests): # Decide what we are going to replace - actual = {} # Items which should be replaced - for replacee, replacers in potential.items(): + replacementsCheaper = {} # Items which should be replaced + for replacee, replacers in replacementsAll.items(): replacer = min(replacers, key=lambda i: i.price.price or math.inf) if (replacer.price.price or math.inf) < (replacee.price.price or math.inf): - actual[replacee] = replacer + replacementsCheaper[replacee] = replacer try: - callback(actual) + callback(replacementsCheaper) except Exception as e: pyfalog.critical("Execution of callback from findCheaperReplacements failed.") pyfalog.critical(e) # Prices older than 2 hours have to be refetched validityOverride = 2 * 60 * 60 - self.getPrices(itemsToFetch, cb, fetchTimeout=fetchTimeout, validityOverride=validityOverride) + self.getPrices(itemsToFetch, makeCheapMapCb, fetchTimeout=fetchTimeout, validityOverride=validityOverride) def optimizeFitPrice(self, fit, callback, includeBetter, fetchTimeout=10): - def cb(replacementMap): + def updateFitCb(replacementsCheaper): changes = False for container in (fit.modules, fit.drones, fit.fighters, fit.implants, fit.boosters, fit.cargo): for obj in container: charge = getattr(obj, 'charge', None) - if charge is not None and charge in replacementMap: - obj.charge = replacementMap[charge] + if charge is not None and charge in replacementsCheaper: + obj.charge = replacementsCheaper[charge] changes = True - if obj.item in replacementMap: - obj.rebase(replacementMap[obj.item]) + if obj.item in replacementsCheaper: + obj.rebase(replacementsCheaper[obj.item]) changes = True if changes: Fit.getInstance().refreshFit(fit.ID) @@ -252,7 +252,7 @@ class Price: pyfalog.critical(e) fitItems = {i for i in self.fitItemIter(fit) if i is not fit.ship.item} - self.findCheaperReplacements(fitItems, cb, includeBetter, fetchTimeout=fetchTimeout) + self.findCheaperReplacements(fitItems, updateFitCb, includeBetter, fetchTimeout=fetchTimeout) class PriceWorkerThread(threading.Thread):