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 17f25ff97..24be637de 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 @@ -302,10 +302,10 @@ public class ExpeditionLogic { Set nodeSets = createNodeSet(user,leve); SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1); if (sExpeditionSetting == null) { - throw new ErrorCodeException(ErrorCode.CFG_NULL); + throw new ErrorCodeException(ErrorCode.CFG_NULL,"配置表错误,获取数据为空"); } if(leve-1>sExpeditionSetting.getMatchForce().length){ - throw new ErrorCodeException(ErrorCode.UNKNOWN); + throw new ErrorCodeException(ErrorCode.UNKNOWN,"大闹天宫层数错误"); } // 万分比 @@ -326,25 +326,17 @@ public class ExpeditionLogic { int robotLevel = MathUtils.random((int)Math.ceil(averageLevel*minFoce),(int)Math.ceil(averageLevel*maxFoce)); // 随机出来的队伍信息 List randomFaceRankTeam = getRandomFaceRankTeam(user); - - //提前战力排序 支持战力查找机器人 -// SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId); -// snapOneFightInfo(nodeInfo, sArenaRobotConfig); - // } else { - // String serarchIdFromRank = typedTuples.iterator().next().getValue(); - // snapOneFightInfo(user, nodeInfo, Integer.valueOf(serarchIdFromRank)); - // } + // 节点英雄快照 + snapOneFightInfo(nodeInfo,randomFaceRankTeam,robotLevel); } - + // boss节点 if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType() ==ExpeditionLogic.NODETYPE_TRY){ snapOneFightInfo(nodeInfo); } - } catch (Exception e) { e.printStackTrace(); } user.getExpeditionManager().putExpeditionNodeInfos(sortId, nodeInfo); - }); } @@ -354,7 +346,7 @@ public class ExpeditionLogic { * @return * @throws Exception */ - public List getRandomFaceRankTeam(User user) throws Exception { + private List getRandomFaceRankTeam(User user) throws Exception { // 获取随机排名的用户id int uid = RankLogic.getInstance().getRandomByFoceRank(user, 1, 50); @@ -365,7 +357,7 @@ public class ExpeditionLogic { ArrayList integers = new ArrayList<>(); heroInfos.forEach(v->{ // 获取英雄模板id - Hero hero = user.getHeroManager().getHero(v.getHeroId()); + Hero hero = other.getHeroManager().getHero(v.getHeroId()); integers.add(hero.getTemplateId()); }); @@ -567,6 +559,58 @@ public class ExpeditionLogic { } + /** + * 新版2021-2-25,节点英雄快照 + * @param nodeInfo + * @param heroIds + * @param level + */ + private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo, List heroIds, int level) { + // 非战斗节点类型 + if (!isBattleNode(nodeInfo.getType())) { + return; + } + + SnapFightInfo fightInfo = new SnapFightInfo(); + // 英雄列表 + Map heroAllAttribute = new HashMap<>(); + // boss血量,这里无用 + Map bossHP = new HashMap<>(); + // 获取对应等级的机器人信息 + SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level); + + // 自增标识 + int innerPosition= 1; + // 战力 + int force = 0; + + for (Integer id : heroIds) { + SCHero scHero = SCHero.getsCHero().get(id); + // 获取技能列表,包含主动和被动技能 + String skills = SRobotSkill.getSkills(id, property.getSkillPool()); + 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++)); + } + + fightInfo.setForce(force); + fightInfo.setPokenmonSkills(""); + fightInfo.setPassiveSkills(""); + fightInfo.setUid(property.getId()); + fightInfo.setHeroAttribute(heroAllAttribute); + nodeInfo.setSnapFightInfo(fightInfo); + + nodeInfo.setBossHP(bossHP); + } + private void snapOneFightInfo(User self, ExpeditionNodeInfo nodeInfo, int defid) throws Exception { int snapTeamId = GlobalsDef.TEAM_ARENA_DEFENSE; @@ -1011,7 +1055,7 @@ public class ExpeditionLogic { } StringBuilder skillSb = new StringBuilder(); StringBuilder propertySb = new StringBuilder(); - HeroLogic.getInstance().getHeroSkills(user,hero,skillSb).toString(); + HeroLogic.getInstance().getHeroSkills(user,hero,skillSb); if(teamId==GlobalsDef.EXPEDITION_TEAM){ ExpeditionManager expeditionManager = user.getExpeditionManager(); 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 34275c37a..96634826a 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 @@ -32,6 +32,7 @@ import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.network.server.ProtocolsManager; import com.ljsd.jieling.network.session.ISession; +import com.sun.jndi.cosnaming.ExceptionMapper; import rpc.protocols.CommonProto; import rpc.protocols.HeroInfoProto; import rpc.protocols.MapInfoProto; @@ -4322,7 +4323,7 @@ public class HeroLogic{ * @param averageNum * @return */ - public int getAverageLevel(User user, int averageNum){ + public int getAverageLevel(User user, int averageNum) throws ErrorCodeException { HeroManager heroManager = user.getHeroManager(); int num = heroManager.getHeroMap().size() > averageNum?averageNum:heroManager.getHeroMap().size(); @@ -4348,10 +4349,10 @@ public class HeroLogic{ count += heroes.get(i).getLevel(heroManager); } // 避免zero异常 - if (count == 0){ - return 0; + if (count == 0 || num == 0){ + throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE); } - return num/count; + 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 3147b072e..d1e24e1a9 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 @@ -101,12 +101,12 @@ public class RankLogic { return 0; } - int random = MathUtils.randomInt(end); + int random = MathUtils.randomInt(end)+1; int rankSize = rankResponse.getRanksCount(); // 随机排名 int anInt = random > rankSize?rankSize:random; - CommonProto.UserRank ranks = rankResponse.getRanks(anInt); + CommonProto.UserRank ranks = rankResponse.getRanks(anInt-1); return ranks.getUid(); } diff --git a/tablemanager/src/main/java/config/SRobotSkill.java b/tablemanager/src/main/java/config/SRobotSkill.java index 70617feb8..6d61d842e 100644 --- a/tablemanager/src/main/java/config/SRobotSkill.java +++ b/tablemanager/src/main/java/config/SRobotSkill.java @@ -3,6 +3,8 @@ package config; import manager.STableManager; import manager.Table; +import java.util.Collection; +import java.util.HashMap; import java.util.Map; @Table(name ="RobotSkill") @@ -15,10 +17,14 @@ public class SRobotSkill implements BaseConfig { private int[] skill; private int[][] passiveSkill; + + private static Map skillMap; @Override public void init() throws Exception { - + Map config = STableManager.getConfig(SRobotSkill.class); + skillMap = new HashMap<>(); + config.forEach((k,v)->skillMap.put(v.getHeroId(),v)); } @@ -38,5 +44,24 @@ public class SRobotSkill implements BaseConfig { return passiveSkill; } + /** + * 根据英雄id和下标id获取几技能 + * @param heroTid + * @param index + * @return + */ + public static String getSkills(int heroTid, int index){ + StringBuilder builder = new StringBuilder(); + SRobotSkill robotSkill = skillMap.get(heroTid); + // 主动技能 + for (int i : robotSkill.getSkill()) { + builder.append(i).append("#"); + } + // 被动技能 + for (int i : robotSkill.getPassiveSkill()[index]) { + builder.append(i).append("#"); + } + return builder.toString(); + } } \ No newline at end of file