Skip to content

Commit

Permalink
✨ Add relic type to model
Browse files Browse the repository at this point in the history
  • Loading branch information
mobyw committed May 26, 2024
1 parent 0262f4f commit 5515b90
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
35 changes: 26 additions & 9 deletions starrailres/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
from .utils import decode_json


relic_type_map: Dict[str, int] = {
"HEAD": 1,
"HAND": 2,
"BODY": 3,
"FOOT": 4,
"NECK": 5,
"OBJECT": 6,
}


class Index:
characters: CharacterIndex
character_ranks: CharacterRankIndex
Expand Down Expand Up @@ -268,6 +278,7 @@ def get_relic_info(self, basic: RelicBasicInfo) -> Optional[RelicInfo]:
info = RelicInfo(
id=basic.id,
name=self.relics[basic.id].name,
type=relic_type_map.get(self.relics[basic.id].type, 0),
set_id=self.relics[basic.id].set_id,
set_name=self.relic_sets[self.relics[basic.id].set_id].name,
rarity=self.relics[basic.id].rarity,
Expand Down Expand Up @@ -321,9 +332,11 @@ def get_relic_sets_info(self, relics: List[RelicInfo]) -> List[RelicSetInfo]:
name=self.relic_sets[k].name,
icon=self.relic_sets[k].icon,
num=4,
desc=self.relic_sets[k].desc[1]
if len(self.relic_sets[k].desc) > 1
else "",
desc=(
self.relic_sets[k].desc[1]
if len(self.relic_sets[k].desc) > 1
else ""
),
properties=[
PropertyInfo(
type=i.type,
Expand Down Expand Up @@ -420,15 +433,19 @@ def get_character_skill_tree_info(
return []
parsed_info = SkillTreeInfo(
id=skill_tree_id,
level=skill_tree_dict[skill_tree_id]
if skill_tree_id in skill_tree_dict
else 0,
level=(
skill_tree_dict[skill_tree_id]
if skill_tree_id in skill_tree_dict
else 0
),
max_level=self.character_skill_trees[skill_tree_id].max_level,
anchor=self.character_skill_trees[skill_tree_id].anchor,
icon=self.character_skill_trees[skill_tree_id].icon,
parent=self.character_skill_trees[skill_tree_id].pre_points[0]
if self.character_skill_trees[skill_tree_id].pre_points
else None,
parent=(
self.character_skill_trees[skill_tree_id].pre_points[0]
if self.character_skill_trees[skill_tree_id].pre_points
else None
),
)
skill_tree_info_list.append(parsed_info)
return skill_tree_info_list
Expand Down
1 change: 1 addition & 0 deletions starrailres/models/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class CharacterBasicInfo(Struct):
class RelicInfo(Struct):
id: str
name: str
type: int
set_id: str
set_name: str
rarity: int
Expand Down

0 comments on commit 5515b90

Please sign in to comment.