This commit is contained in:
bridge
2025-09-02 00:50:29 +08:00
parent 3047de0367
commit d33586888c
4 changed files with 25 additions and 17 deletions

View File

@@ -33,7 +33,10 @@ def long_action(step_month: int):
"""
if self.start_monthstamp is None:
return False
return (self.world.month_stamp - self.start_monthstamp) >= self.step_month
# 修正逻辑:使用 >= step_month - 1 而不是 >= step_month
# 这样1个月的动作在第1个月完成时间差0 >= 010个月的动作在第10个月完成时间差9 >= 9
# 避免了原来多执行一个月的bug
return (self.world.month_stamp - self.start_monthstamp) >= self.step_month - 1
# 只添加 is_finished 方法
cls.is_finished = is_finished
@@ -241,9 +244,7 @@ class Breakthrough(DefineAction, ActualActionMixin):
"""
突破境界
"""
# assert self.avatar.cultivation_progress.can_break_through()
if not self.avatar.cultivation_progress.can_break_through():
print(f"警告,{self.avatar.name} 无法突破境界其level为 {self.avatar.cultivation_progress.level},无法突破")
assert self.avatar.cultivation_progress.can_break_through()
success_rate = self.calc_success_rate()
if random.random() < success_rate:
self.avatar.cultivation_progress.break_through()

View File

@@ -115,7 +115,7 @@ class CultivationProgress:
self.exp += exp_amount
# 检查是否可以升级
while self.can_level_up():
if self.is_level_up():
required_exp = self.get_exp_required()
self.exp -= required_exp
self.level += 1
@@ -140,12 +140,19 @@ class CultivationProgress:
"""
return self.level in level_to_break_through.keys()
def can_level_up(self) -> bool:
def can_cultivate(self) -> bool:
"""
检查是否可以升级
可以突破,说明到顶了,说明不能升级
检查是否可以修炼
可以突破,说明到顶了,说明不能修炼了,必须突破后才能正常修炼
"""
return not self.can_break_through()
def is_level_up(self) -> bool:
"""
检查是否可以进入下一级
"""
exp_required = self.get_exp_required()
return self.exp >= exp_required
def __str__(self) -> str:
return f"{self.realm.value}{self.stage.value}({self.level}级)。可以突破:{self.can_break_through()}"