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 b23322fe2..a917ccc48 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 @@ -2,6 +2,9 @@ package com.ljsd.jieling.config.clazzStaticCfg; import com.ljsd.GameApplication; 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.hero.HeroLogic; import config.*; @@ -356,7 +359,48 @@ public class CommonStaticConfig extends AbstractClassStaticConfig { return type2lay2weight.getOrDefault(floor,new HashMap<>()); } - public Map getType2holy2weight(int type) { + public Map getType2holy2weight(int type) { 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 78c191f53..17f25ff97 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,6 +21,7 @@ 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.RankLogic; import com.ljsd.jieling.logic.store.BuyGoodsLogic; import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.network.session.ISession; @@ -152,9 +153,9 @@ public class ExpeditionLogic { } itemArrs.add(entry.getValue()); } - if (itemArrs.size() == 0) + if (itemArrs.size() == 0) { return; - + } String mailReward = ItemUtil.getMailReward(itemArrs); int nowTime = (int) (TimeUtils.now() / 1000); String title = SErrorCodeEerverConfig.getI18NMessage("expedition_title"); @@ -236,10 +237,12 @@ public class ExpeditionLogic { //移除已经删除的hero Set removeId = heroHP.keySet().stream().filter(k -> { - if(heroMap.keySet().contains(k)) - return heroMap.get(k).getLevel(user.getHeroManager())<20; - if(heroMapTemp.keySet().contains(k)) - return heroMapTemp.get(k).getLevel(user.getHeroManager())<20; + if(heroMap.keySet().contains(k)) { + return heroMap.get(k).getLevel(user.getHeroManager()) < 20; + } + if(heroMapTemp.keySet().contains(k)) { + return heroMapTemp.get(k).getLevel(user.getHeroManager()) < 20; + } return !heroMap.keySet().contains(k) && !heroMapTemp.keySet().contains(k); }).collect(Collectors.toSet()); removeId.forEach(heroHP::remove); @@ -296,7 +299,7 @@ public class ExpeditionLogic { private void reSetNode(User user,int leve) throws Exception { //创建节点束河 - Set nodeSets = createNodeSet(leve); + Set nodeSets = createNodeSet(user,leve); SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1); if (sExpeditionSetting == null) { throw new ErrorCodeException(ErrorCode.CFG_NULL); @@ -304,40 +307,29 @@ public class ExpeditionLogic { if(leve-1>sExpeditionSetting.getMatchForce().length){ throw new ErrorCodeException(ErrorCode.UNKNOWN); } - //存储并设置英雄快照 + // 万分比 + double base = 10000d; + + //存储并设置英雄快照 nodeSets.forEach(nodeInfo -> { int sortId = nodeInfo.getSortId(); try { if(isBattleNode(nodeInfo.getType())){ - //生成节点boss信息 - float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(leve); - //战力基准值=maxforce*0.8+1/15(max-min)*lay) + // 上下浮动值 + 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)); + // 随机出来的队伍信息 + List 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> typedTuples = RedisUtil.getInstence().rangeByScoreWithScores(RedisKey.AREDEF_TEAM_FORCE_RANK, "", 0, randomForce); - - // if (typedTuples.size() == 0) { - //战力没有获取到 从机器人中选 -// Set 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); - snapOneFightInfo(nodeInfo, sArenaRobotConfig); +// SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId); +// snapOneFightInfo(nodeInfo, sArenaRobotConfig); // } else { // String serarchIdFromRank = typedTuples.iterator().next().getValue(); // snapOneFightInfo(user, nodeInfo, Integer.valueOf(serarchIdFromRank)); @@ -356,11 +348,34 @@ public class ExpeditionLogic { }); } + /** + * 获取随机排名的队伍信息 + * @param user + * @return + * @throws Exception + */ + public 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); + + ArrayList integers = new ArrayList<>(); + heroInfos.forEach(v->{ + // 获取英雄模板id + Hero hero = user.getHeroManager().getHero(v.getHeroId()); + integers.add(hero.getTemplateId()); + }); + + return integers; + } /** * 获取节点结构 确定type id state */ - private Set createNodeSet(int leve) throws Exception { + private Set createNodeSet(User user,int leve) throws Exception { Map config = STableManager.getConfig(SExpeditionFloorConfig.class); int totalIndex = 1; Set nodeSets = new HashSet<>(); @@ -368,7 +383,8 @@ public class ExpeditionLogic { if(ids==null){ 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> map = new HashMap<>(); for (Map.Entry> integerMapMap :STableManager.getFigureConfig(CommonStaticConfig.class).getType2lay2weight(leve).entrySet()){ @@ -392,7 +408,7 @@ public class ExpeditionLogic { //生成随机节点 if(map.containsKey(lay)){ for (Integer itemType:map.get(lay)) { - ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, itemType); + ExpeditionNodeInfo nodeInfo = getNode(user,sExpeditionFloorConfig, itemType); nodeInfo.setLay(lay-orDefault); if (nodeInfo.getLay() == 2) { @@ -417,7 +433,7 @@ public class ExpeditionLogic { if (typeArr.length != 2) { continue; } - Set tempnode = getNode(sExpeditionFloorConfig, typeArr[0], Math.min(typeArr[1],indexList.size())); + Set tempnode = getNode(user, sExpeditionFloorConfig, typeArr[0], Math.min(typeArr[1],indexList.size())); tempnode.forEach(nodeInfo -> { if(indexList.size()==0){ @@ -446,7 +462,7 @@ public class ExpeditionLogic { if (Math.random() <= 0.3d) { type = NODETYPE_ADVANCE; } - ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, type); + ExpeditionNodeInfo nodeInfo = getNode(user,sExpeditionFloorConfig, type); nodeInfo.setLay(lay-orDefault); if (nodeInfo.getLay() == 2) { nodeInfo.setState(NODESTATE_NOT_PASS); @@ -460,11 +476,11 @@ public class ExpeditionLogic { return nodeSets; } - private ExpeditionNodeInfo getNode(SExpeditionFloorConfig cfg, int type) throws Exception { - return getNode(cfg, type, 1).iterator().next(); + private ExpeditionNodeInfo getNode(User user,SExpeditionFloorConfig cfg, int type) throws Exception { + return getNode(user, cfg, type, 1).iterator().next(); } - private Set getNode(SExpeditionFloorConfig cfg, int type, int num) throws Exception { + private Set getNode(User user, SExpeditionFloorConfig cfg, int type, int num) throws Exception { Set nodeSets = new HashSet<>(); for (int i = 0; i < num; i++) { ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo(); @@ -472,10 +488,6 @@ public class ExpeditionLogic { //生成圣物 設置 if (type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL) { -// if (cfg.getHolyProbability().length < 3) { -// throw new ErrorCodeException(ErrorCode.newDefineCode("随机库配错")); -// } - Set staffsSet = new HashSet<>(); while (staffsSet.size()<3){ @@ -491,14 +503,13 @@ public class ExpeditionLogic { holyProbability[j][1]+= sExpeditionNodeConfig.getHolyProbability()[j][1]; } } - int ints = staffsSet.size()+1;//默认品质 + int ints; try { ints = MathUtils.randomFromWeight(holyProbability); }catch (Exception e){ break; - // e.printStackTrace(); } - Map type2holy2weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weight(ints); + Map type2holy2weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weightRemoveHas(user,ints); int i1 = ranndomFromWeight(type2holy2weight); staffsSet.add(i1); } @@ -512,9 +523,6 @@ public class ExpeditionLogic { } - - - /** * 节点英雄快照 */ @@ -644,11 +652,6 @@ public class ExpeditionLogic { } - - - - - public static boolean isBattleNode(int type) { return type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL; } @@ -868,9 +871,9 @@ public class ExpeditionLogic { Set jewelInfo = hero.getJewelInfo(); for (String jewel : jewelInfo) { PropertyItem propertyItem = user.getEquipManager().getEquipMap().get(jewel); - if (propertyItem == null) + if (propertyItem == null) { continue; - + } SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId()); if(config==null){ continue; 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 9fdebe04c..34275c37a 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 @@ -4316,4 +4316,42 @@ public class HeroLogic{ 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 values = heroManager.getHeroMap().values(); + 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()); + } + }); + // 等级相加 + 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; + } + } 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 c9f78917d..3147b072e 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 @@ -21,6 +21,7 @@ import config.SSpecialConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import rpc.world.WorldProto; +import util.MathUtils; import java.util.List; @@ -79,6 +80,36 @@ 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); + int rankSize = rankResponse.getRanksCount(); + // 随机排名 + int anInt = random > rankSize?rankSize:random; + + CommonProto.UserRank ranks = rankResponse.getRanks(anInt); + return ranks.getUid(); + } + /** * 获取每个排行第一名信息 * @param session diff --git a/tablemanager/src/main/java/config/SExpeditionHolyConfig.java b/tablemanager/src/main/java/config/SExpeditionHolyConfig.java index 85d3c74ac..3c2523439 100644 --- a/tablemanager/src/main/java/config/SExpeditionHolyConfig.java +++ b/tablemanager/src/main/java/config/SExpeditionHolyConfig.java @@ -19,14 +19,16 @@ public class SExpeditionHolyConfig implements BaseConfig { private int passiveSkillId; private int forceType; - + // 是否可以重复 + private int canRepeat; + // 专属英雄id,0表示没有 + private int heroId; @Override public void init() throws Exception { } - public int getId() { return id; } @@ -51,5 +53,11 @@ public class SExpeditionHolyConfig implements BaseConfig { return forceType; } + public int getCanRepeat() { + return canRepeat; + } + public int getHeroId() { + return heroId; + } } \ No newline at end of file diff --git a/tablemanager/src/main/java/config/SRobotProperty.java b/tablemanager/src/main/java/config/SRobotProperty.java new file mode 100644 index 000000000..777db6e73 --- /dev/null +++ b/tablemanager/src/main/java/config/SRobotProperty.java @@ -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; + } + + +} \ No newline at end of file diff --git a/tablemanager/src/main/java/config/SRobotSkill.java b/tablemanager/src/main/java/config/SRobotSkill.java new file mode 100644 index 000000000..70617feb8 --- /dev/null +++ b/tablemanager/src/main/java/config/SRobotSkill.java @@ -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; + } + + +} \ No newline at end of file