From ae9a7bc1eed612e26beebbcff1cbde8f075716b7 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Tue, 16 Apr 2019 10:25:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=82=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/server/AdventureConfig.txt | 14 +- conf/server/AdventurePoolConfig.txt | 7 - conf/server/AdventureSetting.txt | 7 - .../main/java/com/ljsd/GameApplication.java | 2 - .../ljsd/jieling/config/SAdventureConfig.java | 55 ++-- .../jieling/config/SAdventurePoolConfig.java | 53 ---- .../jieling/config/SAdventureSetting.java | 60 ---- .../combat/AdventureRewardHandler.java | 28 -- .../jieling/logic/dao/AdventureManager.java | 55 +--- .../jieling/logic/dao/AdventureStateInfo.java | 25 +- .../ljsd/jieling/logic/fight/CombatLogic.java | 274 ++++-------------- .../ljsd/jieling/logic/hero/HeroLogic.java | 4 +- .../ljsd/jieling/thread/ThreadManager.java | 4 - .../ljsd/jieling/thread/task/MinuteJob.java | 23 -- .../com/ljsd/jieling/util/CBean2Proto.java | 12 +- 15 files changed, 115 insertions(+), 508 deletions(-) delete mode 100644 conf/server/AdventurePoolConfig.txt delete mode 100644 conf/server/AdventureSetting.txt delete mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SAdventurePoolConfig.java delete mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureSetting.java delete mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureRewardHandler.java delete mode 100644 serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteJob.java diff --git a/conf/server/AdventureConfig.txt b/conf/server/AdventureConfig.txt index 4fa84c223..1ae81fc6e 100644 --- a/conf/server/AdventureConfig.txt +++ b/conf/server/AdventureConfig.txt @@ -1,7 +1,7 @@ -Id OpenLevel RecommendForce RecommendHeroIds MinNum BaseRewardGroup RandomRewardGroup RecommendRewardGroup -int int int mut,int#int,1 int mut,int#int,1 mut,int#int,1 mut,int#int,2 -1 102023 1000 2#1#2 5 101 111 4#121#6#122#8#123|4#124#6#125#8#126 -2 104030 2000 2#1#2 5 102 112 4#121#6#122#8#123|4#124#6#125#8#126 -3 109026 3000 2#1#2 5 103 113 4#121#6#122#8#123|4#124#6#125#8#126 -4 102001 4000 2#1#2 5 104 114 4#121#6#122#8#123|4#124#6#125#8#126 -5 102001 5000 2#1#2 5 105 115 4#121#6#122#8#123|4#124#6#125#8#126 +Id OpenLevel MaxNum BaseRewardGroup RandomRewardGroup NumIncome LeaveBonus +int int int mut,int#int,1 mut,int#int,1 mut,float#float,2 int +1 10 5 101 111 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +2 20 5 102 112 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +3 30 5 103 113 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +4 40 5 104 114 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 +5 50 5 105 115 1#0.2|2#0.4|3#0.6|4#0.8|5#1 8 diff --git a/conf/server/AdventurePoolConfig.txt b/conf/server/AdventurePoolConfig.txt deleted file mode 100644 index 309fc9523..000000000 --- a/conf/server/AdventurePoolConfig.txt +++ /dev/null @@ -1,7 +0,0 @@ -Id Weight Pool -int int int -10001 100 1 -10002 100 1 -10003 100 1 -10004 100 1 -10005 100 2 diff --git a/conf/server/AdventureSetting.txt b/conf/server/AdventureSetting.txt deleted file mode 100644 index 10ded5b80..000000000 --- a/conf/server/AdventureSetting.txt +++ /dev/null @@ -1,7 +0,0 @@ -Id ConsumeGemRatio BaseRewardRatio RandomRewardRatio PerMapMaxHour HourRewardRatio -int mut,int#int,1 mut,float#float,2 mut,float#float,2 int mut,float#float,1 -1 0#0#50#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -2 0#0#55#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -3 0#0#60#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -4 0#0#70#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 -5 0#0#80#0 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 0.7#0.4|0.8#0.6|0.9#0.8|1#1|1.1#1.1|1.2#1.2|1.3#1.3|1.4#1.4|1.5#1.5 8 0#0#1#0 diff --git a/serverlogic/src/main/java/com/ljsd/GameApplication.java b/serverlogic/src/main/java/com/ljsd/GameApplication.java index 8d582c96d..83339019d 100644 --- a/serverlogic/src/main/java/com/ljsd/GameApplication.java +++ b/serverlogic/src/main/java/com/ljsd/GameApplication.java @@ -74,8 +74,6 @@ public class GameApplication { MongoUtil.getInstence().init(configurableApplicationContext); - CombatLogic.getInstance().checkAdventureFlush(); - STableManager.initialize("com.ljsd.jieling.config"); //初始化邮件 MailingSystemManager.init(configurableApplicationContext); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java index be44fec71..faed64147 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureConfig.java @@ -3,49 +3,39 @@ package com.ljsd.jieling.config; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; -import java.util.Arrays; -import java.util.HashSet; import java.util.Map; -import java.util.Set; @Table(name ="AdventureConfig") public class SAdventureConfig implements BaseConfig { - private static Map sAdventureConfigMap; private int id; private int openLevel; - private int recommendForce; - - private int[] recommendHeroIds; - - private int minNum; + private int maxNum; private int[] baseRewardGroup; private int[] randomRewardGroup; - private int[][] recommendRewardGroup; + private float[][] numIncome; + + private int leaveBonus; + + private static Map sAdventureConfigMap; @Override public void init() throws Exception { - - sAdventureConfigMap = STableManager.getConfig(SAdventureConfig.class); - - + sAdventureConfigMap = STableManager.getConfig(SAdventureConfig.class); } - public static SAdventureConfig getsAdventureConfigByPosition(int position) { - return sAdventureConfigMap.get(position); + public static SAdventureConfig getSAdventureConfigByPosition(int position){ + return sAdventureConfigMap.get(position); } - public static Map getsAdventureConfigMap() { - return sAdventureConfigMap; - } - public int getId() { + public int getId() { return id; } @@ -53,28 +43,25 @@ public class SAdventureConfig implements BaseConfig { return openLevel; } - public int getRecommendForce() { - return recommendForce; + public int getMaxNum() { + return maxNum; } - public int[] getRecommendHeroIds() { - return recommendHeroIds; - } - - public int getMinNum() { - return minNum; - } - - public int[] getBaseRewardGroup() { + public int[] getBaseRewardGroup() { return baseRewardGroup; } - public int[] getRandomRewardGroup() { + public int[] getRandomRewardGroup() { return randomRewardGroup; } - public int[][] getRecommendRewardGroup() { - return recommendRewardGroup; + public float[][] getNumIncome() { + return numIncome; } + public int getLeaveBonus() { + return leaveBonus; + } + + } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventurePoolConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventurePoolConfig.java deleted file mode 100644 index fa87a5b72..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventurePoolConfig.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.ljsd.jieling.config; - -import com.ljsd.jieling.logic.STableManager; -import com.ljsd.jieling.logic.Table; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Table(name ="AdventurePoolConfig") -public class SAdventurePoolConfig implements BaseConfig { - - private int id; - - private int weight; - - private int pool; - - private static Map> sAdventurePoolConfigListMap; - - @Override - public void init() throws Exception { - Map> sAdventurePoolConfigListMapTmp = new HashMap<>(); - Map config = STableManager.getConfig(SAdventurePoolConfig.class); - for(SAdventurePoolConfig sAdventurePoolConfig : config.values()){ - int pool = sAdventurePoolConfig.getPool(); - if(!sAdventurePoolConfigListMapTmp.containsKey(pool)){ - sAdventurePoolConfigListMapTmp.put(pool,new ArrayList<>()); - } - sAdventurePoolConfigListMapTmp.get(pool).add(sAdventurePoolConfig); - } - sAdventurePoolConfigListMap = sAdventurePoolConfigListMapTmp; - } - - public static List getsAdventurePoolConfigListByPool(int poolId) { - return sAdventurePoolConfigListMap.get(poolId); - } - - public int getId() { - return id; - } - - public int getWeight() { - return weight; - } - - public int getPool() { - return pool; - } - - -} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureSetting.java deleted file mode 100644 index fb62bd5b8..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SAdventureSetting.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.ljsd.jieling.config; - -import com.ljsd.jieling.logic.STableManager; -import com.ljsd.jieling.logic.Table; - -import java.util.Map; - -@Table(name ="AdventureSetting") -public class SAdventureSetting implements BaseConfig { - - private static Map sAdventureSettingMap; - - private int id; - - private int[] consumeGemRatio; - - private float[][] baseRewardRatio; - - private float[][] randomRewardRatio; - - private int perMapMaxHour; - - private float[] hourRewardRatio; - - - @Override - public void init() throws Exception { - sAdventureSettingMap = STableManager.getConfig(SAdventureSetting.class); - } - - public static SAdventureSetting getsAdventureSetting(int pooId) { - return sAdventureSettingMap.get(pooId); - } - - public int getId() { - return id; - } - - public int[] getConsumeGemRatio() { - return consumeGemRatio; - } - - public float[][] getBaseRewardRatio() { - return baseRewardRatio; - } - - public float[][] getRandomRewardRatio() { - return randomRewardRatio; - } - - public int getPerMapMaxHour() { - return perMapMaxHour; - } - - public float[] getHourRewardRatio() { - return hourRewardRatio; - } - - -} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureRewardHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureRewardHandler.java deleted file mode 100644 index c4d60186d..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/combat/AdventureRewardHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.ljsd.jieling.handler.combat; - -import com.ljsd.jieling.handler.BaseHandler; -import com.ljsd.jieling.logic.fight.CombatLogic; -import com.ljsd.jieling.netty.cocdex.PacketNetData; -import com.ljsd.jieling.network.session.ISession; -import com.ljsd.jieling.protocols.FightInfoProto; -import com.ljsd.jieling.protocols.MessageTypeProto; -import org.springframework.stereotype.Component; - -import java.util.List; - - -@Component -public class AdventureRewardHandler extends BaseHandler { - @Override - public MessageTypeProto.MessageType getMessageCode() { - return MessageTypeProto.MessageType.ADVENTURE_REWARD_REQUEST; - } - - @Override - public void process(ISession iSession, PacketNetData netData) throws Exception { - byte[] bytes = netData.parseClientProtoNetData(); - FightInfoProto.TakeAventureRewardRequest takeAventureRewardRequest = FightInfoProto.TakeAventureRewardRequest.parseFrom(bytes); - int position = takeAventureRewardRequest.getPosition(); - CombatLogic.getInstance().clearStation(iSession,position); - } -} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java index f6d51c339..27752a99b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureManager.java @@ -1,6 +1,7 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.MongoBase; +import com.ljsd.jieling.handler.map.TemporaryItems; import com.ljsd.jieling.logic.dao.root.User; @@ -10,63 +11,35 @@ import java.util.Map; public class AdventureManager extends MongoBase { private Map adventureStateInfoMap; - private Map allowTimeMap; - private long updateTime; + private Map tempDropRatio = new HashMap<>(); public AdventureManager(){ this.setRootCollection(User._COLLECTION_NAME); adventureStateInfoMap = new HashMap<>(); - allowTimeMap = new HashMap<>(); } - public void station(AdventureStateInfo adventureStateInfo,int allowTime) throws Exception { + public void station(AdventureStateInfo adventureStateInfo) throws Exception { int position = adventureStateInfo.getPosition(); updateString("adventureStateInfoMap." + position, adventureStateInfo); - updateString("allowTimeMap." + position, allowTime); adventureStateInfoMap.put(position,adventureStateInfo); - allowTimeMap.put(position,allowTime); } - public void clearStation(int position){ - AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(position); - if (adventureStateInfo!=null){ - removeString(getMongoKey() +".adventureStateInfoMap." + position); - removeString(getMongoKey() +".allowTimeMap." + position); - adventureStateInfoMap.remove(position); - allowTimeMap.remove(position); - } + public Map getTempDropRation() { + return tempDropRatio; + } + public void updateTemp(int dropIds[],float ratio){ + tempDropRatio.put(dropIds,ratio); + updateString("tempDropRatio."+dropIds,ratio); + } + + public void clearTemp(){ + tempDropRatio.clear(); + updateString("tempDropRatio",new HashMap<>()); } public Map getAdventureStateInfoMap() { return adventureStateInfoMap; } - - public void setAdventureStateInfoMap(Map adventureStateInfoMap) { - this.adventureStateInfoMap = adventureStateInfoMap; - } - - public void updateAllowTime(int position,int allowTime){ - updateString("allowTimeMap." + position, allowTime); - allowTimeMap.put(position,allowTime); - } - - public void setUpdateTime(long updateTime) { - updateString("updateTime",updateTime); - this.updateTime = updateTime; - } - - public void setAllowTimeMap(Map allowTimeMap) { - updateString("allowTimeMap.",allowTimeMap); - this.allowTimeMap = allowTimeMap; - } - - public long getUpdateTime() { - return updateTime; - } - - public Map getAllowTimeMap() { - return allowTimeMap; - } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java index 1fc6df165..326b2b623 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/AdventureStateInfo.java @@ -1,8 +1,6 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.MongoBase; -import com.ljsd.jieling.config.SAdventureSetting; -import com.ljsd.jieling.config.SVipLevelConfig; import com.ljsd.jieling.logic.dao.root.User; import java.util.List; @@ -11,24 +9,15 @@ public class AdventureStateInfo extends MongoBase { private int position; private List heroIds; private int startTime; - private int hourDuration; - - - private int totalForce; - private int myRecommendHeroSize; - public AdventureStateInfo(){ this.setRootCollection(User._COLLECTION_NAME); } - public AdventureStateInfo(int position,List heroIds, int startTime, int hourDuration,int totalForce,int myRecommendHeroSize) { + public AdventureStateInfo(int position,List heroIds, int startTime) { this.setRootCollection(User._COLLECTION_NAME); this.heroIds = heroIds; this.startTime = startTime; - this.hourDuration = hourDuration; this.position = position; - this.totalForce = totalForce; - this.myRecommendHeroSize = myRecommendHeroSize; } public List getHeroIds() { @@ -39,19 +28,13 @@ public class AdventureStateInfo extends MongoBase { return startTime; } - public int getHourDuration() { - return hourDuration; - } - public int getPosition() { return position; } - public int getTotalForce() { - return totalForce; - } + public void setStartTime(int startTime) { + updateString("startTime",startTime); + this.startTime = startTime; - public int getMyRecommendHeroSize() { - return myRecommendHeroSize; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java index 704ea14b5..b6630ec18 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java @@ -1,16 +1,12 @@ package com.ljsd.jieling.logic.fight; -import com.ljsd.GameApplication; import com.ljsd.jieling.config.*; import com.ljsd.jieling.core.GlobalsDef; -import com.ljsd.jieling.db.mongo.MongoUtil; import com.ljsd.jieling.handler.map.MapManager; import com.ljsd.jieling.logic.dao.*; -import com.ljsd.jieling.logic.dao.root.AdventureSeasonInfo; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.UserManager; -import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.FightInfoProto; @@ -24,9 +20,6 @@ import java.util.*; public class CombatLogic { private static final Logger LOGGER = LoggerFactory.getLogger(CombatLogic.class); - private static AdventureSeasonInfo adventureSeasonInfoCache; - private static List adventureRecommendHeroInfos ; - private CombatLogic(){} @@ -39,96 +32,18 @@ public class CombatLogic { return CombatLogic.Instance.instance; } - - private void getAdventureRecommendHeroInfos( Map> recommendFinalHeroMap){ - - adventureRecommendHeroInfos = new ArrayList<>(recommendFinalHeroMap.size()); - for(Map.Entry> item : recommendFinalHeroMap.entrySet()){ - Integer key = item.getKey(); - Set value = item.getValue(); - adventureRecommendHeroInfos.add(CommonProto.AdventureRecommendHeroInfo.newBuilder().setPositionId(key).addAllRecommenedId(value).build()); - } - } - - - - //冒险模式 加成英雄刷新 - public void checkAdventureFlush() throws Exception { - AdventureSeasonInfo adventureSeasonInfo = MongoUtil.getInstence().getMyMongoTemplate().findById(AdventureSeasonInfo._COLLECTION_NAME, Integer.toString(GameApplication.serverId), AdventureSeasonInfo.class); - if(adventureSeasonInfo!=null){ - if(adventureSeasonInfoCache == null || adventureSeasonInfo.getUpdateTime()!=adventureSeasonInfoCache.getUpdateTime()){ - adventureSeasonInfoCache = adventureSeasonInfo; - getAdventureRecommendHeroInfos(adventureSeasonInfo.getRecommendFinalHeroMap()); - } - if(TimeUtils.isSameDayWithNow(adventureSeasonInfo.getUpdateTime())){ - return; - } - } - Map> recommendFinalHeroMap = new HashMap<>(); - Map sAdventureConfigMap = SAdventureConfig.getsAdventureConfigMap(); - for(SAdventureConfig sAdventureConfig : sAdventureConfigMap.values()){ - int[] recommendHeroIds = sAdventureConfig.getRecommendHeroIds(); - int recommendNums = recommendHeroIds[0]; - int randomPoolId = recommendHeroIds[1]; - int mustPoolId = recommendHeroIds[2]; - int leftNums = recommendNums; - Set recommendFinalHeroIds = new HashSet<>(recommendNums); - recommendFinalHeroMap.put(sAdventureConfig.getId(),recommendFinalHeroIds); - if(mustPoolId!=0){ - List sAdventurePoolConfigs = SAdventurePoolConfig.getsAdventurePoolConfigListByPool(mustPoolId); - for(SAdventurePoolConfig sAdventurePoolConfig : sAdventurePoolConfigs){ - recommendFinalHeroIds.add(sAdventurePoolConfig.getId()); - leftNums --; - } - } - - if(leftNums>0){ - List sAdventurePoolConfigs = SAdventurePoolConfig.getsAdventurePoolConfigListByPool(randomPoolId); - int totalWeight = 0; - for(SAdventurePoolConfig sAdventurePoolConfig : sAdventurePoolConfigs){ - totalWeight+=sAdventurePoolConfig.getWeight(); - } - while (leftNums>0){ - int randomWeight = MathUtils.randomInt(totalWeight)+1; - for(SAdventurePoolConfig sAdventurePoolConfig : sAdventurePoolConfigs){ - randomWeight-=sAdventurePoolConfig.getWeight(); - if(randomWeight<=0){ - recommendFinalHeroIds.add(sAdventurePoolConfig.getId()); - leftNums--; - break; - } - } - } - } - } - if(adventureSeasonInfo == null){ - adventureSeasonInfo = new AdventureSeasonInfo(); - } - adventureSeasonInfo.setRecommendFinalHeroMap(recommendFinalHeroMap); - adventureSeasonInfo.setUpdateTime(System.currentTimeMillis()); - adventureSeasonInfoCache = adventureSeasonInfo; - getAdventureRecommendHeroInfos(adventureSeasonInfo.getRecommendFinalHeroMap()); - MongoUtil.getInstence().getMyMongoTemplate().save(adventureSeasonInfo); - - } //冒险模式 public void getAdventureStateInfo(ISession session) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); - flushAdventureTime(user); AdventureManager adventureManager = user.getAdventureManager(); Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); List result = new ArrayList<>(); - Map allowTimeMap = adventureManager.getAllowTimeMap(); - for(Map.Entry item : allowTimeMap.entrySet()){ - Integer position = item.getKey(); - Integer allowTime = item.getValue(); - AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(position); - result.add(CBean2Proto.getAdventureStateInfo(adventureStateInfo,position,allowTime)); + CommonProto.Drop.Builder dropBuilder = calAdvenrureReward(user, false,0); + for(AdventureStateInfo item : adventureStateInfoMap.values()){ + result.add(CBean2Proto.getAdventureStateInfo(item,item.getPosition())); } - - FightInfoProto.GetAdventureStateInfoResponse response = FightInfoProto.GetAdventureStateInfoResponse.newBuilder().addAllAdventureStateInfoList(result).addAllAdventureRecommendHeroInfo(adventureRecommendHeroInfos). - build(); + FightInfoProto.GetAdventureStateInfoResponse response = FightInfoProto.GetAdventureStateInfoResponse.newBuilder().addAllAdventureStateInfoList(result).setDrop(dropBuilder.build()).build(); MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_ADVENTURE_INFO_RESPONSE_VALUE,response,true); } @@ -141,47 +56,27 @@ public class CombatLogic { int uid = session.getUid(); User user = UserManager.getUser(uid); - SAdventureConfig sAdventureConfig = SAdventureConfig.getsAdventureConfigByPosition(position); - /* if(sAdventureConfig.getOpenLevel() > user.getPlayerInfoManager().getLevel()){ + SAdventureConfig sAdventureConfig = SAdventureConfig.getSAdventureConfigByPosition(position); + if(sAdventureConfig.getOpenLevel() > user.getPlayerInfoManager().getLevel()){ MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"等级不够"); return; - }*/ - - - if(sAdventureConfig.getMinNum() > heroIds.size()){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"英雄数量小于规定数量"); - return; } - SAdventureSetting sAdventureSetting = SAdventureSetting.getsAdventureSetting(position); - if(hourDuration > sAdventureSetting.getPerMapMaxHour()){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"超出时长"); + + if(heroIds.size()>sAdventureConfig.getMaxNum()){ + MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"英雄数量大于规定数量"); return; } AdventureManager adventureManager = user.getAdventureManager(); //检验 Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); - AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position); - if(adventureStateInfo!=null){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"已驻扎"); - return; - } - - int allowTime =0; - if(!adventureManager.getAllowTimeMap().containsKey(position)){ - int vipLevel = user.getPlayerInfoManager().getVipLevel(); - allowTime = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel).getPrivilegeMap().get(1) -hourDuration; - }else{ - Integer remainAllowTime = adventureManager.getAllowTimeMap().get(position); - allowTime = remainAllowTime - hourDuration; - } - if(allowTime<0){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,"超过时间"); - return; - } for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()){ + int positionTmp = adventureStateInfoTmp.getPosition(); + if(position == positionTmp){ + continue; + } List heroIds1 = adventureStateInfoTmp.getHeroIds(); for(String useHeroId : heroIds1){ if(heroIds.contains(useHeroId)){ @@ -191,117 +86,76 @@ public class CombatLogic { } } } - HeroManager heroManager = user.getHeroManager(); - int myRecommendHeroSize=0; - int totalForce=0; - Set recommendHeroSets =adventureSeasonInfoCache.getRecommendFinalHeroMap().get(position); - Set cacheHeroTid = new HashSet<>(recommendHeroSets.size()); - for(String heroId : heroIds){ - Hero hero = heroManager.getHero(heroId); - int templateId = hero.getTemplateId(); - if(recommendHeroSets.contains(templateId) && !cacheHeroTid.contains(templateId)){ - cacheHeroTid.add(templateId); - myRecommendHeroSize++; + if(adventureManager.getAdventureStateInfoMap().containsKey(position)){ + AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position); + if(adventureStateInfo.getHeroIds()!=null && !adventureStateInfo.getHeroIds().isEmpty()){ + calAdvenrureReward(user,true,position); } - totalForce += HeroLogic.getInstance().calHeoForce(user,hero); } - - adventureManager.station(new AdventureStateInfo(position,heroIds,(int)(System.currentTimeMillis()/1000),hourDuration,totalForce,myRecommendHeroSize),allowTime); - if(adventureManager.getUpdateTime() == 0){ - adventureManager.setUpdateTime(System.currentTimeMillis()); - } - + adventureManager.station(new AdventureStateInfo(position,heroIds,(int)(System.currentTimeMillis()/1000))); //发送成功 MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_STATION_RESPONSE_VALUE,null,true); } - private void flushAdventureTime( User user ){ + public void calAdventureRewardByHeroChange(User user,Set heroIds) throws Exception { AdventureManager adventureManager = user.getAdventureManager(); - long updateTime = adventureManager.getUpdateTime(); - if(updateTime ==0 || TimeUtils.isSameDayWithNow(updateTime)){ - return; - } - int vipLevel = user.getPlayerInfoManager().getVipLevel(); - int allowTime = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel).getPrivilegeMap().get(1); - Map allowTimeMap = adventureManager.getAllowTimeMap(); - if(allowTimeMap!=null && !allowTimeMap.isEmpty()){ - Map result = new HashMap<>(); - for(Integer position : allowTimeMap.keySet()){ - result.put(position,allowTime); + //检验 + Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); + for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()){ + List heroIdsOccupy = adventureStateInfoTmp.getHeroIds(); + boolean remove = heroIdsOccupy.removeAll(heroIds); + if(remove){ + //提前结算 + int position = adventureStateInfoTmp.getPosition(); + calAdvenrureReward(user,true,position); + adventureManager.station(new AdventureStateInfo(adventureStateInfoTmp.getPosition(),heroIdsOccupy,(int)(System.currentTimeMillis()/1000))); } - adventureManager.setUpdateTime(System.currentTimeMillis()); - adventureManager.setAllowTimeMap(result); } } - - public void clearStation(ISession session,int position) throws Exception { - int uid = session.getUid(); - User user = UserManager.getUser(uid); + //消耗道具全部加一遍基础奖励。 + public CommonProto.Drop.Builder calAdvenrureReward(User user, boolean isOnLine,int position) throws Exception { + Map tempDropRation = new HashMap<>(); AdventureManager adventureManager = user.getAdventureManager(); - AdventureStateInfo adventureStateInfo = adventureManager.getAdventureStateInfoMap().get(position); - if( null == adventureStateInfo ){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,""); - return; - } - int startTime = adventureStateInfo.getStartTime(); - int hourDuration = adventureStateInfo.getHourDuration(); + Map adventureStateInfoMap = adventureManager.getAdventureStateInfoMap(); int now = (int)(System.currentTimeMillis()/1000); - if( (now - startTime ) /3600 < hourDuration ){ - MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,"驻扎时长不到"); - return; - } - //计算奖励 - SAdventureConfig sAdventureConfig = SAdventureConfig.getsAdventureConfigByPosition(position); - int recommendForce = sAdventureConfig.getRecommendForce(); - - - SAdventureSetting sAdventureSetting = SAdventureSetting.getsAdventureSetting(position); - - - float[][] baseRewardRatio = sAdventureSetting.getBaseRewardRatio(); - float[][] randomRewardRatio = sAdventureSetting.getRandomRewardRatio(); - float[] hourRewardRatio = sAdventureSetting.getHourRewardRatio(); - - int totalForce =adventureStateInfo.getTotalForce(); - int myRecommendHeroSize =adventureStateInfo.getMyRecommendHeroSize(); - float myForceRatio = totalForce*1.0f / recommendForce; - - float hourRewardRatioTmp = MathUtils.calABX(hourDuration, hourRewardRatio); - float baseRewardRatioTmp = calRatio(myForceRatio, baseRewardRatio) * hourRewardRatioTmp; - float randomRewardRatioTmp = calRatio(myForceRatio, randomRewardRatio) * hourRewardRatioTmp; - int[] baseRewardGroup = sAdventureConfig.getBaseRewardGroup(); - int[][] recommendRewardGroup = sAdventureConfig.getRecommendRewardGroup(); - int[] randomRewardGroup = sAdventureConfig.getRandomRewardGroup(); - Map dropInfoMap = new HashMap<>(); - dropInfoMap.put(baseRewardGroup,baseRewardRatioTmp); - dropInfoMap.put(randomRewardGroup,randomRewardRatioTmp); - if(myRecommendHeroSize>0){ - int[] recommendRewardGroupDetail = recommendRewardGroup[myRecommendHeroSize - 1]; - for(int i=0;i0){ + adventureStateInfoTmp.setStartTime(startTime+times*60); + SAdventureConfig sAdventureConfig = SAdventureConfig.getSAdventureConfigByPosition(positionTmp); + int leaveBonus = sAdventureConfig.getLeaveBonus(); + if(!isOnLine){ + times = times>leaveBonus?leaveBonus:times; } + int baseRewardGroup[] = sAdventureConfig.getBaseRewardGroup(); + float rewardRation = calRation(size,sAdventureConfig.getNumIncome()); + tempDropRation.put(baseRewardGroup,rewardRation * times); + adventureManager.updateTemp(sAdventureConfig.getRandomRewardGroup(),rewardRation*times); } } - CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropInfoMap); - //清除占领 - adventureManager.clearStation(position); - FightInfoProto.TakeAventureRewardResponse response = FightInfoProto.TakeAventureRewardResponse.newBuilder().setDrop(drop).build(); - - //发送成功 - MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,response,true); + if(!isOnLine){ + tempDropRation.putAll(adventureManager.getTempDropRation()); + adventureManager.clearTemp(); + } + return ItemUtil.drop(user, tempDropRation); } - public float calRatio(float value,float[][] base){ - float result = 0; - for(int i=0;i< base.length;i++){ - float weight = base[i][0]; - if(value>= weight){ - result = base[i][1]; + private float calRation(float source,float[][] rationInfos){ + float result = 0.0f; + for(float[] item : rationInfos){ + float num = item[0]; + float value = item[1]; + if(source removeHeroIds){ + public void recyleHeroBySystem(User user,Set removeHeroIds) throws Exception { HeroManager heroManager = user.getHeroManager(); for(String useHeroId : removeHeroIds){ heroManager.removeHero(useHeroId); } - + CombatLogic.getInstance().calAdventureRewardByHeroChange(user,removeHeroIds); } //初始属性*(1+化境增长)*等级系数 + 初始属性*突破系数 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java b/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java index 12c1f973e..28fbf4fa8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/thread/ThreadManager.java @@ -1,6 +1,5 @@ package com.ljsd.jieling.thread; -import com.ljsd.jieling.thread.task.MinuteJob; import com.ljsd.jieling.thread.task.PlatConfigureTask; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,9 +63,6 @@ public class ThreadManager { // testTask 已秒为单位 延迟10s, 间隔30s为周期执行 scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS); - long diff = now/1000 % 60 ; - scheduledExecutor.scheduleAtFixedRate(new MinuteJob(), 60 - diff, 60, TimeUnit.SECONDS); - LOGGER.info("All Task running ..."); } public ScheduledThreadPoolExecutor getScheduledExecutor() { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteJob.java b/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteJob.java deleted file mode 100644 index 124807f2d..000000000 --- a/serverlogic/src/main/java/com/ljsd/jieling/thread/task/MinuteJob.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ljsd.jieling.thread.task; - - -import com.ljsd.jieling.logic.fight.CombatLogic; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MinuteJob extends Thread { - private static final Logger LOGGER = LoggerFactory.getLogger(MinuteJob.class); - public MinuteJob(){ - super("minute-job-thread"); - } - - @Override - public void run() { - try { - LOGGER.info("MinuteJob start working"); - CombatLogic.getInstance().checkAdventureFlush(); - } catch (Exception e) { - LOGGER.error("the exception={}",e); - } - } -} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java index 8fffdbf0f..08a4debe1 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java @@ -90,17 +90,11 @@ public class CBean2Proto { return mailProto; } - public static CommonProto.AdventureStateInfo getAdventureStateInfo(AdventureStateInfo adventureStateInfo,int position,int allowTime){ - CommonProto.AdventureStateInfo.Builder builder = CommonProto.AdventureStateInfo.newBuilder().setAllowTime(allowTime).setPositionId(position); + public static CommonProto.AdventureStateInfo getAdventureStateInfo(AdventureStateInfo adventureStateInfo,int position){ + CommonProto.AdventureStateInfo.Builder builder = CommonProto.AdventureStateInfo.newBuilder().setPositionId(position); if(adventureStateInfo!=null){ int startTime = adventureStateInfo.getStartTime(); - int now = (int)(System.currentTimeMillis()/1000); - int hourDuration = adventureStateInfo.getHourDuration(); - int remainTime = startTime + hourDuration*60*60 - now; - remainTime = remainTime<0?0:remainTime; - builder.addAllHeroIdList(adventureStateInfo.getHeroIds()) - .setHourDuration(hourDuration) - .setRemainTime(remainTime); + builder.addAllHeroIdList(adventureStateInfo.getHeroIds()); } return builder.build();