From 8394061f97732446e2fd6d903a88b882a8883a46 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Sun, 27 Dec 2020 19:05:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9B=E7=81=B5=E8=AF=95=E7=82=BC=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/core/FunctionIdEnum.java | 1 + .../com/ljsd/jieling/globals/BIReason.java | 3 + .../fourChallenge/FourChallengeDoHandler.java | 27 +++ .../FourChallengeGetInfoHandler.java | 28 +++ .../logic/activity/UserLevelEventHandler.java | 6 + .../fourChallenge/FourChallengeLogic.java | 173 ++++++++++++++++++ .../ljsd/jieling/logic/dao/PlayerManager.java | 23 +++ .../ljsd/jieling/thread/task/MinuteTask.java | 7 + .../main/java/config/SCampTowerConfig.java | 55 ++++++ .../main/java/config/SCampTowerSetting.java | 70 +++++++ 10 files changed, 393 insertions(+) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeDoHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeGetInfoHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/fourChallenge/FourChallengeLogic.java create mode 100644 tablemanager/src/main/java/config/SCampTowerConfig.java create mode 100644 tablemanager/src/main/java/config/SCampTowerSetting.java diff --git a/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java index 0604b1cab..7a8b7af17 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java @@ -64,6 +64,7 @@ public enum FunctionIdEnum { Car_Delay(73,new CarDelayFunction()), Situation_challenge(74,null), Multiple_Arena(82,null), + Four_Challenge(84,null) ; private int functionType; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java b/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java index 52bd3613d..79fe69162 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java @@ -161,6 +161,9 @@ public interface BIReason { int ARENA_WIN_REWARD = 92;//竞技场胜利奖励 int ARENA_LOSE_REWARD = 93;//竞技场失败奖励 + int FOUR_CHALLENGE_FIRST = 94;//四灵试炼首通 + int FOUR_CHALLENGE_SWEEP = 95;//四灵试炼扫荡 + int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级 int SECRETBOX_CONSUME = 1001;//秘盒抽卡 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeDoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeDoHandler.java new file mode 100644 index 000000000..d6e5c6e3e --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeDoHandler.java @@ -0,0 +1,27 @@ +package com.ljsd.jieling.handler.fourChallenge; + +import com.ljsd.jieling.handler.BaseHandler; +import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.MessageTypeProto; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import org.springframework.stereotype.Component; + +/** + * @author lvxinran + * @date 2020/12/26 + * @discribe + */ +@Component + +public class FourChallengeDoHandler extends BaseHandler { + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_REQUEST; + } + + @Override + public void processWithProto(ISession iSession, PlayerInfoProto.FourChallengeDoRequest proto) throws Exception { + FourChallengeLogic.getInstance().fourChallengeDo(iSession,proto.getChallengeId(),proto.getType()); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeGetInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeGetInfoHandler.java new file mode 100644 index 000000000..41e76f6bc --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/fourChallenge/FourChallengeGetInfoHandler.java @@ -0,0 +1,28 @@ +package com.ljsd.jieling.handler.fourChallenge; + +import com.google.protobuf.GeneratedMessage; +import com.ljsd.jieling.handler.BaseHandler; +import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic; +import com.ljsd.jieling.netty.cocdex.PacketNetData; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.MessageTypeProto; +import org.springframework.stereotype.Component; + +/** + * @author lvxinran + * @date 2020/12/16 + * @discribe + */ +@Component +public class FourChallengeGetInfoHandler extends BaseHandler { + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.FOUR_CHALLENGE_GET_INFO_REQUEST; + } + + @Override + public void process(ISession iSession, PacketNetData netData) throws Exception { + + FourChallengeLogic.getInstance().fourChallengeGetInfo(iSession); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/UserLevelEventHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/UserLevelEventHandler.java index 7a56aa10a..f9b0acbb0 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/UserLevelEventHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/UserLevelEventHandler.java @@ -1,6 +1,7 @@ package com.ljsd.jieling.logic.activity; import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig; +import com.ljsd.jieling.core.FunctionIdEnum; import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.core.VipPrivilegeType; import com.ljsd.jieling.exception.ErrorCode; @@ -11,6 +12,8 @@ import com.ljsd.jieling.logic.activity.event.ActivityStateChangeEvent; import com.ljsd.jieling.logic.activity.event.IEvent; import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.activity.event.UserLevelEvent; +import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic; +import com.ljsd.jieling.logic.dao.TimeControllerOfFunction; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.expedition.ExpeditionLogic; @@ -75,6 +78,9 @@ public class UserLevelEventHandler implements IEventHandler,IPrivilegeChange{ return; } for(SGlobalSystemConfig sGlobalSystemConfig : sGlobalSystemConfigs){ + if(sGlobalSystemConfig.getId()== FunctionIdEnum.Four_Challenge.getFunctionType()){ + FourChallengeLogic.getInstance().firstGetTimes(user); + } int[][] openGifts = sGlobalSystemConfig.getOpenGifts(); if(openGifts!=null && openGifts.length>0){ ItemUtil.drop(user,openGifts, BIReason.SYSTERM_OPEN_REWARD); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/fourChallenge/FourChallengeLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/fourChallenge/FourChallengeLogic.java new file mode 100644 index 000000000..89b4e9419 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/fourChallenge/FourChallengeLogic.java @@ -0,0 +1,173 @@ +package com.ljsd.jieling.logic.activity.fourChallenge; + +import com.ljsd.jieling.exception.ErrorCode; +import com.ljsd.jieling.exception.ErrorCodeException; +import com.ljsd.jieling.globals.BIReason; +import com.ljsd.jieling.logic.dao.Hero; +import com.ljsd.jieling.logic.dao.TeamPosHeroInfo; +import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.fight.FightDispatcher; +import com.ljsd.jieling.logic.fight.FightUtil; +import com.ljsd.jieling.logic.fight.GameFightType; +import com.ljsd.jieling.logic.fight.PVEFightEvent; +import com.ljsd.jieling.logic.fight.result.FightResult; +import com.ljsd.jieling.logic.player.PlayerLogic; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.CommonProto; +import com.ljsd.jieling.protocols.MessageTypeProto; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import com.ljsd.jieling.util.ItemUtil; +import com.ljsd.jieling.util.MessageUtil; +import config.SCHero; +import config.SCampTowerConfig; +import config.SCampTowerSetting; +import manager.STableManager; +import util.TimeUtils; + +import java.util.List; + +/** + * @author lvxinran + * @date 2020/12/16 + * @discribe + */ +public class FourChallengeLogic { + public static FourChallengeLogic getInstance() { + return FourChallengeLogic.Instance.instance; + } + + + + public int[] status ; + + public final int[][] config; + + public static class Instance { + public final static FourChallengeLogic instance = new FourChallengeLogic(STableManager.getConfig(SCampTowerSetting.class).get(1).getCampOpenDay()); + } + private FourChallengeLogic(int[][] config){ + this.config = config; + } + + public void check(){ + + if(TimeUtils.getHourOfDay()!=0&&status!=null){ + return; + } + + if(status==null) status = new int[4]; + + + for(int[] statusConfig:config){ + for(int i = 1 ;i teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); + + if(teamPosHeroInfos==null||teamPosHeroInfos.size()==0){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + for(TeamPosHeroInfo info:teamPosHeroInfos){ + Hero hero = user.getHeroManager().getHero(info.getHeroId()); + if(SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName()!=sCampTowerConfig.getCampId()){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + + } + + PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(),teamId,20, "",GameFightType.DailyChallenge,sCampTowerConfig.getMonster(),3); + FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent); + int[] checkResult = fightResult.getCheckResult(); + response.setFightData(fightResult.getFightData()); + if(checkResult[0]==1){ + drop = ItemUtil.drop(user, sCampTowerConfig.getFirstReward(), BIReason.FOUR_CHALLENGE_FIRST); + user.getPlayerInfoManager().updateFourChallengeByIndex(campId-1,currentFloor+1); + user.getPlayerInfoManager().setFourChallengeRemainTimes(campId-1,fourChallengeRemainTimes[campId - 1]+1); + } + + }else if(type==1){ + //扫荡 + if(floorId!=currentFloor){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + int[] privilege = flashTimesPrice[campId - 1]; + PlayerLogic.getInstance().checkAndUpdate(user,privilege[0],1); + drop = ItemUtil.drop(user, sCampTowerConfig.getCommonReward(), BIReason.FOUR_CHALLENGE_SWEEP); + }else{ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + response.setDrop(drop); + MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_RESPONSE_VALUE,response.build(),true); + + + } + + public void firstGetTimes(User user){ + + int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getHelpMaxTimes(); + + for(int i = 0 ; i situationPass = new HashMap<>(); + private int[] fourChallenge = new int[4]; + + private int[] fourChallengeRemainTimes = new int[4]; + public PlayerManager(){ this.setRootCollection(User._COLLECTION_NAME); @@ -821,4 +825,23 @@ public class PlayerManager extends MongoBase { this.lastDeviceId = lastDeviceId; updateString("lastDeviceId",lastDeviceId); } + + public int[] getFourChallenge() { + return fourChallenge; + } + + public void updateFourChallengeByIndex(int index,int value) { + fourChallenge[index] = value; + updateString("fourChallenge",fourChallenge); + } + + public int[] getFourChallengeRemainTimes() { + return fourChallengeRemainTimes; + } + + public void setFourChallengeRemainTimes(int index,int value) { + fourChallengeRemainTimes[index] = value; + updateString("fourChallengeRemainTimes",fourChallengeRemainTimes); + + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteTask.java b/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteTask.java index 1985685ea..e72121c36 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteTask.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteTask.java @@ -23,6 +23,7 @@ import com.ljsd.jieling.logic.SituationLogic; import com.ljsd.jieling.logic.activity.ActivityLogic; import com.ljsd.jieling.logic.activity.event.MinuteTaskEvent; import com.ljsd.jieling.logic.activity.event.Poster; +import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic; import com.ljsd.jieling.logic.arena.ArenaLogic; import com.ljsd.jieling.logic.dao.GuildMyInfo; import com.ljsd.jieling.logic.dao.GuilidManager; @@ -83,6 +84,12 @@ public class MinuteTask extends Thread { }catch (Exception e){ LOGGER.error("Exception::=>{}",e.toString()); } + try { + + FourChallengeLogic.getInstance().check(); + }catch (Exception e){ + LOGGER.error("Exception::=>{}",e.toString()); + } try { everyZeroTask(); diff --git a/tablemanager/src/main/java/config/SCampTowerConfig.java b/tablemanager/src/main/java/config/SCampTowerConfig.java new file mode 100644 index 000000000..7b1c5eaab --- /dev/null +++ b/tablemanager/src/main/java/config/SCampTowerConfig.java @@ -0,0 +1,55 @@ +package config; + +import manager.STableManager; +import manager.Table; + +import java.util.Map; + +@Table(name ="CampTowerConfig") +public class SCampTowerConfig implements BaseConfig { + + private int id; + + private int floorId; + + private int campId; + + private int monster; + + private int[][] firstReward; + + private int[][] commonReward; + + + @Override + public void init() throws Exception { + + } + + + public int getId() { + return id; + } + + public int getFloorId() { + return floorId; + } + + public int getCampId() { + return campId; + } + + public int getMonster() { + return monster; + } + + public int[][] getFirstReward() { + return firstReward; + } + + public int[][] getCommonReward() { + return commonReward; + } + + +} \ No newline at end of file diff --git a/tablemanager/src/main/java/config/SCampTowerSetting.java b/tablemanager/src/main/java/config/SCampTowerSetting.java new file mode 100644 index 000000000..0eec8f0a2 --- /dev/null +++ b/tablemanager/src/main/java/config/SCampTowerSetting.java @@ -0,0 +1,70 @@ +package config; + +import manager.STableManager; +import manager.Table; + +import java.util.Map; + +@Table(name ="CampTowerSetting") +public class SCampTowerSetting implements BaseConfig { + + private int id; + + private int timesAddPerDay; + + private int timesStoreMax; + + private int[][] campOpenDay; + + private int[][] flashTimesPrice; + + private int helpFightMax; + + private int[] helpReward; + + private int helpMaxTimes; + + private int[] formation; + + @Override + public void init() throws Exception { + + } + + + public int getId() { + return id; + } + + public int getTimesAddPerDay() { + return timesAddPerDay; + } + + public int getTimesStoreMax() { + return timesStoreMax; + } + + public int[][] getCampOpenDay() { + return campOpenDay; + } + + public int getHelpFightMax() { + return helpFightMax; + } + + public int[] getHelpReward() { + return helpReward; + } + + public int getHelpMaxTimes() { + return helpMaxTimes; + } + + public int[][] getFlashTimesPrice() { + return flashTimesPrice; + } + + public int[] getFormation() { + return formation; + } +} \ No newline at end of file