猎妖和数据库检查bug

back_recharge
zhangshanxue 2020-05-28 11:28:57 +08:00
parent 5ef80fab01
commit 79daca78ee
12 changed files with 575 additions and 91 deletions

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Ldb >
<Jbean name="ActivityProgressInfo">
<Variable name="state" type="int"/>
<Variable name="progrss" type="int"/>

View File

@ -1,9 +1,7 @@
package com.ljsd.jieling.db.mongo;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.gson.*;
import com.ljsd.common.mogodb.LjsdMongoTemplate;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.root.User;
@ -23,6 +21,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.net.UnknownHostException;
import java.util.*;
@ -51,8 +50,8 @@ public class MongoUtil {
private MongoTemplate coreMongoTemplate;
public void init(){
myMongoTemplate = ConfigurableApplicationContextManager.getBean(LjsdMongoTemplate.class);
public void init() {
myMongoTemplate = ConfigurableApplicationContextManager.getBean(LjsdMongoTemplate.class);
coreMongoTemplate = (MongoTemplate) ConfigurableApplicationContextManager.getBean("coreMongoTemplate");
}
@ -64,11 +63,12 @@ public class MongoUtil {
this.myMongoTemplate.lastUpdate();
}
public static LjsdMongoTemplate getLjsdMongoTemplate() throws UnknownHostException {
return MongoUtil.getInstence().getMyMongoTemplate();
public static LjsdMongoTemplate getLjsdMongoTemplate() throws UnknownHostException {
return MongoUtil.getInstence().getMyMongoTemplate();
}
public List<User> getRandomUsers(int size, int uid, int level) throws Exception {
if(size <= 0){
public List<User> getRandomUsers(int size, int uid, int level) throws Exception {
if (size <= 0) {
return null;
}
int randomLevel = MathUtils.random(5, 20);
@ -81,15 +81,16 @@ public class MongoUtil {
criatira.andOperator(Criteria.where("id").nin(uid),
Criteria.where("playerManager.level").gte(minLevel), Criteria.where("playerManager.level").lte(maxLevel),
Criteria.where("playerManager.loginTime").gte(befor3Day));//不包含自己
Query query = new Query(criatira).limit(size*2+1);
Query query = new Query(criatira).limit(size * 2 + 1);
query.fields().include("playerManager");
return this.myMongoTemplate.findAllByCondition(query, User.class) ;
return this.myMongoTemplate.findAllByCondition(query, User.class);
}
public static MongoTemplate getCoreMongoTemplate() throws UnknownHostException {
return MongoUtil.getInstence().coreMongoTemplate;
}
public static void main(String[] args) {
try {
LjsdMongoTemplate ljsdMongoTemplate = getLjsdMongoTemplate();
@ -116,20 +117,31 @@ public class MongoUtil {
}
public static void checkDb(){
public static void checkDb() {
Set<Integer> set = OnlineUserManager.sessionMap.keySet();
Integer[] integers = set.toArray(new Integer[0]);
Set<Integer> ids = new HashSet<>();
if (set.size() == 0) {
return;
}
Random random = new Random();
for (int i = 0; i <3 ; i++) {
for (int i = 0; i < 3; i++) {
int i1 = random.nextInt(set.size());
if (i1 >= integers.length) {
continue;
}
ids.add(integers[i1]);
}
InnerMessageUtil.broadcastWithRandom(user->{
InnerMessageUtil.broadcastWithRandom(user -> {
int id = user.getId();
User byId = MongoUtil.getInstence().getMyMongoTemplate().findById(User.getCollectionName(), user.getId(), User.class);
Gson gson = new GsonBuilder()
.addSerializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipClass(Class<?> arg0) {
return false;
}
@Override
public boolean shouldSkipField(FieldAttributes arg0) {
Transient annotation = arg0.getAnnotation(Transient.class);
@ -138,10 +150,14 @@ public class MongoUtil {
}
return false;
}
@Override
public boolean shouldSkipClass(Class<?> arg0) {
return false;
}).registerTypeAdapter(Map.class, (JsonDeserializer<TreeMap<String, Object>>) (json, typeOfT, context) -> {
TreeMap<String, Object> treeMap = new TreeMap<>();
JsonObject jsonObject = json.getAsJsonObject();
Set<Map.Entry<String, JsonElement>> entrySet = jsonObject.entrySet();
for (Map.Entry<String, JsonElement> entry : entrySet) {
treeMap.put(entry.getKey(), entry.getValue());
}
return treeMap;
}).create();
@ -154,50 +170,54 @@ public class MongoUtil {
int m2 = v2.length;
int j = 0;
while (n-- != 0) {
if (v1[j] != v2[j]){
if (v1[j] != v2[j]) {
System.out.println("args = [" + v1[j] + "][" + v2[j] + "]\r\n");
break;}
break;
}
j++;
}
int start= Math.max(0,j-50);
int end = Math.min(j+1,m2);
if(j!=m2){
File file1 = new File(SysUtil.getPath("conf/checkout_db"+id+".txt"));
try(PrintWriter printWriter = new PrintWriter(new FileOutputStream(file1));) {
int start = Math.max(0, j - 50);
int end = Math.min(j + 1, m2);
if (j != m2) {
File file1 = new File(SysUtil.getPath("conf/checkout_db" + id + ".txt"));
try (PrintWriter printWriter = new PrintWriter(new FileOutputStream(file1));) {
printWriter.print(s);
printWriter.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
File file2 = new File(SysUtil.getPath("conf/checkout_mem"+id+".txt"));
try(PrintWriter printWriter = new PrintWriter(new FileOutputStream(file2));) {
File file2 = new File(SysUtil.getPath("conf/checkout_mem" + id + ".txt"));
try (PrintWriter printWriter = new PrintWriter(new FileOutputStream(file2));) {
printWriter.print(s1);
printWriter.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
File file3 = new File("conf/checkout_diff_start"+id+".txt");
File file3 = new File("conf/checkout_diff_start" + id + ".txt");
String substring = s1.substring(start, end);
String dbstring = s.substring(start, end);
try(PrintWriter printWriter = new PrintWriter(new FileOutputStream(file3));) {
printWriter.print("mem\r\n"+substring);
try (PrintWriter printWriter = new PrintWriter(new FileOutputStream(file3));) {
printWriter.print("mem\r\n" + substring);
printWriter.print("\r\n");
printWriter.print("db\r\n"+dbstring);
printWriter.print("db\r\n" + dbstring);
printWriter.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
LOGGER.error("定期检查数据库对象数据一致性 err"+byId.getId()+" \r\nmem_string \r\n"+substring+" \r\ndb_string \r\n"+dbstring);
}else {
LOGGER.info("定期检查数据库对象数据一致性 匹配"+byId.getId());
LOGGER.error("定期检查数据库对象数据一致性 err" + byId.getId() + " \r\nmem_string \r\n" + substring + " \r\ndb_string \r\n" + dbstring);
} else {
LOGGER.info("定期检查数据库对象数据一致性 匹配" + byId.getId());
}
//JsonObject obj = (JsonObject) parser.parse(json1);
//JsonParser parser1 = new JsonParser();
//JsonObject obj1 = (JsonObject) parser1.parse(json2); 也可以 不好排查
}, new LinkedList<>(ids), 2);
}
}

View File

@ -264,7 +264,7 @@ public class EndExpeditionBattleRequest extends BaseHandler<Expedition.EndExpedi
if(hero==null){
throw new ErrorCodeException("试炼节点英雄掉落失败");
}
Hero hero1 = ExpeditionLogic.createHero(i, uid, hero,false);
Hero hero1 = ExpeditionLogic.createHero(i, uid, hero,-1);
drop.addHero(CBean2Proto.getHero(hero1));
}

View File

@ -49,11 +49,11 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
if (nodeInfo.getType() != ExpeditionLogic.NODETYPE_HERO_GET) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点类型不符"+nodeInfo.getType()));
}
//check node
List<Integer> nextNodeId = ExpeditionLogic.getNextNodeId(user.getExpeditionManager().getSortid(),user.getExpeditionManager().getExpeditionNodeInfos().size());
if(!nextNodeId.contains(nodeId)){
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"));
}
// //check node
// List<Integer> nextNodeId = ExpeditionLogic.getNextNodeId(user.getExpeditionManager().getSortid(),user.getExpeditionManager().getExpeditionNodeInfos().size());
// if(!nextNodeId.contains(nodeId)){
// throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点状态不正确"));
// }
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());
if (sExpeditionNodeConfig == null) {
@ -69,7 +69,7 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
int recruitTime = sExpeditionSetting.getRecruitTime();
Map<String, Hero> heroMapTemp = user.getExpeditionManager().getHeroMapTemp();
Map<String, Hero> heroMapTemp = user.getExpeditionManager().getHeroMapTemp(nodeId);
if(heroMapTemp.size()==0){
SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(sExpeditionNodeConfig.getPoolId());
if(sExpeditionRecruitConfig!=null) {
@ -86,12 +86,12 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
}
for (int j = 0; j < recruitTime; j++) {
ExpeditionLogic.createHero(i, uid, hero, true);
ExpeditionLogic.createHero(i, uid, hero, nodeId);
}
}
}
heroMapTemp = user.getExpeditionManager().getHeroMapTemp(nodeId);
heroMapTemp.forEach((s, hero) -> {
CommonProto.ViewHeroInfo.Builder inner = CommonProto.ViewHeroInfo.newBuilder();
Map<Integer, Integer> heroNotBufferAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, true, 0);

View File

@ -65,12 +65,12 @@ public class HeroNodeRequestHandler extends BaseHandler<Expedition.HeroNodeReque
}
ExpeditionManager expeditionManager = user.getExpeditionManager();
if(!expeditionManager.getHeroMapTemp().containsKey(heroId)){
if(!expeditionManager.getHeroMapTemp(nodeId).containsKey(heroId)){
throw new ErrorCodeException("参数错误");
}
//move temp to
Hero hero = expeditionManager.getHeroMapTemp().get(heroId);
Hero hero = expeditionManager.getHeroMapTemp(nodeId).get(heroId);
expeditionManager.addHero(hero);
Map<String, PropertyItem> equipMapTemp = expeditionManager.getEquipMapTemp();
@ -98,8 +98,8 @@ public class HeroNodeRequestHandler extends BaseHandler<Expedition.HeroNodeReque
drop.addHero(CBean2Proto.getHero(hero));
//clear temp
user.getExpeditionManager().clearEquipToTemp();
user.getExpeditionManager().clearHeroToTemp();
// user.getExpeditionManager().clearEquipToTemp();
// user.getExpeditionManager().clearHeroToTemp();
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());

View File

@ -116,6 +116,10 @@ public class TakeLayRewardHandler extends BaseHandler<Expedition.TakeExpeditionB
ExpeditionManager manager = user.getExpeditionManager();
manager.clearExpeditionNodeInfos();
}
if(expeditionManager.getExpeditionLeve()==3){
expeditionManager.setPassTimes(expeditionManager.getPassTimes()+1);
}
user.getExpeditionManager().addRewardBox(laycfg);
Expedition.TakeExpeditionBoxRewardResponse builder = Expedition.TakeExpeditionBoxRewardResponse.newBuilder().setDrop(drop).addAllLeve(objects).build();
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_TAKE_BOXREWARD_RESONSE_VALUE, builder, true);

View File

@ -0,0 +1,24 @@
package com.ljsd.jieling.kefu;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.logic.dao.ExpeditionManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
/**
* Description: 线
*
* //role_fix 10043343
* CreateDate: 2019/9/26 11:48
*/
public class Cmd_role_fix extends GmRoleAbstract {
@Override
public boolean exec(String[] args) throws Exception {
User user = UserManager.getUser(10043385);
user.getExpeditionManager().setPassTimes(-1);
//mongo
MongoUtil.getInstence().lastUpdate();
return true;
}
}

View File

@ -1,51 +1,478 @@
package com.ljsd.jieling.kefu;
import com.google.gson.Gson;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.config.clazzStaticCfg.SArenaRobotStaticConfig;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.logic.dao.ExpeditionManager;
import com.ljsd.jieling.logic.dao.SnapFightInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.logic.blood.BloodLogic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.protocols.Expedition;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.MonsterUtil;
import config.*;
import manager.STableManager;
import org.springframework.data.redis.core.ZSetOperations;
import util.MathUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* Description: 线
* Author: zsx .//role_gm 10041063
*
* //role_gm 10040936
* //role_gm 10043387
* CreateDate: 2019/9/26 11:48
*/
public class Cmd_role_gm extends GmRoleAbstract {
boolean isfirst =false;
@Override
public boolean exec(String[] args) throws Exception {
// ExpeditionLogic.getInstance().flushUserdataEveryDay(getUser());
boolean check = PlayerLogic.getInstance().check(getUser(), VipPrivilegeType.EXPEDITION_RELIVE, 1);
// boolean check = PlayerLogic.getInstance().check(getUser(), VipPrivilegeType.EXPEDITION_RELIVE, 1);
//
// System.out.println("c"+check);
int NODESTATE_CLOSE = 0;//0未开启
int NODESTATE_NOT_PASS = 1;//1未通过
int NODESTATE_NOT_GET = 2;//2未领取圣物
int NODESTATE_PASS = 3;//已完成
int NODESTATE_OVER_PASS = 4;//已完成
int NODESTATE_HERO = 5;//招募节点
int NODETYPE_ADVANCE = 1;//精英节点
int NODETYPE_BOSS = 2;//首领节点
int NODETYPE_RELIVE = 3;//复活节点
int NODETYPE_RECOVER = 4;//回复节点
int NODETYPE_NORMAL = 5;//普通节点
int NODETYPE_HERO_GET = 7;//招募节点
int NODETYPE_SHOP = 8;//商店节点
int NODETYPE_TRY = 9;//试炼节点
int NODETYPE_GREED= 10;//贪婪节点
int NODETYPE_REWARD= 11;//奖励节点
User user = getUser();
ExpeditionManager expeditionManager = user.getExpeditionManager();
expeditionManager.setPassTimes(-1);
expeditionManager.setExpeditionLeve(2);
ExpeditionManager manager = user.getExpeditionManager();
manager.setLay(1);
manager.setSortid(0);
manager.setExpeditionLeve(2);
manager.clearRewardBox();
manager.clearPropertyItems();
manager.getHeroHPWithChange().clear();
manager.clearExpeditionNodeInfos();
manager.setLay(1);
manager.setSortid(0);
manager.clearRewardBox();
manager.clearPropertyItems();
manager.getHeroHPWithChange().clear();
manager.clearHeroToTemp();
manager.clearEquipToTemp();
manager.clearExpeditionNodeInfos();
//创建节点束河
Set<ExpeditionNodeInfo> nodeSets = createNodeSet(2);
nodeSets.forEach(nodeInfo -> {
int sortId = nodeInfo.getSortId();
if(nodeInfo.getState()==NODESTATE_PASS){
expeditionManager.setSortid(Math.max(expeditionManager.getSortid(),sortId));
}
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
try {
if(nodeInfo.getType() == NODETYPE_ADVANCE || nodeInfo.getType() == NODETYPE_BOSS || nodeInfo.getType() == NODETYPE_NORMAL){
//生成节点boss信息
float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(2);
//战力基准值=maxforce*0.8+1/15(max-min)*lay
int minFoce = sExpeditionSetting.getMatchForce()[2][0];
int manFoce = sExpeditionSetting.getMatchForce()[2][1];
int standerFoce = (int) (user.getPlayerInfoManager().getMaxForce() * ((minFoce / 10000f) + ((float) nodeInfo.getLay()) / size * ((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<ZSetOperations.TypedTuple<String>> typedTuples = RedisUtil.getInstence().rangeByScoreWithScores(RedisKey.AREDEF_TEAM_FORCE_RANK, "", 0, randomForce);
if (typedTuples.size() == 0) {
//战力没有获取到 从机器人中选
// Set<Integer> 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);
} else {
String serarchIdFromRank = typedTuples.iterator().next().getValue();
snapOneFightInfo(user, nodeInfo, Integer.valueOf(serarchIdFromRank));
}
}
if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType() ==ExpeditionLogic.NODETYPE_TRY){
snapOneFightInfo(nodeInfo);
}
} catch (Exception e) {
e.printStackTrace();
}
user.getExpeditionManager().putExpeditionNodeInfos(sortId, nodeInfo);
});
System.out.println("c"+check);
// User user = getUser();
// ExpeditionManager manager = user.getExpeditionManager();
// Expedition.GetExpeditionResponse.Builder builder = Expedition.GetExpeditionResponse.newBuilder();
// builder.addAllLay(manager.getRewardBox());
// // builder.addAllHeroInfo(ExpeditionLogic.getInstance().getAllHeroInfo(user));
// // builder.addAllEquipIds(ExpeditionLogic.getInstance().getEquipnfo(user));
// ExpeditionLogic.getInstance().getNodeInfo(user).forEach(expeditionNodeInfo -> {
// if(expeditionNodeInfo.getType()!=1&&expeditionNodeInfo.getType()!=5&&expeditionNodeInfo.getType()!=2){
// return;
// }
//// builder.addNodeInfo(expeditionNodeInfo);
//
// SnapFightInfo snapFightInfo = user.getExpeditionManager().getExpeditionNodeInfos().get(expeditionNodeInfo.getSortId()).getSnapFightInfo();
// System.out.println(expeditionNodeInfo.getSortId()+"::"+snapFightInfo.getHeroAttribute().keySet().toString()+"::"+snapFightInfo.getForce()+"\r\n");
// });
//
// // System.out.println(new Gson().toJson(snapFightInfo));
//// builder.addAllNodeInfo(ExpeditionLogic.getInstance().getNodeInfo(user));
// System.out.println(builder.build().toString());
return true;
}
public static boolean isBattleNode(int type) {
int NODETYPE_ADVANCE = 1;//精英节点
int NODETYPE_BOSS = 2;//首领节点
int NODETYPE_RELIVE = 3;//复活节点
int NODETYPE_RECOVER = 4;//回复节点
int NODETYPE_NORMAL = 5;//普通节点
int NODETYPE_HERO_GET = 7;//招募节点
int NODETYPE_SHOP = 8;//商店节点
int NODETYPE_TRY = 9;//试炼节点
int NODETYPE_GREED= 10;//贪婪节点
int NODETYPE_REWARD= 11;//奖励节点
return type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL;
}
/**
*
*/
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo, SArenaRobotConfig sArenaRobotConfig) {
if (!isBattleNode(nodeInfo.getType())) {
return;
}
SnapFightInfo fightInfo = new SnapFightInfo();
int force = sArenaRobotConfig.getTotalForce();
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
Map<Integer, Integer> heroStarsMap = sArenaRobotConfig.getStarOfHeroMap();
Map<String, Double> bossHP = new HashMap<>();
for (Map.Entry<Integer, Integer> item : heroStarsMap.entrySet()) {
StringBuilder skillSb = new StringBuilder();
Integer heroTid = item.getKey();
Integer heroStar = item.getValue();
SCHero scHero = SCHero.getsCHero().get(heroTid);
List<Integer> skillIds = scHero.getSkillListByStar(heroStar);
String heroSkill = HeroLogic.getInstance().getRobotHeroSkills(skillIds, skillSb).toString();
fightInfo.updateHeroSkill(heroTid.toString(), heroSkill.substring(0, heroSkill.length() - 1));
bossHP.put(heroTid.toString(), 1d);
int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId();
int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv();
int robotLevel = sArenaRobotConfig.getRoleLv();
Map<Integer, Integer> robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(scHero, robotLevel, sArenaRobotConfig.getBreakId(), differDemonsId, differDemonsLv, false);
heroAllAttribute.put(heroTid.toString(), new FamilyHeroInfo(heroTid, robotLevel, heroStar, robotHeroAttribute));
// String property = HeroLogic.getInstance().getRobotHeroProperty(sArenaRobotConfig,scHero,propertySb,robotHeroAttribute).toString();
}
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
fightInfo.setUid(sArenaRobotConfig.getId());
nodeInfo.setBossHP(bossHP);
fightInfo.setPokenmonSkills("");
fightInfo.setPassiveSkills("");
nodeInfo.setSnapFightInfo(fightInfo);
}
private void snapOneFightInfo(User self, ExpeditionNodeInfo nodeInfo, int defid) throws Exception {
int snapTeamId = GlobalsDef.TEAM_ARENA_DEFENSE;
if (!isBattleNode(nodeInfo.getType())) {
return;
}
User user = UserManager.getUser(defid);
SnapFightInfo fightInfo = new SnapFightInfo();
//血量处理buff处理
int force = HeroLogic.getInstance().calTeamTotalForce(user, snapTeamId, false);
Map<String, FamilyHeroInfo> heroAllAttribute = BloodLogic.getInstance().battleRecord(user, snapTeamId, null);
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
fightInfo.setUid(self.getId());
List<TeamPosHeroInfo> teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(snapTeamId);
if (teamPosHeroInfoList == null || teamPosHeroInfoList.size() < 1) {
teamPosHeroInfoList = user.getTeamPosManager().getTeamPosForHero().get(1);
}
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
Map<String, Double> bossHP = new HashMap<>();
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList) {
String heroId = teamPosHeroInfo.getHeroId();
bossHP.put(heroId, 1d);
Hero hero = heroMap.get(heroId);
StringBuilder skillSb = new StringBuilder();
String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero, skillSb).toString();
fightInfo.updateHeroSkill(heroId, heroSkill.substring(0, heroSkill.length() - 1));
}
nodeInfo.setBossHP(bossHP);
if (self.getPokemonManager().getPokemonMap().size()!=0) {
//玩家未激活异妖(神器)时,敌人阵容中不会出现异妖;激活异妖后,由敌人数据来源方决定战斗时是否有敌方异妖。
String pokenmonSkills = HeroLogic.getInstance().getPokenmonSkills(user, snapTeamId);
String pokenmonPassiveSkills = HeroLogic.getInstance().getPokenmonPassiveSkills(user, snapTeamId);
List<TeamPosForPokenInfo> teamPosForPokenInfos = user.getTeamPosManager().getTeamPosForPoken().get(snapTeamId);
if (null!=teamPosForPokenInfos) {
List<Integer> pokens = new ArrayList<>();
for (TeamPosForPokenInfo teamPosForPokenInfo : teamPosForPokenInfos) {
pokens.add(teamPosForPokenInfo.getPokenId());
}
fightInfo.setPokenmonIds(pokens);
}
fightInfo.setPokenmonSkills(pokenmonSkills);
fightInfo.setPassiveSkills(pokenmonPassiveSkills);
}
nodeInfo.setSnapFightInfo(fightInfo);
}
/**
*
*/
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo) throws ErrorCodeException{
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());
int poolId = sExpeditionNodeConfig.getPoolId();
int tempId =ExpeditionLogic.getRandomTid(poolId,1).first();
SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(tempId);
if(sExpeditionRecruitConfig==null) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
//grop config
int i = sExpeditionRecruitConfig.getHeroId();
SnapFightInfo fightInfo = new SnapFightInfo();
fightInfo.setUid(i);
int force = MonsterUtil.getMonsterForce(new int[]{i});
Map<String, Double> bossHP = new HashMap<>();
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(i);
int[][] groupIds = sMonsterGroup.getContents();
int[] monsterIds = groupIds[0];
for (int monsterId : monsterIds) {
if(monsterId!=0){
bossHP.put(Integer.toString(monsterId), 1d);
heroAllAttribute.put(Integer.toString(monsterId), new FamilyHeroInfo());
}
}
fightInfo.setHeroAttribute(heroAllAttribute);
fightInfo.setForce(force);
nodeInfo.setBossHP(bossHP);
fightInfo.setPokenmonSkills("");
fightInfo.setPassiveSkills("");
nodeInfo.setSnapFightInfo(fightInfo);
}
/**
* type id state
*/
private Set<ExpeditionNodeInfo> createNodeSet(int leve) throws Exception {
int NODESTATE_CLOSE = 0;//0未开启
int NODESTATE_NOT_PASS = 1;//1未通过
int NODESTATE_NOT_GET = 2;//2未领取圣物
int NODESTATE_PASS = 3;//已完成
int NODESTATE_OVER_PASS = 4;//已完成
int NODESTATE_HERO = 5;//招募节点
int NODETYPE_ADVANCE = 1;//精英节点
int NODETYPE_BOSS = 2;//首领节点
int NODETYPE_RELIVE = 3;//复活节点
int NODETYPE_RECOVER = 4;//回复节点
int NODETYPE_NORMAL = 5;//普通节点
int NODETYPE_HERO_GET = 7;//招募节点
int NODETYPE_SHOP = 8;//商店节点
int NODETYPE_TRY = 9;//试炼节点
int NODETYPE_GREED= 10;//贪婪节点
int NODETYPE_REWARD= 11;//奖励节点
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
int totalIndex = 1;
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
Set<Integer> ids = STableManager.getFigureConfig(CommonStaticConfig.class).leve2ids.get(leve);
if(ids==null){
return nodeSets;
}
int orDefault = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.getOrDefault(leve-1, 0)-1;//节点
Map<Integer,Set<Integer>> map = new HashMap<>();
for (Map.Entry<Integer, Map<Integer,Integer>> integerMapMap :STableManager.getFigureConfig(CommonStaticConfig.class).getType2lay2weight(leve).entrySet()){
int type = integerMapMap.getKey();
int lay = ranndomFromWeight(integerMapMap.getValue());
Set<Integer> value = map.getOrDefault(lay,new HashSet<>());
value.add(type);
map.put(lay,value);
}
for (SExpeditionFloorConfig sExpeditionFloorConfig : config.values()) {
if(!ids.contains(sExpeditionFloorConfig.getId())){
continue;
}
int lay = sExpeditionFloorConfig.getId();
isfirst =false;
if(lay-orDefault-1==ids.size()){
isfirst=true;
}
//必出节点 生成本层id
List<Integer> indexList = MathUtils.combineList(totalIndex, totalIndex + sExpeditionFloorConfig.getNode() - 1);
if (indexList.size() <= 0) {
continue;
}
//生成随机节点
if(map.containsKey(lay)){
for (Integer itemType:map.get(lay)) {
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, itemType);
nodeInfo.setLay(lay-orDefault);
nodeInfo.setState(NODESTATE_OVER_PASS);
if(!isfirst){
nodeInfo.setState(NODESTATE_PASS);
isfirst=true;
}
if(lay-orDefault-1==ids.size()){
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeInfo.setSortId(indexList.remove(0));
nodeSets.add(nodeInfo);
totalIndex++;
if (indexList.size() == 0) {
break;
}
}
}
if (indexList.size() == 0) {
continue;
}
//生成必出节点id state
for (int i = 0; i < sExpeditionFloorConfig.getNodeType().length; i++) {
int[] typeArr = sExpeditionFloorConfig.getNodeType()[i];
if (typeArr.length != 2) {
continue;
}
Set<ExpeditionNodeInfo> tempnode = getNode(sExpeditionFloorConfig, typeArr[0], typeArr[1]);
tempnode.forEach(nodeInfo -> {
nodeInfo.setLay(lay-orDefault);
nodeInfo.setState(NODESTATE_OVER_PASS);
if(!isfirst){
isfirst=true;
nodeInfo.setState(NODESTATE_PASS);
}
if(lay-orDefault-1==ids.size()){
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeInfo.setSortId(indexList.remove(0));
});
nodeSets.addAll(tempnode);
totalIndex += tempnode.size();
if (indexList.size() == 0) {
break;
}
}
if (indexList.size() == 0) {
continue;
}
//生成剩余节点
for (Integer anIndexList : indexList) {
//TODO 概率走配置
int type = NODETYPE_NORMAL;
if (Math.random() <= 0.3d) {
type = NODETYPE_ADVANCE;
}
ExpeditionNodeInfo nodeInfo = getNode(sExpeditionFloorConfig, type);
nodeInfo.setLay(lay-orDefault);
nodeInfo.setState(NODESTATE_OVER_PASS);
if(!isfirst){
isfirst=true;
nodeInfo.setState(NODESTATE_PASS);
}
nodeInfo.setSortId(anIndexList);
if(lay-orDefault-1==ids.size()){
nodeInfo.setState(NODESTATE_NOT_PASS);
}
nodeSets.add(nodeInfo);
totalIndex++;
}
}
return nodeSets;
}
private static int ranndomFromWeight(Map<Integer, Integer> weight) {
int amount;
int result = 0;
IntSummaryStatistics collect = weight.values().stream().collect(Collectors.summarizingInt(value -> value));
amount = (int) collect.getSum();
int rate = MathUtils.randomInt(amount);
amount = 0;
for (Map.Entry<Integer, Integer> integerIntegerMap : weight.entrySet()) {
amount += integerIntegerMap.getValue();
if (rate < amount) {
result = integerIntegerMap.getKey();
break;
}
}
return result;
}
private ExpeditionNodeInfo getNode(SExpeditionFloorConfig cfg, int type) throws Exception {
return getNode(cfg, type, 1).iterator().next();
}
private Set<ExpeditionNodeInfo> getNode(SExpeditionFloorConfig cfg, int type, int num) throws Exception {
int NODESTATE_CLOSE = 0;//0未开启
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
for (int i = 0; i < num; i++) {
ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo();
nodeInfo.setType(type);
nodeInfo.setState(NODESTATE_CLOSE);
nodeSets.add(nodeInfo);
}
return nodeSets;
}
}

View File

@ -36,6 +36,7 @@ public class ExpeditionManager extends MongoBase {
private Map<String, Hero> heroMap = new HashMap<>();
private Map<String,PropertyItem> equipMap = new HashMap<>();
private Map<String, Hero> heroMapTemp = new HashMap<>();
private Map<Integer,Map<String, Hero>> heroNodeMapTemp = new HashMap<>();
private Map<String,PropertyItem> equipMapTemp = new HashMap<>();
public void putExpeditionNodeInfos(Integer key, ExpeditionNodeInfo nodeInfo) {
@ -174,16 +175,18 @@ public class ExpeditionManager extends MongoBase {
heroMap.put(hero.getId(), hero);
}
public void addHeroToTemp(Hero hero) throws Exception {
public void addHeroToTemp(Hero hero,int nodeID) throws Exception {
//绑定关系
hero.init(this.getRootId(),getMongoKey() + ".heroMapTemp." + hero.getId());
updateString("heroMapTemp." + hero.getId(), hero);
heroMapTemp.put(hero.getId(), hero);
hero.init(this.getRootId(),getMongoKey() + ".heroNodeMapTemp."+nodeID+"."+ hero.getId());
Map<String, Hero> orDefault = heroNodeMapTemp.getOrDefault(nodeID, new HashMap<>());
updateString("heroNodeMapTemp." + nodeID, orDefault);
orDefault.put(hero.getId(), hero);
heroNodeMapTemp.put(nodeID,orDefault);
}
public void clearHeroToTemp() throws Exception {
heroMapTemp.clear();
updateString("heroMapTemp" , heroMapTemp);
heroNodeMapTemp.clear();
updateString("heroNodeMapTemp" , heroNodeMapTemp);
}
@ -229,8 +232,8 @@ public class ExpeditionManager extends MongoBase {
updateString("freshTime" , freshTime);
}
public Map<String, Hero> getHeroMapTemp() {
return heroMapTemp;
public Map<String, Hero> getHeroMapTemp(int sortid) {
return heroNodeMapTemp.getOrDefault(sortid,new HashMap<>());
}
public Map<String, PropertyItem> getEquipMapTemp() {

View File

@ -60,6 +60,7 @@ public class Hero extends MongoBase {
this.templateId = heroTid;
this.level = initStar;
this.star =hero.getStar() ;
this.equipByPositionMap = new HashMap<>();
this.soulEquipByPositionMap = hero.soulEquipByPositionMap;
this.breakId = hero.breakId;
this.starBreakId = hero.starBreakId;

View File

@ -527,7 +527,7 @@ public class PlayerManager extends MongoBase {
}
public void setChannel(String channel) {
updateString("channel", this.channel);
updateString("channel", channel);
this.channel = channel;
}

View File

@ -292,11 +292,11 @@ public class ExpeditionLogic {
if(isBattleNode(nodeInfo.getType())){
//生成节点boss信息
float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(1);
float size = STableManager.getFigureConfig(CommonStaticConfig.class).leve2num.get(leve);
//战力基准值=maxforce*0.8+1/15(max-min)*lay
int minFoce = sExpeditionSetting.getMatchForce()[leve][0];
int manFoce = sExpeditionSetting.getMatchForce()[leve][1];
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()) / size * ((float) (manFoce - minFoce)/10000f)));
float randomForce = (standerFoce * ((sExpeditionSetting.getMatchForceRange()[0] + (int) (Math.random() * (sExpeditionSetting.getMatchForceRange()[1] - sExpeditionSetting.getMatchForceRange()[0]))) / 10000f));
@ -813,7 +813,14 @@ public class ExpeditionLogic {
}
public static Hero createHero(int tempid,int uid,Hero hero,boolean isTemp)throws Exception{
/**
*
* @param nodeId -1
* @return
* @throws Exception
*/
public static Hero createHero(int tempid,int uid,Hero hero,int nodeId)throws Exception{
boolean isTemp = nodeId != -1;
int star = hero.getLevel();
User user = UserManager.getUser(uid);
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
@ -864,7 +871,7 @@ public class ExpeditionLogic {
newHero.addJewel(newequip.getId());
}
if(isTemp){
user.getExpeditionManager().addHeroToTemp(newHero);
user.getExpeditionManager().addHeroToTemp(newHero,nodeId);
}else {
user.getExpeditionManager().addHero(newHero);
}