async def genShinkaiItems(self): CATEGORY_MEMBERS = await self.__get_allitems() tasks = [] for category in CATEGORY_MEMBERS: title = category['title'] if title.startswith('Template'): continue tasks.append( asyncio.ensure_future(self.__append_shinkai_item(title))) dones, pendings = await asyncio.wait(tasks) print('Shinkai-Items: {} done, {} pendings.'.format( len(dones), len(pendings))) self.items_data = sortDict(self.items_data) items_luatable = 'local d = {}\n' items_luatable += '\nd.equipDataTable = ' items_luatable += luatable(self.items_data) items_luatable += '\n' items_luatable += '\nreturn d\n' with open(OUPUT_PATH + LUATABLE_PATH + SHINKAI_ITEMS_DATA + '.lua', 'w', encoding='utf-8') as fp: fp.write(items_luatable) with open(OUPUT_PATH + JSON_PATH + SHINKAI_ITEMS_DATA + '.json', 'w', encoding='utf-8') as fp: json.dump(self.items_data, fp, ensure_ascii=False, indent=4)
def genClassMappingData(self): self.__gen_classes() self.__fill_classes() self.shipclass_data = sortDict(self.shipclass_data) shipclass_luatable = 'local d = {}\n' shipclass_luatable += '---------------------------------\n' shipclass_luatable += '-- 以下为舰娘和舰级的对应数据 -- \n' shipclass_luatable += '---------------------------------\n' shipclass_luatable += '\nd.shipclassDataTb = ' shipclass_luatable += luatable(self.shipclass_data) shipclass_luatable += '\n' shipclass_luatable += '\nreturn d\n' with open(OUPUT_PATH + LUATABLE_PATH + SHIPCLASSES_MAPPING_DATA + '.lua', 'w', encoding='utf-8') as fp: fp.write(shipclass_luatable) with open(OUPUT_PATH + JSON_PATH + SHIPCLASSES_MAPPING_DATA + '.json', 'w', encoding='utf-8') as fp: json.dump(self.shipclass_data, fp, ensure_ascii=False, indent=4)
def genItemsData(self): self.__load_akashi_list() self.__load_ship_types() for item_id in self.ITEMS_DB.keys(): if item_id in self.SLOTITEMS_KCDATA: self.__append_item(item_id) self.items_data = sortDict(self.items_data) items_luatable = 'local d = {}\n' items_luatable += '------------------------\n' items_luatable += '-- 以下为装备数据列表 -- \n' items_luatable += '------------------------\n' items_luatable += '\nd.equipDataTb = ' items_luatable += luatable(self.items_data) items_luatable += '\n' items_luatable += '\nreturn d\n' with open(OUPUT_PATH + LUATABLE_PATH + ITEMS_DATA + '.lua', 'w', encoding='utf-8') as fp: fp.write(items_luatable) with open(OUPUT_PATH + JSON_PATH + ITEMS_DATA + '.json', 'w', encoding='utf-8') as fp: json.dump(self.items_data, fp, ensure_ascii=False, indent=4)
def genShipsData(self): self.__map_lvl_up() for ship_id in self.SHIPS_DB.keys(): if ship_id in self.SHIPS_KCDATA: self.__append_ship(ship_id) self.ships_data = sortDict(self.ships_data) ships_luatable = 'local d = {}\n' ships_luatable += '------------------------\n' ships_luatable += '-- 以下为舰娘数据列表 -- \n' ships_luatable += '------------------------\n' ships_luatable += '\nd.shipDataTb = ' ships_luatable += luatable(self.ships_data) ships_luatable += '\n' ships_luatable += '\nreturn d\n' with open(OUPUT_PATH + LUATABLE_PATH + SHIPS_DATA + '.lua', 'w', encoding='utf-8') as fp: fp.write(ships_luatable) with open(OUPUT_PATH + JSON_PATH + SHIPS_DATA + '.json', 'w', encoding='utf-8') as fp: json.dump(self.ships_data, fp, ensure_ascii=False, indent=4)
async def genShinkaiShips(self): self.__load_extra() categories = await self.__get_allships() tasks = [] for title in categories: tasks.append( asyncio.ensure_future(self.__append_shinkai_ship(title))) dones, pendings = await asyncio.wait(tasks) print('Shinkai-Ships: {} done, {} pendings.'.format( len(dones), len(pendings))) self.ships_data = sortDict(self.ships_data) ships_luatable = 'local d = {}\n' ships_luatable += '\nd.shipDataTable = ' ships_luatable += luatable(self.ships_data) ships_luatable += '\n' ships_luatable += '\nreturn d\n' with open(OUPUT_PATH + LUATABLE_PATH + SHINKAI_SHIPS_DATA + '.lua', 'w', encoding='utf-8') as fp: fp.write(ships_luatable) with open(OUPUT_PATH + JSON_PATH + SHINKAI_SHIPS_DATA + '.json', 'w', encoding='utf-8') as fp: json.dump(self.ships_data, fp, ensure_ascii=False, indent=4)