2023-07-18 13:14:16 +00:00
|
|
|
"""Starrail chronicle activity."""
|
2023-09-30 11:30:01 +00:00
|
|
|
from typing import List, Optional, Dict
|
2023-07-18 13:14:16 +00:00
|
|
|
|
|
|
|
from simnet.models.base import APIModel
|
2023-07-21 09:11:30 +00:00
|
|
|
from simnet.models.starrail.character import ActivityCharacter
|
2023-07-18 13:14:16 +00:00
|
|
|
|
|
|
|
from .base import PartialTime
|
|
|
|
|
|
|
|
|
|
|
|
class StarRailActivityBase(APIModel):
|
|
|
|
"""StarRailActivity Base Model"""
|
|
|
|
|
2023-09-01 02:56:07 +00:00
|
|
|
exists_data: bool = True
|
2023-07-18 13:14:16 +00:00
|
|
|
is_hot: bool
|
|
|
|
strategy_link: str = ""
|
|
|
|
|
|
|
|
|
2023-07-21 09:11:30 +00:00
|
|
|
class StarRailFantasticStoryBuff(APIModel):
|
|
|
|
"""Fantastic Story Buff"""
|
|
|
|
|
|
|
|
id: int
|
|
|
|
name: str
|
|
|
|
desc: str
|
|
|
|
icon: str
|
|
|
|
|
|
|
|
|
|
|
|
class StarRailFantasticStoryRecord(APIModel):
|
|
|
|
"""Fantastic Story Record"""
|
|
|
|
|
|
|
|
name: str
|
|
|
|
score: int
|
|
|
|
score_rank: int
|
|
|
|
stage_id: int
|
|
|
|
finish_time: Optional[PartialTime]
|
|
|
|
avatars: List[ActivityCharacter]
|
|
|
|
buffs: List[StarRailFantasticStoryBuff]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def time_str(self) -> str:
|
|
|
|
"""Get the time as a string."""
|
|
|
|
if self.finish_time is None:
|
|
|
|
return "N/A"
|
|
|
|
|
|
|
|
return self.finish_time.datetime.strftime("%Y.%m.%d %H:%M")
|
|
|
|
|
|
|
|
|
|
|
|
class StarRailFantasticStory(StarRailActivityBase):
|
|
|
|
"""Fantastic Story"""
|
|
|
|
|
|
|
|
records: List[StarRailFantasticStoryRecord]
|
|
|
|
|
|
|
|
|
2023-08-09 08:55:17 +00:00
|
|
|
class StarRailTreasureDungeonRecord(APIModel):
|
|
|
|
"""Treasure Dungeon Record"""
|
|
|
|
|
|
|
|
stage_id: int
|
|
|
|
name: str
|
|
|
|
difficulty_id: int
|
|
|
|
avatars: List[ActivityCharacter]
|
|
|
|
icon: str
|
|
|
|
atk_buff: int
|
|
|
|
def_buff: int
|
|
|
|
used_stamina: int
|
|
|
|
ancient_weapon: int
|
|
|
|
ancient_armor: int
|
|
|
|
ancient_bomb: int
|
|
|
|
enemy_killed: int
|
|
|
|
finish_time: Optional[PartialTime]
|
|
|
|
special_buff: int
|
|
|
|
|
|
|
|
@property
|
|
|
|
def time_str(self) -> str:
|
|
|
|
"""Get the time as a string."""
|
|
|
|
if self.finish_time is None:
|
|
|
|
return "N/A"
|
|
|
|
|
|
|
|
return self.finish_time.datetime.strftime("%Y.%m.%d %H:%M")
|
|
|
|
|
|
|
|
|
|
|
|
class StarRailTreasureDungeon(StarRailActivityBase):
|
|
|
|
"""Treasure Dungeon"""
|
|
|
|
|
|
|
|
records: List[StarRailTreasureDungeonRecord]
|
|
|
|
|
|
|
|
|
2023-09-01 02:56:07 +00:00
|
|
|
class StarRailCopperManInfoBasic(APIModel):
|
|
|
|
"""Copper Man Info Basic"""
|
|
|
|
|
|
|
|
level: int
|
|
|
|
accumulate: int
|
|
|
|
cur_common_order: int
|
|
|
|
max_common_order: int
|
|
|
|
cur_customer_order: int
|
|
|
|
max_customer_order: int
|
|
|
|
cur_alley_event: int
|
|
|
|
max_alley_event: int
|
|
|
|
|
|
|
|
@property
|
|
|
|
def common_order_process(self) -> float:
|
|
|
|
"""Get the common order process."""
|
|
|
|
return 100.0 * self.cur_common_order / self.max_common_order
|
|
|
|
|
|
|
|
@property
|
|
|
|
def customer_order_process(self) -> float:
|
|
|
|
"""Get the customer order process."""
|
|
|
|
return 100.0 * self.cur_customer_order / self.max_customer_order
|
|
|
|
|
|
|
|
@property
|
|
|
|
def alley_event_process(self) -> float:
|
|
|
|
"""Get the alley event process."""
|
|
|
|
return 100.0 * self.cur_alley_event / self.max_alley_event
|
|
|
|
|
|
|
|
|
|
|
|
class StarRailCopperManInfoShop(APIModel):
|
|
|
|
"""Copper Man Info Shop"""
|
|
|
|
|
|
|
|
id: int
|
|
|
|
icon: str
|
|
|
|
name: str
|
|
|
|
is_unlock: bool
|
|
|
|
|
|
|
|
|
|
|
|
class StarRailCopperManInfo(APIModel):
|
|
|
|
"""Copper Man Info"""
|
|
|
|
|
|
|
|
basic: StarRailCopperManInfoBasic
|
|
|
|
shops: List[StarRailCopperManInfoShop]
|
|
|
|
exists_data: bool
|
|
|
|
|
|
|
|
|
|
|
|
class StarRailCopperMan(StarRailActivityBase):
|
|
|
|
"""Copper Man"""
|
|
|
|
|
|
|
|
info: StarRailCopperManInfo
|
|
|
|
|
|
|
|
|
2023-07-18 13:14:16 +00:00
|
|
|
class StarRailActivity(APIModel):
|
|
|
|
"""Starrail chronicle activity."""
|
|
|
|
|
|
|
|
activities: List
|
|
|
|
|
2023-09-30 11:30:01 +00:00
|
|
|
def find_activity(self, key: str) -> Optional[Dict]:
|
2023-07-21 09:11:30 +00:00
|
|
|
"""Find an activity by key."""
|
|
|
|
for activity in self.activities:
|
|
|
|
if list(activity.keys())[0] == key:
|
2023-09-01 02:56:07 +00:00
|
|
|
return activity[key]
|
2023-09-06 12:50:31 +00:00
|
|
|
raise ValueError("No starrail activity found.")
|
2023-07-21 09:11:30 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def fantastic_story(self) -> StarRailFantasticStory:
|
|
|
|
"""Get the fantastic story activity."""
|
2023-09-01 02:56:07 +00:00
|
|
|
return StarRailFantasticStory(**self.find_activity("fantastic_story"))
|
2023-08-09 08:55:17 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def treasure_dungeon(self) -> StarRailTreasureDungeon:
|
|
|
|
"""Get the treasure dungeon activity."""
|
2023-09-01 02:56:07 +00:00
|
|
|
return StarRailTreasureDungeon(**self.find_activity("treasure_dungeon"))
|
2023-08-09 08:55:17 +00:00
|
|
|
|
2023-09-01 02:56:07 +00:00
|
|
|
@property
|
|
|
|
def copper_man(self) -> StarRailCopperMan:
|
|
|
|
"""Get the copper man activity."""
|
|
|
|
return StarRailCopperMan(**self.find_activity("copper_man"))
|