diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/CommonStaticConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/CommonStaticConfig.java index a917ccc48..33fbedaff 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/CommonStaticConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/CommonStaticConfig.java @@ -363,44 +363,4 @@ public class CommonStaticConfig extends AbstractClassStaticConfig { return type2holy2weight.get(type); } - public Map getType2holy2weightRemoveHas(User user, int type) { - // 策划表的圣物,因为会有删除操作,所以需要重新赋值,而不是直接引用 - Map weight = getType2holy2weight(type); - Map valueMap = new HashMap<>(weight); - - // 已拥有的圣物 - Set items = user.getExpeditionManager().getPropertyItems(); - Set ids = new HashSet<>(); - items.forEach(id->ids.add(id.getEquipId())); - - // 已拥有英雄 - Map heroMap = user.getHeroManager().getHeroMap(); - Set heroIds = new HashSet<>(); - heroMap.values().forEach(v->heroIds.add(v.getTemplateId())); - - // 大闹天宫临时英雄 - Map expeditonHeroMap = user.getExpeditionManager().getHeroMap(); - Set expeditonHeroIds = new HashSet<>(); - expeditonHeroMap.values().forEach(v->expeditonHeroIds.add(v.getTemplateId())); - - // 因为有删除操作,所以使用iterator遍历 - Iterator 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; - } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java index 24be637de..2effcd9df 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java @@ -21,7 +21,10 @@ import com.ljsd.jieling.logic.hero.HeroAttributeEnum; import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.mail.MailLogic; import com.ljsd.jieling.logic.mission.GameEvent; +import com.ljsd.jieling.logic.rank.RankContext; +import com.ljsd.jieling.logic.rank.RankEnum; import com.ljsd.jieling.logic.rank.RankLogic; +import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; import com.ljsd.jieling.logic.store.BuyGoodsLogic; import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.network.session.ISession; @@ -34,6 +37,7 @@ import manager.STableManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.core.ZSetOperations; +import rpc.protocols.PlayerInfoProto; import util.MathUtils; import util.TimeUtils; @@ -311,33 +315,41 @@ public class ExpeditionLogic { // 万分比 double base = 10000d; - //存储并设置英雄快照 - nodeSets.forEach(nodeInfo -> { - int sortId = nodeInfo.getSortId(); - try { + // 上下浮动值 + double minFoce = sExpeditionSetting.getMatchForce()[leve-1][0]/base; + double maxFoce = sExpeditionSetting.getMatchForce()[leve-1][1]/base; + //存储并设置英雄快照 + for (ExpeditionNodeInfo nodeInfo : nodeSets) { + try { + // 战斗节点进入 if(isBattleNode(nodeInfo.getType())){ - // 上下浮动值 - double minFoce = sExpeditionSetting.getMatchForce()[leve-1][0]/base; - 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)); + // 随机出来机器人等级,(【向上取整】基础等级 *(最低浮动 + (当前节点位置 / 总层数 *(最高浮动-最低浮动)))) + int robotLevel = (int) Math.ceil(averageLevel * (minFoce + (nodeInfo.getLay() / 11d * (maxFoce - minFoce)))); + + if (nodeInfo.getType() == NODETYPE_ADVANCE){ + // 精英节点 + robotLevel += (Math.ceil(sExpeditionSetting.getPowerfulForce()[1][1]/base*robotLevel)); + }else if (nodeInfo.getType() == NODETYPE_BOSS){ + // boss节点 + robotLevel += (Math.ceil(sExpeditionSetting.getPowerfulForce()[2][1]/base*robotLevel)); + } // 随机出来的队伍信息 List randomFaceRankTeam = getRandomFaceRankTeam(user); // 节点英雄快照 snapOneFightInfo(nodeInfo,randomFaceRankTeam,robotLevel); } // boss节点 - if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType() ==ExpeditionLogic.NODETYPE_TRY){ + if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType()==ExpeditionLogic.NODETYPE_TRY){ snapOneFightInfo(nodeInfo); } } catch (Exception e) { e.printStackTrace(); } - user.getExpeditionManager().putExpeditionNodeInfos(sortId, nodeInfo); - }); + user.getExpeditionManager().putExpeditionNodeInfos(nodeInfo.getSortId(), nodeInfo); + } } /** @@ -347,14 +359,52 @@ public class ExpeditionLogic { * @throws Exception */ private List getRandomFaceRankTeam(User user) throws Exception { - // 获取随机排名的用户id - int uid = RankLogic.getInstance().getRandomByFoceRank(user, 1, 50); - - User other = UserManager.getUser(uid); - // 获取其主线队伍阵容 - List heroInfos = other.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.FORMATION_NORMAL); + // 战力排行榜 + AbstractRank rank = RankContext.getRankEnum(RankEnum.FORCE_CURR_RANK.getType()); + // 获取排行信息 + PlayerInfoProto.RankResponse rankResponse = null; + try { + rankResponse = rank.getRank(user.getId(), "", 1, 50); + } catch (Exception e) { + throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"获取战力排行榜数据错误"); + } + List heroInfos = new ArrayList<>(); ArrayList integers = new ArrayList<>(); + // -1方便后面取值操作,防止下标越界异常 + int rankSize = rankResponse.getRanksCount()-1; + if (rankSize < 0){ + throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"战力排行榜找不到人"); + } + // 计数器 + int count = 0; + do { + // 从0开始的随机 + int random = MathUtils.randomInt(50); + // 随机排名 + int anInt = random > rankSize?rankSize:random; + + CommonProto.UserRank ranks = rankResponse.getRanks(anInt); + User other = UserManager.getUser(ranks.getUid()); + // 获取随机玩家的主线队伍阵容 + heroInfos = other.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.FORMATION_NORMAL); + if (heroInfos.size() < 6){ + count++; + }else { + heroInfos.forEach(v->{ + // 获取英雄模板id + Hero hero = other.getHeroManager().getHero(v.getHeroId()); + integers.add(hero.getTemplateId()); + }); + return integers; + } + }while (count < 5); + + // 走到这里说明五次循环全部不足6个英雄,直接取第一名的队伍 + CommonProto.UserRank ranks = rankResponse.getRanks(0); + User other = UserManager.getUser(ranks.getUid()); + // 获取随机玩家的主线队伍阵容 + heroInfos = other.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.FORMATION_NORMAL); heroInfos.forEach(v->{ // 获取英雄模板id Hero hero = other.getHeroManager().getHero(v.getHeroId()); @@ -501,7 +551,7 @@ public class ExpeditionLogic { }catch (Exception e){ break; } - Map type2holy2weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weightRemoveHas(user,ints); + Map type2holy2weight = getType2holy2weightRemoveHas(user,ints); int i1 = ranndomFromWeight(type2holy2weight); staffsSet.add(i1); } @@ -578,26 +628,21 @@ public class ExpeditionLogic { Map bossHP = new HashMap<>(); // 获取对应等级的机器人信息 SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level); + // 英雄属性 + Map robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(property); - // 自增标识 - int innerPosition= 1; + // 位置坐标 + int innerPosition = 1; // 战力 int force = 0; for (Integer id : heroIds) { - SCHero scHero = SCHero.getsCHero().get(id); // 获取技能列表,包含主动和被动技能 - String skills = SRobotSkill.getSkills(id, property.getSkillPool()); + String skills = SRobotSkill.getSkills(id, property.getSkillPool()-1); fightInfo.updateHeroSkill(id.toString(), skills.substring(0, skills.length() - 1)); // 需要赋值 bossHP.put(id.toString(), 1D); - // 空值初始化 - int[] differDemonsId = null; - int differDemonsLv = 0; - // 英雄属性 - Map robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(scHero, level, 0, differDemonsId, differDemonsLv, false); force+=HeroLogic.getInstance().calForce(robotHeroAttribute); - heroAllAttribute.put(id.toString(), new FamilyHeroInfo(id, level, property.getStar(), robotHeroAttribute,innerPosition++)); } @@ -869,8 +914,8 @@ public class ExpeditionLogic { */ public static Hero createHero(int tempid,int uid,Hero hero,int nodeId)throws Exception{ boolean isTemp = nodeId != -1; - int star = hero.getOriginalLevel(); User user = UserManager.getUser(uid); + int level = HeroLogic.getInstance().getAverageLevel(user,6); SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1); if (sExpeditionSetting == null) { throw new ErrorCodeException(ErrorCode.CFG_NULL); @@ -878,9 +923,9 @@ public class ExpeditionLogic { //random star int min = sExpeditionSetting.getLevelForce()[0]; int max= sExpeditionSetting.getLevelForce()[1]; - int finalstar = (int) (star * ((min / 10000f) + ((float) (Math.random() *(max - min))/10000f))); - if(finalstar<=20){ - finalstar=50; + int finalLevel = (int) (level * ((min / 10000f) + ((float) (Math.random() *(max - min))/10000f))); + if(finalLevel<=20){ + finalLevel=50; } SCHero hero1 = SCHero.getsCHero().get(tempid); if (hero1 == null) { @@ -888,14 +933,14 @@ public class ExpeditionLogic { } SCHeroRankUpConfig scHeroRankUpConfig = STableManager.getConfig(SCHeroRankUpConfig.class).get(hero1.getStar()); - if (null != scHeroRankUpConfig && finalstar > scHeroRankUpConfig.getOpenLevel()) { - finalstar = scHeroRankUpConfig.getOpenLevel(); + if (null != scHeroRankUpConfig && finalLevel > scHeroRankUpConfig.getOpenLevel()) { + finalLevel = scHeroRankUpConfig.getOpenLevel(); } //random tempid - Hero newHero = new Hero(uid,tempid,finalstar,hero); + Hero newHero = new Hero(uid,tempid,finalLevel,hero); for (Map.Entry next : hero.getEquipByPositionMap().entrySet()) { int equipId = next.getValue(); @@ -1129,4 +1174,45 @@ public class ExpeditionLogic { MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); } + + public Map getType2holy2weightRemoveHas(User user, int type) { + // 策划表的圣物,因为会有删除操作,所以需要重新赋值,而不是直接引用 + Map weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weight(type); + Map valueMap = new HashMap<>(weight); + + // 已拥有的圣物 + Set items = user.getExpeditionManager().getPropertyItems(); + Set ids = new HashSet<>(); + items.forEach(id->ids.add(id.getEquipId())); + + // 已拥有英雄 + Map heroMap = user.getHeroManager().getHeroMap(); + Set heroIds = new HashSet<>(); + heroMap.values().forEach(v->heroIds.add(v.getTemplateId())); + + // 大闹天宫临时英雄 + Map expeditonHeroMap = user.getExpeditionManager().getHeroMap(); + Set expeditonHeroIds = new HashSet<>(); + expeditonHeroMap.values().forEach(v->expeditonHeroIds.add(v.getTemplateId())); + + // 因为有删除操作,所以使用iterator遍历 + Iterator 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; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 96634826a..a578b7779 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -1995,6 +1995,17 @@ public class HeroLogic{ return heroAllAttribute; } + public Map calRobotHeroAttribute(SRobotProperty property){ + int[][] property1 = property.getProperty(); + if (property1 == null){ + return new HashMap<>(); + } + Map attribute = new HashMap<>(property1.length); + for (int[] anInt : property1) { + attribute.put(anInt[0],anInt[1]); + } + return attribute; + } /** * 属性数值计算 @@ -4333,15 +4344,12 @@ public class HeroLogic{ List heroes = new ArrayList<>(values); // 玩家英雄背包按等级排序 - Collections.sort(heroes, new Comparator() { - @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()); + Collections.sort(heroes, (hero1, hero2) -> { + int compareValue = hero2.getOriginalLevel() - hero1.getOriginalLevel(); + if (compareValue != 0) { + return compareValue; } + return Integer.compare(hero2.getStar(), hero1.getStar()); }); // 等级相加 int count = 0; @@ -4349,7 +4357,7 @@ public class HeroLogic{ count += heroes.get(i).getLevel(heroManager); } // 避免zero异常 - if (count == 0 || num == 0){ + if (count == 0){ throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE); } return count/num; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java index d1e24e1a9..3f9699315 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java @@ -1,11 +1,13 @@ package com.ljsd.jieling.logic.rank; +import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.exception.ErrorCode; import com.ljsd.jieling.exception.ErrorCodeException; import com.ljsd.jieling.globals.BIReason; import com.ljsd.jieling.ktbeans.ReportEventEnum; import com.ljsd.jieling.ktbeans.ReportUtil; import com.ljsd.jieling.logic.dao.PlayerManager; +import com.ljsd.jieling.logic.dao.TeamPosHeroInfo; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; @@ -23,6 +25,7 @@ import org.slf4j.LoggerFactory; import rpc.world.WorldProto; import util.MathUtils; +import java.util.ArrayList; import java.util.List; /** @@ -80,36 +83,6 @@ public class RankLogic { 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)+1; - int rankSize = rankResponse.getRanksCount(); - // 随机排名 - int anInt = random > rankSize?rankSize:random; - - CommonProto.UserRank ranks = rankResponse.getRanks(anInt-1); - return ranks.getUid(); - } - /** * 获取每个排行第一名信息 * @param session diff --git a/tablemanager/src/main/java/config/SRobotProperty.java b/tablemanager/src/main/java/config/SRobotProperty.java index 777db6e73..45e36b4a1 100644 --- a/tablemanager/src/main/java/config/SRobotProperty.java +++ b/tablemanager/src/main/java/config/SRobotProperty.java @@ -12,31 +12,7 @@ public class SRobotProperty implements BaseConfig { 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[][] property; private int skillPool; @@ -55,56 +31,8 @@ public class SRobotProperty implements BaseConfig { 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[][] getProperty() { + return property; } public int getSkillPool() {