优化主角神觉

master_yuenan
DESKTOP-C3M45P4\dengdan 2026-10-07 23:14:28 +08:00
parent a27f49ba42
commit 17fc08fc63
4 changed files with 218 additions and 127 deletions

View File

@ -2739,61 +2739,66 @@ public class HeroLogic {
* @param isForce true:展示 false:战斗
*/
public Map<Integer, Long> calHeroNotBufferAttribute(User user, Hero hero, boolean isForce, int teamId) {
// ... 总属性计算 ...
Map<Integer, Long> heroAllAttribute = calHeroAllAttribute(user, hero, isForce);
heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE));
// 主角属性加成
applyPlayerAndSkill(heroAllAttribute, user);
// 灵兽和神兵
applyPokemonAndMagicSoldierAttribute(heroAllAttribute, teamId, user);
// 图鉴,皮肤,称号,坐骑等。。。
applyBonusesAttribute(heroAllAttribute, hero.getSkin(), user);
// 四象心法增加总属性
applyFourQuadrantAttribute(heroAllAttribute, hero.getTemplateId(), user);
// 英雄好感度增加属性
applyHeroLikableAttribute(heroAllAttribute, hero.getTemplateId(), user);
// 法宝聚灵和命格属性加成
applyTrumpAndGemAttribute(heroAllAttribute, user);
// 工坊科技树加成(废弃)
synchronized (user){
// ... 总属性计算 ...
Map<Integer, Long> heroAllAttribute = calHeroAllAttribute(user, hero, isForce);
heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE));
// 主角属性加成
applyPlayerAndSkill(heroAllAttribute, user);
// 灵兽和神兵
applyPokemonAndMagicSoldierAttribute(heroAllAttribute, teamId, user);
// 图鉴,皮肤,称号,坐骑等。。。
applyBonusesAttribute(heroAllAttribute, hero.getSkin(), user);
// 四象心法增加总属性
applyFourQuadrantAttribute(heroAllAttribute, hero.getTemplateId(), user);
// 英雄好感度增加属性
applyHeroLikableAttribute(heroAllAttribute, hero.getTemplateId(), user);
// 法宝聚灵和命格属性加成
applyTrumpAndGemAttribute(heroAllAttribute, user);
// 工坊科技树加成(废弃)
// applyWorkShopTechnologyAttribute(heroAllAttribute, hero.getTemplateId(), user);
// 装备和套装属性
applyEquipSuiteAttribute(heroAllAttribute, hero, user);
// 魂灵宝加成
applyJewelAttribute(heroAllAttribute, hero, user);
// 礼物装备加成
applyGiftEquipAttribute(heroAllAttribute, hero, user);
// 特训加成
applyTrainingAttribute(heroAllAttribute, hero);
// 法宝,法相加成
applyBaublesAndFaxiangAttribute(heroAllAttribute, hero, user);
// 小兵加成
applySoldierAttribute(heroAllAttribute, hero, user);
// 魂印和神印属性加成
applySoulEquipAndGodSealAttribute(heroAllAttribute, hero, user);
// 助阵
applyAssistAttribute(heroAllAttribute, user);
// 主角修为和修行等级属性加成
applyXiuxingAndXiuxianAttribute(heroAllAttribute, user);
// 公会技能和特权加成
applyGuildSkillAndVipAttribute(heroAllAttribute, hero.getTemplateId(), user);
// 阵营光环,大闹天宫特殊加成
applyTeamAttribute(heroAllAttribute, isForce, teamId, user);
// 被动技能
applyPassiveSkillAttribute(heroAllAttribute, hero, teamId, user);
// 主角六道神脉
applyPlayerMeridiansAttribute(heroAllAttribute,user);
// 装备和套装属性
applyEquipSuiteAttribute(heroAllAttribute, hero, user);
// 魂灵宝加成
applyJewelAttribute(heroAllAttribute, hero, user);
// 礼物装备加成
applyGiftEquipAttribute(heroAllAttribute, hero, user);
// 特训加成
applyTrainingAttribute(heroAllAttribute, hero);
// 法宝,法相加成
applyBaublesAndFaxiangAttribute(heroAllAttribute, hero, user);
// 小兵加成
applySoldierAttribute(heroAllAttribute, hero, user);
// 魂印和神印属性加成
applySoulEquipAndGodSealAttribute(heroAllAttribute, hero, user);
// 助阵
applyAssistAttribute(heroAllAttribute, user);
// 主角修为和修行等级属性加成
applyXiuxingAndXiuxianAttribute(heroAllAttribute, user);
// 公会技能和特权加成
applyGuildSkillAndVipAttribute(heroAllAttribute, hero.getTemplateId(), user);
// 阵营光环,大闹天宫特殊加成
applyTeamAttribute(heroAllAttribute, isForce, teamId, user);
// 被动技能
applyPassiveSkillAttribute(heroAllAttribute, hero, teamId, user);
// 主角六道神脉
applyPlayerMeridiansAttribute(heroAllAttribute,user);
//pvp队伍加成特殊处理,必须放在最后
if (!isForce && !TeamEnum.isPvpTeam(teamId)) {
heroAllAttribute.remove(HeroAttributeEnum.PVPDamageBocusFactor.getPropertyId());
heroAllAttribute.remove(HeroAttributeEnum.PVPDamageReduceFactor.getPropertyId());
}
//pvp队伍加成特殊处理,必须放在最后
if (!isForce && !TeamEnum.isPvpTeam(teamId)) {
heroAllAttribute.remove(HeroAttributeEnum.PVPDamageBocusFactor.getPropertyId());
heroAllAttribute.remove(HeroAttributeEnum.PVPDamageReduceFactor.getPropertyId());
}
// LOGGER.info("战力基础属性1=================={}",heroAllAttribute);
// 总计算
calInteractAdd(heroAllAttribute, isForce);
heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE));
// 总计算
calInteractAdd(heroAllAttribute, isForce);
heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(), heroAllAttribute.get(GlobalsDef.HP_TYPE));
// LOGGER.info("战力基础属性2=================={}",heroAllAttribute);
return heroAllAttribute;
// for(int key : heroAllAttribute.keySet()){
// System.out.println("英雄id : " + hero.getTemplateId() + "---英雄属性 key : " + key + "----value : " + heroAllAttribute.get(key) + "------------");
// }
return heroAllAttribute;
}
}
private void applyPokemonAndMagicSoldierAttribute(Map<Integer, Long> heroAllAttribute, int teamId, User user) {
@ -3485,34 +3490,23 @@ public class HeroLogic {
if(config == null){
continue;
}
//根据层数获取解锁的属性库
int[] floor = config.getFloor();
int[] propertyGit = config.getPropertyGit();
int num = 0;
Map<Integer,Integer> propMap = SBecomeAGodSetting.getPropByTypeAndTower(type,towerNum);
if(propMap == null || propMap.size() == 0){
continue;
}
int level = map.get(type);
for(int i = 0;i<floor.length;i++){
if(floor[i] <= towerNum){
//有解锁的属性库,但是要判断索引是否越界
if(i<propertyGit.length){
int propertyId = propertyGit[i];
SBecomeAGodPropertyGit propConfig = SBecomeAGodPropertyGit.getSBecomeAGodPropertyGitByTypeAndLevel(propertyId,level);
if(propConfig == null){
continue;
}
if (propConfig.getProperty() != null) {
for (int[] ints : propConfig.getProperty()) {
attrMap.put(ints[0], attrMap.getOrDefault(ints[0], 0L) + ints[1]);
}
}
for(int propertyId : propMap.values()){
SBecomeAGodPropertyGit propConfig = SBecomeAGodPropertyGit.getSBecomeAGodPropertyGitByTypeAndLevel(propertyId,level);
if(propConfig == null){
continue;
}
if (propConfig.getProperty() != null) {
for (int[] ints : propConfig.getProperty()) {
attrMap.put(ints[0], attrMap.getOrDefault(ints[0], 0L) + ints[1]);
}
}else{
break;
}
}
}
// for(int key:attrMap.keySet()){
// System.out.println("神觉key---------" + key + "-----value:" + attrMap.get(key));
// }
combinedAttribute(attrMap, heroAllAttribute);
}
@ -7516,6 +7510,9 @@ public class HeroLogic {
Map<Integer,Long> prop = this.showPlayerMeridiansAttribute(user);
LOGGER.error("异常的神觉加成,当前战力---" + force + "------神觉加成---" + prop.toString());
}
// for(int i = 1;i<=100;i++){
// this.testPlayerMeridiansAttribute(2400,i);
// }
}
/**
@ -7528,42 +7525,74 @@ public class HeroLogic {
//获取用户神觉塔层数
int towerNum = user.getPlayerInfoManager().getPlayerGodTowerNum();
Map<Integer, Long> attrMap = new HashMap<>();
for(int type:map.keySet()){
if(!map.containsKey(type)){
for(int type:map.keySet()) {
if (!map.containsKey(type)) {
continue;
}
SBecomeAGodSetting config = SBecomeAGodSetting.getConfigBytype(type);
if(config == null){
if (config == null) {
continue;
}
Map<Integer, Integer> propMap = SBecomeAGodSetting.getPropByTypeAndTower(type, towerNum);
if (propMap == null || propMap.size() == 0) {
continue;
}
//根据层数获取解锁的属性库
int[] floor = config.getFloor();
int[] propertyGit = config.getPropertyGit();
int num = 0;
int level = map.get(type);
for(int i = 0;i<floor.length;i++){
if(floor[i] <= towerNum){
//有解锁的属性库,但是要判断索引是否越界
if(i<propertyGit.length){
int propertyId = propertyGit[i];
SBecomeAGodPropertyGit propConfig = SBecomeAGodPropertyGit.getSBecomeAGodPropertyGitByTypeAndLevel(propertyId,level);
if(propConfig == null){
continue;
}
if (propConfig.getProperty() != null) {
for (int[] ints : propConfig.getProperty()) {
attrMap.put(ints[0], attrMap.getOrDefault(ints[0], 0L) + ints[1]);
}
}
for (int propertyId : propMap.values()) {
SBecomeAGodPropertyGit propConfig = SBecomeAGodPropertyGit.getSBecomeAGodPropertyGitByTypeAndLevel(propertyId, level);
if (propConfig == null) {
continue;
}
if (propConfig.getProperty() != null) {
for (int[] ints : propConfig.getProperty()) {
attrMap.put(ints[0], attrMap.getOrDefault(ints[0], 0L) + ints[1]);
}
}else{
break;
}
}
}
return attrMap;
}
public void testPlayerMeridiansAttribute(int towerNum,int level){
Map<Integer,Integer> map = new HashMap<>();
Map<Integer, Long> attrMap = new HashMap<>();
map.put(1,1);
map.put(2,1);
map.put(3,1);
map.put(4,1);
map.put(5,1);
map.put(6,1);
for(int type:map.keySet()) {
if (!map.containsKey(type)) {
continue;
}
SBecomeAGodSetting config = SBecomeAGodSetting.getConfigBytype(type);
if (config == null) {
continue;
}
Map<Integer, Integer> propMap = SBecomeAGodSetting.getPropByTypeAndTower(type, towerNum);
if (propMap == null || propMap.size() == 0) {
continue;
}
for (int propertyId : propMap.values()) {
SBecomeAGodPropertyGit propConfig = SBecomeAGodPropertyGit.getSBecomeAGodPropertyGitByTypeAndLevel(propertyId, level);
if (propConfig == null) {
continue;
}
if (propConfig.getProperty() != null) {
for (int[] ints : propConfig.getProperty()) {
attrMap.put(ints[0], attrMap.getOrDefault(ints[0], 0L) + ints[1]);
}
}
}
}
System.out.println("神觉属性 tower : + " + towerNum + " --- level : " + level + "start------------------------");
for(int propId : attrMap.keySet()){
System.out.println("神觉属性 key : " + propId + "---value--" + attrMap.get(propId));
}
System.out.println("神觉属性 tower : + " + towerNum + " --- level : " + level + "end------------------------");
}
/**
* 解锁天书密卷神技
*/

View File

@ -569,6 +569,12 @@ public class TrainingLogic {
giftCost.put(gifts.getItemId(), gifts.getItemNum());
ItemUtil.itemCostLong(user, giftCost, BIReason.TRAINING_UP_LV_COST, 0);
break;
// case GlobalItemType.SOUL_MARK://魂印
// CommonProto.Item gifts = proto.getPlayerGifts();
// HashMap<Integer, Long> giftCost = new HashMap<>(1);
// giftCost.put(gifts.getItemId(), gifts.getItemNum());
// ItemUtil.itemCostLong(user, giftCost, BIReason.TRAINING_UP_LV_COST, 0);
// break;
default:
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"道具消耗类型找不到");
}

View File

@ -103,10 +103,10 @@ public class PlayerGodLogic {
int needLevel = config.getLevelConfine();
Map<Integer,Integer> map = playerManager.getPlayerGodMeridiansLevels();
for(int i=1;i<=6;i++){
if(!map.containsKey(i)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE, "playerMeridiansLevel not enough");
int playerMeridiansLevel = 0;
if(map.containsKey(i)){
playerMeridiansLevel = map.get(i);
}
int playerMeridiansLevel = map.get(i);
if(playerMeridiansLevel < needLevel){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE, "playerMeridiansLevel not enough");
}

View File

@ -23,16 +23,16 @@ public class SBecomeAGodSetting implements BaseConfig {
public static Map<Integer, SBecomeAGodSetting> map = new HashMap<>();
public static Map<Integer, SBecomeAGodSetting> typeMap = new HashMap<>();
//按照六道类型和阶数存储的累积属性库id集合
public static Map<Integer,Map<Integer, List<Integer>>> propMap = new HashMap<>();
//按塔的层数存储的对应阶数属性库集合
public static Map<Integer,Integer> towerPropMap = new HashMap<>();
//按照六道类型和塔层数存储的累积属性库id集合(为方便快速获取,按层数直接存取对应的属性id集合,只保留3000层的,多余3000层的循环比较)
public static Map<Integer,Map<Integer, Map<Integer,Integer>>> propMap = new HashMap<>();
//按照六道类型存储的最大属性库层数,超过该层数,直接取最大层数属性库集合,无需比较奖励
public static Map<Integer,Integer> towerMaxMap = new HashMap<>();
@Override
public void init() throws Exception {
map = STableManager.getConfig(SBecomeAGodSetting.class);
Map<Integer,Map<Integer, List<Integer>>> _propMap = new HashMap<>();
Map<Integer,Integer> _towerPropMap = new HashMap<>();
Map<Integer,Map<Integer, Map<Integer,Integer>>> _propMap = new HashMap<>();
Map<Integer,Integer> _towerMaxMap = new HashMap<>();
for(SBecomeAGodSetting config : map.values()){
typeMap.put(config.getType(),config);
int[] floor = config.getFloor();
@ -40,37 +40,41 @@ public class SBecomeAGodSetting implements BaseConfig {
if(floor == null || floor.length == 0){
continue;
}
Map<Integer, List<Integer>> map = new HashMap<>();
int maxNum = 0;
Map<Integer, Map<Integer,Integer>> map = new HashMap<>();
int maxNum = 3000;
int trueMaxTowerNum = 0;
if(propertyGit!= null && propertyGit.length > 0){
for(int i = 0;i<floor.length;i++) {
int num = floor[i];
if(maxNum < num){
maxNum = num;
if(trueMaxTowerNum <= num){
trueMaxTowerNum = num;
}
List<Integer> list = new ArrayList<>();
for(int j= 0;j<propertyGit.length;j++){
//每次都要把之前的库id加上,统计的是累积的库id
if(j<=i){
int propertyId = propertyGit[j];
list.add(propertyId);
}else{
break;
for(int j = 0;j<=maxNum;j++){
if(j>=floor[i]){
Map<Integer,Integer> subMap = null;
if(!map.containsKey(j)){
subMap = new HashMap<>();
}else{
subMap = map.get(j);
if(subMap == null){
subMap = new HashMap<>();
}
}
if(i<propertyGit.length){
int propertyId = propertyGit[i];
subMap.put(propertyId,propertyId);
}
map.put(j,subMap);
}
}
map.put(i,list);
}
}
//做个容错处理,假如策划配错了,最大层数超过1w,按1w算
if(maxNum > 10000){
maxNum = 10000;
}
for(int i=0;i<=maxNum;i++){
}
_propMap.put(type,map);
_propMap.put(config.getType(),map);
_towerMaxMap.put(config.getType(),trueMaxTowerNum);
}
propMap = _propMap;
towerMaxMap = _towerMaxMap;
// testTowerProp();
}
@ -101,5 +105,57 @@ public class SBecomeAGodSetting implements BaseConfig {
return null;
}
/**
* 根据六道类型和神觉塔层数获取属性库
* @param type
* @param tower
* @return
*/
public static Map<Integer,Integer> getPropByTypeAndTower(int type,int tower){
Map<Integer,Integer> map = null;
if(propMap.containsKey(type)){
Map<Integer,Map<Integer,Integer>> subMap = propMap.get(type);
//不存在的类型,直接返回null
if(subMap == null){
return map;
}
if(subMap.containsKey(tower)){
return subMap.get(tower);
}
//没获取到,实际塔层数超过了3000,先判断是否超过了真实配置的最大层数,超过了,直接取最大层数属性库
int trueTowerNum = towerMaxMap.get(type);
if(tower > trueTowerNum){
return subMap.get(trueTowerNum);
}
//实际奖励配置的最大层数超过了3000层,则直接真实比较
SBecomeAGodSetting config = SBecomeAGodSetting.getConfigBytype(type);
if(config == null){
return map;
}
//根据层数获取解锁的属性库
int[] floor = config.getFloor();
int[] propertyGit = config.getPropertyGit();
map = new HashMap<>();
for(int i = 0;i<floor.length;i++) {
if (floor[i] <= tower) {
//有解锁的属性库,但是要判断索引是否越界
if (i < propertyGit.length) {
map.put(propertyGit[i],propertyGit[i]);
}
}
}
}
return map;
}
public static void testTowerProp(){
for(int j=1;j<=6;j++){
for(int i=0;i<=3000;i++){
Map<Integer,Integer> map = getPropByTypeAndTower(j,i);
System.out.println("六道属性库测试--type : " + j + "---层数 : " + i + "---属性库 : " + map.values());
}
}
}
}