From fa39c7eb9bcd3f2a40350312d3914a2e2062133d Mon Sep 17 00:00:00 2001 From: duhui Date: Tue, 26 Jan 2021 11:18:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9B=E7=81=B5=E8=AF=95=E7=82=BC=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/core/FunctionIdEnum.java | 2 +- .../fourChallenge/FourChallengeLogic.java | 137 +++++++++++------- 2 files changed, 87 insertions(+), 52 deletions(-) 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 7a8b7af17..f9dda66fe 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java @@ -64,7 +64,7 @@ public enum FunctionIdEnum { Car_Delay(73,new CarDelayFunction()), Situation_challenge(74,null), Multiple_Arena(82,null), - Four_Challenge(84,null) + Four_Challenge(83,null,MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_REQUEST_VALUE) ; private int functionType; 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 index 89b4e9419..6dad5c4c4 100644 --- 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 @@ -8,7 +8,6 @@ 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; @@ -29,40 +28,52 @@ import java.util.List; /** * @author lvxinran + * @author hj * @date 2020/12/16 * @discribe */ public class FourChallengeLogic { + public static FourChallengeLogic getInstance() { return FourChallengeLogic.Instance.instance; } - - - public int[] status ; - + /** + * 当前试炼是否开启,0:未开,1:开启 + * 例子 0,1,1,1 + */ + 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){ + + private FourChallengeLogic(int[][] config) { this.config = config; } - public void check(){ - - if(TimeUtils.getHourOfDay()!=0&&status!=null){ + /** + * 检测试炼开启状态 + */ + public void check() { + // 只检测一次 + if (TimeUtils.getHourOfDay() != 0 && status != null) { return; } + // 空,初始化长度为4 + if (status == null) { + status = new int[4]; + } - 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); + if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) { + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队为空"); } - for(TeamPosHeroInfo info:teamPosHeroInfos){ + 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); + 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); + 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){ + + 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); + user.getPlayerInfoManager().updateFourChallengeByIndex(campId - 1, currentFloor + 1); + user.getPlayerInfoManager().setFourChallengeRemainTimes(campId - 1, fourChallengeRemainTimes[campId - 1] + 1); } - }else if(type==1){ + } else if (type == 1) { //扫荡 - if(floorId!=currentFloor){ - throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + if (floorId != currentFloor) { + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"扫荡层数错误"); } + // 获取特权和消耗 int[] privilege = flashTimesPrice[campId - 1]; - PlayerLogic.getInstance().checkAndUpdate(user,privilege[0],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); + } 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); - - + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.FOUR_CHALLENGE_DO_RESPONSE_VALUE, response.build(), true); } - public void firstGetTimes(User user){ + /** + * 首次获取时间,方法有问题,需要处理 + * @param user + */ + public void firstGetTimes(User user) { int campOpenDay = STableManager.getConfig(SCampTowerSetting.class).get(1).getHelpMaxTimes(); - for(int i = 0 ; i