add hp self recover

This commit is contained in:
bridge
2025-10-15 23:37:05 +08:00
parent 837cb539fc
commit 60ed606f8c
2 changed files with 24 additions and 2 deletions

View File

@@ -561,6 +561,15 @@ class Avatar:
sect_str = other_avatar.sect.name if other_avatar.sect is not None else "散修"
return f"{other_avatar.name},境界:{other_avatar.cultivation_progress.get_info()},关系:{relation_str},阵营:{other_avatar.alignment},宗门:{sect_str},外貌:{other_avatar.appearance.get_info()}"
def update_time_effect(self) -> None:
"""
随时间更新的被动效果。
当前实现:当 HP 未满时,回复最大生命值的 1%
"""
if self.hp.cur < self.hp.max:
recover_amount = int(self.hp.max * 0.01)
self.hp.recover(recover_amount)
@property
def move_step_length(self) -> int:
"""

View File

@@ -108,6 +108,15 @@ class Simulator:
events.append(event)
return events
def _phase_update_time_effect(self):
"""
更新时间效果如HP回复
"""
events = []
for avatar in self.world.avatar_manager.avatars.values():
avatar.update_time_effect()
return events
def _phase_log_events(self, events):
"""
将事件写入日志。
@@ -142,10 +151,14 @@ class Simulator:
# 5. 年龄与新生
events.extend(self._phase_update_age_and_birth())
# 6. 日志
# 6. 时间效果如HP回复
events.extend(self._phase_update_time_effect())
# 7. 日志
self._phase_log_events(events)
# 7. 时间推进
# 8. 时间推进
self.world.month_stamp = self.world.month_stamp + 1
return events