|
|
@@ -0,0 +1,150 @@
|
|
|
+#!/usr/bin/env python3
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+"""
|
|
|
+武器伤害配置测试脚本
|
|
|
+用于验证手动配置的武器伤害值是否正确加载
|
|
|
+"""
|
|
|
+
|
|
|
+import json
|
|
|
+import os
|
|
|
+from pathlib import Path
|
|
|
+
|
|
|
+def test_weapon_damage_config():
|
|
|
+ """测试武器伤害配置"""
|
|
|
+ # 获取weapons.json文件路径
|
|
|
+ weapons_json_path = Path("assets/resources/data/weapons.json")
|
|
|
+
|
|
|
+ if not weapons_json_path.exists():
|
|
|
+ print(f"错误: 找不到武器配置文件 {weapons_json_path}")
|
|
|
+ return False
|
|
|
+
|
|
|
+ try:
|
|
|
+ # 读取武器配置
|
|
|
+ with open(weapons_json_path, 'r', encoding='utf-8') as f:
|
|
|
+ weapons_config = json.load(f)
|
|
|
+
|
|
|
+ print("=== 武器伤害配置测试 ===")
|
|
|
+ print(f"总共加载了 {len(weapons_config['weapons'])} 个武器")
|
|
|
+ print()
|
|
|
+
|
|
|
+ # 检查每个武器的升级配置
|
|
|
+ for weapon in weapons_config['weapons']:
|
|
|
+ weapon_id = weapon['id']
|
|
|
+ weapon_name = weapon['name']
|
|
|
+ base_damage = weapon['stats']['damage']
|
|
|
+
|
|
|
+ print(f"武器: {weapon_name} ({weapon_id})")
|
|
|
+ print(f" 基础伤害: {base_damage}")
|
|
|
+
|
|
|
+ if 'upgradeConfig' in weapon and 'levels' in weapon['upgradeConfig']:
|
|
|
+ levels = weapon['upgradeConfig']['levels']
|
|
|
+ print(f" 升级配置: {len(levels)} 个等级")
|
|
|
+
|
|
|
+ # 检查每个等级的配置
|
|
|
+ for level_str, level_config in levels.items():
|
|
|
+ level = int(level_str)
|
|
|
+ cost = level_config.get('cost', 'N/A')
|
|
|
+ damage = level_config.get('damage', 'N/A')
|
|
|
+
|
|
|
+ if damage != 'N/A':
|
|
|
+ print(f" 等级 {level}: 费用={cost}, 伤害={damage}")
|
|
|
+ else:
|
|
|
+ print(f" 等级 {level}: 费用={cost}, 伤害=未配置")
|
|
|
+ else:
|
|
|
+ print(" ❌ 没有升级配置")
|
|
|
+
|
|
|
+ print()
|
|
|
+
|
|
|
+ # 统计配置完整性
|
|
|
+ weapons_with_damage = 0
|
|
|
+ total_weapons = len(weapons_config['weapons'])
|
|
|
+
|
|
|
+ for weapon in weapons_config['weapons']:
|
|
|
+ if 'upgradeConfig' in weapon and 'levels' in weapon['upgradeConfig']:
|
|
|
+ levels = weapon['upgradeConfig']['levels']
|
|
|
+ has_damage_config = any('damage' in level_config for level_config in levels.values())
|
|
|
+ if has_damage_config:
|
|
|
+ weapons_with_damage += 1
|
|
|
+
|
|
|
+ print("=== 配置统计 ===")
|
|
|
+ print(f"总武器数量: {total_weapons}")
|
|
|
+ print(f"已配置手动伤害的武器: {weapons_with_damage}")
|
|
|
+ print(f"配置完成度: {weapons_with_damage/total_weapons*100:.1f}%")
|
|
|
+
|
|
|
+ if weapons_with_damage == total_weapons:
|
|
|
+ print("✅ 所有武器都已配置手动伤害值")
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ print(f"⚠️ 还有 {total_weapons - weapons_with_damage} 个武器未配置手动伤害值")
|
|
|
+ return False
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ print(f"错误: 读取武器配置失败 - {e}")
|
|
|
+ return False
|
|
|
+
|
|
|
+def simulate_damage_calculation():
|
|
|
+ """模拟伤害计算逻辑"""
|
|
|
+ weapons_json_path = Path("assets/resources/data/weapons.json")
|
|
|
+
|
|
|
+ if not weapons_json_path.exists():
|
|
|
+ print("错误: 找不到武器配置文件")
|
|
|
+ return
|
|
|
+
|
|
|
+ try:
|
|
|
+ with open(weapons_json_path, 'r', encoding='utf-8') as f:
|
|
|
+ weapons_config = json.load(f)
|
|
|
+
|
|
|
+ print("\n=== 伤害计算模拟 ===")
|
|
|
+
|
|
|
+ # 模拟calculateWeaponDamage函数的逻辑
|
|
|
+ for weapon in weapons_config['weapons'][:3]: # 只测试前3个武器
|
|
|
+ weapon_id = weapon['id']
|
|
|
+ weapon_name = weapon['name']
|
|
|
+ base_damage = weapon['stats']['damage']
|
|
|
+
|
|
|
+ print(f"\n武器: {weapon_name} ({weapon_id})")
|
|
|
+ print(f"基础伤害: {base_damage}")
|
|
|
+
|
|
|
+ if 'upgradeConfig' in weapon and 'levels' in weapon['upgradeConfig']:
|
|
|
+ levels = weapon['upgradeConfig']['levels']
|
|
|
+
|
|
|
+ for level in range(1, 6): # 测试1-5级
|
|
|
+ level_str = str(level)
|
|
|
+ if level_str in levels and 'damage' in levels[level_str]:
|
|
|
+ # 使用手动配置的伤害值
|
|
|
+ damage = levels[level_str]['damage']
|
|
|
+ print(f" 等级 {level}: {damage} (手动配置)")
|
|
|
+ else:
|
|
|
+ # 使用自动计算的伤害值(作为对比)
|
|
|
+ rarity = weapon.get('rarity', 'common')
|
|
|
+ damage_per_level_map = {
|
|
|
+ 'common': int(base_damage * 0.15),
|
|
|
+ 'uncommon': int(base_damage * 0.18),
|
|
|
+ 'rare': int(base_damage * 0.20),
|
|
|
+ 'epic': int(base_damage * 0.25)
|
|
|
+ }
|
|
|
+ damage_per_level = max(1, damage_per_level_map.get(rarity, int(base_damage * 0.15)))
|
|
|
+ calculated_damage = base_damage + (level - 1) * damage_per_level
|
|
|
+ print(f" 等级 {level}: {calculated_damage} (自动计算)")
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ print(f"错误: 模拟计算失败 - {e}")
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ print("武器伤害配置测试工具")
|
|
|
+ print("=" * 50)
|
|
|
+
|
|
|
+ # 切换到项目根目录
|
|
|
+ os.chdir(Path(__file__).parent)
|
|
|
+
|
|
|
+ # 运行测试
|
|
|
+ success = test_weapon_damage_config()
|
|
|
+
|
|
|
+ # 运行模拟计算
|
|
|
+ simulate_damage_calculation()
|
|
|
+
|
|
|
+ print("\n=== 测试完成 ===")
|
|
|
+ if success:
|
|
|
+ print("✅ 武器伤害配置测试通过")
|
|
|
+ else:
|
|
|
+ print("❌ 武器伤害配置测试失败")
|