add battle to death

This commit is contained in:
bridge
2025-11-26 19:00:07 +08:00
parent 6227ebd0e8
commit 7980fc0705
3 changed files with 53 additions and 16 deletions

16
src/classes/death.py Normal file
View File

@@ -0,0 +1,16 @@
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from src.classes.world import World
from src.classes.avatar import Avatar
def handle_death(world: World, avatar: Avatar) -> None:
"""
处理角色死亡的统一入口。
负责将角色从世界管理器中移除,并处理相关的清理工作(如关系解除已在 remove_avatar 中实现)。
注意:本函数不负责生成死亡事件文本,调用者应在调用前生成相应的 Event。
"""
# 从管理器中移除角色remove_avatar 内部会自动清理双向关系)
world.avatar_manager.remove_avatar(avatar.id)