From f8a2ad6a32ccec22730fc664c6adc9852eeba231 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Fri, 19 Jun 2020 13:33:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/map/miniGame/CircleGame.java | 2 +- .../ljsd/jieling/logic/dao/HeroManager.java | 15 +- .../ljsd/jieling/logic/hero/HeroLogic.java | 222 +++++++----------- .../src/main/java/config/SLotterySetting.java | 33 --- 4 files changed, 96 insertions(+), 176 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java index edccc9648..e9145b5af 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java @@ -62,7 +62,7 @@ public class CircleGame implements MapGame { int[] id = MathUtils.randomFromWeightWithTaking(randomArray, 1); //todo 需要告诉前端一个拿到的id STrialGameConfig config = STrialGameConfig.trialGameConfigMap.get(id[0]); - CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[][]{{id[0], config.getMin()}}, BIReason.MAP_EVENET_REWARD); + CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[][]{{config.getRewardID(), config.getMin()}}, BIReason.MAP_EVENET_REWARD); MapInfoProto.MapGameUpdateResponse response = MapInfoProto.MapGameUpdateResponse.newBuilder() diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java index 5ebd80808..f13309f3e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java @@ -11,25 +11,20 @@ import java.util.Map; public class HeroManager extends MongoBase { - private Map heroMap; + private Map heroMap= new HashMap<>(); - Map totalCount; + private Map totalCount= new HashMap<>(); - private Map> randomPoolByType; + private Map> randomPoolByType = new HashMap<>(); - private Map mustRandomCount; + private Map mustRandomCount= new HashMap<>(); - Map heroHandBook; + private Map heroHandBook = new HashMap<>(); private int firstTenth; public HeroManager() { - heroMap = new HashMap(); - totalCount = new HashMap(); - heroHandBook = new HashMap<>(); - randomPoolByType = new HashMap<>(); - mustRandomCount = new HashMap<>(); this.setRootCollection(User._COLLECTION_NAME); } 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 3f8f98218..65991de29 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 @@ -184,6 +184,7 @@ public class HeroLogic{ public void random(ISession session,int type) throws Exception { + long time = System.currentTimeMillis(); int uid = session.getUid(); User user = UserManager.getUser(uid); SLotterySetting sLotterySetting = STableManager.getConfig(SLotterySetting.class).get(type); @@ -207,24 +208,12 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN); } } - //筛选卡池 - int pooId =0; - if(heroManager!=null&& heroManager.getHeroMap()!=null){ if(heroManager.getHeroMap().size() + perCount > STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getHeroNumlimit()){ throw new ErrorCodeException(ErrorCode.HERO_MAX); } } - - if(sLotterySetting.getOrderBoxPool()!=null && sLotterySetting.getOrderBoxPool().length>0){ - pooId = getOrderBoxPoolId(sLotterySetting); - if(pooId == 0){ - throw new ErrorCodeException(ErrorCode.newDefineCode("pooId 0")); - } - - } - //检验消耗 boolean allowFree = false; int privilege = sLotterySetting.getFreeTimes(); @@ -244,140 +233,109 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } } -// else{ -// user.getPlayerInfoManager().updateVipPrivilage(privilege, 1); -// } - int[][] tenTimesMustGetItem = new int[perCount][]; + + //抽卡必得积分 + int[][] tenTimesMustGetItem = sLotterySetting.getTenTimesMustGetItem(); + //所有获得物品 + int[][] resultRandom = new int[perCount+tenTimesMustGetItem.length][]; + //进行抽取 + int index = 0; for(int i = 0 ;i0){ -// tenTimesMustGetItem = sLotterySetting.getTenTimesMustGetItem(); -// length+=tenTimesMustGetItem.length; -// } -// int[][] dropHeroAndItem = new int[length][]; -// int randCount = 0; -// int poolCount = 0; -// Map totalCountMap = heroManager.getTotalCount(); -// Map randomPoolByType = heroManager.getRandomPoolByType(); -// if (totalCountMap.containsKey(type)) { -// randCount = totalCountMap.get(type); -// } -// if (randomPoolByType.containsKey(sLotterySetting.getMergePool())) { -// poolCount = randomPoolByType.get(sLotterySetting.getMergePool()); -// } -// int totalCount = 0; -// for(Integer count : totalCountMap.values()){ -// totalCount+=count; -// } -// -// int j=0; -//// //标记是否触发保底 -//// boolean specialTrigger=false; -// for(int i=0;i specialConfigs = SLotterySpecialConfig.getLotterySpecialConfigListByType(mergePool); HeroManager heroManager = user.getHeroManager(); - //设置必出计数器 - if(specialConfigs!=null&&!specialConfigs.isEmpty()){ - if(!heroManager.getRandomPoolByType().containsKey(mergePool)){ - heroManager.getRandomPoolByType().put(mergePool,new HashMap<>()); - for(SLotterySpecialConfig config:specialConfigs){ - heroManager.getRandomPoolByType().get(mergePool).put(config.getDifferentType(),0); -// heroManager.getRandomPoolByType().computeIfAbsent(mergePool,n->new HashMap<>()).put(config.getId(),0); - } - } - } - Map countMap = heroManager.getRandomPoolByType().get(mergePool); Set mustSet = new HashSet<>(); - //次数计算 - for(Map.Entry countEntry:countMap.entrySet()){ - SLotterySpecialConfig config = null; - if(specialConfigs==null||specialConfigs.isEmpty()){ - continue; + Map> randomPoolByType = heroManager.getRandomPoolByType(); + //设置用户必出计数器 + if(specialConfigs!=null&&!specialConfigs.isEmpty()){ + if(!randomPoolByType.containsKey(mergePool)){ + randomPoolByType.put(mergePool,new HashMap<>()); + for(SLotterySpecialConfig config:specialConfigs){ + randomPoolByType.get(mergePool).put(config.getDifferentType(),0); + } } - for(SLotterySpecialConfig everyConfig:specialConfigs){ - if(everyConfig.getDifferentType()!=countEntry.getKey()){ + //保底次数计算 + for(Map.Entry countEntry:randomPoolByType.get(mergePool).entrySet()){ + SLotterySpecialConfig config = null; +// if(specialConfigs.isEmpty()){ +// continue; +// } + for(SLotterySpecialConfig everyConfig:specialConfigs){ + if(everyConfig.getDifferentType()!=countEntry.getKey()){ + continue; + } + config = everyConfig; + } + if(config==null){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + //本次是否触发保底 + if(countEntry.getValue()+1 mustRandomCount = heroManager.getMustRandomCount(); - if(mustRandomCount.containsKey(countEntry.getKey())) { - if(config.getMin_num()!=0&&mustRandomCount.get(countEntry.getKey())>=config.getMin_num()) { - continue; + //保底触发次数统计 + Map mustRandomCount = heroManager.getMustRandomCount(); + if(mustRandomCount.containsKey(countEntry.getKey())) { + //是否已经到了保底触发上限 + if(config.getMin_num()!=0&&mustRandomCount.get(countEntry.getKey())>=config.getMin_num()) { + continue; + }else{ + mustRandomCount.put(countEntry.getKey(), mustRandomCount.get(countEntry.getKey())+1); + } }else{ - mustRandomCount.put(countEntry.getKey(), mustRandomCount.get(countEntry.getKey())+1); + mustRandomCount.put(countEntry.getKey(),1); } - }else{ - mustRandomCount.put(countEntry.getKey(),1); + heroManager.setMustRandomCount(mustRandomCount); + mustSet.add(countEntry.getKey()); } - heroManager.setMustRandomCount(mustRandomCount); - mustSet.add(countEntry.getKey()); } - SLotteryRewardConfig sLotteryRewardConfig; //是否有必出 if(mustSet.isEmpty()){ sLotteryRewardConfig = randomHeroByPoolId(getPooId(sLotterySetting), 1, user.getPlayerInfoManager().getLevel()); int star = sLotteryRewardConfig.getStar(); - for(int key:countMap.keySet()){ + for(int key:randomPoolByType.get(mergePool).keySet()){ if(star==key){ - countMap.put(key,0); + randomPoolByType.get(mergePool).put(key,0); }else{ - countMap.put(key,countMap.get(key)+1); + int curValue= randomPoolByType.get(mergePool).getOrDefault(key,0); + randomPoolByType.get(mergePool).put(key,curValue+1); } } }else{ + + //有必出时比较各个优先级,取优先级高的 int maxId = 0; for(int mustId:mustSet){ maxId = mustId; @@ -393,10 +351,10 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); } sLotteryRewardConfig = randomHeroByPoolId(onConfig.getpool_id(), 1, user.getPlayerInfoManager().getLevel()); - countMap.put(maxId,0); + randomPoolByType.get(mergePool).put(maxId,0); } - heroManager.updateRandomPoolByType(mergePool,countMap); - int result = sLotteryRewardConfig.getReward()[0]; + heroManager.updateRandomPoolByType(mergePool,randomPoolByType.get(mergePool)); + int result = sLotteryRewardConfig.getId(); System.out.print(result+"、"); return result; } @@ -455,19 +413,19 @@ public class HeroLogic{ return 0; } - public int getOrderBoxPoolId(SLotterySetting sLotterySetting) throws Exception { - int[] orderBoxPool = sLotterySetting.getOrderBoxPool(); - int orderBoxOpenTime = sLotterySetting.getOrderBoxOpenTime(); - int orderBoxContinue = sLotterySetting.getOrderBoxContinue(); - long now = System.currentTimeMillis(); - ServerConfig serverConfig = GameApplication.serverConfig; - int diffHours = (int)((now - serverConfig.getCacheOpenTime())/1000/60/60%( (orderBoxOpenTime + orderBoxContinue))); - int diffSeaseon = (int)((now - serverConfig.getCacheOpenTime())/1000/60/60/( (orderBoxOpenTime + orderBoxContinue))); - if(diffHours>=orderBoxOpenTime){ - return orderBoxPool[diffSeaseon%orderBoxPool.length]; - } - return 0; - } +// public int getOrderBoxPoolId(SLotterySetting sLotterySetting) throws Exception { +// int[] orderBoxPool = sLotterySetting.getOrderBoxPool(); +// int orderBoxOpenTime = sLotterySetting.getOrderBoxOpenTime(); +// int orderBoxContinue = sLotterySetting.getOrderBoxContinue(); +// long now = System.currentTimeMillis(); +// ServerConfig serverConfig = GameApplication.serverConfig; +// int diffHours = (int)((now - serverConfig.getCacheOpenTime())/1000/60/60%( (orderBoxOpenTime + orderBoxContinue))); +// int diffSeaseon = (int)((now - serverConfig.getCacheOpenTime())/1000/60/60/( (orderBoxOpenTime + orderBoxContinue))); +// if(diffHours>=orderBoxOpenTime){ +// return orderBoxPool[diffSeaseon%orderBoxPool.length]; +// } +// return 0; +// } diff --git a/tablemanager/src/main/java/config/SLotterySetting.java b/tablemanager/src/main/java/config/SLotterySetting.java index 425cea16f..12738a742 100644 --- a/tablemanager/src/main/java/config/SLotterySetting.java +++ b/tablemanager/src/main/java/config/SLotterySetting.java @@ -7,19 +7,10 @@ public class SLotterySetting implements BaseConfig { private int id; - private int orderBoxOpenTime; - - private int orderBoxContinue; - - private int orderBoxInterval; - - private int[] orderBoxPool; - private int diamondBoxInterval; private int[][] cost; - private int getHerosInterval; private int[][] diamondBoxContain; @@ -33,8 +24,6 @@ public class SLotterySetting implements BaseConfig { private int mergePool; - private int[][] tenTimesMustGetBox; - private int activityId; private int freeTimes; @@ -52,22 +41,6 @@ public class SLotterySetting implements BaseConfig { return id; } - public int getOrderBoxOpenTime() { - return orderBoxOpenTime; - } - - public int getOrderBoxContinue() { - return orderBoxContinue; - } - - public int getOrderBoxInterval() { - return orderBoxInterval; - } - - public int[] getOrderBoxPool() { - return orderBoxPool; - } - public int getDiamondBoxInterval() { return diamondBoxInterval; } @@ -76,9 +49,6 @@ public class SLotterySetting implements BaseConfig { return cost; } - public int getGetHerosInterval() { - return getHerosInterval; - } public int[][] getDiamondBoxContain() { return diamondBoxContain; @@ -104,9 +74,6 @@ public class SLotterySetting implements BaseConfig { return mergePool; } - public int[][] getTenTimesMustGetBox() { - return tenTimesMustGetBox; - } public int getActivityId() { return activityId; From ae4d30761e7c542efc4cfbcdaa855c1cd67bf46a Mon Sep 17 00:00:00 2001 From: lvxinran Date: Fri, 19 Jun 2020 13:57:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=97=A7=E5=85=AC?= =?UTF-8?q?=E4=BC=9A=E6=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ljsd/jieling/logic/family/GuildFightLogic.java | 3 ++- tablemanager/src/main/java/config/SSpecialConfig.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java index b83144f3d..a7d44f0af 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildFightLogic.java @@ -598,7 +598,8 @@ public class GuildFightLogic { * @throws Exception */ public static void familyFightStatus() throws Exception { - if(!GameApplication.serverProperties.isGuildFight()){ + int isOpen = SSpecialConfig.getIntegerValue(SSpecialConfig.GUILD_WAR_ISOPEN); + if(isOpen==0){ return; } if (status == 2 && startMatching) { diff --git a/tablemanager/src/main/java/config/SSpecialConfig.java b/tablemanager/src/main/java/config/SSpecialConfig.java index 7d794dd61..da1b9d063 100644 --- a/tablemanager/src/main/java/config/SSpecialConfig.java +++ b/tablemanager/src/main/java/config/SSpecialConfig.java @@ -65,6 +65,7 @@ public class SSpecialConfig implements BaseConfig { public static final String EXPEDITION_REBORN = "expedition_reborn";// 大闹天宫复活道具id public static final String REWARD_OF_WORSHIP = "reward_of_worship";//膜拜获得金币奖励 public static final String DISCOUNT_LEVEL= "discount_level";//限时折扣推送等级#推送间隔等级 + public static final String GUILD_WAR_ISOPEN = "Guild_war_isopen";//老公会战是否开启 @Override public void init() throws Exception {