完善物品描述
This commit is contained in:
@@ -20,6 +20,8 @@ from .combat_models import (
|
|||||||
ADVENTURE_SOUVENIRS,
|
ADVENTURE_SOUVENIRS,
|
||||||
COMBAT_POTIONS,
|
COMBAT_POTIONS,
|
||||||
EQUIPMENT_REGISTRY,
|
EQUIPMENT_REGISTRY,
|
||||||
|
SKILL_REGISTRY,
|
||||||
|
EquipmentDefinition,
|
||||||
get_combat_db_models,
|
get_combat_db_models,
|
||||||
)
|
)
|
||||||
from .combat_service import CombatService, get_combat_service
|
from .combat_service import CombatService, get_combat_service
|
||||||
@@ -83,12 +85,14 @@ class WPSCombatBase(WPSAPI):
|
|||||||
|
|
||||||
# 1. 注册所有装备
|
# 1. 注册所有装备
|
||||||
for equipment in EQUIPMENT_REGISTRY.values():
|
for equipment in EQUIPMENT_REGISTRY.values():
|
||||||
|
# 生成包含属性数值和技能信息的描述
|
||||||
|
enhanced_description = self._generate_equipment_description(equipment)
|
||||||
self._safe_register_item(
|
self._safe_register_item(
|
||||||
backpack,
|
backpack,
|
||||||
equipment.item_id,
|
equipment.item_id,
|
||||||
equipment.name,
|
equipment.name,
|
||||||
equipment.tier,
|
equipment.tier,
|
||||||
equipment.description,
|
enhanced_description,
|
||||||
)
|
)
|
||||||
# 装备价格根据品质和属性计算
|
# 装备价格根据品质和属性计算
|
||||||
price = self._calculate_equipment_price(equipment)
|
price = self._calculate_equipment_price(equipment)
|
||||||
@@ -184,6 +188,46 @@ class WPSCombatBase(WPSAPI):
|
|||||||
f"{ConsoleFrontColor.YELLOW}注册商店物品 {item_id} 时出错: {e}{ConsoleFrontColor.RESET}"
|
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:
|
def _calculate_equipment_price(self, equipment) -> int:
|
||||||
"""根据装备品质和属性计算价格"""
|
"""根据装备品质和属性计算价格"""
|
||||||
# 基础价格
|
# 基础价格
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class WPSGardenBase(WPSAPI):
|
|||||||
if crop.wine_item_id and crop.wine_tier:
|
if crop.wine_item_id and crop.wine_tier:
|
||||||
wine_tier = getattr(BackpackItemTier, crop.wine_tier.upper(), BackpackItemTier.RARE)
|
wine_tier = getattr(BackpackItemTier, crop.wine_tier.upper(), BackpackItemTier.RARE)
|
||||||
wine_name = f"{crop.display_name}的果酒"
|
wine_name = f"{crop.display_name}的果酒"
|
||||||
wine_desc = f"{crop.display_name}酿制的果酒,饮用后可触发战斗增益。"
|
wine_desc = self._generate_wine_description(crop.display_name, crop.wine_item_id)
|
||||||
self._safe_register_item(
|
self._safe_register_item(
|
||||||
backpack,
|
backpack,
|
||||||
crop.wine_item_id,
|
crop.wine_item_id,
|
||||||
@@ -175,6 +175,38 @@ class WPSGardenBase(WPSAPI):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _generate_wine_description(self, crop_name: str, wine_item_id: str) -> str:
|
||||||
|
"""生成包含buff加成信息的果酒描述"""
|
||||||
|
# 尝试导入战斗系统的WINE_BUFFS(可选依赖)
|
||||||
|
try:
|
||||||
|
from Plugins.WPSCombatSystem.combat_models import WINE_BUFFS
|
||||||
|
buffs = WINE_BUFFS.get(wine_item_id, {})
|
||||||
|
except ImportError:
|
||||||
|
buffs = {}
|
||||||
|
|
||||||
|
parts = [f"{crop_name}酿制的果酒,饮用后可触发战斗增益。"]
|
||||||
|
|
||||||
|
if buffs:
|
||||||
|
buff_parts = []
|
||||||
|
buff_names = {
|
||||||
|
"time_reduction": "冒险时间",
|
||||||
|
"reward_boost": "冒险收益",
|
||||||
|
"success_rate": "冒险成功率",
|
||||||
|
"atk_boost": "攻击力",
|
||||||
|
"def_boost": "防御力",
|
||||||
|
"crit_boost": "暴击率",
|
||||||
|
}
|
||||||
|
for buff_key, buff_value in sorted(buffs.items()):
|
||||||
|
buff_name = buff_names.get(buff_key, buff_key)
|
||||||
|
if buff_key == "time_reduction":
|
||||||
|
buff_parts.append(f"{buff_name}-{buff_value*100:.0f}%")
|
||||||
|
else:
|
||||||
|
buff_parts.append(f"{buff_name}+{buff_value*100:.0f}%")
|
||||||
|
if buff_parts:
|
||||||
|
parts.append(f"效果:{', '.join(buff_parts)}")
|
||||||
|
|
||||||
|
return " | ".join(parts)
|
||||||
|
|
||||||
def _safe_register_recipe(
|
def _safe_register_recipe(
|
||||||
self,
|
self,
|
||||||
alchemy: WPSAlchemyGame,
|
alchemy: WPSAlchemyGame,
|
||||||
|
|||||||
Reference in New Issue
Block a user