战斗日志打印文件名修改,战斗数据optiondata变为userdata

dev_chengFeng
gaoxin 2020-08-01 11:16:33 +08:00
parent 4c93923b39
commit 6bfebc928f
4 changed files with 20 additions and 20 deletions

View File

@ -13,8 +13,8 @@ function this.Initialize()
end
local fightMaxRound, seed, battleType, fightData, optionData, bothNameStr
function this.SetBattleRecord(data, _optionData)
local fightMaxRound, seed, battleType, fightData, userData, bothNameStr
function this.SetBattleRecord(data, userData)
this.isSubmit = true
-- ID自增
_RecordIdFlag = _RecordIdFlag + 1
@ -24,7 +24,7 @@ function this.SetBattleRecord(data, _optionData)
seed = data.fightSeed,
battleType = data.fightType,
fightData = data.fightData,
optionData = _optionData,
userData = userData,
result = -1,
}
BattleRecordList[_RecordIdFlag] = record
@ -79,11 +79,11 @@ function this.GetBattleRecord(Id)
local seed = record.seed
local battleType = record.battleType
local fightData = record.fightData
local optionData = record.optionData
local userData = record.userData
local battleRecord = {}
Random.SetSeed(seed)
BattleLogic.Init(fightData, optionData, fightMaxRound)
BattleLogic.Init(fightData, userData, fightMaxRound)
BattleLogic.Type = battleType
BattleLogic.Event:AddEvent(BattleEventName.AddRole, function (role)
@ -133,10 +133,10 @@ function this.GetBattleRecordResult(Id)
local seed = record.seed
local battleType = record.battleType
local fightData = record.fightData
local optionData = record.optionData
local userData = record.userData
Random.SetSeed(seed)
BattleLogic.Init(fightData, optionData, fightMaxRound)
BattleLogic.Init(fightData, userData, fightMaxRound)
BattleLogic.Type = battleType
BattleLogic.StartOrder()

View File

@ -72,9 +72,13 @@ function this.PrintBattleTable(tb)
return indent_str
end
--
function this.Init(fightdata)
function this.Init(fightdata, userdata)
this.timestamp = Random.GetSeed()
this.fightdata = fightdata
if userdata then
this.userId = userdata.uid
end
this.logList = {}
end
@ -104,17 +108,17 @@ function this.WriteFile()
local platform
-- linux
if not file then
file = io.open("../luafight/BattleRecord/log-"..time..".txt", "a")
file = io.open("../luafight/BattleRecord/log-"..(this.userId or time)..".txt", "a")
platform = "Linux"
end
-- local window server
if not file then
file = io.open("luafight/BattleRecord/log-"..time..".txt", "a")
file = io.open("luafight/BattleRecord/log-"..(this.userId or time)..".txt", "a")
platform = "Local Windows Server"
end
-- local
if not file then
file = io.open("BattleRecord/log-"..time..".txt", "a")
file = io.open("BattleRecord/log-"..(this.userId or time)..".txt", "a")
platform = "Local"
end

View File

@ -23,7 +23,7 @@ local _IsDebug
local fightData
local record
local optionRecord
local userData
--是否开启战斗日志
BattleLogic.IsOpenBattleRecord = false
@ -48,17 +48,13 @@ local rolePool = BattleObjectPool.New(function ()
return RoleLogic.New()
end)
function BattleLogic.Init(data, optionData, maxRound)
function BattleLogic.Init(data, _userData, maxRound)
if BattleLogic.IsOpenBattleRecord then
record = {}
end
fightData = data
if optionData then
optionRecord = optionData
else
optionRecord = {}
end
userData = _userData
BattleLogic.CurOrder = 0
BattleLogic.TotalOrder = #data.enemyData
@ -81,7 +77,7 @@ function BattleLogic.Init(data, optionData, maxRound)
SkillManager.Init()
OutDataManager.Init(fightData)
PassiveManager.Init()
BattleLogManager.Init(fightData)
BattleLogManager.Init(fightData, userData)
end
-- 检测先手阵营

View File

@ -308,7 +308,7 @@ end
function this.InitBattleData()
Random.SetSeed(this.seed)
--BattleLogic.IsOpenBattleRecord = true
BattleLogic.Init(this.fightData, nil, this.maxRound)
BattleLogic.Init(this.fightData, {uid = PlayerManager.uid}, this.maxRound)
BattleLogic.Type = this.battleType
this.InitBattleEvent()