CoolFace
Apppublic

AngoHF/Formulator

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
parse_new_school.py63 linesDownload Raw Back to root
1import json2 3from utils.lua import parse_player4 5 6class Parser:7    @staticmethod8    def parse_talents(detail):9        return [row[1] for row in detail]10 11    def parse_buff(self, row):12        detail = row.strip("{}").split(",")13        buff_id, buff_stack, buff_level = int(detail[4]), int(detail[5]), int(detail[8])14        if buff_id not in self.buffs:15            self.buffs[buff_id] = {}16        if buff_level not in self.buffs[buff_id]:17            self.buffs[buff_id][buff_level] = []18        if buff_stack not in self.buffs[buff_id][buff_level]:19            self.buffs[buff_id][buff_level].append(buff_stack)20            self.buffs[buff_id][buff_level].sort()21 22    def parse_skill(self, row):23        detail = row.strip("{}").split(",")24 25        skill_id, skill_level, critical = int(detail[4]), int(detail[5]), detail[6] == "true"26        # if not sum(parse(row)[-1].values()):27        #     return28        if skill_id not in self.skills:29            self.skills[skill_id] = []30        if skill_level not in self.skills[skill_id]:31            self.skills[skill_id].append(skill_level)32            self.skills[skill_id].sort()33 34    def __call__(self, file_name):35        self.buffs = {}36        self.skills = {}37        self.talents = []38        lines = open(file_name).readlines()39        for line in lines:40            row = line.split("\t")41            if row[4] == "4":42                detail = parse_player(row[-1])43                self.school_id = int(detail[3])44                if isinstance(detail, list):45                    self.talents = self.parse_talents(detail[6])46        for line in lines:47            row = line.split("\t")48            if row[4] == "13":49                self.parse_buff(row[-1])50            elif row[4] == "21":51                self.parse_skill(row[-1])52        print(self.school_id)53        print(self.talents)54        json.dump(self.skills, open("skills.json", "w", encoding="utf-8"))55        print(len(self.skills))56        json.dump(self.buffs, open("buffs.json", "w", encoding="utf-8"))57        print(len(self.buffs))58 59 60if __name__ == '__main__':61    parser = Parser()62    parser(r"2024-05-11-22-42-47-长安(15)-极境试炼木桩(24538).jcl")63