def exportSpawnable(): fname = windows.saveAsFile("xml", "w+") if fname is not None: spawnable = "" rifles = xmlParser.itemFromRows(dao.getType("rifles")) pistols = xmlParser.itemFromRows(dao.getType("pistols")) gun = xmlParser.itemFromRows(dao.getType("gun")) items = gun + rifles + pistols for item in items: if item.mod != "Vanilla": if item.nominal != 0: spawnable += item.getSpawnableTypes() fname.write(spawnable)
def viewCategroy(self): cat = self.typeSel.get() subtype = self.subtypeSel.get() if self.subtypeSel.get() != "" else None try: if cat in categories.categories: rows = dao.getCategory(cat, subtype) elif cat in itemTypes: rows = dao.getType(cat, subtype) else: rows = dao.getAllItems(subtype) except Exception: rows = [] self.updateDisplay(rows)
def distributeLinkedItem(guns, targetCount, type): zeroAllItems(guns, type) elementCount = 0 allItems = dao.getDicts(dao.getType(type)) for gun in guns: elementCount += int(gun["nominal"]) linkedItemsToGun = dao.getDicts( dao.getWeaponAndCorresponding(gun["name"])) matchingItems = getLinkedOfType(linkedItemsToGun, type) # If Multiple item types linked: multiple Mags for example, then the sum of nominals should equal the nominal # of gun for matchingItem in matchingItems: for item in allItems: if matchingItem["name"] == item["name"]: item["nominal"] += gun["nominal"] / len(matchingItems) perUnit = targetCount / elementCount if elementCount != 0 else 0 for item in allItems: item["nominal"] = int(ceil(item["nominal"] * perUnit)) item["min"] = int(ceil(item["nominal"] / 2)) dao.update(item)