diff --git a/conf/server/AdventureConfig.txt b/conf/server/AdventureConfig.txt index 4fa84c223..1ae81fc6e 100644 --- a/conf/server/AdventureConfig.txt +++ b/conf/server/AdventureConfig.txt @@ -1,7 +1,7 @@ -Id OpenLevel RecommendForce RecommendHeroIds MinNum BaseRewardGroup RandomRewardGroup RecommendRewardGroup -int int int mut,int#int,1 int mut,int#int,1 mut,int#int,1 mut,int#int,2 -1 102023 1000 2#1#2 5 101 111 4#121#6#122#8#123|4#124#6#125#8#126 -2 104030 2000 2#1#2 5 102 112 4#121#6#122#8#123|4#124#6#125#8#126 -3 109026 3000 2#1#2 5 103 113 4#121#6#122#8#123|4#124#6#125#8#126 -4 102001 4000 2#1#2 5 104 114 4#121#6#122#8#123|4#124#6#125#8#126 -5 102001 5000 2#1#2 5 105 115 4#121#6#122#8#123|4#124#6#125#8#126 +Id OpenLevel MaxNum BaseRewardGroup RandomRewardGroup NumIncome LeaveBonus +int int int mut,int#int,1 mut,int#int,1 mut,float#float,2 int +1 10 5 101 111 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +2 20 5 102 112 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +3 30 5 103 113 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +4 40 5 104 114 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +5 50 5 105 115 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 diff --git a/conf/server/AdventurePoolConfig.txt b/conf/server/AdventurePoolConfig.txt deleted file mode 100644 index 309fc9523..000000000 --- a/conf/server/AdventurePoolConfig.txt +++ /dev/null @@ -1,7 +0,0 @@ -Id Weight Pool -int int int -10001 100 1 -10002 100 1 -10003 100 1 -10004 100 1 -10005 100 2 diff --git a/conf/server/AdventureSetting.txt b/conf/server/AdventureSetting.txt deleted file mode 100644 index 10ded5b80..000000000 --- a/conf/server/AdventureSetting.txt +++ /dev/null @@ -1,7 +0,0 @@ -Id ConsumeGemRatio BaseRewardRatio RandomRewardRatio PerMapMaxHour HourRewardRatio -int mut,int#int,1 mut,float#float,2 mut,float#float,2 int mut,float#float,1 -1 0#0#50#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -2 0#0#55#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -3 0#0#60#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -4 0#0#70#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -5 0#0#80#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 diff --git a/conf/server/GameSetting.txt b/conf/server/GameSetting.txt index c6e311ddf..b585002df 100644 --- a/conf/server/GameSetting.txt +++ b/conf/server/GameSetting.txt @@ -1,3 +1,3 @@ Id BornItem SpeedFormula InitialEnergy EnergyRecoverSpeed ActionPowerRormula Speed HeroNumlimit EquipNumlimit WorldTalking BornPosition int mut,int#int,2 mut,float#float,1 int mut,int#int,1 mut,int#int,1 mut,int#int,1 int int int mut,int#int,1 -1 10008#1|10013#1|10023#1|1503#8 0#0#0.3164#0 100 60#1 0#0#1#0 70#100 999 9999 1 08#19 +1 10008#1|10013#1|10023#1|1503#8|2#60 0#0#0.3164#0 100 60#1 0#0#1#0 70#100 999 9999 1 08#19 diff --git a/luafight/BattleMain.lua b/luafight/BattleMain.lua index db8c96a60..a0808ca23 100644 --- a/luafight/BattleMain.lua +++ b/luafight/BattleMain.lua @@ -10,14 +10,14 @@ require("Modules.Battle.Logic.Misc.BattleObjectPool") require("Modules.Battle.Logic.Base.BattleEvent") 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") +require("Modules.Battle.Logic.BattleLogic") +require("Modules.Battle.Logic.RoleLogic") + local BattleMain = {} local BattleLogic = BattleLogic local Random = Random @@ -123,7 +123,7 @@ function BattleMain.Execute(seed, fightData, optionData) _fightData = fightData _optionData = optionData - print(PrintTable(fightData)) + --print(PrintTable(fightData)) --该开关用于输出战斗过程中的日志,用于验证前后端是否出现战斗不同步 BattleLogic.IsOpenBattleRecord = false diff --git a/luafight/Modules/Battle/Logic/Base/Buff.lua b/luafight/Modules/Battle/Logic/Base/Buff.lua index 5c6251311..cc2cb8dc0 100644 --- a/luafight/Modules/Battle/Logic/Base/Buff.lua +++ b/luafight/Modules/Battle/Logic/Base/Buff.lua @@ -18,6 +18,10 @@ local putBuff = function(buff) end end +local buffListPool = BattleObjectPool.New(function () + return BattleList.New() +end) + function Buff:New() local o = {} setmetatable(o, self) @@ -51,13 +55,24 @@ function BuffManager.New() return instance end -function BuffManager:Init(owner) - self.buffQueue:Clear() +function BuffManager:Init() + for i=1, self.buffQueue.size do + buffListPool:Put(self.buffQueue:Dequeue()) + end + local list + for i = 1, self.buffList.size do + list = self.buffList.vList[i] + for j=1, list.size do + putBuff(list.buffer[j]) + end + list:Clear() + buffListPool:Put(list) + end self.buffList:Clear() - self.owner = owner end -function BuffManager:AddBuff(buff) +function BuffManager:AddBuff(target, buff) + buff.target = target self.buffQueue:Enqueue(buff) if not buff.exCtrlTime then buff.exCtrlTime = 0 @@ -76,12 +91,13 @@ function BuffManager:AddBuff(buff) buff.frameInterval = floor(buff.interval * BattleLogic.GameFrameRate) end -function BuffManager:HasBuff(type, checkFunc) - local v +function BuffManager:HasBuff(target, type, checkFunc) + local v, buff for i=1, self.buffList:Count() do v = self.buffList.vList[i] if v.size > 0 then - if v.buffer[1].type == type and (not checkFunc or (checkFunc and checkFunc(v.buffer[1]))) then + buff = v.buffer[1] + if buff.target == target and buff.type == type and (not checkFunc or (checkFunc and checkFunc(buff))) then return true end end @@ -89,25 +105,23 @@ function BuffManager:HasBuff(type, checkFunc) return false end -function BuffManager:ClearBuff(func) +function BuffManager:ClearBuff(target, func) + local list, buff, idx for i = 1, self.buffList.size do - local k = self.buffList.kList[i] - local v = self.buffList.vList[i] - if v.size > 0 then - local removeCount = 0 - local idx = 1 - while idx <= v.size do - if func(v.buffer[idx]) then - putBuff:Put(v.buffer[idx]) - v:Remove(idx) - removeCount = removeCount + 1 + list = self.buffList.vList[i] + if list.size > 0 then + idx = 1 + while idx <= list.size do + buff = list.buffer[idx] + if buff.target == target and (not func or (func and func(buff))) then + buff:OnEnd() + buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buff) + putBuff(buff) + list:Remove(idx) else idx = idx + 1 end end - if removeCount > 0 then - self.owner.Event:DispatchEvent(BattleEventName.BuffCountChange, k, v.size) - end end end end @@ -122,42 +136,34 @@ end function BuffManager:Update() for i=1, self.buffQueue.size do local buff = self.buffQueue:Dequeue() - if not buff.caster then - --logErrorTrace("buff's caster can't be nil!") - return - end local buffList if not self.buffList.kvList[buff.id] then - buffList = BattleList.New() + buffList = buffListPool:Get() self.buffList:Add(buff.id, buffList) else buffList = self.buffList.kvList[buff.id] end if buff.cover and buffList.size > 0 then if buffList.buffer[1]:OnCover(buff) then --判定该效果能否被覆盖 - buffList.buffer[1]:OnEnd(self.owner) - self.owner.Event:DispatchEvent(BattleEventName.BuffEnd, buffList.buffer[1]) + buffList.buffer[1]:OnEnd() + buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buffList.buffer[1]) buffList.buffer[1] = buff - buff.target = self.owner buff:OnStart() - self.owner.Event:DispatchEvent(BattleEventName.BuffStart, buff) - self.owner.Event:DispatchEvent(BattleEventName.BuffCover, buff) + buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) + buff.target.Event:DispatchEvent(BattleEventName.BuffCover, buff) end else if buff.maxCount == 0 or buffList.size < buff.maxCount then --限制相同效果的数量,为0则不限制 buffList:Add(buff) - buff.target = self.owner buff:OnStart() - self.owner.Event:DispatchEvent(BattleEventName.BuffStart, buff) - self.owner.Event:DispatchEvent(BattleEventName.BuffCountChange, buff.id, buffList.size) + buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) end end end + local v for i = 1, self.buffList.size do - local k = self.buffList.kList[i] - local v = self.buffList.vList[i] + v = self.buffList.vList[i] if v.size > 0 then - local removeCount = 0 local idx = 1 local buff while idx <= v.size do @@ -193,16 +199,12 @@ function BuffManager:Update() if buff.disperse then buff:OnEnd() buff.target.Event:DispatchEvent(BattleEventName.BuffEnd, buff) - putBuff(v.buffer[idx]) + putBuff(buff) v:Remove(idx) - removeCount = removeCount + 1 else idx = idx + 1 end end - if removeCount > 0 then - self.owner.Event:DispatchEvent(BattleEventName.BuffCountChange, k, v.size) - end end end end diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index 3584f5208..b445ef03d 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -1,4 +1,6 @@ local floor = math.floor +local min = math.min +local max = math.max --local RoleDataName = RoleDataName --local BattleLogic = BattleLogic --local BattleUtil = BattleUtil @@ -119,7 +121,7 @@ local effectList = { end end, --[b]%改变[c]下次重击技能CD[a]秒 - --a[float],b[float] + --a[float],b[float],c[改变类型] [8] = function(caster, target, args, interval) local f1 = args[1] local f2 = args[2] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge))) @@ -131,13 +133,13 @@ local effectList = { target.skill.sp = target.skill.spPass else if ct == 1 then --加算 - target.skill.sp = target.skill.sp - floor(f1 * BattleLogic.GameFrameRate) + target.skill.sp = max(target.skill.sp - floor(f1 * BattleLogic.GameFrameRate), 0) elseif ct == 2 then --乘加算(百分比属性加算) - target.skill.sp = floor(target.skill.sp * (1 - f1)) + target.skill.sp = max(target.skill.sp - floor(target.skill.spPass * f1),0) elseif ct == 3 then --减算 - target.skill.sp = target.skill.sp + floor(f1 * BattleLogic.GameFrameRate) + target.skill.sp = min(target.skill.sp + floor(f1 * BattleLogic.GameFrameRate), target.skill.spPass) elseif ct == 4 then --乘减算(百分比属性减算) - target.skill.sp = floor(target.skill.sp * (1 + f1)) + target.skill.sp = min(target.skill.sp + floor(target.skill.spPass * f1), target.skill.spPass) end end end @@ -198,8 +200,8 @@ local effectList = { target:AddBuff(Buff.Create(caster, BuffName.DOT, f2, 1, 0, dt, f1)) end) end, - --造成[c],每秒造成[d]的[e]的伤害,持续[f]秒 - --c[持续伤害状态].d[float],e[伤害类型],f[int] + --造成[a],每秒造成[b]的[c]的伤害,持续[d]秒 + --a[持续伤害状态].b[float],c[伤害类型],d[int] [13] = function(caster, target, args, interval) local d1 = args[1] local f1 = args[2] @@ -223,7 +225,7 @@ local effectList = { end BattleLogic.WaitForTrigger(interval, function () local layer - if target.BuffMgr:HasBuff(BuffName.Brand, function (buff) + if BattleLogic.BuffMgr:HasBuff(target, BuffName.Brand, function (buff) local b = buff.flag == rid if b then layer = buff.layer @@ -354,7 +356,7 @@ local effectList = { BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, interval) end BattleLogic.WaitForTrigger(interval, function () - if target.BuffMgr:HasBuff(BuffName.Control, function (buff) return i1 == 0 or buff.ctrlType == i1 end) then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.Control, function (buff) return i1 == 0 or buff.ctrlType == i1 end) then f1 = f1 + f2 end BattleUtil.CalDamage(caster, target, dt, f1) @@ -371,7 +373,7 @@ local effectList = { local f3 = args[6] BattleLogic.WaitForTrigger(interval, function () BattleUtil.CalDamage(caster, target, dt, f1) - if target.BuffMgr:HasBuff(BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then BattleUtil.RandomAction(f2, function () target:AddBuff(Buff.Create(caster, BuffName.Control, f3, ct)) end) @@ -386,7 +388,7 @@ local effectList = { local dot = args[3] local f2 = args[4] BattleLogic.WaitForTrigger(interval, function () - if target.BuffMgr:HasBuff(BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then f1 = f1 + f2 end BattleUtil.CalDamage(caster, target, dt, f1) @@ -404,7 +406,7 @@ local effectList = { BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, interval) end BattleLogic.WaitForTrigger(interval, function () - if target.BuffMgr:HasBuff(BuffName.HOT, function (buff) return true end) then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.HOT, function (buff) return true end) then f1 = f1 + f2 end BattleUtil.CalDamage(caster, target, dt, f1) @@ -430,7 +432,7 @@ local effectList = { BattleLogic.WaitForTrigger(interval, function () local func = function(damage) - if target.BuffMgr:HasBuff(BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then damage = damage + floor(damage * f1) end return damage @@ -479,7 +481,7 @@ local effectList = { BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, interval) end BattleLogic.WaitForTrigger(interval, function () - if target.BuffMgr:HasBuff(BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.DOT, function (buff) return dot == 0 or buff.damageType == dot end) then f1 = f1 + f2 end BattleUtil.CalDamage(caster, target, dt, f1) @@ -524,7 +526,7 @@ local effectList = { BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, target, interval) end BattleLogic.WaitForTrigger(interval, function () - if target.BuffMgr:HasBuff(BuffName.Control, function (buff) return ct == 0 or buff.ctrlType == ct end) then + if BattleLogic.BuffMgr:HasBuff(target, BuffName.Control, function (buff) return ct == 0 or buff.ctrlType == ct end) then BattleUtil.CalDamage(caster, target, dt, f1, f2) else BattleUtil.CalDamage(caster, target, dt, f1) @@ -543,6 +545,18 @@ local effectList = { end) end) end, + --[b]%改变[d]重击技能CD[a]秒 ,持续[c]秒 (0代表清除所有) + --a[float],b[float],c[改变类型] + [32] = function(caster, target, args, interval) + local f1 = args[1] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge))) + local ib1 = args[2] + local f2 = args[3] + BattleLogic.WaitForTrigger(interval, function () + BattleUtil.RandomAction(f1, function () + target:AddBuff(Buff.Create(caster, BuffName.Immune, f2, ib1)) + end) + end) + end, } return effectList \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Base/Skill.lua b/luafight/Modules/Battle/Logic/Base/Skill.lua index 8ed67aace..5579dedce 100644 --- a/luafight/Modules/Battle/Logic/Base/Skill.lua +++ b/luafight/Modules/Battle/Logic/Base/Skill.lua @@ -200,12 +200,6 @@ function Skill:ResetCD() BattleLogic.SetAggro(self.owner, 0) end -local function takeEffect(type, caster, target, args, interval) - effect[type](caster, target, args, interval) - if BattleLogic.IsOpenBattleRecord then - BattleLogic.RecordEffect(caster, target, type, args, interval) - end -end function Skill:Cast() for i=1, self.effectList.size do local effectGroup = self.effectList.buffer[i] @@ -227,7 +221,10 @@ function Skill:Cast() for j=1, #arr do for k=1, #effectGroup[3] do local v = effectGroup[3][k] - takeEffect(v[1], self.owner, arr[j], v[2], duration) + effect[v[1]](self.owner, arr[j], v[2], duration) + --if BattleLogic.IsOpenBattleRecord then + -- BattleLogic.RecordEffect(v[1], self.owner, arr[j], v[2], duration) + --end end end elseif chooseId == 20000 then --敌方aoe @@ -235,14 +232,20 @@ function Skill:Cast() for j=1, #arr do for k=1, #effectGroup[3] do local v = effectGroup[3][k] - takeEffect(v[1], self.owner, arr[j], v[2], duration) + effect[v[1]](self.owner, arr[j], v[2], duration) + --if BattleLogic.IsOpenBattleRecord then + -- BattleLogic.RecordEffect(v[1], self.owner, arr[j], v[2], duration) + --end end end elseif nn == 1 or nn == 3 then for j=1, #arr do for k=1, #effectGroup[3] do local v = effectGroup[3][k] - takeEffect(v[1], self.owner, arr[j], v[2], duration) + effect[v[1]](self.owner, arr[j], v[2], duration) + --if BattleLogic.IsOpenBattleRecord then + -- BattleLogic.RecordEffect(v[1], self.owner, arr[j], v[2], duration) + --end end end else @@ -262,7 +265,10 @@ function Skill:Cast() r = arr[i] for k=1, #effectGroup[3] do local v = effectGroup[3][k] - takeEffect(v[1], self.owner, r, v[2], cd) + effect[v[1]](self.owner, r, v[2], cd) + --if BattleLogic.IsOpenBattleRecord then + -- BattleLogic.RecordEffect(v[1], self.owner, r, v[2], cd) + --end end return end @@ -275,7 +281,10 @@ function Skill:Cast() self.choosedList:Add(r) for k=1, #effectGroup[3] do local v = effectGroup[3][k] - takeEffect(v[1], self.owner, r, v[2], cd) + effect[v[1]](self.owner, r, v[2], cd) + --if BattleLogic.IsOpenBattleRecord then + -- BattleLogic.RecordEffect(v[1], self.owner, r, v[2], cd) + --end end end) end diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index f61f6755f..a67407354 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -21,6 +21,7 @@ local enemySkillUsable BattleLogic.IsEnd = false BattleLogic.Result = -1 BattleLogic.Event = BattleEvent.New() +BattleLogic.BuffMgr = BuffManager.New() local playerTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true} local enemyTeamDummyRole = {camp = 0, Event = BattleLogic.Event, isTeam = true} @@ -88,6 +89,7 @@ function BattleLogic.Init(data, optionData) enemySkillUsable = true BattleLogic.Event:ClearEvent() + BattleLogic.BuffMgr:Init() BattleLogic.IsEnd = false BattleLogic.Result = -1 end @@ -383,6 +385,8 @@ function BattleLogic.Update() enemyMP = 0 end + BattleLogic.BuffMgr:Update() + bMyAllDead = true bEnemyAllDead = true for i=1, objList.size do diff --git a/luafight/Modules/Battle/Logic/Buff/DOT.lua b/luafight/Modules/Battle/Logic/Buff/DOT.lua index 4b91309ec..9f76fe09f 100644 --- a/luafight/Modules/Battle/Logic/Buff/DOT.lua +++ b/luafight/Modules/Battle/Logic/Buff/DOT.lua @@ -9,6 +9,14 @@ function DOT:SetData(...) self.damagePro, --1 物理 2 魔法 self.damageFactor = ... --伤害系数 self.isDeBuff = true + + --if self.damageType == 2 then + -- self.cover = true + -- self.layer = 1 + --else + -- self.cover = false + -- self.layer = nil + --end end --初始化后调用一次 @@ -31,6 +39,10 @@ end --只有当cover字段为true时触发,返回true则被新效果覆盖 function DOT:OnCover(newBuff) --log("DOT:OnCover") + --if self.damageType == 2 then + -- newBuff.layer = self.layer + 1 + -- newBuff.damageFactor = + --end return true end diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 64c544ae6..5a9cb8c55 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -82,8 +82,12 @@ function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit) if defRole:GetRoleData(RoleDataName.Hp) <= 0 then defRole.isDead = true + BattleLogic.BuffMgr:ClearBuff(defRole) defRole.Event:DispatchEvent(BattleEventName.RoleDead) BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole) + if defRole.camp == 1 then + BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, BattleLogic.GetAggro(0), 0.3) + end end end return finalDmg diff --git a/luafight/Modules/Battle/Logic/RoleLogic.lua b/luafight/Modules/Battle/Logic/RoleLogic.lua index 0f51fec0b..ddaaeefcd 100644 --- a/luafight/Modules/Battle/Logic/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/RoleLogic.lua @@ -17,7 +17,7 @@ function RoleLogic.New() shield=BattleList.New(), exCalDmgList=BattleList.New(), buffFilter=BattleList.New(), - BuffMgr=BuffManager.New(),Event=BattleEvent:New(),passiveList=0,isDead=false,Auto=false,IsDebug=false,enable=false} + Event=BattleEvent:New(),passiveList=0,isDead=false,Auto=false,IsDebug=false,enable=false} setmetatable(instance, RoleLogic) return instance end @@ -36,7 +36,6 @@ function RoleLogic:Init(uid, data) self.exCalDmgList:Clear() --额外计算伤害列表 self.buffFilter:Clear() --buff屏蔽列表 - self.BuffMgr:Init(self) self.Event:ClearEvent() self.passiveList = {} @@ -71,12 +70,15 @@ function RoleLogic:GetRoleData(property) end function RoleLogic:AddBuff(buff) + if self.isDead then + return + end for i=1, self.buffFilter.size do if self.buffFilter.buffer[i](buff) then return end end - self.BuffMgr:AddBuff(buff) + BattleLogic.BuffMgr:AddBuff(self, buff) end function RoleLogic:Dispose() @@ -93,7 +95,6 @@ function RoleLogic:Dispose() end function RoleLogic:Update() - self.BuffMgr:Update() if not self.enable then return end diff --git a/serverlogic/src/main/java/com/ljsd/GameApplication.java b/serverlogic/src/main/java/com/ljsd/GameApplication.java index 8d582c96d..83339019d 100644 --- a/serverlogic/src/main/java/com/ljsd/GameApplication.java +++ b/serverlogic/src/main/java/com/ljsd/GameApplication.java @@ -74,8 +74,6 @@ public class GameApplication { MongoUtil.getInstence().init(configurableApplicationContext); - CombatLogic.getInstance().checkAdventureFlush(); - STableManager.initialize("com.ljsd.jieling.config"); //初始化邮件 MailingSystemManager.init(configurableApplicationContext); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java index be44fec71..faed64147 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java @@ -3,49 +3,39 @@ package com.ljsd.jieling.config; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; -import java.util.Arrays; -import java.util.HashSet; import java.util.Map; -import java.util.Set; @Table(name ="AdventureConfig") public class SAdventureConfig implements BaseConfig { - private static Map sAdventureConfigMap; private int id; private int openLevel; - private int recommendForce; - - private int[] recommendHeroIds; - - private int minNum; + private int maxNum; private int[] baseRewardGroup; private int[] randomRewardGroup; - private int[][] recommendRewardGroup; + private float[][] numIncome; + + private int leaveBonus; + + private static Map sAdventureConfigMap; @Override public void init() throws Exception { - - sAdventureConfigMap = STableManager.getConfig(SAdventureConfig.class); - - + sAdventureConfigMap = STableManager.getConfig(SAdventureConfig.class); } - public static SAdventureConfig getsAdventureConfigByPosition(int position) { - return sAdventureConfigMap.get(position); + public static SAdventureConfig getSAdventureConfigByPosition(int position){ + return sAdventureConfigMap.get(position); } - public static Map getsAdventureConfigMap() { - return sAdventureConfigMap; - } - public int getId() { + public int getId() { return id; } @@ -53,28 +43,25 @@ public class SAdventureConfig implements BaseConfig { return openLevel; } - public int getRecommendForce() { - return recommendForce; + public int getMaxNum() { + return maxNum; } - public int[] getRecommendHeroIds() { - return recommendHeroIds; - } - - public int getMinNum() { - return minNum; - } - - public int[] getBaseRewardGroup() { + public int[] getBaseRewardGroup() { return baseRewardGroup; } - public int[] getRandomRewardGroup() { + public int[] getRandomRewardGroup() { return randomRewardGroup; } - public int[][] getRecommendRewardGroup() { - return recommendRewardGroup; + public float[][] getNumIncome() { + return numIncome; } + public int getLeaveBonus() { + return leaveBonus; + } + + } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventurePoolConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventurePoolConfig.java deleted file mode 100644 index fa87a5b72..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventurePoolConfig.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.ljsd.jieling.config; - -import com.ljsd.jieling.logic.STableManager; -import com.ljsd.jieling.logic.Table; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Table(name ="AdventurePoolConfig") -public class SAdventurePoolConfig implements BaseConfig { - - private int id; - - private int weight; - - private int pool; - - private static Map> sAdventurePoolConfigListMap; - - @Override - public void init() throws Exception { - Map> sAdventurePoolConfigListMapTmp = new HashMap<>(); - Map config = STableManager.getConfig(SAdventurePoolConfig.class); - for(SAdventurePoolConfig sAdventurePoolConfig : config.values()){ - int pool = sAdventurePoolConfig.getPool(); - if(!sAdventurePoolConfigListMapTmp.containsKey(pool)){ - sAdventurePoolConfigListMapTmp.put(pool,new ArrayList<>()); - } - sAdventurePoolConfigListMapTmp.get(pool).add(sAdventurePoolConfig); - } - sAdventurePoolConfigListMap = sAdventurePoolConfigListMapTmp; - } - - public static List getsAdventurePoolConfigListByPool(int poolId) { - return sAdventurePoolConfigListMap.get(poolId); - } - - public int getId() { - return id; - } - - public int getWeight() { - return weight; - } - - public int getPool() { - return pool; - } - - -} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureSetting.java deleted file mode 100644 index fb62bd5b8..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureSetting.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.ljsd.jieling.config; - -import com.ljsd.jieling.logic.STableManager; -import com.ljsd.jieling.logic.Table; - -import java.util.Map; - -@Table(name ="AdventureSetting") -public class SAdventureSetting implements BaseConfig { - - private static Map sAdventureSettingMap; - - private int id; - - private int[] consumeGemRatio; - - private float[][] baseRewardRatio; - - private float[][] randomRewardRatio; - - private int perMapMaxHour; - - private float[] hourRewardRatio; - - - @Override - public void init() throws Exception { - sAdventureSettingMap = STableManager.getConfig(SAdventureSetting.class); - } - - public static SAdventureSetting getsAdventureSetting(int pooId) { - return sAdventureSettingMap.get(pooId); - } - - public int getId() { - return id; - } - - public int[] getConsumeGemRatio() { - return consumeGemRatio; - } - - public float[][] getBaseRewardRatio() { - return baseRewardRatio; - } - - public float[][] getRandomRewardRatio() { - return randomRewardRatio; - } - - public int getPerMapMaxHour() { - return perMapMaxHour; - } - - public float[] getHourRewardRatio() { - return hourRewardRatio; - } - - -} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java b/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java index 03286ac08..cf3780ec6 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/db/redis/RedisKey.java @@ -35,7 +35,11 @@ public class RedisKey { * 战斗缓存 * sub_key */ - public static final String FIGHT_MONSTERS = "MONSTERS"; + public static final String FIGHT_MONSTERS_1 = "MONSTERS_1"; + + public static final String FIGHT_MONSTERS_2 = "MONSTERS_2"; + + public static final String FIGHT_MONSTERS_3 = "MONSTERS_3"; /** * 战斗缓存 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java b/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java index 11aa33c12..54a86726e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/globals/Global.java @@ -27,4 +27,9 @@ public interface Global { int FIGHT_OPEND = 2; int FIGHT_OPEND_NO_CLEARANCE = 3; int FIGHT_CLEARANCE = 4; + + //怪物波次 + int MONSTER_1 = 0; + int MONSTER_2 = 1; + int MONSTER_3 = 2; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureRewardHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureRewardHandler.java deleted file mode 100644 index c4d60186d..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureRewardHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ljsd.jieling.handler.combat; - -import com.ljsd.jieling.handler.BaseHandler; -import com.ljsd.jieling.logic.fight.CombatLogic; -import com.ljsd.jieling.netty.cocdex.PacketNetData; -import com.ljsd.jieling.network.session.ISession; -import com.ljsd.jieling.protocols.FightInfoProto; -import com.ljsd.jieling.protocols.MessageTypeProto; -import org.springframework.stereotype.Component; - -import java.util.List; - - -@Component -public class AdventureRewardHandler extends BaseHandler { - @Override - public MessageTypeProto.MessageType getMessageCode() { - return MessageTypeProto.MessageType.ADVENTURE_REWARD_REQUEST; - } - - @Override - public void process(ISession iSession, PacketNetData netData) throws Exception { - byte[] bytes = netData.parseClientProtoNetData(); - FightInfoProto.TakeAventureRewardRequest takeAventureRewardRequest = FightInfoProto.TakeAventureRewardRequest.parseFrom(bytes); - int position = takeAventureRewardRequest.getPosition(); - CombatLogic.getInstance().clearStation(iSession,position); - } -} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureStationHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureStationHandler.java index 5412e846f..a0ec70fa9 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureStationHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureStationHandler.java @@ -23,7 +23,6 @@ public class AdventureStationHandler extends BaseHandler { FightInfoProto.AventureStationRequest aventureStationRequest = FightInfoProto.AventureStationRequest.parseFrom(bytes); int position = aventureStationRequest.getPosition(); List heroIdListList = aventureStationRequest.getHeroIdListList(); - int hourDuration = aventureStationRequest.getHourDuration(); - CombatLogic.getInstance().adventureStation(iSession,position,heroIdListList,hourDuration); + CombatLogic.getInstance().adventureStation(iSession,position,heroIdListList); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index 20dccf2dc..be485aa79 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -72,12 +72,6 @@ public class MapLogic { MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), ""); return; } - if (mapManager.getCurMapId() > 0) { - int leftTime = getLeftTime(user); - if (leftTime == 0) { - resetMapInfo(user, true); - } - } // 初始序章地图 if (user.getPlayerInfoManager().getMapId() == 0) { String error = initTeamInfo(teamId, uid, user, mapManager); @@ -111,24 +105,28 @@ public class MapLogic { MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "该地图不存在"); return; } - // TODO 可进入地图条件判断 -// int[][] openRule = sChallengeConfig.getOpenRule(); -// if (openRule != null && openRule.length > 0) { -// if (user.getPlayerInfoManager().getLevel() < openRule[0][1]) { -// MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要等级:" + openRule[0][1]); +// if (scMapConfig == null || scMapConfig.getOpenRule() == null || scMapConfig.getOpenRule().length == 0) { +// LOGGER.info("enterMap() uid=>{} mapId=>{}, scMapConfig.getOpenRule()=>{}", uid, mapId, scMapConfig == null ? "" : scMapConfig.getOpenRule()); +// MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), ""); +// return; +// } +// int missionId = scMapConfig.getOpenRule()[0]; +// if (!user.getMissionManager().getTakeRewardMissions().contains(missionId)) { +// Mission mission = user.getMissionManager().getDoingMissions().get(missionId); +// if (mission == null || mission.getMissionStep() < scMapConfig.getOpenRule()[1]) { +// LOGGER.info("enterMap() uid=>{} map not open == missionId =>{} step=>{}", uid, missionId, mission == null ? 0 : mission.getMissionStep()); +// MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要完成任务:" + (scMapConfig == null ? "" : scMapConfig.getOpenRule()[0] + "#" + scMapConfig.getOpenRule()[1])); // return; // } -// LevelDifficulty levelDifficulty = user.getLevelDifficultyManager().getLevelDifficultyInfosMap().get(openRule[0][0]); -// if (levelDifficulty == null && levelDifficulty.getState() != 4) { -// if (user.getPlayerInfoManager().getLevel() < openRule[0][1]) { -// MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "需要通关:" + openRule[0][0]); -// return; -// } -// } // } if (user.getPlayerInfoManager().getMapId() < mapId) { user.getPlayerInfoManager().setMapId(mapId); } + if (mapId > user.getPlayerInfoManager().getMapId()) { + LOGGER.info("enterMap() uid=>{} mapManager.getMaxMapId()=>{} mapId =>{} ", uid, user.getPlayerInfoManager().getMapId(), mapId); + MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), ""); + return; + } String error = initTeamInfo(teamId, uid, user, mapManager); if (!error.isEmpty()){ LOGGER.info("enterMap() uid=>{} error =>{} ", uid, error); @@ -169,7 +167,6 @@ public class MapLogic { if (mapManager.getTemporaryItems() != null) { mapEnterResponse.setTemporaryItems(CBean2Proto.getDrop(mapManager.getTemporaryItems())); } - LOGGER.info("enterMap() uid=>{} mapId =>{} ", uid, mapManager.getCurMapId()); MessageUtil.sendMessage(iSession, 1, messageType.getNumber(), mapEnterResponse.build(), true); } @@ -259,7 +256,6 @@ public class MapLogic { Mission mission = new Mission(); mission.setMissionId(challengeMapConfig.getMissionId()); mission.setMissionStep(0); - mission.setTime(0); mapManager.setMission(mission); mapManager.setMapInfo(newMap); mapManager.setTypeEight(spicelMap); @@ -304,13 +300,6 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } - if (mapManager.getCanMoveTime() > 0) { - long leftTime = mapManager.getCanMoveTime() - TimeUtils.now(); - if (leftTime > 0) { - MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "英雄 " + (leftTime / 1000) + " 秒后复活"); - return; - } - } if (mapManager.getStartExporeTime() == 0) { LOGGER.info("mapManager.getStartExporeTime() == 0"); MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "未开始探索"); @@ -366,13 +355,6 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "未开始探索"); return; } - if (mapManager.getCanMoveTime() > 0) { - long leftTime = mapManager.getCanMoveTime() - TimeUtils.now(); - if (leftTime > 0) { - MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "英雄 " + (leftTime / 1000) + " 秒后复活"); - return; - } - } Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); if (cell == null) { LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY()); @@ -531,7 +513,7 @@ public class MapLogic { } // LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{} {} sOptionConfig.getReward()=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(), // cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon,eventUpdateResponse.getDrop(), sOptionConfig.getReward()); -// LOGGER.info("updatEvent() uid=>{},nextEventId={},eventId={},mission=>{}", uid, nextEventId, cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMission()); + LOGGER.info("updatEvent() uid=>{},nextEventId={},eventId={},mission=>{}", uid, nextEventId, cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMission()); MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true); } @@ -672,7 +654,6 @@ public class MapLogic { .setItemId(mission.getMissionId()) .setMissionStep(mission.getMissionStep()) .setState("") - .setTime(mission.getTime()) .build(); return openMission; } @@ -693,17 +674,12 @@ public class MapLogic { return; } resetMapInfo(user, true); - MapMission mapMission = mapManager.getAllMissionProgress().get(mapId); - if(mapMission!=null){ - MapInfoProto.MapOutResponse build = MapInfoProto.MapOutResponse.newBuilder().setMapAccomplishInfo(CBean2Proto.getMapAccomplishInfo(mapMission)).build(); - MessageUtil.sendMessage(session, 1, messageType.getNumber(), build, true); - return; - } MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true); } public void resetMapInfo(User user, boolean needTemporaryItem) throws Exception { MapManager mapManager = user.getMapManager(); + mapManager.clearMapMission(); mapManager.setMapInfo(new HashMap<>()); mapManager.setTypeEight(new HashMap<>()); mapManager.setWalkCells(new HashSet<>()); @@ -711,8 +687,6 @@ public class MapLogic { mapManager.setCurMapId(0); mapManager.setStartExporeTime(0); mapManager.setTriggerXY(0); - mapManager.setDieCount(0); - mapManager.setCanMoveTime(0); mapManager.setFoodBufferMap(new HashMap<>()); TemporaryItems temporaryItems = mapManager.getTemporaryItems(); mapManager.setMission(null); @@ -736,13 +710,6 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } - if (mapManager.getCanMoveTime() > 0) { - long leftTime = mapManager.getCanMoveTime() - TimeUtils.now(); - if (leftTime > 0) { - MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "英雄 " + (leftTime / 1000) + " 秒后复活"); - return; - } - } Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); if (cell == null) { cell = mapManager.getMapInfo().get(mapManager.getCurXY()); @@ -808,25 +775,12 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "此战斗已结算过!"); return; } - MapManager mapManager = user.getMapManager(); - if (mapManager.getCanMoveTime() > 0) { - long leftTime = mapManager.getCanMoveTime() - TimeUtils.now(); - if (leftTime > 0) { - MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "英雄 " + (leftTime / 1000) + " 秒后复活"); - return; - } - } int seed = Integer.parseInt((String)valueMap.get(RedisKey.FIGHT_SEED)); int monsterGroupId = Integer.parseInt((String)valueMap.get(RedisKey.FIGHT_GROUPID)); CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder(); JsonFormat.merge((String)valueMap.get(RedisKey.FIGHT_HEROES), builder); CommonProto.FightTeamInfo fightTeamInfo = builder.build(); - CommonProto.FightTeamInfo.Builder monsterBuilder = CommonProto.FightTeamInfo.newBuilder(); - JsonFormat.merge((String)valueMap.get(RedisKey.FIGHT_MONSTERS), monsterBuilder); - CommonProto.FightTeamInfo monsterTeam = monsterBuilder.build(); - List monsterTeamList = new ArrayList<>(); - monsterTeamList.add(monsterTeam); - + List monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap); SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(monsterGroupId); if (sMonsterGroup == null) { LOGGER.info("endFight() uid=>{} monsterGroupId=>{} sMonsterGroup == null", uid, monsterGroupId); @@ -848,34 +802,12 @@ public class MapLogic { } //校验结果码 1:胜利 int resultCode = checkResult[0]; - if (resultCode == -1) { - resetMapInfo(user, false); - MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "战斗异常!"); + if (resultCode == -1){ + MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "战斗异常!"); return; - } else if (resultCode == 0) { - // 失败需要等待n秒后复活所有英雄 - int dieCount = mapManager.getDieCount(); - dieCount++; - mapManager.setDieCount(dieCount); - SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()); - int[] reviveTime = sChallengeConfig.getReviveTime(); - long time = (long) (MathUtils.calABX(dieCount, reviveTime) * 1000); - mapManager.setCanMoveTime(TimeUtils.now() + time); - int leftTime = getLeftTime(user); - if (leftTime <= (int) (time / 1000)) { - resetMapInfo(user, false); - } else { - List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(mapManager.getTeamId()); - for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) { - Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId()); - if (hero == null) { - continue; - } - Map heroAttributeMap = HeroLogic.getInstance().calHeroFinalAttribute(user, hero); - hero.setCurHp(heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())); - hero.setSpeed(heroAttributeMap.get(HeroAttributeEnum.Speed.getPropertyId())); - } - } + }else if(resultCode == 0){ + // 失败处理 +// resetMapInfo(user,true); CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder(); FightInfoProto.FightEndResponse fightEndResponse = FightInfoProto.FightEndResponse .newBuilder() @@ -886,7 +818,8 @@ public class MapLogic { MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse, true); return; } - int teamId = mapManager.getTeamId(); + + int teamId = user.getMapManager().getTeamId(); List team = user.getTeamPosManager().getTeamPosForHero().get(teamId); for (TeamPosHeroInfo teamPosHeroInfo : team){ Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId()); @@ -908,23 +841,23 @@ public class MapLogic { fightEndResponse.setMission(eventUpdateResponse.getMission()); } if (destoryId != 0) { - BehaviorUtil.destoryPoint(user, mapManager.getCurMapId(), destoryId); + BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), destoryId); } if (destoryXY != 0) { BehaviorUtil.destoryApointXY(user, destoryXY); } if (nextEventId != 0) { - int triggerXY = mapManager.getTriggerXY(); - Cell cell = mapManager.getMapInfo().get(triggerXY); + int triggerXY = user.getMapManager().getTriggerXY(); + Cell cell = user.getMapManager().getMapInfo().get(triggerXY); if (cell != null) { cell.setEventId(nextEventId); - mapManager.addOrUpdateCell(triggerXY, cell); - updateMapMission(mapManager,EventType.updateEvent,cell.getEventId(),0); + user.getMapManager().addOrUpdateCell(triggerXY, cell); + updateMapMission(user.getMapManager(),EventType.updateEvent,cell.getEventId(),0); } } -// LOGGER.info("endFight() uid=>{},nextEventId=>{}", uid, nextEventId); - updateMapMission(mapManager,EventType.fightEvent,0,monsterGroupId); -// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} drop=>{} mission=>{}", uid, sMonsterGroup.getRewardgroup(), fightEndResponse.getDrop(), fightEndResponse.getMission()); + LOGGER.info("endFight() uid=>{},nextEventId=>{}", uid, nextEventId); + updateMapMission(user.getMapManager(),EventType.fightEvent,0,monsterGroupId); +// LOGGER.info("endFight() uid=>{} sMonsterGroup.getRewardgroup()=>{} drop=>{}", uid, sMonsterGroup.getRewardgroup(), fightEndResponse.getDrop()); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true); } @@ -1087,34 +1020,6 @@ public class MapLogic { MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_ALL_MAP_ACCOMPLISH_RESPONSE_VALUE,build,true); } - - public void takeMissionBoxReward(ISession session,int mapId,int boxWeight) throws Exception { - int uid = session.getUid(); - User user = UserManager.getUser(uid); - MapManager mapManager = user.getMapManager(); - MapMission mapMission = mapManager.getAllMissionProgress().get(mapId); - if(mapMission == null ){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,""); - return; - } - SAccomplishmentBox sAccomplishmentBox = SAccomplishmentBox.getsAccomplishmentBoxByMapId(mapId); - int totalWeight = mapMission.getTotalWeight(); - Integer rewaedGroupId = sAccomplishmentBox.getBoxMap().get(boxWeight); - if(rewaedGroupId == null || totalWeight < boxWeight ){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,""); - return; - } - if(mapMission.getHadTakeRewardIds().contains(boxWeight)){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,"hadTaked"); - return; - } - mapMission.getHadTakeRewardIds().add(boxWeight); - mapMission.setHadTakeRewardIds(mapMission.getHadTakeRewardIds()); - CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[]{rewaedGroupId}, 1.0f, 0); - MapInfoProto.TakeMapBoxResponse build = MapInfoProto.TakeMapBoxResponse.newBuilder().setDrop(drop).build(); - MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_RESPONSE_VALUE,build,true); - } - public int getLeftTime(User user) throws Exception { SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId()); long startExporeTime = user.getMapManager().getStartExporeTime(); @@ -1123,28 +1028,17 @@ public class MapLogic { } int useTime = (int) ((TimeUtils.now() - startExporeTime) / 1000); if (useTime >= sChallengeConfig.getMapTime()) { + resetMapInfo(user, false); return 0; } else { return sChallengeConfig.getMapTime() - useTime; } } - public int getUseTime(User user) throws Exception { - long startExporeTime = user.getMapManager().getStartExporeTime(); - if (startExporeTime == 0) { - return -1; - } - int useTime = (int) ((TimeUtils.now() - startExporeTime) / 1000); - return useTime; - } - public CheckMissionReturn checkMission(Mission mission, User user) throws Exception { - if (mission.getTime() > 0) { - return null; - } - CheckMissionReturn checkMissionReturn = new CheckMissionReturn(); SMissionEventsConfig sMissionEventsConfig = SMissionEventsConfig.sMissionEventsConfigMap.get(mission.getMissionId()); mission.setMissionStep(mission.getMissionStep() + 1); + CheckMissionReturn checkMissionReturn = new CheckMissionReturn(); if (mission.getMissionStep() >= sMissionEventsConfig.getMissionNum()) { if (mission.getMissionInfo() != null) { checkMissionReturn.newEventId = mission.getMissionInfo(); @@ -1152,9 +1046,9 @@ public class MapLogic { int[] reward = {sMissionEventsConfig.getReward()}; CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, 1, 0); checkMissionReturn.drop = drop; - mission.setTime(getUseTime(user)); + } else { + user.getMapManager().setMission(mission); } - user.getMapManager().setMission(mission); checkMissionReturn.mission = mission; return checkMissionReturn; } @@ -1334,11 +1228,7 @@ public class MapLogic { CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder(); JsonFormat.merge((String)valueMap.get(RedisKey.FIGHT_HEROES), builder); CommonProto.FightTeamInfo fightTeamInfo = builder.build(); - CommonProto.FightTeamInfo.Builder monsterBuilder = CommonProto.FightTeamInfo.newBuilder(); - JsonFormat.merge((String)valueMap.get(RedisKey.FIGHT_MONSTERS), monsterBuilder); - CommonProto.FightTeamInfo monsterTeam = monsterBuilder.build(); - List monsterTeamList = new ArrayList<>(); - monsterTeamList.add(monsterTeam); + List monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap); SLevelDifficultyConfig sLevelDifficultyConfig = SLevelDifficultyConfig.getsLevelDifficultyConfigMap().get(fightId); if (sLevelDifficultyConfig == null) { @@ -1395,6 +1285,12 @@ public class MapLogic { MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true); } + private CommonProto.FightTeamInfo getFightTeamInfo(Map valueMap) throws JsonFormat.ParseException { + CommonProto.FightTeamInfo.Builder monsterBuilder = CommonProto.FightTeamInfo.newBuilder(); + JsonFormat.merge((String)valueMap.get(RedisKey.FIGHT_MONSTERS_1), monsterBuilder); + return monsterBuilder.build(); + } + /** * 开启关卡 * @param levelDifficultyManager diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapManager.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapManager.java index 7ac9f8f4a..9898695a0 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapManager.java @@ -203,6 +203,11 @@ public class MapManager extends MongoBase { allMissionProgress.put(mapMission.getMapId(),mapMission); } + public void clearMapMission(){ + removeString( getMongoKey()+".allMissionProgress." + curMapId); + allMissionProgress.remove(curMapId); + } + public static void getEnergy(User user) throws Exception { @@ -212,20 +217,35 @@ public class MapManager extends MongoBase { if (itemMap.containsKey(Global.STAMINA)) { itemNum = itemMap.get(Global.STAMINA).getItemNum(); } - MapManager mapManager = user.getMapManager(); - int lastUpdateEnergyTime = mapManager.getLastUpdateEnergyTime(); - if(itemNum < playerInfoManager.getMaxStamina()){ - int updateTime = (int)(System.currentTimeMillis()/1000); - int[] energyRecoverSpeed = SGameSetting.getGameSetting().getEnergyRecoverSpeed(); - int addValue = (updateTime - lastUpdateEnergyTime)/60/energyRecoverSpeed[1] * energyRecoverSpeed[0]; - if(addValue != 0){ - int curEnergy = MathUtils.setBetweenWithMax(itemNum + addValue,0,SGameSetting.getGameSetting().getInitialEnergy()); - ItemUtil.drop(user, StringUtil.parseFiledInt2( Global.STAMINA+"#"+curEnergy)); - mapManager.setLastUpdateEnergyTime(updateTime); + Item item = user.getItemManager().getItemMap().get(Global.STAMINA); + int updateTime = (int)(System.currentTimeMillis()/1000); + int lastUpdateEnergyTime = item.getEndingTime(); + if ((updateTime -lastUpdateEnergyTime)/60 >= 1){ + if(itemNum < playerInfoManager.getMaxStamina()){ + int[] energyRecoverSpeed = SGameSetting.getGameSetting().getEnergyRecoverSpeed(); + int addValue = (updateTime - lastUpdateEnergyTime)/60/energyRecoverSpeed[1] * energyRecoverSpeed[0]; + if(addValue != 0){ + int curEnergy = MathUtils.setBetweenWithMax(itemNum + addValue,0,SGameSetting.getGameSetting().getInitialEnergy()); + item.setItemNum(curEnergy>playerInfoManager.getMaxStamina()?playerInfoManager.getMaxStamina():curEnergy); + setLastUpdateEnergyTime(item, updateTime, lastUpdateEnergyTime); + } + }else { + setLastUpdateEnergyTime(item, updateTime, lastUpdateEnergyTime); } } } + private static void setLastUpdateEnergyTime(Item item, int updateTime, int lastUpdateEnergyTime) throws Exception { + int time = lastUpdateEnergyTime + ((updateTime -lastUpdateEnergyTime)/60 )* 60; + item.setEndingTime(time); + } + + public static void main(String [] args){ + int lastUpdateEnergyTime = 1552170600; + int nowTime = 1552170735; + int time = lastUpdateEnergyTime + ((nowTime -lastUpdateEnergyTime)/60 )* 60; + System.out.println(time); + } public void setLastUpdateEnergyTime(int lastUpdateEnergyTime) { updateString("lastUpdateEnergyTime", lastUpdateEnergyTime); this.lastUpdateEnergyTime = lastUpdateEnergyTime; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapMission.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapMission.java index 525ed68ba..d7ce50b8c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapMission.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapMission.java @@ -13,8 +13,6 @@ public class MapMission extends MongoBase { private Map allMissionProgress; - private Set hadTakeRewardIds; - private int totalWeight; public int getMapId() { @@ -31,7 +29,6 @@ public class MapMission extends MongoBase { this.setRootCollection(User._COLLECTION_NAME); this.mapId = mapId; this.allMissionProgress = missionProgress; - this.hadTakeRewardIds = new HashSet<>(); } @@ -44,9 +41,6 @@ public class MapMission extends MongoBase { this.allMissionProgress = allMissionProgress; } - public Set getHadTakeRewardIds() { - return hadTakeRewardIds; - } public void setTotalWeight(int totalWeight) { updateString("totalWeight",totalWeight); @@ -57,8 +51,4 @@ public class MapMission extends MongoBase { return totalWeight; } - public void setHadTakeRewardIds(Set hadTakeRewardIds) { - updateString("hadTakeRewardIds",hadTakeRewardIds); - this.hadTakeRewardIds = hadTakeRewardIds; - } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/TakeMapBoxRewardHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/TakeMapBoxRewardHandler.java deleted file mode 100644 index 6bc847a9e..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/TakeMapBoxRewardHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.ljsd.jieling.handler.map; - -import com.ljsd.jieling.handler.BaseHandler; -import com.ljsd.jieling.netty.cocdex.PacketNetData; -import com.ljsd.jieling.network.session.ISession; -import com.ljsd.jieling.protocols.MapInfoProto; -import com.ljsd.jieling.protocols.MessageTypeProto; -import org.springframework.stereotype.Component; - -@Component -public class TakeMapBoxRewardHandler extends BaseHandler { - @Override - public MessageTypeProto.MessageType getMessageCode() { - return MessageTypeProto.MessageType.TAKE_MAP_MISSION_BOX_REQUEST; - } - - @Override - public void process(ISession iSession, PacketNetData netData) throws Exception { - byte[] bytes = netData.parseClientProtoNetData(); - MapInfoProto.TakeMapBoxRequest takeMapBoxRequest = MapInfoProto.TakeMapBoxRequest.parseFrom(bytes); - int boxWeight = takeMapBoxRequest.getBoxWeight(); - int mapId = takeMapBoxRequest.getMapId(); - MapLogic.getInstance().takeMissionBoxReward(iSession,mapId,boxWeight); - } -} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java index 1b78463e4..fd482cf4e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/behavior/BehaviorUtil.java @@ -4,6 +4,7 @@ import com.googlecode.protobuf.format.JsonFormat; import com.ljsd.jieling.config.MapPointConfig; import com.ljsd.jieling.db.redis.RedisKey; import com.ljsd.jieling.db.redis.RedisUtil; +import com.ljsd.jieling.globals.Global; import com.ljsd.jieling.handler.map.Cell; import com.ljsd.jieling.handler.map.MapLogic; import com.ljsd.jieling.handler.map.MapManager; @@ -95,9 +96,55 @@ public class BehaviorUtil { MapManager mapManager = user.getMapManager(); int teamId = mapManager.getTeamId(); - List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); - List heroFightInfos = new ArrayList<>(); CommonProto.FightData.Builder fightData = CommonProto.FightData.newBuilder(); + CommonProto.FightTeamInfo fightTeamInfo = getFightTeamInfo(user, teamId); + fightData.setHeroFightInfos(fightTeamInfo); + //monster + Map> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId); + List monsterGroupList = getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_1); + List monsterGroupList1 = getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_2); + List monsterGroupList2 = getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_3); + fightData.addAllMonsterList(monsterGroupList).addAllMonsterList(monsterGroupList1).addAllMonsterList(monsterGroupList2); + //设置战斗随机种子 + int seed = (int)(System.currentTimeMillis()/1000); +// int seed = 1553167956; + fightData.setFightSeed(seed); + fightStartRespons.setFightData(fightData); + + String key = RedisKey.getKey(RedisKey.FIGHT, user.getId(), false); + Map fightInfo = new HashMap<>(); + + fightInfo.put(RedisKey.FIGHT_HEROES, JsonFormat.printToString(fightTeamInfo)); + fightInfo.put(RedisKey.FIGHT_MONSTERS_1, JsonFormat.printToString(monsterGroupList.get(0))); + if (monsterGroupList1.size() != 0){ + fightInfo.put(RedisKey.FIGHT_MONSTERS_2, JsonFormat.printToString(monsterGroupList1.get(0))); + } + if (monsterGroupList2.size() != 0){ + fightInfo.put(RedisKey.FIGHT_MONSTERS_3, JsonFormat.printToString(monsterGroupList2.get(0))); + } + fightInfo.put(RedisKey.FIGHT_SEED,Integer.toString(seed)); + fightInfo.put(RedisKey.FIGHT_GROUPID, Integer.toString(groupId)); + fightInfo.put(RedisKey.NEED_MISSION_ID, missionId); + fightInfo.put(RedisKey.NEED_DESORY_ID, destoryId); + fightInfo.put(RedisKey.NEED_DESORY_XY, Integer.toString(destoryXY)); + fightInfo.put(RedisKey.NEXT_EVENT_ID, nextEventId); + RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME); + + +// ISession session = OnlineUserManager.getSessionByUid(Integer.parseInt(user.getId())); +// MapLogic.getInstance().endFight(session,"", MessageTypeProto.MessageType.FIGHT_END_RESPONSE); + + } + + /** + * 获取FightUnitInfo + * @param user + * @param teamId + * @return + */ + private static CommonProto.FightTeamInfo getFightTeamInfo(User user, int teamId) { + List heroFightInfos = new ArrayList<>(); + List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) { Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId()); if (hero == null) { @@ -120,42 +167,7 @@ public class BehaviorUtil { .addAllFightUnitList(heroFightInfos) .setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(user,teamId)) .build(); - fightData.setHeroFightInfos(fightTeamInfo); - //monster - List monsterByGroup = MonsterUtil.getMonsterByGroup(groupId); - String monsterTeamSkill = MonsterUtil.getMonsterTeamSkillByGroup(groupId); - List monsterGroupList = new ArrayList<>(); - CommonProto.FightTeamInfo monsterTeamInfo = CommonProto.FightTeamInfo - .newBuilder() - .addAllFightUnitList(monsterByGroup) - .setTeamSkillList(monsterTeamSkill) - .build(); - monsterGroupList.add(monsterTeamInfo); - fightData.addAllMonsterList(monsterGroupList); - - //设置战斗随机种子 - int seed = (int)(System.currentTimeMillis()/1000); -// int seed = 1553167956; - fightData.setFightSeed(seed); - fightStartRespons.setFightData(fightData); - - String key = RedisKey.getKey(RedisKey.FIGHT, user.getId(), false); - Map fightInfo = new HashMap<>(); - - fightInfo.put(RedisKey.FIGHT_HEROES, JsonFormat.printToString(fightTeamInfo)); - fightInfo.put(RedisKey.FIGHT_MONSTERS, JsonFormat.printToString(monsterGroupList.get(0)));//暂时没考虑多拨怪 - fightInfo.put(RedisKey.FIGHT_SEED,Integer.toString(seed)); - fightInfo.put(RedisKey.FIGHT_GROUPID, Integer.toString(groupId)); - fightInfo.put(RedisKey.NEED_MISSION_ID, missionId); - fightInfo.put(RedisKey.NEED_DESORY_ID, destoryId); - fightInfo.put(RedisKey.NEED_DESORY_XY, Integer.toString(destoryXY)); - fightInfo.put(RedisKey.NEXT_EVENT_ID, nextEventId); - RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME); - - -// ISession session = OnlineUserManager.getSessionByUid(Integer.parseInt(user.getId())); -// MapLogic.getInstance().endFight(session,"", MessageTypeProto.MessageType.FIGHT_END_RESPONSE); - + return fightTeamInfo; } /** @@ -207,44 +219,15 @@ public class BehaviorUtil { } public static void getLevelDifficultyifficuFightInfo(User user,int groupId,int teamId, FightInfoProto.FightStartResponse.Builder fightStartRespons) { - List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); - List heroFightInfos = new ArrayList<>(); CommonProto.FightData.Builder fightData = CommonProto.FightData.newBuilder(); - for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) { - Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId()); - if (hero == null) { - continue; - } - StringBuilder skillSb = new StringBuilder(); - StringBuilder propertySb = new StringBuilder(); - String heroSkill = HeroLogic.getInstance().getHeroSkills(hero,skillSb).toString(); - String property = HeroLogic.getInstance().getHeroProperty(user,hero,propertySb).toString(); - CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo - .newBuilder() - .setUnitId(Integer.toString(hero.getTemplateId())) - .setUnitSkillIds(heroSkill.substring(0,heroSkill.length()-1)) - .setProperty(property.substring(0, property.length()-1)) - .build(); - heroFightInfos.add(heroFightInfo); - } - CommonProto.FightTeamInfo fightTeamInfo = CommonProto.FightTeamInfo. - newBuilder() - .addAllFightUnitList(heroFightInfos) - .setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(user,teamId)) - .build(); + CommonProto.FightTeamInfo fightTeamInfo = getFightTeamInfo(user, teamId); fightData.setHeroFightInfos(fightTeamInfo); - //monster - List monsterByGroup = MonsterUtil.getMonsterByGroup(groupId); - String monsterTeamSkill = MonsterUtil.getMonsterTeamSkillByGroup(groupId); - List monsterGroupList = new ArrayList<>(); - CommonProto.FightTeamInfo monsterTeamInfo = CommonProto.FightTeamInfo - .newBuilder() - .addAllFightUnitList(monsterByGroup) - .setTeamSkillList(monsterTeamSkill) - .build(); - monsterGroupList.add(monsterTeamInfo); - fightData.addAllMonsterList(monsterGroupList); + Map> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId); + List monsterGroupList = getFightTeamInfos(groupId,monsterByGroup,0); + List monsterGroupList1 = getFightTeamInfos(groupId,monsterByGroup,1); + List monsterGroupList2 = getFightTeamInfos(groupId,monsterByGroup,2); + fightData.addAllMonsterList(monsterGroupList).addAllMonsterList(monsterGroupList1).addAllMonsterList(monsterGroupList2); //设置战斗随机种子 int seed = (int)(System.currentTimeMillis()/1000); @@ -254,9 +237,14 @@ public class BehaviorUtil { String key = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_FIGHT, user.getId(), false); Map fightInfo = new HashMap<>(); - fightInfo.put(RedisKey.FIGHT_HEROES, JsonFormat.printToString(fightTeamInfo)); - fightInfo.put(RedisKey.FIGHT_MONSTERS, JsonFormat.printToString(monsterGroupList.get(0)));//暂时没考虑多拨怪 + fightInfo.put(RedisKey.FIGHT_MONSTERS_1, JsonFormat.printToString(monsterGroupList.get(0))); + if (monsterGroupList1.size() != 0){ + fightInfo.put(RedisKey.FIGHT_MONSTERS_2, JsonFormat.printToString(monsterGroupList1.get(0))); + } + if (monsterGroupList2.size() != 0){ + fightInfo.put(RedisKey.FIGHT_MONSTERS_3, JsonFormat.printToString(monsterGroupList2.get(0))); + } fightInfo.put(RedisKey.FIGHT_SEED,Integer.toString(seed)); fightInfo.put(RedisKey.FIGHT_GROUPID, Integer.toString(groupId)); fightInfo.put(RedisKey.NEED_MISSION_ID, Integer.toString(0)); @@ -265,4 +253,48 @@ public class BehaviorUtil { fightInfo.put(RedisKey.NEXT_EVENT_ID, Integer.toString(0)); RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME); } + + /** + * h获取fightTeamInfo + * @param groupId + * @return + */ + public static List getFightTeamInfos(int groupId,Map> monsterByGroup,int mosterNum) { + String monsterTeamSkill = MonsterUtil.getMonsterTeamSkillByGroup(groupId); + List monsterGroupList = new ArrayList<>(); + if (monsterByGroup.size() > mosterNum){ + CommonProto.FightTeamInfo monsterTeamInfo = CommonProto.FightTeamInfo.newBuilder().addAllFightUnitList(monsterByGroup.get(mosterNum)).setTeamSkillList(monsterTeamSkill).build(); + monsterGroupList.add(monsterTeamInfo); + } + return monsterGroupList; + } + + /** + * 获取多波怪物信息 + * @param valueMap + * @return + * @throws JsonFormat.ParseException + */ + public static List getFightTeamInfos(Map valueMap) throws JsonFormat.ParseException { + List monsterTeamList = new ArrayList<>(); + CommonProto.FightTeamInfo.Builder monsterBuilder = CommonProto.FightTeamInfo.newBuilder(); + JsonFormat.merge((String)valueMap.get(RedisKey.FIGHT_MONSTERS_1), monsterBuilder); + CommonProto.FightTeamInfo monsterTeam = monsterBuilder.build(); + monsterTeamList.add(monsterTeam); + String info = (String)valueMap.get(RedisKey.FIGHT_MONSTERS_2); + if (info !=null){ + CommonProto.FightTeamInfo.Builder monsterBuilder1 = CommonProto.FightTeamInfo.newBuilder(); + JsonFormat.merge(info, monsterBuilder1); + CommonProto.FightTeamInfo monsterTeam1 = monsterBuilder.build(); + monsterTeamList.add(monsterTeam1); + } + String info1 = (String)valueMap.get(RedisKey.FIGHT_MONSTERS_3); + if (info1!= null){ + CommonProto.FightTeamInfo.Builder monsterBuilder2 = CommonProto.FightTeamInfo.newBuilder(); + JsonFormat.merge(info1, monsterBuilder2); + CommonProto.FightTeamInfo monsterTeam2 = monsterBuilder.build(); + monsterTeamList.add(monsterTeam2); + } + return monsterTeamList; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java index f6d51c339..e589fe609 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java @@ -1,6 +1,7 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.MongoBase; +import com.ljsd.jieling.handler.map.TemporaryItems; import com.ljsd.jieling.logic.dao.root.User; @@ -10,63 +11,40 @@ import java.util.Map; public class AdventureManager extends MongoBase { private Map adventureStateInfoMap; - private Map allowTimeMap; - private long updateTime; + private Map tempDropRatio = new HashMap<>(); public AdventureManager(){ this.setRootCollection(User._COLLECTION_NAME); adventureStateInfoMap = new HashMap<>(); - allowTimeMap = new HashMap<>(); } - public void station(AdventureStateInfo adventureStateInfo,int allowTime) throws Exception { + public void station(AdventureStateInfo adventureStateInfo) throws Exception { int position = adventureStateInfo.getPosition(); updateString("adventureStateInfoMap." + position, adventureStateInfo); - updateString("allowTimeMap." + position, allowTime); adventureStateInfoMap.put(position,adventureStateInfo); - allowTimeMap.put(position,allowTime); } - public void clearStation(int position){ - AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(position); - if (adventureStateInfo!=null){ - removeString(getMongoKey() +".adventureStateInfoMap." + position); - removeString(getMongoKey() +".allowTimeMap." + position); - adventureStateInfoMap.remove(position); - allowTimeMap.remove(position); - } + public Map getTempDropRation() { + return tempDropRatio; + } + public void updateTemp(int dropIds[],float ratio){ + tempDropRatio.put(dropIds,ratio); + updateString("tempDropRatio."+dropIds,ratio); + } + + public void clearTemp(){ + tempDropRatio.clear(); + updateString("tempDropRatio",new HashMap<>()); } public Map getAdventureStateInfoMap() { return adventureStateInfoMap; } - public void setAdventureStateInfoMap(Map adventureStateInfoMap) { - this.adventureStateInfoMap = adventureStateInfoMap; - } - - public void updateAllowTime(int position,int allowTime){ - updateString("allowTimeMap." + position, allowTime); - allowTimeMap.put(position,allowTime); - } - - public void setUpdateTime(long updateTime) { - updateString("updateTime",updateTime); - this.updateTime = updateTime; - } - - public void setAllowTimeMap(Map allowTimeMap) { - updateString("allowTimeMap.",allowTimeMap); - this.allowTimeMap = allowTimeMap; - } - - public long getUpdateTime() { - return updateTime; - } - - public Map getAllowTimeMap() { - return allowTimeMap; + public void clearStation(int position) { + removeString(getMongoKey()+".adventureStateInfoMap." + position); + adventureStateInfoMap.remove(position); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java index 1fc6df165..326b2b623 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java @@ -1,8 +1,6 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.MongoBase; -import com.ljsd.jieling.config.SAdventureSetting; -import com.ljsd.jieling.config.SVipLevelConfig; import com.ljsd.jieling.logic.dao.root.User; import java.util.List; @@ -11,24 +9,15 @@ public class AdventureStateInfo extends MongoBase { private int position; private List heroIds; private int startTime; - private int hourDuration; - - - private int totalForce; - private int myRecommendHeroSize; - public AdventureStateInfo(){ this.setRootCollection(User._COLLECTION_NAME); } - public AdventureStateInfo(int position,List heroIds, int startTime, int hourDuration,int totalForce,int myRecommendHeroSize) { + public AdventureStateInfo(int position,List heroIds, int startTime) { this.setRootCollection(User._COLLECTION_NAME); this.heroIds = heroIds; this.startTime = startTime; - this.hourDuration = hourDuration; this.position = position; - this.totalForce = totalForce; - this.myRecommendHeroSize = myRecommendHeroSize; } public List getHeroIds() { @@ -39,19 +28,13 @@ public class AdventureStateInfo extends MongoBase { return startTime; } - public int getHourDuration() { - return hourDuration; - } - public int getPosition() { return position; } - public int getTotalForce() { - return totalForce; - } + public void setStartTime(int startTime) { + updateString("startTime",startTime); + this.startTime = startTime; - public int getMyRecommendHeroSize() { - return myRecommendHeroSize; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java index 704ea14b5..a7e0d1057 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java @@ -1,16 +1,12 @@ package com.ljsd.jieling.logic.fight; -import com.ljsd.GameApplication; import com.ljsd.jieling.config.*; import com.ljsd.jieling.core.GlobalsDef; -import com.ljsd.jieling.db.mongo.MongoUtil; import com.ljsd.jieling.handler.map.MapManager; import com.ljsd.jieling.logic.dao.*; -import com.ljsd.jieling.logic.dao.root.AdventureSeasonInfo; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.UserManager; -import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.FightInfoProto; @@ -24,9 +20,6 @@ import java.util.*; public class CombatLogic { private static final Logger LOGGER = LoggerFactory.getLogger(CombatLogic.class); - private static AdventureSeasonInfo adventureSeasonInfoCache; - private static List adventureRecommendHeroInfos ; - private CombatLogic(){} @@ -39,149 +32,57 @@ public class CombatLogic { return CombatLogic.Instance.instance; } - - private void getAdventureRecommendHeroInfos( Map> recommendFinalHeroMap){ - - adventureRecommendHeroInfos = new ArrayList<>(recommendFinalHeroMap.size()); - for(Map.Entry> item : recommendFinalHeroMap.entrySet()){ - Integer key = item.getKey(); - Set value = item.getValue(); - adventureRecommendHeroInfos.add(CommonProto.AdventureRecommendHeroInfo.newBuilder().setPositionId(key).addAllRecommenedId(value).build()); - } - } - - - - //冒险模式 加成英雄刷新 - public void checkAdventureFlush() throws Exception { - AdventureSeasonInfo adventureSeasonInfo = MongoUtil.getInstence().getMyMongoTemplate().findById(AdventureSeasonInfo._COLLECTION_NAME, Integer.toString(GameApplication.serverId), AdventureSeasonInfo.class); - if(adventureSeasonInfo!=null){ - if(adventureSeasonInfoCache == null || adventureSeasonInfo.getUpdateTime()!=adventureSeasonInfoCache.getUpdateTime()){ - adventureSeasonInfoCache = adventureSeasonInfo; - getAdventureRecommendHeroInfos(adventureSeasonInfo.getRecommendFinalHeroMap()); - } - if(TimeUtils.isSameDayWithNow(adventureSeasonInfo.getUpdateTime())){ - return; - } - } - Map> recommendFinalHeroMap = new HashMap<>(); - Map sAdventureConfigMap = SAdventureConfig.getsAdventureConfigMap(); - for(SAdventureConfig sAdventureConfig : sAdventureConfigMap.values()){ - int[] recommendHeroIds = sAdventureConfig.getRecommendHeroIds(); - int recommendNums = recommendHeroIds[0]; - int randomPoolId = recommendHeroIds[1]; - int mustPoolId = recommendHeroIds[2]; - int leftNums = recommendNums; - Set recommendFinalHeroIds = new HashSet<>(recommendNums); - recommendFinalHeroMap.put(sAdventureConfig.getId(),recommendFinalHeroIds); - if(mustPoolId!=0){ - List sAdventurePoolConfigs = SAdventurePoolConfig.getsAdventurePoolConfigListByPool(mustPoolId); - for(SAdventurePoolConfig sAdventurePoolConfig : sAdventurePoolConfigs){ - recommendFinalHeroIds.add(sAdventurePoolConfig.getId()); - leftNums --; - } - } - - if(leftNums>0){ - List sAdventurePoolConfigs = SAdventurePoolConfig.getsAdventurePoolConfigListByPool(randomPoolId); - int totalWeight = 0; - for(SAdventurePoolConfig sAdventurePoolConfig : sAdventurePoolConfigs){ - totalWeight+=sAdventurePoolConfig.getWeight(); - } - while (leftNums>0){ - int randomWeight = MathUtils.randomInt(totalWeight)+1; - for(SAdventurePoolConfig sAdventurePoolConfig : sAdventurePoolConfigs){ - randomWeight-=sAdventurePoolConfig.getWeight(); - if(randomWeight<=0){ - recommendFinalHeroIds.add(sAdventurePoolConfig.getId()); - leftNums--; - break; - } - } - } - } - } - if(adventureSeasonInfo == null){ - adventureSeasonInfo = new AdventureSeasonInfo(); - } - adventureSeasonInfo.setRecommendFinalHeroMap(recommendFinalHeroMap); - adventureSeasonInfo.setUpdateTime(System.currentTimeMillis()); - adventureSeasonInfoCache = adventureSeasonInfo; - getAdventureRecommendHeroInfos(adventureSeasonInfo.getRecommendFinalHeroMap()); - MongoUtil.getInstence().getMyMongoTemplate().save(adventureSeasonInfo); - - } //冒险模式 public void getAdventureStateInfo(ISession session) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); - flushAdventureTime(user); AdventureManager adventureManager = user.getAdventureManager(); Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); List result = new ArrayList<>(); - Map allowTimeMap = adventureManager.getAllowTimeMap(); - for(Map.Entry item : allowTimeMap.entrySet()){ - Integer position = item.getKey(); - Integer allowTime = item.getValue(); - AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(position); - result.add(CBean2Proto.getAdventureStateInfo(adventureStateInfo,position,allowTime)); + CommonProto.Drop.Builder dropBuilder = calAdvenrureReward(user, false,0); + for(AdventureStateInfo item : adventureStateInfoMap.values()){ + result.add(CBean2Proto.getAdventureStateInfo(item,item.getPosition())); } - - FightInfoProto.GetAdventureStateInfoResponse response = FightInfoProto.GetAdventureStateInfoResponse.newBuilder().addAllAdventureStateInfoList(result).addAllAdventureRecommendHeroInfo(adventureRecommendHeroInfos). - build(); + FightInfoProto.GetAdventureStateInfoResponse response = FightInfoProto.GetAdventureStateInfoResponse.newBuilder().addAllAdventureStateInfoList(result).setDrop(dropBuilder.build()).build(); MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_ADVENTURE_INFO_RESPONSE_VALUE,response,true); } - public void adventureStation(ISession session,int position,List heroIds,int hourDuration) throws Exception { - if(heroIds == null || heroIds.isEmpty()){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,""); - return; - } - int uid = session.getUid(); + public void adventureStation(ISession session,int position,List heroIds) throws Exception { + int uid = session.getUid(); User user = UserManager.getUser(uid); - SAdventureConfig sAdventureConfig = SAdventureConfig.getsAdventureConfigByPosition(position); - /* if(sAdventureConfig.getOpenLevel() > user.getPlayerInfoManager().getLevel()){ + SAdventureConfig sAdventureConfig = SAdventureConfig.getSAdventureConfigByPosition(position); + if(sAdventureConfig.getOpenLevel() > user.getPlayerInfoManager().getLevel()){ MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"等级不够"); return; - }*/ - - - if(sAdventureConfig.getMinNum() > heroIds.size()){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"英雄数量小于规定数量"); - return; } - - SAdventureSetting sAdventureSetting = SAdventureSetting.getsAdventureSetting(position); - if(hourDuration > sAdventureSetting.getPerMapMaxHour()){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"超出时长"); - return; - } - AdventureManager adventureManager = user.getAdventureManager(); //检验 Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); - AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position); - if(adventureStateInfo!=null){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"已驻扎"); + if(heroIds == null || heroIds.isEmpty()){ + if(!adventureStateInfoMap.containsKey(position)){ + MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,""); + return; + } + calAdvenrureReward(user,true,position); + adventureManager.clearStation(position); + MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,null,true); return; } - int allowTime =0; - if(!adventureManager.getAllowTimeMap().containsKey(position)){ - int vipLevel = user.getPlayerInfoManager().getVipLevel(); - allowTime = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel).getPrivilegeMap().get(1) -hourDuration; - }else{ - Integer remainAllowTime = adventureManager.getAllowTimeMap().get(position); - allowTime = remainAllowTime - hourDuration; - } - if(allowTime<0){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"超过时间"); + if(heroIds.size()>sAdventureConfig.getMaxNum()){ + MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"英雄数量大于规定数量"); return; } + + for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()){ + int positionTmp = adventureStateInfoTmp.getPosition(); + if(position == positionTmp){ + continue; + } List heroIds1 = adventureStateInfoTmp.getHeroIds(); for(String useHeroId : heroIds1){ if(heroIds.contains(useHeroId)){ @@ -191,117 +92,76 @@ public class CombatLogic { } } } - HeroManager heroManager = user.getHeroManager(); - int myRecommendHeroSize=0; - int totalForce=0; - Set recommendHeroSets =adventureSeasonInfoCache.getRecommendFinalHeroMap().get(position); - Set cacheHeroTid = new HashSet<>(recommendHeroSets.size()); - for(String heroId : heroIds){ - Hero hero = heroManager.getHero(heroId); - int templateId = hero.getTemplateId(); - if(recommendHeroSets.contains(templateId) && !cacheHeroTid.contains(templateId)){ - cacheHeroTid.add(templateId); - myRecommendHeroSize++; + if(adventureManager.getAdventureStateInfoMap().containsKey(position)){ + AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position); + if(adventureStateInfo.getHeroIds()!=null && !adventureStateInfo.getHeroIds().isEmpty()){ + calAdvenrureReward(user,true,position); } - totalForce += HeroLogic.getInstance().calHeoForce(user,hero); } - - adventureManager.station(new AdventureStateInfo(position,heroIds,(int)(System.currentTimeMillis()/1000),hourDuration,totalForce,myRecommendHeroSize),allowTime); - if(adventureManager.getUpdateTime() == 0){ - adventureManager.setUpdateTime(System.currentTimeMillis()); - } - + adventureManager.station(new AdventureStateInfo(position,heroIds,(int)(System.currentTimeMillis()/1000))); //发送成功 MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,null,true); } - private void flushAdventureTime( User user ){ + public void calAdventureRewardByHeroChange(User user,Set heroIds) throws Exception { AdventureManager adventureManager = user.getAdventureManager(); - long updateTime = adventureManager.getUpdateTime(); - if(updateTime ==0 || TimeUtils.isSameDayWithNow(updateTime)){ - return; - } - int vipLevel = user.getPlayerInfoManager().getVipLevel(); - int allowTime = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel).getPrivilegeMap().get(1); - Map allowTimeMap = adventureManager.getAllowTimeMap(); - if(allowTimeMap!=null && !allowTimeMap.isEmpty()){ - Map result = new HashMap<>(); - for(Integer position : allowTimeMap.keySet()){ - result.put(position,allowTime); + //检验 + Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); + for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()){ + List heroIdsOccupy = adventureStateInfoTmp.getHeroIds(); + boolean remove = heroIdsOccupy.removeAll(heroIds); + if(remove){ + //提前结算 + int position = adventureStateInfoTmp.getPosition(); + calAdvenrureReward(user,true,position); + adventureManager.station(new AdventureStateInfo(adventureStateInfoTmp.getPosition(),heroIdsOccupy,(int)(System.currentTimeMillis()/1000))); } - adventureManager.setUpdateTime(System.currentTimeMillis()); - adventureManager.setAllowTimeMap(result); } } - - public void clearStation(ISession session,int position) throws Exception { - int uid = session.getUid(); - User user = UserManager.getUser(uid); + //消耗道具全部加一遍基础奖励。 + public CommonProto.Drop.Builder calAdvenrureReward(User user, boolean isOnLine,int position) throws Exception { + Map tempDropRation = new HashMap<>(); AdventureManager adventureManager = user.getAdventureManager(); - AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position); - if( null == adventureStateInfo ){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,""); - return; - } - int startTime = adventureStateInfo.getStartTime(); - int hourDuration = adventureStateInfo.getHourDuration(); + Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); int now = (int)(System.currentTimeMillis()/1000); - if( (now - startTime ) /3600 < hourDuration ){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,"驻扎时长不到"); - return; - } - //计算奖励 - SAdventureConfig sAdventureConfig = SAdventureConfig.getsAdventureConfigByPosition(position); - int recommendForce = sAdventureConfig.getRecommendForce(); - - - SAdventureSetting sAdventureSetting = SAdventureSetting.getsAdventureSetting(position); - - - float[][] baseRewardRatio = sAdventureSetting.getBaseRewardRatio(); - float[][] randomRewardRatio = sAdventureSetting.getRandomRewardRatio(); - float[] hourRewardRatio = sAdventureSetting.getHourRewardRatio(); - - int totalForce =adventureStateInfo.getTotalForce(); - int myRecommendHeroSize =adventureStateInfo.getMyRecommendHeroSize(); - float myForceRatio = totalForce*1.0f / recommendForce; - - float hourRewardRatioTmp = MathUtils.calABX(hourDuration, hourRewardRatio); - float baseRewardRatioTmp = calRatio(myForceRatio, baseRewardRatio) * hourRewardRatioTmp; - float randomRewardRatioTmp = calRatio(myForceRatio, randomRewardRatio) * hourRewardRatioTmp; - int[] baseRewardGroup = sAdventureConfig.getBaseRewardGroup(); - int[][] recommendRewardGroup = sAdventureConfig.getRecommendRewardGroup(); - int[] randomRewardGroup = sAdventureConfig.getRandomRewardGroup(); - Map dropInfoMap = new HashMap<>(); - dropInfoMap.put(baseRewardGroup,baseRewardRatioTmp); - dropInfoMap.put(randomRewardGroup,randomRewardRatioTmp); - if(myRecommendHeroSize>0){ - int[] recommendRewardGroupDetail = recommendRewardGroup[myRecommendHeroSize - 1]; - for(int i=0;i0){ + adventureStateInfoTmp.setStartTime(startTime+times*60); + SAdventureConfig sAdventureConfig = SAdventureConfig.getSAdventureConfigByPosition(positionTmp); + int leaveBonus = sAdventureConfig.getLeaveBonus(); + if(!isOnLine){ + times = times>leaveBonus?leaveBonus:times; } + int baseRewardGroup[] = sAdventureConfig.getBaseRewardGroup(); + float rewardRation = calRation(size,sAdventureConfig.getNumIncome()); + tempDropRation.put(baseRewardGroup,rewardRation * times); + adventureManager.updateTemp(sAdventureConfig.getRandomRewardGroup(),rewardRation*times); } } - CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropInfoMap); - //清除占领 - adventureManager.clearStation(position); - FightInfoProto.TakeAventureRewardResponse response = FightInfoProto.TakeAventureRewardResponse.newBuilder().setDrop(drop).build(); - - //发送成功 - MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,response,true); + if(!isOnLine){ + tempDropRation.putAll(adventureManager.getTempDropRation()); + adventureManager.clearTemp(); + } + return ItemUtil.drop(user, tempDropRation); } - public float calRatio(float value,float[][] base){ - float result = 0; - for(int i=0;i< base.length;i++){ - float weight = base[i][0]; - if(value>= weight){ - result = base[i][1]; + private float calRation(float source,float[][] rationInfos){ + float result = 0.0f; + for(float[] item : rationInfos){ + float num = item[0]; + float value = item[1]; + if(source removeHeroIds){ + public void recyleHeroBySystem(User user,Set removeHeroIds) throws Exception { HeroManager heroManager = user.getHeroManager(); for(String useHeroId : removeHeroIds){ heroManager.removeHero(useHeroId); } - + CombatLogic.getInstance().calAdventureRewardByHeroChange(user,removeHeroIds); } //初始属性*(1+化境增长)*等级系数 + 初始属性*突破系数 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java b/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java index 12c1f973e..28fbf4fa8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java @@ -1,6 +1,5 @@ package com.ljsd.jieling.thread; -import com.ljsd.jieling.thread.task.MinuteJob; import com.ljsd.jieling.thread.task.PlatConfigureTask; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,9 +63,6 @@ public class ThreadManager { // testTask 已秒为单位 延迟10s, 间隔30s为周期执行 scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS); - long diff = now/1000 % 60 ; - scheduledExecutor.scheduleAtFixedRate(new MinuteJob(), 60 - diff, 60, TimeUnit.SECONDS); - LOGGER.info("All Task running ..."); } public ScheduledThreadPoolExecutor getScheduledExecutor() { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteJob.java b/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteJob.java deleted file mode 100644 index 124807f2d..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteJob.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ljsd.jieling.thread.task; - - -import com.ljsd.jieling.logic.fight.CombatLogic; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MinuteJob extends Thread { - private static final Logger LOGGER = LoggerFactory.getLogger(MinuteJob.class); - public MinuteJob(){ - super("minute-job-thread"); - } - - @Override - public void run() { - try { - LOGGER.info("MinuteJob start working"); - CombatLogic.getInstance().checkAdventureFlush(); - } catch (Exception e) { - LOGGER.error("the exception={}",e); - } - } -} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java index 16c87f655..6a2190b5c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java @@ -86,17 +86,11 @@ public class CBean2Proto { return mailProto; } - public static CommonProto.AdventureStateInfo getAdventureStateInfo(AdventureStateInfo adventureStateInfo,int position,int allowTime){ - CommonProto.AdventureStateInfo.Builder builder = CommonProto.AdventureStateInfo.newBuilder().setAllowTime(allowTime).setPositionId(position); + public static CommonProto.AdventureStateInfo getAdventureStateInfo(AdventureStateInfo adventureStateInfo,int position){ + CommonProto.AdventureStateInfo.Builder builder = CommonProto.AdventureStateInfo.newBuilder().setPositionId(position); if(adventureStateInfo!=null){ int startTime = adventureStateInfo.getStartTime(); - int now = (int)(System.currentTimeMillis()/1000); - int hourDuration = adventureStateInfo.getHourDuration(); - int remainTime = startTime + hourDuration*60*60 - now; - remainTime = remainTime<0?0:remainTime; - builder.addAllHeroIdList(adventureStateInfo.getHeroIds()) - .setHourDuration(hourDuration) - .setRemainTime(remainTime); + builder.addAllHeroIdList(adventureStateInfo.getHeroIds()).setStartTime(startTime); } return builder.build(); @@ -205,7 +199,6 @@ public class CBean2Proto { return CommonProto.MapAccomplishInfo.newBuilder() .setMapId(mapId) .addAllExploreDetail(exploreDetailList) .setTotalWeight(totalWeight) - .addAllHadTakedId(mapMission.getHadTakeRewardIds()) .build(); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index 45d4131dd..5fe8aae76 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -8,7 +8,7 @@ import com.ljsd.jieling.handler.map.MapManager; import com.ljsd.jieling.handler.map.TemporaryItems; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; -import com.ljsd.jieling.logic.item.ItemLogic; +import com.ljsd.jieling.logic.fight.CombatLogic; import com.ljsd.jieling.protocols.CommonProto; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -396,12 +396,15 @@ public class ItemUtil { } - public static List getAllItem(User user){ + public static List getAllItem(User user) throws Exception { List itemList = new ArrayList<>(); ItemManager itemManager = user.getItemManager(); Map itemMap = itemManager.getItemMap(); if (itemMap.size() !=0 ){ for (Map.Entry entry :itemMap.entrySet()){ + if (entry.getKey() ==Global.STAMINA){ + MapManager.getEnergy(user); + } itemList.add(CBean2Proto.getItem(entry.getValue(),-1)); } } @@ -495,6 +498,7 @@ public class ItemUtil { if (itemMap == null) { return true; } + CombatLogic.getInstance().calAdvenrureReward(user,true,0); TemporaryItems temporaryItems = user.getMapManager().getTemporaryItems(); Map temporaryItemList = new HashMap<>(); if (temporaryItems != null) { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/MonsterUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/MonsterUtil.java index a32e453ea..2b3df5694 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/MonsterUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/MonsterUtil.java @@ -7,21 +7,25 @@ import com.ljsd.jieling.protocols.FightInfoProto; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; public class MonsterUtil { - public static List getMonsterByGroup(int groupId){ + public static Map> getMonsterByGroup(int groupId){ SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(groupId); int[][] groupIds = sMonsterGroup.getContents(); - List monsterList = new CopyOnWriteArrayList<>(); + Map> map = new ConcurrentHashMap<>(); Map monsterMap = SMonsterConfig.getMonsterMap(); - for (int[] monsterIds : groupIds){ - for (int monsterId: monsterIds){ + for (int i = 0; i < groupIds.length; i++) { + int[] monsterIds = groupIds[i]; + List monsterList = new CopyOnWriteArrayList<>(); + for (int monsterId : monsterIds) { monsterList.add(monsterMap.get(monsterId)); } + map.put(i,monsterList); } - return monsterList; + return map; } public static String getMonsterSkillById(int monsterId){