| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import pandas as pd
- import json
- import os
- def compare_weapon_configs():
- # 读取Excel文件
- excel_path = r'd:\CocosGame\Pong\assets\resources\data\excel\方块武器配置\方块武器配置表.xlsx'
- json_path = r'd:\CocosGame\Pong\assets\resources\data\weapons.json'
-
- try:
- # 读取Excel文件的所有工作表
- excel_data = pd.read_excel(excel_path, sheet_name=None)
-
- # 读取JSON文件
- with open(json_path, 'r', encoding='utf-8') as f:
- json_data = json.load(f)
-
- print("=== 武器配置对比分析 ===")
- print()
-
- # 分析Excel数据结构
- print("Excel文件分析:")
- for sheet_name, df in excel_data.items():
- print(f"\n工作表: {sheet_name}")
- print(f"数据形状: {df.shape}")
- print(f"列名: {list(df.columns)}")
-
- # 显示实际数据内容
- if not df.empty:
- print("数据内容:")
- for idx, row in df.iterrows():
- if idx < 10: # 只显示前10行
- print(f" 行{idx}: {dict(row)}")
-
- print("\n" + "="*60)
- print("\nJSON配置分析:")
-
- # 创建武器ID到名称的映射
- weapon_mapping = {
- 'pea_shooter': '毛豆射手',
- 'sharp_carrot': '尖胡萝卜',
- 'saw_grass': '锯齿草',
- 'watermelon_bomb': '西瓜炸弹',
- 'boomerang_plant': '回旋镖盆栽',
- 'hot_pepper': '炙热辣椒',
- 'cactus_shotgun': '仙人散弹',
- 'okra_missile': '秋葵导弹',
- 'mace_club': '狼牙棒'
- }
-
- # 分析JSON中的游戏内成本配置
- print("\n当前JSON配置的游戏内成本:")
- for weapon in json_data['weapons']:
- weapon_id = weapon['id']
- weapon_name = weapon['name']
-
- if 'inGameCostConfig' in weapon:
- base_cost = weapon['inGameCostConfig']['baseCost']
- shape_costs = weapon['inGameCostConfig']['shapeCosts']
-
- print(f"\n{weapon_name} ({weapon_id}):")
- print(f" 基础成本: {base_cost}")
- print(f" 形状成本:")
- for shape, cost in shape_costs.items():
- print(f" {shape}: {cost}")
-
- # 尝试从Excel数据中提取成本信息
- print("\n" + "="*60)
- print("\nExcel数据详细分析:")
-
- # 查找包含成本信息的工作表
- for sheet_name, df in excel_data.items():
- print(f"\n工作表 '{sheet_name}' 详细内容:")
- if not df.empty:
- # 打印所有数据
- print(df.to_string())
-
- # 尝试识别成本相关的列
- cost_related_columns = []
- for col in df.columns:
- if any(keyword in str(col).lower() for keyword in ['成本', 'cost', '价格', 'price', '费用']):
- cost_related_columns.append(col)
-
- if cost_related_columns:
- print(f"\n发现成本相关列: {cost_related_columns}")
-
- print("\n" + "="*60)
- print("\n对比结论:")
- print("1. JSON文件包含完整的游戏内成本配置")
- print("2. Excel文件需要进一步分析以确定是否包含对应的成本数据")
- print("3. 建议检查Excel文件的具体内容格式和数据结构")
-
- except Exception as e:
- print(f"错误: {e}")
- import traceback
- traceback.print_exc()
- if __name__ == "__main__":
- compare_weapon_configs()
|