From b4e7cf3e5dc549518e61a451ed010c586eaaada5 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 5 Aug 2019 15:58:48 +0800 Subject: [PATCH] vip level task --- luafight/Modules/Battle/Logic/BattleLogic.lua | 10 ++-- luafight/Modules/Battle/Logic/RoleLogic.lua | 56 +++++++++++++++++-- .../ljsd/jieling/config/SMonsterConfig.java | 4 ++ .../ljsd/jieling/logic/family/GuildLogic.java | 6 +- .../mission/data/DataManagerDistributor.java | 3 + .../event/MissionEventDistributor.java | 8 ++- .../event/VipLevelUpEventProcessor.java | 7 ++- .../com/ljsd/jieling/util/FightDataUtil.java | 10 ++++ 8 files changed, 91 insertions(+), 13 deletions(-) diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index c65a98b9a..bf31fe2aa 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -477,9 +477,10 @@ function BattleLogic.CastTeamSkill(camp) local teamSkill = playerTeamSkillList[playerTeamSkillIndex] if teamSkill then teamSkill:Cast() - playerTeamSkillIndex = playerTeamSkillIndex + 1 - if playerTeamSkillIndex > #playerTeamSkillList then + if playerTeamSkillIndex == #playerTeamSkillList then playerTeamSkillIndex = 1 + else + playerTeamSkillIndex = playerTeamSkillIndex + 1 end playerMP = 0 end @@ -487,9 +488,10 @@ function BattleLogic.CastTeamSkill(camp) local teamSkill = enemyTeamSkillList[enemyTeamSkillIndex] if teamSkill then teamSkill:Cast() - enemyTeamSkillIndex = enemyTeamSkillIndex + 1 - if enemyTeamSkillIndex > #enemyTeamSkillList then + if enemyTeamSkillIndex == #enemyTeamSkillList then enemyTeamSkillIndex = 1 + else + enemyTeamSkillIndex = enemyTeamSkillIndex + 1 end enemyMP = 0 end diff --git a/luafight/Modules/Battle/Logic/RoleLogic.lua b/luafight/Modules/Battle/Logic/RoleLogic.lua index 7bbab68b3..f6ac0df3c 100644 --- a/luafight/Modules/Battle/Logic/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/RoleLogic.lua @@ -9,12 +9,33 @@ local max = math.max local min = math.min local Passivity = require("Modules/Battle/Logic/Base/Passivity") +local aiList = { + [0] = function(skill, superSkill) --默认75%释放点击技、25%释放上滑技 + return Random.Range01() <= 0.75 + end, + [1] = function(skill, superSkill) --只放点技 + return true + end, + [2] = function(skill, superSkill) --只放滑技 + return false + end, + [3] = function(skill, superSkill) --上滑技初始概率为5%,每次释放点击技后,增加上滑技释放概率20%,释放上滑技后,上滑技释放概率回到5%。 + local b = Random.Range01() > (0.05 + 0.2 * skill.owner.aiTempCount) + if b then + skill.owner.aiTempCount = skill.owner.aiTempCount + 1 + else + skill.owner.aiTempCount = 0 + end + return b + end, +} + local skillPool = BattleObjectPool.New(function () return Skill:New() end) function RoleLogic.New() - local instance = {uid=0,roleData=0,data=RoleData.New(),camp=0,name=0,roleType=0, + local instance = {uid=0,roleData=0,data=RoleData.New(),camp=0,name=0,roleType=0,aiIndex = 1, shield=BattleList.New(), exCalDmgList=BattleList.New(), proTranList=BattleList.New(), @@ -67,6 +88,10 @@ function RoleLogic:Init(uid, data) end end + self.aiOrder = data.ai + self.aiIndex = 1 + self.aiTempCount = 0 + self.isDead = self:GetRoleData(RoleDataName.Hp) <= 0 self.Auto = true self.IsDebug = false @@ -106,11 +131,7 @@ function RoleLogic:Init(uid, data) if superSkill.sp >= superSkill.spPass then if skill.sp >= skill.spPass then if self.Auto and self:CanCastSkill() then - if Random.Range01() <= 0.75 then - skill:Cast() - else - superSkill:Cast() - end + self:ExecuteAI(skill, superSkill) end else skill.sp = skill.sp + 1 @@ -256,6 +277,29 @@ function RoleLogic:Dispose() end end +function RoleLogic:ExecuteAI(skill, superSkill) + local ai + if self.aiOrder and self.aiOrder[self.aiIndex] then + ai = aiList[self.aiOrder[self.aiIndex]] + else + ai = aiList[0] + end + + if ai(skill, superSkill) then + skill:Cast() + else + superSkill:Cast() + end + + if self.aiOrder then + if self.aiIndex == #self.aiOrder then + self.aiIndex = 1 + else + self.aiIndex = self.aiIndex + 1 + end + end +end + function RoleLogic:Update() if not self.enable then return diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java index 50bea0995..34b938a29 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java @@ -195,4 +195,8 @@ public class SMonsterConfig implements BaseConfig { public float getDifferDemonsBocusFactor() { return differDemonsBocusFactor; } + + public int[] getMonsterAi() { + return monsterAi; + } } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java index 0d8b0e9b1..94b9a4780 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java @@ -436,7 +436,11 @@ public class GuildLogic { targetUser.getPlayerInfoManager().setGuildId(0); addGuildLog(guildInfo.getId(),GuildDef.Log.KICK,user.getPlayerInfoManager().getNickName()); Family.FamilyKickIndication build = Family.FamilyKickIndication.newBuilder().setType(1).build(); - MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.FAMILY_KICK_INDICATION_VALUE,build,true); + ISession targetSession = OnlineUserManager.getSessionByUid(targetUid); + if(targetSession!=null){ + MessageUtil.sendIndicationMessage(targetSession,1, MessageTypeProto.MessageType.FAMILY_KICK_INDICATION_VALUE,build,true); + } + MessageUtil.sendMessage(session,1,msgId,null,true); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/data/DataManagerDistributor.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/data/DataManagerDistributor.java index cff0ba088..6be3e9819 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/data/DataManagerDistributor.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/data/DataManagerDistributor.java @@ -83,6 +83,9 @@ public class DataManagerDistributor { judges.put(MissionType.SYNTHESIS_HERO_STAR_TIMES,new HeroComposDataManager()); + judges.put(MissionType.VIP_LEVEL,new DefaultDataManager()); + + } public static CumulationData.Result updateData(CumulationData data, MissionType missionType, Object...parm) throws Exception { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/MissionEventDistributor.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/MissionEventDistributor.java index 903b9b604..21e9f8469 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/MissionEventDistributor.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/MissionEventDistributor.java @@ -30,7 +30,7 @@ public class MissionEventDistributor { public static void init(){ - eventProcessor.put(GameEvent.VIP_LEVLUP,new VipLevelUpEventProcessor()); + eventProcessor.put(GameEvent.DAILY_REFRESH,new DailyRefreshEventProcess()); eventProcessor.put(GameEvent.TREASH_REFRESH,new TreasureRefreshEventProcess()); eventProcessor.put(GameEvent.SERVENHAPPY_REFRESH,new TreasureRefreshEventProcess()); @@ -42,6 +42,12 @@ public class MissionEventDistributor { eventEnumListMap.put(GameEvent.RANDOM_HERO,typeList); eventProcessor.put(GameEvent.RANDOM_HERO,new CumulationDataEventProcessor()); + + typeList = new ArrayList<>(); + typeList.add(MissionType.VIP_LEVEL); + eventEnumListMap.put(GameEvent.VIP_LEVLUP,typeList); + eventProcessor.put(GameEvent.VIP_LEVLUP,new VipLevelUpEventProcessor()); + typeList = new ArrayList<>(); typeList.add(MissionType.COLLECT_QUALITY_HERO); eventEnumListMap.put(GameEvent.GET_HERO,typeList); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/VipLevelUpEventProcessor.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/VipLevelUpEventProcessor.java index 95e8c8386..3c61389af 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/VipLevelUpEventProcessor.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/mission/event/VipLevelUpEventProcessor.java @@ -3,6 +3,7 @@ package com.ljsd.jieling.logic.mission.event; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.mission.GameMisionType; +import com.ljsd.jieling.logic.mission.MissionType; import com.ljsd.jieling.logic.mission.main.MissionStateChangeInfo; import java.util.List; @@ -11,7 +12,11 @@ import java.util.Map; public class VipLevelUpEventProcessor implements BaseGameEventProcessor { @Override - public void onGameEvent(User user, Map> missionTypeEnumListMap, GameEvent event, Object... parm) { + public void onGameEvent(User user, Map> missionTypeEnumListMap, GameEvent event, Object... parm) throws Exception { user.getUserMissionManager().openMission(user,event, missionTypeEnumListMap,parm); + List typeList = MissionEventDistributor.eventEnumListMap.get(event); + for (MissionType type : typeList) { + user.getUserMissionManager().calCumulationDataResult(user,type,missionTypeEnumListMap,parm); + } } } 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 20401aec3..6c444574f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java @@ -93,6 +93,7 @@ public class FightDataUtil { unitData.set("superSkill", getSkill(unitSkill[1])); unitData.set("passivity", getPassivity(unitSkill)); } + unitData.set("ai", getMonsterAi(sMonster.getMonsterAi())); CommonProto.FightUnitInfo fightUnitList = data.getFightUnitList(i); String property = fightUnitList.getProperty(); @@ -105,6 +106,15 @@ public class FightDataUtil { return enemyData; } + private static LuaValue getMonsterAi(int[] monsterAIs) { + LuaValue property = new LuaTable(); + int index =1; + for(int monsterAI : monsterAIs){ + property.rawset(index++, LuaValue.valueOf(monsterAI)); + } + return property; + } + private static LuaValue getPassivity(String[] unitSkill) { LuaValue passivityData = new LuaTable(); int length = unitSkill.length;