parent
c766cc8622
commit
cf740db4e4
|
|
@ -38,10 +38,28 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
|
|||
|
||||
public Map<Integer, List<int[]>> matrixforGroupInfo;
|
||||
|
||||
public Map<Integer,Map<Integer, Map<Integer,Integer>>> type2lay2weight;
|
||||
public Map<Integer, Integer> leve2num;//阶段第一层
|
||||
public Map<Integer, Set<Integer>> leve2ids;//ids
|
||||
public Map<Integer,Map<Integer,Integer>> type2holy2weight;
|
||||
/**
|
||||
* 随机节点信息
|
||||
* map<层数,<随机节点类型,<自增id,随机节点权重>>>
|
||||
*/
|
||||
private Map<Integer,Map<Integer, Map<Integer,Integer>>> type2lay2weight;
|
||||
/**
|
||||
* 阶段第一层
|
||||
* map<层数,该层最大位置>
|
||||
*/
|
||||
public Map<Integer, Integer> leve2num;
|
||||
/**
|
||||
* ids
|
||||
* map<层数,自增id>
|
||||
*/
|
||||
public Map<Integer, Set<Integer>> leve2ids;
|
||||
/**
|
||||
* 圣物相关信息
|
||||
*/
|
||||
public Map<Integer,Map<Integer,Integer>> type2holy2weight;
|
||||
/**
|
||||
* 特殊节点相关信息
|
||||
*/
|
||||
public Map<Integer,Map<Integer,Integer>> type2Recruitcfgs;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ package com.ljsd.jieling.logic.dao;
|
|||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Description: des
|
||||
|
|
@ -85,4 +82,17 @@ public class ExpeditionNodeInfo extends MongoBase {
|
|||
this.snapFightInfo = snapFightInfo;
|
||||
updateString("snapFightInfo",snapFightInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ExpeditionNodeInfo that = (ExpeditionNodeInfo) o;
|
||||
return Objects.equals(this.sortId, that.sortId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.sortId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package com.ljsd.jieling.logic.expedition;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 大闹天宫抽象类
|
||||
* @author hj
|
||||
*/
|
||||
public abstract class AbstractExpedition {
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractExpedition.class);
|
||||
|
||||
public int type;
|
||||
|
||||
AbstractExpedition(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建节点并赋值初始信息,根据需求重写功能
|
||||
* @param uid 抽象不用
|
||||
* @param index 抽象不用
|
||||
* @param leve 层数
|
||||
* @param sortId 排序id
|
||||
* @param lay 行数
|
||||
* @exception
|
||||
* @return
|
||||
*/
|
||||
public abstract ExpeditionNodeInfo creatNodes(int uid,int index,int leve,int sortId,int lay) throws Exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sortId
|
||||
* @param lay
|
||||
* @return
|
||||
*/
|
||||
ExpeditionNodeInfo creatNodes(int sortId,int lay){
|
||||
ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo();
|
||||
nodeInfo.setSortId(sortId);
|
||||
// 玩家所占为第一次,所以层数应该是从第二层开始
|
||||
lay++;
|
||||
nodeInfo.setLay(lay);
|
||||
// 2层为玩家看到得下一层,所以状态为未通过,其他得是未开启
|
||||
if (lay == 2){
|
||||
nodeInfo.setState(ExpeditionLogic.NODESTATE_NOT_PASS);
|
||||
}else {
|
||||
nodeInfo.setState(ExpeditionLogic.NODESTATE_CLOSE);
|
||||
}
|
||||
nodeInfo.setType(type);
|
||||
return nodeInfo;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,288 @@
|
|||
package com.ljsd.jieling.logic.expedition;
|
||||
|
||||
import com.ljsd.fight.FamilyHeroInfo;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.rank.RankLogic;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
import util.MathUtils;
|
||||
import util.StringUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 战斗节点
|
||||
* 普通,精英,boss,贪婪
|
||||
* @author hj
|
||||
*/
|
||||
public class BattleNode extends AbstractExpedition {
|
||||
|
||||
BattleNode(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpeditionNodeInfo creatNodes(int uid,int index,int leve,int sortId, int lay) throws Exception {
|
||||
ExpeditionNodeInfo nodeInfo = creatNodes(sortId, lay);
|
||||
|
||||
SExpeditionFloorConfig config = STableManager.getConfig(SExpeditionFloorConfig.class).get(index);
|
||||
User user = UserManager.getUser(uid);
|
||||
|
||||
nodeHolyInfo(user,type,config,nodeInfo);
|
||||
|
||||
nodeFightInfo(user,leve,nodeInfo);
|
||||
|
||||
return nodeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点战斗信息
|
||||
* @param user
|
||||
* @param leve
|
||||
* @param nodeInfo
|
||||
* @throws Exception
|
||||
*/
|
||||
private void nodeFightInfo(User user, int leve, ExpeditionNodeInfo nodeInfo) throws Exception {
|
||||
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
||||
if (sExpeditionSetting == null) {
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL,"配置表错误,获取数据为空");
|
||||
}
|
||||
|
||||
// 随机出来的队伍信息
|
||||
List<List<Integer>> rankTeam = RankLogic.getInstance().getRandomUserByRank(user, 1);
|
||||
List<Integer> randomFaceRankTeam = rankTeam.get(0);
|
||||
|
||||
// 万分比
|
||||
double base = 10000d;
|
||||
// 上下浮动值
|
||||
double min = sExpeditionSetting.getMatchForce()[leve-1][0]/base;
|
||||
double max = sExpeditionSetting.getMatchForce()[leve-1][1]/base;
|
||||
// 初始等级,前六名平均等级
|
||||
int averageLevel = HeroLogic.getInstance().getAverageLevel(user, 6);
|
||||
// 第一次计算,随机出来机器人等级,(【向上取整】基础等级 *(最低浮动 + (当前节点位置 / 总层数 *(最高浮动-最低浮动))))
|
||||
int robotLevel = (int) Math.ceil(averageLevel * (min + (nodeInfo.getLay() / 11d * (max - min))));
|
||||
// 第二次计算,根据节点类型浮动
|
||||
int amendLevel = getAmendLevel(sExpeditionSetting,robotLevel);
|
||||
// 第三次计算,根据玩家等级浮动
|
||||
int robotLevelByUser = getRobotLevelByUser(user, amendLevel);
|
||||
|
||||
// 节点英雄快照
|
||||
snapOneFightInfo(nodeInfo, randomFaceRankTeam, robotLevelByUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据节点类型浮动等级,部分战斗节点需要重写
|
||||
* @param sExpeditionSetting
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
protected int getAmendLevel(SExpeditionSetting sExpeditionSetting, int level){
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点圣物信息
|
||||
* @param user
|
||||
* @param type
|
||||
* @param cfg
|
||||
* @param nodeInfo
|
||||
*/
|
||||
private void nodeHolyInfo(User user, int type, SExpeditionFloorConfig cfg, ExpeditionNodeInfo nodeInfo){
|
||||
Set<Integer> staffsSet = new HashSet<>();
|
||||
while (staffsSet.size()<3){
|
||||
|
||||
int[][] holyProbability = new int[cfg.getHolyProbability().length][2];
|
||||
for(int j = 0; j < holyProbability.length; j++){
|
||||
System.arraycopy(cfg.getHolyProbability()[j], 0, holyProbability[j], 0, 2);
|
||||
}
|
||||
|
||||
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(type);
|
||||
if(null!=sExpeditionNodeConfig && sExpeditionNodeConfig.getHolyProbability().length==3){
|
||||
for (int j = 0; j <holyProbability.length ; j++) {
|
||||
holyProbability[j][1]+= sExpeditionNodeConfig.getHolyProbability()[j][1];
|
||||
}
|
||||
}
|
||||
int ints;
|
||||
try {
|
||||
ints = MathUtils.randomFromWeight(holyProbability);
|
||||
}catch (Exception e){
|
||||
break;
|
||||
}
|
||||
Map<Integer, Integer> type2holy2weight = getType2holy2weightRemoveHas(user,ints);
|
||||
int i1 = ExpeditionLogic.ranndomFromWeight(type2holy2weight);
|
||||
staffsSet.add(i1);
|
||||
}
|
||||
nodeInfo.setHolyEquipId(staffsSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户等级修正机器人等级
|
||||
* @param user
|
||||
* @param originalLevel
|
||||
* @return
|
||||
*/
|
||||
protected int getRobotLevelByUser(User user,int originalLevel){
|
||||
SExpeditionSetting setting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
||||
// 表配置错误
|
||||
if (setting == null){
|
||||
return originalLevel;
|
||||
}
|
||||
// 用户等级
|
||||
int userLevel = user.getPlayerInfoManager().getLevel();
|
||||
// 等级限制
|
||||
int[] levelLimit = setting.getPlayerLevelfix()[0];
|
||||
// 对应条件
|
||||
int[] condition = setting.getPlayerLevelfix()[1];
|
||||
// 长度不等
|
||||
if (levelLimit.length != condition.length){
|
||||
return originalLevel;
|
||||
}
|
||||
// 修正的等级
|
||||
int offset = 0;
|
||||
// 计数器,防止表里的修正等级为0
|
||||
int count = 0;
|
||||
for (int i = 0; i < levelLimit.length; i++) {
|
||||
// 满足条件
|
||||
if (userLevel < levelLimit[i]){
|
||||
offset = condition[i];
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 等级超过限制条件,取最大限制条件
|
||||
if (offset == 0 && count == 0){
|
||||
offset = condition[condition.length-1];
|
||||
}
|
||||
|
||||
int level = originalLevel+offset;
|
||||
|
||||
return level>1?level:1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版2021-2-25,节点英雄快照
|
||||
* @param nodeInfo
|
||||
* @param heroIds
|
||||
* @param level
|
||||
*/
|
||||
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo, List<Integer> heroIds, int level) {
|
||||
SnapFightInfo fightInfo = new SnapFightInfo();
|
||||
// 英雄列表
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
// boss血量,这里无用
|
||||
Map<String, Double> bossHP = new HashMap<>();
|
||||
// 获取对应等级的机器人信息
|
||||
SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level);
|
||||
if (property == null){
|
||||
Map<Integer, SRobotProperty> config = STableManager.getConfig(SRobotProperty.class);
|
||||
// 玩家等级超上限,取表里最大值
|
||||
property = config.get(config.values().size());
|
||||
}
|
||||
// 英雄属性
|
||||
Map<Integer, Integer> robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(property);
|
||||
|
||||
// 位置坐标
|
||||
int innerPosition = 1;
|
||||
// 战力
|
||||
int force = 0;
|
||||
|
||||
for (Integer id : heroIds) {
|
||||
// 获取技能列表,包含主动和被动技能
|
||||
String skills = SRobotSkill.getSkills(id, property.getSkillPool()-1);
|
||||
fightInfo.updateHeroSkill(id.toString(), skills.substring(0, skills.length() - 1));
|
||||
// 需要赋值
|
||||
bossHP.put(id.toString(), 1D);
|
||||
force+=HeroLogic.getInstance().calForce(robotHeroAttribute);
|
||||
heroAllAttribute.put(id.toString(), new FamilyHeroInfo(id, property.getId(), property.getStar(), robotHeroAttribute,innerPosition++));
|
||||
}
|
||||
|
||||
fightInfo.setForce(force);
|
||||
fightInfo.setPokenmonSkills(StringUtil.parseArrayToString(property.getAnimal()));
|
||||
fightInfo.setPassiveSkills("");
|
||||
fightInfo.setUid(property.getId());
|
||||
fightInfo.setHeroAttribute(heroAllAttribute);
|
||||
nodeInfo.setSnapFightInfo(fightInfo);
|
||||
|
||||
nodeInfo.setBossHP(bossHP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不重复得圣物
|
||||
* @param user
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private Map<Integer, Integer> getType2holy2weightRemoveHas(User user, int type) {
|
||||
// 策划表的圣物,因为会有删除操作,所以需要重新赋值,而不是直接引用
|
||||
Map<Integer, Integer> weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weight(type);
|
||||
if (weight == null){
|
||||
return new HashMap<>();
|
||||
}
|
||||
Map<Integer, Integer> valueMap = new HashMap<>(weight);
|
||||
|
||||
// 已拥有的圣物
|
||||
Set<ExpeditionItem> items = user.getExpeditionManager().getPropertyItems();
|
||||
Set<Integer> ids = new HashSet<>();
|
||||
items.forEach(id->ids.add(id.getEquipId()));
|
||||
|
||||
// 已拥有英雄
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
Set<Integer> heroIds = new HashSet<>();
|
||||
heroMap.values().forEach(v->heroIds.add(v.getTemplateId()));
|
||||
|
||||
// 大闹天宫临时英雄
|
||||
Map<String, Hero> expeditonHeroMap = user.getExpeditionManager().getHeroMap();
|
||||
Set<Integer> expeditonHeroIds = new HashSet<>();
|
||||
expeditonHeroMap.values().forEach(v->expeditonHeroIds.add(v.getTemplateId()));
|
||||
|
||||
// 已生成得节点圣物信息
|
||||
Set<Integer> nodeHolyInfo = getNodeHolyInfo(user);
|
||||
|
||||
// 因为有删除操作,所以使用iterator遍历
|
||||
Iterator<Integer> 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();
|
||||
}
|
||||
}
|
||||
// 已经生成过得圣物
|
||||
if(nodeHolyInfo.contains(v)){
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部节点得圣物信息
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
private static Set<Integer> getNodeHolyInfo(User user){
|
||||
Set<Integer> set = new HashSet<>();
|
||||
// 以生成得节点信息,非空验证
|
||||
Collection<ExpeditionNodeInfo> values = user.getExpeditionManager().getExpeditionNodeInfos().values();
|
||||
if (values.size() <= 0){
|
||||
return set;
|
||||
}
|
||||
// 聚合操作,首先排除不存在圣物得节点,然后循环添加剩余节点圣物
|
||||
values.stream()
|
||||
.filter(val->val.getHolyEquipId() != null && val.getHolyEquipId().size() > 0)
|
||||
.forEach(val->set.addAll(val.getHolyEquipId()));
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.ljsd.jieling.logic.expedition;
|
||||
|
||||
import config.SExpeditionSetting;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* boss节点,贪婪节点
|
||||
*/
|
||||
public class BossNode extends BattleNode {
|
||||
|
||||
BossNode(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getAmendLevel(SExpeditionSetting sExpeditionSetting, int level){
|
||||
level += (Math.ceil(sExpeditionSetting.getPowerfulForce()[1][1] / 10000d * level));
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.ljsd.jieling.logic.expedition;
|
||||
|
||||
import config.SExpeditionSetting;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 精英节点
|
||||
*/
|
||||
public class EliteNode extends BattleNode {
|
||||
|
||||
EliteNode(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getAmendLevel(SExpeditionSetting sExpeditionSetting, int level){
|
||||
level += (Math.ceil(sExpeditionSetting.getPowerfulForce()[2][1] / 10000d * level));
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
package com.ljsd.jieling.logic.expedition;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public enum ExpeditionEnum {
|
||||
/**
|
||||
* 精英节点
|
||||
*/
|
||||
ADVANCE_NODE(ExpeditionLogic.NODETYPE_ADVANCE, EliteNode::new),
|
||||
/**
|
||||
* boss节点
|
||||
*/
|
||||
BOSS_NODE(ExpeditionLogic.NODETYPE_BOSS,BossNode::new),
|
||||
/**
|
||||
* 复活节点
|
||||
*/
|
||||
RELIVE_NODE(ExpeditionLogic.NODETYPE_RELIVE,OtherNode::new),
|
||||
/**
|
||||
* 回复节点
|
||||
*/
|
||||
RECOVER_NODE(ExpeditionLogic.NODETYPE_RECOVER,OtherNode::new),
|
||||
/**
|
||||
* 普通战斗节点
|
||||
*/
|
||||
NORMAL_NODE(ExpeditionLogic.NODETYPE_NORMAL,BattleNode::new),
|
||||
/**
|
||||
* 招募节点
|
||||
*/
|
||||
HERO_GET_NODE(ExpeditionLogic.NODETYPE_HERO_GET,OtherNode::new),
|
||||
/**
|
||||
* 商店节点
|
||||
*/
|
||||
SHOP_NODE(ExpeditionLogic.NODETYPE_SHOP,OtherNode::new),
|
||||
/**
|
||||
* 试炼节点
|
||||
*/
|
||||
TRY_NODE(ExpeditionLogic.NODETYPE_TRY,SpecialNode::new),
|
||||
/**
|
||||
* 贪婪节点
|
||||
*/
|
||||
GREED_NODE(ExpeditionLogic.NODETYPE_GREED,BossNode::new),
|
||||
/**
|
||||
* 奖励节点
|
||||
*/
|
||||
REWARD_NODE(ExpeditionLogic.NODETYPE_REWARD,OtherNode::new)
|
||||
;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private int type;
|
||||
/**
|
||||
* 方法
|
||||
*/
|
||||
private Function<Integer,AbstractExpedition> function;
|
||||
|
||||
ExpeditionEnum(int type, Function<Integer,AbstractExpedition> function) {
|
||||
this.type = type;
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Function<Integer, AbstractExpedition> getFunction() {
|
||||
return function;
|
||||
}
|
||||
|
||||
public void setFunction(Function<Integer, AbstractExpedition> function) {
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
private static Map<Integer,AbstractExpedition> expeditionMap;
|
||||
|
||||
static {
|
||||
// 初始化
|
||||
expeditionMap = new HashMap<>();
|
||||
for (ExpeditionEnum value : ExpeditionEnum.values()) {
|
||||
expeditionMap.put(value.getType(),value.getFunction().apply(value.type));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取对象
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static AbstractExpedition getExpedition(int type){
|
||||
if (expeditionMap.containsKey(type)){
|
||||
return expeditionMap.get(type);
|
||||
}
|
||||
ExpeditionEnum anEnum = getEnum(type);
|
||||
if (anEnum == null){
|
||||
return null;
|
||||
}
|
||||
AbstractExpedition apply = anEnum.getFunction().apply(type);
|
||||
expeditionMap.put(type,apply);
|
||||
return apply;
|
||||
}
|
||||
|
||||
public static ExpeditionEnum getEnum(int type){
|
||||
for (ExpeditionEnum anEnum : ExpeditionEnum.values()) {
|
||||
if (anEnum.getType() == type){
|
||||
return anEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -44,6 +44,7 @@ import util.MathUtils;
|
|||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.rmi.server.UID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -61,14 +62,14 @@ public class ExpeditionLogic {
|
|||
public static final int NODESTATE_NOT_PASS = 1;//1未通过
|
||||
public static final int NODESTATE_NOT_GET = 2;//2未领取圣物
|
||||
public static final int NODESTATE_PASS = 3;//已完成
|
||||
public static final int NODESTATE_OVER_PASS = 4;//已完成
|
||||
private static final int NODESTATE_OVER_PASS = 4;//已完成
|
||||
public static final int NODESTATE_HERO = 5;//招募节点
|
||||
|
||||
public static final int NODETYPE_ADVANCE = 1;//精英节点
|
||||
static final int NODETYPE_ADVANCE = 1;//精英节点
|
||||
public static final int NODETYPE_BOSS = 2;//首领节点
|
||||
public static final int NODETYPE_RELIVE = 3;//复活节点
|
||||
public static final int NODETYPE_RECOVER = 4;//回复节点
|
||||
public static final int NODETYPE_NORMAL = 5;//普通节点
|
||||
static final int NODETYPE_NORMAL = 5;//普通节点
|
||||
public static final int NODETYPE_HERO_GET = 7;//招募节点
|
||||
public static final int NODETYPE_SHOP = 8;//商店节点
|
||||
public static final int NODETYPE_TRY = 9;//试炼节点
|
||||
|
|
@ -268,7 +269,7 @@ public class ExpeditionLogic {
|
|||
Set<CommonProto.ExpeditionNodeInfo> nodeInfos = new HashSet<>();
|
||||
Map<Integer, ExpeditionNodeInfo> expeditionNodeInfos = user.getExpeditionManager().getExpeditionNodeInfos();
|
||||
if (expeditionNodeInfos.size() == 0) {
|
||||
reSetNode(user,user.getExpeditionManager().getExpeditionLeve());
|
||||
createNodeSet(user,user.getExpeditionManager().getExpeditionLeve());
|
||||
}
|
||||
expeditionNodeInfos.values().forEach(nodeInfo ->
|
||||
nodeInfos.add(CommonProto.ExpeditionNodeInfo.newBuilder()
|
||||
|
|
@ -296,462 +297,112 @@ public class ExpeditionLogic {
|
|||
return equips;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加节点战力数据 匹配的战力数值= 每层的基准战力+random战力+ 类型加成战力
|
||||
* 优先从战力排行榜中向下匹配真人数据 ,没有从机器人中匹配
|
||||
* @param user user
|
||||
* @param leve 阶段
|
||||
*/
|
||||
private void reSetNode(User user,int leve) throws Exception {
|
||||
|
||||
//创建节点束河
|
||||
Set<ExpeditionNodeInfo> nodeSets = createNodeSet(user,leve);
|
||||
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
||||
if (sExpeditionSetting == null) {
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL,"配置表错误,获取数据为空");
|
||||
}
|
||||
if(leve-1>sExpeditionSetting.getMatchForce().length){
|
||||
throw new ErrorCodeException(ErrorCode.UNKNOWN,"大闹天宫层数错误");
|
||||
}
|
||||
|
||||
// 万分比
|
||||
double base = 10000d;
|
||||
|
||||
// 上下浮动值
|
||||
double minFoce = sExpeditionSetting.getMatchForce()[leve-1][0]/base;
|
||||
double maxFoce = sExpeditionSetting.getMatchForce()[leve-1][1]/base;
|
||||
|
||||
List<List<Integer>> rankTeam = RankLogic.getInstance().getRandomUserByRank(user, nodeSets.size());
|
||||
|
||||
int count = 0;
|
||||
//存储并设置英雄快照
|
||||
for (ExpeditionNodeInfo nodeInfo : nodeSets) {
|
||||
try {
|
||||
// 战斗节点进入
|
||||
if(isBattleNode(nodeInfo.getType())){
|
||||
// 前六名平均等级
|
||||
int averageLevel = HeroLogic.getInstance().getAverageLevel(user,6);
|
||||
// 随机出来机器人等级,(【向上取整】基础等级 *(最低浮动 + (当前节点位置 / 总层数 *(最高浮动-最低浮动))))
|
||||
int robotLevel = (int) Math.ceil(averageLevel * (minFoce + (nodeInfo.getLay() / 11d * (maxFoce - minFoce))));
|
||||
|
||||
if (nodeInfo.getType() == NODETYPE_ADVANCE){
|
||||
// 精英节点
|
||||
robotLevel += (Math.ceil(sExpeditionSetting.getPowerfulForce()[1][1]/base*robotLevel));
|
||||
}else if (nodeInfo.getType() == NODETYPE_BOSS){
|
||||
// boss节点
|
||||
robotLevel += (Math.ceil(sExpeditionSetting.getPowerfulForce()[2][1]/base*robotLevel));
|
||||
}
|
||||
// 随机出来的队伍信息
|
||||
List<Integer> randomFaceRankTeam = rankTeam.get(count);
|
||||
|
||||
int robotLevel2 = getRobotLevelByUser(user, robotLevel);
|
||||
// 节点英雄快照
|
||||
snapOneFightInfo(nodeInfo,randomFaceRankTeam,robotLevel2);
|
||||
}
|
||||
// boss节点
|
||||
if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType()==ExpeditionLogic.NODETYPE_TRY){
|
||||
snapOneFightInfo(nodeInfo,user);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
user.getExpeditionManager().putExpeditionNodeInfos(nodeInfo.getSortId(), nodeInfo);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户等级修正机器人等级
|
||||
* @param user
|
||||
* @param originalLevel
|
||||
* @return
|
||||
*/
|
||||
private int getRobotLevelByUser(User user,int originalLevel){
|
||||
SExpeditionSetting setting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
||||
// 表配置错误
|
||||
if (setting == null){
|
||||
return originalLevel;
|
||||
}
|
||||
// 用户等级
|
||||
int userLevel = user.getPlayerInfoManager().getLevel();
|
||||
// 等级限制
|
||||
int[] levelLimit = setting.getPlayerLevelfix()[0];
|
||||
// 对应条件
|
||||
int[] condition = setting.getPlayerLevelfix()[1];
|
||||
// 长度不等
|
||||
if (levelLimit.length != condition.length){
|
||||
return originalLevel;
|
||||
}
|
||||
// 修正的等级
|
||||
int offset = 0;
|
||||
// 计数器,防止表里的修正等级为0
|
||||
int count = 0;
|
||||
for (int i = 0; i < levelLimit.length; i++) {
|
||||
// 满足条件
|
||||
if (userLevel < levelLimit[i]){
|
||||
offset = condition[i];
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 等级超过限制条件,取最大限制条件
|
||||
if (offset == 0 && count == 0){
|
||||
offset = condition[condition.length-1];
|
||||
}
|
||||
|
||||
int level = originalLevel+offset;
|
||||
|
||||
return level>1?level:1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点结构 确定type id state
|
||||
*/
|
||||
private Set<ExpeditionNodeInfo> createNodeSet(User user,int leve) throws Exception {
|
||||
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
|
||||
int totalIndex = 1;
|
||||
// 配置表信息
|
||||
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
||||
if(leve-1>sExpeditionSetting.getMatchForce().length){
|
||||
throw new ErrorCodeException(ErrorCode.UNKNOWN,"大闹天宫层数错误");
|
||||
}
|
||||
|
||||
// 节点信息
|
||||
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
|
||||
Map<Integer, SExpeditionFloorConfig> config = STableManager.getConfig(SExpeditionFloorConfig.class);
|
||||
// 根据层数获取对应得每行id
|
||||
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;
|
||||
if(ids.contains(sExpeditionFloorConfig.getId())){
|
||||
// 创建每行的节点
|
||||
createNodesByLay(user,sExpeditionFloorConfig.getId(),leve,nodeSets);
|
||||
}
|
||||
int lay = sExpeditionFloorConfig.getId();
|
||||
}
|
||||
return nodeSets;
|
||||
}
|
||||
|
||||
//必出节点 生成本层id
|
||||
List<Integer> indexList = MathUtils.combineList(totalIndex, totalIndex + sExpeditionFloorConfig.getNode() - 1);
|
||||
if (indexList.size() <= 0) {
|
||||
continue;
|
||||
/**
|
||||
* 根据id创建一小层得战斗节点
|
||||
* @param id
|
||||
* @param nodeSets
|
||||
* @throws Exception
|
||||
*/
|
||||
private void createNodesByLay(User user,int id,int leve,Set<ExpeditionNodeInfo> nodeSets) throws Exception{
|
||||
SExpeditionFloorConfig config = STableManager.getConfig(SExpeditionFloorConfig.class).get(id);
|
||||
if (config == null){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"配置表id错误:"+id);
|
||||
}
|
||||
// 排序
|
||||
int sort = nodeSets.size()+1;
|
||||
// 节点类型列表
|
||||
List<Integer> nodeType = getNodeType(config);
|
||||
|
||||
for (int i = 0; i < nodeType.size(); i++) {
|
||||
// 根据节点类型获取接口
|
||||
AbstractExpedition expedition = ExpeditionEnum.getExpedition(nodeType.get(i));
|
||||
if (expedition != null){
|
||||
// 创建节点信息
|
||||
ExpeditionNodeInfo nodeInfo = expedition.creatNodes(user.getId(),id,leve,sort,config.getFloorLay());
|
||||
nodeSets.add(nodeInfo);
|
||||
// mongodb:入库
|
||||
user.getExpeditionManager().putExpeditionNodeInfos(nodeInfo.getSortId(),nodeInfo);
|
||||
sort++;
|
||||
}
|
||||
//生成随机节点
|
||||
if(map.containsKey(lay)){
|
||||
for (Integer itemType:map.get(lay)) {
|
||||
ExpeditionNodeInfo nodeInfo = getNode(user,sExpeditionFloorConfig, itemType);
|
||||
}
|
||||
}
|
||||
|
||||
nodeInfo.setLay(lay-orDefault);
|
||||
if (nodeInfo.getLay() == 2) {
|
||||
nodeInfo.setState(NODESTATE_NOT_PASS);
|
||||
}
|
||||
nodeInfo.setSortId(indexList.remove(0));
|
||||
nodeSets.add(nodeInfo);
|
||||
totalIndex++;
|
||||
if (indexList.size() == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取节点类型
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
private List<Integer> getNodeType(SExpeditionFloorConfig config){
|
||||
List<Integer> list = new ArrayList<>(config.getNode());
|
||||
// 随机节点
|
||||
int[][] randomNode = config.getRandomNode();
|
||||
if (randomNode != null && randomNode.length > 0){
|
||||
int weight = 0;
|
||||
// 计算权重
|
||||
for (int[] ints2 : randomNode) {
|
||||
weight+=ints2[1];
|
||||
}
|
||||
|
||||
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(user, sExpeditionFloorConfig, typeArr[0], Math.min(typeArr[1],indexList.size()));
|
||||
|
||||
tempnode.forEach(nodeInfo -> {
|
||||
if(indexList.size()==0){
|
||||
return;
|
||||
}
|
||||
nodeInfo.setLay(lay-orDefault);
|
||||
if (nodeInfo.getLay() == 2) {
|
||||
nodeInfo.setState(NODESTATE_NOT_PASS);
|
||||
}
|
||||
nodeInfo.setSortId(indexList.remove(0));
|
||||
});
|
||||
nodeSets.addAll(tempnode);
|
||||
totalIndex += tempnode.size();
|
||||
if (indexList.size() == 0) {
|
||||
// 概率随机
|
||||
int rondom = MathUtils.randomInt(weight);
|
||||
for (int[] ints2 : randomNode) {
|
||||
if (rondom <= ints2[1]){
|
||||
// 目前,随机节点只取一个
|
||||
list.add(ints2[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (indexList.size() == 0) {
|
||||
continue;
|
||||
// 固定节点
|
||||
int[][] nodeType = config.getNodeType();
|
||||
for (int[] ints1 : nodeType) {
|
||||
for (int i = 0; i < ints1[1]; i++) {
|
||||
list.add(ints1[0]);
|
||||
}
|
||||
//生成剩余节点
|
||||
for (Integer anIndexList : indexList) {
|
||||
//TODO 概率走配置
|
||||
int type = NODETYPE_NORMAL;
|
||||
}
|
||||
|
||||
// 节点不足,随机普通和精英节点
|
||||
int num = config.getNode() - list.size();
|
||||
if (num > 0){
|
||||
int type = NODETYPE_NORMAL;
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (Math.random() <= 0.3d) {
|
||||
type = NODETYPE_ADVANCE;
|
||||
}
|
||||
ExpeditionNodeInfo nodeInfo = getNode(user,sExpeditionFloorConfig, type);
|
||||
nodeInfo.setLay(lay-orDefault);
|
||||
if (nodeInfo.getLay() == 2) {
|
||||
nodeInfo.setState(NODESTATE_NOT_PASS);
|
||||
}
|
||||
nodeInfo.setSortId(anIndexList);
|
||||
nodeSets.add(nodeInfo);
|
||||
totalIndex++;
|
||||
list.add(type);
|
||||
}
|
||||
|
||||
}
|
||||
return nodeSets;
|
||||
}
|
||||
|
||||
private ExpeditionNodeInfo getNode(User user,SExpeditionFloorConfig cfg, int type) throws Exception {
|
||||
return getNode(user, cfg, type, 1).iterator().next();
|
||||
}
|
||||
|
||||
private Set<ExpeditionNodeInfo> getNode(User user, SExpeditionFloorConfig cfg, int type, int num) throws Exception {
|
||||
Set<ExpeditionNodeInfo> nodeSets = new HashSet<>();
|
||||
for (int i = 0; i < num; i++) {
|
||||
ExpeditionNodeInfo nodeInfo = new ExpeditionNodeInfo();
|
||||
nodeInfo.setType(type);
|
||||
|
||||
//生成圣物 設置
|
||||
if (type == NODETYPE_ADVANCE || type == NODETYPE_BOSS || type == NODETYPE_NORMAL) {
|
||||
|
||||
Set<Integer> staffsSet = new HashSet<>();
|
||||
while (staffsSet.size()<3){
|
||||
|
||||
int[][] holyProbability = new int[cfg.getHolyProbability().length][2];
|
||||
for(int j = 0; j < holyProbability.length; j++){
|
||||
System.arraycopy(cfg.getHolyProbability()[j], 0, holyProbability[j], 0, 2);
|
||||
}
|
||||
|
||||
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(type);
|
||||
if(null!=sExpeditionNodeConfig && sExpeditionNodeConfig.getHolyProbability().length==3){
|
||||
for (int j = 0; j <holyProbability.length ; j++) {
|
||||
holyProbability[j][1]+= sExpeditionNodeConfig.getHolyProbability()[j][1];
|
||||
}
|
||||
}
|
||||
int ints;
|
||||
try {
|
||||
ints = MathUtils.randomFromWeight(holyProbability);
|
||||
}catch (Exception e){
|
||||
break;
|
||||
}
|
||||
Map<Integer, Integer> type2holy2weight = getType2holy2weightRemoveHas(user,ints);
|
||||
int i1 = ranndomFromWeight(type2holy2weight);
|
||||
staffsSet.add(i1);
|
||||
}
|
||||
nodeInfo.setHolyEquipId(staffsSet);
|
||||
}
|
||||
|
||||
nodeInfo.setState(NODESTATE_CLOSE);
|
||||
nodeSets.add(nodeInfo);
|
||||
}
|
||||
return nodeSets;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点英雄快照
|
||||
*/
|
||||
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, CommonProto.Hero> heroMapList = sArenaRobotConfig.getHeroMapList();
|
||||
Map<String, Double> bossHP = new HashMap<>();
|
||||
|
||||
int innerPosition= 1;
|
||||
for (Map.Entry<Integer, CommonProto.Hero> item : heroMapList.entrySet()) {
|
||||
StringBuilder skillSb = new StringBuilder();
|
||||
Integer heroTid = item.getKey();
|
||||
Integer heroStar = item.getValue().getStar();
|
||||
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, 0, differDemonsId, differDemonsLv, false);
|
||||
heroAllAttribute.put(heroTid.toString(), new FamilyHeroInfo(heroTid, robotLevel, heroStar, robotHeroAttribute,innerPosition++));
|
||||
// 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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版2021-2-25,节点英雄快照
|
||||
* @param nodeInfo
|
||||
* @param heroIds
|
||||
* @param level
|
||||
*/
|
||||
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo, List<Integer> heroIds, int level) {
|
||||
// 非战斗节点类型
|
||||
if (!isBattleNode(nodeInfo.getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SnapFightInfo fightInfo = new SnapFightInfo();
|
||||
// 英雄列表
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
// boss血量,这里无用
|
||||
Map<String, Double> bossHP = new HashMap<>();
|
||||
// 获取对应等级的机器人信息
|
||||
SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level);
|
||||
if (property == null){
|
||||
Map<Integer, SRobotProperty> config = STableManager.getConfig(SRobotProperty.class);
|
||||
// 玩家等级超上限,取表里最大值
|
||||
property = config.get(config.values().size());
|
||||
}
|
||||
// 英雄属性
|
||||
Map<Integer, Integer> robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(property);
|
||||
|
||||
// 位置坐标
|
||||
int innerPosition = 1;
|
||||
// 战力
|
||||
int force = 0;
|
||||
|
||||
for (Integer id : heroIds) {
|
||||
// 获取技能列表,包含主动和被动技能
|
||||
String skills = SRobotSkill.getSkills(id, property.getSkillPool()-1);
|
||||
fightInfo.updateHeroSkill(id.toString(), skills.substring(0, skills.length() - 1));
|
||||
// 需要赋值
|
||||
bossHP.put(id.toString(), 1D);
|
||||
force+=HeroLogic.getInstance().calForce(robotHeroAttribute);
|
||||
heroAllAttribute.put(id.toString(), new FamilyHeroInfo(id, level, property.getStar(), robotHeroAttribute,innerPosition++));
|
||||
}
|
||||
|
||||
fightInfo.setForce(force);
|
||||
fightInfo.setPokenmonSkills(StringUtil.parseArrayToString(property.getAnimal()));
|
||||
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;
|
||||
|
||||
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);
|
||||
String pokenmonPassiveSkills = HeroLogic.getInstance().getPokenmonPassiveSkills(user, snapTeamId);
|
||||
// fightInfo.setPokenmonSkills(pokenmonSkills);
|
||||
fightInfo.setPassiveSkills(pokenmonPassiveSkills);
|
||||
}
|
||||
|
||||
|
||||
nodeInfo.setSnapFightInfo(fightInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 节点英雄快照,试炼节点和贪婪节点生成节点数据
|
||||
*/
|
||||
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo,User user) throws ErrorCodeException{
|
||||
|
||||
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());
|
||||
int poolId = sExpeditionNodeConfig.getPoolId();
|
||||
SnapFightInfo fightInfo = new SnapFightInfo();
|
||||
int tempId =ExpeditionLogic.getRandomTid(poolId,1).first();
|
||||
SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(tempId);
|
||||
if(sExpeditionRecruitConfig==null) {
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
int heroId = sExpeditionRecruitConfig.getHeroId();
|
||||
|
||||
fightInfo.setUid(heroId);
|
||||
Map<String, Double> bossHP = new HashMap<>();
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
String pokemon = "";
|
||||
if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED){
|
||||
//grop config
|
||||
int force = MonsterUtil.getMonsterForce(new int[]{heroId});
|
||||
|
||||
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(heroId);
|
||||
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.setForce(force);
|
||||
fightInfo.setPassiveSkills("");
|
||||
}else{
|
||||
int level = HeroLogic.getInstance().getAverageLevel(user, 6);
|
||||
RobotInfo robot = FightUtil.createRobot(fightInfo.getUid(), level);
|
||||
//组装
|
||||
String skills = robot.getSkill() + robot.getPassiveSkill();
|
||||
bossHP.put(Integer.toString(heroId),1d);
|
||||
int force = HeroLogic.getInstance().calForce(robot.getRobotHeroAttribute());
|
||||
fightInfo.setForce(force);
|
||||
//试炼节点 放到第二个位置上
|
||||
heroAllAttribute.put(Integer.toString(heroId), new FamilyHeroInfo(heroId,level,robot.getStar(),robot.getRobotHeroAttribute(),2));
|
||||
fightInfo.updateHeroSkill(String.valueOf(heroId),skills.substring(0,skills.length()-1));
|
||||
// 获取灵兽信息
|
||||
SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level);
|
||||
pokemon = StringUtil.parseArrayToString(property.getAnimal());
|
||||
}
|
||||
fightInfo.setPassiveSkills("");
|
||||
fightInfo.setHeroAttribute(heroAllAttribute);
|
||||
nodeInfo.setBossHP(bossHP);
|
||||
fightInfo.setPokenmonSkills(pokemon);
|
||||
nodeInfo.setSnapFightInfo(fightInfo);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static boolean isBattleNode(int type) {
|
||||
|
|
@ -794,7 +445,7 @@ public class ExpeditionLogic {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
private static int ranndomFromWeight(Map<Integer, Integer> weight) {
|
||||
public static int ranndomFromWeight(Map<Integer, Integer> weight) {
|
||||
int amount;
|
||||
int result = 0;
|
||||
IntSummaryStatistics collect = weight.values().stream().collect(Collectors.summarizingInt(value -> value));
|
||||
|
|
@ -811,12 +462,16 @@ public class ExpeditionLogic {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//返回猎妖之路下一个阶段sortId;
|
||||
/**
|
||||
* 返回猎妖之路下一个阶段sortId;
|
||||
* @param sortId
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> getNextNodeId(int sortId,int size){
|
||||
LinkedList<Integer> integers= new LinkedList<>();
|
||||
boolean b = sortId >= size - 2;//是否是boss节点 节点从2开始计算
|
||||
//是否是boss节点 节点从2开始计算
|
||||
boolean b = sortId >= size - 2;
|
||||
if(b){
|
||||
integers.add(sortId+1);
|
||||
return integers;
|
||||
|
|
@ -879,7 +534,7 @@ public class ExpeditionLogic {
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkAndResetTreasure(User user) throws Exception {
|
||||
private static void checkAndResetTreasure(User user) throws Exception {
|
||||
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
|
||||
WorldTreasureReward worldTreasureReward = user.getExpeditionManager().getWorldTreasureReward();
|
||||
if(worldTreasureReward.getFirstStartTime()>TimeUtils.nowInt()){
|
||||
|
|
@ -1234,77 +889,4 @@ public class ExpeditionLogic {
|
|||
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不重复得圣物
|
||||
* @param user
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private Map<Integer, Integer> getType2holy2weightRemoveHas(User user, int type) {
|
||||
// 策划表的圣物,因为会有删除操作,所以需要重新赋值,而不是直接引用
|
||||
Map<Integer, Integer> weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weight(type);
|
||||
Map<Integer, Integer> valueMap = new HashMap<>(weight);
|
||||
|
||||
// 已拥有的圣物
|
||||
Set<ExpeditionItem> items = user.getExpeditionManager().getPropertyItems();
|
||||
Set<Integer> ids = new HashSet<>();
|
||||
items.forEach(id->ids.add(id.getEquipId()));
|
||||
|
||||
// 已拥有英雄
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
Set<Integer> heroIds = new HashSet<>();
|
||||
heroMap.values().forEach(v->heroIds.add(v.getTemplateId()));
|
||||
|
||||
// 大闹天宫临时英雄
|
||||
Map<String, Hero> expeditonHeroMap = user.getExpeditionManager().getHeroMap();
|
||||
Set<Integer> expeditonHeroIds = new HashSet<>();
|
||||
expeditonHeroMap.values().forEach(v->expeditonHeroIds.add(v.getTemplateId()));
|
||||
|
||||
// 已生成得节点圣物信息
|
||||
Set<Integer> nodeHolyInfo = getNodeHolyInfo(user);
|
||||
|
||||
// 因为有删除操作,所以使用iterator遍历
|
||||
Iterator<Integer> 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();
|
||||
}
|
||||
}
|
||||
// 已经生成过得圣物
|
||||
if(nodeHolyInfo.contains(v)){
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部节点得圣物信息
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
private Set<Integer> getNodeHolyInfo(User user){
|
||||
Set<Integer> set = new HashSet<>();
|
||||
// 以生成得节点信息,非空验证
|
||||
Collection<ExpeditionNodeInfo> values = user.getExpeditionManager().getExpeditionNodeInfos().values();
|
||||
if (values.size() <= 0){
|
||||
return set;
|
||||
}
|
||||
// 聚合操作,首先排除不存在圣物得节点,然后循环添加剩余节点圣物
|
||||
values.stream()
|
||||
.filter(val->val.getHolyEquipId() != null && val.getHolyEquipId().size() > 0)
|
||||
.forEach(val->set.addAll(val.getHolyEquipId()));
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.ljsd.jieling.logic.expedition;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
|
||||
|
||||
/**
|
||||
* 其他节点,统一处理
|
||||
* @author hj
|
||||
*/
|
||||
public class OtherNode extends AbstractExpedition {
|
||||
OtherNode(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpeditionNodeInfo creatNodes(int uid, int index, int leve, int sortId, int lay) throws Exception {
|
||||
return creatNodes(sortId,lay);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package com.ljsd.jieling.logic.expedition;
|
||||
|
||||
import com.ljsd.fight.FamilyHeroInfo;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo;
|
||||
import com.ljsd.jieling.logic.dao.SnapFightInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.fight.robot.RobotInfo;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import config.SExpeditionNodeConfig;
|
||||
import config.SExpeditionRecruitConfig;
|
||||
import config.SRobotProperty;
|
||||
import manager.STableManager;
|
||||
import util.StringUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 特殊节点
|
||||
* 试炼
|
||||
* @author hj
|
||||
*/
|
||||
public class SpecialNode extends AbstractExpedition {
|
||||
|
||||
SpecialNode(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpeditionNodeInfo creatNodes(int uid,int index,int leve,int sortId, int lay) throws Exception {
|
||||
ExpeditionNodeInfo nodeInfo = creatNodes(sortId, lay);
|
||||
|
||||
User user = UserManager.getUser(uid);
|
||||
snapOneFightInfo(nodeInfo,user);
|
||||
|
||||
return nodeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点英雄快照,试炼节点生成节点数据
|
||||
*/
|
||||
private void snapOneFightInfo(ExpeditionNodeInfo nodeInfo, User user) throws ErrorCodeException {
|
||||
|
||||
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());
|
||||
int poolId = sExpeditionNodeConfig.getPoolId();
|
||||
SnapFightInfo fightInfo = new SnapFightInfo();
|
||||
int tempId =ExpeditionLogic.getRandomTid(poolId,1).first();
|
||||
SExpeditionRecruitConfig sExpeditionRecruitConfig = STableManager.getConfig(SExpeditionRecruitConfig.class).get(tempId);
|
||||
if(sExpeditionRecruitConfig==null) {
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
int heroId = sExpeditionRecruitConfig.getHeroId();
|
||||
|
||||
fightInfo.setUid(heroId);
|
||||
Map<String, Double> bossHP = new HashMap<>();
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
|
||||
int level = HeroLogic.getInstance().getAverageLevel(user, 6);
|
||||
RobotInfo robot = FightUtil.createRobot(fightInfo.getUid(), level);
|
||||
//组装
|
||||
String skills = robot.getSkill() + robot.getPassiveSkill();
|
||||
bossHP.put(Integer.toString(heroId),1d);
|
||||
int force = HeroLogic.getInstance().calForce(robot.getRobotHeroAttribute());
|
||||
fightInfo.setForce(force);
|
||||
//试炼节点 放到第二个位置上
|
||||
heroAllAttribute.put(Integer.toString(heroId), new FamilyHeroInfo(heroId,level,robot.getStar(),robot.getRobotHeroAttribute(),2));
|
||||
fightInfo.updateHeroSkill(String.valueOf(heroId),skills.substring(0,skills.length()-1));
|
||||
// 获取灵兽信息
|
||||
SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level);
|
||||
String pokemon = StringUtil.parseArrayToString(property.getAnimal());
|
||||
|
||||
fightInfo.setPassiveSkills("");
|
||||
fightInfo.setHeroAttribute(heroAllAttribute);
|
||||
nodeInfo.setBossHP(bossHP);
|
||||
fightInfo.setPokenmonSkills(pokemon);
|
||||
nodeInfo.setSnapFightInfo(fightInfo);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.ljsd.jieling.logic.rank;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.rank.rankImpl.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ public class SExpeditionFloorConfig implements BaseConfig {
|
|||
|
||||
private int floor;
|
||||
|
||||
private int floorLay;
|
||||
|
||||
private int node;
|
||||
|
||||
private int[][] nodeType;
|
||||
|
|
@ -60,5 +62,7 @@ public class SExpeditionFloorConfig implements BaseConfig {
|
|||
return treasureBox;
|
||||
}
|
||||
|
||||
|
||||
public int getFloorLay() {
|
||||
return floorLay;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ public class SExpeditionHolyConfig implements BaseConfig {
|
|||
// 专属英雄id,0表示没有
|
||||
private int heroId;
|
||||
|
||||
private int[] skillModify;
|
||||
private int[][] skillModify;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
|
@ -63,7 +63,7 @@ public class SExpeditionHolyConfig implements BaseConfig {
|
|||
return heroId;
|
||||
}
|
||||
|
||||
public int[] getSkillModify() {
|
||||
public int[][] getSkillModify() {
|
||||
return skillModify;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue