diff --git a/extra/gear.py b/extra/gear.py index cc53c6b..e95f897 100644 --- a/extra/gear.py +++ b/extra/gear.py @@ -5,7 +5,7 @@ def get_row_from_reader(table_name: str, row_id: int): - rows = READER.query(table_name, dict(ID=row_id)) + rows = Tool.READER.query(table_name, dict(ID=row_id)) if not rows: return None return rows[0] @@ -15,23 +15,20 @@ class ExtraGear(Gear): id: int = 0 temp_enchant: Enchant = None - def __init__( - self, gear_id: int, strength_level: int, embed_levels: list[int], - position_id: int = None, tab_id: int = None - ): + def __init__(self, gear_id: int, strength_level: int, embed_levels: list[int], position_id: int = None, tab_id: int = None): if tab_id in EQUIPMENT_BY_TABS: row = get_row_from_reader(EQUIPMENT_BY_TABS[tab_id], gear_id) elif position_id in EQUIPMENT_BY_POSITIONS: row = get_row_from_reader(EQUIPMENT_BY_POSITIONS[position_id], gear_id) else: - raise KeyError("Not Passing Any ID") + raise KeyError('Not Passing Any ID') if row and row['SubType'] in POSITION_MAP: detail = get_equip_code(get_equip_detail(row)) super().__init__(detail['school'], detail['kind'], detail['name'], detail) self.strength_level = strength_level self.embed_levels = {i: level for i, level in enumerate(embed_levels)} else: - super().__init__("", "", "", {}) + super().__init__('', '', '', {}) def __bool__(self): return bool(self.id) @@ -59,7 +56,7 @@ def __init__(self, enchant_id: int): detail = get_enchant_code(get_enchant_detail(row)) super().__init__(detail['name'], detail) else: - super().__init__("", {}) + super().__init__('', {}) def __bool__(self): return bool(self.id) @@ -76,7 +73,7 @@ def __init__(self, item_id: int = None, enchant_id: int = None): detail = get_stone_code(STONE_BY_ENCHANT_IDS[enchant_id].copy()) super().__init__(detail) else: - raise KeyError("Not Passing Any ID") + raise KeyError('Not Passing Any ID') def __bool__(self): return bool(self.enchant_id) @@ -127,7 +124,7 @@ def from_item(cls, data: dict): gear.temp_enchant = temp_enchant if not gear.is_primary_weapon: continue - _, stone_id = equip_data["ColorInfo"]["0"] + _, stone_id = equip_data['ColorInfo']['0'] gear.stone = ExtraStone(item_id=stone_id) return cls(gears) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..813a239 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ + +[tool.poetry] +name = "KlAttribute" +version = "0.0.1" +description = "AttributeDpsCalc" +authors = ["IcyTide","serfend "] +license = "AGPL" + +[tool.poetry.dependencies] +python = "^3.13.3" + +[build-system] +requires = ["poetry_core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.ruff] +line-length=160 +# Enable Pyflakes `E` and `F` codes by default. +# select = ["E", "F"] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", + 'tests', + 'lib_config_debug.py', + 'ins_u_const.py', + 'docs', +] + +# Allow unused variables when underscore-prefixed. +# lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +target-version = "py313" + +# Never enforce `E501` (line length violations). +# Never enforce `F401` (imported but not used). +# Never enforce `F403` (star imported unable to detect undefined). +# Never enforce `F405` (star imported make defined fuss). +# Never enforce `F811` (redefinition of unused xxx). +lint.ignore = ["E402","E501", "F401", "F403", "F405", "F811"] + +# Never try to fix +lint.unfixable = ["E402","E501", "F401", "F403", "F405", "F811"] + +[tool.ruff.format] +# 使用单引号 +quote-style = "single" \ No newline at end of file diff --git a/tools/generate.py b/tools/generate.py index 7502ef4..e580b25 100644 --- a/tools/generate.py +++ b/tools/generate.py @@ -5,60 +5,62 @@ from kungfus import SUPPORT_KUNGFUS from tools.lua.enums import ATTRIBUTE_TYPE -from tools.reader import DataFrameReader +from tools.reader import DataFrameReader, BaseReader from tools.utils import camel_to_capital, get_variable, save_code, save_json -READER = DataFrameReader() + +class Tool: + READER = DataFrameReader() + """用于定义基础数据的读取模式,继承BaseReader""" + KINDS = set(sum([[kungfu.kind, kungfu.major] for kungfu in SUPPORT_KUNGFUS], [])) -SCHOOLS = set(["精简", "通用"] + [kungfu.school for kungfu in SUPPORT_KUNGFUS]) +SCHOOLS = set(['精简', '通用'] + [kungfu.school for kungfu in SUPPORT_KUNGFUS]) MIN_EQUIP_LEVEL = 28000 ENCHANT_START_ID = 15778 -MIN_EQUIP_SCORE = { - k: round(MIN_EQUIP_LEVEL * READER.QUALITY_COF[4] * v) for k, v in READER.POSITION_COF.items() -} +MIN_EQUIP_SCORE = {k: round(MIN_EQUIP_LEVEL * Tool.READER.QUALITY_COF[4] * v) for k, v in Tool.READER.POSITION_COF.items()} POSITION_MAP = { - 0: "primary_weapon", - 1: "tertiary_weapon", - 2: "jacket", - 3: "hat", - 4: "necklace", - 5: "ring", - 6: "belt", - 7: "pendant", - 8: "bottoms", - 9: "shoes", - 10: "wrist", + 0: 'primary_weapon', + 1: 'tertiary_weapon', + 2: 'jacket', + 3: 'hat', + 4: 'necklace', + 5: 'ring', + 6: 'belt', + 7: 'pendant', + 8: 'bottoms', + 9: 'shoes', + 10: 'wrist', } USAGE_MAP = { - 0: "PVP", - 1: "PVE", - 2: "PVX", - 3: "ALL" + 0: 'PVP', + 1: 'PVE', + 2: 'PVX', + 3: 'ALL', } STONE_LEVELS = { - "(壹)": 1, - "(贰)": 2, - "(叁)": 3, - "(肆)": 4, - "(伍)": 5, - "(陆)": 6 + '(壹)': 1, + '(贰)': 2, + '(叁)': 3, + '(肆)': 4, + '(伍)': 5, + '(陆)': 6, } ATTR_ABBR = { - "therapy_base": "治疗", - "overcome_base": "破防", - "critical_strike_base": "会心", - "critical_power_base": "会效", - "haste_base": "加速", - "surplus_base": "破招", - "strain_base": "无双", - "physical_shield": "外防", - "magical_shield": "内防", - "toughness": "御劲", - "decritical_power": "化劲" + 'therapy_base': '治疗', + 'overcome_base': '破防', + 'critical_strike_base': '会心', + 'critical_power_base': '会效', + 'haste_base': '加速', + 'surplus_base': '破招', + 'strain_base': '无双', + 'physical_shield': '外防', + 'magical_shield': '内防', + 'toughness': '御劲', + 'decritical_power': '化劲', } MAX_BASE_ATTR = 6 @@ -73,9 +75,9 @@ def simplify_attrs(attrs): attributes, recipes, gains = {}, [], [] for attr in attrs: - if attr['attr_type'] == "event": + if attr['attr_type'] == 'event': gains.append(attr['value']) - elif attr['attr_type'] == "recipe": + elif attr['attr_type'] == 'recipe': recipes.append(attr['value']) elif attr_type := attr['attr_type']: if attr_type not in attributes: @@ -90,54 +92,54 @@ def get_row(df: pd.DataFrame, condition: dict): rows = rows[rows[k] == v] if rows.empty: return [] - return rows.to_dict("records") + return rows.to_dict('records') def get_attr_desc(attr): - attr_rows = READER.query("attrib_txts", dict(ID=attr)) + attr_rows = Tool.READER.query('attrib_txts', dict(ID=attr)) if not attr_rows: - return "" + return '' attr_row = attr_rows[0] - return re.sub(r"{.*}", "{}", attr_row['GeneratedMagic']) + return re.sub(r'{.*}', '{}', attr_row['GeneratedMagic']) def get_recipe_desc(recipe_id, recipe_level): - recipe_rows = READER.query("recipe_txts", dict(ID=recipe_id, Level=recipe_level)) + recipe_rows = Tool.READER.query('recipe_txts', dict(ID=recipe_id, Level=recipe_level)) if not recipe_rows: - return "", "" + return '', '' recipe_row = recipe_rows[0] - value = get_variable("recipe", recipe_id, recipe_level) + value = get_variable('recipe', recipe_id, recipe_level) return recipe_row['Desc'], value def get_event_desc(event_id): - event_rows = READER.query("event_txts", dict(ID=event_id)) + event_rows = Tool.READER.query('event_txts', dict(ID=event_id)) if not event_rows: desc = event_rows[0]['Desc'] else: - desc = "" - event_rows = READER.query("event_settings", dict(ID=event_id)) + desc = '' + event_rows = Tool.READER.query('event_settings', dict(ID=event_id)) if event_rows: event_row = event_rows[0] if event_row['Odds']: - value = get_variable("gain", event_row['SkillID'], event_row['SkillLevel']) + value = get_variable('gain', event_row['SkillID'], event_row['SkillLevel']) else: - value = "" + value = '' else: - value = "" + value = '' return desc, value def get_equip_tags(detail): tags = [] attr_tags = [] - if detail['school'] == "精简": - tags += ["精简"] + if detail['school'] == '精简': + tags += ['精简'] for attr in detail['magic']: - if detail.get('skill') and "特效" not in tags: - tags += ["特效"] - if attr['attr_type'] == "event" and attr['value'] and "特效" not in tags: - tags += ["特效"] + if detail.get('skill') and '特效' not in tags: + tags += ['特效'] + if attr['attr_type'] == 'event' and attr['value'] and '特效' not in tags: + tags += ['特效'] continue for k, v in ATTR_ABBR.items(): if k in attr['attr_type'] and v not in attr_tags: @@ -153,12 +155,7 @@ def get_base_attrs(row): break cap_attr = camel_to_capital(attr[2:]) attr_type = ATTRIBUTE_TYPE[cap_attr] # noqa - attrs.append({ - "attr": attr, - "attr_type": attr_type, - "value": row[f'Base{i + 1}Max'], - "desc": get_attr_desc(attr) - }) + attrs.append({'attr': attr, 'attr_type': attr_type, 'value': row[f'Base{i + 1}Max'], 'desc': get_attr_desc(attr)}) return attrs @@ -168,7 +165,7 @@ def get_magic_attrs(row): for i in range(MAX_MAGIC_ATTR): if not (attr_id := row[f'Magic{i + 1}Type']): break - attr_row = READER.query("attrib_settings", dict(ID=attr_id))[0] + attr_row = Tool.READER.query('attrib_settings', dict(ID=attr_id))[0] attr = attr_row['ModifyType'] cap_attr = camel_to_capital(attr[2:]) attr_type = ATTRIBUTE_TYPE[cap_attr] # noqa @@ -179,12 +176,7 @@ def get_magic_attrs(row): desc, value = get_recipe_desc(param_1, param_2) else: desc, value = get_attr_desc(attr), param_1 - attrs.append({ - "attr": attr, - "attr_type": attr_type, - "value": value, - "desc": desc - }) + attrs.append({'attr': attr, 'attr_type': attr_type, 'value': value, 'desc': desc}) return attrs @@ -193,16 +185,11 @@ def get_embed_attrs(row): for i in range(MAX_EMBED_ATTR): if not (attr_id := row[f'DiamondAttributeID{i + 1}']): break - attr_row = READER.query("attrib_settings", dict(ID=attr_id))[0] + attr_row = Tool.READER.query('attrib_settings', dict(ID=attr_id))[0] attr = attr_row['ModifyType'] cap_attr = camel_to_capital(attr[2:]) attr_type = ATTRIBUTE_TYPE[cap_attr] # noqa - attrs.append({ - "attr": attr, - "attr_type": attr_type, - "value": attr_row['Param1Max'], - "desc": get_attr_desc(attr) - }) + attrs.append({'attr': attr, 'attr_type': attr_type, 'value': attr_row['Param1Max'], 'desc': get_attr_desc(attr)}) return attrs @@ -211,11 +198,11 @@ def get_set_attrs(row): set_id = int(row['SetID']) if not set_id: return set_id, attrs - set_row = READER.query("set_settings", dict(ID=set_id))[0] + set_row = Tool.READER.query('set_settings', dict(ID=set_id))[0] for i in range(1, MAX_SET_COUNT): for j in range(MAX_SET_ATTR): - if attr_id := set_row[f"{i + 1}_{j + 1}"]: - attr_row = READER.query("attrib_settings", dict(ID=attr_id))[0] + if attr_id := set_row[f'{i + 1}_{j + 1}']: + attr_row = Tool.READER.query('attrib_settings', dict(ID=attr_id))[0] attr = attr_row['ModifyType'] cap_attr = camel_to_capital(attr[2:]) attr_type = ATTRIBUTE_TYPE[cap_attr] # noqa @@ -228,22 +215,23 @@ def get_set_attrs(row): desc, value = get_recipe_desc(param_1, param_2) else: desc, value = get_attr_desc(attr), param_1 - attrs[i + 1].append({ - "attr": attr, - "attr_type": attr_type, - "value": value, - "desc": desc - }) + attrs[i + 1].append({'attr': attr, 'attr_type': attr_type, 'value': value, 'desc': desc}) return set_id, attrs def get_equip_detail(row): detail = { - "id": row['ID'], "name": row['Name'], "school": row['BelongSchool'], "kind": row['MagicKind'], - "position": POSITION_MAP[row['SubType']], "usage": USAGE_MAP[row['EquipUsage']], - "level": int(row['Level']), "score": int(row['Score']), "max_strength": int(row['MaxStrengthLevel']) + 'id': row['ID'], + 'name': row['Name'], + 'school': row['BelongSchool'], + 'kind': row['MagicKind'], + 'position': POSITION_MAP[row['SubType']], + 'usage': USAGE_MAP[row['EquipUsage']], + 'level': int(row['Level']), + 'score': int(row['Score']), + 'max_strength': int(row['MaxStrengthLevel']), } - item_row = READER.query("item_txts", dict(ItemID=row['UiID']))[0] + item_row = Tool.READER.query('item_txts', dict(ItemID=row['UiID']))[0] detail['icon_id'] = int(item_row['IconID']) detail['desc'] = item_row['Desc'] detail['base'] = get_base_attrs(row) @@ -255,8 +243,8 @@ def get_equip_detail(row): detail['skill'] = int(row['SkillID']), int(row['SkillLevel']) detail['tags'] = get_equip_tags(detail) - if detail['position'] == "primary_weapon" and row['DetailType'] == 9: - detail['position'] = "big_sword" + if detail['position'] == 'primary_weapon' and row['DetailType'] == 9: + detail['position'] = 'big_sword' return detail @@ -269,9 +257,9 @@ def get_equip_code(detail): sets[count] = {} sets[count]['attributes'], sets[count]['recipes'], sets[count]['gains'] = simplify_attrs(attrs) detail['sets'] = sets - if skill := detail.pop("skill", None): - detail['gains'].append(get_variable("gain", *skill)) # noqa - for key in ["desc", "icon_id", "usage"]: + if skill := detail.pop('skill', None): + detail['gains'].append(get_variable('gain', *skill)) # noqa + for key in ['desc', 'icon_id', 'usage']: detail.pop(key, None) return detail @@ -280,7 +268,7 @@ def build_equip_code(details: dict[int, dict]): results = {} for detail in details.values(): position, school, kind, usage = detail['position'], detail['school'], detail['kind'], detail['usage'] - if usage in ["PVP", "PVX"]: + if usage in ['PVP', 'PVX']: continue if position not in results: results[position] = {} @@ -288,7 +276,7 @@ def build_equip_code(details: dict[int, dict]): results[position][school] = {} if kind not in results[position][school]: results[position][school][kind] = {} - name = f"{detail['name']}#{detail['id']} ({detail['level']} {' '.join(detail.pop('tags'))})" + name = f'{detail["name"]}#{detail["id"]} ({detail["level"]} {" ".join(detail.pop("tags"))})' results[position][school][kind][name] = get_equip_code(detail.copy()) return results @@ -297,10 +285,10 @@ def get_equip_list(equip_tab): equip_tab = equip_tab[equip_tab.SubType.isin(MIN_EQUIP_SCORE)] equip_tab = equip_tab[equip_tab.Score >= equip_tab.SubType.map(MIN_EQUIP_SCORE)] equip_tab = equip_tab[(equip_tab.MagicKind.isin(KINDS)) & (equip_tab.BelongSchool.isin(SCHOOLS))] - equip_tab = equip_tab.sort_values(["SubType", "Score", "ID"], ascending=False) + equip_tab = equip_tab.sort_values(['SubType', 'Score', 'ID'], ascending=False) results = {} - for row in tqdm(equip_tab.to_dict("records")): + for row in tqdm(equip_tab.to_dict('records')): detail = get_equip_detail(row) results[detail['id']] = detail return results, build_equip_code(results) @@ -309,35 +297,35 @@ def get_equip_list(equip_tab): def get_enchant_attrs(row): attrs = [] for i in range(MAX_ENCHANT_ATTR): - if not (attr := row[f"Attribute{i + 1}ID"]): + if not (attr := row[f'Attribute{i + 1}ID']): continue cap_attr = camel_to_capital(attr[2:]) attr_type = ATTRIBUTE_TYPE[cap_attr] # noqa - value = row[f"Attribute{i + 1}Value1"] - attrs.append({ - "attr": attr, - "attr_type": attr_type, - "value": int(value) if value.isdigit() else value, - "desc": get_attr_desc(attr) - }) + value = row[f'Attribute{i + 1}Value1'] + attrs.append({'attr': attr, 'attr_type': attr_type, 'value': int(value) if value.isdigit() else value, 'desc': get_attr_desc(attr)}) return attrs def get_enchant_detail(row): detail = { - "id": row['ID'], "name": row['Name'], "desc": row['AttriName'], - "position": POSITION_MAP[row['DestItemSubType']], "score": int(row['Score']), - "attributes": get_enchant_attrs(row), "temporary": bool(row['Time']) + 'id': row['ID'], + 'name': row['Name'], + 'desc': row['AttriName'], + 'position': POSITION_MAP[row['DestItemSubType']], + 'score': int(row['Score']), + 'attributes': get_enchant_attrs(row), + 'temporary': bool(row['Time']), } return detail def get_enchant_code(detail): detail['attributes'], _, _ = simplify_attrs(detail['attributes']) - for key in ["desc", "position"]: + for key in ['desc', 'position']: detail.pop(key, None) return detail + def build_enchant_code(details: dict[int, dict]): results = dict(consumables={}) for detail in details.values(): @@ -350,8 +338,8 @@ def build_enchant_code(details: dict[int, dict]): detail = get_enchant_code(detail.copy()) if not detail['attributes']: continue - temporary = detail.pop("temporary") - name = f"{detail['name']} {desc}" + temporary = detail.pop('temporary') + name = f'{detail["name"]} {desc}' if temporary: results['consumables'][name] = detail['attributes'] else: @@ -361,9 +349,9 @@ def build_enchant_code(details: dict[int, dict]): def get_enchants_list(enchant_settings): enchant_tab = enchant_settings[(enchant_settings.ID >= ENCHANT_START_ID) & (enchant_settings.DiamondType1 == 0)] - enchant_tab = enchant_tab.sort_values(["Score", "ID"], ascending=False) + enchant_tab = enchant_tab.sort_values(['Score', 'ID'], ascending=False) results = {} - for row in tqdm(enchant_tab.to_dict("records")): + for row in tqdm(enchant_tab.to_dict('records')): detail = get_enchant_detail(row) results[detail['id']] = detail return results, build_enchant_code(results) @@ -377,17 +365,12 @@ def get_stone_attrs(row): cap_attr = camel_to_capital(attr[2:]) attr_type = ATTRIBUTE_TYPE[cap_attr] # noqa value = row[f'Attribute{i + 1}Value1'] - attrs.append({ - "attr": attr, - "attr_type": attr_type, - "value": int(value), - "desc": get_attr_desc(attr) - }) + attrs.append({'attr': attr, 'attr_type': attr_type, 'value': int(value), 'desc': get_attr_desc(attr)}) return attrs def get_stone_detail(row): - item_rows = READER.query("other_settings", dict(EnchantID=int(row['ID']))) + item_rows = Tool.READER.query('other_settings', dict(EnchantID=int(row['ID']))) item_ids = [row['ID'] for row in item_rows] level = 0 for key in STONE_LEVELS: @@ -395,10 +378,7 @@ def get_stone_detail(row): level = STONE_LEVELS[key] if not level: return {} - detail = { - "enchant_id": row['ID'], "item_ids": item_ids, "name": row['Name'], "level": level, - "attributes": get_stone_attrs(row) - } + detail = {'enchant_id': row['ID'], 'item_ids': item_ids, 'name': row['Name'], 'level': level, 'attributes': get_stone_attrs(row)} return detail @@ -406,6 +386,7 @@ def get_stone_code(detail): detail['attributes'], _, _ = simplify_attrs(detail['attributes']) return detail + def build_stone_code(details: dict[int, dict]): results = {} for detail in details.values(): @@ -427,7 +408,7 @@ def get_stones_list(enchant_settings): stone_tab = enchant_settings[enchant_settings.DiamondType1 > 0] results = {} - for row in tqdm(stone_tab.to_dict("records")): + for row in tqdm(stone_tab.to_dict('records')): detail = get_stone_detail(row) if not detail: continue @@ -437,19 +418,19 @@ def get_stones_list(enchant_settings): def generate(): - armor_json, armor_code = get_equip_list(READER.TABLES['armor_settings']) - save_json("armors", armor_json) - trinket_json, trinket_code = get_equip_list(READER.TABLES['trinket_settings']) - save_json("trinkets", trinket_json) - weapon_json, weapon_code = get_equip_list(READER.TABLES['weapon_settings']) - save_json("weapons", weapon_json) - save_code("equipments", armor_code | trinket_code | weapon_code) - enchant_json, enchant_code = get_enchants_list(READER.TABLES["enchant_settings"]) - save_code("enchants", enchant_code) - save_json("enchants", enchant_json) - stone_json, stone_code = get_stones_list(READER.TABLES['enchant_settings']) - save_code("stones", stone_code) - save_json("stones", stone_json) + armor_json, armor_code = get_equip_list(Tool.READER.TABLES['armor_settings']) + save_json('armors', armor_json) + trinket_json, trinket_code = get_equip_list(Tool.READER.TABLES['trinket_settings']) + save_json('trinkets', trinket_json) + weapon_json, weapon_code = get_equip_list(Tool.READER.TABLES['weapon_settings']) + save_json('weapons', weapon_json) + save_code('equipments', armor_code | trinket_code | weapon_code) + enchant_json, enchant_code = get_enchants_list(Tool.READER.TABLES['enchant_settings']) + save_code('enchants', enchant_code) + save_json('enchants', enchant_json) + stone_json, stone_code = get_stones_list(Tool.READER.TABLES['enchant_settings']) + save_code('stones', stone_code) + save_json('stones', stone_json) if __name__ == '__main__': diff --git a/tools/reader.py b/tools/reader.py index 13df27f..b0b3982 100644 --- a/tools/reader.py +++ b/tools/reader.py @@ -2,38 +2,14 @@ class BaseReader: - TABLES: dict = {} - - def __init__(self): - ... - - def query(self, table_name, condition) -> list[dict]: - ... - - -class DataFrameReader(BaseReader): - TABLES = dict( - weapon_settings=read_tab("settings/item/Custom_Weapon.tab"), - armor_settings = read_tab("settings/item/Custom_Armor.tab"), - trinket_settings = read_tab("settings/item/Custom_Trinket.tab"), - enchant_settings = read_tab("settings/item/Enchant.tab"), - attrib_settings = read_tab("settings/item/Attrib.tab"), - set_settings = read_tab("settings/item/Set.tab"), - other_settings = read_tab("settings/item/Other.tab"), - event_settings = read_tab("settings/skill/SkillEvent.tab", "settings/skill_mobile/SkillEvent.tab"), - - item_txts = read_tab("ui/scheme/case/Item.txt"), - attrib_txts = read_tab("ui/scheme/case/Attribute.txt"), - recipe_txts = read_tab("ui/scheme/case/EquipmentRecipe.txt"), - event_txts = read_tab("ui/scheme/case/SkillEvent.txt") - ) QUALITY_COF = { 1: 1, 2: 1.4, 3: 1.6, 4: 1.8, - 5: 2.5 + 5: 2.5, } + """计算装分:紫橙装系数""" POSITION_COF = { 0: 1.2, 1: 0.6, @@ -47,6 +23,39 @@ class DataFrameReader(BaseReader): 9: 0.7, 10: 0.7, } + """计算装分:各部位系数""" + + TABLES: dict = {} + + def __init__(self): ... + + def query(self, table_name, condition: dict[str, any]) -> list[dict]: + """实现数据查询 + @table_name: 表名 + @condition: 查询条件,字典格式,如{'ID': 1001} + + @return: 符合条件的多行数据,列表套字典 + + TODO 此处应明确哪些表会被调用、各是什么数据结构,建立Entity类进行返回 + """ + ... + + +class DataFrameReader(BaseReader): + TABLES = dict( + weapon_settings=read_tab('settings/item/Custom_Weapon.tab'), + armor_settings=read_tab('settings/item/Custom_Armor.tab'), + trinket_settings=read_tab('settings/item/Custom_Trinket.tab'), + enchant_settings=read_tab('settings/item/Enchant.tab'), + attrib_settings=read_tab('settings/item/Attrib.tab'), + set_settings=read_tab('settings/item/Set.tab'), + other_settings=read_tab('settings/item/Other.tab'), + event_settings=read_tab('settings/skill/SkillEvent.tab', 'settings/skill_mobile/SkillEvent.tab'), + item_txts=read_tab('ui/scheme/case/Item.txt'), + attrib_txts=read_tab('ui/scheme/case/Attribute.txt'), + recipe_txts=read_tab('ui/scheme/case/EquipmentRecipe.txt'), + event_txts=read_tab('ui/scheme/case/SkillEvent.txt'), + ) def __init__(self): super().__init__() @@ -64,4 +73,4 @@ def query(self, table_name, condition) -> list[dict]: rows = table for k, v in condition.items(): rows = rows[rows[k] == v] - return rows.to_dict("records") \ No newline at end of file + return rows.to_dict('records')