back_recharge
parent
761776f126
commit
ae9a7bc1ee
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -74,8 +74,6 @@ public class GameApplication {
|
|||
|
||||
MongoUtil.getInstence().init(configurableApplicationContext);
|
||||
|
||||
CombatLogic.getInstance().checkAdventureFlush();
|
||||
|
||||
STableManager.initialize("com.ljsd.jieling.config");
|
||||
//初始化邮件
|
||||
MailingSystemManager.init(configurableApplicationContext);
|
||||
|
|
|
@ -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<Integer, SAdventureConfig> 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<Integer, SAdventureConfig> 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<Integer, SAdventureConfig> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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<Integer, List<SAdventurePoolConfig>> sAdventurePoolConfigListMap;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, List<SAdventurePoolConfig>> sAdventurePoolConfigListMapTmp = new HashMap<>();
|
||||
Map<Integer, SAdventurePoolConfig> 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<SAdventurePoolConfig> getsAdventurePoolConfigListByPool(int poolId) {
|
||||
return sAdventurePoolConfigListMap.get(poolId);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public int getPool() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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<Integer, SAdventureSetting> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<Integer,AdventureStateInfo> adventureStateInfoMap;
|
||||
private Map<Integer,Integer> allowTimeMap;
|
||||
|
||||
private long updateTime;
|
||||
private Map<int[],Float> 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<int[], Float> 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<Integer, AdventureStateInfo> getAdventureStateInfoMap() {
|
||||
return adventureStateInfoMap;
|
||||
}
|
||||
|
||||
public void setAdventureStateInfoMap(Map<Integer, AdventureStateInfo> 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<Integer, Integer> allowTimeMap) {
|
||||
updateString("allowTimeMap.",allowTimeMap);
|
||||
this.allowTimeMap = allowTimeMap;
|
||||
}
|
||||
|
||||
public long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getAllowTimeMap() {
|
||||
return allowTimeMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String> 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<String> heroIds, int startTime, int hourDuration,int totalForce,int myRecommendHeroSize) {
|
||||
public AdventureStateInfo(int position,List<String> 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<String> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CommonProto.AdventureRecommendHeroInfo> adventureRecommendHeroInfos ;
|
||||
|
||||
private CombatLogic(){}
|
||||
|
||||
|
||||
|
@ -39,96 +32,18 @@ public class CombatLogic {
|
|||
return CombatLogic.Instance.instance;
|
||||
}
|
||||
|
||||
|
||||
private void getAdventureRecommendHeroInfos( Map<Integer, Set<Integer>> recommendFinalHeroMap){
|
||||
|
||||
adventureRecommendHeroInfos = new ArrayList<>(recommendFinalHeroMap.size());
|
||||
for(Map.Entry<Integer,Set<Integer>> item : recommendFinalHeroMap.entrySet()){
|
||||
Integer key = item.getKey();
|
||||
Set<Integer> 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<Integer,Set<Integer>> recommendFinalHeroMap = new HashMap<>();
|
||||
Map<Integer, SAdventureConfig> 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<Integer> recommendFinalHeroIds = new HashSet<>(recommendNums);
|
||||
recommendFinalHeroMap.put(sAdventureConfig.getId(),recommendFinalHeroIds);
|
||||
if(mustPoolId!=0){
|
||||
List<SAdventurePoolConfig> sAdventurePoolConfigs = SAdventurePoolConfig.getsAdventurePoolConfigListByPool(mustPoolId);
|
||||
for(SAdventurePoolConfig sAdventurePoolConfig : sAdventurePoolConfigs){
|
||||
recommendFinalHeroIds.add(sAdventurePoolConfig.getId());
|
||||
leftNums --;
|
||||
}
|
||||
}
|
||||
|
||||
if(leftNums>0){
|
||||
List<SAdventurePoolConfig> 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<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
|
||||
List<CommonProto.AdventureStateInfo> result = new ArrayList<>();
|
||||
Map<Integer, Integer> allowTimeMap = adventureManager.getAllowTimeMap();
|
||||
for(Map.Entry<Integer,Integer> 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<Integer, AdventureStateInfo> 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<String> 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<Integer> recommendHeroSets =adventureSeasonInfoCache.getRecommendFinalHeroMap().get(position);
|
||||
Set<Integer> 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<String> 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<Integer, Integer> allowTimeMap = adventureManager.getAllowTimeMap();
|
||||
if(allowTimeMap!=null && !allowTimeMap.isEmpty()){
|
||||
Map<Integer,Integer> result = new HashMap<>();
|
||||
for(Integer position : allowTimeMap.keySet()){
|
||||
result.put(position,allowTime);
|
||||
//检验
|
||||
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
|
||||
for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()){
|
||||
List<String> 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<int[], Float> 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<Integer, AdventureStateInfo> 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<int[],Float> dropInfoMap = new HashMap<>();
|
||||
dropInfoMap.put(baseRewardGroup,baseRewardRatioTmp);
|
||||
dropInfoMap.put(randomRewardGroup,randomRewardRatioTmp);
|
||||
if(myRecommendHeroSize>0){
|
||||
int[] recommendRewardGroupDetail = recommendRewardGroup[myRecommendHeroSize - 1];
|
||||
for(int i=0;i<recommendRewardGroupDetail.length;i=i+2){
|
||||
int hourLimit = recommendRewardGroupDetail[i];
|
||||
if(hourDuration<=hourLimit){
|
||||
dropInfoMap.put(new int[]{recommendRewardGroupDetail[i+1]},1.0f);
|
||||
break;
|
||||
for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()){
|
||||
int positionTmp = adventureStateInfoTmp.getPosition();
|
||||
if(position!=0 && positionTmp!=position){
|
||||
continue;
|
||||
}
|
||||
int startTime = adventureStateInfoTmp.getStartTime();
|
||||
int times = (now - startTime)%60;
|
||||
int size = adventureStateInfoTmp.getHeroIds().size();
|
||||
if(times>0){
|
||||
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<num){
|
||||
break;
|
||||
}
|
||||
result = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -542,12 +542,12 @@ public class HeroLogic {
|
|||
|
||||
|
||||
|
||||
public void recyleHeroBySystem(User user,Set<String> removeHeroIds){
|
||||
public void recyleHeroBySystem(User user,Set<String> removeHeroIds) throws Exception {
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
for(String useHeroId : removeHeroIds){
|
||||
heroManager.removeHero(useHeroId);
|
||||
}
|
||||
|
||||
CombatLogic.getInstance().calAdventureRewardByHeroChange(user,removeHeroIds);
|
||||
}
|
||||
|
||||
//初始属性*(1+化境增长)*等级系数 + 初始属性*突破系数
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue