大闹天宫,初版未完成
parent
f87beb7368
commit
1099169d1f
|
@ -2,6 +2,9 @@ package com.ljsd.jieling.config.clazzStaticCfg;
|
||||||
|
|
||||||
import com.ljsd.GameApplication;
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.jieling.globals.Global;
|
import com.ljsd.jieling.globals.Global;
|
||||||
|
import com.ljsd.jieling.logic.dao.ExpeditionItem;
|
||||||
|
import com.ljsd.jieling.logic.dao.Hero;
|
||||||
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||||
import config.*;
|
import config.*;
|
||||||
|
@ -359,4 +362,45 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
|
||||||
public Map<Integer, Integer> getType2holy2weight(int type) {
|
public Map<Integer, Integer> getType2holy2weight(int type) {
|
||||||
return type2holy2weight.get(type);
|
return type2holy2weight.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Integer> getType2holy2weightRemoveHas(User user, int type) {
|
||||||
|
// 策划表的圣物,因为会有删除操作,所以需要重新赋值,而不是直接引用
|
||||||
|
Map<Integer, Integer> weight = getType2holy2weight(type);
|
||||||
|
Map<Integer, Integer> valueMap = new HashMap<>(weight);
|
||||||
|
|
||||||
|
// 已拥有的圣物
|
||||||
|
Set<ExpeditionItem> items = user.getExpeditionManager().getPropertyItems();
|
||||||
|
Set<Integer> ids = new HashSet<>();
|
||||||
|
items.forEach(id->ids.add(id.getEquipId()));
|
||||||
|
|
||||||
|
// 已拥有英雄
|
||||||
|
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||||
|
Set<Integer> heroIds = new HashSet<>();
|
||||||
|
heroMap.values().forEach(v->heroIds.add(v.getTemplateId()));
|
||||||
|
|
||||||
|
// 大闹天宫临时英雄
|
||||||
|
Map<String, Hero> expeditonHeroMap = user.getExpeditionManager().getHeroMap();
|
||||||
|
Set<Integer> expeditonHeroIds = new HashSet<>();
|
||||||
|
expeditonHeroMap.values().forEach(v->expeditonHeroIds.add(v.getTemplateId()));
|
||||||
|
|
||||||
|
// 因为有删除操作,所以使用iterator遍历
|
||||||
|
Iterator<Integer> iterator = valueMap.keySet().iterator();
|
||||||
|
while (iterator.hasNext()){
|
||||||
|
Integer v = iterator.next();
|
||||||
|
|
||||||
|
SExpeditionHolyConfig holyConfig = STableManager.getConfig(SExpeditionHolyConfig.class).get(v);
|
||||||
|
// 重复圣物
|
||||||
|
if (ids.contains(v) && holyConfig.getCanRepeat() == 0){
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
// 不存在的英雄,专属圣物
|
||||||
|
if (holyConfig.getHeroId() != 0){
|
||||||
|
if (!heroIds.contains(holyConfig.getHeroId()) || !expeditonHeroIds.contains(holyConfig.getHeroId())){
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return valueMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||||
|
import com.ljsd.jieling.logic.rank.RankLogic;
|
||||||
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
|
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
|
||||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
@ -152,9 +153,9 @@ public class ExpeditionLogic {
|
||||||
}
|
}
|
||||||
itemArrs.add(entry.getValue());
|
itemArrs.add(entry.getValue());
|
||||||
}
|
}
|
||||||
if (itemArrs.size() == 0)
|
if (itemArrs.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
String mailReward = ItemUtil.getMailReward(itemArrs);
|
String mailReward = ItemUtil.getMailReward(itemArrs);
|
||||||
int nowTime = (int) (TimeUtils.now() / 1000);
|
int nowTime = (int) (TimeUtils.now() / 1000);
|
||||||
String title = SErrorCodeEerverConfig.getI18NMessage("expedition_title");
|
String title = SErrorCodeEerverConfig.getI18NMessage("expedition_title");
|
||||||
|
@ -236,10 +237,12 @@ public class ExpeditionLogic {
|
||||||
|
|
||||||
//移除已经删除的hero
|
//移除已经删除的hero
|
||||||
Set<String> removeId = heroHP.keySet().stream().filter(k -> {
|
Set<String> removeId = heroHP.keySet().stream().filter(k -> {
|
||||||
if(heroMap.keySet().contains(k))
|
if(heroMap.keySet().contains(k)) {
|
||||||
return heroMap.get(k).getLevel(user.getHeroManager()) < 20;
|
return heroMap.get(k).getLevel(user.getHeroManager()) < 20;
|
||||||
if(heroMapTemp.keySet().contains(k))
|
}
|
||||||
|
if(heroMapTemp.keySet().contains(k)) {
|
||||||
return heroMapTemp.get(k).getLevel(user.getHeroManager()) < 20;
|
return heroMapTemp.get(k).getLevel(user.getHeroManager()) < 20;
|
||||||
|
}
|
||||||
return !heroMap.keySet().contains(k) && !heroMapTemp.keySet().contains(k);
|
return !heroMap.keySet().contains(k) && !heroMapTemp.keySet().contains(k);
|
||||||
}).collect(Collectors.toSet());
|
}).collect(Collectors.toSet());
|
||||||
removeId.forEach(heroHP::remove);
|
removeId.forEach(heroHP::remove);
|
||||||
|
@ -296,7 +299,7 @@ public class ExpeditionLogic {
|
||||||
private void reSetNode(User user,int leve) throws Exception {
|
private void reSetNode(User user,int leve) throws Exception {
|
||||||
|
|
||||||
//创建节点束河
|
//创建节点束河
|
||||||
Set<ExpeditionNodeInfo> nodeSets = createNodeSet(leve);
|
Set<ExpeditionNodeInfo> nodeSets = createNodeSet(user,leve);
|
||||||
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
||||||
if (sExpeditionSetting == null) {
|
if (sExpeditionSetting == null) {
|
||||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||||
|
@ -304,40 +307,29 @@ public class ExpeditionLogic {
|
||||||
if(leve-1>sExpeditionSetting.getMatchForce().length){
|
if(leve-1>sExpeditionSetting.getMatchForce().length){
|
||||||
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||||
}
|
}
|
||||||
//存储并设置英雄快照
|
|
||||||
|
|
||||||
|
// 万分比
|
||||||
|
double base = 10000d;
|
||||||
|
|
||||||
|
//存储并设置英雄快照
|
||||||
nodeSets.forEach(nodeInfo -> {
|
nodeSets.forEach(nodeInfo -> {
|
||||||
int sortId = nodeInfo.getSortId();
|
int sortId = nodeInfo.getSortId();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(isBattleNode(nodeInfo.getType())){
|
if(isBattleNode(nodeInfo.getType())){
|
||||||
//生成节点boss信息
|
// 上下浮动值
|
||||||
float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(leve);
|
double minFoce = sExpeditionSetting.getMatchForce()[leve-1][0]/base;
|
||||||
//战力基准值=maxforce*0.8+1/15(max-min)*lay)
|
double maxFoce = sExpeditionSetting.getMatchForce()[leve-1][1]/base;
|
||||||
|
// 前六名平均等级
|
||||||
|
int averageLevel = HeroLogic.getInstance().getAverageLevel(user,6);
|
||||||
|
// 随机出来机器人等级
|
||||||
|
int robotLevel = MathUtils.random((int)Math.ceil(averageLevel*minFoce),(int)Math.ceil(averageLevel*maxFoce));
|
||||||
|
// 随机出来的队伍信息
|
||||||
|
List<Integer> randomFaceRankTeam = getRandomFaceRankTeam(user);
|
||||||
|
|
||||||
int minFoce = sExpeditionSetting.getMatchForce()[leve-1][0];
|
|
||||||
int manFoce = sExpeditionSetting.getMatchForce()[leve-1][1];
|
|
||||||
int standerFoce = (int) (user.getPlayerInfoManager().getMaxForce() * ((minFoce / 10000f) + ((float) nodeInfo.getLay()) / 11 * ((float) (manFoce - minFoce)/10000f)));
|
|
||||||
float randomForce = (standerFoce * ((sExpeditionSetting.getMatchForceRange()[0] + (int) (Math.random() * (sExpeditionSetting.getMatchForceRange()[1] - sExpeditionSetting.getMatchForceRange()[0]))) / 10000f));
|
|
||||||
|
|
||||||
if(nodeInfo.getType()==NODETYPE_ADVANCE){
|
|
||||||
randomForce*=(sExpeditionSetting.getPowerfulForce()[1][1]/10000f+1);
|
|
||||||
}else if(nodeInfo.getType()==NODETYPE_BOSS){
|
|
||||||
randomForce*=(sExpeditionSetting.getPowerfulForce()[2][1]/10000f+1);
|
|
||||||
}
|
|
||||||
Set<ZSetOperations.TypedTuple<String>> typedTuples = RedisUtil.getInstence().rangeByScoreWithScores(RedisKey.AREDEF_TEAM_FORCE_RANK, "", 0, randomForce);
|
|
||||||
|
|
||||||
// if (typedTuples.size() == 0) {
|
|
||||||
//战力没有获取到 从机器人中选
|
|
||||||
// Set<Integer> set = ArenaLogic.randomRobot(SArenaSetting.getSArenaSetting().getScore(), 1);
|
|
||||||
//// if (set.size() == 0) {
|
|
||||||
//// throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
|
||||||
//// }
|
|
||||||
// int robotId = set.iterator().next();
|
|
||||||
//提前战力排序 支持战力查找机器人
|
//提前战力排序 支持战力查找机器人
|
||||||
int robotId= SArenaRobotStaticConfig.getFloorForce2robotId((int)randomForce);
|
// SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId);
|
||||||
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId);
|
// snapOneFightInfo(nodeInfo, sArenaRobotConfig);
|
||||||
snapOneFightInfo(nodeInfo, sArenaRobotConfig);
|
|
||||||
// } else {
|
// } else {
|
||||||
// String serarchIdFromRank = typedTuples.iterator().next().getValue();
|
// String serarchIdFromRank = typedTuples.iterator().next().getValue();
|
||||||
// snapOneFightInfo(user, nodeInfo, Integer.valueOf(serarchIdFromRank));
|
// snapOneFightInfo(user, nodeInfo, Integer.valueOf(serarchIdFromRank));
|
||||||
|
@ -356,11 +348,34 @@ public class ExpeditionLogic {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取随机排名的队伍信息
|
||||||
|
* @param user
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public List<Integer> getRandomFaceRankTeam(User user) throws Exception {
|
||||||
|
// 获取随机排名的用户id
|
||||||
|
int uid = RankLogic.getInstance().getRandomByFoceRank(user, 1, 50);
|
||||||
|
|
||||||
|
User other = UserManager.getUser(uid);
|
||||||
|
// 获取其主线队伍阵容
|
||||||
|
List<TeamPosHeroInfo> heroInfos = other.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.FORMATION_NORMAL);
|
||||||
|
|
||||||
|
ArrayList<Integer> integers = new ArrayList<>();
|
||||||
|
heroInfos.forEach(v->{
|
||||||
|
// 获取英雄模板id
|
||||||
|
Hero hero = user.getHeroManager().getHero(v.getHeroId());
|
||||||
|
integers.add(hero.getTemplateId());
|
||||||
|
});
|
||||||
|
|
||||||
|
return integers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取节点结构 确定type id state
|
* 获取节点结构 确定type id state
|
||||||
*/
|
*/
|
||||||
private Set<ExpeditionNodeInfo> createNodeSet(int leve) throws Exception {
|
private Set<ExpeditionNodeInfo> createNodeSet(User user,int leve) throws Exception {
|
||||||
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
|
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
|
||||||
int totalIndex = 1;
|
int totalIndex = 1;
|
||||||
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
|
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
|
||||||
|
@ -368,7 +383,8 @@ public class ExpeditionLogic {
|
||||||
if(ids==null){
|
if(ids==null){
|
||||||
return nodeSets;
|
return nodeSets;
|
||||||
}
|
}
|
||||||
int orDefault = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.getOrDefault(leve-1, 0)-1;//节点
|
//节点
|
||||||
|
int orDefault = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.getOrDefault(leve-1, 0)-1;
|
||||||
|
|
||||||
Map<Integer,Set<Integer>> map = new HashMap<>();
|
Map<Integer,Set<Integer>> map = new HashMap<>();
|
||||||
for (Map.Entry<Integer, Map<Integer,Integer>> integerMapMap :STableManager.getFigureConfig(CommonStaticConfig.class).getType2lay2weight(leve).entrySet()){
|
for (Map.Entry<Integer, Map<Integer,Integer>> integerMapMap :STableManager.getFigureConfig(CommonStaticConfig.class).getType2lay2weight(leve).entrySet()){
|
||||||
|
@ -392,7 +408,7 @@ public class ExpeditionLogic {
|
||||||
//生成随机节点
|
//生成随机节点
|
||||||
if(map.containsKey(lay)){
|
if(map.containsKey(lay)){
|
||||||
for (Integer itemType:map.get(lay)) {
|
for (Integer itemType:map.get(lay)) {
|
||||||
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, itemType);
|
ExpeditionNodeInfo nodeInfo = getNode(user,sExpeditionFloorConfig, itemType);
|
||||||
|
|
||||||
nodeInfo.setLay(lay-orDefault);
|
nodeInfo.setLay(lay-orDefault);
|
||||||
if (nodeInfo.getLay() == 2) {
|
if (nodeInfo.getLay() == 2) {
|
||||||
|
@ -417,7 +433,7 @@ public class ExpeditionLogic {
|
||||||
if (typeArr.length != 2) {
|
if (typeArr.length != 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Set<ExpeditionNodeInfo> tempnode = getNode(sExpeditionFloorConfig, typeArr[0], Math.min(typeArr[1],indexList.size()));
|
Set<ExpeditionNodeInfo> tempnode = getNode(user, sExpeditionFloorConfig, typeArr[0], Math.min(typeArr[1],indexList.size()));
|
||||||
|
|
||||||
tempnode.forEach(nodeInfo -> {
|
tempnode.forEach(nodeInfo -> {
|
||||||
if(indexList.size()==0){
|
if(indexList.size()==0){
|
||||||
|
@ -446,7 +462,7 @@ public class ExpeditionLogic {
|
||||||
if (Math.random() <= 0.3d) {
|
if (Math.random() <= 0.3d) {
|
||||||
type = NODETYPE_ADVANCE;
|
type = NODETYPE_ADVANCE;
|
||||||
}
|
}
|
||||||
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, type);
|
ExpeditionNodeInfo nodeInfo = getNode(user,sExpeditionFloorConfig, type);
|
||||||
nodeInfo.setLay(lay-orDefault);
|
nodeInfo.setLay(lay-orDefault);
|
||||||
if (nodeInfo.getLay() == 2) {
|
if (nodeInfo.getLay() == 2) {
|
||||||
nodeInfo.setState(NODESTATE_NOT_PASS);
|
nodeInfo.setState(NODESTATE_NOT_PASS);
|
||||||
|
@ -460,11 +476,11 @@ public class ExpeditionLogic {
|
||||||
return nodeSets;
|
return nodeSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExpeditionNodeInfo getNode(SExpeditionFloorConfig cfg, int type) throws Exception {
|
private ExpeditionNodeInfo getNode(User user,SExpeditionFloorConfig cfg, int type) throws Exception {
|
||||||
return getNode(cfg, type, 1).iterator().next();
|
return getNode(user, cfg, type, 1).iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<ExpeditionNodeInfo> getNode(SExpeditionFloorConfig cfg, int type, int num) throws Exception {
|
private Set<ExpeditionNodeInfo> getNode(User user, SExpeditionFloorConfig cfg, int type, int num) throws Exception {
|
||||||
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
|
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo();
|
ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo();
|
||||||
|
@ -472,10 +488,6 @@ public class ExpeditionLogic {
|
||||||
|
|
||||||
//生成圣物 設置
|
//生成圣物 設置
|
||||||
if (type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL) {
|
if (type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL) {
|
||||||
// if (cfg.getHolyProbability().length < 3) {
|
|
||||||
// throw new ErrorCodeException(ErrorCode.newDefineCode("随机库配错"));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
Set<Integer> staffsSet = new HashSet<>();
|
Set<Integer> staffsSet = new HashSet<>();
|
||||||
while (staffsSet.size()<3){
|
while (staffsSet.size()<3){
|
||||||
|
@ -491,14 +503,13 @@ public class ExpeditionLogic {
|
||||||
holyProbability[j][1]+= sExpeditionNodeConfig.getHolyProbability()[j][1];
|
holyProbability[j][1]+= sExpeditionNodeConfig.getHolyProbability()[j][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int ints = staffsSet.size()+1;//默认品质
|
int ints;
|
||||||
try {
|
try {
|
||||||
ints = MathUtils.randomFromWeight(holyProbability);
|
ints = MathUtils.randomFromWeight(holyProbability);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
break;
|
break;
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
Map<Integer, Integer> type2holy2weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weight(ints);
|
Map<Integer, Integer> type2holy2weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weightRemoveHas(user,ints);
|
||||||
int i1 = ranndomFromWeight(type2holy2weight);
|
int i1 = ranndomFromWeight(type2holy2weight);
|
||||||
staffsSet.add(i1);
|
staffsSet.add(i1);
|
||||||
}
|
}
|
||||||
|
@ -512,9 +523,6 @@ public class ExpeditionLogic {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点英雄快照
|
* 节点英雄快照
|
||||||
*/
|
*/
|
||||||
|
@ -644,11 +652,6 @@ public class ExpeditionLogic {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isBattleNode(int type) {
|
public static boolean isBattleNode(int type) {
|
||||||
return type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL;
|
return type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -868,9 +871,9 @@ public class ExpeditionLogic {
|
||||||
Set<String> jewelInfo = hero.getJewelInfo();
|
Set<String> jewelInfo = hero.getJewelInfo();
|
||||||
for (String jewel : jewelInfo) {
|
for (String jewel : jewelInfo) {
|
||||||
PropertyItem propertyItem = user.getEquipManager().getEquipMap().get(jewel);
|
PropertyItem propertyItem = user.getEquipManager().getEquipMap().get(jewel);
|
||||||
if (propertyItem == null)
|
if (propertyItem == null) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId());
|
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId());
|
||||||
if(config==null){
|
if(config==null){
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -4316,4 +4316,42 @@ public class HeroLogic{
|
||||||
return !contains;
|
return !contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定英雄数量的平均等级
|
||||||
|
* @param user
|
||||||
|
* @param averageNum
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getAverageLevel(User user, int averageNum){
|
||||||
|
HeroManager heroManager = user.getHeroManager();
|
||||||
|
|
||||||
|
int num = heroManager.getHeroMap().size() > averageNum?averageNum:heroManager.getHeroMap().size();
|
||||||
|
|
||||||
|
// 获取玩家全部英雄
|
||||||
|
Collection<Hero> values = heroManager.getHeroMap().values();
|
||||||
|
List<Hero> heroes = new ArrayList<>(values);
|
||||||
|
|
||||||
|
// 玩家英雄背包按等级排序
|
||||||
|
Collections.sort(heroes, new Comparator<Hero>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Hero hero1, Hero hero2) {
|
||||||
|
int compareValue = hero2.getOriginalLevel() - hero1.getOriginalLevel();
|
||||||
|
if (compareValue != 0) {
|
||||||
|
return compareValue;
|
||||||
|
}
|
||||||
|
return Integer.compare(hero2.getStar(), hero1.getStar());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 等级相加
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
count += heroes.get(i).getLevel(heroManager);
|
||||||
|
}
|
||||||
|
// 避免zero异常
|
||||||
|
if (count == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return num/count;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import config.SSpecialConfig;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import rpc.world.WorldProto;
|
import rpc.world.WorldProto;
|
||||||
|
import util.MathUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -79,6 +80,36 @@ public class RankLogic {
|
||||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),rankResponse,true);
|
MessageUtil.sendMessage(session,1,messageType.getNumber(),rankResponse,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取战力排行榜指定区间的随机玩家信息
|
||||||
|
* @param user
|
||||||
|
* @param start
|
||||||
|
* @param end
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int getRandomByFoceRank(User user,int start,int end) {
|
||||||
|
// 战力排行榜
|
||||||
|
AbstractRank rank = RankContext.getRankEnum(RankEnum.FORCE_CURR_RANK.getType());
|
||||||
|
// 获取排行信息
|
||||||
|
PlayerInfoProto.RankResponse rankResponse = null;
|
||||||
|
try {
|
||||||
|
rankResponse = rank.getRank(user.getId(), "", start, end);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("获取战力排行榜数据错误:{}",e.getMessage());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int random = MathUtils.randomInt(end);
|
||||||
|
int rankSize = rankResponse.getRanksCount();
|
||||||
|
// 随机排名
|
||||||
|
int anInt = random > rankSize?rankSize:random;
|
||||||
|
|
||||||
|
CommonProto.UserRank ranks = rankResponse.getRanks(anInt);
|
||||||
|
return ranks.getUid();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取每个排行第一名信息
|
* 获取每个排行第一名信息
|
||||||
* @param session
|
* @param session
|
||||||
|
|
|
@ -19,14 +19,16 @@ public class SExpeditionHolyConfig implements BaseConfig {
|
||||||
private int passiveSkillId;
|
private int passiveSkillId;
|
||||||
|
|
||||||
private int forceType;
|
private int forceType;
|
||||||
|
// 是否可以重复
|
||||||
|
private int canRepeat;
|
||||||
|
// 专属英雄id,0表示没有
|
||||||
|
private int heroId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -51,5 +53,11 @@ public class SExpeditionHolyConfig implements BaseConfig {
|
||||||
return forceType;
|
return forceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCanRepeat() {
|
||||||
|
return canRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeroId() {
|
||||||
|
return heroId;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
package config;
|
||||||
|
|
||||||
|
import manager.STableManager;
|
||||||
|
import manager.Table;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Table(name ="RobotProperty")
|
||||||
|
public class SRobotProperty implements BaseConfig {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int star;
|
||||||
|
|
||||||
|
private int hp;
|
||||||
|
|
||||||
|
private int attack;
|
||||||
|
|
||||||
|
private int physicalDefence;
|
||||||
|
|
||||||
|
private int magicDefence;
|
||||||
|
|
||||||
|
private float hit;
|
||||||
|
|
||||||
|
private float dodge;
|
||||||
|
|
||||||
|
private float critFactor;
|
||||||
|
|
||||||
|
private float critDamageFactor;
|
||||||
|
|
||||||
|
private float damageBocusFactor;
|
||||||
|
|
||||||
|
private float damageReduceFactor;
|
||||||
|
|
||||||
|
private float cureFacter;
|
||||||
|
|
||||||
|
private float treatFacter;
|
||||||
|
|
||||||
|
private float antiCritDamageFactor;
|
||||||
|
|
||||||
|
private int skillPool;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStar() {
|
||||||
|
return star;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHp() {
|
||||||
|
return hp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAttack() {
|
||||||
|
return attack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPhysicalDefence() {
|
||||||
|
return physicalDefence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMagicDefence() {
|
||||||
|
return magicDefence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getHit() {
|
||||||
|
return hit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDodge() {
|
||||||
|
return dodge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCritFactor() {
|
||||||
|
return critFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCritDamageFactor() {
|
||||||
|
return critDamageFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDamageBocusFactor() {
|
||||||
|
return damageBocusFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDamageReduceFactor() {
|
||||||
|
return damageReduceFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCureFacter() {
|
||||||
|
return cureFacter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTreatFacter() {
|
||||||
|
return treatFacter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getAntiCritDamageFactor() {
|
||||||
|
return antiCritDamageFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSkillPool() {
|
||||||
|
return skillPool;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package config;
|
||||||
|
|
||||||
|
import manager.STableManager;
|
||||||
|
import manager.Table;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Table(name ="RobotSkill")
|
||||||
|
public class SRobotSkill implements BaseConfig {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int heroId;
|
||||||
|
|
||||||
|
private int[] skill;
|
||||||
|
|
||||||
|
private int[][] passiveSkill;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeroId() {
|
||||||
|
return heroId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getSkill() {
|
||||||
|
return skill;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[][] getPassiveSkill() {
|
||||||
|
return passiveSkill;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue