From 143c7a52301756be6f1c55ff88b0a47b4a61d2ef Mon Sep 17 00:00:00 2001 From: duhui Date: Fri, 10 Dec 2021 14:24:47 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=8B=9B=E5=8B=9F=E7=A7=98=E5=AE=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jieling/logic/GlobalDataManaager.java | 6 +- .../jieling/logic/activity/ActivityLogic.java | 35 ++-- .../jieling/logic/activity/ActivityType.java | 3 +- .../logic/activity/ActivityTypeEnum.java | 3 +- .../activity/SummonTreasureActivity.java | 163 ++++++++++++++++++ .../event/SummonTreasureActivityEvent.java | 17 ++ .../activity/event/SummonTreasureEvent.java | 37 ++++ .../ActivityStateChangeHandler.java | 30 ++++ .../eventhandler/SummonTreasureHandler.java | 27 +++ .../ljsd/jieling/logic/dao/PlayerManager.java | 12 ++ .../jieling/logic/store/BuyGoodsNewLogic.java | 20 +++ .../bean/AbstractWelfareBag.java | 4 + .../bean/ReceiveWelfareBag.java | 5 + .../java/com/ljsd/jieling/util/ItemUtil.java | 1 + .../src/main/java/config/SSummonTreasure.java | 72 ++++++++ 15 files changed, 412 insertions(+), 23 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/SummonTreasureActivity.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureActivityEvent.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureEvent.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/SummonTreasureHandler.java create mode 100644 tablemanager/src/main/java/config/SSummonTreasure.java 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 04ba87d09..9e9ec5c68 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java @@ -16,10 +16,7 @@ import com.ljsd.jieling.logic.activity.UserLevelEventHandler; import com.ljsd.jieling.logic.activity.activityLogic.WeekCardLogic; import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.activity.event.SuperBoxEvent; -import com.ljsd.jieling.logic.activity.eventhandler.ActivityStateChangeHandler; -import com.ljsd.jieling.logic.activity.eventhandler.BuyGoodsDirectHandler; -import com.ljsd.jieling.logic.activity.eventhandler.GuildForceChangeEventHandler; -import com.ljsd.jieling.logic.activity.eventhandler.ShanHeSheJiTuEventHandler; +import com.ljsd.jieling.logic.activity.eventhandler.*; import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic; import com.ljsd.jieling.logic.arena.ArenaLogic; import com.ljsd.jieling.logic.championship.ChampionshipLogic; @@ -297,6 +294,7 @@ public class GlobalDataManaager implements IManager { new ActivityStateChangeHandler(); new GuildForceChangeEventHandler(); new ShanHeSheJiTuEventHandler(); + new SummonTreasureHandler(); ChampionshipLogic.minuteCheck(true); GuildFightLogic.minuteCheckForCarFight(); } catch (Exception e) { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java index 7e9988389..fa8bf7a4d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java @@ -660,28 +660,29 @@ public class ActivityLogic implements IEventHandler{ if(openRules!=null&&openRules.length>0){ int openRuleType = openRules[0]; int openRulleValue = openRules[1]; - if(openRuleType == 1){ + if (openRuleType == 1) { int virtureId = SMainLevelConfig.config.get(openRulleValue).getVirtureId(); int fightId = user.getMainLevelManager().getFightId(); - SMainLevelConfig mineMainLevelConfig = SMainLevelConfig.fightPreMap.get(fightId); - if(user.getMainLevelManager().getState() == 2 ){ + SMainLevelConfig mineMainLevelConfig = SMainLevelConfig.fightPreMap.get(fightId); + if (user.getMainLevelManager().getState() == 2) { mineMainLevelConfig = SMainLevelConfig.config.get(user.getMainLevelManager().getFightId()); } - int myVirtureId =0; - if(mineMainLevelConfig != null){ - myVirtureId =mineMainLevelConfig.getVirtureId(); + int myVirtureId = 0; + if (mineMainLevelConfig != null) { + myVirtureId = mineMainLevelConfig.getVirtureId(); } - if(virtureId > myVirtureId){ + if (virtureId > myVirtureId) { state = ActivityType.UNOPEN_STATE; } - }else if(openRuleType == 2){ - if(user.getPlayerInfoManager().getLevel() activityMissionMap = user.getActivityManager().getActivityMissionMap(); - for(Integer activityId:activityMissionMap.keySet()){ - if(SGlobalActivity.getsGlobalActivityMap().get(activityId).getType()==ActivityType.BLESSACTIVITY){ - return activityId; - } - } +// Map activityMissionMap = user.getActivityManager().getActivityMissionMap(); +// for(Integer activityId:activityMissionMap.keySet()){ +// if(SGlobalActivity.getsGlobalActivityMap().get(activityId).getType()==ActivityType.BLESSACTIVITY){ +// return activityId; +// } +// } return 0; } /** diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java index 29acdc727..f01421b17 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java @@ -26,7 +26,8 @@ public interface ActivityType { int RechargeTotal = 5; //首充 // int RechargeTotal = 5; //累计充值 int GrowthFund = 6; //成长基金 - int BLESSACTIVITY = 7;//云梦祈福 +// int BLESSACTIVITY = 7;//云梦祈福(跟策划对过,活动已删除) + int SUMMON_TREASURE = 7;//招募秘宝 int TREASURE = 8; //青龙秘宝(孙龙的宝藏) int LUCKYCAT = 9;//招財貓 int SERVERHAPPY = 10; //七日狂欢 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java index a445f7512..66f9023ab 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java @@ -14,7 +14,7 @@ public enum ActivityTypeEnum { FIRSTRECHARGE(ActivityType.RechargeTotal, RechargeTotalActivity::new), // RECHARGETOTAL(ActivityType.RechargeTotal, RechargeTotalActivity::new), GROWTHFUND(ActivityType.GrowthFund, GrowthFundActivity::new), - BLESSACTIVITY(ActivityType.BLESSACTIVITY, BlessActivity::new), +// BLESSACTIVITY(ActivityType.BLESSACTIVITY, BlessActivity::new), TREASUREACTIVITY(ActivityType.TREASURE, TreasureActivity::new), LUCKYCAT(ActivityType.LUCKYCAT, LuckyCatActivity::new), SERVERHAPPY(ActivityType.SERVERHAPPY, DefaultEmptyActivity::new), @@ -94,6 +94,7 @@ public enum ActivityTypeEnum { TRANSFORMATION_DRAW_CARD(ActivityType.TRANSFORMATION_DRAW_CARD,DefaultEmptyActivity::new),//方寸寻宝 CONTINUOUS_GIFT_NEW(ActivityType.CONTINUOUS_GIFT_NEW,ContinuousGiftActivity::new),//新连续礼包 ARENA_RANK_EXPERIMENT(ActivityType.ARENA_RANK_EXPERIMENT,ArenaRankActivity::new),//竞技试炼 + SUMMON_TREASURE(ActivityType.SUMMON_TREASURE,SummonTreasureActivity::new),//招募秘宝 ; private int type; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/SummonTreasureActivity.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/SummonTreasureActivity.java new file mode 100644 index 000000000..e0b4509a3 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/SummonTreasureActivity.java @@ -0,0 +1,163 @@ +package com.ljsd.jieling.logic.activity; + +import com.ljsd.jieling.exception.ErrorCode; +import com.ljsd.jieling.exception.ErrorCodeException; +import com.ljsd.jieling.globals.BIReason; +import com.ljsd.jieling.jbean.ActivityMission; +import com.ljsd.jieling.jbean.ActivityProgressInfo; +import com.ljsd.jieling.logic.OnlineUserManager; +import com.ljsd.jieling.logic.activity.event.*; +import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.store.BuyGoodsNewLogic; +import com.ljsd.jieling.logic.store.newRechargeInfo.PushRechargeType; +import com.ljsd.jieling.logic.store.newRechargeInfo.bean.ReceiveWelfareBag; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.util.ItemUtil; +import com.ljsd.jieling.util.MessageUtil; +import config.*; +import manager.STableManager; +import rpc.protocols.CommonProto; +import rpc.protocols.PlayerInfoProto; + +import java.util.ArrayList; +import java.util.Optional; + +class SummonTreasureActivity extends AbstractActivity { + + public SummonTreasureActivity(int id) { + super(id); + Poster.getPoster().listenEvent(this, SummonTreasureActivityEvent.class); + } + + @Override + public void initActivity(User user) throws Exception { + ActivityMission mission = new ActivityMission(); + // 初始化阶段奖励 + ActivityLogic.getInstance().initOtherMission(mission, new ArrayList<>()); + user.getActivityManager().getActivityMissionMap().put(id, mission); + LOGGER.info("招募秘宝初始化..."+id); + } + + @Override + public void onEvent(IEvent event) throws Exception { + if (!(event instanceof SummonTreasureActivityEvent)) { + return; + } + SummonTreasureActivityEvent event1 = (SummonTreasureActivityEvent) event; + //动态控制购买数量 + User user = UserManager.getUser(event1.getUid()); + // 客户端推送 + ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id); + if (mission != null){ + Poster.getPoster().dispatchEvent(new ActivityStateChangeEvent(user.getId(),id,mission.getActivityState())); + // 推送客户端数据 + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + mission.setV(user.getPlayerInfoManager().getGetFiveStarHeroNum()); + sendActivityProgress(session, mission, null); + } + } + + @Override + public boolean takeReward(ISession session, int missionId) throws Exception { + User user = UserManager.getUser(session.getUid()); + //checkAndUpdate cfg + SSummonTreasure treasure = STableManager.getConfig(SSummonTreasure.class).get(missionId); + if (treasure == null || treasure.getGrade() != id) { + throw new ErrorCodeException(ErrorCode.CFG_NULL,"功能不存在:"+missionId); + } + // acitvityinfo check + ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(id); + if (mission == null){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"数据错误"); + } + if (mission.getActivityState() != ActivityType.OPEN_STATE) { + throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN,"活动未开启"); + } + ActivityProgressInfo progressInfo = mission.getActivityMissionMap().get(missionId); + if (progressInfo != null && progressInfo.getState() == ActivityType.FINISH_TAKED) { + throw new ErrorCodeException(ErrorCode.newDefineCode("活动奖励已经领取")); + } + // 验证领取条件值 + if (!takeRewardsProcess(session,treasure)) { + LOGGER.error("the uid={} the missionId={},the missionProgress={},the require is={} ", session.getUid(), treasure.getId(), user.getPlayerInfoManager().getGetFiveStarHeroNum(), treasure.getCount()); + throw new ErrorCodeException(ErrorCode.newDefineCode("未达到领取条件")); + } + + ArrayList reward = new ArrayList<>(); + // 是否购买礼包 + if (isBuyGift(user)){ + // 宝藏奖励 + reward.add(treasure.getTreasureReward()); + // 普通奖励 + if (progressInfo == null){ + reward.add(treasure.getReward()); + } + checkAndSetProgress(mission,missionId,ActivityType.FINISH_TAKED); + }else { + if (progressInfo != null){ + throw new ErrorCodeException(ErrorCode.newDefineCode("普通奖励已经领取")); + } + // 普通奖励 + reward.add(treasure.getReward()); + checkAndSetProgress(mission,missionId,ActivityType.HAD_TAKED); + } + // reward + CommonProto.Drop.Builder drop = ItemUtil.drop(user, reward, BIReason.TAKE_ACTIVITY_REWARD); + PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build(); + MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true); + // 状态推送 + sendActivityProgress(session, mission, null); + // 打点上报 + reportTakeActivityReward(user,reward,missionId); + return true; + } + + /** + * 是否购买礼包 + * @param user + * @return + * @throws Exception + */ + private boolean isBuyGift(User user){ + int[] ints = Optional.ofNullable(SGlobalActivity.getsGlobalActivityMap().get(id)).map(SGlobalActivity::getCanBuyRechargeId).orElse(null); + if (ints == null){ + return true; + } + for (int anInt : ints) { + ReceiveWelfareBag bag = (ReceiveWelfareBag) Optional.ofNullable(user.getPlayerInfoManager().getNewRechargeInfo().getReceiveMap()) + .map(v -> v.get(anInt)).orElse(null); + // 礼包为null,礼包可买,礼包未买 + if (bag == null || !bag.isBought()){ + return false; + } + } + return true; + } + + @Override + public boolean checkActivityMissionFinishAndTake(int uid, int activityId, ActivityMission activityMission) { + return false; + } + + /** + * 验证奖励是否可以领取 + * @param session + * @param treasure + * @return + * @throws Exception + */ + boolean takeRewardsProcess(ISession session, SSummonTreasure treasure) throws Exception { + User user = UserManager.getUser(session.getUid()); + return user.getPlayerInfoManager().getGetFiveStarHeroNum() >= treasure.getCount(); + } + + /** + * 领奖后更新奖励进度 + */ + public void checkAndSetProgress(ActivityMission activityMission, int missionId, int state) { + ActivityProgressInfo progressInfo = new ActivityProgressInfo(); + progressInfo.setState(state); + activityMission.getActivityMissionMap().put(missionId, progressInfo); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureActivityEvent.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureActivityEvent.java new file mode 100644 index 000000000..21525474d --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureActivityEvent.java @@ -0,0 +1,17 @@ +package com.ljsd.jieling.logic.activity.event; + +public class SummonTreasureActivityEvent implements IEvent{ + private int uid; + + public SummonTreasureActivityEvent(int uid) { + this.uid = uid; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureEvent.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureEvent.java new file mode 100644 index 000000000..1e40d8277 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/SummonTreasureEvent.java @@ -0,0 +1,37 @@ +package com.ljsd.jieling.logic.activity.event; + +public class SummonTreasureEvent implements IEvent{ + private int uid; + private int star; + private int num; + + public SummonTreasureEvent(int uid, int star, int num) { + this.uid = uid; + this.star = star; + this.num = num; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public int getStar() { + return star; + } + + public void setStar(int star) { + this.star = star; + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/ActivityStateChangeHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/ActivityStateChangeHandler.java index 57657287b..65af6e0bb 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/ActivityStateChangeHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/ActivityStateChangeHandler.java @@ -11,10 +11,13 @@ import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.store.BuyGoodsNewLogic; import com.ljsd.jieling.util.ToolsUtil; import config.SGlobalActivity; +import config.SSummonTreasure; +import javax.naming.spi.ObjectFactory; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class ActivityStateChangeHandler implements IEventHandler { public ActivityStateChangeHandler() { @@ -39,6 +42,33 @@ public class ActivityStateChangeHandler implements IEventHandler { ActivityLogic.getInstance().checkNeedOpenStore(user,shopId,startTime,endTime); } } + // 活动开启类型4 + List treasureList = SSummonTreasure.getTreasureMap().get(activityId); + // 招募基金活动 + if (treasureList != null && !treasureList.isEmpty()){ + List sGlobalActivities = SGlobalActivity.sGlobalActivityMapByOpenRules.getOrDefault(4, new ArrayList<>()); + int getFiveStarHeroNum = user.getPlayerInfoManager().getGetFiveStarHeroNum(); + List activities = sGlobalActivities.stream().filter(s -> s.getOpenRules()[1] == activityId).collect(Collectors.toList()); + boolean result = true; + for (SGlobalActivity activity : activities) { + for (SSummonTreasure treasure : treasureList) { + // 条件未满足 + if (treasure.getCount() > getFiveStarHeroNum){ + result = false; + break; + } + } + if (result){ + ActivityMission mission = user.getActivityManager().getActivityMissionMap().get(activity.getId()); + AbstractActivity abstractActivity = ActivityTypeEnum.getActicityType(activity.getId()); + if(mission != null && mission.getActivityState() == ActivityType.UNOPEN_STATE && abstractActivity != null){ + //修改活动状态,推送给前端 + abstractActivity.setOpenState(user,ActivityType.OPEN_STATE); + ActivityLogic.getInstance().sendActivityInfo(user,activity.getId()); + } + } + } + } }else if(state == ActivityType.FINISH_STATE){ List sGlobalActivities = SGlobalActivity.sGlobalActivityMapByOpenRules.getOrDefault(3, new ArrayList<>(0)); sGlobalActivities.stream().filter(s->s.getOpenRules()[1] == activityId).forEach(s->{ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/SummonTreasureHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/SummonTreasureHandler.java new file mode 100644 index 000000000..87b59da28 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/eventhandler/SummonTreasureHandler.java @@ -0,0 +1,27 @@ +package com.ljsd.jieling.logic.activity.eventhandler; + +import com.ljsd.jieling.logic.activity.IEventHandler; +import com.ljsd.jieling.logic.activity.event.IEvent; +import com.ljsd.jieling.logic.activity.event.Poster; +import com.ljsd.jieling.logic.activity.event.SummonTreasureActivityEvent; +import com.ljsd.jieling.logic.activity.event.SummonTreasureEvent; +import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.dao.root.User; + +public class SummonTreasureHandler implements IEventHandler { + public SummonTreasureHandler() { + Poster.getPoster().listenEvent(this, SummonTreasureEvent.class); + } + @Override + public void onEvent(IEvent event) throws Exception { + if( ! (event instanceof SummonTreasureEvent) ){ + return; + } + SummonTreasureEvent event1 = (SummonTreasureEvent) event; + User user = UserManager.getUser(event1.getUid()); + if (event1.getStar() == 5){ + user.getPlayerInfoManager().setGetFiveStarHeroNum(user.getPlayerInfoManager().getGetFiveStarHeroNum()+event1.getNum()); + Poster.getPoster().dispatchEvent(new SummonTreasureActivityEvent(user.getId())); + } + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java index 4a227fd0f..882fff334 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java @@ -196,10 +196,22 @@ public class PlayerManager extends MongoBase { private long weekCardTimeFirst;//本周第一次看到周卡的时间 private int weekCardTimeFirstLevel;//本周第一次看到周卡时人物等级 + //玩家抽取到的五星次数,目前只应用于招募基金使用 + private int getFiveStarHeroNum; + public PlayerManager(){ this.setRootCollection(User._COLLECTION_NAME); } + public int getGetFiveStarHeroNum() { + return getFiveStarHeroNum; + } + + public void setGetFiveStarHeroNum(int getFiveStarHeroNum) { + this.getFiveStarHeroNum = getFiveStarHeroNum; + updateString("getFiveStarHeroNum", getFiveStarHeroNum); + } + public int getTreasureLevel() { return treasureLevel; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java index cf2adb1e6..a3a1c1f9e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsNewLogic.java @@ -506,6 +506,15 @@ public class BuyGoodsNewLogic { result = true; } } + if (bag.getType() == RechargeType.receive.getType()){ + for (String[] strings : bag.getCondition()) { + if (strings[0].equals("9")){ + if(!judgeOpen(strings,user)){ + bag.setOpen(false); + } + } + } + } }else{ if(bag.getType() == RechargeType.push.getType() && !bag.isOpen()){ user.getPlayerInfoManager().getNewRechargeInfo().removePush(bag.getModId()); @@ -635,6 +644,17 @@ public class BuyGoodsNewLogic { return user.getPlayerInfoManager().getMonthCard().get(Global.LMONTHCARDID) != null; }else if(con[0].equals("7")){ return true; + }else if (con[0].equals("9")){ + SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(Integer.parseInt(con[1])); + if (config == null){ + return true; + } + RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype()); + AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(config.getId()); + if (bag == null){ + return true; + } + return bag.buyAgo(); } return false; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java index 0057218ef..86ab68c6c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/AbstractWelfareBag.java @@ -90,6 +90,10 @@ public class AbstractWelfareBag extends MongoBase{ return true; } + public boolean buyAgo(){ + return buyTimes >= getLimit(); + } + public boolean checkBuy() { if(!open){ LOGGER.error("礼包:{}未开启",modId); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/ReceiveWelfareBag.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/ReceiveWelfareBag.java index e550848a5..7a2f86e41 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/ReceiveWelfareBag.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/newRechargeInfo/bean/ReceiveWelfareBag.java @@ -74,6 +74,11 @@ public class ReceiveWelfareBag extends AbstractWelfareBag { } } + @Override + public boolean buyAgo(){ + return bought; + } + @Override public void refresh(){ super.refresh(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index 002be0484..5e462826e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -1388,6 +1388,7 @@ public class ItemUtil { PlayerManager playerInfoManager = user.getPlayerInfoManager(); int[] heroStar = SItem.getsItemMap().get(cardId).getHeroStar(); Hero hero = new Hero(user.getId(),heroStar[0],heroStar[1]); + Poster.getPoster().dispatchEvent(new SummonTreasureEvent(user.getId(),hero.getStar(),1)); heroManager.addHero(hero); // 鸿蒙阵推送 HeroLogic.getInstance().addOrUpdateHongmeng(OnlineUserManager.getSessionByUid(user.getId())); diff --git a/tablemanager/src/main/java/config/SSummonTreasure.java b/tablemanager/src/main/java/config/SSummonTreasure.java new file mode 100644 index 000000000..15a0105cb --- /dev/null +++ b/tablemanager/src/main/java/config/SSummonTreasure.java @@ -0,0 +1,72 @@ +package config; + +import manager.STableManager; +import manager.Table; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Table(name ="SummonTreasure") +public class SSummonTreasure implements BaseConfig { + + private int id; + + private int level; + + private int grade; + + private int count; + + private int[][] reward; + + private int[][] treasureReward; + + /** + * key:活动id, value:对象列表 + */ + private static Map> treasureMap = new HashMap<>(); + + @Override + public void init() throws Exception { + Map config = STableManager.getConfig(SSummonTreasure.class); + HashMap> map = new HashMap<>(); + config.values().forEach(v->{ + List treasures = map.getOrDefault(v.getGrade(), new ArrayList()); + treasures.add(v); + map.put(v.getGrade(),treasures); + }); + treasureMap = map; + } + + public static Map> getTreasureMap() { + return treasureMap; + } + + public int getId() { + return id; + } + + public int getLevel() { + return level; + } + + public int getGrade() { + return grade; + } + + public int getCount() { + return count; + } + + public int[][] getReward() { + return reward; + } + + public int[][] getTreasureReward() { + return treasureReward; + } + + +} \ No newline at end of file From 1af8836d720fee3824d4139c0069e9d95c6ba6f5 Mon Sep 17 00:00:00 2001 From: duhui Date: Fri, 10 Dec 2021 16:24:53 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ljsd/jieling/kefu/Cmd_guildboss.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_guildboss.java b/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_guildboss.java index bcf66e189..7ad186e56 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_guildboss.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_guildboss.java @@ -11,7 +11,7 @@ import java.util.Map; /** * @author hj - * gm,扶持功能 + * 公会boss层数 命令:guildboss 角色id 层数id */ public class Cmd_guildboss extends GmRoleAbstract { @Override From 8d7394d1ac56a9607441b57a6acfbc66dded8a65 Mon Sep 17 00:00:00 2001 From: duhui Date: Fri, 10 Dec 2021 16:44:38 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=85=AC=E4=BC=9Aboss=E4=BC=A4=E5=AE=B3?= =?UTF-8?q?=E8=B6=85=E4=B8=8A=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ljsd/jieling/logic/dao/GuildMyInfo.java | 6 +++--- .../com/ljsd/jieling/logic/family/GuildChallengeLogic.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/GuildMyInfo.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/GuildMyInfo.java index bfb4e66f2..b3ac8b1e6 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/GuildMyInfo.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/GuildMyInfo.java @@ -40,7 +40,7 @@ public class GuildMyInfo extends MongoBase { private int joinTime;//加入公会时间 //公会副本 - private int guildChallengeDamage; + private long guildChallengeDamage; private int lastMonsterId; //已经使用过刷新的boss private Set refreshedBoss = new HashSet<>(); @@ -300,11 +300,11 @@ public class GuildMyInfo extends MongoBase { updateString("joinTime",joinTime); } - public int getGuildChallengeDamage() { + public long getGuildChallengeDamage() { return guildChallengeDamage; } - public void setGuildChallengeDamage(int guildChallengeDamage) { + public void setGuildChallengeDamage(long guildChallengeDamage) { this.guildChallengeDamage = guildChallengeDamage; updateString("guildChallengeDamage",guildChallengeDamage); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java index 8dc3ed70e..309aea5ea 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java @@ -205,7 +205,7 @@ public class GuildChallengeLogic { } FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent); fightData = fightResult.getFightData(); - int damageInt = (int)fightResult.getDuration(); + long damageInt = fightResult.getDuration(); if(fightResult.getResult()==1) { if(guildInfo.getBossHpRemain()!=-1){ From 9a7a6f71f55344160fa381d82049012bdfc097f9 Mon Sep 17 00:00:00 2001 From: duhui Date: Fri, 10 Dec 2021 18:27:30 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=85=AC=E4=BC=9Aboss=E4=BC=A4=E5=AE=B3?= =?UTF-8?q?=E8=B6=85=E4=B8=8A=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/logic/family/GuildChallengeLogic.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java index 309aea5ea..d48a39228 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildChallengeLogic.java @@ -356,9 +356,6 @@ public class GuildChallengeLogic { } indication.setIsKill(kill); //伤害排行 - - - Family.GuildChallengeResponse.Builder response = Family.GuildChallengeResponse.newBuilder(); response.setDrop(drop); @@ -374,7 +371,7 @@ public class GuildChallengeLogic { response.setKill(kill); - response.setDamage((int)damage); + response.setDamage(damage); PlayerLogic.getInstance().checkAndUpdate(user,config.getPrivilege()[0],1); From 8a77b7c2d51eecaa6b3e3efacfcba6585f0d8556 Mon Sep 17 00:00:00 2001 From: yuanshuai <243578945@qq.com> Date: Fri, 10 Dec 2021 18:43:49 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E9=99=84=E5=8A=A0=E6=9D=A1=E4=BB=B6=E5=8A=9F=E8=83=BD=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/handler/map/MapLogic.java | 72 +++++++++++++++++++ .../main/java/config/SMainLevelConfig.java | 7 ++ 2 files changed, 79 insertions(+) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index f74de0d19..ae66c8d07 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -34,8 +34,10 @@ import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.fight.*; import com.ljsd.jieling.logic.fight.result.FightResult; +import com.ljsd.jieling.logic.hardStage.HardStageLogic; import com.ljsd.jieling.logic.hero.HeroAttributeEnum; import com.ljsd.jieling.logic.hero.HeroLogic; +import com.ljsd.jieling.logic.hero.HongMengAttributeEnum; import com.ljsd.jieling.logic.item.ItemLogic; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; @@ -2102,6 +2104,11 @@ public class MapLogic { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } + boolean isOpenRule=CheckFigthLevelOpen(user,sMainLevelConfig.getOpenRule()); + if (!isOpenRule){ + LOGGER.info("startMainLevelFight==> uid={},fightId={}, levelDifficulty is not allow ", uid, fightId); + throw new ErrorCodeException(ErrorCode.HANDLE_FAILED); + } List teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) { @@ -2123,6 +2130,71 @@ public class MapLogic { } + /** + * 检测附加关卡解锁条件 + * 0:无限制 + * 1:山河星数(3-20后) + * 2:心魔层数(3-10后) + * 3:鸿蒙阵等级(6-15后) + * 4:指定星级(运算星级)装备数量(初始可用) + * 5:英雄总好感度等级(5-10后) + * @param user + * @param openRule + * @return + * @throws Exception + */ + private boolean CheckFigthLevelOpen(User user,int[][] openRule) throws Exception { + boolean isOpen = true; + for (int[] ints : openRule) { + int type = ints[0]; + if (type == 0) { + break; + } + switch (type) { + case 1:{ + if (ints[1]> HardStageLogic.getHardStageStarsSum(user)) { + return false; + } + break; + } + case 2: { + if (ints[1]> user.getMapManager().getLastMonsterAttack()-1) { + return false; + } + break; + } + case 3:{ + HongMengAddAttribute hongMengAddAttribute = user.getHeroManager().getResonanceAddition().get(HongMengAttributeEnum.LEVEL); + if (hongMengAddAttribute==null||ints[1]> hongMengAddAttribute.value) { + return false; + } + break; + } + case 4:{ + int num=0; + MapequipConfig=STableManager.getConfig(SEquipConfig.class); + for (Map.Entry entry : user.getItemManager().getEquipBookMap().entrySet()) { + if (equipConfig.get(entry.getKey()).getStar()>=ints[1]) { + num++; + } + } + if (ints[2]>num) { + return false; + } + break; + } + case 5:{ + if (ints[1]> user.getHeroManager().GetAllLikableLv()) { + return false; + } + break; + } + + } + } + return isOpen; + } + public void endMainLevelFight(ISession session, String frames, int fightId, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); diff --git a/tablemanager/src/main/java/config/SMainLevelConfig.java b/tablemanager/src/main/java/config/SMainLevelConfig.java index fd7ca12c5..0b3a12e5d 100644 --- a/tablemanager/src/main/java/config/SMainLevelConfig.java +++ b/tablemanager/src/main/java/config/SMainLevelConfig.java @@ -15,6 +15,8 @@ public class SMainLevelConfig implements BaseConfig { private int levelLimit; + private int[][] openRule;//附加关卡解锁条件 + private int monsterGroup; private int[] reward; @@ -31,6 +33,7 @@ public class SMainLevelConfig implements BaseConfig { private int[][] invasionBossReward; + private int invasionBossTime; private int invasionBossRefresh; @@ -143,4 +146,8 @@ public class SMainLevelConfig implements BaseConfig { public int getPlotId() { return storyId; } + + public int[][] getOpenRule() { + return openRule; + } } \ No newline at end of file From ea545c50acd6df1473d9002d40aec17ecf6445b1 Mon Sep 17 00:00:00 2001 From: yuanshuai <243578945@qq.com> Date: Mon, 13 Dec 2021 10:12:29 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=B8=BB=E7=BA=BF=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E9=99=90=E5=88=B6=E6=9D=A1=E4=BB=B6=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/handler/map/MapLogic.java | 847 +++++++++--------- 1 file changed, 439 insertions(+), 408 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index ae66c8d07..18abb6334 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -75,7 +75,7 @@ public class MapLogic { public Map baseGameMap = new HashMap<>(); - public static Map> endlessMapCell = new HashMap<>(); + public static Map> endlessMapCell = new HashMap<>(); public static int endlessMapId; public static final int STAR_1 = 1; // 完成任务 @@ -90,19 +90,19 @@ public class MapLogic { baseBehaviorMap.put(baseBehavior.getBehaviorType(), baseBehavior); } for (MapGame mapGame : beansOfMapGame.values()) { - baseGameMap.put(mapGame.getType(), mapGame); + baseGameMap.put(mapGame.getType(), mapGame); } Map sChallengeConfigs = STableManager.getConfig(SChallengeMapConfig.class); - for(Map.Entry entry:sChallengeConfigs.entrySet()){ + for (Map.Entry entry : sChallengeConfigs.entrySet()) { SChallengeMapConfig value = entry.getValue(); - if(value.getMapId()>4000&&value.getMapId()<5000){ + if (value.getMapId() > 4000 && value.getMapId() < 5000) { Set xy = new HashSet<>(); - for(int i = 1;i<=entry.getValue().getSize()[0];i++){ - for(int j = 1;j teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId); if (teamPosHeroInfos == null || teamPosHeroInfos.isEmpty()) { return "阵容不存在"; @@ -384,19 +384,19 @@ public class MapLogic { if (hero == null) { break; } - Map heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero,false,teamId); + Map heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, teamId); TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.Endless); - if(teamId==TeamEnum.ENDLESS_TEAM.getTeamId()&&user.getMapManager().getEndlessMapInfo().getSeason()==timeControllerOfFunction.getTimes()){ + if (teamId == TeamEnum.ENDLESS_TEAM.getTeamId() && user.getMapManager().getEndlessMapInfo().getSeason() == timeControllerOfFunction.getTimes()) { Map endlessHeroInfo = user.getMapManager().getEndlessMapInfo().getEndlessHeroInfo(); - if(endlessHeroInfo!=null&&endlessHeroInfo.size()>0){ - if(initType!=2){ + if (endlessHeroInfo != null && endlessHeroInfo.size() > 0) { + if (initType != 2) { Integer heroPercent = endlessHeroInfo.get(heroInfo.getHeroId()); - if(heroPercent!=null){ - int curHp = (int)((double)heroPercent/10000 * heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); + if (heroPercent != null) { + int curHp = (int) ((double) heroPercent / 10000 * heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())); heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), (long) curHp); } - }else{ - mapManager.updateEndlessHeroHp(hero.getId(),10000); + } else { + mapManager.updateEndlessHeroHp(hero.getId(), 10000); } } } @@ -408,13 +408,13 @@ public class MapLogic { LOGGER.info("enterMap() uid=>{} team pos is wrong ", uid, teamId); return "阵容有误"; } - if(2 == initType && teamId!=TeamEnum.ENDLESS_TEAM.getTeamId()){ + if (2 == initType && teamId != TeamEnum.ENDLESS_TEAM.getTeamId()) { Map foodBufferMap = mapManager.getFoodBufferMap(); - for(Map.Entry item : foodBufferMap.entrySet()){ + for (Map.Entry item : foodBufferMap.entrySet()) { Integer value = item.getValue(); - if(value<=-1){ + if (value <= -1) { SFoodsConfig sFoodsConfig = STableManager.getConfig(SFoodsConfig.class).get(item.getKey()); - CombatLogic.getInstance().updateHeroAttributJustOne(user,teamPosHeroInfos,sFoodsConfig,heroAllAttributeMap,true); + CombatLogic.getInstance().updateHeroAttributJustOne(user, teamPosHeroInfos, sFoodsConfig, heroAllAttributeMap, true); } } } @@ -559,7 +559,7 @@ public class MapLogic { for (int[] weightItem : randomProbability) { totalWeight += weightItem[1]; } - if(totalWeight==0){ + if (totalWeight == 0) { return false; } int random = MathUtils.randomInt(totalWeight); @@ -576,22 +576,22 @@ public class MapLogic { if (triggerXY == -1000) { int uid = session.getUid(); User user = UserManager.getUser(uid); - if(!cells.isEmpty()){ - int curXY = cells.get(cells.size()-1); + if (!cells.isEmpty()) { + int curXY = cells.get(cells.size() - 1); MapManager mapManager = user.getMapManager(); mapManager.addWalkCells(new HashSet<>(cells)); - if(mapManager.getCurMapId()!=0){ - if(SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()==4){ + if (mapManager.getCurMapId() != 0) { + if (SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType() == 4) { int[][] cost = new int[1][]; int costId = SChallengeSetting.getChallengeSetting().getActionPowerId(); int costNum = cells.size(); - mapManager.updateEndlessConsumeExecution(mapManager.getEndlessMapInfo().getConsumeExecution()+costNum); - cost[0]= new int[]{costId,costNum}; - boolean costResult = ItemUtil.itemCost(user,cost,BIReason.ENDLESS_CONSUME_EXECUTION,1); - if(!costResult){ - costNum = (int)user.getItemManager().getItem(costId).getItemNum(); - cost[0][1]= costNum; - ItemUtil.itemCost(user,cost,BIReason.ENDLESS_CONSUME_EXECUTION,1); + mapManager.updateEndlessConsumeExecution(mapManager.getEndlessMapInfo().getConsumeExecution() + costNum); + cost[0] = new int[]{costId, costNum}; + boolean costResult = ItemUtil.itemCost(user, cost, BIReason.ENDLESS_CONSUME_EXECUTION, 1); + if (!costResult) { + costNum = (int) user.getItemManager().getItem(costId).getItemNum(); + cost[0][1] = costNum; + ItemUtil.itemCost(user, cost, BIReason.ENDLESS_CONSUME_EXECUTION, 1); } } } @@ -602,7 +602,7 @@ public class MapLogic { MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder() .setLeftTime(getLeftTime(user, true)) .build(); - MessageUtil.sendMessage(session, 1, messageType.getNumber(),mapUpdateResponse, true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true); return true; } return false; @@ -610,7 +610,7 @@ public class MapLogic { public void updateMap(ISession session, int curXY, int triggerXY, List cells, MessageTypeProto.MessageType messageType) throws Exception { - LOGGER.info("updateMap() curXY=>{},triggerXY=>{},cells={}", curXY, triggerXY,cells); + LOGGER.info("updateMap() curXY=>{},triggerXY=>{},cells={}", curXY, triggerXY, cells); if (updateMapByOnlyConsumeActionPower(session, triggerXY, cells, messageType)) { return; } @@ -634,7 +634,7 @@ public class MapLogic { if (leftTime > 0) { // MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "英雄 " + (leftTime / 1000) + " 秒后复活"); // return; - throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN,Collections.singletonList((leftTime / 1000)+"")); + throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN, Collections.singletonList((leftTime / 1000) + "")); } } // if (mapManager.getStartExporeTime() == 0) { @@ -652,14 +652,14 @@ public class MapLogic { Cell cell = mapManager.getMapInfo().get(triggerXY); if (cell == null) { cell = mapManager.getMapInfo().get(curXY); - if (cell == null&&mapManager.getTrialInfo().getEnergy()!=-1) { + if (cell == null && mapManager.getTrialInfo().getEnergy() != -1) { LOGGER.info("xy is wrong =>{} triggerXY=>{}", curXY, triggerXY); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } - if(cell ==null){ - if(mapManager.getTrialInfo().getEnergy()==100||mapManager.getTrialInfo().getEnergy()==-1){ - MessageUtil.sendErrorResponse(session, -1,messageType.getNumber(),"怪物已被清除!"); + if (cell == null) { + if (mapManager.getTrialInfo().getEnergy() == 100 || mapManager.getTrialInfo().getEnergy() == -1) { + MessageUtil.sendErrorResponse(session, -1, messageType.getNumber(), "怪物已被清除!"); } return; } @@ -674,14 +674,14 @@ public class MapLogic { mapManager.findSuddenlyBoss(bossId, now); } } else if (mapPointConfig.getStyle() == EventType.businessman) { - if (!StoreLogic.checkContainsStore(user, StoreType.CLOUD_STORE,false)) { + if (!StoreLogic.checkContainsStore(user, StoreType.CLOUD_STORE, false)) { int initialEventId = mapPointConfig.getInitialEventId(); SEventPointConfig sEventPointConfig = STableManager.getConfig(SEventPointConfig.class).get(initialEventId); StoreLogic.initOneStore(user, sEventPointConfig.getOption()[0]); } - }else if(mapPointConfig.getStyle()==EventType.towerBuff){ - if(cell.getEventId()==0){ - BehaviorUtil.destoryApointXY(user,triggerXY); + } else if (mapPointConfig.getStyle() == EventType.towerBuff) { + if (cell.getEventId() == 0) { + BehaviorUtil.destoryApointXY(user, triggerXY); throw new ErrorCodeException(ErrorCode.newDefineCode("该点已被清除")); } } @@ -689,7 +689,7 @@ public class MapLogic { mapManager.setTriggerXY(triggerXY); mapManager.addWalkCells(new HashSet<>(cells)); mapManager.setCurXY(curXY); - getMap(user).updateLocation(user,curXY); + getMap(user).updateLocation(user, curXY); MapInfoProto.MapUpdateResponse.Builder mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder(); mapUpdateResponse.setLeftTime(getLeftTime(user, true)); mapUpdateResponse.setEventId(cell.getEventId()); @@ -713,38 +713,39 @@ public class MapLogic { // } mapManager.updateFoodBufferByStep(cells.size()); - if(!cells.isEmpty()){ - if(cells.size() >1){ - lastXY = cells.get(cells.size()-2); + if (!cells.isEmpty()) { + if (cells.size() > 1) { + lastXY = cells.get(cells.size() - 2); } } mapManager.setLastXY(lastXY); - if(mapManager.getCurMapType()==2){ + if (mapManager.getCurMapType() == 2) { Item item = user.getItemManager().getItemMap().get(1); - LOGGER.info("^^^^^^^^玩家:{},无尽副本[行动力]消耗前:{},消耗数量:{}",uid,item.getItemNum(),cells.size()); - ItemUtil.itemCost(user,new int[][]{{1,Math.min((int)item.getItemNum(),cells.size())}},BIReason.ENDLESS_CONSUME_EXECUTION,1); - LOGGER.info("^^^^^^^^玩家:{},无尽副本[行动力]消耗后:{}",uid,Optional.ofNullable(user.getItemManager().getItemMap().get(1)).map(Item::getItemNum).orElse(0L)); - Set openCells = getOpenCells(mapManager.getCurMapId(),cells); + LOGGER.info("^^^^^^^^玩家:{},无尽副本[行动力]消耗前:{},消耗数量:{}", uid, item.getItemNum(), cells.size()); + ItemUtil.itemCost(user, new int[][]{{1, Math.min((int) item.getItemNum(), cells.size())}}, BIReason.ENDLESS_CONSUME_EXECUTION, 1); + LOGGER.info("^^^^^^^^玩家:{},无尽副本[行动力]消耗后:{}", uid, Optional.ofNullable(user.getItemManager().getItemMap().get(1)).map(Item::getItemNum).orElse(0L)); + Set openCells = getOpenCells(mapManager.getCurMapId(), cells); mapManager.addEndlessOpenCell(openCells); Set walkCells = mapManager.getEndlessMapInfo().getOpenCell(); - user.getUserMissionManager().onGameEvent(user,GameEvent.ENDLESS_OPEN_MAP,walkCells.size()*100/(30*30)); + user.getUserMissionManager().onGameEvent(user, GameEvent.ENDLESS_OPEN_MAP, walkCells.size() * 100 / (30 * 30)); } - LOGGER.info("the uid+{},the lastXy={}",uid,lastXY); + LOGGER.info("the uid+{},the lastXy={}", uid, lastXY); MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse.build(), true); } - private Set getOpenCells(int mapId,List cells){ + + private Set getOpenCells(int mapId, List cells) { int square = 3;//范围是3 - Set openCells= new HashSet<>(); - if(!endlessMapCell.containsKey(mapId)){ + Set openCells = new HashSet<>(); + if (!endlessMapCell.containsKey(mapId)) { return null; } Set mapAllCell = endlessMapCell.get(mapId); - for(int cell:cells){ - for(int i =-square;i<=square;i++){ + for (int cell : cells) { + for (int i = -square; i <= square; i++) { int yOff = square - Math.abs(i); - for(int j = -yOff;j<=yOff;j++){ + for (int j = -yOff; j <= yOff; j++) { int openCell = cell + 256 * i + j; - if(!mapAllCell.contains(openCell)){ + if (!mapAllCell.contains(openCell)) { continue; } openCells.add(openCell); @@ -778,7 +779,7 @@ public class MapLogic { if (mapManager.getCanMoveTime() > 0) { long leftTime = mapManager.getCanMoveTime() - TimeUtils.now(); if (leftTime > 0) { - throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN,Collections.singletonList((leftTime / 1000)+"")); + throw new ErrorCodeException(ErrorCode.HERO_LIVE_AGAIN, Collections.singletonList((leftTime / 1000) + "")); } } Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); @@ -913,7 +914,7 @@ public class MapLogic { // 3 条件跳转 1001#1002|0(0或1为和)#条件id#条件id case 3: case 8: - case 10: { + case 10: { SOptionAddCondition sOptionAddConditions = SOptionAddCondition.sOptionAddConditionMap.get(jumpTypeValues[1][1]); if (sOptionAddConditions == null) { LOGGER.info("sOptionAddConditions == null jumpTypeValues[1][1]=>{}", jumpTypeValues[1][1]); @@ -925,9 +926,9 @@ public class MapLogic { case 4: { return cell.getEventId(); } - case 11:{ + case 11: { int lastFightResult = user.getMapManager().getLastFightResult(); - if(lastFightResult == 1){ + if (lastFightResult == 1) { return jumpTypeValues[0][0]; } return jumpTypeValues[0][1]; @@ -993,7 +994,7 @@ public class MapLogic { case 2: { Map itemMap = new HashMap<>(); int[][] values = sOptionAddConditions.getValues(); - for(int [] item: values){ + for (int[] item : values) { itemMap.put(item[0], item[1]); } boolean b = ItemUtil.checkCost(user, itemMap); @@ -1013,7 +1014,7 @@ public class MapLogic { if (values[0][0] == 1) { for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) { Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId()); - Map map = HeroLogic.getInstance().calHeroFinalAttributeWhenInMap(user, hero,false,teamId); + Map map = HeroLogic.getInstance().calHeroFinalAttributeWhenInMap(user, hero, false, teamId); Long integer = map.get(values[0][1]); if (integer == null || integer < values[0][2]) { return jumpTypeValues[0][1]; @@ -1023,7 +1024,7 @@ public class MapLogic { } else if (values[0][0] == 0) { for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) { Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId()); - Map map = HeroLogic.getInstance().calHeroFinalAttributeWhenInMap(user, hero,false,teamId); + Map map = HeroLogic.getInstance().calHeroFinalAttributeWhenInMap(user, hero, false, teamId); Long integer = map.get(values[0][1]); if (integer != null && integer >= values[0][2]) { return jumpTypeValues[0][0]; @@ -1061,20 +1062,20 @@ public class MapLogic { } break; } - case 7:{ + case 7: { int lastFightResult = user.getMapManager().getLastFightResult(); - if(lastFightResult == 1){ + if (lastFightResult == 1) { return jumpTypeValues[0][0]; } return jumpTypeValues[0][1]; } - case 10:{ + case 10: { Map cellRefreshTime = user.getMapManager().getEndlessMapInfo().getCellRefreshTime(); Integer time = cellRefreshTime.get(mapManager.getCurXY()); - if(time!=null&&time>TimeUtils.now()/1000){ - nextEventId=jumpTypeValues[0][0]; - }else{ - nextEventId=jumpTypeValues[0][1]; + if (time != null && time > TimeUtils.now() / 1000) { + nextEventId = jumpTypeValues[0][0]; + } else { + nextEventId = jumpTypeValues[0][1]; } break; } @@ -1105,21 +1106,21 @@ public class MapLogic { * @param messageType * @throws Exception */ - public void outMap(ISession session, int mapId,int outType, int curXY,int targetMapId,MessageTypeProto.MessageType messageType) throws Exception { + public void outMap(ISession session, int mapId, int outType, int curXY, int targetMapId, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); MapManager mapManager = user.getMapManager(); SChallengeConfig challengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()); - if(mapManager.getCurMapId()==0){ + if (mapManager.getCurMapId() == 0) { mapManager.setCurXY(0); - MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true); return; } MapInfoProto.MapOutResponse.Builder builder = MapInfoProto.MapOutResponse.newBuilder(); //无尽副本 - if(challengeConfig.getType()==4) { - if(outType==1){ + if (challengeConfig.getType() == 4) { + if (outType == 1) { // mapManager.updateEndlessLocation(0); // int[][] cost = new int[1][]; // int costId = SChallengeSetting.getChallengeSetting().getActionPowerId(); @@ -1138,7 +1139,7 @@ public class MapLogic { // return; // } // LOGGER.info("传送消耗{}行动力"+Math.abs(costNum-costNum2)); - }else{ + } else { // if(MapLogic.endlessSeason!=mapManager.getEndlessMapInfo().getSeason()){ // mapManager.updateEndlessLocation(0); // }else{ @@ -1148,25 +1149,25 @@ public class MapLogic { mapManager.updateEndlessFightCount(0); } //无尽副本信息保存 - if(mapManager.getWalkCells()!=null){ + if (mapManager.getWalkCells() != null) { mapManager.endlessWalkCellSave(mapManager.getWalkCells()); } mapManager.endlessMapInfoSave(mapManager.getMapInfo()); } - if(outType == 0||mapManager.getTrialInfo().getFloor()-1==STrialConfig.getHighestTower()){ - if(mapManager.getTowerUnusedBuffer()!=null){ + if (outType == 0 || mapManager.getTrialInfo().getFloor() - 1 == STrialConfig.getHighestTower()) { + if (mapManager.getTowerUnusedBuffer() != null) { mapManager.setTowerUnusedBuffer(new HashMap<>()); } LOGGER.info("退出地图"); - if(challengeConfig.getType()==2){ - if(mapManager.getTrialInfo().getFloor()>=1){ + if (challengeConfig.getType() == 2) { + if (mapManager.getTrialInfo().getFloor() >= 1) { mapManager.setMapIntoFlag(1); - if(mapManager.getTrialInfo().getFloor()==STrialConfig.getHighestTower()){ + if (mapManager.getTrialInfo().getFloor() == STrialConfig.getHighestTower()) { mapManager.setHighestFloor(mapManager.getTrialInfo().getFloor()); AbstractRank towerRank = RankContext.getRankEnum(RankEnum.TOWER_RANK.getType()); // TowerRankUtil.getRankNumber(mapManager.getTrialInfo().getFloor(),(int)(mapManager.getCurrTowerTime()/1000)) - if(towerRank.getScore(mapManager.getTrialInfo().getFloor(),(int)(mapManager.getCurrTowerTime()/1000))>towerRank.getScoreById(user.getId(),"")){ - towerRank.addRank(user.getId(),"",mapManager.getTrialInfo().getFloor(),(int)(mapManager.getCurrTowerTime()/1000)); + if (towerRank.getScore(mapManager.getTrialInfo().getFloor(), (int) (mapManager.getCurrTowerTime() / 1000)) > towerRank.getScoreById(user.getId(), "")) { + towerRank.addRank(user.getId(), "", mapManager.getTrialInfo().getFloor(), (int) (mapManager.getCurrTowerTime() / 1000)); // RedisUtil.getInstence().zsetAddOne(RedisKey.getKey(RedisKey.TOWER_RANK,"",false),String.valueOf(user.getId()),TowerRankUtil.getRankNumber(mapManager.getTrialInfo().getFloor(),(int)(mapManager.getCurrTowerTime()/1000))); } } @@ -1181,21 +1182,21 @@ public class MapLogic { } } - int time = (int)(mapManager.getCurrTowerTime())/1000; + int time = (int) (mapManager.getCurrTowerTime()) / 1000; builder.setUseTime(time); - LOGGER.info("当前层使用时间{}",time); + LOGGER.info("当前层使用时间{}", time); //清除副本中增加的怪物被动技能 user.getMapManager().removeMonsterTempSkill(); //精英本功绩清除计数 - if(challengeConfig.getType()==3){ + if (challengeConfig.getType() == 3) { int[] achievementRefreshType = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getAchievementRefreshType(); List accomplishmentConfig = SAccomplishmentConfig.getsAccomplishmentConfigByMapId(challengeConfig.getMapId()); MapMission mapMission = mapManager.getCopyMissionProgresById(challengeConfig.getMapId()); Map copyMissionProgresById = mapMission.getAllMissionProgress(); - for(SAccomplishmentConfig accomplishment:accomplishmentConfig){ - for(int i = 0 ; i + * // * @param session + * // * @param messageType */ // public void fastFight(ISession session, MessageTypeProto.MessageType messageType) throws Exception { // int uid = session.getUid(); @@ -1709,8 +1710,6 @@ public class MapLogic { // } // MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true); // } - - public void initMapMission(MapManager mapManager) { int mapId = mapManager.getCurMapId(); if (mapManager.getCopyMissionProgresById(mapId) != null) { @@ -1808,7 +1807,7 @@ public class MapLogic { if (hero == null) { continue; } - heroForces += HeroLogic.getInstance().calHeoForce(user, hero,mapManager.getTeamId()); + heroForces += HeroLogic.getInstance().calHeoForce(user, hero, mapManager.getTeamId()); crossInfo.getHeroIds().add(hero.getTemplateId()); } @@ -1833,7 +1832,7 @@ public class MapLogic { MapMissionManager.processPassMapEvent(user, useTime); } - mission.setDeadTimes( mapManager.getDieCount()); + mission.setDeadTimes(mapManager.getDieCount()); mapManager.setMission(mission); checkMissionReturn.mission = mission; return checkMissionReturn; @@ -1926,25 +1925,25 @@ public class MapLogic { SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapId); MapManager mapManager = user.getMapManager(); - if(sChallengeConfig.getSweepingOpenRule().length<1){ + if (sChallengeConfig.getSweepingOpenRule().length < 1) { throw new ErrorCodeException(ErrorCode.MAP_SWEEP_CANT); } - if(sChallengeConfig.getSweepingOpenRule()[0]==1){ + if (sChallengeConfig.getSweepingOpenRule()[0] == 1) { CrossInfo crossInfo = mapManager.getCrossInfoMap().get(mapId); - if (null == crossInfo||crossInfo.getStars().size() < sChallengeConfig.getSweepingOpenRule()[1]) { + if (null == crossInfo || crossInfo.getStars().size() < sChallengeConfig.getSweepingOpenRule()[1]) { throw new ErrorCodeException(ErrorCode.newDefineCode("sweepBossFight 未三星通关")); } - }else if(sChallengeConfig.getSweepingOpenRule()[0]==2){ + } else if (sChallengeConfig.getSweepingOpenRule()[0] == 2) { CrossInfo crossInfo = mapManager.getCrossInfoMap().get(mapId); - if(crossInfo == null){ + if (crossInfo == null) { throw new ErrorCodeException(ErrorCode.newDefineCode("未通关")); } MapMission copyMission = mapManager.getCopyMissionProgresById(sChallengeConfig.getMapId()); - if(copyMission.getTotalWeight()0){ + if (sweepingStoreProbability.length > 0) { hasStore = MathUtils.randomFromWeight(sChallengeConfig.getSweepingStoreProbability()); - if(hasStore==1){ - StoreLogic.initOneStore(user,sChallengeConfig.getSweepingStoreId()); + if (hasStore == 1) { + StoreLogic.initOneStore(user, sChallengeConfig.getSweepingStoreId()); mapSweepResponse.setCloudStore(hasStore); break; } @@ -1977,17 +1976,17 @@ public class MapLogic { //随机 int sweepingMonsterId = sChallengeConfig.getSweepingMonsterId(); - if(sweepingMonsterId!=0){ + if (sweepingMonsterId != 0) { mapManager.checkSuddenlyBoss(); int suddenlyBoss = mapManager.getSuddenlyBoss(); if (suddenlyBoss == 0) { int now = (int) (TimeUtils.now() / 1000); int hasBoss = 0; - for(int i=0;i0){ + if (sweepingMonsterProbability.length > 0) { hasBoss = MathUtils.randomFromWeight(sChallengeConfig.getSweepingMonsterProbability()); - if(hasBoss==1){ + if (hasBoss == 1) { mapManager.findSuddenlyBoss(sChallengeConfig.getSweepingMonsterId(), now); mapManager.setFindSuddenlyBossMapId(mapId); mapSweepResponse.setSuddenlyBossInfo(CommonProto.SuddenlyBossInfo.newBuilder().setSuddBossId(mapManager.getSuddenlyBoss()).setEndTime(mapManager.getSuddenlyBossEndTime()).setFindMapId(mapManager.getFindSuddenlyBossMapId()).build()); @@ -2003,10 +2002,10 @@ public class MapLogic { CommonProto.Drop.Builder dropBuilder = ItemUtil.drop(user, sChallengeMapConfig.getSweepingAward(), 1, 0, BIReason.MAP_SWEEP_REWARD); mapSweepResponse.addDrop(dropBuilder); } - Poster.getPoster().dispatchEvent(new StoryEvent(user.getId(),count)); - user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, mapId,1,count); - user.getUserMissionManager().onGameEvent(user, GameEvent.PlAY_STORY, type,count); - user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP, mapId,1,count); + Poster.getPoster().dispatchEvent(new StoryEvent(user.getId(), count)); + user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, mapId, 1, count); + user.getUserMissionManager().onGameEvent(user, GameEvent.PlAY_STORY, type, count); + user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP, mapId, 1, count); MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapSweepResponse.build(), true); } @@ -2029,7 +2028,7 @@ public class MapLogic { } FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder(); SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getFindSuddenlyBossMapId()); - BehaviorUtil.getLevelDifficultyifficuFightInfo(user,FightType.MapExploreFight, suddenlyBoss, teamId, sChallengeConfig.getMostTime(), fightStartResponse, RedisKey.SUDDLENLY_FIGHT); + BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.MapExploreFight, suddenlyBoss, teamId, sChallengeConfig.getMostTime(), fightStartResponse, RedisKey.SUDDLENLY_FIGHT); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true); } @@ -2038,7 +2037,7 @@ public class MapLogic { User user = UserManager.getUser(uid); MapManager mapManager = user.getMapManager(); SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getFindSuddenlyBossMapId()); - FightEvent fightEvent = new FightEvent(uid, -1, sChallengeConfig.getMostTime(),frames,GameFightType.EndSuddlenlyFight); + FightEvent fightEvent = new FightEvent(uid, -1, sChallengeConfig.getMostTime(), frames, GameFightType.EndSuddlenlyFight); FightResult fightResult = FightDispatcher.dispatcher(fightEvent); //校验结果码 1:胜利 if (fightResult.getResult() == -1) { @@ -2060,7 +2059,6 @@ public class MapLogic { } - /** * 获取所有关卡信息 * @@ -2079,33 +2077,30 @@ public class MapLogic { } - - /** - * 新关卡战斗 + * 新关卡战斗 */ public void startMainLevelFight(ISession session, int fightId, int teamId, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); MainLevelManager mainLevelManager = user.getMainLevelManager(); SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId); - LOGGER.info("the uid={},play fightId={}",uid,fightId); + LOGGER.info("the uid={},play fightId={}", uid, fightId); int mineFightId = mainLevelManager.getFightId(); if (mineFightId != fightId) { LOGGER.info("startMainLevelFight==> uid={},fightId={}, levelDifficulty is not allow ", uid, fightId); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); - } - else if (mainLevelManager.getState()!=1){ + } else if (mainLevelManager.getState() != 1) { // 动态匹配最新的表数据 - if (sMainLevelConfig != null && sMainLevelConfig.getNextLevel() != -1 && user.getPlayerInfoManager().getLevel() >= sMainLevelConfig.getLevelLimit()){ + if (sMainLevelConfig != null && sMainLevelConfig.getNextLevel() != -1 && user.getPlayerInfoManager().getLevel() >= sMainLevelConfig.getLevelLimit()) { mainLevelManager.setState(1); - }else { + } else { LOGGER.info("startMainLevelFight==> uid={},fightId={}, levelDifficulty is not allow ", uid, fightId); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } - boolean isOpenRule=CheckFigthLevelOpen(user,sMainLevelConfig.getOpenRule()); - if (!isOpenRule){ + boolean isOpenRule = CheckFigthLevelOpen(user, sMainLevelConfig.getOpenRule()); + if (!isOpenRule) { LOGGER.info("startMainLevelFight==> uid={},fightId={}, levelDifficulty is not allow ", uid, fightId); throw new ErrorCodeException(ErrorCode.HANDLE_FAILED); } @@ -2117,15 +2112,15 @@ public class MapLogic { } // KtEventUtils.onKtEvent(user,ParamEventBean.UserGameType,KTGameType.STORY.getIndex(),fightId); - ReportUtil.onReportEvent(user, ReportEventEnum.ENTER_STAGE.getType(),String.valueOf(fightId)); + ReportUtil.onReportEvent(user, ReportEventEnum.ENTER_STAGE.getType(), String.valueOf(fightId)); user.getTeamPosManager().setCurTeamPosId(teamId); String fightInfo = fightId + "#" + teamId; String key = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_INFO, String.valueOf(uid), false); - LOGGER.info("关卡战斗start{},{}",uid,fightInfo); + LOGGER.info("关卡战斗start{},{}", uid, fightInfo); RedisUtil.getInstence().set(key, fightInfo, 600); //扣除预先道具 FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder(); - BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.StoryFight,sMainLevelConfig.getMonsterGroup(), teamId, sMainLevelConfig.getRankTime(), fightStartResponse, RedisKey.LEVE_DIFFICULTY_FIGHT); + BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.StoryFight, sMainLevelConfig.getMonsterGroup(), teamId, sMainLevelConfig.getRankTime(), fightStartResponse, RedisKey.LEVE_DIFFICULTY_FIGHT); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true); } @@ -2138,12 +2133,14 @@ public class MapLogic { * 3:鸿蒙阵等级(6-15后) * 4:指定星级(运算星级)装备数量(初始可用) * 5:英雄总好感度等级(5-10后) + * 7:达到指定英雄等级及数量 + * * @param user * @param openRule * @return * @throws Exception */ - private boolean CheckFigthLevelOpen(User user,int[][] openRule) throws Exception { + private boolean CheckFigthLevelOpen(User user, int[][] openRule) throws Exception { boolean isOpen = true; for (int[] ints : openRule) { int type = ints[0]; @@ -2151,40 +2148,52 @@ public class MapLogic { break; } switch (type) { - case 1:{ - if (ints[1]> HardStageLogic.getHardStageStarsSum(user)) { + case 1: { + if (HardStageLogic.getHardStageStarsSum(user) < ints[1]) { return false; } break; } case 2: { - if (ints[1]> user.getMapManager().getLastMonsterAttack()-1) { + if (user.getMapManager().getLastMonsterAttack() - 1 < ints[1]) { return false; } break; } - case 3:{ + case 3: { HongMengAddAttribute hongMengAddAttribute = user.getHeroManager().getResonanceAddition().get(HongMengAttributeEnum.LEVEL); - if (hongMengAddAttribute==null||ints[1]> hongMengAddAttribute.value) { + if (hongMengAddAttribute == null || hongMengAddAttribute.value < ints[1]) { return false; } break; } - case 4:{ - int num=0; - MapequipConfig=STableManager.getConfig(SEquipConfig.class); + case 4: { + int num = 0; + Map equipConfig = STableManager.getConfig(SEquipConfig.class); for (Map.Entry entry : user.getItemManager().getEquipBookMap().entrySet()) { - if (equipConfig.get(entry.getKey()).getStar()>=ints[1]) { + if (equipConfig.get(entry.getKey()).getStar() >= ints[1]) { num++; } } - if (ints[2]>num) { + if (num < ints[2]) { return false; } break; } - case 5:{ - if (ints[1]> user.getHeroManager().GetAllLikableLv()) { + case 5: { + if (user.getHeroManager().GetAllLikableLv() < ints[1]) { + return false; + } + break; + } + case 7: { + int num = 0; + for (Map.Entry stringHeroEntry : user.getHeroManager().getHeroMap().entrySet()) { + if (stringHeroEntry.getValue().getOriginalLevel()>= ints[1]) { + num++; + } + } + if (num < ints[2]) { return false; } break; @@ -2210,7 +2219,7 @@ public class MapLogic { LOGGER.info("endFight() uid=>{} fightId=>{},checkFightId={}", uid, fightId, checkFightId); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - LOGGER.info("关卡战斗end{},{}",uid,fightInfos); + LOGGER.info("关卡战斗end{},{}", uid, fightInfos); SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId); FightResult fightResult = null; if (sMainLevelConfig.getPlotId() == 0) { @@ -2228,85 +2237,84 @@ public class MapLogic { } } CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMainLevelConfig.getReward(), 1, 0, BIReason.LEVELDIFFICULTY_FIGHT_REWARD); - openNextMainLevel(session,user, fightId); + openNextMainLevel(session, user, fightId); FightInfoProto.FightEndResponse.Builder fightEndResponse = FightInfoProto.FightEndResponse.newBuilder(); fightEndResponse.setEnventDrop(drop); fightEndResponse.setResult(fightResult == null ? 1 : fightResult.getResult()); fightEndResponse.build(); MainLevelManager mainLevelManager = user.getMainLevelManager(); FightInfoProto.MainLevelFightUpdateIndication build = FightInfoProto.MainLevelFightUpdateIndication.newBuilder().setState(mainLevelManager.getState()).setFightId(mainLevelManager.getFightId()).build(); - MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.MAIN_LEVEL_FIGHT_UPDATE_INDICATION_VALUE,build,true); + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MAIN_LEVEL_FIGHT_UPDATE_INDICATION_VALUE, build, true); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true); int integerValue = SSpecialConfig.getIntegerValue(SSpecialConfig.DISCOUNT_MAIN); // String rankKey = RedisKey.getKey(RedisKey.MAINLEVEL_RANK, "", false); // RedisUtil.getInstence().zsetAddOne(rankKey, String.valueOf(user.getId()), sMainLevelConfig.getVirtureId()); - RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(uid,"",sMainLevelConfig.getVirtureId(),user.getPlayerInfoManager().getMaxForce()); - ReportUtil.onReportEvent(user, ReportEventEnum.PASS_STAGE.getType(),String.valueOf(fightId),"",sMainLevelConfig.getReward(),new Date()); + RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(uid, "", sMainLevelConfig.getVirtureId(), user.getPlayerInfoManager().getMaxForce()); + ReportUtil.onReportEvent(user, ReportEventEnum.PASS_STAGE.getType(), String.valueOf(fightId), "", sMainLevelConfig.getReward(), new Date()); } - public void openNextMainLevel(ISession session,User user,int fightId) throws Exception { + public void openNextMainLevel(ISession session, User user, int fightId) throws Exception { int level = user.getPlayerInfoManager().getLevel(); int state = 1; int updateFightId = fightId; SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId); - if(sMainLevelConfig.getNextLevel()!=-1){ + if (sMainLevelConfig.getNextLevel() != -1) { SMainLevelConfig sMainLevelConfigNext = SMainLevelConfig.config.get(sMainLevelConfig.getNextLevel()); - if(sMainLevelConfigNext.getLevelLimit()>level){ - state =-1; + if (sMainLevelConfigNext.getLevelLimit() > level) { + state = -1; } updateFightId = sMainLevelConfigNext.getId(); - }else{ - state =2; + } else { + state = 2; } - Poster.getPoster().dispatchEvent(new FightMainEvent(user.getId(),fightId)); - Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.LEVEL_FIGHT.getType(),fightId)); - user.getMainLevelManager().updateFight(updateFightId,state); - BuyGoodsNewLogic.openPush(session,user, PushRechargeType.main_line.getType(),fightId,0); - if(state == -1){ + Poster.getPoster().dispatchEvent(new FightMainEvent(user.getId(), fightId)); + Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.LEVEL_FIGHT.getType(), fightId)); + user.getMainLevelManager().updateFight(updateFightId, state); + BuyGoodsNewLogic.openPush(session, user, PushRechargeType.main_line.getType(), fightId, 0); + if (state == -1) { //删除为0的 Map fightStateInfo = user.getMainLevelManager().getFightStateInfo(); Set removeCache = new HashSet<>(); - for(Map.Entry item : fightStateInfo.entrySet()){ - if(item.getValue()==0 && item.getKey()!=fightId){ + for (Map.Entry item : fightStateInfo.entrySet()) { + if (item.getValue() == 0 && item.getKey() != fightId) { removeCache.add(item.getKey()); } } - for(Integer removeId : removeCache){ + for (Integer removeId : removeCache) { user.getMainLevelManager().removeFightStateInfo(removeId); } } - user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, fightId,0,1); - user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP, fightId,0,1); + user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, fightId, 0, 1); + user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP, fightId, 0, 1); // user.getUserMissionManager().gameEvent(user, new LevelEvent(), fightId); } public void getMainLevelInfo(ISession session) throws Exception { User user = UserManager.getUser(session.getUid()); PlayerInfoProto.GetMainLevelInfoResponse mainLevelInfoResponse = CBean2Proto.getMainLevelInfoResponse(user); - MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.MAIN_LEVEL_GET_INFO_RESPONSE_VALUE,mainLevelInfoResponse,true); + MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.MAIN_LEVEL_GET_INFO_RESPONSE_VALUE, mainLevelInfoResponse, true); } - /** * 兽潮开始战斗 * * @param session * @param fightId */ - public void startMonsterAttackFight(ISession session, int fightId, int teamId, MessageTypeProto.MessageType messageType) throws Exception { + public void startMonsterAttackFight(ISession session, int fightId, int teamId, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); - if(user.getMapManager().getLastMonsterAttack()!=fightId){ + if (user.getMapManager().getLastMonsterAttack() != fightId) { LOGGER.info("endFight() uid=>{} fightId=>{} SLevelDifficultyConfig == null", uid, fightId, teamId); throw new ErrorCodeException(ErrorCode.newDefineCode("fightId 有误")); } - SFloodConfig sFloodConfig =STableManager.getConfig(SFloodConfig.class).get(fightId); + SFloodConfig sFloodConfig = STableManager.getConfig(SFloodConfig.class).get(fightId); if (sFloodConfig == null) { LOGGER.info("endFight() uid=>{} fightId=>{} SLevelDifficultyConfig == null", uid, fightId); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); @@ -2324,8 +2332,8 @@ public class MapLogic { RedisUtil.getInstence().set(key, fightInfo, -1); FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder(); - BehaviorUtil.getLevelDifficultyifficuFightInfo(user,FightType.MonterFight, sFloodConfig.getMonster(), teamId, sFloodConfig.getBattleTime(), fightStartResponse, RedisKey.CHALLENGE_MONSTER_ATTACK); - user.getUserMissionManager().onGameEvent(user,GameEvent.MONSTER_ATTACK_PLAY); + BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.MonterFight, sFloodConfig.getMonster(), teamId, sFloodConfig.getBattleTime(), fightStartResponse, RedisKey.CHALLENGE_MONSTER_ATTACK); + user.getUserMissionManager().onGameEvent(user, GameEvent.MONSTER_ATTACK_PLAY); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true); // ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_XINMO.getType(),fightId,sFloodConfig.getMonster(),MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}),""); } @@ -2339,7 +2347,7 @@ public class MapLogic { User user = UserManager.getUser(uid); String fightKey = RedisKey.getKey(RedisKey.CHALLENGE_MONSTER_INFO, String.valueOf(uid), false); String fightInfos = (String) RedisUtil.getInstence().get(fightKey); - if (fightInfos == null|| fightInfos.isEmpty()) { + if (fightInfos == null || fightInfos.isEmpty()) { LOGGER.info("endFight() uid=>{} fightKey={},fightId={} fightInfos == null", uid, fightKey); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } @@ -2352,7 +2360,7 @@ public class MapLogic { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - FightEvent fightEvent = new FightEvent(uid, -1, sFloodConfig.getBattleTime(),frames, GameFightType.EndMonsterAttackFight); + FightEvent fightEvent = new FightEvent(uid, -1, sFloodConfig.getBattleTime(), frames, GameFightType.EndMonsterAttackFight); FightResult fightResult = FightDispatcher.dispatcher(fightEvent); //校验结果码 1:胜利 int resultCode = fightResult.getResult(); @@ -2367,23 +2375,23 @@ public class MapLogic { .setEnventDrop(dropBuilder) .build(); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse, true); - ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_XINMO.getType(),checkFightId,sFloodConfig.getMonster(),MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}),new Date(),"",null,null,"失败"); + ReportUtil.onReportEvent(user, ReportEventEnum.COMPLETE_XINMO.getType(), checkFightId, sFloodConfig.getMonster(), MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}), new Date(), "", null, null, "失败"); return; } - BuyGoodsNewLogic.openPush(session,user,PushRechargeType.tower.getType(),sFloodConfig.getId(),0); + BuyGoodsNewLogic.openPush(session, user, PushRechargeType.tower.getType(), sFloodConfig.getId(), 0); //排行榜 // String rankKey = RedisKey.getKey(RedisKey.MONSTER_ATTACK_RANK,"", false); // RedisUtil.getInstence().zsetAddOneOffsetByTime(rankKey, String.valueOf(user.getId()), checkFightId); - RankContext.getRankEnum(RankEnum.MONSTER_ATTACK_RANK.getType()).addRank(uid,"",checkFightId); + RankContext.getRankEnum(RankEnum.MONSTER_ATTACK_RANK.getType()).addRank(uid, "", checkFightId); CommonProto.Drop.Builder drop = ItemUtil.drop(user, sFloodConfig.getReward(), BIReason.MONSTERATTACK_REWARD); FightInfoProto.FightEndResponse.Builder fightEndResponse = FightInfoProto.FightEndResponse.newBuilder(); fightEndResponse.setEnventDrop(drop); fightEndResponse.setResult(resultCode); fightEndResponse.build(); user.getMapManager().setLastMonsterAttack(checkFightId + 1); - ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.THREE_WORLD_NEW,checkFightId); - user.getUserMissionManager().onGameEvent(user,GameEvent.MONSTER_ATTACK_LEVEL); - user.getUserMissionManager().onGameEvent(user,GameEvent.MISTY_TRIP); + ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.THREE_WORLD_NEW, checkFightId); + user.getUserMissionManager().onGameEvent(user, GameEvent.MONSTER_ATTACK_LEVEL); + user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP); MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true); String stringValue = SSpecialConfig.getStringValue(SSpecialConfig.DISCOUNT_MONSTER_LEVEL); @@ -2405,18 +2413,16 @@ public class MapLogic { List itemDrop = drop.getItemlistList(); List itemIdList = new ArrayList<>(); List itemNumList = new ArrayList<>(); - itemDrop.forEach(item->{ + itemDrop.forEach(item -> { itemIdList.add(item.getItemId()); - itemNumList.add((int)item.getItemNum()); + itemNumList.add((int) item.getItemNum()); }); //发福利红包 - Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.soul_demon.getType(),checkFightId)); - ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_XINMO.getType(),checkFightId,sFloodConfig.getMonster(),MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}),new Date(),"",itemIdList,itemNumList,"成功"); + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.soul_demon.getType(), checkFightId)); + ReportUtil.onReportEvent(user, ReportEventEnum.COMPLETE_XINMO.getType(), checkFightId, sFloodConfig.getMonster(), MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}), new Date(), "", itemIdList, itemNumList, "成功"); } - - public void gmCrossFight(int uid, int arrayMapId) throws Exception { User user = UserManager.getUser(uid); if (user == null || user.getMapManager() == null) { @@ -2438,8 +2444,8 @@ public class MapLogic { crossInfo.getStars().add(STAR_3); crossInfoMap.put(i, crossInfo); mapManager.updateCrossInfoMap(i, crossInfo); - user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, i, 1,1); - user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP, i, 1,1); + user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, i, 1, 1); + user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP, i, 1, 1); } } @@ -2455,15 +2461,14 @@ public class MapLogic { } - public void clearNormalMonster(User user) throws Exception { LOGGER.info("删除当前地图小怪!!"); Map configMap = MapPointConfig.scMapEventMap; Set destoryCell = new HashSet<>(); Map mapInfo = user.getMapManager().getMapInfo(); - for(Map.Entry entry:mapInfo.entrySet()){ + for (Map.Entry entry : mapInfo.entrySet()) { int monsterType = configMap.get(entry.getValue().getPointId()).getStyle(); - if(monsterType==1||monsterType==11){ + if (monsterType == 1 || monsterType == 11) { // if(!CellUtil.checkIsNextCell(mapManager.getTriggerXY(),entry.getKey())&&entry.getValue().getEventId() == -1){ // continue; // } @@ -2471,21 +2476,23 @@ public class MapLogic { } } - LOGGER.info("几种:{}",mapInfo.size()); + LOGGER.info("几种:{}", mapInfo.size()); int[] x = Arrays.stream(destoryCell.toArray(new Integer[destoryCell.size()])).mapToInt(Integer::valueOf).toArray(); - BehaviorUtil.destoryPoints(user,x); + BehaviorUtil.destoryPoints(user, x); } + /** * 爬塔使用Buff + * * @param session * @param messageType */ - public void useTowerBuff(ISession session,int towerLevel,int optionId , MessageTypeProto.MessageType messageType) throws Exception { + public void useTowerBuff(ISession session, int towerLevel, int optionId, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); MapManager mapManager = UserManager.getUser(uid).getMapManager(); User user = UserManager.getUser(uid); String err = checkUseTowerBuff(mapManager, towerLevel, optionId); - if(!"".equals(err)){ + if (!"".equals(err)) { throw new ErrorCodeException(ErrorCode.newDefineCode(err)); } int eventId = mapManager.getTowerUnusedBuffer().get(towerLevel); @@ -2523,24 +2530,24 @@ public class MapLogic { .setBehaviorType(sOptionConfig.getBehaviorType()) .addAllEventBehaviorValues(eventBehaviorValuesList) .build(); - LOGGER.info("使用第{},mapPointId,id是:{}",towerLevel,eventId); + LOGGER.info("使用第{},mapPointId,id是:{}", towerLevel, eventId); MapInfoProto.UseTowerBuffResponse.Builder useTowerBuffResponse = MapInfoProto.UseTowerBuffResponse.newBuilder(); useTowerBuffResponse.setEventBehaviorCommon(eventBehaviorCommon); - // useTowerBuffResponse.setBuffId(buffId); - MessageUtil.sendMessage(session,1,messageType.getNumber(),useTowerBuffResponse.build(),true); + // useTowerBuffResponse.setBuffId(buffId); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), useTowerBuffResponse.build(), true); } - public String checkUseTowerBuff(MapManager mapManager,int towerLevel,int optionId){ - if(!mapManager.getTowerUnusedBuffer().containsKey(towerLevel)){ + public String checkUseTowerBuff(MapManager mapManager, int towerLevel, int optionId) { + if (!mapManager.getTowerUnusedBuffer().containsKey(towerLevel)) { return "使用错误,当前层不存在buff"; } int mapPointId = mapManager.getTowerUnusedBuffer().get(towerLevel); SEventPointConfig sEventPointConfig = STableManager.getConfig(SEventPointConfig.class).get(mapPointId); int[] options = sEventPointConfig.getOption(); - for(int optionTmp : options){ - if(optionTmp == optionId){ + for (int optionTmp : options) { + if (optionTmp == optionId) { return ""; } } @@ -2571,31 +2578,31 @@ public class MapLogic { int star = crossInfo.getStars().size(); totalStar += star; } - if (totalStar < sChallengeStarBox.getStarNum()){ - LOGGER.info("totalStar less sChallengeStarBox.getStarNum totalStar is {} uid=>{}, id=>{}", totalStar,session.getUid(), id); + if (totalStar < sChallengeStarBox.getStarNum()) { + LOGGER.info("totalStar less sChallengeStarBox.getStarNum totalStar is {} uid=>{}, id=>{}", totalStar, session.getUid(), id); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } boolean allowed = user.getPlayerInfoManager().checkFunctionIsAllowed(VipPrivilegeType.UNLOCK_STAR_EXTRA_REWARD); - int[][] dropReward = sChallengeStarBox.getReward(); - if(allowed){ + int[][] dropReward = sChallengeStarBox.getReward(); + if (allowed) { int[][] extraReward = sChallengeStarBox.getExtraReward(); - int length= sChallengeStarBox.getReward().length + extraReward.length; + int length = sChallengeStarBox.getReward().length + extraReward.length; dropReward = new int[length][]; - int i=0; - for(;i towerReceivedReward = user.getMapManager().getTrialInfo().getTowerReceivedReward(); - if(towerReceivedReward.contains(id)){ + if (towerReceivedReward.contains(id)) { throw new ErrorCodeException(ErrorCode.newDefineCode("当前任务已领取过")); } - if(user.getMapManager().getTrialInfo().getKillCount() heroInfo = trialInfo.getHeroInfo(); - if(mapManager.getCurMapId()==0){ + if (mapManager.getCurMapId() == 0) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(heroInfo.size()<1||!heroInfo.containsKey(heroId)){ + if (heroInfo.size() < 1 || !heroInfo.containsKey(heroId)) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } int[] healing = STrialSetting.sTrialSetting.getHealingId(); - if(trialInfo.getAddHpCount()>=healing[1]){ + if (trialInfo.getAddHpCount() >= healing[1]) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } Map propertyMap = heroInfo.get(heroId).getProperty(); long curHp = propertyMap.get(HeroAttributeEnum.CurHP.getPropertyId()); - if(curHp==0){ + if (curHp == 0) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); - }else{ - boolean itemCost = ItemUtil.itemCost(user, new int[][]{{healing[0],1}}, BIReason.TRIAL_ADD_HP_CONSUME, 1); - if(!itemCost){ + } else { + boolean itemCost = ItemUtil.itemCost(user, new int[][]{{healing[0], 1}}, BIReason.TRIAL_ADD_HP_CONSUME, 1); + if (!itemCost) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } //todo 加血逻辑 long maxHp = propertyMap.get(HeroAttributeEnum.Hp.getPropertyId()); - long resultHp = Math.min(curHp+maxHp/2,maxHp); - propertyMap.put(HeroAttributeEnum.CurHP.getPropertyId(),resultHp); + long resultHp = Math.min(curHp + maxHp / 2, maxHp); + propertyMap.put(HeroAttributeEnum.CurHP.getPropertyId(), resultHp); trialInfo.getHeroInfo().get(heroId).setProperty(propertyMap); mapManager.updateTrialAddHpCount(1); mapManager.updateTrailHeroInfo(heroInfo); } - }else{ + } else { boolean itemCost = ItemUtil.itemCost(user, new int[][]{{1227, 1}}, BIReason.TRIAL_ADD_HP_CONSUME, 1); - if(!itemCost){ + if (!itemCost) { throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } EndlessMapInfo endlessMapInfo = mapManager.getEndlessMapInfo(); Map endlessHeroInfo = endlessMapInfo.getEndlessHeroInfo(); Set hero = endlessHeroInfo.keySet(); - hero.forEach(n->mapManager.updateEndlessHeroHp(n,10000)); + hero.forEach(n -> mapManager.updateEndlessHeroHp(n, 10000)); } - MessageUtil.sendMessage(session,1,messageType.getNumber(),null); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); } /** * 获取无尽副本英雄信息 + * * @param session * @param messageType */ @@ -2709,7 +2721,7 @@ public class MapLogic { MapManager mapManager = user.getMapManager(); HeroManager heroManager = user.getHeroManager(); EndlessMapInfo endlessMapInfo = mapManager.getEndlessMapInfo(); - if(endlessMapInfo==null){ + if (endlessMapInfo == null) { mapManager.setEndlessMapInfo(new EndlessMapInfo()); endlessMapInfo = mapManager.getEndlessMapInfo(); } @@ -2717,23 +2729,23 @@ public class MapLogic { MapInfoProto.GetEndlessHeroResponse.Builder response = MapInfoProto.GetEndlessHeroResponse.newBuilder(); //已开启地图处理 Map sEndlessMapConfigMap = SEndlessMapConfig.sEndlessMapConfigMap; - if(endlessMapInfo.getOpenMap()==null||endlessMapInfo.getOpenMap().size()<1){ + if (endlessMapInfo.getOpenMap() == null || endlessMapInfo.getOpenMap().size() < 1) { Set openMap = new HashSet<>(); - for(Map.Entry entry :sEndlessMapConfigMap.entrySet()){ + for (Map.Entry entry : sEndlessMapConfigMap.entrySet()) { openMap.add(entry.getKey()); break; } mapManager.updateEndlessOpenedMap(openMap); } - for(Integer map:mapManager.getEndlessMapInfo().getOpenMap()){ + for (Integer map : mapManager.getEndlessMapInfo().getOpenMap()) { response.addOpenMapId(map); } - for(Map.Entry heroEntry : heroManager.getEndlessHeroInfo().entrySet()) { - if(heroEntry.getValue().getLevel(user.getHeroManager())<20){ + for (Map.Entry heroEntry : heroManager.getEndlessHeroInfo().entrySet()) { + if (heroEntry.getValue().getLevel(user.getHeroManager()) < 20) { continue; } - if(endlessHeroInfo.get(heroEntry.getKey())==null){ - mapManager.addEndlessHero(heroEntry.getKey(),10000); + if (endlessHeroInfo.get(heroEntry.getKey()) == null) { + mapManager.addEndlessHero(heroEntry.getKey(), 10000); } // LOGGER.info("英雄ID{},血量{}",heroEntry.getKey(),endlessHeroInfo.get(heroEntry.getKey())); CommonProto.endlessHero endlessHero = CommonProto.endlessHero.newBuilder().setHeroId(heroEntry.getKey()).setHp(endlessHeroInfo.get(heroEntry.getKey())).build(); @@ -2767,11 +2779,12 @@ public class MapLogic { // } // } - MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true); } /** * 无尽副本复位 + * * @param session * @param messageType */ @@ -2781,11 +2794,11 @@ public class MapLogic { EndlessMapInfo endlessMapInfo = mapManager.getEndlessMapInfo(); // SChallengeMapConfig sChallengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(endlessMapInfo.getCurMapId()); // mapManager.updateEndlessLocation(CellUtil.xy2Pos(sChallengeMapConfig.getPosition()[0],sChallengeMapConfig.getPosition()[1])); - for(Map.Entry entry:endlessMapInfo.getEndlessHeroInfo().entrySet()){ - mapManager.updateEndlessHeroHp(entry.getKey(),10000); + for (Map.Entry entry : endlessMapInfo.getEndlessHeroInfo().entrySet()) { + mapManager.updateEndlessHeroHp(entry.getKey(), 10000); } - for (Map.Entry> entry:mapManager.getHeroAllAttributeMap().entrySet()){ - mapManager.updateHeroOneAttribute(entry.getKey(),HeroAttributeEnum.CurHP.getPropertyId(),entry.getValue().get(HeroAttributeEnum.Hp.getPropertyId()).intValue()); + for (Map.Entry> entry : mapManager.getHeroAllAttributeMap().entrySet()) { + mapManager.updateHeroOneAttribute(entry.getKey(), HeroAttributeEnum.CurHP.getPropertyId(), entry.getValue().get(HeroAttributeEnum.Hp.getPropertyId()).intValue()); } // int[][] tempExe = new int[1][]; // int [] temp = new int[2]; @@ -2794,21 +2807,22 @@ public class MapLogic { // tempExe[0] = temp; // ItemUtil.drop(user,tempExe,1); - MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true); } /** - * 无尽副本设置标记 + * 无尽副本设置标记 + * * @param session * @param cellId * @param content * @param messageType */ - public void setEndlessSign(ISession session,int type,int mapId,int cellId, String content, MessageTypeProto.MessageType messageType) throws Exception { + public void setEndlessSign(ISession session, int type, int mapId, int cellId, String content, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); if (type == 1) { - boolean result = ShieldedWordUtils.checkName(user,content, false, ChatContentType.OTHER); + boolean result = ShieldedWordUtils.checkName(user, content, false, ChatContentType.OTHER); String error; if (!result) { error = "输入有敏感字符"; @@ -2829,77 +2843,82 @@ public class MapLogic { if (endlessMapInfo.getMapSign().get(mapId).get(cellId) == null) { throw new ErrorCodeException(ErrorCode.newDefineCode("该点无标记")); } - mapManager.removeEndlessSign(mapId,cellId); + mapManager.removeEndlessSign(mapId, cellId); MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true); } } /** * 刷新获取行动力 + * * @param session * @param messageType * @throws Exception */ public void refreshEndlessExecution(ISession session, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); - MapInfoProto.ExecutionRefreshResponse response = MapInfoProto.ExecutionRefreshResponse.newBuilder().setExeValue((int)user.getItemManager().getItem(1).getItemNum()).build(); - MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true); + MapInfoProto.ExecutionRefreshResponse response = MapInfoProto.ExecutionRefreshResponse.newBuilder().setExeValue((int) user.getItemManager().getItem(1).getItemNum()).build(); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true); } /** * 获取出图统计数据 + * * @param session * @param messageType */ - public void endlessOutMapConsume(ISession session , MessageTypeProto.MessageType messageType) throws Exception { + public void endlessOutMapConsume(ISession session, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); MapInfoProto.EndlessOutConsumeResponse.Builder response = MapInfoProto.EndlessOutConsumeResponse.newBuilder(); response.setFightCount(mapManager.getEndlessMapInfo().getFightCount()); response.setConsumeExecution(mapManager.getEndlessMapInfo().getConsumeExecution()); - LOGGER.info("战斗次数{}",response.getFightCount()); - LOGGER.info("消耗行动力{}",response.getConsumeExecution()); - MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); + LOGGER.info("战斗次数{}", response.getFightCount()); + LOGGER.info("消耗行动力{}", response.getConsumeExecution()); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true); } /** * 无尽副本复活消耗行动力 + * * @param user * @throws Exception */ public void reviveConsumeExecution(User user) throws Exception { MapManager mapManager = user.getMapManager(); - if(SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()!=4){ + if (SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType() != 4) { return; } - mapManager.updateEndlessFightCount(mapManager.getEndlessMapInfo().getFightCount()+1); + mapManager.updateEndlessFightCount(mapManager.getEndlessMapInfo().getFightCount() + 1); //消耗行动力 - int [][] cost = new int[1][]; + int[][] cost = new int[1][]; int costId = SChallengeSetting.getChallengeSetting().getActionPowerId(); int costNum = SEndlessMapConfig.sEndlessMapConfigMap.get(mapManager.getCurMapId()).getDeathCost(); - mapManager.updateEndlessConsumeExecution(mapManager.getEndlessMapInfo().getConsumeExecution()+costNum); - int [] cost1 = new int[]{costId,costNum}; + mapManager.updateEndlessConsumeExecution(mapManager.getEndlessMapInfo().getConsumeExecution() + costNum); + int[] cost1 = new int[]{costId, costNum}; cost[0] = cost1; boolean costResult = ItemUtil.itemCost(user, cost, BIReason.ENDLESS_CONSUME_EXECUTION, 1); - if(!costResult) { - costNum = (int)user.getItemManager().getItem(costId).getItemNum(); - cost1[1]= costNum; + if (!costResult) { + costNum = (int) user.getItemManager().getItem(costId).getItemNum(); + cost1[1] = costNum; cost[0] = cost1; - ItemUtil.itemCost(user,cost,BIReason.ENDLESS_CONSUME_EXECUTION,1); + ItemUtil.itemCost(user, cost, BIReason.ENDLESS_CONSUME_EXECUTION, 1); } } /** * 清理无尽副本道具 + * * @param uid * @throws Exception */ public void clearEndLessDrop(int uid) throws Exception { - ItemLogic.getInstance().functionEndClearItem(uid,FunctionIdEnum.Endless.getFunctionType(),BIReason.ENDLESS_REASON_CHANGE); + ItemLogic.getInstance().functionEndClearItem(uid, FunctionIdEnum.Endless.getFunctionType(), BIReason.ENDLESS_REASON_CHANGE); } /** * 无尽副本小地图信息 + * * @param session * @param messageType */ @@ -2908,31 +2927,31 @@ public class MapLogic { int[][] endlessMinMapPoint = SEndlessMapConfig.sEndlessMapConfigMap.get(mapManager.getEndlessMapInfo().getCurMapId()).getEndlessPoint(); MapInfoProto.EndlessMinMapResponse.Builder response = MapInfoProto.EndlessMinMapResponse.newBuilder(); Map scMap = SCMap.sCMap.get(mapManager.getEndlessMapInfo().getCurMapId()); - for(Map.Entry entry:scMap.entrySet()){ - for(int i = 0 ; i entry : scMap.entrySet()) { + for (int i = 0; i < endlessMinMapPoint.length; i++) { + if (entry.getValue().getEvent() == endlessMinMapPoint[i][0]) { int[][] groups = entry.getValue().getGroups(); - for(int j = 0 ; j ()); trialInfo.setCurXY(0); @@ -2954,19 +2973,19 @@ public class MapLogic { trialInfo.setTimes(openTimeOfFuntionCacheByType.getTimes()); List initBuff = new ArrayList<>(); //先出奖励层 - trialInfo.setFloor(trialInfo.getFloor()%10000); - if(trialInfo.getHighestTower()!=0&&trialInfo.getFloor()<=trialInfo.getHighestTower()){ + trialInfo.setFloor(trialInfo.getFloor() % 10000); + if (trialInfo.getHighestTower() != 0 && trialInfo.getFloor() <= trialInfo.getHighestTower()) { initBuff.add(STrialSetting.sTrialSetting.getBaseBuff()); } trialInfo.setBuffIds(initBuff); - trialInfo.setFloor(trialInfo.getHighestTower()-7>1?trialInfo.getHighestTower()-7:1); + trialInfo.setFloor(trialInfo.getHighestTower() - 7 > 1 ? trialInfo.getHighestTower() - 7 : 1); trialInfo.setKillCount(0); trialInfo.setBombUseTimes(0); trialInfo.setTowerReceivedReward(new HashSet<>()); trialInfo.setMonsterHp(new HashMap<>()); - if(mapManager.getCurMapId()!=0){ - if(MapLogic.getInstance().getMap(user) instanceof TowerMap){ - resetMapInfo(user,false); + if (mapManager.getCurMapId() != 0) { + if (MapLogic.getInstance().getMap(user) instanceof TowerMap) { + resetMapInfo(user, false); } } storeManager.removeStoreInfo(8); @@ -2974,26 +2993,30 @@ public class MapLogic { } } + /** * 无尽副本赛季更换,用户信息清除 + * * @throws Exception */ public void resetEndlessInfo() throws Exception { Map onlineUserMap = OnlineUserManager.sessionMap; - for(Map.Entry entry:onlineUserMap.entrySet()){ + for (Map.Entry entry : onlineUserMap.entrySet()) { endLessClear(entry.getValue()); // 清理无尽副本道具 clearEndLessDrop(entry.getValue().getUid()); } } + /** * 无尽副本赛季更换,用户信息清除 + * * @throws Exception */ public void resetTrialInfo() throws Exception { Map onlineUserMap = OnlineUserManager.sessionMap; - for(Map.Entry entry:onlineUserMap.entrySet()){ + for (Map.Entry entry : onlineUserMap.entrySet()) { trialClear(entry.getValue()); } } @@ -3002,17 +3025,18 @@ public class MapLogic { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); mapManager.setEndlessMapInfo(new EndlessMapInfo()); - if(mapManager.getCurMapId()!=0&&SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()==4){ - MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.MAP_OUT_INDICATION_VALUE,null,true); + if (mapManager.getCurMapId() != 0 && SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType() == 4) { + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MAP_OUT_INDICATION_VALUE, null, true); // resetMapInfo(user,false); } } + public void trialClear(ISession session) throws Exception { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); - if(mapManager.getCurMapId()!=0){ - if(getMap(user) instanceof TowerMap) - MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.MAP_OUT_INDICATION_VALUE,null,true); + if (mapManager.getCurMapId() != 0) { + if (getMap(user) instanceof TowerMap) + MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.MAP_OUT_INDICATION_VALUE, null, true); } } @@ -3066,13 +3090,14 @@ public class MapLogic { /** * 设置无尽副本是否跳过战斗 + * * @param session * @param type * @param messageType */ public void setEndlessSkipType(ISession session, int type, MessageTypeProto.MessageType messageType) throws Exception { UserManager.getUser(session.getUid()).getMapManager().updateEndlessSkipFight(type); - MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true); } public void getDifficult() throws Exception { @@ -3105,12 +3130,12 @@ public class MapLogic { public void dailyChallenge(ISession session, int type, int id, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); - PlayerInfoProto.DailyChallengeResponse.Builder builder= PlayerInfoProto.DailyChallengeResponse.newBuilder(); + PlayerInfoProto.DailyChallengeResponse.Builder builder = PlayerInfoProto.DailyChallengeResponse.newBuilder(); PlayerManager playerInfoManager = user.getPlayerInfoManager(); //次数校验 SDailyChallengeConfig sDailyChallengeConfig = STableManager.getConfig(SDailyChallengeConfig.class).get(id); SDailyChallengeConfig lastChange = STableManager.getConfig(SDailyChallengeConfig.class).get(id - 1); - if(sDailyChallengeConfig==null){ + if (sDailyChallengeConfig == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } // boolean check = PlayerLogic.getInstance().check(user, sDailyChallengeConfig.getPrivilegeId()[1], 1); @@ -3120,48 +3145,47 @@ public class MapLogic { boolean consumeCount = false; boolean isFailed = false; Set dailyPass = playerInfoManager.getDailyPass(); - if(type==2){ - if(!dailyPass.contains(id)){ + 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)){ + } 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)){ + 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]){ + for (int[] rule : openRules) { + switch (rule[0]) { case 1: - open = playerInfoManager.getLevel()>=rule[1]; + open = playerInfoManager.getLevel() >= rule[1]; break; case 2: - open = SMainLevelConfig.biggerThanFight(user.getMainLevelManager().getFightId(),rule[1]); + open = SMainLevelConfig.biggerThanFight(user.getMainLevelManager().getFightId(), rule[1]); break; case 3: - open = playerInfoManager.getMaxForce()>=rule[1]; + open = playerInfoManager.getMaxForce() >= rule[1]; break; - default:{ + default: { LOGGER.info("dailyChallenge wrong type=>{} uid=>{}", rule[0], session.getUid()); break; } } - if(!open){ + if (!open) { throw new ErrorCodeException(ErrorCode.DAILY_NO_OPEN); } } - PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.FORMATION_NORMAL.getTeamId(), 1000, "", GameFightType.DailyChallenge, sDailyChallengeConfig.getMonsterId(), 3); FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent); CommonProto.FightData fightData = CommonProto.FightData.newBuilder() @@ -3170,26 +3194,26 @@ public class MapLogic { .setHeroFightInfos(fightResult.getFightTeamInfo()) .addAllMonsterList(fightResult.getMonsterTeamList()) .setFightType(GameFightType.DailyChallenge.getFightType().getType()) - .setFightId(FightUtil.getFightId(user.getId(),GameFightType.DailyChallenge)) + .setFightId(FightUtil.getFightId(user.getId(), GameFightType.DailyChallenge)) .build(); builder.setFightData(fightData); // 记录战报 - FightRecordLogic.getInstance().addRecordMap(user,fightData); + FightRecordLogic.getInstance().addRecordMap(user, fightData); - if(fightResult.getResult()>0){ + if (fightResult.getResult() > 0) { CommonProto.Drop.Builder drop = ItemUtil.drop(user, sDailyChallengeConfig.getReward(), 1, 0, 1); builder.setDrop(drop); playerInfoManager.addDailyPass(id); - }else{ + } else { isFailed = true; } - }else{ + } else { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - if(consumeCount){ + if (consumeCount) { boolean consume = PlayerLogic.getInstance().checkAndUpdate(user, sDailyChallengeConfig.getPrivilegeId()[1], 1); - if(!consume){ + if (!consume) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } @@ -3197,63 +3221,64 @@ public class MapLogic { List itemDrop = drop.getItemlistList(); List itemIdList = new ArrayList<>(); List itemNumList = new ArrayList<>(); - itemDrop.forEach(item->{ + itemDrop.forEach(item -> { itemIdList.add(item.getItemId()); - itemNumList.add((int)item.getItemNum()); + itemNumList.add((int) item.getItemNum()); }); - ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_DAILY_DUNGEON.getType(),id,sDailyChallengeConfig.getType(),sDailyChallengeConfig.getMonsterId(),MonsterUtil.getMonsterForce(new int[]{sDailyChallengeConfig.getMonsterId()}),new Date(),"",0,itemIdList,itemNumList,type==1?"挑战":"扫荡",isFailed?"失败":"通过"); - user.getUserMissionManager().onGameEvent(user,GameEvent.DAILY_CHALLENGE,sDailyChallengeConfig.getType()); - user.getUserMissionManager().onGameEvent(user,GameEvent.DAILY_CHALLENGE_COUNT,1); - MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build()); + ReportUtil.onReportEvent(user, ReportEventEnum.COMPLETE_DAILY_DUNGEON.getType(), id, sDailyChallengeConfig.getType(), sDailyChallengeConfig.getMonsterId(), MonsterUtil.getMonsterForce(new int[]{sDailyChallengeConfig.getMonsterId()}), new Date(), "", 0, itemIdList, itemNumList, type == 1 ? "挑战" : "扫荡", isFailed ? "失败" : "通过"); + user.getUserMissionManager().onGameEvent(user, GameEvent.DAILY_CHALLENGE, sDailyChallengeConfig.getType()); + user.getUserMissionManager().onGameEvent(user, GameEvent.DAILY_CHALLENGE_COUNT, 1); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), builder.build()); } /** * 试炼副本保存阵容 + * * @param session * @param heroes * @param messageType * @throws Exception */ - public void saveTrailTeam(ISession session, List heroes , MessageTypeProto.MessageType messageType) throws Exception { + public void saveTrailTeam(ISession session, List heroes, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); TrialInfo trialInfo = mapManager.getTrialInfo(); Map heroInfo = trialInfo.getHeroInfo(); //校验保存条件 - if(!heroInfo.isEmpty()||heroes.isEmpty()||heroes.size()>5){ + if (!heroInfo.isEmpty() || heroes.isEmpty() || heroes.size() > 5) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } HeroManager heroManager = user.getHeroManager(); - for(MapInfoProto.TrialSaveHero saveHero:heroes){ + for (MapInfoProto.TrialSaveHero saveHero : heroes) { Hero hero = heroManager.getHero(saveHero.getHeroId()); - if(hero==null){ + if (hero == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } } - for(MapInfoProto.TrialSaveHero saveHero:heroes){ + for (MapInfoProto.TrialSaveHero saveHero : heroes) { Hero hero = heroManager.getHero(saveHero.getHeroId()); - String heroSkill = HeroLogic.getInstance().getHeroSkills(user,hero,new StringBuilder()).toString(); + String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero, new StringBuilder()).toString(); int skinTime = heroManager.getSkinInfo().getOrDefault(hero.getSkin(), 0); int skinId = hero.getSkin(); - if(skinTime!=-1&&skinTime entry:heroInfo.entrySet()){ + for (Map.Entry entry : heroInfo.entrySet()) { TrailHero trailHero = entry.getValue(); long remainHp = trailHero.getProperty().get(HeroAttributeEnum.CurHP.getPropertyId()); long maxHp = trailHero.getProperty().get(HeroAttributeEnum.Hp.getPropertyId()); //判断血量万分比,如果小于0.01%返回0.01% - int calHp = remainHp>0? (int) (remainHp * 10000D / maxHp > 0 ? remainHp * 10000D / maxHp : 1) :0; + int calHp = remainHp > 0 ? (int) (remainHp * 10000D / maxHp > 0 ? remainHp * 10000D / maxHp : 1) : 0; MapInfoProto.TrialHeroInfo info = MapInfoProto.TrialHeroInfo.newBuilder().setHeroId(entry.getKey()) .setTmpId(trailHero.getTmpId()) .setHeroHp(calHp) @@ -3267,37 +3292,39 @@ public class MapLogic { } mapManager.updateTrailHeroInfo(heroInfo); - MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true); } /** * 获取宝箱 + * * @param session * @param messageType * @throws Exception */ - public void trialGetBox(ISession session,int type,MessageTypeProto.MessageType messageType) throws Exception { + public void trialGetBox(ISession session, int type, MessageTypeProto.MessageType messageType) throws Exception { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); AbstractMap map = getMap(user); //是否在试炼副本中 - MapInfoProto.GetTrialBoxRewardResponse.Builder response = null; + MapInfoProto.GetTrialBoxRewardResponse.Builder response = null; - if(map instanceof TowerMap){ + if (map instanceof TowerMap) { int curXY = mapManager.getCurXY(); int floor = mapManager.getTrialInfo().getFloor(); - TreeMap sTrialConfigMap = (TreeMap)STrialConfig.sTrialConfigMap; + TreeMap sTrialConfigMap = (TreeMap) STrialConfig.sTrialConfigMap; STrialConfig sTrialConfig = sTrialConfigMap.ceilingEntry(floor).getValue(); - response = getBoxReward(sTrialConfig.getBoxPosition(),sTrialConfig.getBoxReward(),user,curXY,type); + response = getBoxReward(sTrialConfig.getBoxPosition(), sTrialConfig.getBoxReward(), user, curXY, type); } - if(response==null){ + if (response == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true); } /** * 内部调用,根据不同层数进行获取宝箱 + * * @param boxPosition * @param boxReward * @param user @@ -3305,19 +3332,19 @@ public class MapLogic { * @return * @throws Exception */ - private MapInfoProto.GetTrialBoxRewardResponse.Builder getBoxReward(int[][] boxPosition,int[][][] boxReward,User user,int curXY,int type) throws Exception { + private MapInfoProto.GetTrialBoxRewardResponse.Builder getBoxReward(int[][] boxPosition, int[][][] boxReward, User user, int curXY, int type) throws Exception { MapManager mapManager = user.getMapManager(); - MapInfoProto.GetTrialBoxRewardResponse.Builder response= MapInfoProto.GetTrialBoxRewardResponse.newBuilder(); - CommonProto.Drop.Builder drop= null; + MapInfoProto.GetTrialBoxRewardResponse.Builder response = MapInfoProto.GetTrialBoxRewardResponse.newBuilder(); + CommonProto.Drop.Builder drop = null; Map mapInfo = mapManager.getMapInfo(); - if(type==1){ + if (type == 1) { List reward = Arrays.asList(boxReward); - drop = ItemUtil.drop(user,reward,BIReason.MAP_EVENET_REWARD); - for(int[] position:boxPosition){ + drop = ItemUtil.drop(user, reward, BIReason.MAP_EVENET_REWARD); + for (int[] position : boxPosition) { int xyPos = CellUtil.xy2Pos(position[0], position[1]); Cell cell = mapInfo.get(xyPos); - if(cell!=null&&cell.getPointId()==STrialSetting.sTrialSetting.getBoxPointId()) { + if (cell != null && cell.getPointId() == STrialSetting.sTrialSetting.getBoxPointId()) { cell.setPointId(0); mapManager.addOrUpdateCell(cell.getCellId(), cell); } @@ -3325,15 +3352,15 @@ public class MapLogic { List deleteCell = new ArrayList<>(); //判断添加buff - for(Cell cell:mapInfo.values()){ - if(MapPointConfig.getScMapEventMap().get(cell.getPointId()).getStyle()!=9){//9为地图点buff类型 + for (Cell cell : mapInfo.values()) { + if (MapPointConfig.getScMapEventMap().get(cell.getPointId()).getStyle() != 9) {//9为地图点buff类型 continue; } int optionId = STableManager.getConfig(SEventPointConfig.class).get(cell.getEventId()).getOption()[0]; SOptionConfig sOptionConfig = SOptionConfig.sOptionConfigMap.get(optionId); List buffIds = mapManager.getTrialInfo().getBuffIds(); - for(int[] values:sOptionConfig.getBehaviorTypeValues()){ - for(int value:values){ + for (int[] values : sOptionConfig.getBehaviorTypeValues()) { + for (int value : values) { buffIds.add(value); } } @@ -3341,21 +3368,21 @@ public class MapLogic { mapManager.updateTrialBuffIds(buffIds); response.addBuffIds(sOptionConfig.getBehaviorTypeValues()[0][0]); } - for(Cell cell:deleteCell){ - BehaviorUtil.destoryApointXY(user,cell.getCellId()); + for (Cell cell : deleteCell) { + BehaviorUtil.destoryApointXY(user, cell.getCellId()); } - }else{ - for(int i = 0 ; i idList = new ArrayList<>(ids.length); - for(int id:ids){ + for (int id : ids) { idList.add(id); } BehaviorUtil.destoryCurPoint(user); @@ -3389,11 +3416,12 @@ public class MapLogic { user.getUserMissionManager().onGameEvent(user, GameEvent.PLAY_MINI_GAME, 0); MapInfoProto.MapGameResponse response = MapInfoProto.MapGameResponse.newBuilder().setType(mapGameInfo.getType()).addAllParam(idList).build(); - MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true); } /** * 小游戏更新操作 + * * @param session * @param index * @param messageType @@ -3403,36 +3431,36 @@ public class MapLogic { User user = UserManager.getUser(session.getUid()); MapManager mapManager = user.getMapManager(); MapGameInfo mapGameInfo = mapManager.getTrialInfo().getMapGameInfo(); - if(mapGameInfo==null||mapGameInfo.getType()==0){ + if (mapGameInfo == null || mapGameInfo.getType() == 0) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } MapGame mapGame = baseGameMap.get(mapGameInfo.getType()); - if(mapGame==null){ + if (mapGame == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } MapInfoProto.MapGameUpdateResponse response = mapGame.updateGame(user, index); - if(response==null){ + if (response == null) { throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } - MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response, true); } - public int getDifficultMonster(int groupId,int level,int mapId){ + public int getDifficultMonster(int groupId, int level, int mapId) { Map> mapDifficult = SEndlessDifficulty.mapDifficult; Map levelMap = mapDifficult.get(mapId); - if(levelMap==null||!levelMap.containsKey(level)){ + if (levelMap == null || !levelMap.containsKey(level)) { return groupId; } int difficultId = levelMap.get(level); int baseId = levelMap.get(0); - if(difficultId==baseId){ + if (difficultId == baseId) { return groupId; } Map map = SEndlessDifficulty.mapMonsterDifficult.get(mapId); - if(!map.containsKey(groupId)){ + if (!map.containsKey(groupId)) { return groupId; } //拿到groupId的位置 @@ -3445,16 +3473,17 @@ public class MapLogic { groupId = levelDifficult.getMonsterId()[position]; return groupId; } - public int getDifficultReward(int rewardId,int level,int mapId){ + + public int getDifficultReward(int rewardId, int level, int mapId) { Map> mapDifficult = SEndlessDifficulty.mapDifficult; Map levelMap = mapDifficult.get(mapId); int difficultId = levelMap.get(level); int baseId = levelMap.get(0); - if(difficultId==baseId){ + if (difficultId == baseId) { return rewardId; } Map map = SEndlessDifficulty.mapRewardDifficult.get(mapId); - if(!map.containsKey(rewardId)){ + if (!map.containsKey(rewardId)) { return rewardId; } //拿到rewardId的位置 @@ -3468,6 +3497,7 @@ public class MapLogic { return rewardId; } + public void getAllEndlessTreasureInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); @@ -3479,16 +3509,17 @@ public class MapLogic { // response.setResetTime(-1); // } - MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), response.build(), true); } - public MapInfoProto.EndlessTreasureInfoResponse.Builder getEndlessResponseBuilder(EndlessTreasureReward worldTreasureReward){ - MapInfoProto.EndlessTreasureInfoResponse.Builder response = MapInfoProto.EndlessTreasureInfoResponse.newBuilder(); + + public MapInfoProto.EndlessTreasureInfoResponse.Builder getEndlessResponseBuilder(EndlessTreasureReward worldTreasureReward) { + MapInfoProto.EndlessTreasureInfoResponse.Builder response = MapInfoProto.EndlessTreasureInfoResponse.newBuilder(); // if(worldTreasureReward.getFirstStartTime()!=0&&worldTreasureReward.getFirstStartTime()<=TimeUtils.nowInt()&&worldTreasureReward.getCreateTime()>TimeUtils.now()/1000){ Map rewardStatusMap = worldTreasureReward.getRewardStatusMap(); Map worldBossTreasureStaticConfig = STableManager.getConfig(SEndlessTreasure.class); List states = new ArrayList<>(100); - worldBossTreasureStaticConfig.forEach((k,v)->{ - MapInfoProto.EndlessTreasureRewardState.Builder builder = MapInfoProto.EndlessTreasureRewardState.newBuilder().setId(k).setState(rewardStatusMap.getOrDefault(k,0)); + worldBossTreasureStaticConfig.forEach((k, v) -> { + MapInfoProto.EndlessTreasureRewardState.Builder builder = MapInfoProto.EndlessTreasureRewardState.newBuilder().setId(k).setState(rewardStatusMap.getOrDefault(k, 0)); states.add(builder.build()); }); response.addAllTreasureRewardState(states); @@ -3499,21 +3530,21 @@ public class MapLogic { } public void flushEndlessTreasure(User user) throws Exception { - if(user.getMapManager().getEndlessTreasureReward().getCreateTime() 0){ + if (item != null && item.getItemNum() > 0) { item.setItemNum(0); } // 无尽秘宝礼包刷新 ReceiveWelfareBag bagInfo = (ReceiveWelfareBag) user.getPlayerInfoManager().getNewRechargeInfo().getReceiveMap().get(107); - if (bagInfo == null){ + if (bagInfo == null) { return; } bagInfo.refresh(); - LOGGER.info("刷新无尽秘宝uid=>{}",user.getId()); + LOGGER.info("刷新无尽秘宝uid=>{}", user.getId()); MapInfoProto.EndlessTreasureInfoResponse.Builder response = getEndlessResponseBuilder(user.getMapManager().getEndlessTreasureReward()); - MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(user.getId()),1, MessageTypeProto.MessageType.ENDLESS_TREASURE_REFRESH_INDICATION_VALUE,response.build(),true); + MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(user.getId()), 1, MessageTypeProto.MessageType.ENDLESS_TREASURE_REFRESH_INDICATION_VALUE, response.build(), true); } }