From 0ef63cdd797dc9bee2b1dd5d2b12d97b926f4d9e Mon Sep 17 00:00:00 2001 From: whb <15647141185@163.com> Date: Fri, 5 Mar 2021 10:54:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E9=97=B9=E5=A4=A9=E5=AE=AB=E6=8B=9B?= =?UTF-8?q?=E5=8B=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HeroNodeGetInfoRequestHandler.java | 5 +- .../jieling/logic/dao/ExpeditionManager.java | 9 ++- .../java/com/ljsd/jieling/logic/dao/Hero.java | 27 ++++++-- .../logic/expedition/ExpeditionLogic.java | 69 ++++++++++++++++--- 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java index 2ce4fc89b..96c871520 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java @@ -67,6 +67,7 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler heroMapTemp = user.getExpeditionManager().getHeroMapTemp(nodeId); + if(heroMapTemp.size()==0){ int poolId = sExpeditionNodeConfig.getPoolId(); TreeSet randomTid = ExpeditionLogic.getRandomTid(poolId, recruitTime); @@ -82,11 +83,13 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler { @@ -63,10 +65,10 @@ public class Hero extends MongoBase implements Comparable { this.setRootCollection(User._COLLECTION_NAME); this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid); this.templateId = heroTid; - this.level = initStar; + this.level = initStar;// SCHero hero1 = SCHero.getsCHero().get(heroTid); int initCfgStar = hero1.getStar(); - int maxStar = hero1.getMaxRank(); + int maxStar = hero1.getMaxRank(); //最高星级 if(hero.getStar()maxStar){ @@ -92,6 +94,23 @@ public class Hero extends MongoBase implements Comparable { this.especialEquipLevel = hero.especialEquipLevel; this.createType = 1; } + //~~~~~ + public Hero(int uid,int heroTid,int level,int star,Hero hero) { + this.setRootCollection(User._COLLECTION_NAME); + this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid); + this.templateId = heroTid; + this.level = level;// + this.star = star; + + this.equipByPositionMap = new HashMap<>(); + // this.soulEquipByPositionMap = hero.soulEquipByPositionMap; + this.soulEquipByPositionMap = new HashMap<>(); + this.breakId = hero.breakId; + this.createTime = (int)(System.currentTimeMillis()/1000); + this.speed = hero.speed; + this.especialEquipLevel = hero.especialEquipLevel; + this.createType = 1; + } public Hero(int uid, int heroTid, int initStar){ this.setRootCollection(User._COLLECTION_NAME); 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 f7096ab92..7d135bfc9 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 @@ -952,20 +952,26 @@ public class ExpeditionLogic { for (Map.Entry next : hero.getEquipByPositionMap().entrySet()) { int equipId = next.getValue(); -// if (equip == null) { -// continue; -// } -//// if(isTemp){ -//// user.getExpeditionManager().addEquipToTemp(user, newequip); -//// }else { -// user.getExpeditionManager().addEquip(user, newequip); -// // } - newHero.updateEquipPositionMap(next.getKey(), equipId); } Set jewelInfo = hero.getJewelInfo(); + + addExpeditionJewel(jewelInfo,user,hero1,newHero); + + updateExpenditionSoulEquip(hero.getSoulEquipByPositionMap(),user,newHero,tempid); + + + if(isTemp){ + user.getExpeditionManager().addHeroToTemp(newHero,nodeId); + }else { + user.getExpeditionManager().addHero(newHero); + } + return newHero; + } + //添加宝物 + private static void addExpeditionJewel(Set jewelInfo, User user, SCHero hero1, Hero newHero) throws Exception { for (String jewel : jewelInfo) { PropertyItem propertyItem = user.getEquipManager().getEquipMap().get(jewel); if (propertyItem == null) { @@ -988,9 +994,10 @@ public class ExpeditionLogic { // } newHero.addJewel(newequip.getId()); } + } - - Map soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); + //添加魂印 + private static void updateExpenditionSoulEquip(Map soulEquipByPositionMap, User user, Hero newHero, int tempid){ for (Map.Entry entry:soulEquipByPositionMap.entrySet()) { SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(entry.getValue()); if (sEquipConfig == null) { @@ -1013,6 +1020,45 @@ public class ExpeditionLogic { } newHero.updateSoulEquipPositionMap(entry.getKey(),entry.getValue()); } + } + + + //~~~~~~~~ + public static Hero createRandomHero(int tempid,int uid,Hero hero,int nodeId,int level,int star)throws Exception{ + + boolean isTemp = nodeId != -1; + User user = UserManager.getUser(uid); + SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1); + if (sExpeditionSetting == null) { + throw new ErrorCodeException(ErrorCode.CFG_NULL); + } + //random star + SCHero hero1 = SCHero.getsCHero().get(tempid); + if (hero1 == null) { + throw new ErrorCodeException(ErrorCode.CFG_NULL); + } + + SCHeroRankUpConfig scHeroRankUpConfig = STableManager.getConfig(SCHeroRankUpConfig.class).get(star); + if (null != scHeroRankUpConfig && level > scHeroRankUpConfig.getOpenLevel()) { + level = scHeroRankUpConfig.getOpenLevel(); + } + + + //random tempid + Hero newHero = new Hero(uid,tempid,level,star,hero); + + + for (Map.Entry next : hero.getEquipByPositionMap().entrySet()) { + int equipId = next.getValue(); + newHero.updateEquipPositionMap(next.getKey(), equipId); + } + + + Set jewelInfo = hero.getJewelInfo(); + + addExpeditionJewel(jewelInfo,user,hero1,newHero); + + updateExpenditionSoulEquip(hero.getSoulEquipByPositionMap(),user,newHero,tempid); if(isTemp){ @@ -1023,6 +1069,7 @@ public class ExpeditionLogic { return newHero; } + public static TreeSet getRandomTid(int type,int size)throws ErrorCodeException{ //select collections