fix: use str() instead of .value for realm i18n display (#98)
* fix: use str() instead of .value for realm i18n display Fix bug where user-facing messages displayed raw enum values like "FOUNDATION_ESTABLISHMENT" instead of translated names like "筑基". The Realm and Stage classes already have __str__ methods that return i18n translated text, but several places were incorrectly using .value which returns the raw enum string. Changed files: - src/classes/single_choice.py: item exchange messages - src/classes/kill_and_grab.py: loot messages - src/classes/fortune.py: fortune discovery messages - src/classes/avatar/inventory_mixin.py: purchase error messages Also added unit tests and integration tests to prevent regression. * test: add integration tests for all modified files Add tests covering: - kill_and_grab.py: context string realm display - fortune.py: weapon/auxiliary intro realm display - inventory_mixin.py: can_buy_item error message realm display
This commit is contained in:
@@ -190,7 +190,8 @@ class InventoryMixin:
|
||||
if isinstance(obj, Elixir):
|
||||
# 境界限制
|
||||
if obj.realm > self.cultivation_progress.realm:
|
||||
return False, f"境界不足,无法承受药力 ({obj.realm.value})"
|
||||
# 使用 str() 来触发 Realm 的 __str__ 方法进行 i18n 翻译。
|
||||
return False, f"境界不足,无法承受药力 ({str(obj.realm)})"
|
||||
|
||||
# 耐药性/生效中检查
|
||||
for consumed in self.elixirs:
|
||||
|
||||
Reference in New Issue
Block a user