Skip to content

Commit 02cd580

Browse files
authored
Merge pull request #230 from lclbm/feat/unit-promote-to-max-level
feat: unit promote to max level when no exceed
2 parents 65e23fb + 51b7bd5 commit 02cd580

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

autopcr/module/modules/unit.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class UnitController(Module):
2020
auto_level_up : bool = True
2121
auto_rank_up : bool = True
2222
auto_unique1_slot: bool = True
23+
to_max_level: bool = True
2324
use_raw_ore : bool = True
2425

2526
skill_name = {
@@ -178,11 +179,18 @@ async def unit_level_up(self, target_level: int, free: bool):
178179
await self.client.unit_level_up(self.unit.id, cost_potion)
179180

180181
async def unit_level_up_aware(self, target_level: int, limit: Union[GrowthParameter, None] = None):
182+
level_limit = self.client.data.team_level + (10 if self.unit.exceed_stage else 0)
183+
if self.to_max_level:
184+
target_level = min(target_level, level_limit)
185+
if self.unit.unit_level >= level_limit:
186+
raise AbortError(f"{self.unit_name}未突破,已达当前可提升的最高等级{level_limit}")
187+
if target_level > level_limit:
188+
self._log(f"{self.unit_name}未突破,将升级至最高允许的等级{level_limit}")
189+
181190
if limit and target_level > limit.unit_level and self.unit.unit_level < limit.unit_level:
182191
self._log(f"{self.unit_name}目标等级{target_level}超过了免费可提升等级{limit.unit_level},先提升至等级{limit.unit_level}")
183192
await self.unit_level_up_aware(limit.unit_level, limit)
184193

185-
level_limit = self.client.data.team_level + (10 if self.unit.exceed_stage else 0)
186194
if target_level > level_limit:
187195
raise AbortError(f"{self.unit_name}目标等级{target_level}超过了可提升的最高等级{level_limit},无法升级")
188196

@@ -742,8 +750,10 @@ async def do_task(self, client: pcrclient):
742750
self.unit_id = int(unit_id)
743751
await self.set_unique_growth_unit()
744752

745-
@description('支持全部角色,装备星级-1表示不穿装备,自动拉等级指当前等级不足以穿装备或提升技能等级,将会提升角色等级,自动拉品级指当前品级不足以装备专武时,会提升角色品级,自动专武1指开专武2未开专武1时自动开专武1,使用原矿指装备不足时用原矿补充')
753+
@description('支持全部角色,装备星级-1表示不穿装备,自动拉等级指当前等级不足以穿装备或提升技能等级,将会提升角色等级,自动拉品级指当前品级不足以装备专武时,会提升角色品级,自动专武1指开专武2未开专武1时自动开专武1,使用原矿指装备不足时用原矿补充'
754+
'\n等级升至上限:在当前升级条件下,升级至角色允许的等级上限(比如未突破角色升级至突破后等级,开启该选项可以升级至最大的未突破等级,避免升级失败)')
746755
@name('拉角色练度')
756+
@booltype("unit_promote_to_max_level", "等级升至上限", False)
747757
@booltype("unit_promote_unique2_when_fail_to_unique_equip2", "自动专武1", False)
748758
@booltype("unit_promote_rank_when_fail_to_unique_equip", "自动拉品级", False)
749759
@booltype("unit_promote_level_when_fail_to_equip_or_skill", "自动拉等级", False)
@@ -774,6 +784,7 @@ async def do_task(self, client: pcrclient):
774784
self.auto_rank_up = bool(self.get_config('unit_promote_rank_when_fail_to_unique_equip'))
775785
self.use_raw_ore = bool(self.get_config('unit_promote_rank_use_raw_ore'))
776786
self.auto_unique1_slot = bool(self.get_config('unit_promote_unique2_when_fail_to_unique_equip2'))
787+
self.to_max_level = bool(self.get_config('unit_promote_to_max_level'))
777788

778789
target_level = int(self.get_config('unit_promote_level'))
779790
target_promotion_rank = int(self.get_config('unit_promote_rank'))

0 commit comments

Comments
 (0)