Esempio n. 1
0
def load_data(window):
    item_data = [ItemMethods.itemparser(item)[0] for item in GC.ITEMDATA]
    item_data = sorted(item_data, key=lambda item: GC.ITEMDATA[item.id]['num'])
    item_data = [item for item in item_data if not item.virtual]
    for item in item_data:
        if item.image:
            item.icon = create_icon(item.image.convert_alpha(), window)
    skill_data = [
        StatusObject.statusparser(skill.find('id').text)
        for skill in GC.STATUSDATA.getroot().findall('status')
    ]
    for skill in skill_data:
        if skill.icon:
            skill.icon = create_icon(skill.icon.convert_alpha(), window)
    portrait_data = SaveLoad.create_portrait_dict()
    class_dict = SaveLoad.create_class_dict()
    for klass in class_dict.values():
        generic_unit = GenericUnit(klass['name'])
        klass['images'] = (generic_unit.image1, generic_unit.image2,
                           generic_unit.image3)
        klass['icon'] = create_icon(klass['images'][0], window)
    class_data = sorted([klass for klass in class_dict.values()],
                        key=lambda x: (x['id'] % 100, x['id']))
    unit_data = build_units(class_dict, portrait_data)

    return unit_data, class_dict, class_data, item_data, skill_data, portrait_data
Esempio n. 2
0
    def load_data(self):
        # === Terrain Data ===
        # Saved dictionary of terrains 2-tuple {color: (id, name)}
        self.terrain_data = OrderedDict()
        # Ingest terrain_data
        for terrain in GC.TERRAINDATA.getroot().findall('terrain'):
            color = tuple(
                int(num) for num in terrain.find('color').text.split(','))
            tid = terrain.find('id').text
            name = terrain.get('name')
            self.terrain_data[color] = (tid, name)

        # === Item Data ===
        self.item_data = OrderedDict()
        items = [ItemMethods.itemparser(item)[0] for item in GC.ITEMDATA]
        items = sorted(items, key=lambda item: GC.ITEMDATA[item.id]['num'])
        items = [item for item in items if not item.virtual]
        for item in items:
            if item.image:
                item.image = item.image.convert_alpha()
            self.item_data[item.id] = item

        # === Skill Data ===
        self.skill_data = OrderedDict()
        skills = [
            StatusObject.statusparser(skill.find('id').text)
            for skill in GC.STATUSDATA.getroot().findall('status')
        ]
        for skill in skills:
            if skill.image:
                skill.image = skill.image.convert_alpha()
            self.skill_data[skill.id] = skill

        # === Portrait Data ===
        # Has mouth and blink positions by name
        portrait_dict = SaveLoad.create_portrait_dict()
        # Setting up portrait data
        self.portrait_data = OrderedDict()
        for name, portrait in portrait_dict.items():
            try:
                self.portrait_data[name] = UnitPortrait(
                    name, portrait['blink'], portrait['mouth'], (0, 0))
            except KeyError as e:
                print('%s: %s portrait not found' % (e, name))
        for portrait in self.portrait_data.values():
            portrait.create_image()
            portrait.image = portrait.image.convert_alpha()

        # === Class Data ===
        self.class_dict = SaveLoad.create_class_dict()
        self.class_data = OrderedDict()
        for klass_id, klass in self.class_dict.items():
            self.class_data[klass_id] = Klass(klass)

        # === Loaded Preset Unit Data ===
        self.unit_data = build_named_units(self.class_dict)