From 9677055faafe42a73fb391054f29d97509e1a746 Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Mon, 19 Jan 2026 04:48:05 -0800 Subject: [PATCH] fix: use sect_id instead of sect in fortune technique filter (#55) PR #32 changed Technique.sect (str) to Technique.sect_id (int), but fortune.py was not updated. This caused AttributeError when fortune event triggered and tried to access t.sect. Error: 'Technique' object has no attribute 'sect' --- src/classes/fortune.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/classes/fortune.py b/src/classes/fortune.py index 282504d..943b0eb 100644 --- a/src/classes/fortune.py +++ b/src/classes/fortune.py @@ -280,12 +280,10 @@ def _get_fortune_technique_for_avatar(avatar: Avatar) -> Optional[Technique]: """ candidates: list[Technique] = [] - # 确定允许的宗门范围 - allowed_sects: set[Optional[str]] = {None, ""} + # 确定允许的宗门 ID 范围 + allowed_sect_ids: set[Optional[int]] = {None} if avatar.sect is not None: - sect_name = avatar.sect.name.strip() if avatar.sect.name else None - if sect_name: - allowed_sects.add(sect_name) + allowed_sect_ids.add(avatar.sect.id) # 筛选功法 for t in techniques_by_id.values(): @@ -294,8 +292,7 @@ def _get_fortune_technique_for_avatar(avatar: Avatar) -> Optional[Technique]: continue # 宗门限制:宗门弟子只能获得本宗门或无宗门的功法 - tech_sect = t.sect.strip() if t.sect else None - if tech_sect not in allowed_sects: + if t.sect_id not in allowed_sect_ids: continue # condition 检查