mirror of
https://github.com/mhwikicn/mhdos-armor-set-searcher
synced 2025-12-06 04:59:04 +08:00
Update get-equipment-decos.py
This commit is contained in:
parent
b1d7507bfa
commit
9b86920e82
@ -1,6 +1,5 @@
|
||||
import json
|
||||
|
||||
|
||||
def reorder_resistances(raw: list) -> list:
|
||||
return [
|
||||
raw[0],
|
||||
@ -10,7 +9,6 @@ def reorder_resistances(raw: list) -> list:
|
||||
raw[4],
|
||||
]
|
||||
|
||||
|
||||
def map_skills_map(raw: dict, skill_ids: dict) -> dict:
|
||||
skills = {}
|
||||
for s in raw:
|
||||
@ -21,10 +19,8 @@ def map_skills_map(raw: dict, skill_ids: dict) -> dict:
|
||||
except:
|
||||
v = 0 # torso up
|
||||
skills[id] = v
|
||||
|
||||
return skills
|
||||
|
||||
|
||||
def map_deco(raw: dict, skill_ids: dict) -> dict:
|
||||
return {
|
||||
"name": raw["name"],
|
||||
@ -33,6 +29,56 @@ def map_deco(raw: dict, skill_ids: dict) -> dict:
|
||||
"skills": map_skills_map(raw["skills"], skill_ids),
|
||||
}
|
||||
|
||||
def process_armor_piece(piece, cat_index, skill_ids):
|
||||
name = piece["name"]
|
||||
if name == "None":
|
||||
return []
|
||||
|
||||
# skip if unacquirable
|
||||
if piece.get("acquire", 0) or piece.get("dev", 0):
|
||||
return []
|
||||
|
||||
# skip if only female
|
||||
if piece.get("sex", "") == "Female":
|
||||
return []
|
||||
|
||||
# get type
|
||||
x = piece.get("hunterClass", "")
|
||||
type = 1 if x == "Blademaster" else 2 if x == "Gunner" else 0
|
||||
|
||||
# get unique slots and their first occurrence positions
|
||||
slots = piece["slots"]
|
||||
defe = piece["defense"]
|
||||
skills = piece.get("skills", [])
|
||||
|
||||
# create a dictionary to track first occurrence of each slot value
|
||||
slot_variants = {}
|
||||
for pos, slot_value in enumerate(slots):
|
||||
if slot_value not in slot_variants:
|
||||
slot_variants[slot_value] = pos + 1 # LV starts from 1
|
||||
|
||||
# generate variants for each unique slot value
|
||||
variants = []
|
||||
for slot_value, lv_pos in slot_variants.items():
|
||||
variant_name = f"{name}(LV{lv_pos}+)"
|
||||
variant_defense_base = defe[lv_pos - 1] # positions are 0-based in array
|
||||
|
||||
modeled_piece = {
|
||||
"category": cat_index,
|
||||
"name": variant_name,
|
||||
"rarity": piece["rarity"],
|
||||
"skills": map_skills_map(skills, skill_ids),
|
||||
"slots": slot_value,
|
||||
"defense": {
|
||||
"base": variant_defense_base,
|
||||
"max": defe[-1],
|
||||
},
|
||||
"type": type,
|
||||
"resistance": reorder_resistances(piece["resistances"]),
|
||||
}
|
||||
variants.append(modeled_piece)
|
||||
|
||||
return variants
|
||||
|
||||
if __name__ == "__main__":
|
||||
# read input
|
||||
@ -55,40 +101,8 @@ if __name__ == "__main__":
|
||||
pieces_of_cat = []
|
||||
# iterate over pieces of that category
|
||||
for piece in armor_category["armor"]:
|
||||
# get attributes
|
||||
name = piece["name"]
|
||||
if name == "None":
|
||||
continue
|
||||
defe = piece["defense"]
|
||||
skills = piece.get("skills", [])
|
||||
|
||||
# skip if unacquirable
|
||||
if piece.get("acquire", 0) or piece.get("dev", 0):
|
||||
continue
|
||||
|
||||
# skip if only female
|
||||
if piece.get("sex", "") == "Female":
|
||||
continue
|
||||
|
||||
# get type
|
||||
x = piece.get("hunterClass", "")
|
||||
type = 1 if x == "Blademaster" else 2 if x == "Gunner" else 0
|
||||
|
||||
# model and push piece
|
||||
modeled_piece = {
|
||||
"category": cat_index,
|
||||
"name": name,
|
||||
"rarity": piece["rarity"],
|
||||
"skills": map_skills_map(skills, skill_ids),
|
||||
"slots": piece["slots"][-1],
|
||||
"defense": {
|
||||
"base": defe[0],
|
||||
"max": defe[-1],
|
||||
},
|
||||
"type": type,
|
||||
"resistance": reorder_resistances(piece["resistances"]),
|
||||
}
|
||||
pieces_of_cat.append(modeled_piece)
|
||||
variants = process_armor_piece(piece, cat_index, skill_ids)
|
||||
pieces_of_cat.extend(variants)
|
||||
pieces_per_category.append(pieces_of_cat)
|
||||
|
||||
# save files
|
||||
|
||||
Loading…
Reference in New Issue
Block a user