Skip to content

Commit e6e74c3

Browse files
authored
Merge pull request #1 from nullpluto/dev
Dev
2 parents f7761c1 + b7ec556 commit e6e74c3

7 files changed

Lines changed: 152 additions & 1 deletion

File tree

autopcr/core/apiclient.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from re import search
22

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

187+
if response.data_headers.result_code == 203:
188+
raise PanicError(f"{response.data.server_error.message}")
189+
185190
self.active_server = (self.active_server + 1) % len(self.servers)
186191

187192
if "维护" in response.data.server_error.message:

autopcr/core/pcrclient.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,15 @@ async def abd_top(self):
821821
req = SubStoryAbdTopRequest()
822822
return await self.request(req)
823823

824+
async def read_rag_story(self, sub_story_id: int):
825+
req = SubStoryRagReadStoryRequest()
826+
req.sub_story_id = sub_story_id
827+
req.skip_info = StorySkipInfo(
828+
skip_type = eStorySkipType.MENU_SKIP,
829+
scroll_coordinate = ""
830+
)
831+
return await self.request(req)
832+
824833
async def read_abd_story(self, sub_story_id: int):
825834
req = SubStoryAbdReadStoryRequest()
826835
req.sub_story_id = sub_story_id

autopcr/db/database.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,14 @@ def event_quest_data(self) -> Dict[int, List[Union[HatsuneQuest, SevenQuestDatum
14271427
for event_id, quests in ret.items():
14281428
quests.sort(key=self.get_event_quest_order)
14291429
return dict(ret)
1430+
1431+
@lazy_property
1432+
def rag_story_data(self) -> Dict[int, RagStoryDatum]:
1433+
with self.dbmgr.session() as db:
1434+
return (
1435+
RagStoryDatum.query(db)
1436+
.to_dict(lambda x: x.sub_story_id, lambda x: x)
1437+
)
14301438

14311439
@lazy_property
14321440
def abd_story_data(self) -> Dict[int, AbdStoryDatum]:

autopcr/model/handlers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,18 @@ async def update(self, mgr: datamgr, request):
889889
if self.exchange_rewards:
890890
for reward in self.exchange_rewards:
891891
mgr.update_inventory(reward)
892+
893+
@handles
894+
class SubStoryRagReadStoryResponse(responses.SubStoryRagReadStoryResponse):
895+
async def update(self, mgr: datamgr, request):
896+
if self.reward_info:
897+
for reward in self.reward_info:
898+
mgr.update_inventory(reward)
899+
if self.special_reward_list:
900+
for reward in self.special_reward_list:
901+
mgr.update_inventory(reward)
902+
if self.user_jewel:
903+
mgr.jewel = self.user_jewel
892904

893905
@handles
894906
class SubStoryAbdReadStoryResponse(responses.SubStoryAbdReadStoryResponse):

autopcr/module/modules/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class ModuleList:
9797
mirai_very_hard_sweep,
9898
smart_hard_sweep,
9999
smart_shiori_sweep,
100+
mirai_sp1_h_sweep,
101+
mirai_sp1_shiori_sweep,
100102
last_normal_quest_sweep,
101103
lazy_normal_sweep,
102104

autopcr/module/modules/autosweep.py

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def get_max_times(self, client: pcrclient, quest_id: int) -> int:
402402
116901, # 电子龙
403403
]
404404
@conditional_execution1("very_hard_sweep_run_time", ["vh庆典"])
405-
@description('储备专二需求的150碎片(目标角色见模块内 `unique_equip_2_pure_memory_id`)')
405+
@description('储备专二需求的150碎片' + ','.join(db.get_unit_name(unit_id) for unit_id in unique_equip_2_pure_memory_id))
406406
@name('专二纯净碎片储备')
407407
@default(False)
408408
@tag_stamina_consume
@@ -432,6 +432,92 @@ def get_need_quest(self, token: ItemType) -> List[QuestDatum]:
432432
def get_max_times(self, client: pcrclient, quest_id: int) -> int:
433433
return 5 if db.is_shiori_quest(quest_id) else 3
434434

435+
unique_equip_1_sp_memory_id = [
436+
# 103201, # 哈哈剑 送515
437+
# 102801, # 充电宝 送515
438+
# 100101, # 猫拳 送515
439+
# 101001, # 真步 送515
440+
# 100401, # 炸弹人 商店换
441+
# 106101, # 611 商店换
442+
# 103601, # xcw 送515
443+
# 106401, # 雪菲 送515
444+
# 107701, # 水女仆 商店换
445+
# 107901, # 水猫剑 商店换
446+
104801, # 子龙
447+
108001, # 水子龙
448+
# 102301, # 熊锤 商店换
449+
106301, # yls
450+
102101, # 铃铛
451+
# 105901, # 普白 送515
452+
# 103701, # 智 送515
453+
102001, # 兔子
454+
# 101401, # 驴 送515
455+
105701, # 姬塔
456+
# 101601, # 暴击弓 商店换
457+
# 101201, # 星法 送515
458+
# 105801, # 吃货 送515
459+
# 103401, # 黄骑 商店换
460+
# 100601, # 妹法 商店换
461+
104401, # yly
462+
# 106001, # 黑猫 送515
463+
# 105101, # 深月 商店换
464+
# 100701, # 布丁 商店换
465+
# 102201, # 姐法 商店换
466+
]
467+
@conditional_not_execution("mirai_sp1_h_sweep_not_run_time", [])
468+
@conditional_execution1("mirai_sp1_h_sweep_run_time", ["h庆典"])
469+
@description('储备专一SP需求的300碎片' + ','.join(db.get_unit_name(unit_id) for unit_id in unique_equip_1_sp_memory_id))
470+
@name('专一SP碎片储备(H本)')
471+
@default(False)
472+
@tag_stamina_consume
473+
class mirai_sp1_h_sweep(simple_demand_sweep_base):
474+
475+
async def get_need_list(self, client: pcrclient) -> List[Tuple[ItemType, int]]:
476+
memory_gap = client.data.get_memory_demand_gap()
477+
target = Counter()
478+
need_list = []
479+
for unit in unique_equip_1_sp_memory_id:
480+
token = (eInventoryType.Item, db.unit_to_memory[unit])
481+
target[unit] += 300
482+
if -memory_gap[token] < target[unit]:
483+
need_list.append((token, target[unit] - memory_gap[token]))
484+
if not need_list:
485+
raise SkipError("所有角色碎片均已盈余")
486+
return need_list
487+
488+
def get_need_quest(self, token: ItemType) -> List[QuestDatum]:
489+
return db.memory_hard_quest.get(token, [])
490+
491+
def get_max_times(self, client: pcrclient, quest_id: int) -> int:
492+
return 3
493+
494+
@conditional_not_execution("mirai_sp1_shiori_sweep_not_run_time", ["n3", 'n4及以上'])
495+
@conditional_execution1("mirai_sp1_shiori_sweep_run_time", ["无庆典"])
496+
@description('储备专一SP需求的300碎片' + ','.join(db.get_unit_name(unit_id) for unit_id in unique_equip_1_sp_memory_id))
497+
@name('专一SP碎片储备(外传)')
498+
@default(False)
499+
@tag_stamina_consume
500+
class mirai_sp1_shiori_sweep(simple_demand_sweep_base):
501+
502+
async def get_need_list(self, client: pcrclient) -> List[Tuple[ItemType, int]]:
503+
memory_gap = client.data.get_memory_demand_gap()
504+
target = Counter()
505+
need_list = []
506+
for unit in unique_equip_1_sp_memory_id:
507+
token = (eInventoryType.Item, db.unit_to_memory[unit])
508+
target[unit] += 300
509+
if -memory_gap[token] < target[unit]:
510+
need_list.append((token, target[unit] - memory_gap[token]))
511+
if not need_list:
512+
raise SkipError("所有角色碎片均已盈余")
513+
return need_list
514+
515+
def get_need_quest(self, token: ItemType) -> List[QuestDatum]:
516+
return db.memory_shiori_quest.get(token, [])
517+
518+
def get_max_times(self, client: pcrclient, quest_id: int) -> int:
519+
return 5
520+
435521
@singlechoice("vh_sweep_campaign_times", "庆典次数", 3, [0, 3, 6])
436522
@singlechoice("vh_sweep_times", "非庆典次数", 3, [0, 3, 6])
437523
@description('根据纯净碎片缺口智能刷vh图')

autopcr/util/substory.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,35 @@ def GetSubStoryReader(sub_story_data: EventSubStory, client: pcrclient) -> Union
4747
return constructor[sub_story_data.event_id](client)
4848
return None
4949

50+
@EventId(10152)
51+
class rag_substory(SubStoryReader):
52+
53+
def is_readable(self, sub_story_id: int) -> bool:
54+
story_data = db.rag_story_data[sub_story_id]
55+
if db.parse_time(story_data.condition_time) > apiclient.datetime:
56+
return False
57+
58+
condition_id = story_data.read_condition_sub_story_id
59+
if condition_id == 0:
60+
return True
61+
62+
event_sub_story = self.client.data.event_sub_story.get(story_data.original_event_id)#根据前置剧情判断是否可以阅读
63+
return event_sub_story is not None and any(
64+
info.sub_story_id == condition_id and info.status == eEventSubStoryStatus.READED
65+
for info in event_sub_story.sub_story_info_list
66+
)
67+
68+
def title(self, sub_story_id: int) -> str:
69+
return db.rag_story_data[sub_story_id].title
70+
71+
async def sort_by_time(self, sub_story_ids: List[EventSubStory]) -> List[EventSubStory]:
72+
return sorted(sub_story_ids, key=lambda s: db.rag_story_data[s.sub_story_id].read_condition_sub_story_id != 0)#将没有前置剧情的放在前面,优先阅读
73+
74+
async def read(self, sub_story_id: int):
75+
if sub_story_id == 5152601:
76+
await self.client.story_check(sub_story_id)
77+
await self.client.read_rag_story(sub_story_id)
78+
5079
@EventId(10154)
5180
class abd_substory(SubStoryReader):
5281

0 commit comments

Comments
 (0)