diff --git a/luafight/BattleMain_test.lua b/luafight/BattleMain_test.lua new file mode 100644 index 000000000..a1d5551ad --- /dev/null +++ b/luafight/BattleMain_test.lua @@ -0,0 +1,167 @@ +require("Modules.Battle.Logic.Misc.BattleDefine") +require("Modules.Battle.Logic.Misc.BattleUtil") +require("Modules.Battle.Logic.Misc.BattleQueue") +require("Modules.Battle.Logic.Misc.BattleDictionary") +require("Modules.Battle.Logic.Misc.BattleList") +require("Modules.Battle.Logic.Misc.BattleObjectPool") + +require("Modules.Battle.Logic.Base.BattleEvent") +require("Modules.Battle.Logic.Base.Random") + +require("Modules.Battle.Logic.Base.RoleData") +require("Modules.Battle.Logic.Base.Buff") +require("Modules.Battle.Logic.Base.Skill") +require("Modules.Battle.Logic.Base.Passivity") + +require("Modules.Battle.Logic.BattleLogic") +require("Modules.Battle.Logic.RoleLogic") + +local BattleMain = {} +local BattleLogic = BattleLogic +local Random = Random + +local _fightData +local _optionData + +local function newPairs(tbl, func) + if func == nil then + return pairs(tbl) + end + + local ary = {} + local lastUsed = 0 + for key --[[, val--]] in pairs(tbl) do + if (lastUsed == 0) then + ary[1] = key + else + local done = false + for j=1,lastUsed do -- 进行插入排序 + if (func(key, ary[j]) == true) then + arrayInsert( ary, key, j ) + done = true + break + end + end + if (done == false) then + ary[lastUsed + 1] = key + end + end + lastUsed = lastUsed + 1 + end + + -- 定义并返回迭代器 + local i = 0 + local iter = function () + i = i + 1 + if ary[i] == nil then + return nil + else + return ary[i], tbl[ary[i]] + end + end + return iter +end + +local function PrintTable(tb) + local indent_str = "{" + for k=1, #tb do + local v = tb[k] + if type(v) == "table" then + indent_str = indent_str .. PrintTable(v) + else + indent_str = indent_str .. tostring(v).."," + end + end + for k,v in newPairs(tb) do + if type(k) ~= "number" then + if type(v) == "table" then + indent_str = string.format("%s%s=%s", indent_str, tostring(k), PrintTable(v)) + else + indent_str = string.format("%s%s=%s", indent_str, tostring(k), tostring(v)..",") + end + end + end + indent_str = indent_str .. "}," + return indent_str +end + +--捕获异常,并输出错误日志 +local function error( err ) + 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("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) + print(debug.traceback(err)) +end + +local function generateRecordFile() + 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") + local record = BattleLogic.GetRecord() + for i=1, #record do + file:write(record[i].."\n") + end + io.close(file) +end + +function BattleMain.Execute(seed, fightData, optionData) + _fightData = fightData + _optionData = optionData + + print(PrintTable(fightData)) + --该开关用于输出战斗过程中的日志,用于验证前后端是否出现战斗不同步 + BattleLogic.IsOpenBattleRecord = false + + if xpcall(function () + Random.SetSeed(seed) + BattleLogic.Init(fightData, optionData) + BattleLogic.StartOrder() + + while not BattleLogic.IsEnd do + BattleLogic.Update() + end + end, error) then + local resultList = {} + if BattleLogic.Result == 1 then --胜利记录我方剩余血量 + local arr = RoleManager.QueryIncludeExile(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.QueryIncludeExile(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 + generateRecordFile() + end + + -- print ----------------------------------------- + for i=1, #resultList do + print("hp:"..resultList[i]) + end + print("最终运行帧数:"..BattleLogic.GetCurRound()) + print("result:"..BattleLogic.Result) + + return resultList + end + return { result = -1 } +end +return BattleMain \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Buff/BuDongSign.lua b/luafight/Modules/Battle/Logic/Buff/BuDongSign.lua new file mode 100644 index 000000000..daba55b7d --- /dev/null +++ b/luafight/Modules/Battle/Logic/Buff/BuDongSign.lua @@ -0,0 +1,75 @@ +--不动明王印记 +BuDongSign = Buff:New() --压制 +--初始化Buff,通过传入一些自定义参数控制成长相关的数值 +function BuDongSign:SetData(...) + -- self.atkType, --1 物理 2.魔法 + -- self.ct, + -- self.value1=... + self.f1=... + self.maxPro=0 + -- 刷新排序等级 + self.curDamage=0 + self.sort = 4 +end + + +--初始化后调用一次 +function BuDongSign:OnStart() + + + self.curDamage = 0 + --本回合最多能扣到多少比例的血条 + self.maxPro=(self.target:GetRoleData(RoleDataName.Hp)/self.target:GetRoleData(RoleDataName.MaxHp))-self.f1 + if self.maxPro<0 then + self.maxPro=0 + end + + local function onFinalBeDamage(damagingFunc, atkRole, damage, skill, dotType, bCrit, damageType,isDirect) + -- 非直接伤害不免除 + if not skill and not isDirect then + return + end + --判断伤害是否能超出能扣除的最大伤害 + local maxDamage =math.floor(self.target:GetRoleData(RoleDataName.Hp)-(self.target:GetRoleData(RoleDataName.MaxHp) * self.maxPro)) + self.curDamage=damage + if self.curDamage > maxDamage then + -- 计算免除的伤害值 + local md = self.curDamage - maxDamage + if md > damage then + md = damage + end + if damagingFunc then damagingFunc(md) end + end + + end + self.target.Event:AddEvent(BattleEventName.CheckLiZhanZhiQu, onFinalBeDamage,nil,nil,self.target) + + local function onRoundChange() + self.curDamage = 0 + --本回合最多能扣到多少比例的血条 + self.maxPro=(self.target:GetRoleData(RoleDataName.Hp)/self.target:GetRoleData(RoleDataName.MaxHp))-self.f1 + if self.maxPro<0 then + self.maxPro=0 + end + --LogError("本回合最多能扣到的比例=="..maxPro) + + end + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, onRoundChange,nil,nil,self.target) +end + +--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd +function BuDongSign:OnTrigger() + return true +end + +--效果结束时调用一次 +function BuDongSign:OnEnd() + +end + +--只有当cover字段为true时触发,返回true则被新效果覆盖 +function BuDongSign:OnCover(newBuff) + return true +end + +return BuDongSign \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Buff/FalseNoDead.lua b/luafight/Modules/Battle/Logic/Buff/FalseNoDead.lua new file mode 100644 index 000000000..8771077c0 --- /dev/null +++ b/luafight/Modules/Battle/Logic/Buff/FalseNoDead.lua @@ -0,0 +1,60 @@ +FalseNoDead = Buff:New() + +--初始化Buff,通过传入一些自定义参数控制成长相关的数值 +function FalseNoDead:SetData(...) + self.pro, + self.time=... + --self.changePro = ... -- buff期间的增伤系数 + self.cover = true --控制效果可被覆盖 + -- 刷新排序等级 + self.sort = 4 + self.triggerTime=0 +end + +-- 伤害降低 +function FalseNoDead:onPassiveDamaging(func,attacker, damage, skill) + if self.triggerTime>=self.time then + --LogError("22222222222222222") + return + end + BattleUtil.RandomAction(self.pro,function() + local hp=self.target:GetRoleData(RoleDataName.Hp) + if damage >= hp then + if func then + func(hp-1) + end + self.triggerTime=self.triggerTime+1 + end + end) +end + +--初始化后调用一次 +function FalseNoDead:OnStart() + -- + self.target.Event:AddEvent(BattleEventName.CheckFalseNoDead, self.onPassiveDamaging, self) +end + +--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd +function FalseNoDead:OnTrigger() + return true +end + +--效果结束时调用一次 +function FalseNoDead:OnEnd() + self.target.Event:RemoveEvent(BattleEventName.CheckFalseNoDead, self.onPassiveDamaging, self) + self.triggerTime=0 +end + +--只有当cover字段为true时触发,返回true则被新效果覆盖 +function FalseNoDead:OnCover(newBuff) + + return true +end + +-- 比较buff +function FalseNoDead:OnCompare(buff) + return true +end + + +return FalseNoDead \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Buff/SuckBlood.lua b/luafight/Modules/Battle/Logic/Buff/SuckBlood.lua new file mode 100644 index 000000000..c3c56c84b --- /dev/null +++ b/luafight/Modules/Battle/Logic/Buff/SuckBlood.lua @@ -0,0 +1,44 @@ +SuckBlood = Buff:New() + +--初始化Buff,通过传入一些自定义参数控制成长相关的数值 +function SuckBlood:SetData(...) + self.pro=... + self.cover = true --控制效果可被覆盖 + -- 刷新排序等级 + self.sort = 4 + self.triggerTime=0 +end + +-- 伤害降低 +function SuckBlood:onPassiveDamaging(target, damage, bCrit, finalDmg,damageType,skill) + BattleUtil.FinalTreat(self.target, self.target, math.floor(BattleUtil.ErrorCorrection(damage * self.pro))) +end + +--初始化后调用一次 +function SuckBlood:OnStart() + self.target.Event:AddEvent(BattleEventName.RoleHit, self.onPassiveDamaging, self) +end + +--间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd +function SuckBlood:OnTrigger() + return true +end + +--效果结束时调用一次 +function SuckBlood:OnEnd() + self.target.Event:RemoveEvent(BattleEventName.RoleHit, self.onPassiveDamaging, self) +end + +--只有当cover字段为true时触发,返回true则被新效果覆盖 +function SuckBlood:OnCover(newBuff) + + return true +end + +-- 比较buff +function SuckBlood:OnCompare(buff) + return true +end + + +return SuckBlood \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Weapon/FightWeapon.lua b/luafight/Modules/Battle/Logic/Weapon/FightWeapon.lua new file mode 100644 index 000000000..5ac2b96fc --- /dev/null +++ b/luafight/Modules/Battle/Logic/Weapon/FightWeapon.lua @@ -0,0 +1,123 @@ +require("Modules.Battle.Logic.Monster.MonsterSkill.MSkillManager") +require("Modules.Battle.Logic.Weapon.WeaponSkillManager") +FightWeapon = {} +function FightWeapon:New() + local o = { + data=RoleData.New(), + buffFilter=BattleList.New(), + Event = BattleEvent:New() + } + setmetatable(o, self) + self.__index = self + return o +end + +-- 初始化 +function FightWeapon:Init(data) + self.type = BattleUnitType.Weapon + self.camp = data.camp + -- if data.position==10 then + -- self.type = BattleUnitType.Player + -- end + self.position = data.position + self.star = data.star + self.uid= data.id + self.teamDamage=data.teamDamage + self.roleData = data + self.sex=data.sex + self.addAttack=0 + self.data:Init(self, data.property) + self.buffFilter:Clear() --buff屏蔽列表 + self.Event:ClearEvent() + self.exileTargets={}--已经被放逐过的目标 + -- self.skillGroup = MSkillManager.CreateMSkillGroup(self, data.skill) + --LogError("神兵初始化=============================") + -- self.skillList=data.skill + self.skillNum=#data.skill + self.skillGroupList = {} + --self.ownHero=RoleManager.GetRole(data.camp,data.position) + for i = 1, #data.skill do + --LogError("---------------------"..data.skill[i].skillData.effect[1]) + --LogError("monster skill id=="..data.skill[i]) + self.skillGroupList[i] = WeaponSkillManager.CreateMSkillGroup(self, i, data.skill[i]) + end + if data.passivity and #data.passivity > 0 then + table.sort(data.passivity,function(a,b) + return a[1] < b[1] + end) + for i = 1, #data.passivity do + local v = data.passivity[i] + local passivityId = tonumber(v[1]) + local judge=v[2] + local id = tonumber(v[3]) + local args = {} + for j = 4, #v do + args[j-3] = v[j] + end + if BattleUtil.Passivity[id] then + BattleUtil.Passivity[id](self, args,passivityId,judge) + BattleLogManager.Log( + "Add Passive", + "id", tostring(id), + "camp", tostring(self.camp), + "pos", tostring(self.position), + "passivityId", tostring(passivityId), + "judge", tostring(judge) + ) + end + end + end +end + + + +function FightWeapon:AddBuff(buff) + + -- buff的miss率 + local missF = 0 + -- 检测被动对miss概率的影响 + local cl = {} + local function _CallBack(v, ct) + if v then + table.insert(cl, {v, ct}) + end + end + BattleLogic.Event:DispatchEvent(BattleEventName.RoleAddBuffMiss, _CallBack, self, buff) + missF = BattleUtil.CountChangeList(missF, cl) + + -- 如果概率为0 或者没有miss + if missF == 0 or not BattleUtil.RandomAction(missF, function() BattleLogic.BuffMgr:PutBuff(buff) end) then + for i=1, self.buffFilter.size do + if self.buffFilter.buffer[i](buff) then + BattleLogic.BuffMgr:PutBuff(buff) + return + end + end + BattleLogic.BuffMgr:AddBuff(self, buff) + end +end + + +function FightWeapon:GetRoleData(property) + local tarPro = self.data:GetData(property) + return tarPro +end +function FightWeapon:GetCamp() + return self.camp +end +function FightWeapon:GetPosition() + return self.position +end +function FightWeapon:GetStar() + return self.star +end + +function FightWeapon:IsRealDead() + return false +end +-- 数据回收 +function FightWeapon:Dispose() + +end + +return FightWeapon \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Weapon/FightWeaponManager.lua b/luafight/Modules/Battle/Logic/Weapon/FightWeaponManager.lua new file mode 100644 index 000000000..b11c68b65 --- /dev/null +++ b/luafight/Modules/Battle/Logic/Weapon/FightWeaponManager.lua @@ -0,0 +1,56 @@ + +require("Modules.Battle.Logic.Weapon.FightWeapon") + +FightWeaponManager = {} +local this = FightWeaponManager + + +function FightWeaponManager.Init() + this.monsterList = {} + -- 初始化灵兽技能管理 + -- if MSkillManager.isInit==false then + -- LogError("初始化 ====================mskikkmanager") + -- MSkillManager.Init() + -- end + WeaponSkillManager.Init() +end + +function FightWeaponManager.AddWeapon(data) + local index = data.camp * 6 + data.position + local monster = FightWeapon:New() + monster:Init(data) + if not this.monsterList then + this.monsterList = {} + end + this.monsterList[index] = monster + + BattleLogic.Event:DispatchEvent(BattleEventName.AddWeapon, monster) +end + +-- 获取角色数据 +function this.GetMonster(camp, pos) + local index = camp * 6 + pos + return this.monsterList[index] +end + +function FightWeaponManager.Update() + +end + + +-- 切换时使用(已废弃) +function FightWeaponManager.ClearEnemy() + local removePos = {} + for pos, obj in pairs(this.monsterList) do + if obj.camp == 1 then + removePos[pos] = 1 + BattleLogic.Event:DispatchEvent(BattleEventName.RemoveMonster, obj) + obj:Dispose() + end + end + for pos, _ in pairs(removePos) do + this.monsterList[pos] = nil + end +end + +return FightWeaponManager \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Weapon/WeaponCondition.lua b/luafight/Modules/Battle/Logic/Weapon/WeaponCondition.lua new file mode 100644 index 000000000..71d89c465 --- /dev/null +++ b/luafight/Modules/Battle/Logic/Weapon/WeaponCondition.lua @@ -0,0 +1,223 @@ +WeaponCondition = {} +local this = WeaponCondition + +local skillRound={} +local enSkillRound={} +local _ConditionConfig = { + [0] = function(skill, condition) --0:无限制条件 + return true + end, + [1] = function(skill, condition) --1:我方任意神将生命百分比 【比较类型】 N(万分比) + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + -- 获取该技能相同阵营人物 + local roleList = RoleManager.Query(function(role) + return role.camp == skill.owner.camp + end) + -- 判断 + for _, role in ipairs(roleList) do + local hpf = role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp) + if BattleUtil.CompareValue(hpf, comValue/10000, comType) then + return true + end + end + return false + end, + [2] = function(skill, condition) --2:回合数 【比较类型】 N + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + -- 获取当前回合 + local curRound = BattleLogic.GetCurRound() + return BattleUtil.CompareValue(curRound, comValue, comType) + end, + + [3] = function(skill, condition) --2:回合数 【比较类型】 N 且 概率为 N + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + local rand = condition[4] + -- 获取当前回合 + local curRound = BattleLogic.GetCurRound() + local isRoundOk = BattleUtil.CompareValue(curRound, comValue, comType) + -- 判断概率 + local r = Random.Range01() + local isRandomOk = r <= rand/10000 + return isRoundOk and isRandomOk + end, + + [4] = function(skill, condition) --4:场上燃烧目标的数量 【比较类型】 N + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + -- 当前释放技能的单位的职业 + local professionId = skill.owner.professionId + + local list = RoleManager.Query(function(role) + return role.camp ~= skill.owner.camp + end) + if not list then + return false + end + local num=0 + for key, value in pairs(list) do + local isHave=BattleLogic.BuffMgr:HasBuff(value, BuffName.DOT, function(buff) return buff.damageType == 1 end) + if isHave then + num=num+1 + end + end + return BattleUtil.CompareValue(num, comValue, comType) + end, + [5] = function(skill, condition) --5:敌方上场神将数量 且概率(万分比) + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + local rand = condition[4] + local roleList = RoleManager.Query(function(role) + return role.camp ~= skill.owner.camp + end) + local isEnough=BattleUtil.CompareValue(#roleList, comValue, comType) + local r = Random.Range01() + -- 判断概率 + if isEnough then + return rand/10000>r + end + return false + end, + [6] = function(skill, condition) --6:敌方任意神将生命百分比 【比较类型】 N(万分比) + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + local round = condition[4] + -- 获取该技能相同阵营人物 + local roleList = RoleManager.Query(function(role) + return role.camp ~= skill.owner.camp + end) + -- 判断 + local r = Random.Range01() + for _, role in ipairs(roleList) do + local hpf = role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp) + if BattleUtil.CompareValue(hpf, comValue/10000, comType) then + return round/10000>r + end + end + return false + end, + [7] = function(skill, condition) --7:敌方上场神将数量 且概率(万分比)(检测放逐) + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + local rand = condition[4] + local roleList = RoleManager.QueryIncludeExile(function(role) + return role.camp ~= skill.owner.camp + end) + --判断场上敌方数量是否足够 + local isEnough=BattleUtil.CompareValue(#roleList, comValue, comType) + if isEnough then + local ishave=false + --是否有没被放逐的目标 + local list=skill.owner.exileTargets + for key, value in pairs(roleList) do + if not BattleUtil.ChecklistIsContainValue(list,value) then + ishave=true + break + end + end + if ishave then + local r = Random.Range01() + -- 判断概率 + if isEnough then + return rand/10000>r + end + end + return false + end + return false + end, + [8] = function(skill, condition) --6:回合cd数限制 + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + + -- 获取当前回合 + local curRound = BattleLogic.GetCurRound() + --我方主角技能计算回合 + if skill.owner.camp==0 then + if not skillRound[skill.id] then + skillRound[skill.id]=curRound + return true + else + if curRound==skillRound[skill.id]+comValue then + skillRound[skill.id]=curRound + return true + end + end + else + --敌方主角技能计算回合 + if not enSkillRound[skill.id] then + enSkillRound[skill.id]=curRound + return true + else + if curRound==enSkillRound[skill.id]+comValue then + enSkillRound[skill.id]=curRound + return true + end + end + end + + + return false + end, + [9] = function(skill, condition) --6:我方道系非治疗数量 + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + local list=RoleManager.Query(function(role) return role.camp==skill.owner.camp and role.element==BattleRoleElementType.DAO and role.job~=1 end) + return BattleUtil.CompareValue(#list, comValue, comType) + end, + [10] = function(skill, condition) --10:神兵所属神将生命百分比 【比较类型】 N(万分比) + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + if skill.ownHero==nil or skill.ownHero:IsDead() then + --LogError("没有持有者") + return false + end + -- 判断 + local hpf = skill.ownHero:GetRoleData(RoleDataName.Hp) / skill.ownHero:GetRoleData(RoleDataName.MaxHp) + --LogError("hpf==="..hpf) + if BattleUtil.CompareValue(hpf, comValue/10000, comType) then + --LogError("触发技能"..hpf) + return true + end + return false + end, +} + +-- 条件检测 +function WeaponCondition.CheckCondition(skill, condition) + if not condition then + --LogError("condition==") + return true + end + + local conId = condition[1] + local comType = condition[2] + local comValue = condition[3] + --LogError("conid=="..conId.." comtype=="..comType.." comvalue=="..comValue) + return _ConditionConfig[conId](skill, condition) +end + +-- 清除缓存 +function WeaponCondition.ClearCache() + if skillRound then + skillRound={} + end + if enSkillRound then + enSkillRound={} + end +end + + +return WeaponCondition \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Weapon/WeaponSkill.lua b/luafight/Modules/Battle/Logic/Weapon/WeaponSkill.lua new file mode 100644 index 000000000..bda581b7f --- /dev/null +++ b/luafight/Modules/Battle/Logic/Weapon/WeaponSkill.lua @@ -0,0 +1,170 @@ +WeaponSkill = {} + +function WeaponSkill:New() + local o = {} + setmetatable(o, self) + self.__index = self + return o +end + +function WeaponSkill:Init(owner, group, index, skillData,playerSkillIndex) + self.owner = owner + self.group = group + self.groupIndex = index + self.skillData = skillData + self.isKill = false --是否技能击杀目标 + self.isAdd = false + self.isRage = false + self.type = BattleSkillType.Monster + --后端传过来的数据最后一个是主角技能 + if owner.position==100 then + if playerSkillIndex==self.owner.skillNum then + self.isPlayerSkill=true + else + self.isPlayerSkill=false + end + end + + self.curCastCount = 0 + self.maxCastCount = self.skillData.maxCount + -- LogError("monster skill id=="..skillData.effect[1]) + self.curRoundCount = 0 + self.maxRoundCount = self.skillData.maxRoundCount + + --MTrigger.AddSkill(self.skillData, self.skillData.triggerCondition, self) + local effectData = self.skillData.effect + self.id = tonumber(effectData[1]) -- 技能ID + self.ownHero=RoleManager.GetRoleByCampAndPos(owner.camp,owner.position) + -- 将技能加入触发检测 + WeaponTrigger.AddSkill(self.skillData.triggerId, self.skillData.triggerCondition, self) + self.hitTime = effectData[2] -- 效果命中需要的时间 + self.continueTime = effectData[3] -- 命中后伤害持续时间 + self.attackCount = effectData[4] -- 伤害持续时间内伤害次数 + -- 初始化 + local effects = {} + for i=5, #effectData do + table.insert(effects, effectData[i]) + end + self.effectCaster = EffectCaster:New() + self.effectCaster:Init(self, effects, targets) + --监听回合开始消息 + BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange,function (round) + self.curRoundCount = 0 + end) +end + +-- 是否可以释放 +function WeaponSkill:canCastSkill() + -- 超出最大次数限制 + if self.curCastCount >= self.maxCastCount then + return false + end + -- 超出轮数最大次数限制 + if self.curRoundCount >= self.maxRoundCount then + return false + end + return true +end + +function WeaponSkill:Cast(func) + self.castDoneFunc = func + self.isTriggePassivity=false + self.triggerPassivityId={} + + -- 技能效果生效 + if self.effectCaster then + --放技能前判断是否有目标,没有就不会放技能,直接执行技能回调 by 王振兴 2021/03/26 + --为解决攻击目标只剩被放逐的单位导致技能播放异常 + self.effectCaster:ChooseTarget() + local targets=BattleUtil.LengthOfTable(self:GetDirectTargetsNoExile()) + if targets==0 and self.castDoneFunc then + self.castDoneFunc() + return + end + --end + self.effectCaster:Cast() + end + + -- 释放技能开始 + if self.owner.type==BattleUnitType.Weapon then + if self.ownHero then + self.ownHero.Event:DispatchEvent(BattleEventName.WeaponSkillCast, self) + end + end + self.owner.Event:DispatchEvent(BattleEventName.SkillCast, self) + BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self) + -- 只对效果1的目标发送事件,效果1是技能的直接伤害目标 + self.effectCaster:ForeachTargets(function(role) + role.Event:DispatchEvent(BattleEventName.BeSkillCastEnd, self) + end) + --技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个 + local duration = self.hitTime + self.continueTime + -- 结算时间向后延长0.2秒,避免在效果结算完成前就结束了技能释放 + BattleLogic.WaitForTrigger(duration + 0.8, function() + self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) + BattleLogic.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) + + -- 只对效果1的目标发送事件,效果1是技能的直接伤害目标 + self.effectCaster:ForeachTargets(function(role) + role.Event:DispatchEvent(BattleEventName.BeSkillCastEnd, self) + end) + -- 技能结束 + self:EndSkill() + --技能消息发送完后 iskill 设置为false + self.isKill=false + end) + self.curRoundCount = self.curRoundCount+1 + self.curCastCount =self.curCastCount+1 +end + +function WeaponSkill:GetOwner() + return self.owner +end + +function WeaponSkill:GetGroupIndex() + return self.groupIndex +end + + +-- 获取直接选择目标的ID +function WeaponSkill:GetDirectChooseId() + return self.effectCaster:GetDirectChooseId() +end + +-- 获取技能的直接目标,和策划规定第一个效果的目标为直接效果目标,(包含miss的目标) +function WeaponSkill:GetDirectTargets() + return self.effectCaster:GetDirectTargets() +end +-- 获取直接目标,不包含miss的目标,可能为空 +function WeaponSkill:GetDirectTargetsNoMiss() + return self.effectCaster:GetDirectTargetsNoMiss() +end +-- 获取技能目标最大人数 +function WeaponSkill:GetMaxTargetNum() + return self.effectCaster:GetMaxTargetNum() +end +-- 获取直接目标,不包含放逐的目标,可能为空 +function WeaponSkill:GetDirectTargetsNoExile() + return self.effectCaster:GetDirectTargetsNoExile() +end +-- 判断是否命中 +function WeaponSkill:CheckTargetIsHit(role) + return self.effectCaster:CheckTargetIsHit(role) +end + +-- 结束技能 +function WeaponSkill:EndSkill() + -- 技能后摇 + -- 技能结束后摇后结束技能释放 + BattleLogic.WaitForTrigger(0.3, function() + -- 结束回调 + self.isTriggePassivity=false + self.triggerPassivityId={} + if self.castDoneFunc then self.castDoneFunc() end + + end) + -- + self.effectTargets = {} +end + +return WeaponSkill \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Weapon/WeaponSkillGroup.lua b/luafight/Modules/Battle/Logic/Weapon/WeaponSkillGroup.lua new file mode 100644 index 000000000..b60c53e8f --- /dev/null +++ b/luafight/Modules/Battle/Logic/Weapon/WeaponSkillGroup.lua @@ -0,0 +1,38 @@ +WeaponSkillGroup = {} + +function WeaponSkillGroup:New() + local o = {} + setmetatable(o, self) + self.__index = self + return o +end + +-- 初始化数据 +function WeaponSkillGroup:Init(monster, groupIndex, groupData) + self.owner = monster + self.groupIndex = groupIndex + self.skillGroupData = groupData + -- 创建技能 + self.skillList = {} + local num=0 + -- for index, data in ipairs(self.skillGroupData) do + -- LogError("careat skill=="..index.." data=="..data.effect[1]) + -- num=num+1 + -- self.skillList[num] = MSkillManager.CreateMSkill(monster, self, num, data) + + -- end + for i = 1, #self.skillGroupData do + self.skillList[i] = WeaponSkillManager.CreateMSkill(monster, self, i, self.skillGroupData[i],groupIndex) + end +end + +function WeaponSkillGroup:GetOwner() + return self.owner +end + + +function WeaponSkillGroup:Run() + +end + +return WeaponSkillGroup \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Weapon/WeaponSkillManager.lua b/luafight/Modules/Battle/Logic/Weapon/WeaponSkillManager.lua new file mode 100644 index 000000000..65829eee8 --- /dev/null +++ b/luafight/Modules/Battle/Logic/Weapon/WeaponSkillManager.lua @@ -0,0 +1,51 @@ +require("Modules.Battle.Logic.Weapon.WeaponTrigger") +require("Modules.Battle.Logic.Weapon.WeaponSkill") +require("Modules.Battle.Logic.Weapon.WeaponSkillGroup") + +WeaponSkillManager = {} +local this = WeaponSkillManager + +function this.Init() + this.MSkillGroupList = {} -- 技能组列表 + this.MSkillList = {} -- 技能列表 + WeaponTrigger.Init() +end + +-- 创建一个技能组 +function this.CreateMSkillGroup(monster, groupIndex, skillGroupData) + --LogError("创建神兵技能组====================") + local position = monster:GetCamp() * 6 + monster:GetPosition() + if not this.MSkillGroupList then + this.MSkillGroupList = {} + end + if not this.MSkillGroupList[position] then + this.MSkillGroupList[position] = WeaponSkillGroup:New() + end + this.MSkillGroupList[position]:Init(monster, groupIndex, skillGroupData) + return this.MSkillGroupList[position] +end + +-- 创建一个技能 +function this.CreateMSkill(monster, group, index, skilldata,groupIndex) + --LogError("创建神兵技能====================") + local owner = group:GetOwner() + local groupIndex = group.groupIndex + local position = owner:GetCamp() * 6 + owner:GetPosition() + if not this.MSkillList then + this.MSkillList = {} + end + if not this.MSkillList[position] then + this.MSkillList[position] = {} + end + if not this.MSkillList[position][groupIndex] then + this.MSkillList[position][groupIndex] = {} + end + if not this.MSkillList[position][groupIndex][index] then + this.MSkillList[position][groupIndex][index] = WeaponSkill:New() + end + this.MSkillList[position][groupIndex][index]:Init(monster, group, index, skilldata,groupIndex) + + return this.MSkillList[position][groupIndex][index] +end + +return WeaponSkillManager \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Weapon/WeaponTrigger.lua b/luafight/Modules/Battle/Logic/Weapon/WeaponTrigger.lua new file mode 100644 index 000000000..18e55553b --- /dev/null +++ b/luafight/Modules/Battle/Logic/Weapon/WeaponTrigger.lua @@ -0,0 +1,343 @@ +require("Modules.Battle.Logic.Weapon.WeaponCondition") +WeaponTrigger = {} +local this = WeaponTrigger + +-- local _TriggerConfig = { +-- [1] = { --1:敌方单位行动前 +-- event = BattleEventName.RoleTurnStart, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local role = args[1] +-- return role.camp ~= skill.owner.camp +-- end +-- }, +-- [2] = {--2:敌方单位行动后 +-- event = BattleEventName.RoleTurnEnd, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local role = args[1] +-- return role.camp ~= skill.owner.camp +-- end +-- }, +-- [3] = {--3:我方单位行动前 +-- event = BattleEventName.RoleTurnStart, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local role = args[1] +-- return role.camp == skill.owner.camp +-- end +-- }, +-- [4] = {--4:我方单位行动后 +-- event = BattleEventName.RoleTurnEnd, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local role = args[1] +-- return role.camp == skill.owner.camp +-- end +-- }, +-- [5] = {--5:战前 +-- event = BattleEventName.BattleStart, +-- triggerFunc = function(skill, ...) +-- return true +-- end +-- }, +-- [6] = {--6:奇数回合开始前 +-- event = BattleEventName.BattleRoundStart, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local curRound = args[1] +-- return curRound%2 == 1 +-- end +-- }, +-- [7] = {--7:偶数回合开始前 +-- event = BattleEventName.BattleRoundStart, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local curRound = args[1] +-- return curRound%2 == 0 +-- end +-- }, +-- [8] = {--8:奇数回合结束后 +-- event = BattleEventName.BattleRoundEnd, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local curRound = args[1] +-- return curRound%2 == 1 +-- end +-- }, +-- [9] = {--9:偶数回合结束后 +-- event = BattleEventName.BattleRoundEnd, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local curRound = args[1] +-- return curRound%2 == 0 +-- end +-- }, +-- [10] = {--10:回合开始前 +-- event = BattleEventName.BattleRoundStart, +-- triggerFunc = function(skill, ...) +-- return true +-- end +-- }, +-- [11] = {--11:回合结束后 +-- event = BattleEventName.BattleRoundEnd, +-- triggerFunc = function(skill, ...) +-- return true +-- end +-- }, +-- [12] = {--12:我方单位释放技能后 +-- event = BattleEventName.SkillCastEnd, +-- triggerFunc = function(skill, ...) +-- local args = {...} +-- local castSkill = args[1] +-- return castSkill.owner.camp == skill.owner.camp and castSkill.owner.job==2 and (castSkill.type==BattleSkillType.DeadSkill or castSkill.type==BattleSkillType.Extra or castSkill.type==BattleSkillType.Special) +-- end +-- }, +-- } + +local _TriggerConfig = { + [BattleEventName.RoleTurnStart] = { + [1] = function(skill, ...) --1:敌方单位行动前 + local args = {...} + local role = args[1] + return role.camp ~= skill.owner.camp + end, + [3] = function(skill, ...) --3:我方单位行动前 + local args = {...} + local role = args[1] + return role.camp == skill.owner.camp + end + }, + [BattleEventName.RoleTurnEnd] = { + [2] = function(skill, ...)--2:敌方单位行动后 + local args = {...} + local role = args[1] + if skill.ownHero==nil then + return + end + return role.camp ~= skill.owner.camp + end, + [4] = function(skill, ...)--4:我方单位行动后 + local args = {...} + local role = args[1] + if skill.ownHero==nil then + return + end + return role.camp == skill.owner.camp + end, + [13] = function(skill, ...)--13:敌方攻击最高单位行动后 + local args = {...} + local caster = args[1] + local cam=skill.owner.camp + if caster.camp==cam then + return false + end + local list = RoleManager.Query(function(v) return v.camp~=cam end) + if list and #list>0 then + BattleUtil.SortByProp(list,RoleDataName.Attack,0) + if caster==list[1] then + return true + end + end + return false + end + }, + [BattleEventName.BattleStart] = { + [5] = function(skill, ...)--5:战前 + return true + end + }, + [BattleEventName.BattleRoundStart] = { + [6] = function(skill, ...)--6:奇数回合开始前 + local args = {...} + local curRound = args[1] + return curRound%2 == 1 + end, + [7] = function(skill, ...)--7:偶数回合开始前 + local args = {...} + local curRound = args[1] + return curRound%2 == 0 + end, + [10] = function(skill, ...)--10:回合开始前 + return true + end + }, + [BattleEventName.BattleRoundEnd] = { + [8] = function(skill, ...)--8:奇数回合结束后 + local args = {...} + local curRound = args[1] + return curRound%2 == 1 + end, + [9] = function(skill, ...)--9:偶数回合结束后 + local args = {...} + local curRound = args[1] + return curRound%2 == 0 + end, + [11] = function(skill, ...)--11:回合结束后 + return true + end + }, + [BattleEventName.SkillCastEnd] = { + [12] = function(skill, ...)--12:我方单位释放技能后 + local args = {...} + local castSkill = args[1] + return castSkill.owner.camp == skill.owner.camp and castSkill.owner.job==2 and (castSkill.type==BattleSkillType.DeadSkill or castSkill.type==BattleSkillType.Extra or castSkill.type==BattleSkillType.Special) + end, + [14] =function(skill,...) --14:我方金乌释放技能后 + local args = {...} + local castSkill = args[1] + return castSkill.owner.camp == skill.owner.camp and castSkill.owner.type==BattleUnitType.Monster and castSkill.owner.uid==20008 + end, + [16] =function(skill,...) --16:神兵所属者释放技能活普攻 + local args = {...} + local castSkill = args[1] + if skill.ownHero==nil then + return + end + --LogError("castSkill.owner=="..castSkill.owner.uid.." skill.ownHero=="..skill.ownHero.uid) + return castSkill.owner == skill.ownHero and not castSkill.isAdd and (castSkill.type==BattleSkillType.Normal or castSkill.type==BattleSkillType.Special) + end, + [17] =function(skill,...) --17:神兵所属者释放普攻 + local args = {...} + local castSkill = args[1] + if skill.ownHero==nil then + return + end + --LogError("============================17") + return castSkill.owner == skill.ownHero and castSkill.type==BattleSkillType.Normal + end, + [19] =function(skill,...) --19:神兵所属者释放技能(不包含追加技能) + local args = {...} + local castSkill = args[1] + if skill.ownHero==nil then + return + end + return castSkill.owner == skill.ownHero and not castSkill.isAdd and (castSkill.type==BattleSkillType.Special or castSkill.type==BattleSkillType.Extra ) + end, + }, + [BattleEventName.RoleIsVanish]={ + [15]=function(skill, ...) + local args={...} + local role=RoleManager.GetDeadRole(skill.owner.camp) + if role and role:IsRealDead() and not BattleUtil.CheckIsNoDead(role) then + return true + end + return false + end, + }, + [BattleEventName.BattleRoleDead]={ + [18]=function(skill, ...) + local args={...} + local defRole=args[1] + local atkRole=args[2] + local deadSkill=args[3] + if skill.ownHero==nil then + return + end + if skill==deadSkill then + defRole:GetRoleData(RoleDataName.MaxHp) + end + end, + }, +} + +function WeaponTrigger.Init() + this.TriggerList ={} + this.InitListener() +end + +-- 初始化事件监听 +function this.InitListener() + --每次初始化时间监听前 清除下缓存数据 + WeaponCondition.ClearCache() + --LogError("初始u啊神兵技能监听-------") + for event, list in pairs(_TriggerConfig) do + BattleLogic.Event:AddEvent(event, function(...) + -- 用于排序 + local firstList = {} + -- 用于排序 + local sortList = {} + for triggerId, triggerFunc in pairs(list) do + -- 判断是否有需要触发的技能 + --LogError("判断是否有需要触发的技能") + local triggerSkill = this.TriggerList[triggerId] + if triggerSkill then + for _, trigger in ipairs(triggerSkill) do + local skill = trigger.skill + local condition = trigger.condition + --LogError("判断技能是否可以释放") + -- 判断技能是否可以释放 + if skill:canCastSkill() then + -- 判断是否符合触发类型条件 + --LogError("判断是否符合触发类型条件") + if triggerFunc(skill, ... ) then + -- 检测是否符合子条件 + if WeaponCondition.CheckCondition(skill, condition) then + -- 加入技能排序对列 + --LogError("-- 加入技能排序对列") + if skill.owner.position == 100 then + table.insert(firstList, skill) + else + table.insert(sortList, skill) + end + end + end + end + end + end + end + -- 对技能进行排序 + table.sort(firstList, function(a, b) + -- 同阵营按位置排序 + if a.owner.camp == b.owner.camp then + if a.owner.position == b.owner.position then + return a.id < b.id + else + return a.owner.position < b.owner.position + end + else + -- 不同阵营的根据先手阵营排序 + return a.owner.camp == BattleLogic.FirstCamp + end + end) + -- 对技能进行排序 + table.sort(sortList, function(a, b) + -- 同阵营按位置排序 + if a.owner.camp == b.owner.camp then + if a.owner.position == b.owner.position then + return a.id < b.id + else + return a.owner.position < b.owner.position + end + else + -- 不同阵营的根据先手阵营排序 + return a.owner.camp == BattleLogic.FirstCamp + end + end) + --依次加入技能管理 + for _, skill in ipairs(firstList) do + + SkillManager.AddMonsterSkill(skill) + end + for _, skill in ipairs(sortList) do + --LogError("添加技能到skillmanager") + SkillManager.AddMonsterSkill(skill) + end + end) + end +end + + + +-- 技能加入检测 +function WeaponTrigger.AddSkill(triggerId, condition, skill) + if not this.TriggerList then + this.TriggerList = {} + end + if not this.TriggerList[triggerId] then + this.TriggerList[triggerId] = {} + end + table.insert(this.TriggerList[triggerId], {condition = condition, skill = skill,trigger= triggerId}) +end + +return WeaponTrigger \ No newline at end of file diff --git a/luafight/test.lua b/luafight/test.lua new file mode 100644 index 000000000..0066be928 --- /dev/null +++ b/luafight/test.lua @@ -0,0 +1,132 @@ + +local function pairsByKeys(t) + local a = {} + for n in pairs(t) do + if n then + a[#a+1] = n + end + end + table.sort(a, function( op1, op2 ) + local type1, type2 = type(op1), type(op2) + local num1, num2 = tonumber(op1), tonumber(op2) + + if ( num1 ~= nil) and (num2 ~= nil) then + return num1 < num2 + elseif type1 ~= type2 then + return type1 < type2 + elseif type1 == "string" then + return op1 < op2 + elseif type1 == "boolean" then + return op1 + -- 以上处理: number, string, boolean + else -- 处理剩下的: function, table, thread, userdata + return tostring(op1) < tostring(op2) -- tostring后比较字符串 + end + end) + local i = 0 + return function() + i = i + 1 + return a[i], t[a[i]] + end +end +local function PrintTable(tb) + local indent_str = "{" + local count = 0 + for k,v in pairs(tb) do + count = count + 1 + end + for k=1, #tb do + local v = tb[k] + if type(v) == "table" then + indent_str = indent_str .. PrintTable(v) + else + indent_str = indent_str .. tostring(v) + end + if k < count then + indent_str = indent_str.."," + end + end + + local index = 0 + for k,v in pairsByKeys(tb) do + index = index + 1 + if type(k) ~= "number" then + if type(v) == "table" then + indent_str = string.format("%s%s=%s", indent_str, tostring(k), PrintTable(v)) + else + indent_str = string.format("%s%s=%s", indent_str, tostring(k), tostring(v)) + end + if index < count then + indent_str = indent_str .. "," + end + end + end + indent_str = indent_str .. "}" + return indent_str +end + + + +local testFightData ={enemyData={{{ai={0},camp=1,element=3,godSoulLv=0,job=0,monsterId=30040701,passivity={{107205,0,107,1},{107106,0,90,16,2,1},{107107,1,107,1}},position=1,professionId=0,property={165,92782,92782,14395,4279,4279,0,0,0,1.5,0.058,0.067,0.067,0.067,1,1,0,0,0,0,0,0,0,0,0},quality=0,roleId=10005,skill={1071,0.2,0,1,{400000,{1,0.95,0.4}}},skinId=0,star=7,superSkill={1072,0.3,0,1,{210003,{2,1.63,2},{3,0.4,2,1}}},type=0},{ai={0},camp=1,element=2,godSoulLv=0,job=0,monsterId=30040702,passivity={{115205,0,110,1},{115106,0,90,16,2,1},{115107,1,107,2}},position=2,professionId=0,property={165,92782,92782,14395,4279,4279,0,0,0,1.5,0.058,0.067,0.067,0.067,1,1,0,0,0,0,0,0,0,0,0},quality=0,roleId=10022,skill={1151,0.2,0,1,{220000,{1,0.44,2}}},skinId=0,star=7,superSkill={1152,0.05,0,1,{220000,{2,1.55,2},{3,0.45,1,1}}},type=0},{ai={0},camp=1,element=2,godSoulLv=0,job=0,monsterId=30040703,passivity={{119106,0,90,16,2,1},{119205,0,105,1}},position=3,professionId=0,property={165,92782,92782,14395,4279,4279,0,0,0,1.5,0.058,0.067,0.067,0.067,1,1,0,0,0,0,0,0,0,0,0},quality=0,roleId=10033,skill={1191,0.2,0,1,{220801,{1,0.9,2}}},skinId=0,star=7,superSkill={1192,1,0,1,{220801,{103,3.15,2,0.3,1}}},type=0},{ai={0},camp=1,element=3,godSoulLv=0,job=0,monsterId=30040704,passivity={{104106,0,90,16,2,1},{104107,1,104,1,2}},position=4,professionId=0,property={165,92782,92782,14395,4279,4279,0,0,0,1.5,0.058,0.067,0.067,0.067,1,1,0,0,0,0,0,0,0,0,0},quality=0,roleId=10006,skill={1041,0.2,0,1,{220801,{1,0.95,2}}},skinId=0,star=7,superSkill={1042,0,0,1,{220801,{1,3.33,2}},{300000,{100,1,1}}},type=0},{ai={0},camp=1,element=1,godSoulLv=0,job=1,monsterId=30040705,passivity={{129106,0,90,16,2,1},{129107,1,137,1,0.2,2},{129205,0,300,1,0.32}},position=5,professionId=0,property={165,92782,92782,14395,4279,4279,0,0,0,1.5,0.058,0.067,0.067,0.067,1,1,0,0,0,0,0,0,0,0,0},quality=0,roleId=10004,skill={1291,0.05,0,1,{100211,{24,1,1.03}}},skinId=0,star=7,superSkill={1292,1.4,0,1,{100000,{24,1,0.9}}},type=0},{ai={0},camp=1,element=3,godSoulLv=0,job=0,monsterId=30040706,passivity={{103205,0,95,1},{103106,0,90,16,2,1},{103107,1,91,0.25,2}},position=6,professionId=0,property={165,92782,92782,14395,4279,4279,0,0,0,1.5,0.058,0.067,0.067,0.067,1,1,0,0,0,0,0,0,0,0,0},quality=0,roleId=10002,skill={1031,0.2,0,1,{230002,{1,0.65,1}}},skinId=0,star=7,superSkill={1032,0.3,0,1,{220003,{1,1.63,1}},{300000,{100,1,1}}},type=0},firstCamp=0,monsterList={},outData="",teamPassive={},teamSkill={}}},nodeId=0,playerData={{camp=0,element=3,godSoulLv=0,job=0,passivity={{1061060,0,90,16,2,1},{1061110,1,108,1}},position=1,professionId=1,property={330,3523964,3523964,447044,27751,27751,0,0.42,0.05,1.19,0,0.2,0,0.12,1,1.12,0,0,0,0,0,0,0,0,0.05},quality=0,roleId=10003,skill={1061,0.2,0,1,{400000,{1,0.95,1}}},skinId=0,star=11,superSkill={1062,1.7,0,1,{230002,{10,2.23,1,0.3}}},type=1},{camp=0,element=4,godSoulLv=0,job=0,passivity={{1471110,1,110,1},{1471060,0,90,16,2,1},{1471111,1,91,0.18,2},{1471100,1,160,0.8,2,1.6,2},{1471071,1,107,1},{1471070,1,159,2,1,0.6}},position=2,professionId=2,property={330,2280212,2280212,505865,27751,27751,0,0.3,0.05,1.17,0,0.3,0,0.12,1,1,0,0,0,0,0,0,0,0,0.05},quality=0,roleId=10041,skill={1471,0.5,0,1,{400000,{1,1,2}}},skinId=0,star=11,superSkill={1472,0.05,0.8,3,{210003,{2,1.72,2},{111,0.6,2,1,1,2}}},type=1},{camp=0,element=1,godSoulLv=0,job=0,passivity={{1311111,1,327,1},{1311100,1,105,1},{1311101,1,283,1,0,1,1,10},{1311060,0,90,16,2,1}},position=3,professionId=4,property={330,2280212,2280212,447044,27751,27751,0,0.3,0.17,1.09,0.1,0.2,0,0.2,1,1,0,0,0,0,0,0,0,0,0.05},quality=0,roleId=10009,skill={1311,0.48,0,1,{400000,{1,0.9,2}}},skinId=0,star=11,superSkill={1312,2.5,0,1,{210003,{113,1.55,2,1,0.4,7,1}}},type=1},{camp=0,element=3,godSoulLv=0,job=0,passivity={{1131070,1,112,1,1},{1131071,1,115,1,0.3,1,2},{1131060,0,90,16,2,1},{1131110,1,118,0.5,2},{1131111,1,56,0.1},{1131100,1,245,2},{1131101,1,337,1}},position=4,professionId=2,property={330,2280212,2280212,505865,27751,27751,0,0.42,0.05,1.17,0,0.3,0,0.12,1,1,0,0,0,0,0,0,0,0,0.05},quality=0,roleId=10085,skill={1131,0.7,0,1,{230002,{1,0.6,2}}},skinId=0,star=11,superSkill={1132,0.8,0,1,{200212,{2,2.12,2}},{400000,{116,1}}},type=1},{camp=0,element=2,godSoulLv=0,job=0,passivity={{1141100,1,107,2},{1141110,1,102,1},{1141070,1,119,1,0.1,5,7},{1141111,1,258,12,0.15},{1141071,1,119,1,0.06,6,7},{1141060,0,90,16,2,1},{1141101,1,296,2,1}},position=5,professionId=2,property={330,2280212,2280212,482337,27751,27751,0,0.3,0.17,1.23,0,0.32,0,0.12,1,1,0,0,0,0,0,0,0,0,0.05},quality=0,roleId=10023,skill={1141,0.4,0,1,{230002,{1,0.6,1}}},skinId=0,star=11,superSkill={1142,2,0,1,{230002,{1,2.12,1}},{300000,{112,5,0.1,7,1}}},type=1},{camp=0,element=2,godSoulLv=0,job=0,passivity={{1181101,1,99,0.3},{1181100,1,124,1},{1181071,1,98,0.3},{1181060,0,90,16,2,1}},position=6,professionId=4,property={330,2280212,2280212,447044,27751,27751,0,0.3,0.29,1.09,0.1,0.2,0,0.2,1,1,0,0,0,0,0,0,0,0,0.05},quality=0,roleId=10089,skill={1181,0.2,0,1,{400000,{1,0.9,2}}},skinId=0,star=11,superSkill={1182,0.8,0,1,{230002,{2,2.12,2}},{300000,{100,1,1}}},type=1},firstCamp=0,monsterList={{camp=0,id=0,passivity={{2510060,0,430,1,14,3,0.073,1},{2500060,0,429,0.525,1,0.5,1},{2520060,0,431,1,0.0575,12}},position=100,property={0},sex=0,skill={{{effect={40006,1.2,1.5,5,{200000,{128,0.0006,12000}}},maxCount=99,maxRoundCount=1,triggerCondition={8,3,20},triggerId=6}}},star=100,teamDamage=88809}},outData="",teamPassive={{}},teamSkill={}}} + + + + +require "Modules/Battle/Data/ConfigData" +local BattleMain = require("BattleMain") +local seed = 1646989655 + local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) + print(PrintTable(resultList)) + --print(PrintTable(resultList.starRecord)) +-- local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = seed, type = BATTLE_SERVER_TYPE.MonterFight, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- -- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local testFightData = +-- {enemyData={{{ai={0},camp=1,element=3,monsterId=10101162,passivity={},position=2,professionId=0,property={1,1100,1100,350,100,100,400,0,0,1,0,0.2,0,0,1,1,0,0,0,0,0,0,0,0,0},quality=1,roleId=10048,skill={100481,0.05,0,1,{210003,{1,0.47,1}}},skinId=0,star=0,superSkill={100482,0.05,0,1,{210003,{1,1.72,1}}},type=2},firstCamp=0,monsterList={},outData="",teamPassive={},teamSkill={}}},playerData={{camp=0,element=1,passivity={},position=1,professionId=4,property={1,3000,3000,450,150,150,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0},quality=0,roleId=10068,skill={100681,0.05,0,1,{400000,{1,0.9,2}}},skinId=0,star=4,superSkill={100682,0.05,0,1,{200003,{113,1.55,2,1,0.2,7,1}}},type=1},firstCamp=0,monsterList={},outData="",teamPassive={{}},teamSkill={}}} + + +-- local BattleMain = require("BattleMain") +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +-- local resultList = BattleMain.Execute({seed = os.time(), type = 2, maxRound = 20}, testFightData) +-- print(PrintTable(resultList)) +