compare_weapon_config.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import pandas as pd
  2. import json
  3. import os
  4. def compare_weapon_configs():
  5. # 读取Excel文件
  6. excel_path = r'd:\CocosGame\Pong\assets\resources\data\excel\方块武器配置\方块武器配置表.xlsx'
  7. json_path = r'd:\CocosGame\Pong\assets\resources\data\weapons.json'
  8. try:
  9. # 读取Excel文件的所有工作表
  10. excel_data = pd.read_excel(excel_path, sheet_name=None)
  11. # 读取JSON文件
  12. with open(json_path, 'r', encoding='utf-8') as f:
  13. json_data = json.load(f)
  14. print("=== 武器配置对比分析 ===")
  15. print()
  16. # 分析Excel数据结构
  17. print("Excel文件分析:")
  18. for sheet_name, df in excel_data.items():
  19. print(f"\n工作表: {sheet_name}")
  20. print(f"数据形状: {df.shape}")
  21. print(f"列名: {list(df.columns)}")
  22. # 显示实际数据内容
  23. if not df.empty:
  24. print("数据内容:")
  25. for idx, row in df.iterrows():
  26. if idx < 10: # 只显示前10行
  27. print(f" 行{idx}: {dict(row)}")
  28. print("\n" + "="*60)
  29. print("\nJSON配置分析:")
  30. # 创建武器ID到名称的映射
  31. weapon_mapping = {
  32. 'pea_shooter': '毛豆射手',
  33. 'sharp_carrot': '尖胡萝卜',
  34. 'saw_grass': '锯齿草',
  35. 'watermelon_bomb': '西瓜炸弹',
  36. 'boomerang_plant': '回旋镖盆栽',
  37. 'hot_pepper': '炙热辣椒',
  38. 'cactus_shotgun': '仙人散弹',
  39. 'okra_missile': '秋葵导弹',
  40. 'mace_club': '狼牙棒'
  41. }
  42. # 分析JSON中的游戏内成本配置
  43. print("\n当前JSON配置的游戏内成本:")
  44. for weapon in json_data['weapons']:
  45. weapon_id = weapon['id']
  46. weapon_name = weapon['name']
  47. if 'inGameCostConfig' in weapon:
  48. base_cost = weapon['inGameCostConfig']['baseCost']
  49. shape_costs = weapon['inGameCostConfig']['shapeCosts']
  50. print(f"\n{weapon_name} ({weapon_id}):")
  51. print(f" 基础成本: {base_cost}")
  52. print(f" 形状成本:")
  53. for shape, cost in shape_costs.items():
  54. print(f" {shape}: {cost}")
  55. # 尝试从Excel数据中提取成本信息
  56. print("\n" + "="*60)
  57. print("\nExcel数据详细分析:")
  58. # 查找包含成本信息的工作表
  59. for sheet_name, df in excel_data.items():
  60. print(f"\n工作表 '{sheet_name}' 详细内容:")
  61. if not df.empty:
  62. # 打印所有数据
  63. print(df.to_string())
  64. # 尝试识别成本相关的列
  65. cost_related_columns = []
  66. for col in df.columns:
  67. if any(keyword in str(col).lower() for keyword in ['成本', 'cost', '价格', 'price', '费用']):
  68. cost_related_columns.append(col)
  69. if cost_related_columns:
  70. print(f"\n发现成本相关列: {cost_related_columns}")
  71. print("\n" + "="*60)
  72. print("\n对比结论:")
  73. print("1. JSON文件包含完整的游戏内成本配置")
  74. print("2. Excel文件需要进一步分析以确定是否包含对应的成本数据")
  75. print("3. 建议检查Excel文件的具体内容格式和数据结构")
  76. except Exception as e:
  77. print(f"错误: {e}")
  78. import traceback
  79. traceback.print_exc()
  80. if __name__ == "__main__":
  81. compare_weapon_configs()