from utils import load_json,other_data,Dict2Obj class Material: def __init__(self,name:str,level:str,main:dict,deputy:dict,assist:dict): self.name:str = name self.level:str = level assert list(main.keys()) == ["h_a_c","type","power"], f"{name}主药数据错误" assert list(deputy.keys()) == ["h_a_c","type","power"], f"{name}药引数据错误" assert list(assist.keys()) == ["type","power"], f"{name}辅药数据错误" self.main = Dict2Obj(main) self.deputy = Dict2Obj(deputy) self.assist = Dict2Obj(assist) self.children = [] def __str__(self): return f"""名字:{self.name} 品级:{self.level} 主药 {other_data.material_type[str(self.main.h_a_c.type)]}{str(self.main.h_a_c.power)} {other_data.material_type[str(self.main.type)]}{str(self.main.power)} 药引 {other_data.material_type[str(self.deputy.h_a_c.type)]}{str(self.deputy.h_a_c.power)} 辅药 {other_data.material_type[str(self.assist.type)]}{str(self.assist.power)}"""