完善物品描述
This commit is contained in:
@@ -20,6 +20,8 @@ from .combat_models import (
|
||||
ADVENTURE_SOUVENIRS,
|
||||
COMBAT_POTIONS,
|
||||
EQUIPMENT_REGISTRY,
|
||||
SKILL_REGISTRY,
|
||||
EquipmentDefinition,
|
||||
get_combat_db_models,
|
||||
)
|
||||
from .combat_service import CombatService, get_combat_service
|
||||
@@ -83,12 +85,14 @@ class WPSCombatBase(WPSAPI):
|
||||
|
||||
# 1. 注册所有装备
|
||||
for equipment in EQUIPMENT_REGISTRY.values():
|
||||
# 生成包含属性数值和技能信息的描述
|
||||
enhanced_description = self._generate_equipment_description(equipment)
|
||||
self._safe_register_item(
|
||||
backpack,
|
||||
equipment.item_id,
|
||||
equipment.name,
|
||||
equipment.tier,
|
||||
equipment.description,
|
||||
enhanced_description,
|
||||
)
|
||||
# 装备价格根据品质和属性计算
|
||||
price = self._calculate_equipment_price(equipment)
|
||||
@@ -184,6 +188,46 @@ class WPSCombatBase(WPSAPI):
|
||||
f"{ConsoleFrontColor.YELLOW}注册商店物品 {item_id} 时出错: {e}{ConsoleFrontColor.RESET}"
|
||||
)
|
||||
|
||||
def _generate_equipment_description(self, equipment:EquipmentDefinition) -> str:
|
||||
"""生成包含属性数值和技能信息的装备描述"""
|
||||
parts = []
|
||||
|
||||
# 基础描述
|
||||
if equipment.description:
|
||||
parts.append(equipment.description)
|
||||
|
||||
# 属性信息
|
||||
if equipment.attributes:
|
||||
attr_parts = []
|
||||
attr_names = {
|
||||
"HP": "生命值",
|
||||
"ATK": "攻击力",
|
||||
"DEF": "防御力",
|
||||
"SPD": "速度",
|
||||
"CRIT": "暴击率",
|
||||
"CRIT_DMG": "暴击伤害",
|
||||
}
|
||||
for attr_key, attr_value in sorted(equipment.attributes.items()):
|
||||
attr_name = attr_names.get(attr_key, attr_key)
|
||||
if attr_key in ["CRIT", "CRIT_DMG"]:
|
||||
attr_parts.append(f"{attr_name}+{attr_value}%")
|
||||
else:
|
||||
attr_parts.append(f"{attr_name}+{attr_value}")
|
||||
if attr_parts:
|
||||
parts.append(f"属性:{', '.join(attr_parts)}")
|
||||
|
||||
# 技能信息
|
||||
if equipment.skill_ids:
|
||||
skill_names = []
|
||||
for skill_id in equipment.skill_ids:
|
||||
skill = SKILL_REGISTRY.get(skill_id)
|
||||
if skill:
|
||||
skill_names.append(skill.name)
|
||||
if skill_names:
|
||||
parts.append(f"附带技能:{', '.join(skill_names)}")
|
||||
|
||||
return " | ".join(parts) if parts else equipment.description
|
||||
|
||||
def _calculate_equipment_price(self, equipment) -> int:
|
||||
"""根据装备品质和属性计算价格"""
|
||||
# 基础价格
|
||||
|
||||
Reference in New Issue
Block a user