From 424b64e6c91c3c2d7135cd514eef7b60f285e9c5 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Fri, 7 Aug 2020 15:26:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=91=E6=88=98=20=E6=89=AB=E8=8D=A1=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/logic/SituationLogic.java | 127 ++++++------------ 1 file changed, 43 insertions(+), 84 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/SituationLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/SituationLogic.java index 3db9546e5..baefc2917 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/SituationLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/SituationLogic.java @@ -113,95 +113,54 @@ public class SituationLogic { PlayerManager playerInfoManager = user.getPlayerInfoManager(); // //次数校验 SRaceTowerConfig sRaceTowerConfig = STableManager.getConfig(SRaceTowerConfig.class).get(id); - int openRules = sRaceTowerConfig.getOpenRules(); Set situationPass = playerInfoManager.getSituationPass(); - if(openRules!=0&&!situationPass.contains(openRules)){ + + + + boolean consumeCount = false; + if(type==2){ + if(!situationPass.contains(id)){ + throw new ErrorCodeException(ErrorCode.DAILY_ALREADY_PASS); + } + CommonProto.Drop.Builder drop = ItemUtil.drop(user, sRaceTowerConfig.getReward(), 1, 0, 1); + builder.setDrop(drop); + consumeCount = true; + }else if(type==1){ +// //判断上一关是否已过 + int openRules = sRaceTowerConfig.getOpenRules(); + if(openRules!=0&&!situationPass.contains(openRules)){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + + PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), GlobalsDef.FORMATION_NORMAL, 1000, "", GameFightType.DailyChallenge, sRaceTowerConfig.getMonsterId(), 3); + FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent); + CommonProto.FightData fightData = CommonProto.FightData.newBuilder() + .setFightMaxTime(20) + .setFightSeed(fightResult.getSeed()) + .setHeroFightInfos(fightResult.getFightTeamInfo()) + .addAllMonsterList(fightResult.getMonsterTeamList()) + .build(); + int[] checkResult = fightResult.getCheckResult(); + builder.setFightData(fightData); + if(checkResult[0]>0){ + CommonProto.Drop.Builder drop = ItemUtil.drop(user, sRaceTowerConfig.getFirstReward(), 1, 0, 1); + builder.setDrop(drop); + situationPass.add(id); + playerInfoManager.updateSituationPass(situationPass); + consumeCount = true; + } + }else{ throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - - -// boolean consumeCount = false; -// boolean isFailed = false; -// Set dailyPass = playerInfoManager.getDailyPass(); -// if(type==2){ -// if(!dailyPass.contains(id)){ -// throw new ErrorCodeException(ErrorCode.DAILY_ALREADY_PASS); -// } -// CommonProto.Drop.Builder drop = ItemUtil.drop(user, sDailyChallengeConfig.getReward(), 1, 0, 1); -// builder.setDrop(drop); -// consumeCount = true; -// }else if(type==1){ -// if(dailyPass.contains(id)){ -// throw new ErrorCodeException(ErrorCode.DAILY_ALREADY_PASS); -// } -// //判断上一关是否已过 -// if(lastChange!=null&&lastChange.getType()==sDailyChallengeConfig.getType()){ -// if(!dailyPass.contains(id - 1)){ -// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); -// } -// } -// int[][] openRules = sDailyChallengeConfig.getOpenRules(); -// boolean open = true; -// for(int[] rule:openRules){ -// switch (rule[0]){ -// case 1: -// open = playerInfoManager.getLevel()>=rule[1]; -// break; -// case 2: -// open = SMainLevelConfig.biggerThanFight(user.getMainLevelManager().getFightId(),rule[1]); -// break; -// case 3: -// open = playerInfoManager.getMaxForce()>=rule[1]; -// break; -// } -// if(!open){ -// throw new ErrorCodeException(ErrorCode.DAILY_NO_OPEN); -// } -// } -// -// -// -// PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), GlobalsDef.FORMATION_NORMAL, 1000, "", GameFightType.DailyChallenge, sDailyChallengeConfig.getMonsterId(), 3); -// FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent); -// CommonProto.FightData fightData = CommonProto.FightData.newBuilder() -// .setFightMaxTime(20) -// .setFightSeed(fightResult.getSeed()) -// .setHeroFightInfos(fightResult.getFightTeamInfo()) -// .addAllMonsterList(fightResult.getMonsterTeamList()) -// .build(); -// int[] checkResult = fightResult.getCheckResult(); -// builder.setFightData(fightData); -// if(checkResult[0]>0){ -// CommonProto.Drop.Builder drop = ItemUtil.drop(user, sDailyChallengeConfig.getReward(), 1, 0, 1); -// builder.setDrop(drop); -// playerInfoManager.addDailyPass(id); -// consumeCount = true; -// }else{ -// isFailed = true; -// } -// }else{ -// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); -// } // ReportUtil.onReportEvent(user, ReportEventEnum.START_DAILY_DUNGEON.getType(),id,sDailyChallengeConfig.getMonsterId(), MonsterUtil.getMonsterForce(new int[]{sDailyChallengeConfig.getMonsterId()}),"",0); -// if(consumeCount){ -// boolean consume = PlayerLogic.getInstance().checkAndUpdate(user, sDailyChallengeConfig.getPrivilegeId()[1], 1); -// if(!consume){ -// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); -// } -// } -// CommonProto.Drop drop = builder.getDrop(); -// if(!isFailed){ -// List itemDrop = drop.getItemlistList(); -// List itemIdList = new ArrayList<>(); -// List itemNumList = new ArrayList<>(); -// itemDrop.forEach(item->{ -// itemIdList.add(item.getItemId()); -// itemIdList.add(item.getItemNum()); -// }); -// ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_DAILY_DUNGEON.getType(),id,sDailyChallengeConfig.getMonsterId(),MonsterUtil.getMonsterForce(new int[]{sDailyChallengeConfig.getMonsterId()}),new Date(),"",0,itemIdList,itemNumList,type==1?"挑战":"扫荡"); -// } + if(consumeCount){ + boolean consume = PlayerLogic.getInstance().checkAndUpdate(user, sRaceTowerConfig.getPrivilege()[1], 1); + if(!consume){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + } // user.getUserMissionManager().onGameEvent(user, GameEvent.DAILY_CHALLENGE,sDailyChallengeConfig.getType()); -// MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build()); + MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build()); } }