def __init__(self, db): super().__init__(db, 'DragonData', labeled_fields=[ '_Name', '_SecondName', '_Profile', '_CvInfo', '_CvInfoEn' ]) self.abilities = AbilityData(db) self.actions = PlayerAction(db) self.skills = SkillData(db) self.motions = DragonMotion(db)
def __init__(self, db): super().__init__(db, 'CharaData', labeled_fields=[ '_Name', '_SecondName', '_CvInfo', '_CvInfoEn', '_ProfileText' ]) self.abilities = AbilityData(db) self.ex = ExAbilityData(db) self.skills = SkillData(db) self.motions = CharacterMotion(db) self.mode = CharaModeData(db) self.actions = PlayerAction(db)
class CharaModeData(DBView): def __init__(self, db): super().__init__(db, 'CharaModeData') self.actions = PlayerAction(db) self.skills = SkillData(db) self.combo = CharaUniqueCombo(db) def get(self, pk, fields=None, exclude_falsy=True, full_query=True): res = super().get(pk, fields=fields, exclude_falsy=exclude_falsy) if not res: return None if not full_query: return res if '_ActionId' in res and res['_ActionId']: res['_ActionId'] = self.actions.get(res['_ActionId'], exclude_falsy=exclude_falsy) for s in ('_Skill1Id', '_Skill2Id'): if s in res and res[s]: res[s] = self.skills.get(res[s], exclude_falsy=exclude_falsy) if '_UniqueComboId' and res['_UniqueComboId']: res['_UniqueComboId'] = self.combo.get(res['_UniqueComboId'], exclude_falsy=exclude_falsy) if '_BurstAttackId' in res and res['_BurstAttackId']: res['_BurstAttackId'] = self.actions.get( res['_BurstAttackId'], exclude_falsy=exclude_falsy) return res
class WeaponData(DBView): def __init__(self, db): super().__init__(db, 'WeaponData', labeled_fields=['_Name', '_Text']) self.abilities = AbilityData(db) self.skills = SkillData(db) def process_result(self, res, exclude_falsy=True, full_query=True): if not full_query: return res if '_Type' in res: res['_Type'] = WEAPON_TYPES.get(res['_Type'], res['_Type']) if '_ElementalType' in res: res['_ElementalType'] = ELEMENTS.get(res['_ElementalType'], res['_ElementalType']) if '_Skill' in res: res['_Skill'] = self.skills.get(res['_Skill'], exclude_falsy=exclude_falsy, full_abilities=True) for k in ('_Abilities11', '_Abilities21'): if k in res and res[k]: res[k] = self.abilities.get(res[k], full_query=True, exclude_falsy=exclude_falsy) return res def get(self, pk, fields=None, exclude_falsy=False, full_query=True): res = super().get(pk, fields=fields, exclude_falsy=exclude_falsy) return self.process_result(res, exclude_falsy, full_query) @staticmethod def outfile_name(res, ext='.json'): name = 'UNKNOWN' if '_Name' not in res else res['_Name'] if '_BaseId' in res: return get_valid_filename( f'{res["_BaseId"]}_{res["_VariationId"]:02}_{name}{ext}') else: return get_valid_filename(f'{res["_Id"]:02}_{name}{ext}') def export_all_to_folder(self, out_dir='./out/weapons', ext='.json', exclude_falsy=True): super().export_all_to_folder(out_dir, ext, exclude_falsy=exclude_falsy, full_query=True)
c_gen_disc, _, c_seen_id = describe_skill( s, wiki_format=wiki_format, extra_info=extra_info) seen_id.update(c_seen_id) shift_gen_disc.append(c_gen_disc) for idx, gen_disc in enumerate(shift_gen_disc): for lv, d in gen_disc.items(): gen_disc[lv] = f'Shift {ROMAN[idx+1]}: {d}' if idx >= 1: gen_desc_by_level[lv] += lb + gen_disc[lv] return gen_desc_by_level, og_desc_by_level, seen_id if __name__ == '__main__': index = DBViewIndex() view = SkillData(index) specific_id = None if specific_id: skill = view.get(specific_id) skill_name = skill['_Name'] skill_id = str(skill['_Id']) gen_disc, og_disc, _ = describe_skill(skill, wiki_format=True) for lv, d in gen_disc.items(): o = og_disc[lv] print(f'{skill_id} - {skill_name} LV{lv}') print(f'Original:\n{o}') print(f'Generated:\n{d}\n') else: all_seen_id = set()
class DragonData(DBView): ACTIONS = ['_AvoidActionFront', '_AvoidActionBack', '_Transform'] def __init__(self, db): super().__init__(db, 'DragonData', labeled_fields=[ '_Name', '_SecondName', '_Profile', '_CvInfo', '_CvInfoEn' ]) self.abilities = AbilityData(db) self.actions = PlayerAction(db) self.skills = SkillData(db) self.motions = DragonMotion(db) def process_result(self, res, exclude_falsy, full_query=True, full_abilities=False): if not full_query: return res if '_Skill1' in res: res['_Skill1'] = self.skills.get(res['_Skill1'], exclude_falsy=exclude_falsy, full_abilities=full_abilities) inner = (1, 2) if full_abilities else (2, ) outer = (1, 2) for i in outer: for j in inner: k = f'_Abilities{i}{j}' if k in res and res[k]: res[k] = self.abilities.get(res[k], full_query=True, exclude_falsy=exclude_falsy) for act in self.ACTIONS: if act in res: res[act] = self.actions.get(res[act], exclude_falsy=exclude_falsy) if '_DefaultSkill' in res and res['_DefaultSkill']: base_action_id = res['_DefaultSkill'] res['_DefaultSkill'] = [ self.actions.get(base_action_id + i, exclude_falsy=exclude_falsy) for i in range(0, res['_ComboMax']) ] if '_AnimFileName' in res and res['_AnimFileName']: anim_key = int(res['_AnimFileName'][1:].replace('_', '')) else: anim_key = f'{res["_BaseId"]}{res["_VariationId"]:02}' res['_Animations'] = self.motions.get(anim_key, by='ref') return res def get(self, pk, fields=None, exclude_falsy=False, full_query=True, full_abilities=False): res = super().get(pk, fields=fields, exclude_falsy=exclude_falsy) return self.process_result(res, exclude_falsy, full_query, full_abilities) @staticmethod def outfile_name(res, ext='.json'): name = 'UNKNOWN' if '_Name' not in res else res[ '_Name'] if '_SecondName' not in res else res['_SecondName'] return f'{res["_BaseId"]}_{res["_VariationId"]:02}_{name}{ext}' def export_all_to_folder(self, out_dir='./out/dragons', ext='.json', exclude_falsy=True): super().export_all_to_folder(out_dir, ext, exclude_falsy=exclude_falsy, full_query=True, full_abilities=False)
class CharaData(DBView): def __init__(self, db): super().__init__(db, 'CharaData', labeled_fields=[ '_Name', '_SecondName', '_CvInfo', '_CvInfoEn', '_ProfileText' ]) self.abilities = AbilityData(db) self.ex = ExAbilityData(db) self.skills = SkillData(db) self.motions = CharacterMotion(db) self.mode = CharaModeData(db) self.actions = PlayerAction(db) @staticmethod def condense_stats(res): for s in ('Hp', 'Atk'): if res['_MaxLimitBreakCount'] > 4: MAX = f'_AddMax{s}1' else: MAX = f'_Max{s}' del res[f'_AddMax{s}1'] PLUS = [ f'_Plus{s}{i}' for i in range(res['_MaxLimitBreakCount'] + 1) ] FULL = f'_McFullBonus{s}5' stat = 0 OUT = f'_Max{s}' for key in (MAX, *PLUS, FULL): stat += res[key] if key != OUT: del res[key] res[OUT] = stat if res['_MaxLimitBreakCount'] == 4: del res[f'_Plus{s}5'] for m in [f'_Min{s}' + str(i) for i in range(3, 6)]: del res[m] return res def all_abilities(self, res, exclude_falsy=True): for i in (1, 2, 3): for j in (1, 2, 3, 4): ab = f'_Abilities{i}{j}' res[ab] = self.abilities.get(res[ab], full_query=True, exclude_falsy=exclude_falsy) for i in (1, 2, 3, 4, 5): ex = f'_ExAbilityData{i}' if ex in res and res[ex]: res[ex] = self.ex.get(res[ex], exclude_falsy=exclude_falsy) ex2 = f'_ExAbility2Data{i}' if ex2 in res and res[ex2]: res[ex2] = self.abilities.get(res[ex2], exclude_falsy=exclude_falsy) return res def last_abilities(self, res, exclude_falsy=True): for i in (1, 2, 3): j = 4 ab = f'_Abilities{i}{j}' while not (ab in res and res[ab]) and j > 0: j -= 1 ab = f'_Abilities{i}{j}' if j > 0: res[ab] = self.abilities.get(res[ab], full_query=True, exclude_falsy=exclude_falsy) ex = f'_ExAbilityData5' if ex in res and res[ex]: res[ex] = self.ex.get(res[ex], exclude_falsy=exclude_falsy) ex2 = f'_ExAbility2Data5' if ex2 in res and res[ex2]: res[ex2] = self.abilities.get(res[ex2], exclude_falsy=exclude_falsy) return res def process_result(self, res, exclude_falsy=True, condense=True): if '_WeaponType' in res: res['_WeaponType'] = WEAPON_TYPES.get(res['_WeaponType'], res['_WeaponType']) if '_ElementalType' in res: res['_ElementalType'] = ELEMENTS.get(res['_ElementalType'], res['_ElementalType']) if '_CharaType' in res: res['_CharaType'] = CLASS_TYPES.get(res['_CharaType'], res['_CharaType']) if condense: res = self.condense_stats(res) if '_ModeChangeType' in res and res['_ModeChangeType']: res['_ModeChangeType'] = MODE_CHANGE_TYPES.get( res['_ModeChangeType'], res['_ModeChangeType']) for m in ('_ModeId1', '_ModeId2', '_ModeId3'): if m in res: res[m] = self.mode.get(res[m], exclude_falsy=exclude_falsy, full_query=True) for s in ('_Skill1', '_Skill2'): if s in res and res[s]: res[s] = self.skills.get(res[s], exclude_falsy=exclude_falsy, full_query=True, full_hitattr=not condense) if condense: res = self.last_abilities(res) else: res = self.all_abilities(res) chara_id = f'{res["_BaseId"]}{res["_VariationId"]:02}' res['_Animations'] = self.motions.get(chara_id, by='ref') return res def get(self, pk, fields=None, exclude_falsy=True, full_query=True, condense=True): res = super().get(pk, fields=fields, exclude_falsy=exclude_falsy) if not full_query: return res return self.process_result(res, exclude_falsy=exclude_falsy, condense=True) @staticmethod def outfile_name(res, ext='.json'): name = 'UNKNOWN' if '_Name' not in res else res[ '_Name'] if '_SecondName' not in res else res['_SecondName'] return f'{res["_BaseId"]}_{res["_VariationId"]:02}_{name}{ext}' def export_all_to_folder(self, out_dir='./out/adventurers', ext='.json', exclude_falsy=True): super().export_all_to_folder(out_dir, ext, exclude_falsy=exclude_falsy, condense=True)
def __init__(self, db): super().__init__(db, 'CharaModeData') self.actions = PlayerAction(db) self.skills = SkillData(db) self.combo = CharaUniqueCombo(db)
def __init__(self, db): super().__init__(db, 'WeaponData', labeled_fields=['_Name', '_Text']) self.abilities = AbilityData(db) self.skills = SkillData(db)