大闹天宫,遇敌

back_recharge
duhui 2021-03-01 11:01:24 +08:00
parent 2dc01e8b26
commit 974891f80a
5 changed files with 145 additions and 190 deletions

View File

@ -363,44 +363,4 @@ public class CommonStaticConfig extends AbstractClassStaticConfig {
return type2holy2weight.get(type); return type2holy2weight.get(type);
} }
public Map<Integer, Integer> getType2holy2weightRemoveHas(User user, int type) {
// 策划表的圣物,因为会有删除操作,所以需要重新赋值,而不是直接引用
Map<Integer, Integer> weight = 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()));
// 因为有删除操作所以使用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();
}
}
}
return valueMap;
}
} }

View File

@ -21,7 +21,10 @@ import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic; import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.rank.RankLogic; import com.ljsd.jieling.logic.rank.RankLogic;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
import com.ljsd.jieling.logic.store.BuyGoodsLogic; import com.ljsd.jieling.logic.store.BuyGoodsLogic;
import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.network.session.ISession;
@ -34,6 +37,7 @@ import manager.STableManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.ZSetOperations; import org.springframework.data.redis.core.ZSetOperations;
import rpc.protocols.PlayerInfoProto;
import util.MathUtils; import util.MathUtils;
import util.TimeUtils; import util.TimeUtils;
@ -311,33 +315,41 @@ public class ExpeditionLogic {
// 万分比 // 万分比
double base = 10000d; double base = 10000d;
//存储并设置英雄快照 // 上下浮动值
nodeSets.forEach(nodeInfo -> { double minFoce = sExpeditionSetting.getMatchForce()[leve-1][0]/base;
int sortId = nodeInfo.getSortId(); double maxFoce = sExpeditionSetting.getMatchForce()[leve-1][1]/base;
try {
//存储并设置英雄快照
for (ExpeditionNodeInfo nodeInfo : nodeSets) {
try {
// 战斗节点进入
if(isBattleNode(nodeInfo.getType())){ if(isBattleNode(nodeInfo.getType())){
// 上下浮动值
double minFoce = sExpeditionSetting.getMatchForce()[leve-1][0]/base;
double maxFoce = sExpeditionSetting.getMatchForce()[leve-1][1]/base;
// 前六名平均等级 // 前六名平均等级
int averageLevel = HeroLogic.getInstance().getAverageLevel(user,6); int averageLevel = HeroLogic.getInstance().getAverageLevel(user,6);
// 随机出来机器人等级 // 随机出来机器人等级,(【向上取整】基础等级 *(最低浮动 + (当前节点位置 / 总层数 *(最高浮动-最低浮动))))
int robotLevel = MathUtils.random((int)Math.ceil(averageLevel*minFoce),(int)Math.ceil(averageLevel*maxFoce)); 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 = getRandomFaceRankTeam(user); List<Integer> randomFaceRankTeam = getRandomFaceRankTeam(user);
// 节点英雄快照 // 节点英雄快照
snapOneFightInfo(nodeInfo,randomFaceRankTeam,robotLevel); snapOneFightInfo(nodeInfo,randomFaceRankTeam,robotLevel);
} }
// boss节点 // boss节点
if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType() ==ExpeditionLogic.NODETYPE_TRY){ if(nodeInfo.getType()==ExpeditionLogic.NODETYPE_GREED||nodeInfo.getType()==ExpeditionLogic.NODETYPE_TRY){
snapOneFightInfo(nodeInfo); snapOneFightInfo(nodeInfo);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
user.getExpeditionManager().putExpeditionNodeInfos(sortId, nodeInfo); user.getExpeditionManager().putExpeditionNodeInfos(nodeInfo.getSortId(), nodeInfo);
}); }
} }
/** /**
@ -347,14 +359,52 @@ public class ExpeditionLogic {
* @throws Exception * @throws Exception
*/ */
private List<Integer> getRandomFaceRankTeam(User user) throws Exception { private List<Integer> getRandomFaceRankTeam(User user) throws Exception {
// 获取随机排名的用户id // 战力排行榜
int uid = RankLogic.getInstance().getRandomByFoceRank(user, 1, 50); AbstractRank rank = RankContext.getRankEnum(RankEnum.FORCE_CURR_RANK.getType());
// 获取排行信息
User other = UserManager.getUser(uid); PlayerInfoProto.RankResponse rankResponse = null;
// 获取其主线队伍阵容 try {
List<TeamPosHeroInfo> heroInfos = other.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.FORMATION_NORMAL); rankResponse = rank.getRank(user.getId(), "", 1, 50);
} catch (Exception e) {
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"获取战力排行榜数据错误");
}
List<TeamPosHeroInfo> heroInfos = new ArrayList<>();
ArrayList<Integer> integers = new ArrayList<>(); ArrayList<Integer> integers = new ArrayList<>();
// -1方便后面取值操作防止下标越界异常
int rankSize = rankResponse.getRanksCount()-1;
if (rankSize < 0){
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"战力排行榜找不到人");
}
// 计数器
int count = 0;
do {
// 从0开始的随机
int random = MathUtils.randomInt(50);
// 随机排名
int anInt = random > rankSize?rankSize:random;
CommonProto.UserRank ranks = rankResponse.getRanks(anInt);
User other = UserManager.getUser(ranks.getUid());
// 获取随机玩家的主线队伍阵容
heroInfos = other.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.FORMATION_NORMAL);
if (heroInfos.size() < 6){
count++;
}else {
heroInfos.forEach(v->{
// 获取英雄模板id
Hero hero = other.getHeroManager().getHero(v.getHeroId());
integers.add(hero.getTemplateId());
});
return integers;
}
}while (count < 5);
// 走到这里说明五次循环全部不足6个英雄直接取第一名的队伍
CommonProto.UserRank ranks = rankResponse.getRanks(0);
User other = UserManager.getUser(ranks.getUid());
// 获取随机玩家的主线队伍阵容
heroInfos = other.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.FORMATION_NORMAL);
heroInfos.forEach(v->{ heroInfos.forEach(v->{
// 获取英雄模板id // 获取英雄模板id
Hero hero = other.getHeroManager().getHero(v.getHeroId()); Hero hero = other.getHeroManager().getHero(v.getHeroId());
@ -501,7 +551,7 @@ public class ExpeditionLogic {
}catch (Exception e){ }catch (Exception e){
break; break;
} }
Map<Integer, Integer> type2holy2weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weightRemoveHas(user,ints); Map<Integer, Integer> type2holy2weight = getType2holy2weightRemoveHas(user,ints);
int i1 = ranndomFromWeight(type2holy2weight); int i1 = ranndomFromWeight(type2holy2weight);
staffsSet.add(i1); staffsSet.add(i1);
} }
@ -578,26 +628,21 @@ public class ExpeditionLogic {
Map<String, Double> bossHP = new HashMap<>(); Map<String, Double> bossHP = new HashMap<>();
// 获取对应等级的机器人信息 // 获取对应等级的机器人信息
SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level); SRobotProperty property = STableManager.getConfig(SRobotProperty.class).get(level);
// 英雄属性
Map<Integer, Integer> robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(property);
// 自增标识 // 位置坐标
int innerPosition= 1; int innerPosition = 1;
// 战力 // 战力
int force = 0; int force = 0;
for (Integer id : heroIds) { for (Integer id : heroIds) {
SCHero scHero = SCHero.getsCHero().get(id);
// 获取技能列表,包含主动和被动技能 // 获取技能列表,包含主动和被动技能
String skills = SRobotSkill.getSkills(id, property.getSkillPool()); String skills = SRobotSkill.getSkills(id, property.getSkillPool()-1);
fightInfo.updateHeroSkill(id.toString(), skills.substring(0, skills.length() - 1)); fightInfo.updateHeroSkill(id.toString(), skills.substring(0, skills.length() - 1));
// 需要赋值 // 需要赋值
bossHP.put(id.toString(), 1D); bossHP.put(id.toString(), 1D);
// 空值初始化
int[] differDemonsId = null;
int differDemonsLv = 0;
// 英雄属性
Map<Integer, Integer> robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(scHero, level, 0, differDemonsId, differDemonsLv, false);
force+=HeroLogic.getInstance().calForce(robotHeroAttribute); force+=HeroLogic.getInstance().calForce(robotHeroAttribute);
heroAllAttribute.put(id.toString(), new FamilyHeroInfo(id, level, property.getStar(), robotHeroAttribute,innerPosition++)); heroAllAttribute.put(id.toString(), new FamilyHeroInfo(id, level, property.getStar(), robotHeroAttribute,innerPosition++));
} }
@ -869,8 +914,8 @@ public class ExpeditionLogic {
*/ */
public static Hero createHero(int tempid,int uid,Hero hero,int nodeId)throws Exception{ public static Hero createHero(int tempid,int uid,Hero hero,int nodeId)throws Exception{
boolean isTemp = nodeId != -1; boolean isTemp = nodeId != -1;
int star = hero.getOriginalLevel();
User user = UserManager.getUser(uid); User user = UserManager.getUser(uid);
int level = HeroLogic.getInstance().getAverageLevel(user,6);
SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1); SExpeditionSetting sExpeditionSetting = STableManager.getConfig(SExpeditionSetting.class).get(1);
if (sExpeditionSetting == null) { if (sExpeditionSetting == null) {
throw new ErrorCodeException(ErrorCode.CFG_NULL); throw new ErrorCodeException(ErrorCode.CFG_NULL);
@ -878,9 +923,9 @@ public class ExpeditionLogic {
//random star //random star
int min = sExpeditionSetting.getLevelForce()[0]; int min = sExpeditionSetting.getLevelForce()[0];
int max= sExpeditionSetting.getLevelForce()[1]; int max= sExpeditionSetting.getLevelForce()[1];
int finalstar = (int) (star * ((min / 10000f) + ((float) (Math.random() *(max - min))/10000f))); int finalLevel = (int) (level * ((min / 10000f) + ((float) (Math.random() *(max - min))/10000f)));
if(finalstar<=20){ if(finalLevel<=20){
finalstar=50; finalLevel=50;
} }
SCHero hero1 = SCHero.getsCHero().get(tempid); SCHero hero1 = SCHero.getsCHero().get(tempid);
if (hero1 == null) { if (hero1 == null) {
@ -888,14 +933,14 @@ public class ExpeditionLogic {
} }
SCHeroRankUpConfig scHeroRankUpConfig = STableManager.getConfig(SCHeroRankUpConfig.class).get(hero1.getStar()); SCHeroRankUpConfig scHeroRankUpConfig = STableManager.getConfig(SCHeroRankUpConfig.class).get(hero1.getStar());
if (null != scHeroRankUpConfig && finalstar > scHeroRankUpConfig.getOpenLevel()) { if (null != scHeroRankUpConfig && finalLevel > scHeroRankUpConfig.getOpenLevel()) {
finalstar = scHeroRankUpConfig.getOpenLevel(); finalLevel = scHeroRankUpConfig.getOpenLevel();
} }
//random tempid //random tempid
Hero newHero = new Hero(uid,tempid,finalstar,hero); Hero newHero = new Hero(uid,tempid,finalLevel,hero);
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();
@ -1129,4 +1174,45 @@ public class ExpeditionLogic {
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true); MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
} }
public 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()));
// 因为有删除操作所以使用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();
}
}
}
return valueMap;
}
} }

View File

@ -1995,6 +1995,17 @@ public class HeroLogic{
return heroAllAttribute; return heroAllAttribute;
} }
public Map<Integer,Integer> calRobotHeroAttribute(SRobotProperty property){
int[][] property1 = property.getProperty();
if (property1 == null){
return new HashMap<>();
}
Map<Integer, Integer> attribute = new HashMap<>(property1.length);
for (int[] anInt : property1) {
attribute.put(anInt[0],anInt[1]);
}
return attribute;
}
/** /**
* *
@ -4333,15 +4344,12 @@ public class HeroLogic{
List<Hero> heroes = new ArrayList<>(values); List<Hero> heroes = new ArrayList<>(values);
// 玩家英雄背包按等级排序 // 玩家英雄背包按等级排序
Collections.sort(heroes, new Comparator<Hero>() { Collections.sort(heroes, (hero1, hero2) -> {
@Override int compareValue = hero2.getOriginalLevel() - hero1.getOriginalLevel();
public int compare(Hero hero1, Hero hero2) { if (compareValue != 0) {
int compareValue = hero2.getOriginalLevel() - hero1.getOriginalLevel(); return compareValue;
if (compareValue != 0) {
return compareValue;
}
return Integer.compare(hero2.getStar(), hero1.getStar());
} }
return Integer.compare(hero2.getStar(), hero1.getStar());
}); });
// 等级相加 // 等级相加
int count = 0; int count = 0;
@ -4349,7 +4357,7 @@ public class HeroLogic{
count += heroes.get(i).getLevel(heroManager); count += heroes.get(i).getLevel(heroManager);
} }
// 避免zero异常 // 避免zero异常
if (count == 0 || num == 0){ if (count == 0){
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE); throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE);
} }
return count/num; return count/num;

View File

@ -1,11 +1,13 @@
package com.ljsd.jieling.logic.rank; package com.ljsd.jieling.logic.rank;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.exception.ErrorCode; import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException; import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason; import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.ktbeans.ReportEventEnum; import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil; import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.dao.PlayerManager; import com.ljsd.jieling.logic.dao.PlayerManager;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
@ -23,6 +25,7 @@ import org.slf4j.LoggerFactory;
import rpc.world.WorldProto; import rpc.world.WorldProto;
import util.MathUtils; import util.MathUtils;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -80,36 +83,6 @@ public class RankLogic {
MessageUtil.sendMessage(session,1,messageType.getNumber(),rankResponse,true); MessageUtil.sendMessage(session,1,messageType.getNumber(),rankResponse,true);
} }
/**
*
* @param user
* @param start
* @param end
* @return
* @throws Exception
*/
public int getRandomByFoceRank(User user,int start,int end) {
// 战力排行榜
AbstractRank rank = RankContext.getRankEnum(RankEnum.FORCE_CURR_RANK.getType());
// 获取排行信息
PlayerInfoProto.RankResponse rankResponse = null;
try {
rankResponse = rank.getRank(user.getId(), "", start, end);
} catch (Exception e) {
LOGGER.error("获取战力排行榜数据错误:{}",e.getMessage());
return 0;
}
int random = MathUtils.randomInt(end)+1;
int rankSize = rankResponse.getRanksCount();
// 随机排名
int anInt = random > rankSize?rankSize:random;
CommonProto.UserRank ranks = rankResponse.getRanks(anInt-1);
return ranks.getUid();
}
/** /**
* *
* @param session * @param session

View File

@ -12,31 +12,7 @@ public class SRobotProperty implements BaseConfig {
private int star; private int star;
private int hp; private int[][] property;
private int attack;
private int physicalDefence;
private int magicDefence;
private float hit;
private float dodge;
private float critFactor;
private float critDamageFactor;
private float damageBocusFactor;
private float damageReduceFactor;
private float cureFacter;
private float treatFacter;
private float antiCritDamageFactor;
private int skillPool; private int skillPool;
@ -55,56 +31,8 @@ public class SRobotProperty implements BaseConfig {
return star; return star;
} }
public int getHp() { public int[][] getProperty() {
return hp; return property;
}
public int getAttack() {
return attack;
}
public int getPhysicalDefence() {
return physicalDefence;
}
public int getMagicDefence() {
return magicDefence;
}
public float getHit() {
return hit;
}
public float getDodge() {
return dodge;
}
public float getCritFactor() {
return critFactor;
}
public float getCritDamageFactor() {
return critDamageFactor;
}
public float getDamageBocusFactor() {
return damageBocusFactor;
}
public float getDamageReduceFactor() {
return damageReduceFactor;
}
public float getCureFacter() {
return cureFacter;
}
public float getTreatFacter() {
return treatFacter;
}
public float getAntiCritDamageFactor() {
return antiCritDamageFactor;
} }
public int getSkillPool() { public int getSkillPool() {