大闹天宫招募

back_recharge
whb 2021-03-05 10:54:42 +08:00
parent 9cc1fd8fc9
commit 0ef63cdd79
4 changed files with 89 additions and 21 deletions

View File

@ -67,6 +67,7 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
Map<String, Hero> heroMapTemp = user.getExpeditionManager().getHeroMapTemp(nodeId); Map<String, Hero> heroMapTemp = user.getExpeditionManager().getHeroMapTemp(nodeId);
if(heroMapTemp.size()==0){ if(heroMapTemp.size()==0){
int poolId = sExpeditionNodeConfig.getPoolId(); int poolId = sExpeditionNodeConfig.getPoolId();
TreeSet<Integer> randomTid = ExpeditionLogic.getRandomTid(poolId, recruitTime); TreeSet<Integer> randomTid = ExpeditionLogic.getRandomTid(poolId, recruitTime);
@ -82,11 +83,13 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
throw new ErrorCodeException("招募节点英雄掉落失败"); throw new ErrorCodeException("招募节点英雄掉落失败");
} }
int level = 200;
int star = 8;
for (Integer integer:randomTid) { for (Integer integer:randomTid) {
SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(integer); SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(integer);
if(sExpeditionRecruitConfig!=null) { if(sExpeditionRecruitConfig!=null) {
int i = sExpeditionRecruitConfig.getHeroId(); int i = sExpeditionRecruitConfig.getHeroId();
ExpeditionLogic.createHero(i, uid, hero, nodeId); ExpeditionLogic.createRandomHero(i, uid, hero, nodeId,level,star);
} }
} }

View File

@ -1,15 +1,14 @@
package com.ljsd.jieling.logic.dao; package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase; import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.logic.activity.event.EquipEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.RemoveHeroEvent;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import config.SExpeditionHolyConfig; import config.SExpeditionHolyConfig;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import java.util.*; import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/** /**
* Description: * Description:

View File

@ -12,12 +12,14 @@ import com.ljsd.jieling.util.UUIDEnum;
import config.SCHero; import config.SCHero;
import config.SCHeroRankUpConfig; import config.SCHeroRankUpConfig;
import config.SEquipConfig; import config.SEquipConfig;
import config.SItem;
import manager.STableManager; import manager.STableManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.*; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Hero extends MongoBase implements Comparable<Hero> { public class Hero extends MongoBase implements Comparable<Hero> {
@ -63,10 +65,10 @@ public class Hero extends MongoBase implements Comparable<Hero> {
this.setRootCollection(User._COLLECTION_NAME); this.setRootCollection(User._COLLECTION_NAME);
this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid); this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid);
this.templateId = heroTid; this.templateId = heroTid;
this.level = initStar; this.level = initStar;//
SCHero hero1 = SCHero.getsCHero().get(heroTid); SCHero hero1 = SCHero.getsCHero().get(heroTid);
int initCfgStar = hero1.getStar(); int initCfgStar = hero1.getStar();
int maxStar = hero1.getMaxRank(); int maxStar = hero1.getMaxRank(); //最高星级
if(hero.getStar()<initCfgStar){ if(hero.getStar()<initCfgStar){
this.star =initCfgStar; this.star =initCfgStar;
}else if(hero.getStar()>maxStar){ }else if(hero.getStar()>maxStar){
@ -92,6 +94,23 @@ public class Hero extends MongoBase implements Comparable<Hero> {
this.especialEquipLevel = hero.especialEquipLevel; this.especialEquipLevel = hero.especialEquipLevel;
this.createType = 1; 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){ public Hero(int uid, int heroTid, int initStar){
this.setRootCollection(User._COLLECTION_NAME); this.setRootCollection(User._COLLECTION_NAME);

View File

@ -952,20 +952,26 @@ public class ExpeditionLogic {
for (Map.Entry<Integer, Integer> next : hero.getEquipByPositionMap().entrySet()) { for (Map.Entry<Integer, Integer> next : hero.getEquipByPositionMap().entrySet()) {
int equipId = next.getValue(); 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); newHero.updateEquipPositionMap(next.getKey(), equipId);
} }
Set<String> jewelInfo = hero.getJewelInfo(); Set<String> 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<String> jewelInfo, User user, SCHero hero1, Hero newHero) throws Exception {
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) {
@ -988,9 +994,10 @@ public class ExpeditionLogic {
// } // }
newHero.addJewel(newequip.getId()); newHero.addJewel(newequip.getId());
} }
}
//添加魂印
Map<Integer, Integer> soulEquipByPositionMap = hero.getSoulEquipByPositionMap(); private static void updateExpenditionSoulEquip(Map<Integer, Integer> soulEquipByPositionMap, User user, Hero newHero, int tempid){
for (Map.Entry<Integer,Integer> entry:soulEquipByPositionMap.entrySet()) { for (Map.Entry<Integer,Integer> entry:soulEquipByPositionMap.entrySet()) {
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(entry.getValue()); SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(entry.getValue());
if (sEquipConfig == null) { if (sEquipConfig == null) {
@ -1013,6 +1020,45 @@ public class ExpeditionLogic {
} }
newHero.updateSoulEquipPositionMap(entry.getKey(),entry.getValue()); 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<Integer, Integer> next : hero.getEquipByPositionMap().entrySet()) {
int equipId = next.getValue();
newHero.updateEquipPositionMap(next.getKey(), equipId);
}
Set<String> jewelInfo = hero.getJewelInfo();
addExpeditionJewel(jewelInfo,user,hero1,newHero);
updateExpenditionSoulEquip(hero.getSoulEquipByPositionMap(),user,newHero,tempid);
if(isTemp){ if(isTemp){
@ -1023,6 +1069,7 @@ public class ExpeditionLogic {
return newHero; return newHero;
} }
public static TreeSet<Integer> getRandomTid(int type,int size)throws ErrorCodeException{ public static TreeSet<Integer> getRandomTid(int type,int size)throws ErrorCodeException{
//select collections //select collections