|
|
@@ -1044,11 +1044,143 @@ class ConfigManagerGUI:
|
|
|
break
|
|
|
|
|
|
if base_sheet is not None:
|
|
|
+ # 设置武器配置的映射
|
|
|
+ old_mapping = self.current_mapping
|
|
|
+ self.current_mapping = {
|
|
|
+ 'format_type': 'horizontal',
|
|
|
+ 'param_types': {
|
|
|
+ 'ID': str,
|
|
|
+ '名称': str,
|
|
|
+ '类型': str,
|
|
|
+ '稀有度': str,
|
|
|
+ '权重': int,
|
|
|
+ '伤害': int,
|
|
|
+ '射速': float,
|
|
|
+ '射程': int,
|
|
|
+ '子弹速度': int,
|
|
|
+ # 英文字段支持
|
|
|
+ 'id': str,
|
|
|
+ 'name': str,
|
|
|
+ 'type': str,
|
|
|
+ 'rarity': str,
|
|
|
+ 'weight': int,
|
|
|
+ 'damage': int,
|
|
|
+ 'fireRate': float,
|
|
|
+ 'range': int,
|
|
|
+ 'bulletSpeed': int
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
base_config = self.parse_config_data(base_sheet, filename)
|
|
|
if 'items' in base_config:
|
|
|
weapons_config['weapons'] = base_config['items']
|
|
|
+ print(f"成功解析武器基础配置,共{len(base_config['items'])}个武器")
|
|
|
+
|
|
|
+ # 恢复原来的映射
|
|
|
+ self.current_mapping = old_mapping
|
|
|
+
|
|
|
+ # 解析武器升级费用配置工作表(新增支持)
|
|
|
+ upgrade_cost_sheet = None
|
|
|
+ print(f"可用的工作表: {list(all_sheets_data.keys())}")
|
|
|
+ for sheet_name in ['武器升级费用配置', 'Weapon Upgrade Cost', 'upgrade_costs', '升级费用']:
|
|
|
+ if sheet_name in all_sheets_data:
|
|
|
+ upgrade_cost_sheet = all_sheets_data[sheet_name]
|
|
|
+ print(f"找到升级费用配置工作表: {sheet_name}")
|
|
|
+ break
|
|
|
+
|
|
|
+ if upgrade_cost_sheet is None:
|
|
|
+ print("未找到升级费用配置工作表")
|
|
|
+
|
|
|
+ if upgrade_cost_sheet is not None:
|
|
|
+ # 直接处理升级费用数据(横向表格格式)
|
|
|
+ print(f"开始处理升级费用配置,工作表行数: {len(upgrade_cost_sheet)}")
|
|
|
+ upgrade_cost_data = []
|
|
|
+
|
|
|
+ # 检查第一行是否为表头
|
|
|
+ first_row = upgrade_cost_sheet.iloc[0] if len(upgrade_cost_sheet) > 0 else None
|
|
|
+ is_header = False
|
|
|
+ if first_row is not None:
|
|
|
+ first_cell = str(first_row.iloc[0]).strip() if len(first_row) > 0 else ""
|
|
|
+ # 如果第一列是"武器ID"等表头文字,则认为是表头
|
|
|
+ if first_cell in ['武器ID', 'ID', 'weapon_id', 'weaponId']:
|
|
|
+ is_header = True
|
|
|
+ print(f"检测到表头行,第一列内容: {first_cell}")
|
|
|
+
|
|
|
+ for index, row in upgrade_cost_sheet.iterrows():
|
|
|
+ if is_header and index == 0: # 只有确认是表头时才跳过第一行
|
|
|
+ print(f"跳过表头行 {index}")
|
|
|
+ continue
|
|
|
+
|
|
|
+ # 支持多种武器ID字段名:武器ID、ID、weapon_id等
|
|
|
+ weapon_id = None
|
|
|
+ for id_field in ['武器ID', 'ID', 'weapon_id', 'weaponId']:
|
|
|
+ if id_field in row and pd.notna(row[id_field]):
|
|
|
+ weapon_id = row[id_field]
|
|
|
+ break
|
|
|
+
|
|
|
+ # 如果没有找到命名字段,则使用第一列
|
|
|
+ if weapon_id is None:
|
|
|
+ weapon_id = row.iloc[0] if len(row) > 0 else None
|
|
|
+
|
|
|
+ print(f"处理行 {index}: weapon_id = {weapon_id}")
|
|
|
+ if weapon_id and str(weapon_id).strip(): # 确保武器ID不为空
|
|
|
+ upgrade_levels = {}
|
|
|
+ # 从第5列开始是等级1-10的费用(E列到N列)
|
|
|
+ for level in range(1, 11):
|
|
|
+ cost_col_index = 4 + (level - 1) # 等级1费用在第5列(索引4),等级2在第6列(索引5),以此类推
|
|
|
+ if cost_col_index < len(row):
|
|
|
+ cost = row.iloc[cost_col_index]
|
|
|
+ if cost and str(cost).strip() and str(cost) != 'nan':
|
|
|
+ try:
|
|
|
+ upgrade_levels[str(level)] = {'cost': int(float(cost))}
|
|
|
+ print(f" 等级 {level} 费用: {cost}")
|
|
|
+ except (ValueError, TypeError):
|
|
|
+ print(f" 等级 {level} 费用解析失败: {cost}")
|
|
|
+
|
|
|
+ if upgrade_levels: # 只有当有升级费用数据时才添加
|
|
|
+ upgrade_cost_data.append({
|
|
|
+ 'weapon_id': str(weapon_id).strip(),
|
|
|
+ 'levels': upgrade_levels
|
|
|
+ })
|
|
|
+ print(f"为武器 {weapon_id} 添加了 {len(upgrade_levels)} 个等级的升级费用")
|
|
|
+ else:
|
|
|
+ print(f"武器 {weapon_id} 没有有效的升级费用数据")
|
|
|
+
|
|
|
+ # 将升级费用配置合并到原始武器数据中(在转换之前)
|
|
|
+ print(f"总共解析到 {len(upgrade_cost_data)} 个武器的升级费用配置")
|
|
|
+ # 检查数据结构,支持两种格式:items 或 weapons
|
|
|
+ weapon_list = None
|
|
|
+ if 'items' in weapons_config:
|
|
|
+ weapon_list = weapons_config['items']
|
|
|
+ print(f"使用items字段,开始合并升级费用配置到 {len(weapon_list)} 个武器")
|
|
|
+ elif 'weapons' in weapons_config:
|
|
|
+ weapon_list = weapons_config['weapons']
|
|
|
+ print(f"使用weapons字段,开始合并升级费用配置到 {len(weapon_list)} 个武器")
|
|
|
+ else:
|
|
|
+ print("weapons_config中没有items或weapons字段")
|
|
|
+
|
|
|
+ if weapon_list:
|
|
|
+ for weapon in weapon_list:
|
|
|
+ # 支持两种字段名格式:ID(原始数据)和id(转换后数据)
|
|
|
+ weapon_id = weapon.get('ID', '') or weapon.get('id', '')
|
|
|
+ if weapon_id:
|
|
|
+ # 查找对应的升级费用配置
|
|
|
+ matching_upgrade = None
|
|
|
+ for upgrade_data in upgrade_cost_data:
|
|
|
+ if upgrade_data['weapon_id'] == weapon_id:
|
|
|
+ matching_upgrade = upgrade_data
|
|
|
+ break
|
|
|
+
|
|
|
+ if matching_upgrade:
|
|
|
+ weapon['upgradeConfig'] = {
|
|
|
+ 'maxLevel': 10,
|
|
|
+ 'levels': matching_upgrade['levels']
|
|
|
+ }
|
|
|
+ print(f"✓ 为武器 {weapon_id} 添加了升级费用配置")
|
|
|
+ else:
|
|
|
+ print(f"✗ 武器 {weapon_id} 未找到匹配的升级费用配置")
|
|
|
|
|
|
- # 解析升级配置工作表(支持中英文工作表名)
|
|
|
+ # 解析旧版升级配置工作表(向后兼容)
|
|
|
upgrade_sheet = None
|
|
|
for sheet_name in ['升级配置', 'Upgrade Config', 'upgrades', '武器升级']:
|
|
|
if sheet_name in all_sheets_data:
|
|
|
@@ -1065,7 +1197,7 @@ class ConfigManagerGUI:
|
|
|
# 为每个武器添加升级配置
|
|
|
for weapon in weapons_config['weapons']:
|
|
|
weapon_id = weapon.get('ID')
|
|
|
- if weapon_id:
|
|
|
+ if weapon_id and 'upgradeConfig' not in weapon: # 如果还没有升级配置
|
|
|
# 查找对应的升级配置
|
|
|
weapon_upgrades = [item for item in upgrade_items if item.get('ID') == weapon_id]
|
|
|
if weapon_upgrades:
|
|
|
@@ -1091,6 +1223,8 @@ class ConfigManagerGUI:
|
|
|
|
|
|
except Exception as e:
|
|
|
print(f"解析武器配置表时出错: {e}")
|
|
|
+ import traceback
|
|
|
+ traceback.print_exc()
|
|
|
return {'weapons': []}
|
|
|
|
|
|
def clear_selection(self):
|
|
|
@@ -1740,6 +1874,13 @@ class ConfigManagerGUI:
|
|
|
'bulletConfig': self._generate_bullet_config(weapon_id, weapon_type, damage, weapon_range),
|
|
|
'visualConfig': self._generate_visual_config(weapon_id, weapon_name)
|
|
|
}
|
|
|
+
|
|
|
+ # 如果原始数据中有upgradeConfig,则添加到结果中
|
|
|
+ if 'upgradeConfig' in item:
|
|
|
+ result['upgradeConfig'] = item['upgradeConfig']
|
|
|
+ print(f"为武器 {weapon_id} 保留了升级配置: {item['upgradeConfig']}")
|
|
|
+ else:
|
|
|
+ print(f"武器 {weapon_id} 没有升级配置数据")
|
|
|
print(f"成功转换武器数据: {result}")
|
|
|
return result
|
|
|
except Exception as e:
|