Skip to content

Commit

Permalink
Merge pull request cc004#139 from cc004/fix
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
Lanly109 authored Sep 2, 2024
2 parents a02ee8f + 3ceddc0 commit 96ce4b3
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 16 deletions.
4 changes: 2 additions & 2 deletions autopcr/core/pcrclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,14 @@ async def receive_all(self):
req.type = 1
await self.request(req)

async def serlize_gacha_reward(self, gacha: GachaReward):
async def serlize_gacha_reward(self, gacha: GachaReward, gacha_id: int = 0):
res = ""
if gacha.new_unit:
res += f"NEW: \n" + '\n'.join([db.get_inventory_name(item) for item in gacha.new_unit]) + '\n'
if gacha.unit_rarity:
res += ' '.join(["★"*i + f"x{cnt}" for i, cnt in gacha.unit_rarity.items()]) + '\n'
if gacha.prize_rarity:
res += ' '.join([f"{i}" + f"x{cnt}" for i, cnt in gacha.prize_rarity.items()]) + '\n'
res += ' '.join([f"{db.get_gacha_prize_name(gacha_id, i)}" + f"x{cnt}" for i, cnt in gacha.prize_rarity.items()]) + '\n'

res += await self.serlize_reward(gacha.reward_list)

Expand Down
20 changes: 19 additions & 1 deletion autopcr/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,18 @@ def update(self, dbmgr: dbmgr):
PrizegachaDatum.query(db)
.to_dict(lambda x: x.prizegacha_id, lambda x: x)
)


self.prizegacha_sp_data: Dict[int, Dict[int, PrizegachaSpDatum]] = (
PrizegachaSpDatum.query(db)
.group_by(lambda x: x.gacha_id)
.to_dict(lambda x: x.key, lambda x: x.to_dict(lambda x: x.rarity, lambda x: x))
)

self.prizegacha_sp_detail: Dict[int, PrizegachaSpDetail] = (
PrizegachaSpDetail.query(db)
.to_dict(lambda x: x.disp_rarity, lambda x: x)
)

self.campaign_gacha: Dict[int, CampaignFreegacha] = (
CampaignFreegacha.query(db)
.to_dict(lambda x: x.campaign_id, lambda x: x)
Expand Down Expand Up @@ -1023,4 +1034,11 @@ def last_normal_quest_candidate(self):
.select(lambda x: f"{x.quest_id}: {x.quest_name.split(' ')[1]}") \
.to_list()

def get_gacha_prize_name(self, gacha_id: int, prize_rarity: int) -> str:
if gacha_id in self.prizegacha_sp_data:
prize_rarity = self.prizegacha_sp_data[gacha_id][prize_rarity].disp_rarity
if prize_rarity in self.prizegacha_sp_detail:
return self.prizegacha_sp_detail[prize_rarity].name
return f"{prize_rarity}等奖"

db = database()
1 change: 1 addition & 0 deletions autopcr/module/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
tool_modules = [
# cook_pudding,
unit_promote,
missing_unit,
get_need_equip,
get_normal_quest_recommand,
get_need_memory,
Expand Down
10 changes: 5 additions & 5 deletions autopcr/module/modules/autosweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_max_times(self, client: pcrclient, quest_id: int) -> int:
return 5

unique_equip_2_pure_memory_id = [
(32025, 1), # 水女仆
(32025, 2), # 水女仆,女仆
(32046, 1), # 水猫剑
(32048, 1), # 水子龙
(32060, 1), # 黑猫
Expand Down Expand Up @@ -356,8 +356,8 @@ async def get_start_quest(self, client: pcrclient) -> List[Tuple[int, int]]:
if is_start_run_time:
self._log(f"刷取start关卡")
for tab in client.data.user_my_quest:
for x in tab.skip_list:
if tab.tab_name == 'start':
if tab.tab_name == 'start':
for x in tab.skip_list:
quest.append((x, tab.skip_count))
return quest

Expand All @@ -367,8 +367,8 @@ async def get_loop_quest(self, client: pcrclient) -> List[Tuple[int, int]]:
if is_loop_run_time:
self._log(f"刷取loop关卡")
for tab in client.data.user_my_quest:
for x in tab.skip_list:
if tab.tab_name == 'loop':
if tab.tab_name == 'loop':
for x in tab.skip_list:
quest.append((x, tab.skip_count))
return quest

Expand Down
4 changes: 2 additions & 2 deletions autopcr/module/modules/gacha.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def do_task(self, client: pcrclient):
self._log("使用十连")
gacha_reward += await client.exec_gacha_aware(gacha, 10, eGachaDrawType.Monthly_Free_Multi, 1, 0)

reward = await client.serlize_gacha_reward(gacha_reward)
reward = await client.serlize_gacha_reward(gacha_reward, gacha.id)
if reward != "无":
self._log(reward)
point = client.data.gacha_point[gacha.exchange_id].current_point if gacha.exchange_id in client.data.gacha_point else 0
Expand Down Expand Up @@ -115,4 +115,4 @@ async def do_task(self, client: pcrclient):
gacha_reward += await client.exec_gacha_aware(target_gacha, 10, eGachaDrawType.Campaign10Shot, cnt, res.campaign_info.campaign_id)
cnt -= 1

self._log(await client.serlize_gacha_reward(gacha_reward))
self._log(await client.serlize_gacha_reward(gacha_reward, target_gacha.id))
2 changes: 1 addition & 1 deletion autopcr/module/modules/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def buy_kind(self) -> List[str]: return self.get_config('normal_shop_buy_kind')
@default(False)
class limit_shop(shop_buyer):
def _exp_count(self): return 999000 if "经验药水" in self.get_config('limit_shop_buy_kind') else 0
def _equip_count(self): return 999000 if "装备" in self.get_config('limit_shop_buy_kind') else 0
def _equip_count(self): return 999000 if "装备" in self.get_config('limit_shop_buy_kind') else -999000
def coin_limit(self) -> int: return self.get_config('limit_shop_buy_coin_limit')
def system_id(self) -> eSystemId: return eSystemId.LIMITED_SHOP
def reset_count(self) -> int: return 0
Expand Down
29 changes: 24 additions & 5 deletions autopcr/module/modules/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,27 @@ async def read_drama(psy_top_resp: PsyTopResponse):
if is_abort: raise AbortError("")
if is_skip: raise SkipError("")


@description('来进行赛博抽卡')
@description('看看你缺了什么角色')
@name('查缺角色')
@default(True)
class missing_unit(Module):
async def do_task(self, client: pcrclient):
missing_unit = set(db.unlock_unit_condition.keys()) - set(client.data.unit.keys())
if not missing_unit:
self._log("全图鉴玩家!你竟然没有缺少的角色!")
else:
limit_unit = set(id for id in missing_unit if db.unit_data[id].is_limited)
resident_unit = missing_unit - limit_unit
self._log(f"缺少{len(missing_unit)}个角色,其中{len(limit_unit)}个限定角色,{len(resident_unit)}个常驻角色")
if limit_unit:
self._log(f"==限定角色==" )
self._log('\n'.join(db.get_unit_name(id) for id in limit_unit))
self._log('')
if resident_unit:
self._log(f"==常驻角色==" )
self._log('\n'.join(db.get_unit_name(id) for id in resident_unit))

@description('警告!真抽!抽到出指NEW出保底角色,或达天井停下来,如果已有保底角色,就不会NEW!意味着就是一井!')
@name('抽卡')
@booltype("single_ticket", "用单抽券", False)
@singlechoice("pool_id", "池子", "", db.get_cur_gacha)
Expand Down Expand Up @@ -136,7 +155,7 @@ async def do_task(self, client: pcrclient):
raise
finally:
self._log(f"抽取了{cnt}{'十连' if not single_ticket else '单抽'}")
self._log(await client.serlize_gacha_reward(reward))
self._log(await client.serlize_gacha_reward(reward, target_gacha.id))
point = client.data.gacha_point[target_gacha.exchange_id].current_point if target_gacha.exchange_id in client.data.gacha_point else 0
self._log(f"当前pt为{point}")

Expand Down Expand Up @@ -311,7 +330,7 @@ async def update_deck(self, units: ArenaQueryResult, client: pcrclient):

under_rank_bonus_unit = [unit for unit in units_id if client.data.unit[unit].promotion_level < db.equip_max_rank - 1]
if under_rank_bonus_unit:
self._warn(f"警告{'|'.join([db.get_unit_name(unit_id) for unit_id in under_rank_bonus_unit])}无品级加成")
self._warn(f"无品级加成{''.join([db.get_unit_name(unit_id) for unit_id in under_rank_bonus_unit])}")

await client.deck_update(ePartyType.ARENA, units_id)

Expand Down Expand Up @@ -387,7 +406,7 @@ async def update_deck(self, units: List[ArenaQueryResult], client: pcrclient):
under_rank_bonus_unit = [uni_id for unit_id in units_id for uni_id in unit_id if
client.data.unit[uni_id].promotion_level < db.equip_max_rank - 1]
if under_rank_bonus_unit:
self._warn(f"警告{'|'.join([db.get_unit_name(unit_id) for unit_id in under_rank_bonus_unit])}无品级加成")
self._warn(f"无品级加成{''.join([db.get_unit_name(unit_id) for unit_id in under_rank_bonus_unit])}")

deck_list = []
for i, unit_id in enumerate(units_id):
Expand Down
3 changes: 3 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,9 @@ async def quest_recommand(botev: BotEvent):
}
return config

@register_tool("查缺角色", "missing_unit")
async def find_missing_unit(botev: BotEvent):
return {}

# @register_tool("获取导入", "get_library_import_data")
# async def get_library_import(botev: BotEvent):
Expand Down

0 comments on commit 96ce4b3

Please sign in to comment.