From 0a437537bc0495e31bbeee1844ddfe45d547eb41 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 31 Jan 2024 11:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExportExcelTools/ExportExcelTools.cs | 148 ++++++++++-------- 1 file changed, 82 insertions(+), 66 deletions(-) diff --git a/Assets/Editor/BFOthersTools/ExportExcelTools/ExportExcelTools.cs b/Assets/Editor/BFOthersTools/ExportExcelTools/ExportExcelTools.cs index 3233a366f..78e2938f4 100644 --- a/Assets/Editor/BFOthersTools/ExportExcelTools/ExportExcelTools.cs +++ b/Assets/Editor/BFOthersTools/ExportExcelTools/ExportExcelTools.cs @@ -136,71 +136,17 @@ namespace BFEditor var configFileInfos = configDirInfo.GetFiles(suffix, SearchOption.TopDirectoryOnly); // 检查棋盘文件格式 + checkBoard("chapter_board", env, sb); + checkBoard("chapter_board_bossrush", env, sb); + checkBoard("chapter_board_daily_challenge", env, sb); + checkBoard("chapter_board_dungeon_armor", env, sb); + checkBoard("chapter_board_dungeon_equip", env, sb); + checkBoard("chapter_board_dungeon_gold", env, sb); + checkBoard("chapter_board_dungeon_shards", env, sb); + checkBoard("chapter_board_rune", env, sb); + checkBoard("activity_pvp_board", env, sb); + checkBoard("arena_board", env, sb); - var luaScriptString = @"local cfg = require('app/config/chapter_board') - if not cfg or not cfg.data then - return '' - end - cfg = cfg.data - local tempMap = {} - local addErrorInfo = function(errorInfo, cfgId, errorStr) - if not tempMap[cfgId] then - tempMap[cfgId] = true - table.insert(errorInfo, 'cfgId = ' .. cfgId) - end - - table.insert(errorInfo, ' ' .. errorStr) - end - - local errorInfo = {} - for k, info in pairs(cfg) do - local board = info.board - if not board then - addErrorInfo(errorInfo, k, '没有board字段,请检查') - end - - if #board < 49 then - addErrorInfo(errorInfo, k, '没有board长度不足,请检查,当前长度为' .. #board) - end - - for index, v in ipairs(board) do - if not v[1] then - addErrorInfo(errorInfo, k, 'board字段中' .. index .. '索引没有格子类型') - end - if not v[2] then - addErrorInfo(errorInfo, k, 'board字段中' .. index .. '索引没有元素类型') - end - end - - local mystery_box_board = info.mystery_box_board - if mystery_box_board then - for index, v in ipairs(mystery_box_board) do - if not v[1] then - addErrorInfo(errorInfo, k, 'mystery_box_board字段中' .. index .. '索引没有格子类型') - end - if not v[2] then - addErrorInfo(errorInfo, k, 'mystery_box_board字段中' .. index .. '索引没有元素类型') - end - end - end - end - if #errorInfo > 0 then - return table.concat(errorInfo, '\n'); - end - - return ''"; - var resultStr = env.DoString(luaScriptString); - if (resultStr.Length > 0) - { - foreach(var strObj in resultStr) - { - var str = Convert.ToString(strObj); - if(!String.IsNullOrEmpty(str)) - { - sb.Append(str + "\n"); - } - } - } // 检查monster string monsterConfigListLua = "{"; @@ -213,7 +159,7 @@ namespace BFEditor } } monsterConfigListLua += "}"; - luaScriptString = "local ids = {}\n local MONSTER_LIST = " + monsterConfigListLua + "\n"; + var luaScriptString = "local ids = {}\n local MONSTER_LIST = " + monsterConfigListLua + "\n"; luaScriptString += @"local str = {} for i, name in ipairs(MONSTER_LIST) do if name ~= 'monster_base' and name ~= 'monster_position' and name ~= 'monster_position_base' then @@ -230,7 +176,7 @@ namespace BFEditor return table.concat(str, '\n'); end return ''"; - resultStr = env.DoString(luaScriptString); + var resultStr = env.DoString(luaScriptString); if (resultStr.Length > 0) { foreach(var strObj in resultStr) @@ -299,6 +245,76 @@ namespace BFEditor return sb; } + public static void checkBoard(string configName, LuaEnv env, in StringBuilder sb) + { + var luaScriptString = @" + if not cfg or not cfg.data then + return '' + end + cfg = cfg.data + local tempMap = {} + local addErrorInfo = function(errorInfo, cfgId, errorStr) + if not tempMap[cfgId] then + tempMap[cfgId] = true + table.insert(errorInfo, 'cfgId = ' .. cfgId) + end + + table.insert(errorInfo, ' ' .. errorStr) + end + + local errorInfo = {} + for k, info in pairs(cfg) do + local board = info.board or info.board_daily_challenge + if not board then + addErrorInfo(errorInfo, k, configName .. ' 没有board字段,请检查') + else + if #board < 49 then + addErrorInfo(errorInfo, k, configName .. ' 没有board长度不足,请检查,当前长度为' .. #board) + end + + for index, v in ipairs(board) do + if not v[1] then + addErrorInfo(errorInfo, k, configName .. ' board字段中' .. index .. '索引没有格子类型') + end + if not v[2] then + addErrorInfo(errorInfo, k, configName .. ' board字段中' .. index .. '索引没有元素类型') + elseif v[2] > 5 or v[2] < 0 then + addErrorInfo(errorInfo, k, configName .. ' board字段中' .. index .. '元素类型不合法,当前为' .. v[2]) + end + end + + local mystery_box_board = info.mystery_box_board + if mystery_box_board then + for index, v in ipairs(mystery_box_board) do + if not v[1] then + addErrorInfo(errorInfo, k, configName .. ' mystery_box_board字段中' .. index .. '索引没有格子类型') + end + if not v[2] then + addErrorInfo(errorInfo, k, configName .. ' mystery_box_board字段中' .. index .. '索引没有元素类型') + end + end + end + end + end + if #errorInfo > 0 then + return table.concat(errorInfo, '\n'); + end + + return ''"; + var resultStr = env.DoString(" local cfg = require('app/config/" + configName + "')\n" + "local configName = '" + configName + "'\n" + luaScriptString); + if (resultStr.Length > 0) + { + foreach(var strObj in resultStr) + { + var str = Convert.ToString(strObj); + if(!String.IsNullOrEmpty(str)) + { + sb.Append(str + "\n"); + } + } + } + } + public static bool FastExportExcelToLua(bool isDeveloper, string designExcelPath) { failFlag = false;