update
This commit is contained in:
@@ -4,6 +4,7 @@ import random
|
||||
from src.classes.action import DefineAction, ActualActionMixin
|
||||
from src.classes.event import Event
|
||||
from src.classes.region import Region, resolve_region
|
||||
from src.classes.sect_region import SectRegion
|
||||
from src.classes.action import Move
|
||||
from src.classes.action_runtime import ActionResult, ActionStatus
|
||||
from src.classes.action.move_helper import clamp_manhattan_with_diagonal_priority
|
||||
@@ -60,7 +61,13 @@ class MoveToRegion(DefineAction, ActualActionMixin):
|
||||
if region is None:
|
||||
return False, "缺少参数 region"
|
||||
try:
|
||||
resolve_region(self.world, region)
|
||||
r = resolve_region(self.world, region)
|
||||
|
||||
# 宗门总部限制:非本门弟子禁止入内
|
||||
if isinstance(r, SectRegion):
|
||||
if self.avatar.sect is None or self.avatar.sect.id != r.sect_id:
|
||||
return False, f"【{r.name}】是其他宗门驻地,你并非该宗门弟子。"
|
||||
|
||||
return True, ""
|
||||
except Exception:
|
||||
return False, f"无法解析区域: {region}"
|
||||
|
||||
@@ -264,6 +264,15 @@ class Avatar(
|
||||
|
||||
# ========== 魔法方法 ==========
|
||||
|
||||
@property
|
||||
def current_action_name(self) -> str:
|
||||
"""获取当前动作名称,默认返回'思考'"""
|
||||
if self.current_action and self.current_action.action:
|
||||
action = self.current_action.action
|
||||
# 优先取 ACTION_NAME (中文名),如果没有则使用类名
|
||||
return getattr(action, "ACTION_NAME", getattr(action, "name", "思考"))
|
||||
return "思考"
|
||||
|
||||
def __post_init__(self):
|
||||
"""在Avatar创建后自动初始化tile和HP"""
|
||||
self.tile = self.world.map.get_tile(self.pos_x, self.pos_y)
|
||||
|
||||
@@ -127,7 +127,7 @@ def get_avatar_structured_info(avatar: "Avatar") -> dict:
|
||||
"nickname_reason": avatar.nickname.reason if avatar.nickname else None,
|
||||
"is_dead": avatar.is_dead,
|
||||
"death_info": avatar.death_info,
|
||||
"action_state": f"正在{getattr(avatar.current_action.action, 'ACTION_NAME', '思考')}" if hasattr(avatar, "current_action") and avatar.current_action and getattr(avatar.current_action, "action", None) else "思考"
|
||||
"action_state": f"正在{avatar.current_action_name}"
|
||||
}
|
||||
|
||||
# 1. 特质 (Personas)
|
||||
@@ -265,7 +265,7 @@ def get_avatar_hover_info(avatar: "Avatar") -> list[str]:
|
||||
|
||||
# 思考与目标
|
||||
if avatar.thinking:
|
||||
add_section(lines, "思考", [avatar.thinking])
|
||||
add_section(lines, "正在思考", [avatar.thinking])
|
||||
if avatar.long_term_objective:
|
||||
add_section(lines, "长期目标", [avatar.long_term_objective.content])
|
||||
if avatar.short_term_objective:
|
||||
|
||||
@@ -8,7 +8,6 @@ from src.utils.config import CONFIG
|
||||
from src.classes.avatar import Avatar
|
||||
from src.classes.event import Event
|
||||
from src.classes.story_teller import StoryTeller
|
||||
from src.classes.fortune import get_cultivation_exp_reward
|
||||
|
||||
class MisfortuneKind(Enum):
|
||||
"""霉运类型"""
|
||||
@@ -136,7 +135,7 @@ async def try_trigger_misfortune(avatar: Avatar) -> list[Event]:
|
||||
|
||||
# 生成故事
|
||||
event_text = f"遭遇霉运({theme}),{res_text}"
|
||||
story_prompt = "请据此写100~300字小故事。只描述倒霉事件本身,不要描述角色的心理活动或者愈挫愈勇。"
|
||||
story_prompt = "请据此写100~300字小故事。只描述倒霉事件本身,不要描述角色的心理活动或者愈挫愈勇,不要有数值。"
|
||||
|
||||
month_at_finish = avatar.world.month_stamp
|
||||
base_event = Event(month_at_finish, event_text, related_avatars=[avatar.id], is_major=True)
|
||||
|
||||
@@ -395,7 +395,7 @@ async def game_loop():
|
||||
"y": int(getattr(a, "pos_y", 0)),
|
||||
"gender": a.gender.value,
|
||||
"pic_id": resolve_avatar_pic_id(a),
|
||||
"action": getattr(a, "current_action", {}).get("name", "思考") if hasattr(a, "current_action") and a.current_action else "思考",
|
||||
"action": a.current_action_name,
|
||||
"action_emoji": resolve_avatar_action_emoji(a),
|
||||
"is_dead": False
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ from src.classes.world import World
|
||||
from src.classes.avatar import Avatar, Gender
|
||||
from src.classes.appearance import get_appearance_by_level
|
||||
from src.classes.calendar import MonthStamp
|
||||
from src.classes.region import Region, resolve_region
|
||||
from src.classes.cultivation import CultivationProgress
|
||||
from src.classes.root import Root
|
||||
from src.classes.age import Age
|
||||
@@ -455,6 +456,11 @@ class AvatarFactory:
|
||||
# 自己.relations[师傅] = MASTER (自己认为师傅是师傅)
|
||||
plan.master_avatar.set_relation(avatar, Relation.APPRENTICE)
|
||||
|
||||
# 宗门弟子天生知道宗门总部位置
|
||||
if avatar.sect is not None:
|
||||
hq_region = resolve_region(world, avatar.sect.headquarter.name)
|
||||
avatar.known_regions.add(hq_region.id)
|
||||
|
||||
if avatar.technique is not None:
|
||||
mapped = attribute_to_root(avatar.technique.attribute)
|
||||
if mapped is not None:
|
||||
|
||||
Reference in New Issue
Block a user