diff --git a/conf/BattleMain.lua b/conf/BattleMain.lua index 63f497bd1..61c05d349 100644 --- a/conf/BattleMain.lua +++ b/conf/BattleMain.lua @@ -23,6 +23,10 @@ local BattleMain = {} local BattleLogic = BattleLogic local Random = Random +local _BattleErrorCache = {} +local _BattleErrorIndex = 0 +local _seed +local _type local _fightData local _optionData @@ -101,7 +105,7 @@ local function generateRecordFile() os.date("%H"), os.date("%M"), os.date("%S")) - local file = io.open("../luafight/BattleRecord/"..time..".txt", "a") + local file = io.open("luafight/BattleRecord/"..time..".txt", "a") local record = BattleLogic.GetRecord() for i=1, #record do file:write(record[i].."\n") @@ -109,7 +113,25 @@ local function generateRecordFile() io.close(file) end + +local function addBattleData() + local str = "" + str = str.."seed:\n"..tostring(_seed).."\n" + str = str.."type:\n"..tostring(_type).."\n" + str = str.."fightData:\n"..PrintTable(_fightData).."\n" + str = str.."optionData:\n"..PrintTable(_optionData).."\n" + + _BattleErrorIndex = _BattleErrorIndex + 1 + if _BattleErrorIndex > 5 then + _BattleErrorIndex = 1 + end + _BattleErrorCache[_BattleErrorIndex] = str +end + function BattleMain.Execute(args, fightData, optionData) + print("trfghjdfgucvhbjnfdcgvj") + _seed = args.seed + _type = args.type _fightData = fightData _optionData = optionData or {} @@ -121,6 +143,7 @@ function BattleMain.Execute(args, fightData, optionData) if xpcall(function () Random.SetSeed(args.seed) BattleLogic.Init(args.maxTime, fightData, optionData) + BattleLogic.Type = _type BattleLogic.StartOrder() while not BattleLogic.IsEnd do @@ -155,19 +178,7 @@ function BattleMain.Execute(args, fightData, optionData) --print("最终运行帧数:"..BattleLogic.CurFrame()) --print("result:"..BattleLogic.Result) - 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("../luafight/BattleRecord//record_"..time..".txt", "a") - file:write("fightData:\n"..PrintTable(_fightData).."\n") - file:write("optionData:\n"..PrintTable(_optionData).."\n") - file:write("seed:\n"..args.seed.."\n") - io.close(file) - + addBattleData() return resultList end if isError then --捕获异常,并输出错误日志 @@ -178,16 +189,25 @@ function BattleMain.Execute(args, fightData, optionData) os.date("%H"), os.date("%M"), os.date("%S")) - local file = io.open("../luafight/LogError/"..time..".txt", "a") + local file = io.open("luafight/LogError/"..time..".txt", "a") file:write(errorCache) + file:write("seed:\n"..tostring(args.seed).."\n") + file:write("type:\n"..tostring(args.type).."\n") file:write("fightData:\n"..PrintTable(_fightData).."\n") file:write("optionData:\n"..PrintTable(_optionData).."\n") - file:write("seed:\n"..args.seed.."\n") + file:write("\n\nlast battle data:\n") + for i=1, #_BattleErrorCache do + file:write(string.format("\nindex:%d\n", i)) + file:write(_BattleErrorCache[i]) + end io.close(file) end return { result = -1 } end ---BattleMain.Execute(1553167956, {playerData={{professionId=3,passivity={},type=1,skill={0,{40001,0.7,{1,2.3,2,},},{30011,0.7,{4,9,0.2,4,1,},{4,10,0.2,4,1,},},},superSkill={1.6,{20211,0.7,{1,3.3,2,},{15,1.98,2,1.98,},},},roleId=10022,camp=0,property={1,1676,1678,248,167,200,173,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=5,passivity={},type=1,skill={0,{40001,0.7,{11,0.93,2,2,0.2,},},},superSkill={3,{20000,0.7,{2,1.06,2,},{3,0.6,1,4,},},},roleId=10008,camp=0,property={1,2206,2208,221,193,232,130,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=4,passivity={},type=1,skill={0,{40001,0.7,{1,1.35,2,},},{30011,0.7,{3,0,0,5,},},},superSkill={2.5,{20000,0.7,{14,1.55,2,1,10023,0.2,},},},roleId=10023,camp=0,property={1,1439,1441,284,131,157,168,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=1,passivity={},type=1,skill={0,{40001,0.7,{1,1,1,},},{30011,0.7,{4,9,0.1,5,1,},{4,10,0.1,5,1,},},},superSkill={2.3,{20312,0.7,{19,1.35,1,0.5,5,},},},roleId=10013,camp=0,property={1,1678,1680,246,194,162,163,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=3,passivity={},type=1,skill={0,{40001,0.7,{1,2.3,2,},},{30011,0.7,{4,9,0.2,4,1,},{4,10,0.2,4,1,},},},superSkill={1.6,{20211,0.7,{1,3.3,2,},{15,1.98,2,1.98,},},},roleId=10022,camp=0,property={17,2732,2734,401,272,326,308,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},teamSkill={},},enemyData={{{professionId=0,passivity={},type=2,skill={0,{20013,0.7,{1,0.45,1,},},},superSkill={},roleId=1,camp=1,property={0,483,483,260,61,61,240,0,0,0.3,0.3,0.2,1.5,1,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=0,passivity={},type=2,skill={0,{20013,0.7,{1,0.45,1,},},},superSkill={},roleId=2,camp=1,property={0,483,483,260,61,61,80,0,0,0.3,0.3,0.2,1.5,1,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=0,passivity={},type=2,skill={0,{20013,0.7,{1,0.45,1,},},},superSkill={},roleId=3,camp=1,property={0,483,483,260,61,61,7,0,0,0.3,0.3,0.2,1.5,1,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},teamSkill={},},},}) ---BattleMain.Execute(1553167956, {playerData={{professionId=4,passivity={},type=1,skill={0,{40001,0.7,{1,1.35,2,},},{30011,0.7,{3,0,0,5,},},},superSkill={2.5,{20000,0.7,{14,1.55,2,1,10023,0.2,},},},roleId=10023,camp=0,property={1,1439,1441,284,131,157,168,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=3,passivity={},type=1,skill={0,{40001,0.7,{1,2.3,2,},},{30011,0.7,{4,9,0.2,4,1,},{4,9,0.2,4,1,},},},superSkill={1.6,{20211,0.7,{1,3.3,2,},{15,1.98,2,1.98,},},},roleId=10022,camp=0,property={1,1676,1678,248,167,200,173,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=2,passivity={},type=1,skill={0,{40001,0.7,{1,1.05,2,},{4,4,5,5,3,},},},superSkill={2.3,{20000,0.7,{2,1.89,2,},},{20012,0.7,{3,1,5,5,},},},roleId=10021,camp=0,property={1,1920,1922,209,170,204,178,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=5,passivity={},type=1,skill={0,{40001,0.7,{11,0.93,2,2,0.2,},},},superSkill={3,{20000,0.7,{2,1.06,2,},{3,0.6,1,4,},},},roleId=10008,camp=0,property={1,2206,2208,221,193,232,130,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=1,passivity={},type=1,skill={0,{40001,0.7,{1,1,1,},},{30011,0.7,{4,9,0.1,5,1,},{4,9,0.1,5,1,},},},superSkill={2.3,{20312,0.7,{19,1.35,1,0.5,5,},},},roleId=10013,camp=0,property={1,1678,1680,246,194,162,163,0,0,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},teamSkill={{3,{20012,0.7,{26,600,},{27,100,4,},},{10014,0.7,{25,2,0.1,4,},},},},},enemyData={{{professionId=0,passivity={},type=2,skill={0,{20011,0.7,{1,1,1,},{3,0.3,1,3,},},},superSkill={},roleId=14,camp=1,property={0,772,772,260,61,61,80,0,0,0.3,0.3,0.2,1.5,1,0,0,0,0,0,0,0,0,0,0,2,2,},quality=1,},{professionId=0,passivity={},type=2,skill={0,{20013,0.7,{1,0.45,1,},},},superSkill={},roleId=1,camp=1,property={0,483,483,260,61,61,240,0,0,0.3,0.3,0.2,1.5,1,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},{professionId=0,passivity={},type=2,skill={0,{20013,0.7,{1,0.45,1,},},},superSkill={},roleId=3,camp=1,property={0,483,483,260,61,61,7,0,0,0.3,0.3,0.2,1.5,1,0,0,0,0,0,0,0,0,0,0,0,0,},quality=1,},teamSkill={},},},}) +--[[ +BattleMain.Execute({seed=1565094199,maxTime=300} +,{enemyData={{{ai={0},camp=1,element=1,passivity={{45,1},{45,2}},professionId=0,property={139,117440,117440,18564,2911,2911,5960,0.0,0.0,0.05,0.15,0.2,1.5,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},quality=3,roleId=23,skill={0,{20001,0.7,{1,0.848,1},{13,2,0.1,2,4},{4,4,0.2,12,4}}},superSkill={1.5,{20002,0.7,{10,1.072,1,0.4},{13,3,0.2,1,4}},{30000,0.7,{4,4,0.2,9,2}}},type=4},teamSkill={}}},playerData={{camp=0,element=4,passivity={{5,0.3,1,0.1,5},{39,5,2800},{12,0.15,0.15,2},{44,0.1,4,0.05,6,2}},professionId=5,property={139,76728,76728,4144,3372,2321,3740,0,0,0,0,0.0847,1.5,0,1,1,0,0,0,0,0,0,0,0,0},quality=1,roleId=10005,skill={0,{20001,0.7,{1,0.65,2}},{30101,0.7,{24,1,0.68}},{30001,0.7,{4,1,0.2,9,2}}},superSkill={2,{20004,0.7,{2,0.86,2}},{10100,0.7,{24,1,0.74}}},type=1},{camp=0,element=3,passivity={{5,0.3,1,0.1,5},{39,5,2800},{12,0.15,0.15,2},{44,0.1,4,0.05,6,2}},professionId=5,property={139,76559,76559,4086,2372,3370,3734,0,0,0,0,0.0808,1.5,0,1,1,0,0,0,0,0,0,0,0,0},quality=1,roleId=10007,skill={0,{20001,0.7,{6,3,3,0.88,1},{4,2,0.15,8,4},{4,3,0.15,8,4}}},superSkill={2,{20001,0.7,{1,1.1,1}},{10721,0.7,{8,0,1,1}}},type=1},{camp=0,element=5,passivity={{6,0.25,1,0.25,1,10},{39,5,2800},{12,0.15,0.15,2},{44,0.1,4,0.05,6,2}},professionId=2,property={139,60127,60127,7669,1672,3242,4060,0,0,0,0,0.1287,1.5,0,1,1,0,0,0,0,0,0,0,0,0},quality=1,roleId=10015,skill={0,{20001,0.7,{10,0.95,2,0.3}}},superSkill={3,{20002,0.7,{33,1.4,2,1,10015,0.15,10},{16,0.04,1,10,2}}},type=1},{camp=0,element=1,passivity={{6,0.25,1,0.25,1,10},{39,5,2800},{12,0.15,0.15,2},{44,0.1,4,0.05,6,2}},professionId=1,property={140,72220,72220,3858,4378,2630,4246,0,0,0,0,0.1274,1.5,0,1,1,0,0,0,0,0,0,0,0,0},quality=1,roleId=10020,skill={0,{20001,0.7,{6,3,3,0.35,1}},{10002,0.7,{24,1,0.9}}},superSkill={5,{20000,0.7,{2,0.65,1}},{10000,0.7,{4,6,0.15,6,1}}},type=1},{camp=0,element=2,passivity={{14,0.4,2,0.3,1,10,1},{39,5,2800},{12,0.15,0.15,2},{44,0.1,4,0.05,6,2}},professionId=3,property={139,58750,58750,5175,2145,3634,3581,0,0,0,0,0.0915,1.5,0,1,1,0,0,0,0,0,0,0,0,0},quality=1,roleId=10008,skill={0,{20001,0.7,{29,4,4,0.45,2,2,0.1}}},superSkill={4,{20000,0.7,{2,0.7,2}},{20000,0.7,{3,0.15,1,8}}},type=1},teamSkill={}}} +,{{1,1,0},{1,6,11},{1,6,21},{1,6,31},{1,6,41},{1,6,51},{1,5,0}}) +]]-- return BattleMain \ No newline at end of file diff --git a/luafight/BattleMain.lua b/luafight/BattleMain.lua index 9df5e4324..4a8827909 100644 --- a/luafight/BattleMain.lua +++ b/luafight/BattleMain.lua @@ -27,6 +27,7 @@ local Random = Random local _BattleErrorCache = {} local _BattleErrorIndex = 0 local _seed +local _type local _fightData local _optionData @@ -117,6 +118,7 @@ end local function addBattleData() local str = "" str = str.."seed:\n"..tostring(_seed).."\n" + str = str.."type:\n"..tostring(_type).."\n" str = str.."fightData:\n"..PrintTable(_fightData).."\n" str = str.."optionData:\n"..PrintTable(_optionData).."\n" @@ -128,7 +130,9 @@ local function addBattleData() end function BattleMain.Execute(args, fightData, optionData) + print("trfghjdfgucvhbjnfdcgvj") _seed = args.seed + _type = args.type _fightData = fightData _optionData = optionData or {} @@ -140,6 +144,7 @@ function BattleMain.Execute(args, fightData, optionData) if xpcall(function () Random.SetSeed(args.seed) BattleLogic.Init(args.maxTime, fightData, optionData) + BattleLogic.Type = _type BattleLogic.StartOrder() while not BattleLogic.IsEnd do @@ -188,6 +193,7 @@ function BattleMain.Execute(args, fightData, optionData) local file = io.open("luafight/LogError/"..time..".txt", "a") file:write(errorCache) file:write("seed:\n"..tostring(args.seed).."\n") + file:write("type:\n"..tostring(args.type).."\n") file:write("fightData:\n"..PrintTable(_fightData).."\n") file:write("optionData:\n"..PrintTable(_optionData).."\n") file:write("\n\nlast battle data:\n") diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index 3af59a593..66f85177c 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -20,6 +20,7 @@ local enemySkillUsable local isAuto +BattleLogic.Type = 0 --1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战 BattleLogic.IsEnd = false BattleLogic.Result = -1 BattleLogic.Event = BattleEvent.New() @@ -123,6 +124,17 @@ function BattleLogic.StartOrder() playerTeamSkillList[i] = skillPool:Get() playerTeamSkillList[i]:Init(playerTeamDummyRole, fightData.playerData.teamSkill[i], true) end + for i=1, #fightData.playerData.teamPassive do + for j=1, #fightData.playerData.teamPassive[i] do + local v = fightData.playerData.teamPassive[i][j] + local id = v[1] + local args = {} + for k = 2, #v do + args[k-1] = v[k] + end + BattleUtil.Passivity[id](playerTeamDummyRole, args) + end + end for i=1, #enemyTeamSkillList do skillPool:Put(enemyTeamSkillList[i]) @@ -132,6 +144,17 @@ function BattleLogic.StartOrder() enemyTeamSkillList[i] = skillPool:Get() enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], true) end + for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do + for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do + local v = fightData.enemyData[BattleLogic.CurOrder].teamPassive[i][j] + local id = v[1] + local args = {} + for k = 2, #v do + args[k-1] = v[k] + end + BattleUtil.Passivity[id](enemyTeamDummyRole, args) + end + end else BattleLogic.ClearOrder() for i=1, #fightData.enemyData[BattleLogic.CurOrder] do @@ -146,6 +169,17 @@ function BattleLogic.StartOrder() enemyTeamSkillList[i] = skillPool:Get() enemyTeamSkillList[i]:Init(enemyTeamDummyRole, fightData.enemyData[BattleLogic.CurOrder].teamSkill[i], true) end + for i=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive do + for j=1, #fightData.enemyData[BattleLogic.CurOrder].teamPassive[i] do + local v = fightData.enemyData[BattleLogic.CurOrder].teamPassive[i][j] + local id = v[1] + local args = {} + for k = 2, #v do + args[k-1] = v[k] + end + BattleUtil.Passivity[id](enemyTeamDummyRole, args) + end + end end BattleLogic.InitAggro() end diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/BattleManager.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/BattleManager.java index b1d07026b..4a1ebecd9 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/BattleManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/BattleManager.java @@ -2,20 +2,177 @@ package com.ljsd.jieling.battle; +import com.googlecode.protobuf.format.JsonFormat; +import com.ljsd.jieling.battle.actor.Creature; +import com.ljsd.jieling.battle.actor.Life; +import com.ljsd.jieling.battle.actor.SceneMonster; +import com.ljsd.jieling.config.SArenaSetting; +import com.ljsd.jieling.config.SBloodyBattleSetting; +import com.ljsd.jieling.globals.Global; import com.ljsd.jieling.handler.map.behavior.BehaviorUtil; +import com.ljsd.jieling.logic.blood.BloodLogic; +import com.ljsd.jieling.logic.dao.FamilyHeroInfo; +import com.ljsd.jieling.logic.dao.Hero; +import com.ljsd.jieling.logic.dao.TeamPosHeroInfo; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.fight.CheckFight; +import com.ljsd.jieling.logic.fight.FightType; +import com.ljsd.jieling.logic.hero.HeroAttributeEnum; +import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.protocols.CommonProto; +import com.ljsd.jieling.util.FightDataUtil; +import com.ljsd.jieling.util.MonsterUtil; +import org.luaj.vm2.LuaValue; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public class BattleManager { + public static Map bloodMyHeroInfoMap = new HashMap<>(); - static Map fightTeamInfoMap = new HashMap<>(); + /** + * 匹配成功后,把上阵的英雄做快照处理,发给血战服务器 + * @param mine + * @param myteamId + */ + public static UserBloodySnpInfo snapUserFightInfo(User mine, int myteamId){ + //血量处理 + mine.getTeamPosManager().setCurTeamPosId(myteamId); + UserBloodySnpInfo userBloodySnpInfo = new UserBloodySnpInfo(mine.getId(),mine.getPlayerInfoManager().getNickName()); + List teamPosHeroInfoList = mine.getTeamPosManager().getTeamPosForHero().get(myteamId); + Map heroMap = mine.getHeroManager().getHeroMap(); + for(TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList){ + String heroId = teamPosHeroInfo.getHeroId(); + Hero hero = heroMap.get(heroId); + StringBuilder skillSb = new StringBuilder(); + String heroSkill = HeroLogic.getInstance().getHeroSkills(mine, hero,skillSb ).toString(); + userBloodySnpInfo.updateHeroSkill(heroId,heroSkill.substring(0, heroSkill.length() - 1)); + } + String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(mine, myteamId); + userBloodySnpInfo.setPokenmonSkills(pokenmonSkills); + Map heroAllAttribute = BloodLogic.getInstance().battleRecord(mine, myteamId,null); + userBloodySnpInfo.setHeroAllAttributes(heroAllAttribute); + int maxHp = 0; + for(FamilyHeroInfo familyHeroInfo : heroAllAttribute.values()){ + maxHp += familyHeroInfo.getAttribute().get(HeroAttributeEnum.Hp.getPropertyId()); + } + userBloodySnpInfo.setMaxHp(maxHp); + bloodMyHeroInfoMap.put(mine.getId(),userBloodySnpInfo); + return userBloodySnpInfo; + } - public static void snapUserFightInfo(User mine, int myteamId){ - CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId,false); - fightTeamInfoMap.put(mine.getId(),fightTeamInfo); + /** + * 血战战斗 更新血量 人互打 + * @return + */ + public static int[] battleOfP2P(Creature redCreature ,Creature blueCreature){ + UserBloodySnpInfo redUserBloodySnpInfo = bloodMyHeroInfoMap.get(redCreature.getId()); + UserBloodySnpInfo blueUserBloodySnpInfo = bloodMyHeroInfoMap.get(blueCreature.getId()); + int seed = (int)(System.currentTimeMillis()/1000); + CommonProto.FightTeamInfo redFightTeamInfo = fightDataMake(redUserBloodySnpInfo); + CommonProto.FightTeamInfo bluefightTeamInfo = fightDataMake(blueUserBloodySnpInfo); + System.out.println(JsonFormat.printToString(redFightTeamInfo)); + System.out.println(JsonFormat.printToString(bluefightTeamInfo)); + LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(redFightTeamInfo, bluefightTeamInfo); + LuaValue getOptionData = FightDataUtil.getOptionData(""); + int[] checkResult = CheckFight.getInstance().checkFight(seed, SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData,FightType.BloodyFight); + int resultCode = checkResult[0]; + if(resultCode == 1){ + rebirth(blueUserBloodySnpInfo); + blueCreature.setLife(new Life(blueCreature.getLife().getMaxMp(),blueCreature.getLife().getMaxMp())); + afterBattleRecord(redUserBloodySnpInfo.getHeroAllAttributes(),checkResult); + return checkResult; + } + + rebirth(redUserBloodySnpInfo); + redCreature.setLife(new Life(redCreature.getLife().getMaxMp(),redCreature.getLife().getMaxMp())); + afterBattleRecord(blueUserBloodySnpInfo.getHeroAllAttributes(),checkResult); + return checkResult; + } + + /** + * 血战战斗 更新血量 人怪打 + * @return + */ + public static int[] battleOfP2M(Creature creature, SceneMonster sceneMonster){ + UserBloodySnpInfo redUserBloodySnpInfo = bloodMyHeroInfoMap.get(creature.getId()); + int seed = (int)(System.currentTimeMillis()/1000); + CommonProto.FightTeamInfo redFightTeamInfo = fightDataMake(redUserBloodySnpInfo); + int[][] monster = SBloodyBattleSetting.sBloodyBattleSetting.getMonster(); + int monsterGroupId = monster[sceneMonster.getId() - 1][0]; + Map> hps = new HashMap<>(1); + hps.put(0,sceneMonster.getRemainHps()); + Map> monsterByGroup = MonsterUtil.getMonsterByGroup(monsterGroupId,hps); + List monsterGroupList = BehaviorUtil.getFightTeamInfos(monsterGroupId,monsterByGroup, Global.MONSTER_1); + LuaValue getFightData = FightDataUtil.getFinalFightData(redFightTeamInfo, monsterGroupList); + LuaValue getOptionData = FightDataUtil.getOptionData(""); + int[] checkResult = CheckFight.getInstance().checkFight(seed, SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData, FightType.BloodyFight); + int resultCode = checkResult[0]; + if(resultCode == 1){ + afterBattleRecord(redUserBloodySnpInfo.getHeroAllAttributes(),checkResult); + return checkResult; + } + rebirth(redUserBloodySnpInfo); + creature.setLife(new Life(creature.getLife().getMaxMp(),creature.getLife().getMaxMp())); + updateMonsterHp(checkResult,sceneMonster); + return checkResult; + } + + public static void updateMonsterHp(int[] checkResult,SceneMonster sceneMonster){ + List oldRemainHp = sceneMonster.getRemainHps(); + List result =new ArrayList<>(5); + for(int i=2;i<=oldRemainHp.size()+1;i++){ + result.add(checkResult[i]); + } + sceneMonster.setRemainHps(result); + } + + + //战斗之后血量计算 + public static Map afterBattleRecord(Map heroAttribute,int[] fightResult){ + int index = 2; + for (Map.Entry entry : heroAttribute.entrySet()) { + FamilyHeroInfo value = entry.getValue(); + Map attribute = value.getAttribute(); + attribute.put(HeroAttributeEnum.CurHP.getPropertyId(), fightResult[index]); + value.setAttribute(attribute); + index++; + } + return heroAttribute; + } + + + + public static void rebirth(UserBloodySnpInfo userBloodySnpInfo){ + Map heroAllAttributes = userBloodySnpInfo.getHeroAllAttributes(); + for(FamilyHeroInfo familyHeroInfo : heroAllAttributes.values()){ + Integer maxHp = familyHeroInfo.getAttribute().get(HeroAttributeEnum.Hp.getPropertyId()); + familyHeroInfo.getAttribute().put(HeroAttributeEnum.CurHP.getPropertyId(),maxHp); + } + } + + + public static CommonProto.FightTeamInfo fightDataMake(UserBloodySnpInfo redUserBloodySnpInfo ){ + List heroDefendFightInfos = new ArrayList<>(5); + Map heroAllAttributes = redUserBloodySnpInfo.getHeroAllAttributes(); + + for (Map.Entry entry : heroAllAttributes.entrySet()) { + FamilyHeroInfo value = entry.getValue(); + String heroSkill = redUserBloodySnpInfo.getHeroSkills().get(entry.getKey()); + StringBuilder propertySb = new StringBuilder(); + String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, value, entry.getValue().getAttribute()).toString(); + CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo + .newBuilder() + .setUnitId(Integer.toString(value.getTempleteId())) + .setUnitSkillIds(heroSkill) + .setProperty(property.substring(0, property.length() - 1)) + .build(); + heroDefendFightInfos.add(heroFightInfo); + } + return CommonProto.FightTeamInfo. + newBuilder() + .addAllFightUnitList(heroDefendFightInfos) + .setTeamSkillList(redUserBloodySnpInfo.getPokenmonSkills()) + .build(); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/BattleRequest.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/BattleRequest.java new file mode 100644 index 000000000..66abee348 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/BattleRequest.java @@ -0,0 +1,38 @@ +package com.ljsd.jieling.battle; + +import com.ljsd.jieling.battle.actor.ActorType; +import com.ljsd.jieling.battle.actor.SceneActor; + +public class BattleRequest { + private long requestTime; // 请求时间戳 + + private SceneActor attackActor; //攻击方 只能是玩家 + + private SceneActor defActor; // 防守方 可能是玩家,可能是怪物 + + private ActorType defActorType; // 用于区分防守方类型 + + + public BattleRequest(long requestTime, SceneActor attackActor, SceneActor defActor, ActorType defActorType) { + this.requestTime = requestTime; + this.attackActor = attackActor; + this.defActor = defActor; + this.defActorType = defActorType; + } + + public long getRequestTime() { + return requestTime; + } + + public SceneActor getAttackActor() { + return attackActor; + } + + public SceneActor getDefActor() { + return defActor; + } + + public ActorType getDefActorType() { + return defActorType; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/FutureResult.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/FutureResult.java new file mode 100644 index 000000000..79c471766 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/FutureResult.java @@ -0,0 +1,21 @@ +package com.ljsd.jieling.battle; + +import java.util.concurrent.Future; + +public class FutureResult { + private int type; //future类型 ,不同类型不同逻辑处理 + private Future future; + + public FutureResult(int type, Future future) { + this.type = type; + this.future = future; + } + + public int getType() { + return type; + } + + public Future getFuture() { + return future; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/UserBloodySnpInfo.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/UserBloodySnpInfo.java new file mode 100644 index 000000000..98aafc747 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/UserBloodySnpInfo.java @@ -0,0 +1,68 @@ +package com.ljsd.jieling.battle; + +import com.ljsd.jieling.logic.dao.FamilyHeroInfo; + +import java.util.HashMap; +import java.util.Map; + +public class UserBloodySnpInfo { + private int uid; + + private String name; + + private Map heroAllAttributes = new HashMap<>(5); + + private Map heroSkills = new HashMap<>(); + + private String pokenmonSkills; + + private int maxHp; + + + public UserBloodySnpInfo(int uid, String name) { + this.uid = uid; + this.name = name; + } + + public void updateHeroSkill(String heroId, String skills){ + heroSkills.put(heroId,skills); + } + + + public void setPokenmonSkills(String pokenmonSkills) { + this.pokenmonSkills = pokenmonSkills; + } + + public void setHeroAllAttributes(Map heroAllAttributes) { + this.heroAllAttributes = heroAllAttributes; + } + + + public int getUid() { + return uid; + } + + public String getName() { + return name; + } + + public Map getHeroAllAttributes() { + return heroAllAttributes; + } + + public Map getHeroSkills() { + return heroSkills; + } + + public String getPokenmonSkills() { + return pokenmonSkills; + } + + public int getMaxHp() { + return maxHp; + } + + public void setMaxHp(int maxHp) { + this.maxHp = maxHp; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Creature.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Creature.java index 242ae00ce..97ed7641c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Creature.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Creature.java @@ -2,6 +2,10 @@ package com.ljsd.jieling.battle.actor; +import com.ljsd.jieling.battle.BattleManager; +import com.ljsd.jieling.battle.BattleRequest; +import com.ljsd.jieling.battle.room.SceneManager; +import com.ljsd.jieling.config.SBloodyBattleSetting; import com.ljsd.jieling.util.CellUtil; import com.ljsd.jieling.util.MathUtils; import org.slf4j.Logger; @@ -17,16 +21,6 @@ public abstract class Creature extends SceneActor{ private static final Logger LOGGER = LoggerFactory.getLogger(Creature.class); - private static List reclyPath = new ArrayList<>(); - static { - reclyPath.add(256*5+11); - reclyPath.add(256*5+12); - reclyPath.add(256*5+13); - reclyPath.add(256*5+14); - reclyPath.add(256*4+14); - } - - private Life life; private List path = new ArrayList<>(); //路径 @@ -77,12 +71,10 @@ public abstract class Creature extends SceneActor{ if(result){ if(commandType == 1){ List pathTmp = (List) parm; - System.out.println("the uid="+getId() + " " + pathTmp); - System.out.println(getPos()); if(getPos()!=pathTmp.get(0)){ return false; } - boolean continuous = CellUtil.isContinuous(getPos(), (List) parm); + boolean continuous = CellUtil.isContinuous(getPos(), (List) parm, SceneManager.bloodyMap.getBarrierPoints()); if(continuous){ continuous = canMoveNext(pathTmp.get(1), false); } @@ -155,7 +147,8 @@ public abstract class Creature extends SceneActor{ } } int curPos = getPos(); - LOGGER.info("the id={},preMoveTimestamp={},the time ={},move={},the oldXy={},the curXy={}",getId(),new Date(preMoveTimestamp),new Date(timestamp),moveDistance,oldXY,curPos); + + LOGGER.info("the id={},preMoveTimestamp={},the time ={},move={},the oldXy={},the curXy={}",getId(),new Date(preMoveTimestamp),new Date(timestamp),moveDistance,CellUtil.pos2XY(oldXY),CellUtil.pos2XY(curPos)); preMoveTimestamp = timestamp; return curPos; @@ -183,10 +176,19 @@ public abstract class Creature extends SceneActor{ this.addOrUpdateBuffer(effectBuffer); //战斗buffer //打断自己行使路线 广播自己状态 位置信息 this.preMoveTimestamp = timestamp; - this.path.clear(); + if(this.getType() != ActorType.Monster){ + /*Collections.reverse(path); + cachePath.addAll(path);*/ + this.path.clear(); + } + + } public boolean checkEventTrigger(long timestamp){ + if(this.getType() ==ActorType.Mineral || this.getType() ==ActorType.Npc){ + return false; + } Scene scene = getScene(); int curPos = getPos(); Set xySet = CellUtil.getSurroundPos(15,20,curPos); @@ -222,17 +224,19 @@ public abstract class Creature extends SceneActor{ if(getStateType()!=StateType.FROZEN &&sceneActor.getStateType()!= StateType.FROZEN&& xySet.contains(sceneActor.getPos())){ triggerEvent=3; setStateType(StateType.FROZEN); + //异步计算战斗结果 + getScene().execASync(new BattleRequest(timestamp,this,sceneActor,sceneActor.getType())); + LOGGER.info("the attackUid={},the battleId={}",this.getId(),sceneActor.getId()); } } if(triggerEvent!=0){ - int randomResult = MathUtils.randomInt(10) > 5 ?0:1; - if(this.getType() == ActorType.Player){ - EffectBuffer effectBuffer = new EffectBuffer(getScene().getBufferId(),triggerEvent, timestamp, timestamp + 6000,getId(), sceneActor.getId(), randomResult&1); + if(triggerEvent == 3 || this.getType() == ActorType.Player){ + EffectBuffer effectBuffer = new EffectBuffer(getScene().getBufferId(),triggerEvent, timestamp, -1,getId(), sceneActor.getId(), -1); whenTriggerEvent(effectBuffer,timestamp); result = true; } - if(sceneActor.getType() == ActorType.Player){ - EffectBuffer othereffectBuffer = new EffectBuffer(getScene().getBufferId(),triggerEvent, timestamp, timestamp + 6000,sceneActor.getId(),getId(), randomResult^1); + if(triggerEvent == 3 ){ + EffectBuffer othereffectBuffer = new EffectBuffer(getScene().getBufferId(),triggerEvent, timestamp, -1,sceneActor.getId(),getId(), -1); sceneActor.whenTriggerEvent(othereffectBuffer,timestamp); result = true; } @@ -268,4 +272,8 @@ public abstract class Creature extends SceneActor{ public void setPreMoveTimestamp(long preMoveTimestamp) { this.preMoveTimestamp = preMoveTimestamp; } + + public void setSpeed(int speed) { + this.speed = speed; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/EffectBuffer.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/EffectBuffer.java index d6761a665..f72fca8ef 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/EffectBuffer.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/EffectBuffer.java @@ -23,6 +23,10 @@ public class EffectBuffer { this.values.add(value); } + public void addEffectValue(int value){ + this.values.add(value); + } + public int getId() { return id; } @@ -79,4 +83,8 @@ public class EffectBuffer { ", values=" + values + '}'; } + + public void clearvalues(){ + values.clear(); + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Scene.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Scene.java index 5a1dbf2d1..a290f8925 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Scene.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/Scene.java @@ -2,23 +2,44 @@ package com.ljsd.jieling.battle.actor; import com.googlecode.protobuf.format.JsonFormat; import com.ljsd.common.mogodb.util.BlockingUniqueQueue; +import com.ljsd.jieling.battle.BattleManager; +import com.ljsd.jieling.battle.BattleRequest; +import com.ljsd.jieling.battle.FutureResult; +import com.ljsd.jieling.battle.match.MatchServerice; import com.ljsd.jieling.battle.room.BeanToProto; import com.ljsd.jieling.battle.room.Command; +import com.ljsd.jieling.battle.room.SceneManager; +import com.ljsd.jieling.config.SBloodyBattleSetting; +import com.ljsd.jieling.db.mongo.MongoUtil; import com.ljsd.jieling.logic.OnlineUserManager; +import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.SceneFight; +import com.ljsd.jieling.util.MathUtils; import com.ljsd.jieling.util.MessageUtil; import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class Scene implements Runnable{ + + private List futureList = new ArrayList<>(); + public static ExecutorService executorService = Executors.newFixedThreadPool(32); + private int roomId; private int bufferId; private int mapId; //地图id private int state; + private long startTime; + private int tick; private Map sceneActorMap = new HashMap<>(3); private BlockingUniqueQueue commandBlockingUniqueQueue = new BlockingUniqueQueue<>(); + private Map minealForPosMap = new HashMap<>(); + public void addScenActor(SceneActor sceneActor){ sceneActorMap.put(sceneActor.getId(),sceneActor); @@ -38,6 +59,13 @@ public class Scene implements Runnable{ private Set willUpdateActors = new HashSet<>(2); + private boolean isEnd; + + + public void monsterReflush(){ + + } + public void tick() throws InterruptedException { Iterator> iterator = sceneActorMap.entrySet().iterator(); @@ -73,6 +101,9 @@ public class Scene implements Runnable{ Thread.sleep(50); } + + + /** * 信息收集器 */ @@ -104,7 +135,14 @@ public class Scene implements Runnable{ while ( (poll = commandBlockingUniqueQueue.poll())!=null){ poll.getSceneActor().exec(poll.getType(),poll.getOperParm()); } + if(isEnd){ + break; + } + tick++; tick(); + if(tick/20 == 1 && tick%20==0){ + startAllRunning(); + } }catch (Exception e){ e.printStackTrace(); } @@ -112,6 +150,135 @@ public class Scene implements Runnable{ } + public void startAllRunning(){ + for(SceneActor sceneActor : sceneActorMap.values()){ + if(sceneActor.getType()== ActorType.Player){ + sceneActor.setStateType(StateType.MOVEABLE); + processEventUpdate(EventType.SCENEACTORE_UPDATE,sceneActor.getId()); + } + } + } + + public void sysTick(){ + int round = SceneManager.bloodyMap.getRound(); + if( tick % round != 0){ + return; + } + int[][] mineralCeiling = SBloodyBattleSetting.sBloodyBattleSetting.getMineralCeiling(); + Map mineralNums = new HashMap<>(mineralCeiling.length); + for(SceneActor sceneActor : sceneActorMap.values()){ + if(sceneActor.getType() == ActorType.Mineral){ + SceneMineral sceneMineral = (SceneMineral) sceneActor; + int size = sceneMineral.getSize(); + Integer nums = mineralNums.get(size); + if(nums == null){ + nums = 0; + } + mineralNums.put(size,nums); + } + } + for(int[] mineralCeilingSingle :mineralCeiling){ + + int flushTime = mineralCeilingSingle[1]; + if(tick%(flushTime*20)==0){ + int size = mineralCeilingSingle[0]; + int flushNums = mineralCeilingSingle[2]; + int maxNums = mineralCeilingSingle[3]; + Integer existNums = mineralNums.get(size); + if(existNums == null){ + existNums = 0; + } + //新增矿点 + if(maxNums > existNums){ + + } + + } + } + + } + + + //退出操作 + public void gameEnd() throws Exception { + isEnd = true; + for(SceneActor sceneActor : sceneActorMap.values()){ + if(sceneActor.getType() == ActorType.Player){ + int id = sceneActor.getId(); + User user = UserManager.getUser(id); + user.getRoomInfo().setRoomId(-1); + MatchServerice.clearUidRoomInfo(id); + ISession iSession = OnlineUserManager.getSessionByUid(id); + if(iSession!=null){ + MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.SCENE_GAME_OVER_INDICATION_VALUE, null, true); + } + + } + } + SceneManager.clearScene(roomId); + MongoUtil.getLjsdMongoTemplate().lastUpdate(); + } + + + + + public void execASync(BattleRequest battleRequest){ + executorService.submit(new Callable() { + @Override + public Integer call() throws Exception { + System.out.println("exce battle..............................."); + SceneActor attackActor = battleRequest.getAttackActor(); + SceneActor defActor = battleRequest.getDefActor(); + SceneActor temp = null; + int checkResult[] = null; + Thread.sleep(150); + //只能人是进攻方 + if(attackActor.getType() == ActorType.Monster){ + temp = defActor; + defActor = attackActor; + attackActor = temp; + } + /* if(defActor.getType() == ActorType.Monster || attackActor.getType() == ActorType.Monster){ + checkResult = BattleManager.battleOfP2M((Creature) attackActor, (SceneMonster) defActor); + }else{ + checkResult = BattleManager.battleOfP2P((Creature) attackActor, (Creature) defActor); + }*/ + int[] fightTime = SBloodyBattleSetting.sBloodyBattleSetting.getFightTime(); + //todo + checkResult = new int[]{0,1000,200,0,0,0,0}; + int displayTime = checkResult[1] / fightTime[0]; + if(displayTime>fightTime[2]){ + displayTime = fightTime[2]; + } + if(displayTime bufferMap = attackActor.getBufferMap(); + for(EffectBuffer effectBuffer : bufferMap.values()){ + if(effectBuffer.getType() == 3 && effectBuffer.getTarget() == attackActor.getId() && effectBuffer.getCaster() == defActor.getId()){ + effectBuffer.clearvalues(); + effectBuffer.addEffectValue(checkResult[0]); + effectBuffer.setEndTime(effectBuffer.getStartTime() + displayTime *1000); + System.out.println(effectBuffer); + System.out.println(attackActor.getId()); + } + } + Map defBufferMap = defActor.getBufferMap(); + for(EffectBuffer effectBuffer : defBufferMap.values()){ + if(effectBuffer.getType() == 3 && effectBuffer.getTarget() == defActor.getId() && effectBuffer.getCaster() == attackActor.getId()){ + effectBuffer.clearvalues(); + effectBuffer.addEffectValue(checkResult[0]==1?0:1); + effectBuffer.setEndTime(effectBuffer.getStartTime() + displayTime *1000); + System.out.println(effectBuffer); + + } + } + return 1; + } + }); + } + public int getMapId() { return mapId; } @@ -133,4 +300,20 @@ public class Scene implements Runnable{ public void setState(int state) { this.state = state; } + + public int getRoomId() { + return roomId; + } + + public void setRoomId(int roomId) { + this.roomId = roomId; + } + + public long getStartTime() { + return startTime; + } + + public void setStartTime(long startTime) { + this.startTime = startTime; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneActor.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneActor.java index cf5864239..6e86fbf10 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneActor.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneActor.java @@ -2,6 +2,9 @@ package com.ljsd.jieling.battle.actor; +import com.ljsd.jieling.battle.room.SceneManager; +import com.ljsd.jieling.config.SBloodyBattleSetting; + import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -32,6 +35,7 @@ public abstract class SceneActor{ if(effectBuffer.getType() == 3){ stateType = StateType.FROZEN; scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,this.getId()); + System.out.println("the actor" + id + "is frozen"); } if(effectBuffer.getType() == 2){ scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,this.getId()); @@ -49,8 +53,12 @@ public abstract class SceneActor{ while (iterator.hasNext()){ Map.Entry next = iterator.next(); EffectBuffer value = next.getValue(); + if(value.getType() ==3 && value.getEndTime() == -1){ + continue; + } if(value.getType() == 2){ //挖矿 - int willDgger = (int)((now - value.getStartTime()) / 1000); + int intervalMs = SBloodyBattleSetting.sBloodyBattleSetting.getCollectingInterval() * 1000; + int willDgger = (int)((now - value.getStartTime()) / intervalMs); Creature creature = (Creature) this; Creature mineral =(Creature) scene.getSceneActorMap().get(value.getCaster()); if(willDgger>0&&mineral.getLife().getCurHp()>0) { @@ -60,7 +68,7 @@ public abstract class SceneActor{ if(mineral.getLife().getCurHp()>0){ scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,mineral.getId()); } - value.setStartTime(value.getStartTime() + reallyDigger*1000); + value.setStartTime(value.getStartTime() + reallyDigger*intervalMs); } if(needRemoveDigger || mineral.getLife().getCurHp()<=0 ){ iterator.remove(); @@ -95,15 +103,28 @@ public abstract class SceneActor{ return; } addOrUpdateBuffer(new EffectBuffer(scene.getBufferId(),4,now,now+5000,this.getId(),0,0)); + // 定位到出生点位置 + this.setPos(SceneManager.selectForPlayerRebirth(scene)); + scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,id); + }else{ Creature creature = (Creature) scene.getSceneActorMap().get(value.getCaster()); - int mineral = creature.getMineral(); - if(mineral>0){ - creature.setMineral(0); - scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,creature.getId()); - ((Creature)this).addMineral(mineral); - } + if(creature.getType() == ActorType.Monster){ + ((Creature)this).addMineral(SBloodyBattleSetting.sBloodyBattleSetting.getMonster()[creature.getId()][2]); + }else{ + int mineral = creature.getMineral(); + if(mineral>1){ + int gainMineral=mineral/2 + mineral%2; + creature.setMineral(mineral -gainMineral); + scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,creature.getId()); + if(this.getType() == ActorType.Player){ + ((Creature)this).addMineral(gainMineral); + }else{ + //todo 随机散落 + } + } + } stateType = StateType.MOVEABLE; scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,this.getId()); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMineral.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMineral.java index 323ed4dca..a4b26b7a3 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMineral.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMineral.java @@ -2,6 +2,16 @@ package com.ljsd.jieling.battle.actor; public class SceneMineral extends Creature { + private int size; + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + @Override public ActorType getType() { return ActorType.Mineral; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMonster.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMonster.java index 484384ed2..17222a1c8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMonster.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/actor/SceneMonster.java @@ -1,8 +1,20 @@ package com.ljsd.jieling.battle.actor; +import java.util.List; + public class SceneMonster extends Creature{ + + private List remainHps; @Override public ActorType getType() { return ActorType.Monster; } + + public List getRemainHps() { + return remainHps; + } + + public void setRemainHps(List remainHps) { + this.remainHps = remainHps; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/match/BloodyBattleMatchServer.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/match/BloodyBattleMatchServer.java index 545da208f..40724ae8e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/match/BloodyBattleMatchServer.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/match/BloodyBattleMatchServer.java @@ -14,7 +14,7 @@ public class BloodyBattleMatchServer implements IMatch{ private static Map roomFull = new HashMap<>(); private static Map uidToRommMap = new HashMap<>(); static { - roomFull.put(1,2); + roomFull.put(1,1); } @@ -51,4 +51,9 @@ public class BloodyBattleMatchServer implements IMatch{ public Room getRoomId(int uid) { return uidToRommMap.get(uid); } + + @Override + public void clearUidRoom(int uid) { + uidToRommMap.remove(uid); + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/match/IMatch.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/match/IMatch.java index e9937871f..99994f4bc 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/match/IMatch.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/match/IMatch.java @@ -26,4 +26,6 @@ public interface IMatch { Room filter(List rooms) ; } + public void clearUidRoom(int uid); + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/match/MatchServerice.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/match/MatchServerice.java index 5c32e4192..aa5d75c0d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/match/MatchServerice.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/match/MatchServerice.java @@ -21,6 +21,11 @@ public class MatchServerice { matcherServerMap.put(1,new BloodyBattleMatchServer()); } + public static void clearUidRoomInfo(int uid){ + IMatch iMatch = matcherServerMap.get(1); + iMatch.clearUidRoom(uid); + } + //有用户加入时,同时做匹配 //matchRule 匹配规则 public static synchronized void addPlayer(ISession iSession, RoomProto.RoomMatchRequest request, int responseMsgId) throws Exception { @@ -115,8 +120,6 @@ public class MatchServerice { SceneManager.startGame(scene); for(SceneActor sceneActor : scene.getSceneActorMap().values()){ if(sceneActor.getType()== ActorType.Player){ - sceneActor.setStateType(StateType.MOVEABLE); - scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,sceneActor.getId()); MessageUtil.sendRoomStartGameIndication(sceneActor.getId()); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/room/BeanToProto.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/room/BeanToProto.java index e98bbb1c5..3e690b088 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/room/BeanToProto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/room/BeanToProto.java @@ -1,6 +1,10 @@ package com.ljsd.jieling.battle.room; +import com.ljsd.jieling.battle.BattleManager; +import com.ljsd.jieling.battle.UserBloodySnpInfo; import com.ljsd.jieling.battle.actor.*; +import com.ljsd.jieling.logic.dao.FamilyHeroInfo; +import com.ljsd.jieling.logic.hero.HeroAttributeEnum; import com.ljsd.jieling.protocols.CommonProto; import java.util.Iterator; @@ -18,12 +22,27 @@ public class BeanToProto { if(actorType != ActorType.Npc){ builder.setCreature(getCreature((Creature)sceneActor)); } + if(actorType == ActorType.Player){ + builder.setUserName(BattleManager.bloodMyHeroInfoMap.get(sceneActor.getId()).getName()); + } return builder.build(); } public static CommonProto.Creature getCreature(Creature creature){ - return CommonProto.Creature.newBuilder() - .setCurHp(creature.getLife().getCurHp()) + CommonProto.Creature.Builder builder = CommonProto.Creature.newBuilder(); + if(creature.getType() == ActorType.Player){ + UserBloodySnpInfo userBloodySnpInfo = BattleManager.bloodMyHeroInfoMap.get(creature.getId()); + Map heroAllAttributes = userBloodySnpInfo.getHeroAllAttributes(); + for(Map.Entry familyHeroInfoEntry : heroAllAttributes.entrySet()){ + String heroId = familyHeroInfoEntry.getKey(); + FamilyHeroInfo familyHeroInfo = familyHeroInfoEntry.getValue(); + Map attribute = familyHeroInfo.getAttribute(); + Integer hp = attribute.get(HeroAttributeEnum.Hp.getPropertyId()); + Integer curHp = attribute.get(HeroAttributeEnum.CurHP.getPropertyId()); + builder.addHeroInfo(CommonProto.BloodyHeroInfo.newBuilder().setHeroId(heroId).setHeroHp(curHp).setHeroMaxHp(hp).setHeroTid(familyHeroInfo.getTempleteId())); + } + } + return builder.setCurHp(creature.getLife().getCurHp()) .setMaxHp(creature.getLife().getMaxMp()) .setSpeed(creature.getSpeed()) .addAllPath(creature.getPath()) @@ -33,11 +52,16 @@ public class BeanToProto { } public static CommonProto.ActorEffectBufferInfo getActorEffectBufferInfo(EffectBuffer effectBuffer){ + int sendEndTime=-1; + long endTime = effectBuffer.getEndTime(); + if(endTime!=-1){ + sendEndTime = (int)(endTime/1000); + } return CommonProto.ActorEffectBufferInfo.newBuilder() .setId(effectBuffer.getId()) .setType(effectBuffer.getType()) .setStartTime((int)(effectBuffer.getStartTime()/1000)) - .setEndTime((int)(effectBuffer.getEndTime()/1000)) + .setEndTime(sendEndTime) .setTarget(effectBuffer.getTarget()) .setCaster(effectBuffer.getCaster()) .addAllValue(effectBuffer.getValues()) @@ -56,6 +80,7 @@ public class BeanToProto { builder.addActorEffectBufferInfo(getActorEffectBufferInfo(next.getValue())); } } + builder.addAllBarrierPoint(SceneManager.bloodyMap.getBarrierPoints()); return builder.build(); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/room/BloodyMap.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/room/BloodyMap.java new file mode 100644 index 000000000..fc7bd9412 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/room/BloodyMap.java @@ -0,0 +1,38 @@ +package com.ljsd.jieling.battle.room; + +import java.util.ArrayList; +import java.util.List; + +public class BloodyMap { + private int mapId; + + private List barrierPoints = new ArrayList<>(); + + private int round; + + public BloodyMap(int mapId) { + this.mapId = mapId; + } + + public void addBarrierPoint(int pos){ + barrierPoints.add(pos); + } + + + public int getMapId() { + return mapId; + } + + public List getBarrierPoints() { + return barrierPoints; + } + + + public int getRound() { + return round; + } + + public void setRound(int round) { + this.round = round; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/battle/room/SceneManager.java b/serverlogic/src/main/java/com/ljsd/jieling/battle/room/SceneManager.java index 9ad936071..4d73ecf71 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/battle/room/SceneManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/battle/room/SceneManager.java @@ -1,16 +1,29 @@ package com.ljsd.jieling.battle.room; +import com.ljsd.jieling.battle.BattleManager; +import com.ljsd.jieling.battle.UserBloodySnpInfo; import com.ljsd.jieling.battle.actor.*; +import com.ljsd.jieling.config.MapPointConfig; +import com.ljsd.jieling.config.SBloodyBattleSetting; +import com.ljsd.jieling.config.SCMap; +import com.ljsd.jieling.config.SChallengeMapConfig; +import com.ljsd.jieling.globals.Global; +import com.ljsd.jieling.handler.map.EventType; +import com.ljsd.jieling.handler.map.behavior.BehaviorUtil; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.SceneFight; +import com.ljsd.jieling.util.CellUtil; import com.ljsd.jieling.util.MathUtils; import com.ljsd.jieling.util.MessageUtil; +import com.ljsd.jieling.util.MonsterUtil; import java.util.*; +import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ScheduledThreadPoolExecutor; public class SceneManager { @@ -18,10 +31,46 @@ public class SceneManager { private static ScheduledThreadPoolExecutor scheduledExecutor=new ScheduledThreadPoolExecutor(8); //管理task + public static BloodyMap bloodyMap; + public static Queue> possibalePositions = new LinkedBlockingDeque<>(); + + public static void initMap(){ + BloodyMap bloodyMapTmp = new BloodyMap(12); + Map scMap = SCMap.sCMap.get(12); + for (Map.Entry entry : scMap.entrySet()) { + SCMap scMap1 = entry.getValue(); + MapPointConfig mapPointConfig = MapPointConfig.getScMapEventMap().get(scMap1.getEvent()); + if(mapPointConfig !=null && mapPointConfig.getStyle() == EventType.hinder){ + int[][] groups = scMap1.getGroups(); + for(int[] pos : groups){ + int xy = CellUtil.xy2Pos(pos[0], pos[1]); + bloodyMapTmp.addBarrierPoint(xy); + } + } + } + int[][] mineralCeiling = SBloodyBattleSetting.sBloodyBattleSetting.getMineralCeiling(); + int min =999999999; + for(int[] mineralCeilingSingle : mineralCeiling){ + int minRound = mineralCeilingSingle[1]; + if(min < minRound){ + min = minRound; + } + } + bloodyMapTmp.setRound(min); + bloodyMap = bloodyMapTmp; + calPossiblePoss(); + + } + public static void createScene(Room room){ Scene scene = new Scene(); - scene.setMapId(101); - int i = 6; + List userInitBirths = null; + while ( ( userInitBirths=possibalePositions.poll()) == null){ + calPossiblePoss(); + } + scene.setMapId(bloodyMap.getMapId()); + scene.setRoomId(room.getId()); + SBloodyBattleSetting sBloodyBattleSetting = SBloodyBattleSetting.sBloodyBattleSetting; for(Integer uid : room.fightPlayer){ User user = null; try { @@ -31,54 +80,124 @@ public class SceneManager { } catch (Exception e) { e.printStackTrace(); } - + UserBloodySnpInfo userBloodySnpInfo = BattleManager.snapUserFightInfo(user, 1); ScenePlayer playerA = new ScenePlayer(); playerA.setId(uid); playerA.setScene(scene); playerA.setStateType(StateType.UNREADY_STATE); - playerA.setLife(new Life(1000,1000)); - playerA.setPos(256*i+ MathUtils.randomInt(i)+1); - i++; + int hp = userBloodySnpInfo.getMaxHp(); + playerA.setLife(new Life(hp,hp)); + playerA.setPos(userInitBirths.remove(0)); + playerA.setSpeed(sBloodyBattleSetting.getPlayerSpeed()); scene.addScenActor(playerA); } + //创建矿点 + createMinear(scene,-1,1); - SceneMineral sceneMineral = new SceneMineral(); - sceneMineral.setId(999); - sceneMineral.setPos(256*3+10); - sceneMineral.setLife(new Life(300000,300000)); - sceneMineral.setStateType(StateType.READYED_STATE); - scene.addScenActor(sceneMineral); - - SceneMineral sceneMinera2 = new SceneMineral(); - sceneMinera2.setId(1999); - sceneMinera2.setPos(256*5+2); - sceneMinera2.setLife(new Life(5,5)); - scene.addScenActor(sceneMinera2); - - /* SceneMonster sceneMonster = new SceneMonster(); - sceneMonster.setId(52014); - sceneMonster.setScene(scene); - sceneMonster.setLife(new Life(20000,20000)); - sceneMonster.setPos(256*5+ 10); - List secondPath = new ArrayList<>(); - secondPath.add(256*5+11); - secondPath.add(256*5+12); - secondPath.add(256*5+13); - secondPath.add(256*5+14); - secondPath.add(256*4+14); - Command commandC = new Command(1,sceneMonster,secondPath); - scene.addCommand(commandC); - scene.addScenActor(sceneMonster);*/ + //创建怪物 + int[][] monster = sBloodyBattleSetting.getMonster(); + int[][][] monsterPatrol = sBloodyBattleSetting.getMonsterPatrol(); + Map> monsterPotrolPaths = sBloodyBattleSetting.getMonsterPotrolPaths(); + int monsterIndex = 0; + for(int[] monsterSingle : monster){ + SceneMonster sceneMonster = new SceneMonster(); + sceneMonster.setScene(scene); + sceneMonster.setId(monsterIndex+1); + int[][] patrol = monsterPatrol[monsterIndex]; + int xy2Pos = CellUtil.xy2Pos(patrol[0][0], patrol[0][1]); + sceneMonster.setPos(xy2Pos); + int monsterGroupId = monsterSingle[0]; + Map> monsterByGroup = MonsterUtil.getMonsterByGroup(monsterGroupId); + List monsterGroupList = BehaviorUtil.getFightTeamInfos(monsterGroupId,monsterByGroup, Global.MONSTER_1); + int hp = 0; + List hps = new ArrayList<>(); + for(CommonProto.FightTeamInfo fightTeamInfo : monsterGroupList){ + List fightUnitListList = fightTeamInfo.getFightUnitListList(); + for(CommonProto.FightUnitInfo fightUnitInfo : fightUnitListList){ + String hpS = fightUnitInfo.getProperty().split("#")[1]; + int fightHp = Integer.parseInt(hpS); + hp+=fightHp; + hps.add(fightHp); + } + } + sceneMonster.setRemainHps(hps); + sceneMonster.setLife(new Life(hp,hp)); + sceneMonster.setSpeed(sBloodyBattleSetting.getMonsterSpeed()); + Command commandC = new Command(1,sceneMonster,monsterPotrolPaths.get(monsterIndex+1)); + scene.addCommand(commandC); + scene.addScenActor(sceneMonster); + monsterIndex++; + break; + } sceneMap.put(room.getId(),scene); + //todo 发送到redis,房间服务器去这里拿数据 MessageUtil.sendRoomMatchSuccessIndication(scene); } + + + public static void createMinear(Scene scene,int target,int nums){ + //创建矿点 + SBloodyBattleSetting sBloodyBattleSetting = SBloodyBattleSetting.sBloodyBattleSetting; + Map initializeMineMap = sBloodyBattleSetting.getInitializeMineMap(); + Map scMap = SCMap.sCMap.get(bloodyMap.getMapId()); + Set excluIndexs = new HashSet<>(bloodyMap.getBarrierPoints()); + for(SceneActor sceneActor : scene.getSceneActorMap().values()){ + excluIndexs.add(sceneActor.getPos()); + } + for (Map.Entry entry : scMap.entrySet()) { + SCMap scMap1 = entry.getValue(); + int event = scMap1.getEvent(); + if(event == 1 || event == 2 ){ + if(target!=-1 && target!=event){ + continue; + } + int[][] groups = scMap1.getGroups(); + if(target == -1){ + nums = initializeMineMap.get(event); + } + + Set randomIndex = new HashSet<>(); + Set cacheRemove = new HashSet<>(); + while (nums -- >0){ + int index = MathUtils.randomWeight(groups, randomIndex); + int pos = CellUtil.xy2Pos(groups[index][0], groups[index][1]); + while(excluIndexs.contains(pos)){ + cacheRemove.add(index); + index = MathUtils.randomWeight(groups, randomIndex); + pos = CellUtil.xy2Pos(groups[index][0], groups[index][1]); + } + excluIndexs.add(pos); + + } + randomIndex.removeAll(cacheRemove); + for(Integer index : randomIndex){ + SceneMineral sceneMineral = new SceneMineral(); + int pos = CellUtil.xy2Pos(groups[index][0], groups[index][1]); + sceneMineral.setId(pos); + sceneMineral.setPos(pos); + int hp = sBloodyBattleSetting.getMineralCeilingMap().get(event)[4]; + sceneMineral.setLife(new Life(hp,hp)); + sceneMineral.setStateType(StateType.READYED_STATE); + sceneMineral.setSize(event); + scene.addScenActor(sceneMineral); + break; + } + break; + } + } + } + public static Scene getSceneMap(int roomId) { return sceneMap.get(roomId); } + public static void clearScene(int roomId){ + sceneMap.remove(roomId); + } + public static void createScene() throws InterruptedException { @@ -170,11 +289,70 @@ public class SceneManager { } + public static void calPossiblePoss(){ + SChallengeMapConfig sChallengeMapConfig = SChallengeMapConfig.integerSChallengeMapConfigMap.get(bloodyMap.getMapId()); + int[] size = sChallengeMapConfig.getSize(); + int maxX = size[0]; + int maxY = size[1]; + SBloodyBattleSetting sBloodyBattleSetting = SBloodyBattleSetting.sBloodyBattleSetting; + if(possibalePositions.size()>50){ + return; + } + for(int i=0;i<100;i++){ + List randomPositions = new ArrayList<>(10); + int[][] points = sBloodyBattleSetting.getPoint(); + int selectNums = 0; + Set randomIndexs = new HashSet<>(); + Set removeIndexs = new HashSet<>(); + while (true){ + int index= MathUtils.randomWeight(points,randomIndexs); + Set cache = new HashSet<>(); + int[] possiblePoint = points[index]; + if( !CellUtil.calSurPos(possiblePoint[0],possiblePoint[1],sBloodyBattleSetting.getPointInterval(),maxX,maxY,cache) ){ + removeIndexs.add(index); + continue; + } + selectNums++; + if(selectNums>=10){ + break; + } + } + randomIndexs.removeAll(removeIndexs); + for(Integer index : randomIndexs){ + int[] possiable = points[index]; + randomPositions.add(CellUtil.xy2Pos(possiable[0], possiable[1])); + } + possibalePositions.add(randomPositions); + } + + } + + public static int selectForPlayerRebirth(Scene scene){ + List excludePosList = new ArrayList<>(); + Map sceneActorMap = scene.getSceneActorMap(); + for(SceneActor sceneActor : sceneActorMap.values()){ + int pos = sceneActor.getPos(); + excludePosList.add(pos); + } + + List poll = null; + while (true){ + while ( ( poll=possibalePositions.poll()) == null){ + calPossiblePoss(); + } + poll.removeAll(excludePosList); + if(poll.size()>0){ + return poll.get(0); + } + } + } + public static void main(String[] args) throws InterruptedException { createScene(); } public static void startGame(Scene scene) { + scene.setStartTime(System.currentTimeMillis()); scheduledExecutor.execute(scene); System.out.println("start battle pvp..........................."); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SBeStronger.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SBeStronger.java new file mode 100644 index 000000000..44b847a6f --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SBeStronger.java @@ -0,0 +1,31 @@ +package com.ljsd.jieling.config; + +import com.ljsd.jieling.logic.STableManager; +import com.ljsd.jieling.logic.Table; + +import java.util.Map; + +@Table(name ="BeStronger") +public class SBeStronger implements BaseConfig { + + private int id; + + private int type; + + + @Override + public void init() throws Exception { + + } + + + public int getId() { + return id; + } + + public int getType() { + return type; + } + + +} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SBloodyBattleSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SBloodyBattleSetting.java new file mode 100644 index 000000000..4c8ae2a11 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SBloodyBattleSetting.java @@ -0,0 +1,227 @@ +package com.ljsd.jieling.config; + +import com.ljsd.jieling.logic.STableManager; +import com.ljsd.jieling.logic.Table; +import com.ljsd.jieling.util.CellUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Table(name ="BloodyBattleSetting") +public class SBloodyBattleSetting implements BaseConfig { + + private int id; + + private int matchTime; + + private int battleTime; + + private int countDown; + + private int invincible; + + private int[] settleTime; + + private int[][] playerSscore; + + private int[] danIntegral; + + private int[][] dropPoints; + + private int[] price; + + private int[] seasonPass; + + private int[][][] seasonReward; + + private int[][][] seasonTokenReward; + + private int[][] point; + + private int pointInterval; + + private int[][] monster; + + private int[][][] monsterPatrol; + + private int[][] buildingBuff; + + private int[][] mineralCeiling; + + private int collectingInterval; + + private int[][] debuff; + + private int monsterSpeed; + + public static SBloodyBattleSetting sBloodyBattleSetting; + + private int[][] initializeMine; + private Map initializeMineMap; + private Map> monsterPotrolPaths; + private Map mineralCeilingMap; + + private int playerSpeed; + + private int[] fightTime; + + + @Override + public void init() throws Exception { + + SBloodyBattleSetting sBloodyBattleSettingTmp = STableManager.getConfig(SBloodyBattleSetting.class).get(1); + int[][] initializeMine = sBloodyBattleSettingTmp.getInitializeMine(); + Map initializeMineMapTmp = new HashMap<>(initializeMine.length); + for(int[] initializeMineSingle : initializeMine ){ + initializeMineMapTmp.put(initializeMineSingle[0],initializeMineSingle[1]); + } + + int[][][] monsterPatrol = sBloodyBattleSettingTmp.getMonsterPatrol(); + int[][] monster = sBloodyBattleSettingTmp.getMonster(); + Map> monsterPotrolPaths = new HashMap<>(monsterPatrol.length); + for(int i=0;i paths = new ArrayList<>(monsterPotrolPath.length); + for(int j=0;j mineralCeilingMapTmp = new HashMap<>(2); + for(int[] mineralCeilingSingle : sBloodyBattleSettingTmp.getMineralCeiling()){ + mineralCeilingMapTmp.put(mineralCeilingSingle[0],mineralCeilingSingle); + } + sBloodyBattleSettingTmp.setMonsterPotrolPaths(monsterPotrolPaths); + sBloodyBattleSettingTmp.setInitializeMineMap(initializeMineMapTmp); + sBloodyBattleSettingTmp.setMineralCeilingMap(mineralCeilingMapTmp); + sBloodyBattleSetting = sBloodyBattleSettingTmp; + } + + + public int getId() { + return id; + } + + public int getMatchTime() { + return matchTime; + } + + public int getBattleTime() { + return battleTime; + } + + public int getCountDown() { + return countDown; + } + + public int getInvincible() { + return invincible; + } + + public int[] getSettleTime() { + return settleTime; + } + + public int[][] getPlayerSscore() { + return playerSscore; + } + + public int[] getDanIntegral() { + return danIntegral; + } + + public int[][] getDropPoints() { + return dropPoints; + } + + public int[] getPrice() { + return price; + } + + public int[] getSeasonPass() { + return seasonPass; + } + + public int[][][] getSeasonReward() { + return seasonReward; + } + + public int[][][] getSeasonTokenReward() { + return seasonTokenReward; + } + + public int[][] getPoint() { + return point; + } + + public int getPointInterval() { + return pointInterval; + } + + public int[][] getMonster() { + return monster; + } + + public int[][][] getMonsterPatrol() { + return monsterPatrol; + } + + public int[][] getBuildingBuff() { + return buildingBuff; + } + + public int[][] getMineralCeiling() { + return mineralCeiling; + } + + public int getCollectingInterval() { + return collectingInterval; + } + + public int[][] getDebuff() { + return debuff; + } + + public int[][] getInitializeMine() { + return initializeMine; + } + + public Map getInitializeMineMap() { + return initializeMineMap; + } + + public void setInitializeMineMap(Map initializeMineMap) { + this.initializeMineMap = initializeMineMap; + } + + public void setMonsterPotrolPaths(Map> monsterPotrolPaths) { + this.monsterPotrolPaths = monsterPotrolPaths; + } + + public Map> getMonsterPotrolPaths() { + return monsterPotrolPaths; + } + + public Map getMineralCeilingMap() { + return mineralCeilingMap; + } + + public void setMineralCeilingMap(Map mineralCeilingMap) { + this.mineralCeilingMap = mineralCeilingMap; + } + + public int getMonsterSpeed() { + return monsterSpeed; + } + + public int getPlayerSpeed() { + return playerSpeed; + } + + public int[] getFightTime() { + return fightTime; + } +} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java index 33aa943c6..4b2c852f3 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java @@ -11,6 +11,12 @@ public class SDifferDemonsStageConfig implements BaseConfig { private int id; + private int[] passiveSkillId; + + + private String passiveSkillString; + + private int skillId; @@ -23,7 +29,19 @@ public class SDifferDemonsStageConfig implements BaseConfig { @Override public void init() throws Exception { - sDifferDemonsStageConfigMap = STableManager.getConfig(SDifferDemonsStageConfig.class); + Map sDifferDemonsStageConfigMapTmp = SDifferDemonsStageConfig.sDifferDemonsStageConfigMap = STableManager.getConfig(SDifferDemonsStageConfig.class); + for(SDifferDemonsStageConfig sDifferDemonsStageConfig : sDifferDemonsStageConfigMapTmp.values()){ + int[] passiveSkillIds = sDifferDemonsStageConfig.getPassiveSkillId(); + if(passiveSkillIds.length>0){ + StringBuilder sb = new StringBuilder(); + for(int i=0;i remainHp = new ArrayList<>(5); for (int i = 2; i < checkResult.length; i++) { if (checkResult[i] <= 0) { @@ -1417,7 +1418,7 @@ public class MapLogic { LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList); LuaValue getOptionData = FightDataUtil.getOptionData(frames); int mostTime = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getMostTime(); - checkResult = CheckFight.getInstance().checkFight(seed, mostTime, getFightData, getOptionData); + checkResult = CheckFight.getInstance().checkFight(seed, mostTime, getFightData, getOptionData, FightType.MapExploreFight); resultCode = checkResult[0]; if (resultCode == -1) { MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "战斗异常!"); @@ -2003,7 +2004,7 @@ public class MapLogic { LuaValue getOptionData = FightDataUtil.getOptionData(frames); MapManager mapManager = user.getMapManager(); SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getFindSuddenlyBossMapId()); - int[] checkResult = CheckFight.getInstance().checkFight(seed, sChallengeConfig.getMostTime(), getFightData, getOptionData); + int[] checkResult = CheckFight.getInstance().checkFight(seed, sChallengeConfig.getMostTime(), getFightData, getOptionData,FightType.MapExploreFight); //校验结果码 1:胜利 int resultCode = checkResult[0]; @@ -2145,7 +2146,7 @@ public class MapLogic { LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList); LuaValue getOptionData = FightDataUtil.getOptionData(frames); - int[] checkResult = CheckFight.getInstance().checkFight(seed, sLevelDifficultyConfig.getRankTime(), getFightData, getOptionData); + int[] checkResult = CheckFight.getInstance().checkFight(seed, sLevelDifficultyConfig.getRankTime(), getFightData, getOptionData,FightType.StoryFight); LevelDifficultyManager levelDifficultyManager = user.getLevelDifficultyManager(); @@ -2288,7 +2289,7 @@ public class MapLogic { LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList); LuaValue getOptionData = FightDataUtil.getOptionData(frames); - int[] checkResult = CheckFight.getInstance().checkFight(seed, sFloodConfig.getBattleTime(), getFightData, getOptionData); + int[] checkResult = CheckFight.getInstance().checkFight(seed, sFloodConfig.getBattleTime(), getFightData, getOptionData,FightType.MapExploreFight); //校验结果码 1:胜利 int resultCode = checkResult[0]; 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 d12da03e5..f26475638 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 @@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.dao.StoreInfo; import com.ljsd.jieling.logic.dao.StoreManager; import com.ljsd.jieling.logic.dao.TeamPosHeroInfo; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.fight.FightType; import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.protocols.CommonProto; @@ -229,6 +230,7 @@ public class BehaviorUtil { newBuilder() .addAllFightUnitList(heroFightInfos) .setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(user,teamId)) + .setTeamPassiveList(HeroLogic.getInstance().getPokenmonPassiveSkills(user,teamId)) .build(); return fightTeamInfo; } @@ -362,6 +364,7 @@ public class BehaviorUtil { //设置战斗随机种子 int seed = (int)(System.currentTimeMillis()/1000); fightData.setFightSeed(seed); + fightData.setFightType(FightType.StoryFight.getType()); fightData.setFightMaxTime(maxTime); fightStartRespons.setFightData(fightData); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/KTDataUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/KTDataUtil.java index 0787a3956..cb29a8290 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/KTDataUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/ktbeans/KTDataUtil.java @@ -15,6 +15,7 @@ public class KTDataUtil { ParamDataBean paramDataBean = dataInfo.get(uid); if(paramDataBean!=null){ try { + paramDataBean.setData_unix((int)(System.currentTimeMillis()/1000)); return paramDataBean.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java index c34b4380c..274965025 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java @@ -1,6 +1,7 @@ package com.ljsd.jieling.logic; import com.ljsd.GameApplication; +import com.ljsd.jieling.battle.room.SceneManager; import com.ljsd.jieling.config.SDailyTasksConfig; import com.ljsd.jieling.config.SGlobalSystemConfig; import com.ljsd.jieling.config.ServerConfig; @@ -198,7 +199,7 @@ public class GlobalDataManaager { TimeControllerOfFunction timeControllerOfFunction = globalSystemControl.getTimeControllerOfFunctionMap().get(8); ArenaLogic.getInstance().updateArenaSeason(timeControllerOfFunction.getTimes()); MapLogic.getInstance().updateEndlessSeason(globalSystemControl.getTimeControllerOfFunctionMap().get(46).getTimes()); - MapLogic.getInstance().setEndlessMapId(getEndleeMapIdByLevel()); + MapLogic.setEndlessMapId(getEndleeMapIdByLevel()); } MissionEventDistributor.init(); DataManagerDistributor.init(); @@ -207,6 +208,7 @@ public class GlobalDataManaager { GuilidManager.init(); new RPCServerTask(configurableApplicationContext).start(); new RPCGmServerTask(configurableApplicationContext).start(); + SceneManager.initMap(); } catch (Exception e) { LOGGER.error("e",e); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java index d5c49d2fe..c9e215ede 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java @@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.arena; +import com.googlecode.protobuf.format.JsonFormat; import com.ljsd.jieling.config.*; import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.core.VipPrivilegeType; @@ -20,6 +21,7 @@ import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.fight.CheckFight; +import com.ljsd.jieling.logic.fight.FightType; import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.mail.MailLogic; import com.ljsd.jieling.logic.mission.GameEvent; @@ -249,6 +251,8 @@ public class ArenaLogic { public static int getFightResultByPersonToPerson(User mine, int myteamId, User defUser, int defTeamId, ArenaRecord arenaRecord, int skipFight, ArenaInfoProto.ArenaChallengeResponse.Builder builder){ CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId,true); CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser,defTeamId,false); + System.out.println(JsonFormat.printToString(fightTeamInfo)); + System.out.println(JsonFormat.printToString(deffightTeamInfo)); //设置战斗随机种子 int seed = (int)(System.currentTimeMillis()/1000); @@ -269,7 +273,7 @@ public class ArenaLogic { arenaRecord.setFightData(snapRecord); LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo); LuaValue getOptionData = FightDataUtil.getOptionData(""); - int[] checkResult = CheckFight.getInstance().checkFight(seed,SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData); + int[] checkResult = CheckFight.getInstance().checkFight(seed,SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData, FightType.ArenaFight); return checkResult[0]; } @@ -288,7 +292,7 @@ public class ArenaLogic { .build()); LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo); LuaValue getOptionData = FightDataUtil.getOptionData(""); - int[] checkResult = CheckFight.getInstance().checkFight(seed,SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData); + int[] checkResult = CheckFight.getInstance().checkFight(seed,SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData,FightType.ArenaFight); return checkResult[0]; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/blood/BloodLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/blood/BloodLogic.java index 3ad51b68d..e1505bf73 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/blood/BloodLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/blood/BloodLogic.java @@ -38,9 +38,9 @@ public class BloodLogic { while (it.hasNext()) { TeamPosHeroInfo heroInfo = it.next(); Hero hero = heroManager.getHero(heroInfo.getHeroId()); - Map heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, 501); + Map heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId); //加buff - if(buffInfo.length>0){ + if(buffInfo!=null && buffInfo.length>0){ for(int i = 0 ; i < buffInfo.length ; i++){ heroAttributeMap = CombatLogic.getInstance().bufferOneHeroAttrAfterEat(heroAttributeMap,buffInfo[i]); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java index ccdaba040..756f93617 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java @@ -13,6 +13,7 @@ import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.GuildInfo; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.fight.CheckFight; +import com.ljsd.jieling.logic.fight.FightType; import com.ljsd.jieling.logic.hero.HeroAttributeEnum; import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.network.session.ISession; @@ -377,7 +378,7 @@ public class GuildFightLogic { heroAttackFightInfos.add(heroFightInfo); } CommonProto.FightTeamInfo.Builder fightAttackTeamInfoBuilder = CommonProto.FightTeamInfo.newBuilder().addAllFightUnitList(heroAttackFightInfos) - .setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(userAttack, 1)); + .setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(userAttack, 1)).setTeamPassiveList(HeroLogic.getInstance().getPokenmonPassiveSkills(userAttack,1)); fightAttackTeamInfo = fightAttackTeamInfoBuilder.build(); }else{ fightAttackTeamInfo = BehaviorUtil.getFightTeamInfo(userAttack,502,true); @@ -392,7 +393,7 @@ public class GuildFightLogic { .setHeroFightInfos(fightAttackTeamInfo) .addMonsterList(fightDefendTeamInfo) .build(); - int[] fightResult = CheckFight.getInstance().checkFight(seed, 1000, getFightData, getOptionData); + int[] fightResult = CheckFight.getInstance().checkFight(seed, 1000, getFightData, getOptionData, FightType.GuildFight); for (int i = 0; i < fightResult.length; i++) { System.out.println(fightResult[i]); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CheckFight.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CheckFight.java index a399d27c0..0df857522 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CheckFight.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CheckFight.java @@ -101,12 +101,14 @@ public class CheckFight { * @param optionData * @return {战斗结果,战斗时间,单位1剩余血量,单位2剩余血量,单位3剩余血量,单位4剩余血量,单位5剩余血量} */ - public int[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData){ + public int[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){ LuaValue transCoderObj = this.getTransCoderObj(); LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute")); LuaValue args = new LuaTable(); args.set("seed",seed); args.set("maxTime",maxTime); + //todo type + args.set("type",fightType.getType()); LuaValue result = func.call( args,fightData,optionData); int status = result.get("result").toint(); int duration = result.get("duration").toint(); 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 f779cac4e..21efdd77c 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 @@ -227,7 +227,7 @@ public class CombatLogic { int seed = (int)(System.currentTimeMillis()/1000); LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList); LuaValue getOptionData = FightDataUtil.getOptionData(""); - int[] checkResult = CheckFight.getInstance().checkFight(seed, sAdventureConfig.getSystemBossTime(), getFightData, getOptionData); + int[] checkResult = CheckFight.getInstance().checkFight(seed, sAdventureConfig.getSystemBossTime(), getFightData, getOptionData,FightType.AdventureLock); int fightResult = checkResult[0]; if(fightResult == 1){ adventureManager.addAdventureStation(new AdventureStateInfo(arenaId)); @@ -716,7 +716,7 @@ public class CombatLogic { .addAllMonsterList(monsterGroupList) .build(); builder.setFightData(build); - int[] checkResult = CheckFight.getInstance().checkFight(seed, sAdventureConfig.getInvasionBossTime(), getFightData, getOptionData); + int[] checkResult = CheckFight.getInstance().checkFight(seed, sAdventureConfig.getInvasionBossTime(), getFightData, getOptionData,FightType.InvasionBossFight); totalHurt+= updateBossAndGetHurtForFight(checkResult, adventureBoss); fightResult = checkResult[0]; //发送击杀boss奖励和发现者奖励 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/FightType.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/FightType.java new file mode 100644 index 000000000..64731931b --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/FightType.java @@ -0,0 +1,24 @@ +package com.ljsd.jieling.logic.fight; + +public enum FightType { + StoryFight(1), //故事副本 + MapExploreFight(2), // 地图探索 + ArenaFight(3), //竞技场 + InvasionBossFight(4),//秘境boss + AdventureLock(5), // 解锁秘境 + GuildFight(6), // 公会站 + BloodyFight(7), // 血战 + + + ; + + private int type; + + public int getType() { + return type; + } + + FightType(int type) { + this.type = type; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 012e70b05..0afad01bb 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -860,6 +860,32 @@ public class HeroLogic { return sb; } + public StringBuilder getHeroPropertyBuilder(StringBuilder sb,FamilyHeroInfo hero,Map heroAttributeMap){ + int heroLevel = hero.getLevel(); + sb.append(heroLevel).append(DIVISION); + SCHero scHero = SCHero.getsCHero().get(hero.getTempleteId()); + List templatePropetyIds = transTemplateByHeroPropertyName.get(scHero.getPropertyName()); + for(Integer templatePropetyId:templatePropetyIds){ + Integer propertyValue = heroAttributeMap.get(templatePropetyId); + if(propertyValue == null){ + propertyValue =0; + } + SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(templatePropetyId); + if(sPropertyConfig.getIfFormula() == 1){ + sb.append(propertyValue/(heroLevel+10)/100).append(DIVISION); + }else{ + if(sPropertyConfig.getStyle() == GlobalsDef.PERCENT_TYPE){ + sb.append(propertyValue/10000f).append(DIVISION); + + }else{ + sb.append(propertyValue).append(DIVISION); + } + } + + } + return sb; + } + public StringBuilder getRobotHeroProperty(SArenaRobotConfig sArenaRobotConfig,SCHero scHero, StringBuilder sb){ int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId(); @@ -892,7 +918,7 @@ public class HeroLogic { StringBuilder pokenSkillResult = new StringBuilder(); List teamPosForPokenInfos = user.getTeamPosManager().getTeamPosForPoken().get(teamId); if (teamPosForPokenInfos==null){ - return ""; + return ""; } Map pokemonMap = user.getPokemonManager().getPokemonMap(); Collections.sort(teamPosForPokenInfos); @@ -905,6 +931,24 @@ public class HeroLogic { return pokenSkillResult.toString(); } + public String getPokenmonPassiveSkills(User user,int teamId){ + StringBuilder pokenSkillResult = new StringBuilder(); + List teamPosForPokenInfos = user.getTeamPosManager().getTeamPosForPoken().get(teamId); + if (teamPosForPokenInfos==null){ + return ""; + } + Map pokemonMap = user.getPokemonManager().getPokemonMap(); + Collections.sort(teamPosForPokenInfos); + for(TeamPosForPokenInfo teamPosForPokenInfo:teamPosForPokenInfos){ + int pokemonId = teamPosForPokenInfo.getPokenId(); + Pokemon pokemon = pokemonMap.get(pokemonId); + SDifferDemonsStageConfig sDifferDemonsStageConfig = SDifferDemonsStageConfig.getsDifferDemonsStageConfigMap(pokemonId*100 + pokemon.getAllStage()); + pokenSkillResult.append(sDifferDemonsStageConfig.getPassiveSkillString()).append("|"); + } + String s = pokenSkillResult.toString(); + return s.substring( 0,(s.length()-1)); + } + public String getRobotPokenmonSkills(SArenaRobotConfig sArenaRobotConfig){ StringBuilder pokenSkillResult = new StringBuilder(); int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId(); @@ -925,6 +969,7 @@ public class HeroLogic { SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); int profession = scHero.getProfession(); Map pokemonMap = pokemonManager.getPokemonMap(); + LOGGER.info("cal herotid = {},hero51value = {},end",hero.getTemplateId(),heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); for(Map.Entry item : pokemonMap.entrySet()){ Pokemon pokemon = item.getValue(); Map comonpentsLevelMap = pokemon.getComonpentsLevelMap(); @@ -941,6 +986,7 @@ public class HeroLogic { combinedAttribute(sDifferDemonsComonpentsConfig.getBaseAttribute(),heroAllAttribute); } } + LOGGER.info("cal herotid = {},hero51value = {},end",hero.getTemplateId(),heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); //装备总战力评分 int equipForce=0; boolean needRemove = false; @@ -988,6 +1034,7 @@ public class HeroLogic { HandlerLogicThread handlerThread = instance.handlerThreads[user.getId() % instance.HANDLER_THREAD_NUM]; handlerThread.addAyyncWorker(ayyncWorker); } + LOGGER.info("cal herotid = {},hero51value = {},end",hero.getTemplateId(),heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); //天赋异妖加成 Map ringFireMap = pokemonManager.getRingFireMap(); for(Map.Entry item : ringFireMap.entrySet()){ @@ -1016,10 +1063,12 @@ public class HeroLogic { SRingFireMaterialConfig sRingFireMaterialConfig = SRingFireMaterialConfig.config.get(comonpentId); int[][] comonpentIdProperty = sRingFireMaterialConfig.getProperty(); combinedAttribute(comonpentIdProperty,heroAllAttribute); + LOGGER.info("cal herotid = {},hero51value = {},end",hero.getTemplateId(),heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); } } + LOGGER.info("cal herotid = {},hero51value = {},end",hero.getTemplateId(),heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); //工坊科技树加成 - Map techProfressionMap = user.getWorkShopController().getTechnologyMap().get(scHero.getProfession()); + /* Map techProfressionMap = user.getWorkShopController().getTechnologyMap().get(scHero.getProfession()); if(techProfressionMap!=null){ for(Map.Entry item : techProfressionMap.entrySet()){ SWorkShopTechnology sWorkShopTechnology = SWorkShopTechnology.getsWorkTechMapByTechIdAndLevel(item.getKey(), item.getValue()); @@ -1032,7 +1081,7 @@ public class HeroLogic { } } - } + }*/ //阵营光环加成 if(!isForce){ if(teamId!=0){ @@ -1048,7 +1097,7 @@ public class HeroLogic { heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAllAttribute.get(GlobalsDef.HP_TYPE)); //装备战力保存 heroAllAttribute.put(HeroAttributeEnum.EquipForce.getPropertyId(),equipForce); - // LOGGER.info("cal herotid = {},end",hero.getTemplateId()); + LOGGER.info("cal herotid = {},hero51value = {},end",hero.getTemplateId(),heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); return heroAllAttribute; } @@ -1154,7 +1203,7 @@ public class HeroLogic { Integer propertyId = item.getKey(); float propertyValue = item.getValue(); if(propertyId == HeroAttributeEnum.EquipForce.getPropertyId()){ - // LOGGER.info("the equipScore={}",propertyValue); + LOGGER.info("the equipScore={}",propertyValue); continue; } SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(propertyId); @@ -1164,7 +1213,7 @@ public class HeroLogic { float score = sPropertyConfig.getScore(); result += propertyValue*score; - //LOGGER.info("the propertyId={} the value is ={},propertyValue={},score={},result ={},the value={}",propertyId,propertyValue*score,propertyValue,score,result,propertyValue*score); + // LOGGER.info("the propertyId={} the value is ={},propertyValue={},score={},result ={},the value={}",propertyId,propertyValue*score,propertyValue,score,result,propertyValue*score); } return (int)result; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java index 0409a7a29..97508aa6f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java @@ -306,7 +306,8 @@ public class WorkShopLogic { CommonProto.Equip equipProto = CBean2Proto.getEquipProto(unDetermined); builder.setUnDetermined(equipProto); } - builder.addAllTechnologyInfo(CBean2Proto.getTechInfo(workShopController.getTechnologyMap().values())); + // builder.addAllTechnologyInfo(CBean2Proto.getTechInfo(workShopController.getTechnologyMap().values())); + builder.addAllTechnologyInfo(new ArrayList<>()); MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_WORKSHOP_INFO_RESPONSE_VALUE,builder.build(),true); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java index 90b5081eb..b3b0f040d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CellUtil.java @@ -25,9 +25,10 @@ public class CellUtil { public static void main(String[] args) { + System.out.println(17*256+13); List path = new ArrayList<>(); - path.add(2051); - path.add(2307); + path.add(1257); + path.add(1798); for(Integer pos : path){ System.out.println(pos +"----------------"); System.out.print(pos2XY(pos)[0] + " "); @@ -167,5 +168,50 @@ public class CellUtil { return true; } + public static boolean isContinuous(int lastXY, List cells,List excludes){ + boolean first = false; + if (cells.size() > 0) { + first = checkIsNextOrMineCell(lastXY, cells.get(0)); + if(!first){ + return false; + } + } + for (int i = 1; i < cells.size() - 1; i++) { + if(excludes.contains(cells.get(i)) || excludes.contains(cells.get(i +1 )) ){ + return false; + } + boolean other = checkIsNextOrMineCell(cells.get(i), cells.get(i + 1)); + if (!other) { + return false; + } + } + return true; + } + + public static boolean calSurPos(int x,int y,int diff,int maxX,int maxY,Set cachePos){ + Set possibalePos = new HashSet<>(); + for(int i = 0 ; i <=diff ; i++){ + for(int j = 0 ;j <=i;j++){ + if(x-j>0 && x+i-j>0 && x+i-j <= maxY){ + int xy2Pos = xy2Pos(x - j, y + i - j); + if(cachePos.contains(xy2Pos)){ + return false; + } + possibalePos.add(xy2Pos(x-j,y+i-j)); + } + if(x+j>0 && x+j <= maxX && y-i+j<= maxY && y-i+j>0){ + int xy2Pos = xy2Pos(x+j,y-i+j); + if(cachePos.contains(xy2Pos)){ + return false; + } + possibalePos.add(xy2Pos(x+j,y-i+j)); + } + } + } + cachePos.addAll(possibalePos); + // System.out.println(possibalePos); + return true; + } + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java index 6c444574f..35267efdb 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java @@ -171,9 +171,41 @@ public class FightDataUtil { playerData.rawset(i, getHeroFightUnit(heroTeam.getFightUnitList(i - 1),position)); } playerData.set("teamSkill", getTeamSkill(heroTeam.getTeamSkillList())); + playerData.set("teamPassive", getTeamPassive(heroTeam.getTeamPassiveList())); return playerData; } + private static LuaValue getTeamPassive(String pokemonSkill) { + LuaValue passivityData = new LuaTable(); + if (StringUtil.isEmpty(pokemonSkill)){ + return passivityData; + } + String[] skills = pokemonSkill.trim().split("\\|"); + for (int j = 0; j < skills.length; j++) { + if (skills[j].length()>0){ + String[] unitSkill = skills[j].split("#"); + LuaValue passivityDataPer= new LuaTable(); + for(int i=0;i effectList = parseArraayToLuaValues(sPassiveSkillLogicConfig.getValue()); + int size = effectList.size(); + if (size > 0) { + for (int t = 0; t < size; t++) { + detail.rawset(t + 2, effectList.get(t)); + } + } + passivityDataPer.rawset(i+1,detail); + } + passivityData.rawset(j+1,passivityDataPer); + } + + } + return passivityData; + } + private static LuaValue getTeamSkill(String pokemonSkill) { LuaValue teamSkill = new LuaTable(); if (pokemonSkill.equals("") || pokemonSkill==null){ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/MathUtils.java b/serverlogic/src/main/java/com/ljsd/jieling/util/MathUtils.java index 96b3bc224..eacddca3e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/MathUtils.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/MathUtils.java @@ -259,4 +259,18 @@ public class MathUtils { } } + + public static int randomWeight(int[][] source,Set excluIndexs){ + int length = source.length; + int randomIndex = 0; + while (true){ + randomIndex= randomInt(length); + if(!excluIndexs.contains(randomIndex)){ + break; + } + } + excluIndexs.add(randomIndex); + return randomIndex; + } + }