Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions autopcr/core/apiclient.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from re import search

from ..model.error import PanicError

from .base import Container
from ..model.modelbase import *
from asyncio import Lock
Expand Down Expand Up @@ -182,6 +184,9 @@ async def _request_internal(self, request: Request[TResponse]) -> TResponse:
logger.error(json.dumps(dict(resp.headers), indent=4, ensure_ascii=False) + '\n')
logger.error(json.dumps(response0, indent=4, ensure_ascii=False) + '\n')

if response.data_headers.result_code == 203:
raise PanicError(f"{response.data.server_error.message}")

self.active_server = (self.active_server + 1) % len(self.servers)

if "维护" in response.data.server_error.message:
Expand Down
9 changes: 9 additions & 0 deletions autopcr/core/pcrclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,15 @@ async def abd_top(self):
req = SubStoryAbdTopRequest()
return await self.request(req)

async def read_rag_story(self, sub_story_id: int):
req = SubStoryRagReadStoryRequest()
req.sub_story_id = sub_story_id
req.skip_info = StorySkipInfo(
skip_type = eStorySkipType.MENU_SKIP,
scroll_coordinate = ""
)
return await self.request(req)

async def read_abd_story(self, sub_story_id: int):
req = SubStoryAbdReadStoryRequest()
req.sub_story_id = sub_story_id
Expand Down
8 changes: 8 additions & 0 deletions autopcr/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,14 @@ def event_quest_data(self) -> Dict[int, List[Union[HatsuneQuest, SevenQuestDatum
for event_id, quests in ret.items():
quests.sort(key=self.get_event_quest_order)
return dict(ret)

@lazy_property
def rag_story_data(self) -> Dict[int, RagStoryDatum]:
with self.dbmgr.session() as db:
return (
RagStoryDatum.query(db)
.to_dict(lambda x: x.sub_story_id, lambda x: x)
)

@lazy_property
def abd_story_data(self) -> Dict[int, AbdStoryDatum]:
Expand Down
12 changes: 12 additions & 0 deletions autopcr/model/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,18 @@ async def update(self, mgr: datamgr, request):
if self.exchange_rewards:
for reward in self.exchange_rewards:
mgr.update_inventory(reward)

@handles
class SubStoryRagReadStoryResponse(responses.SubStoryRagReadStoryResponse):
async def update(self, mgr: datamgr, request):
if self.reward_info:
for reward in self.reward_info:
mgr.update_inventory(reward)
if self.special_reward_list:
for reward in self.special_reward_list:
mgr.update_inventory(reward)
if self.user_jewel:
mgr.jewel = self.user_jewel

@handles
class SubStoryAbdReadStoryResponse(responses.SubStoryAbdReadStoryResponse):
Expand Down
2 changes: 2 additions & 0 deletions autopcr/module/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class ModuleList:
mirai_very_hard_sweep,
smart_hard_sweep,
smart_shiori_sweep,
mirai_sp1_h_sweep,
mirai_sp1_shiori_sweep,
last_normal_quest_sweep,
lazy_normal_sweep,

Expand Down
88 changes: 87 additions & 1 deletion autopcr/module/modules/autosweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def get_max_times(self, client: pcrclient, quest_id: int) -> int:
116901, # 电子龙
]
@conditional_execution1("very_hard_sweep_run_time", ["vh庆典"])
@description('储备专二需求的150碎片(目标角色见模块内 `unique_equip_2_pure_memory_id`)')
@description('储备专二需求的150碎片' + ','.join(db.get_unit_name(unit_id) for unit_id in unique_equip_2_pure_memory_id))
@name('专二纯净碎片储备')
@default(False)
@tag_stamina_consume
Expand Down Expand Up @@ -432,6 +432,92 @@ def get_need_quest(self, token: ItemType) -> List[QuestDatum]:
def get_max_times(self, client: pcrclient, quest_id: int) -> int:
return 5 if db.is_shiori_quest(quest_id) else 3

unique_equip_1_sp_memory_id = [
# 103201, # 哈哈剑 送515
# 102801, # 充电宝 送515
# 100101, # 猫拳 送515
# 101001, # 真步 送515
# 100401, # 炸弹人 商店换
# 106101, # 611 商店换
# 103601, # xcw 送515
# 106401, # 雪菲 送515
# 107701, # 水女仆 商店换
# 107901, # 水猫剑 商店换
104801, # 子龙
108001, # 水子龙
# 102301, # 熊锤 商店换
106301, # yls
102101, # 铃铛
# 105901, # 普白 送515
# 103701, # 智 送515
102001, # 兔子
# 101401, # 驴 送515
105701, # 姬塔
# 101601, # 暴击弓 商店换
# 101201, # 星法 送515
# 105801, # 吃货 送515
# 103401, # 黄骑 商店换
# 100601, # 妹法 商店换
104401, # yly
# 106001, # 黑猫 送515
# 105101, # 深月 商店换
# 100701, # 布丁 商店换
# 102201, # 姐法 商店换
]
@conditional_not_execution("mirai_sp1_h_sweep_not_run_time", [])
@conditional_execution1("mirai_sp1_h_sweep_run_time", ["h庆典"])
@description('储备专一SP需求的300碎片' + ','.join(db.get_unit_name(unit_id) for unit_id in unique_equip_1_sp_memory_id))
@name('专一SP碎片储备(H本)')
@default(False)
@tag_stamina_consume
class mirai_sp1_h_sweep(simple_demand_sweep_base):

async def get_need_list(self, client: pcrclient) -> List[Tuple[ItemType, int]]:
memory_gap = client.data.get_memory_demand_gap()
target = Counter()
need_list = []
for unit in unique_equip_1_sp_memory_id:
token = (eInventoryType.Item, db.unit_to_memory[unit])
target[unit] += 300
if -memory_gap[token] < target[unit]:
need_list.append((token, target[unit] - memory_gap[token]))
if not need_list:
raise SkipError("所有角色碎片均已盈余")
return need_list

def get_need_quest(self, token: ItemType) -> List[QuestDatum]:
return db.memory_hard_quest.get(token, [])

def get_max_times(self, client: pcrclient, quest_id: int) -> int:
return 3

@conditional_not_execution("mirai_sp1_shiori_sweep_not_run_time", ["n3", 'n4及以上'])
@conditional_execution1("mirai_sp1_shiori_sweep_run_time", ["无庆典"])
@description('储备专一SP需求的300碎片' + ','.join(db.get_unit_name(unit_id) for unit_id in unique_equip_1_sp_memory_id))
@name('专一SP碎片储备(外传)')
@default(False)
@tag_stamina_consume
class mirai_sp1_shiori_sweep(simple_demand_sweep_base):

async def get_need_list(self, client: pcrclient) -> List[Tuple[ItemType, int]]:
memory_gap = client.data.get_memory_demand_gap()
target = Counter()
need_list = []
for unit in unique_equip_1_sp_memory_id:
token = (eInventoryType.Item, db.unit_to_memory[unit])
target[unit] += 300
if -memory_gap[token] < target[unit]:
need_list.append((token, target[unit] - memory_gap[token]))
if not need_list:
raise SkipError("所有角色碎片均已盈余")
return need_list

def get_need_quest(self, token: ItemType) -> List[QuestDatum]:
return db.memory_shiori_quest.get(token, [])

def get_max_times(self, client: pcrclient, quest_id: int) -> int:
return 5

@singlechoice("vh_sweep_campaign_times", "庆典次数", 3, [0, 3, 6])
@singlechoice("vh_sweep_times", "非庆典次数", 3, [0, 3, 6])
@description('根据纯净碎片缺口智能刷vh图')
Expand Down
29 changes: 29 additions & 0 deletions autopcr/util/substory.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,35 @@ def GetSubStoryReader(sub_story_data: EventSubStory, client: pcrclient) -> Union
return constructor[sub_story_data.event_id](client)
return None

@EventId(10152)
class rag_substory(SubStoryReader):

def is_readable(self, sub_story_id: int) -> bool:
story_data = db.rag_story_data[sub_story_id]
if db.parse_time(story_data.condition_time) > apiclient.datetime:
return False

condition_id = story_data.read_condition_sub_story_id
if condition_id == 0:
return True

event_sub_story = self.client.data.event_sub_story.get(story_data.original_event_id)#根据前置剧情判断是否可以阅读
return event_sub_story is not None and any(
info.sub_story_id == condition_id and info.status == eEventSubStoryStatus.READED
for info in event_sub_story.sub_story_info_list
)

def title(self, sub_story_id: int) -> str:
return db.rag_story_data[sub_story_id].title

async def sort_by_time(self, sub_story_ids: List[EventSubStory]) -> List[EventSubStory]:
return sorted(sub_story_ids, key=lambda s: db.rag_story_data[s.sub_story_id].read_condition_sub_story_id != 0)#将没有前置剧情的放在前面,优先阅读

async def read(self, sub_story_id: int):
if sub_story_id == 5152601:
await self.client.story_check(sub_story_id)
await self.client.read_rag_story(sub_story_id)

@EventId(10154)
class abd_substory(SubStoryReader):

Expand Down
Loading