back_recharge
parent
e56acaea56
commit
a37e7310f6
|
@ -13,17 +13,34 @@ require("Modules.Battle.Logic.Base.Random")
|
|||
require("Modules.Battle.Logic.BattleLogic")
|
||||
require("Modules.Battle.Logic.RoleLogic")
|
||||
|
||||
|
||||
require("Modules.Battle.Logic.Base.RoleData")
|
||||
require("Modules.Battle.Logic.Base.Buff")
|
||||
require("Modules.Battle.Logic.Base.Skill")
|
||||
require("Modules.Battle.Logic.Base.Passivity")
|
||||
|
||||
local BattleMain = {}
|
||||
local BattleLogic = BattleLogic
|
||||
local Random = Random
|
||||
|
||||
local _fightData
|
||||
local _optionData
|
||||
|
||||
function PrintTable(tb)
|
||||
local indent_str = "{"
|
||||
for k,v in pairs(tb) do
|
||||
indent_str = string.format("%s%s=%s", indent_str,
|
||||
type(k) == "number" and string.format("[%d]",k) or tostring(k),
|
||||
type(v) == "table" and "" or tostring(v)..",")
|
||||
if type(v) == "table" then
|
||||
indent_str = indent_str .. PrintTable(v)
|
||||
end
|
||||
end
|
||||
indent_str = indent_str .. "},"
|
||||
return indent_str
|
||||
end
|
||||
|
||||
--捕获异常,并输出错误日志
|
||||
local function error( err )
|
||||
print("error....")
|
||||
local time = string.format("%d-%d-%d-%d-%d-%d",
|
||||
os.date("%Y"),
|
||||
os.date("%m"),
|
||||
|
@ -31,631 +48,56 @@ local function error( err )
|
|||
os.date("%H"),
|
||||
os.date("%M"),
|
||||
os.date("%S"))
|
||||
local file = io.open("luafight/LogError/"..time..".txt", "a")
|
||||
file:write(debug.traceback(err))
|
||||
local file = io.open("LogError/"..time..".txt", "a")
|
||||
file:write("fightData:\n"..PrintTable(_fightData).."\n")
|
||||
file:write("optionData:\n"..PrintTable(_optionData).."\n")
|
||||
file:write("error:\n"..debug.traceback(err).."\n")
|
||||
io.close(file)
|
||||
end
|
||||
|
||||
--测试战斗数据
|
||||
local test_fight_data= {
|
||||
playerData =
|
||||
{
|
||||
[1] =
|
||||
{
|
||||
professionId = 5,
|
||||
passivity =
|
||||
{
|
||||
},
|
||||
type = 1,
|
||||
skill =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] =
|
||||
{
|
||||
[1] = 40001,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 11,
|
||||
[2] = 0.93,
|
||||
[3] = 2,
|
||||
[4] = 2,
|
||||
[5] = 0.2,
|
||||
},
|
||||
},
|
||||
},
|
||||
superSkill =
|
||||
{
|
||||
[1] = 3,
|
||||
[2] =
|
||||
{
|
||||
[1] = 20000,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 2,
|
||||
[2] = 1.06,
|
||||
[3] = 2,
|
||||
},
|
||||
[4] =
|
||||
{
|
||||
[1] = 3,
|
||||
[2] = 0.6,
|
||||
[3] = 1,
|
||||
[4] = 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
roleId = 10008,
|
||||
camp = 0,
|
||||
property =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 2206,
|
||||
[3] = 2206,
|
||||
[4] = 217,
|
||||
[5] = 193,
|
||||
[6] = 232,
|
||||
[7] = 130,
|
||||
[8] = 0,
|
||||
[9] = 0,
|
||||
[10] = 0,
|
||||
[11] = 0,
|
||||
[12] = 0,
|
||||
[13] = 0,
|
||||
[14] = 0,
|
||||
[15] = 0,
|
||||
[16] = 0,
|
||||
[17] = 0,
|
||||
[18] = 0,
|
||||
[19] = 0,
|
||||
[20] = 0,
|
||||
[21] = 0,
|
||||
[22] = 0,
|
||||
[23] = 0,
|
||||
[24] = 0,
|
||||
[25] = 0,
|
||||
[26] = 0,
|
||||
},
|
||||
quality = 1,
|
||||
},
|
||||
[2] =
|
||||
{
|
||||
professionId = 1,
|
||||
passivity =
|
||||
{
|
||||
},
|
||||
type = 1,
|
||||
skill =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] =
|
||||
{
|
||||
[1] = 40001,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 1,
|
||||
[3] = 1,
|
||||
},
|
||||
},
|
||||
[3] =
|
||||
{
|
||||
[1] = 30011,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 4,
|
||||
[2] = 9,
|
||||
[3] = 0.1,
|
||||
[4] = 5,
|
||||
[5] = 1,
|
||||
},
|
||||
[4] =
|
||||
{
|
||||
[1] = 4,
|
||||
[2] = 10,
|
||||
[3] = 0.1,
|
||||
[4] = 5,
|
||||
[5] = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
superSkill =
|
||||
{
|
||||
[1] = 2.3,
|
||||
[2] =
|
||||
{
|
||||
[1] = 20312,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 19,
|
||||
[2] = 1.35,
|
||||
[3] = 1,
|
||||
[4] = 0.5,
|
||||
[5] = 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
roleId = 10013,
|
||||
camp = 0,
|
||||
property =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 1678,
|
||||
[3] = 1678,
|
||||
[4] = 242,
|
||||
[5] = 194,
|
||||
[6] = 162,
|
||||
[7] = 163,
|
||||
[8] = 0,
|
||||
[9] = 0,
|
||||
[10] = 0,
|
||||
[11] = 0,
|
||||
[12] = 0,
|
||||
[13] = 0,
|
||||
[14] = 0,
|
||||
[15] = 0,
|
||||
[16] = 0,
|
||||
[17] = 0,
|
||||
[18] = 0,
|
||||
[19] = 0,
|
||||
[20] = 0,
|
||||
[21] = 0,
|
||||
[22] = 0,
|
||||
[23] = 0,
|
||||
[24] = 0,
|
||||
[25] = 0,
|
||||
[26] = 0,
|
||||
},
|
||||
quality = 1,
|
||||
},
|
||||
[3] =
|
||||
{
|
||||
professionId = 4,
|
||||
passivity =
|
||||
{
|
||||
},
|
||||
type = 1,
|
||||
skill =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] =
|
||||
{
|
||||
[1] = 40001,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 1.35,
|
||||
[3] = 2,
|
||||
},
|
||||
},
|
||||
[3] =
|
||||
{
|
||||
[1] = 30011,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 3,
|
||||
[2] = 0,
|
||||
[3] = 0,
|
||||
[4] = 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
superSkill =
|
||||
{
|
||||
[1] = 2.5,
|
||||
[2] =
|
||||
{
|
||||
[1] = 20000,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 14,
|
||||
[2] = 1.55,
|
||||
[3] = 2,
|
||||
[4] = 1,
|
||||
[5] = 10023,
|
||||
[6] = 0.2,
|
||||
},
|
||||
},
|
||||
},
|
||||
roleId = 10023,
|
||||
camp = 0,
|
||||
property =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 1439,
|
||||
[3] = 1439,
|
||||
[4] = 280,
|
||||
[5] = 131,
|
||||
[6] = 157,
|
||||
[7] = 168,
|
||||
[8] = 0,
|
||||
[9] = 0,
|
||||
[10] = 0,
|
||||
[11] = 0,
|
||||
[12] = 0,
|
||||
[13] = 0,
|
||||
[14] = 0,
|
||||
[15] = 0,
|
||||
[16] = 0,
|
||||
[17] = 0,
|
||||
[18] = 0,
|
||||
[19] = 0,
|
||||
[20] = 0,
|
||||
[21] = 0,
|
||||
[22] = 0,
|
||||
[23] = 0,
|
||||
[24] = 0,
|
||||
[25] = 0,
|
||||
[26] = 0,
|
||||
},
|
||||
quality = 1,
|
||||
},
|
||||
teamSkill =
|
||||
{
|
||||
},
|
||||
},
|
||||
enemyData =
|
||||
{
|
||||
[1] =
|
||||
{
|
||||
[1] =
|
||||
{
|
||||
professionId = 0,
|
||||
passivity =
|
||||
{
|
||||
},
|
||||
type = 2,
|
||||
skill =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] =
|
||||
{
|
||||
[1] = 20011,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 1,
|
||||
[3] = 1,
|
||||
},
|
||||
[4] =
|
||||
{
|
||||
[1] = 3,
|
||||
[2] = 0.3,
|
||||
[3] = 1,
|
||||
[4] = 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
superSkill =
|
||||
{
|
||||
},
|
||||
roleId = 14,
|
||||
camp = 1,
|
||||
property =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] = 772,
|
||||
[3] = 772,
|
||||
[4] = 260,
|
||||
[5] = 61,
|
||||
[6] = 61,
|
||||
[7] = 80,
|
||||
[8] = 0,
|
||||
[9] = 0,
|
||||
[10] = 0.3,
|
||||
[11] = 0.3,
|
||||
[12] = 0.2,
|
||||
[13] = 1.5,
|
||||
[14] = 1,
|
||||
[15] = 0,
|
||||
[16] = 0,
|
||||
[17] = 0,
|
||||
[18] = 0,
|
||||
[19] = 0,
|
||||
[20] = 0,
|
||||
[21] = 0,
|
||||
[22] = 0,
|
||||
[23] = 0,
|
||||
[24] = 0,
|
||||
[25] = 2,
|
||||
[26] = 2,
|
||||
},
|
||||
quality = 1,
|
||||
},
|
||||
[2] =
|
||||
{
|
||||
professionId = 0,
|
||||
passivity =
|
||||
{
|
||||
},
|
||||
type = 2,
|
||||
skill =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] =
|
||||
{
|
||||
[1] = 20013,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 0.45,
|
||||
[3] = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
superSkill =
|
||||
{
|
||||
},
|
||||
roleId = 1,
|
||||
camp = 1,
|
||||
property =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] = 483,
|
||||
[3] = 483,
|
||||
[4] = 260,
|
||||
[5] = 61,
|
||||
[6] = 61,
|
||||
[7] = 240,
|
||||
[8] = 0,
|
||||
[9] = 0,
|
||||
[10] = 0.3,
|
||||
[11] = 0.3,
|
||||
[12] = 0.2,
|
||||
[13] = 1.5,
|
||||
[14] = 1,
|
||||
[15] = 0,
|
||||
[16] = 0,
|
||||
[17] = 0,
|
||||
[18] = 0,
|
||||
[19] = 0,
|
||||
[20] = 0,
|
||||
[21] = 0,
|
||||
[22] = 0,
|
||||
[23] = 0,
|
||||
[24] = 0,
|
||||
[25] = 0,
|
||||
[26] = 0,
|
||||
},
|
||||
quality = 1,
|
||||
},
|
||||
[3] =
|
||||
{
|
||||
professionId = 0,
|
||||
passivity =
|
||||
{
|
||||
},
|
||||
type = 2,
|
||||
skill =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] =
|
||||
{
|
||||
[1] = 20013,
|
||||
[2] = 0.7,
|
||||
[3] =
|
||||
{
|
||||
[1] = 1,
|
||||
[2] = 0.45,
|
||||
[3] = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
superSkill =
|
||||
{
|
||||
},
|
||||
roleId = 3,
|
||||
camp = 1,
|
||||
property =
|
||||
{
|
||||
[1] = 0,
|
||||
[2] = 483,
|
||||
[3] = 483,
|
||||
[4] = 260,
|
||||
[5] = 61,
|
||||
[6] = 61,
|
||||
[7] = 7,
|
||||
[8] = 0,
|
||||
[9] = 0,
|
||||
[10] = 0.3,
|
||||
[11] = 0.3,
|
||||
[12] = 0.2,
|
||||
[13] = 1.5,
|
||||
[14] = 1,
|
||||
[15] = 0,
|
||||
[16] = 0,
|
||||
[17] = 0,
|
||||
[18] = 0,
|
||||
[19] = 0,
|
||||
[20] = 0,
|
||||
[21] = 0,
|
||||
[22] = 0,
|
||||
[23] = 0,
|
||||
[24] = 0,
|
||||
[25] = 0,
|
||||
[26] = 0,
|
||||
},
|
||||
quality = 1,
|
||||
},
|
||||
teamSkill =
|
||||
{
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
local optionData = {
|
||||
{14,1,0}, --{第几帧,操作类型,操作参数}
|
||||
{132,2,3},
|
||||
{152,2,5},
|
||||
{178,3,2},
|
||||
{219,2,4},
|
||||
{260,3,1},
|
||||
{287,2,2},
|
||||
{312,3,5},
|
||||
{467,1,1},
|
||||
}
|
||||
|
||||
local BattleMain = {}
|
||||
local BattleLogic = BattleLogic
|
||||
local Random = Random
|
||||
|
||||
function PrintItem(v)
|
||||
if type(v) == "table" then
|
||||
return ""
|
||||
end
|
||||
return tostring(v)..","
|
||||
end
|
||||
function PrintKey(v)
|
||||
if type(v) == "number" then
|
||||
return string.format("[%d]",v)
|
||||
end
|
||||
return tostring(v)
|
||||
end
|
||||
function PrintTable( tbl , level, filteDefault)
|
||||
filteDefault = filteDefault or true --默认过滤关键字(DeleteMe, _class_type)
|
||||
level = level or 1
|
||||
local indent_str = ""
|
||||
for i = 1, level do
|
||||
indent_str = indent_str.."\t"
|
||||
end
|
||||
|
||||
print(indent_str .. "{")
|
||||
for k,v in pairs(tbl) do
|
||||
if filteDefault then
|
||||
if k ~= "_class_type" and k ~= "DeleteMe" then
|
||||
local item_str = string.format("%s%s = %s", indent_str ,PrintKey(k), PrintItem(v))
|
||||
print(item_str)
|
||||
if type(v) == "table" then
|
||||
PrintTable(v, level + 1)
|
||||
end
|
||||
end
|
||||
else
|
||||
local item_str = string.format("%s%s = %s", indent_str ,PrintKey(k), PrintItem(v))
|
||||
print(item_str)
|
||||
if type(v) == "table" then
|
||||
PrintTable(v, level + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
print(indent_str .. "},")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function BattleMain.Execute(seed, fightData, optionData)
|
||||
_fightData = fightData
|
||||
_optionData = optionData
|
||||
|
||||
--该开关用于输出战斗过程中的日志,用于验证前后端是否出现战斗不同步
|
||||
BattleLogic.IsOpenBattleRecord = false
|
||||
|
||||
--PrintTable(fightData)
|
||||
if xpcall(function ()
|
||||
Random.SetSeed(seed)
|
||||
BattleLogic.Init(fightData, optionData)
|
||||
BattleLogic.StartOrder()
|
||||
|
||||
Random.SetSeed(seed)
|
||||
BattleLogic.Init(fightData, optionData)
|
||||
BattleLogic.StartOrder()
|
||||
|
||||
while not BattleLogic.IsEnd do
|
||||
BattleLogic.Update()
|
||||
end
|
||||
|
||||
local resultList = {}
|
||||
if BattleLogic.Result == 1 then --胜利记录我方剩余血量
|
||||
local arr = BattleLogic.Query(function (r) return r.camp == 0 end, true)
|
||||
for i=1, #arr do
|
||||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
while not BattleLogic.IsEnd do
|
||||
BattleLogic.Update()
|
||||
end
|
||||
elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量
|
||||
local arr = BattleLogic.Query(function (r) return r.camp == 1 end, true)
|
||||
for i=1, #arr do
|
||||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end, error) then
|
||||
local resultList = {}
|
||||
if BattleLogic.Result == 1 then --胜利记录我方剩余血量
|
||||
local arr = BattleLogic.Query(function (r) return r.camp == 0 end, true)
|
||||
for i=1, #arr do
|
||||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量
|
||||
local arr = BattleLogic.Query(function (r) return r.camp == 1 end, true)
|
||||
for i=1, #arr do
|
||||
resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
end
|
||||
end
|
||||
resultList.result = BattleLogic.Result
|
||||
|
||||
if BattleLogic.IsOpenBattleRecord then
|
||||
BattleLogic.GenerateRecordFile()
|
||||
end
|
||||
|
||||
-- print -----------------------------------------
|
||||
--for i=1, #resultList do
|
||||
-- print("hp:"..resultList[i])
|
||||
--end
|
||||
--print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
--print("result:"..BattleLogic.Result)
|
||||
return resultList
|
||||
end
|
||||
resultList.result = BattleLogic.Result
|
||||
|
||||
if BattleLogic.IsOpenBattleRecord then
|
||||
BattleLogic.GenerateRecordFile()
|
||||
end
|
||||
|
||||
--print -----------------------------------------
|
||||
--for i=1, #resultList do
|
||||
-- print("hp:"..resultList[i])
|
||||
--end
|
||||
--print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
--print("result:"..BattleLogic.Result)
|
||||
|
||||
|
||||
return resultList
|
||||
|
||||
--if xpcall(function ()
|
||||
-- while not BattleLogic.IsEnd do
|
||||
-- BattleLogic.Update()
|
||||
-- end
|
||||
--end, error) then
|
||||
-- local resultList = {}
|
||||
-- if BattleLogic.Result == 1 then --胜利记录我方剩余血量
|
||||
-- local arr = BattleLogic.Query(function (r) return r.camp == 0 end, true)
|
||||
-- for i=1, #arr do
|
||||
-- resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
-- end
|
||||
-- elseif BattleLogic.Result == 0 then --失败记录敌方剩余血量
|
||||
-- local arr = BattleLogic.Query(function (r) return r.camp == 1 end, true)
|
||||
-- for i=1, #arr do
|
||||
-- resultList[i] = arr[i]:GetRoleData(RoleDataName.Hp)
|
||||
-- end
|
||||
-- end
|
||||
-- resultList.result = BattleLogic.Result
|
||||
--
|
||||
-- if BattleLogic.IsOpenBattleRecord then
|
||||
-- BattleLogic.GenerateRecordFile()
|
||||
-- end
|
||||
--
|
||||
-- --print -----------------------------------------
|
||||
-- for i=1, #resultList do
|
||||
-- print("hp:"..resultList[i])
|
||||
-- end
|
||||
-- print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
-- print("result:"..BattleLogic.Result)
|
||||
--
|
||||
--
|
||||
-- return resultList
|
||||
-- --[[ --TODO:需要导入cjson库
|
||||
-- --local json = require("cjson")
|
||||
-- --local time = string.format("%d-%d-%d-%d-%d-%d",
|
||||
-- -- os.date("%Y"),
|
||||
-- -- os.date("%m"),
|
||||
-- -- os.date("%d"),
|
||||
-- -- os.date("%H"),
|
||||
-- -- os.date("%M"),
|
||||
-- -- os.date("%S"))
|
||||
-- --local file = io.open("BattleRecord/"..time..".txt", "a")
|
||||
-- --file:write(json.encode(test_fight_data))
|
||||
-- --io.close(file)
|
||||
-- ]]
|
||||
--end
|
||||
--return { result = -1 }
|
||||
return { result = -1 }
|
||||
end
|
||||
|
||||
--local starttime = os.clock()
|
||||
--
|
||||
--for i=1, 100 do
|
||||
-- BattleMain.Execute(932590676, test_fight_data, optionData)
|
||||
--end
|
||||
--
|
||||
--print("cost time : %.4f", os.clock() - starttime)
|
||||
|
||||
return BattleMain
|
||||
--> hp:2084
|
||||
--> hp:9934
|
||||
--> hp:9781
|
||||
--> hp:9868
|
||||
--> hp:9752
|
||||
--> 最终运行帧数:2735
|
||||
--> result:1 (1胜,0负,-1战斗异常)
|
||||
return BattleMain
|
|
@ -714,9 +714,10 @@ public class MapLogic {
|
|||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, getFightData, getOptionData);
|
||||
//校验结果码 1:胜利
|
||||
int resultCode = checkResult[0];
|
||||
if (resultCode!=-1){
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "战斗失败!");
|
||||
if (resultCode ==1){
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "特殊处理-->战斗成功");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue