Skip to content

Commit 1199fe2

Browse files
authored
Merge pull request #233 from cc004/dev
Dev
2 parents 2f327fd + 6251219 commit 1199fe2

8 files changed

Lines changed: 97 additions & 24 deletions

File tree

autopcr/core/pcrclient.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,10 @@ async def prepare_mana(self, mana: int):
617617
else:
618618
return False
619619

620-
async def exec_gacha_aware(self, target_gacha: GachaParameter, gacha_times: int, draw_type: eGachaDrawType, current_cost_num: int, campaign_id: int, auto_select_pickup: bool = True) -> GachaReward:
620+
async def exec_gacha_aware(self, target_gacha: GachaParameter, gacha_times: int, draw_type: eGachaDrawType, current_cost_num: int, campaign_id: int, auto_select_pickup: bool = True, pickup_min_first: bool = False) -> GachaReward:
621621

622-
if draw_type == eGachaDrawType.Payment and current_cost_num < 1500:
623-
raise AbortError(f"宝石{current_cost_num}不足1500")
622+
if draw_type == eGachaDrawType.Payment and current_cost_num < 150 * gacha_times:
623+
raise AbortError(f"宝石{current_cost_num}不足{150 * gacha_times}")
624624

625625
if draw_type == eGachaDrawType.Ticket and current_cost_num < 1:
626626
raise AbortError(f"单抽券{current_cost_num}不足")
@@ -642,8 +642,9 @@ async def exec_gacha_aware(self, target_gacha: GachaParameter, gacha_times: int,
642642
if target_gacha.select_pickup_slot_num == len(target_gacha.priority_list) and all(db.gacha_pickup[pickup_id][u].reward_id not in self.data.unit for u in target_gacha.priority_list):
643643
pass
644644
elif auto_select_pickup or target_gacha.select_pickup_slot_num > len(target_gacha.priority_list):
645+
sign = -1 if pickup_min_first else 1
645646
pickup_units = [u for u in db.gacha_pickup[pickup_id].values()]
646-
pickup_units.sort(key = lambda x: (x.reward_id not in self.data.unit, -x.reward_id), reverse = True)
647+
pickup_units.sort(key = lambda x: (x.reward_id not in self.data.unit, x.reward_id * sign), reverse = True)
647648
pickup_units = pickup_units[:target_gacha.select_pickup_slot_num]
648649
pickup_units = [u.priority for u in pickup_units]
649650
if set(pickup_units) != set(target_gacha.priority_list):
@@ -655,7 +656,7 @@ async def exec_gacha_aware(self, target_gacha: GachaParameter, gacha_times: int,
655656
raise AbortError(f"已达到天井{self.data.gacha_point[target_gacha.exchange_id].current_point}pt,请上号兑换角色")
656657

657658
if draw_type == eGachaDrawType.Payment: # 怎么回传没有宝石数
658-
tot = 1500
659+
tot = 150 * gacha_times
659660
mine = min(tot, self.data.jewel.free_jewel)
660661

661662
tot -= mine
@@ -713,6 +714,11 @@ async def read_story(self, story_id: int):
713714
await self.story_check(story_id)
714715
return await self.story_view(story_id)
715716

717+
async def read_ais_story(self, sub_story_id: int):
718+
req = SubStoryAisReadStoryRequest()
719+
req.sub_story_id = sub_story_id
720+
await self.request(req)
721+
716722
async def read_nyd_story(self, sub_story_id: int):
717723
req = SubStoryNydReadStoryRequest()
718724
req.sub_story_id = sub_story_id

autopcr/db/database.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class database():
5252
jewel: ItemType = (eInventoryType.Jewel, 91002)
5353
travel_speed_up_paper: ItemType = (eInventoryType.Item, 23002)
5454
gacha_single_ticket: ItemType = (eInventoryType.Item, 24001)
55+
gacha_ten_tickets: List[ItemType] = [(eInventoryType.Item, 24002), (eInventoryType.Item, 24004)]
5556
dice: ItemType = (eInventoryType.Item, 99009)
5657
ex_pt: ItemType = (eInventoryType.Item, 26201)
5758

@@ -1201,6 +1202,14 @@ def hatsune_item(self) -> Dict[int, HatsuneItem]:
12011202
.to_dict(lambda x: x.event_id, lambda x: x)
12021203
)
12031204

1205+
@lazy_property
1206+
def ais_story_data(self) -> Dict[int, AisStoryDatum]:
1207+
with self.dbmgr.session() as db:
1208+
return (
1209+
AisStoryDatum.query(db)
1210+
.to_dict(lambda x: x.sub_story_id, lambda x: x)
1211+
)
1212+
12041213
@lazy_property
12051214
def nyd_story_data(self) -> Dict[int, NydStoryDatum]:
12061215
with self.dbmgr.session() as db:

autopcr/model/handlers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,13 @@ async def update(self, mgr: datamgr, request):
710710
for reward in self.rewards:
711711
mgr.update_inventory(reward)
712712

713+
@handles
714+
class SubStoryAisReadStoryResponse(responses.SubStoryAisReadStoryResponse):
715+
async def update(self, mgr: datamgr, request):
716+
if self.reward_info:
717+
for reward in self.reward_info:
718+
mgr.update_inventory(reward)
719+
713720
@handles
714721
class SubStoryNydReadStoryResponse(responses.SubStoryNydReadStoryResponse):
715722
async def update(self, mgr: datamgr, request):

autopcr/module/modules/autosweep.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,19 @@ def get_max_times(self, client: pcrclient, quest_id: int) -> int:
219219
@conditional_not_execution("shiori_sweep_not_run_time", ["n3", 'n4及以上'])
220220
@conditional_execution1("shiori_sweep_run_time", ["无庆典"])
221221
@singlechoice('shiori_sweep_consider_unit_order', "刷取顺序", "缺口少优先", ["缺口少优先", "缺口大优先"])
222-
@description('根据记忆碎片缺口刷外传图,直到盈余超过阈值')
222+
@booltype('shiori_sweep_only_consider_limit_unit', "仅限定角色", True)
223+
@description('根据记忆碎片缺口刷外传图,直到盈余超过阈值,仅限定角色指只考虑活动赠送角色,不考虑常驻角色')
223224
@name('智能刷外传图')
224225
@default(False)
225226
@tag_stamina_consume
226227
class smart_shiori_sweep(simple_demand_sweep_base):
227228

228229
async def get_need_list(self, client: pcrclient) -> List[Tuple[ItemType, int]]:
229230
gap_limit = self.get_config('shiori_sweep_gap_limit')
231+
consider_limit = self.get_config('shiori_sweep_only_consider_limit_unit')
230232
need_list = client.data.get_memory_demand_gap()
233+
if consider_limit:
234+
need_list = {token: need for token, need in need_list.items() if db.unit_data[db.memory_to_unit[token[1]]].is_limited}
231235
need_list = [(token, need) for token, need in need_list.items() if need > -gap_limit]
232236
if not need_list:
233237
raise SkipError("所有记忆碎片均已盈余")

autopcr/module/modules/gacha.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ async def do_task(self, client: pcrclient):
6969
@description('有免费十连时自动抽取,附奖池自动选择缺口最多的碎片,多卡池可抽取则选择编号大的。卡池编号名字可于“危险”栏查看。智能pickup指当抽出pickup角色后自动切换未拥有的pickup角色,有多个则选角色编号大的。未选够pickup角色会自动选。')
7070
@name('免费十连')
7171
@booltype('today_end_gacha_no_do', "当日切卡池前不抽取", True)
72+
@booltype('free_gacha_start_auto_select_pickup_min_first', "PickUp编号小优先", False)
7273
@booltype('free_gacha_auto_select_pickup', "智能pickup", True)
7374
@multichoice('free_gacha_select_ids', "抽取卡池", db.free_gacha_ids_candidate, db.free_gacha_ids_candidate)
7475
@default(False)
@@ -79,6 +80,7 @@ async def do_task(self, client: pcrclient):
7980
raise SkipError("免费十连已结束")
8081
free_gacha_select_ids: List[str] = self.get_config("free_gacha_select_ids")
8182
free_gacha_auto_select_pickup: bool = self.get_config("free_gacha_auto_select_pickup")
83+
pickup_min_first: bool = self.get_config("free_gacha_start_auto_select_pickup_min_first")
8284
schedule = db.campaign_gacha[res.campaign_info.campaign_id]
8385
gacha_list = db.campaign_free_gacha_data[schedule.campaign_id]
8486
start_time = db.parse_time(schedule.start_time)
@@ -122,7 +124,7 @@ async def do_task(self, client: pcrclient):
122124
self._log(f"抽取卡池:{db.gacha_data[target_gacha.id].gacha_name}")
123125

124126
while cnt > 0:
125-
gacha_reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Campaign10Shot, cnt, res.campaign_info.campaign_id, free_gacha_auto_select_pickup)
127+
gacha_reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Campaign10Shot, cnt, res.campaign_info.campaign_id, free_gacha_auto_select_pickup, pickup_min_first)
126128
cnt -= 1
127129

128130
self._log(await client.serlize_gacha_reward(gacha_reward, target_gacha.id))

autopcr/module/modules/tools.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,12 @@ async def do_task(self, client: pcrclient):
246246
self._log(f"==常驻角色==" )
247247
self._log('\n'.join(db.get_unit_name(id) for id in resident_unit))
248248

249-
@description('警告!真抽!\n抽到出指NEW出保底角色,或达天井停下来,如果已有保底角色,就不会NEW!意味着就是一井!\n智能pickup指当前pickup角色为已拥有角色时会自动切换成未拥有的角色。\n附奖池自动选择缺口最多的碎片,pickup池未选满角色自动选择未拥有角色,有多个则按角色编号大到小选取\n先免费十连->限定十连券->钻石')
249+
@description('警告!真抽!\n抽到出指NEW出保底角色,或达天井停下来,如果已有保底角色,就不会NEW!意味着就是一井!\n智能pickup指当前pickup角色为已拥有角色时会自动切换成未拥有的角色。\n附奖池自动选择缺口最多的碎片,pickup池未选满角色自动选择未拥有角色,有多个则按角色编号大到小或小到大选取\n先免费十连->限定十连券->钻石')
250250
@name('抽卡')
251-
@booltype("single_ticket", "用单抽券", False)
251+
@singlechoice("gacha_method", "抽取方式", '十连', ['十连', '单抽', '单抽券'])
252252
@singlechoice("pool_id", "池子", "", db.get_cur_gacha)
253-
@booltype('gacha_start_auto_select_pickup', "智能pickup", True)
253+
@booltype('gacha_start_auto_select_pickup_min_first', "PickUp编号小优先", False)
254+
@booltype('gacha_start_auto_select_pickup', "智能PickUp", True)
254255
@booltype("cc_until_get", "抽到出", False)
255256
@default(True)
256257
class gacha_start(Module):
@@ -262,7 +263,8 @@ async def do_task(self, client: pcrclient):
262263
if ':' not in self.get_config('pool_id'):
263264
raise ValueError("配置格式不正确")
264265
gacha_id = int(self.get_config('pool_id').split(':')[0])
265-
single_ticket = self.get_config('single_ticket')
266+
gacha_method = self.get_config('gacha_method')
267+
pickup_min_first = self.get_config('gacha_start_auto_select_pickup_min_first')
266268
real_exchange_id = 0
267269
if gacha_id == 120001:
268270
if not client.data.return_fes_info_list or all(item.end_time <= client.time for item in client.data.return_fes_info_list):
@@ -287,26 +289,36 @@ async def do_task(self, client: pcrclient):
287289
gacha_start_auto_select_pickup: bool = self.get_config('gacha_start_auto_select_pickup')
288290
try:
289291
while True:
290-
if single_ticket:
291-
reward += await client.exec_gacha_aware(target_gacha, 1, eGachaDrawType.Ticket, client.data.get_inventory(db.gacha_single_ticket), 0)
292-
else:
292+
if gacha_method == '单抽券':
293+
reward += await client.exec_gacha_aware(target_gacha, 1, eGachaDrawType.Ticket, client.data.get_inventory(db.gacha_single_ticket), 0, gacha_start_auto_select_pickup, pickup_min_first)
294+
elif gacha_method == '单抽':
295+
reward += await client.exec_gacha_aware(target_gacha, 1, eGachaDrawType.Payment, client.data.jewel.free_jewel + client.data.jewel.jewel, 0, gacha_start_auto_select_pickup, pickup_min_first)
296+
elif gacha_method == '十连':
293297
if isinstance(resp, GachaIndexResponse) and resp.campaign_info and resp.campaign_info.fg10_exec_cnt and target_gacha.id in db.campaign_free_gacha_data[resp.campaign_info.campaign_id]:
294-
reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Campaign10Shot, cnt, resp.campaign_info.campaign_id, gacha_start_auto_select_pickup)
298+
reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Campaign10Shot, cnt, resp.campaign_info.campaign_id, gacha_start_auto_select_pickup, pickup_min_first)
295299
resp.campaign_info.campaign_id -= 1
296300
elif any(client.data.get_inventory(temp_ticket) > 0 for temp_ticket in temp_tickets):
297301
# find first ticket
298302
ticket = next((temp_ticket for temp_ticket in temp_tickets if client.data.get_inventory(temp_ticket)))
299303
num = client.data.get_inventory(ticket)
300-
reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Temp_Ticket_10, num, 0, gacha_start_auto_select_pickup)
304+
reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Temp_Ticket_10, num, 0, gacha_start_auto_select_pickup, pickup_min_first)
305+
elif any(client.data.get_inventory(gacha_ten_ticket) > 0 for gacha_ten_ticket in db.gacha_ten_tickets):
306+
ticket = next((gacha_ten_ticket for gacha_ten_ticket in db.gacha_ten_tickets if client.data.get_inventory(gacha_ten_ticket)))
307+
num = client.data.get_inventory(ticket)
308+
reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Ticket, num, 0, gacha_start_auto_select_pickup, pickup_min_first) # real ticket ?
301309
else:
302-
reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Payment, client.data.jewel.free_jewel + client.data.jewel.jewel, 0, gacha_start_auto_select_pickup)
310+
reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Payment, client.data.jewel.free_jewel + client.data.jewel.jewel, 0, gacha_start_auto_select_pickup, pickup_min_first)
311+
else:
312+
raise ValueError("未知的抽卡方式")
313+
303314
cnt += 1
304315
if not always or self.can_stop(reward.new_unit, db.gacha_exchange_chara[target_gacha.exchange_id if not real_exchange_id else real_exchange_id]):
305316
break
317+
306318
except:
307319
raise
308320
finally:
309-
self._log(f"抽取了{cnt}{'十连' if not single_ticket else '单抽'}")
321+
self._log(f"抽取了{cnt}{gacha_method}")
310322
self._log(await client.serlize_gacha_reward(reward, target_gacha.id))
311323
point = client.data.gacha_point[target_gacha.exchange_id].current_point if target_gacha.exchange_id in client.data.gacha_point else 0
312324
self._log(f"当前pt为{point}")

autopcr/util/substory.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ def GetSubStoryReader(sub_story_data: EventSubStory, client: pcrclient) -> Union
3535
return constructor[sub_story_data.event_id](client)
3636
return None
3737

38+
@EventId(10137)
39+
@EventId(10136)
40+
class ais_substory(SubStoryReader):
41+
42+
def title(self, sub_story_id: int) -> str:
43+
return db.ais_story_data[sub_story_id].title
44+
45+
async def read(self, sub_story_id: int):
46+
await self.client.read_ais_story(sub_story_id)
47+
3848
@EventId(10134)
3949
class nyd_substory(SubStoryReader):
4050

server.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
- {prefix}卡池 查看当前卡池
6262
- {prefix}编队 1 1 春妈 蝶妈 狗妈 水妈 礼妈 便捷设置编队
6363
- {prefix}免费十连 <卡池id> 卡池id来自【{prefix}卡池】
64-
- {prefix}来发十连 <卡池id> [抽到出] [单抽券] [开抽] 赛博抽卡,谨慎使用。卡池id来自【{prefix}卡池】,[抽到出]表示抽到出货或达天井,[单抽券]表示仅用厕纸,[开抽]表示确认抽卡。已有up也可再次触发。
64+
- {prefix}来发十连 <卡池id> [抽到出] [单抽券|单抽] [编号小优先] [开抽] 赛博抽卡,谨慎使用。卡池id来自【{prefix}卡池】,[抽到出]表示抽到出货或达天井,默认十连,[单抽券]表示仅用厕纸,[单抽]表示宝石单抽,[标号小优先]指智能pickup时优先选择编号小的角色,[开抽]表示确认抽卡。已有up也可再次触发。
6565
""".strip()
6666

6767
if address is None:
@@ -667,7 +667,9 @@ async def shilian(botev: BotEvent):
667667
cc_until_get = False
668668
pool_id = ""
669669
really_do = False
670-
ticket = False
670+
single_ticket = False
671+
single = False
672+
small_first = False
671673
msg = await botev.message()
672674
try:
673675
pool_id = msg[0]
@@ -686,7 +688,17 @@ async def shilian(botev: BotEvent):
686688
pass
687689

688690
try:
689-
ticket = is_args_exist(msg, '单抽券')
691+
single_ticket = is_args_exist(msg, '单抽券')
692+
except:
693+
pass
694+
695+
try:
696+
single = is_args_exist(msg, '单抽')
697+
except:
698+
pass
699+
700+
try:
701+
small_first = is_args_exist(msg, '编号小优先')
690702
except:
691703
pass
692704

@@ -697,19 +709,30 @@ async def shilian(botev: BotEvent):
697709

698710
pool_id = current_gacha[pool_id]
699711

712+
if single_ticket and single:
713+
await botev.finish("单抽券和单抽只能选一个")
714+
715+
gacha_method = "十连"
716+
if single_ticket:
717+
gacha_method = "单抽券"
718+
elif single:
719+
gacha_method = "单抽"
720+
700721
if not really_do:
701722
msg = f"卡池{pool_id}\n"
702723
if cc_until_get:
703724
msg += "抽到出\n"
704-
if ticket:
705-
msg += "单抽券\n"
725+
if small_first:
726+
msg += "编号小优先\n"
727+
msg += f"{gacha_method}\n"
706728
msg += "确认无误,消息末尾加上【开抽】即可开始抽卡"
707729
await botev.finish(msg)
708730

709731
config = {
710732
"pool_id": pool_id,
711733
"cc_until_get": cc_until_get,
712-
"single_ticket": ticket,
734+
"gacha_method": gacha_method,
735+
"gacha_start_auto_select_pickup_min_first": small_first,
713736
}
714737
return config
715738

0 commit comments

Comments
 (0)