From 5b1e55b61ed23ff98bace8ef005439b06e11fa89 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Thu, 20 Jun 2019 11:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E8=8B=B1=E6=80=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/core/FunctionIdEnum.java | 5 +++ .../ljsd/jieling/core/HandlerLogicThread.java | 29 ++++++++++-- .../jieling/handler/GetPlayerInfoHandler.java | 4 +- .../jieling/logic/GlobalDataManaager.java | 4 ++ .../ljsd/jieling/logic/hero/HeroLogic.java | 44 ++++++++++++++++--- .../jieling/logic/item/WorkShopLogic.java | 13 +++--- 6 files changed, 80 insertions(+), 19 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java index 486c33ddb..0288f3fff 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/FunctionIdEnum.java @@ -35,6 +35,11 @@ public enum FunctionIdEnum { DailyMission(20), + WorkShopTech(101), + WorkShopCreateEquip(102), + WorkShopCreateProtectEquip(103), + WorkShopRebuildEquip(104), + ; private int functionId; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/core/HandlerLogicThread.java b/serverlogic/src/main/java/com/ljsd/jieling/core/HandlerLogicThread.java index 768229117..6f383775d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/HandlerLogicThread.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/HandlerLogicThread.java @@ -4,6 +4,7 @@ import com.ljsd.GameApplication; import com.ljsd.jieling.config.SGlobalSystemConfig; import com.ljsd.jieling.globals.Global; import com.ljsd.jieling.handler.BaseHandler; +import com.ljsd.jieling.logic.GlobalDataManaager; import com.ljsd.jieling.logic.OnlineUserManager; import com.ljsd.jieling.logic.dao.LevelDifficulty; import com.ljsd.jieling.logic.dao.UserManager; @@ -162,14 +163,31 @@ public class HandlerLogicThread extends Thread{ return false; } break; - case MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_REQUEST_VALUE: // 锻造 - case MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_REQUEST_VALUE: - case MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_RESPONSE_VALUE: + case MessageTypeProto.MessageType.WORKSHOP_LEVELUP_RESPONSE_VALUE: // 升级 sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.WorkShop); if (checkOpen(user,sGlobalSystemConfig)) { return false; } break; + case MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_REQUEST_VALUE: // 基础锻造 + case MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_REQUEST_VALUE: //武器打造 防具打造 特殊处理 业务逻辑自己处理 + sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.WorkShop); + if (checkOpen(user,sGlobalSystemConfig)) { + return false; + } + break; + case MessageTypeProto.MessageType.WORKSHOP_TECHNOLOGY_LEVEL_REQUEST_VALUE: // 科技树 + sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.WorkShopTech); + if (checkOpen(user,sGlobalSystemConfig)) { + return false; + } + break; + case MessageTypeProto.MessageType.WORKSHOP_REBUILD_REQUEST_VALUE: //武器重铸 + sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.WorkShopRebuildEquip); + if (checkOpen(user,sGlobalSystemConfig)) { + return false; + } + break; case MessageTypeProto.MessageType.COOK_FOOD_REQUEST_VALUE: sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.Foods); if (checkOpen(user,sGlobalSystemConfig)) { @@ -196,7 +214,10 @@ public class HandlerLogicThread extends Thread{ return true; } - private boolean checkOpen(User user, SGlobalSystemConfig sGlobalSystemConfig) { + public static boolean checkOpen(User user, SGlobalSystemConfig sGlobalSystemConfig) { + if(!GlobalDataManaager.getInstance().checkIsOpen(sGlobalSystemConfig.getId())){ + return false; + } int level = user.getPlayerInfoManager().getLevel(); int workShopLevel = user.getWorkShopController().getWorkShopLevel(); Map levelDifficultyInfosMap = user.getLevelDifficultyManager().getLevelDifficultyInfosMap(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java index 41c866a86..bb35cd9f6 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java @@ -77,6 +77,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ RoomInfo roomInfo = user.getRoomInfo(); MapManager mapManager = user.getMapManager(); CommonProto.Player player = CBean2Proto.getPlayer(userId, user.getPlayerInfoManager(), user.getPlayerInfoManager().getMapId(), user.getMapManager().getCurMapId(),user.getMapManager(),roomInfo); + CommonProto.SuddenlyBossInfo suddenlyBossInfo = CommonProto.SuddenlyBossInfo.newBuilder().setSuddBossId(mapManager.getSuddenlyBoss()).setEndTime(mapManager.getSuddenlyBossEndTime()).setFindMapId(mapManager.getFindSuddenlyBossMapId()).build(); RechargeInfo rechargeInfo = playerInfoManager.getRechargeInfo(); PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse = PlayerInfoProto.GetPlayerInfoResponse.newBuilder() @@ -85,8 +86,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ .addAllPrivilege(privilegeList) .addAllGiftGoodsInfo(BuyGoodsLogic.getGoodsBagInfo(userId)) .addAllBuyGoodsId(rechargeInfo.getBuyGoodsTimes().keySet()) - .setSuddBossId(mapManager.getSuddenlyBoss()) - .setEndTime(mapManager.getSuddenlyBossEndTime()) + .setSuddenlyBossInfo(suddenlyBossInfo) .build(); try { MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true); 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 f0d77744c..e22cf30b9 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java @@ -51,6 +51,10 @@ public class GlobalDataManaager { private PlayerInfoProto.GetFunctionOfTimeResponse getFunctionOfTimeResponse = PlayerInfoProto.GetFunctionOfTimeResponse.newBuilder().build(); + public boolean checkIsOpen(int id) { + return openTimeOfFuntionCache.containsKey(id); + } + public void checkSystemFunctioIsOpen() throws Exception { long now = TimeUtils.now(); Map sGlobalSystemConfigMap = SGlobalSystemConfig.getsGlobalSystemConfigMap(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 4751e488b..26174ea6f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -185,9 +185,13 @@ public class HeroLogic { } int[][] dropHeroAndItem = new int[length][]; int randCount = 0; - Map totalCount = heroManager.getTotalCount(); - if (totalCount.containsKey(type)) { - randCount = totalCount.get(type); + Map totalCountMap = heroManager.getTotalCount(); + if (totalCountMap.containsKey(type)) { + randCount = totalCountMap.get(type); + } + int totalCount = 0; + for(Integer count : totalCountMap.values()){ + totalCount+=count; } int j=0; for(int i=0;i sLotteryRewardConfigListByPoolId = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(poolId); + public int[] randomHeroByPoolId(int poolId,int randomCount,int userLevel){ + List sLotteryRewardConfigListByPoolId = getMineSLotteryRewardConfig(poolId,randomCount,userLevel); int totalCountByPoolId = SLotteryRewardConfig.getTotalCountByPoolId(poolId); int randCount = MathUtils.randomInt(totalCountByPoolId) + 1; int weight =0; @@ -283,11 +288,36 @@ public class HeroLogic { if(weight>=randCount){ return sLotteryRewardConfig.getReward(); } - } return null; } + private List getMineSLotteryRewardConfig(int poolId,int randomCount,int userLevel){ + List sLotteryRewardConfigs = new ArrayList<>(); + List sLotteryRewardConfigListByPoolId = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(poolId); + for(SLotteryRewardConfig sLotteryRewardConfig : sLotteryRewardConfigListByPoolId ){ + int[] openRules = sLotteryRewardConfig.getOpenRules(); + boolean canAdd = true; + if(openRules!=null&&openRules.length>0){ + int openType = openRules[0]; + int openValue = openRules[1]; + switch (openType){ + case 1: + canAdd = randomCount>openValue; + break; + case 2: + canAdd = userLevel > openValue; + break; + } + } + if(canAdd){ + sLotteryRewardConfigs.add(sLotteryRewardConfig); + } + } + return sLotteryRewardConfigs; + + } + public void getAllTeamPosInfo(ISession session) throws Exception { User user = UserManager.getUser(session.getUid()); List teamPosInfoList = new ArrayList<>(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java index 91a715d8e..8eff57d57 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/WorkShopLogic.java @@ -1,7 +1,9 @@ package com.ljsd.jieling.logic.item; import com.ljsd.jieling.config.*; +import com.ljsd.jieling.core.FunctionIdEnum; import com.ljsd.jieling.core.GlobalsDef; +import com.ljsd.jieling.core.HandlerLogicThread; import com.ljsd.jieling.globals.BIReason; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; @@ -300,11 +302,6 @@ public class WorkShopLogic { finalMaterial.put(materialId,nums*sWorkShopFoundationConfig.getNum()); ItemUtil.addItem(user,finalMaterial,null, BIReason.WORKSHOP_CREATEMATERIAL); - //熟练度提升 - int type = sWorkShopFoundationConfig.getType(); - int addExp = sWorkShopFoundationConfig.getExp()*nums; - - MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,null,true); } @@ -312,6 +309,11 @@ public class WorkShopLogic { public void createEquipByUser(ISession session,int equipTid, List runneIdsList,int nums) throws Exception { int uid=session.getUid(); User user = UserManager.getUser(uid); + SGlobalSystemConfig sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.Adventure); + if (HandlerLogicThread.checkOpen(user,sGlobalSystemConfig)) { + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"未开"); + return; + } SWorkShopEquipmentConfig sWorkShopEquipmentConfig = SWorkShopEquipmentConfig.getsWorkShopEquipmentConfigMap().get(equipTid); if(sWorkShopEquipmentConfig == null){ MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_RESPONSE_VALUE,"equipTid not exists"); @@ -355,7 +357,6 @@ public class WorkShopLogic { CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder(); //熟练度提升 int type = sWorkShopEquipmentConfig.getType(); - int addExp = sWorkShopEquipmentConfig.getExp()*nums; int workShopLevel = user.getWorkShopController().getWorkShopLevel(); if(type == GlobalsDef.WORK_SHOP_TYPE){ while (nums-->0){