From f9ef5ffb1b3095f1794d9afee1c6ee8588428b23 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 28 Jan 2019 11:16:43 +0800 Subject: [PATCH 1/8] hero atribute --- .../jieling/config/SCHeroRankUpConfig.java | 6 +- .../com/ljsd/jieling/config/SGameSetting.java | 7 +- .../ljsd/jieling/config/SHeroLevlConfig.java | 6 ++ .../com/ljsd/jieling/core/GlobalsDef.java | 4 ++ .../ljsd/jieling/logic/hero/HeroLogic.java | 66 ++++++++++++++----- 5 files changed, 68 insertions(+), 21 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java index 4ce60c4f5..7f5152f6e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java @@ -1,5 +1,6 @@ package com.ljsd.jieling.config; +import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; @@ -36,11 +37,10 @@ public class SCHeroRankUpConfig implements BaseConfig{ if(!result.containsKey(type)){ result.put(type,new TreeMap<>()); } - if(type == 1){ - result.get(type).put(scHeroRankUpConfig.getLimitLevel(),scHeroRankUpConfig); - }else{ + if(type == GlobalsDef.UP_STAR_TYPE){ result.get(type).put(scHeroRankUpConfig.getLimitStar(),scHeroRankUpConfig); } + result.get(type).put(scHeroRankUpConfig.getLimitLevel(),scHeroRankUpConfig); } scHeroRankUpConfigByType = result; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SGameSetting.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SGameSetting.java index ca9f197b6..e910437d8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SGameSetting.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SGameSetting.java @@ -60,11 +60,14 @@ public class SGameSetting implements BaseConfig { return actionPowerRormula; } - public float calSpeed(float speed, int level){ + public float calSpeed(float speed, int breakTimes){ + if(breakTimes == 0){ + return 0; + } float result = speed; int length = speedFormula.length; for(int i=0;i< speedFormula.length;i++){ - double pow = Math.pow(level, --length); + double pow = Math.pow(breakTimes, --length); result += speedFormula[i]*pow; } return result; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SHeroLevlConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SHeroLevlConfig.java index 276e2dd8f..d20e6e284 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SHeroLevlConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SHeroLevlConfig.java @@ -16,6 +16,8 @@ public class SHeroLevlConfig implements BaseConfig{ private float characterLevelPara; + private float speedLevelPara; + private int[][] consume; @@ -49,4 +51,8 @@ public class SHeroLevlConfig implements BaseConfig{ public int[][] getConsume() { return consume; } + + public float getSpeedLevelPara() { + return speedLevelPara; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java index 29e52b9d2..114471c80 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java @@ -13,4 +13,8 @@ public interface GlobalsDef { int MagicDefence_TYPE =4; int SPEED_TYPE =5; + // + int RANKUP_PARA_TYPE =1; + int BREAK_PARA_TYPE =2; + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 5f86eaa3e..86d493b70 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -268,8 +268,14 @@ public class HeroLogic { MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,""); return; } - int oldStar = targetHero.getStar(); + int oldStar = targetHero.getStar(); + Map scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE); + SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(oldStar); + if( targetHero.getLevel() < scHeroRankUpConfig.getLimitLevel()){ + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,"等级不够"); + return; + } SCHero scHero = SCHero.getsCHero().get(targetHero.getTemplateId()); Map consumeMaterialInfoByPosition = scHero.getConsumeMaterialInfoOfPositionByStar(oldStar + 1); boolean canUse = true; @@ -324,11 +330,10 @@ public class HeroLogic { } if(!canUse){ - MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,""); + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,"所选英雄不符合"); return; } - Map scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE); - SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(oldStar); + int[][] consumeMaterial = scHeroRankUpConfig.getConsumeMaterial(); boolean enoughCost = ItemUtil.itemCost(user, consumeMaterial); if(!enoughCost){ @@ -354,21 +359,53 @@ public class HeroLogic { } //初始属性*(1+化境增长)*等级系数 + 初始属性*突破系数 + public Map calHeroAllAttribute(Hero hero){ + Map result = new HashMap<>(); + int templateId = hero.getTemplateId(); + SCHero scHero = SCHero.getsCHero().get(templateId); + SHeroLevlConfig sHeroLevlConfig = SHeroLevlConfig.getsCHero().get(hero.getLevel()); + float characterLevelPara = sHeroLevlConfig.getCharacterLevelPara(); + Map paraForHero = getParaForHero(hero); + Map baseValueMap = new HashMap<>(); + baseValueMap.put(GlobalsDef.HP_TYPE,getBaseValueByType(scHero,GlobalsDef.HP_TYPE)); + baseValueMap.put(GlobalsDef.ATTACK_TYPE,getBaseValueByType(scHero,GlobalsDef.ATTACK_TYPE)); + baseValueMap.put(GlobalsDef.PhysicalDefence_TYPE,getBaseValueByType(scHero,GlobalsDef.PhysicalDefence_TYPE)); + baseValueMap.put(GlobalsDef.MagicDefence_TYPE,getBaseValueByType(scHero,GlobalsDef.MagicDefence_TYPE)); + baseValueMap.put(GlobalsDef.SPEED_TYPE,getBaseValueByType(scHero,GlobalsDef.SPEED_TYPE)); + for(Map.Entry item : baseValueMap.entrySet()){ + Integer attributeType = item.getKey(); + Float heroBaseValue = item.getValue(); + if(attributeType == GlobalsDef.SPEED_TYPE){ + result.put (attributeType,(int)(heroBaseValue * sHeroLevlConfig.getSpeedLevelPara() + SGameSetting.getGameSetting().calSpeed(heroBaseValue, hero.getBreakId()))); + } + result.put(attributeType,(int)(heroBaseValue * ( 1 + paraForHero.get(GlobalsDef.RANKUP_PARA_TYPE)/10000.f) * characterLevelPara + heroBaseValue * paraForHero.get(GlobalsDef.BREAK_PARA_TYPE)/10000.f)); + } - public float calHeroAttribute(Hero hero,int type){ + return result; + } + public int calHeroAttribute(Hero hero,int type){ + //计算化境增长 int templateId = hero.getTemplateId(); SCHero scHero = SCHero.getsCHero().get(templateId); float baseValue = getBaseValueByType(scHero,type); + SHeroLevlConfig sHeroLevlConfig = SHeroLevlConfig.getsCHero().get(hero.getLevel()); + float characterLevelPara = sHeroLevlConfig.getCharacterLevelPara(); + Map paraForHero = getParaForHero(hero); + if(type == GlobalsDef.SPEED_TYPE){ + return (int)(baseValue * sHeroLevlConfig.getSpeedLevelPara() + SGameSetting.getGameSetting().calSpeed(baseValue, hero.getBreakId())); + } + return (int)(baseValue * ( 1 + paraForHero.get(GlobalsDef.RANKUP_PARA_TYPE)/10000.f) * characterLevelPara + baseValue * paraForHero.get(GlobalsDef.BREAK_PARA_TYPE)/10000.f); + } - float characterLevelPara = SHeroLevlConfig.getsCHero().get(hero.getLevel()).getCharacterLevelPara(); - //计算化境增长 + private Map getParaForHero(Hero hero){ + Map result = new HashMap<>(2); Map scHeroRankUpConfigByTypeOfStar = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE); SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByTypeOfStar.get(hero.getStar()); float rankupPara =0.0f; if( scHeroRankUpConfig!=null ){ rankupPara = scHeroRankUpConfig.getRankupPara(); } - //突破系数 + //突破系数 float breakPara = 0.0f; int heroLevel = hero.getLevel(); Map scHeroRankUpConfigByTypOfBreak = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE); @@ -380,13 +417,9 @@ public class HeroLogic { break; } } - - if(type == GlobalsDef.SPEED_TYPE){ - return SGameSetting.getGameSetting().calSpeed(baseValue,heroLevel); - } - - return baseValue * ( 1 + rankupPara/10000.f) + characterLevelPara * breakPara; - + result.put(GlobalsDef.RANKUP_PARA_TYPE,rankupPara); + result.put(GlobalsDef.BREAK_PARA_TYPE,breakPara); + return result; } private float getBaseValueByType(SCHero scHero,int type){ @@ -415,7 +448,8 @@ public class HeroLogic { //todo 计算英雄战斗力 战斗力 = 生命*0.7 + (护甲 + 魔坑)*5 + 攻击 *10 + (暴击率 + 效果命中率 )*5 +(属性攻击率 + 属性防御率)*30 public int calHeoForce(Hero hero){ - double heroBaseForce = calHeroAttribute(hero, GlobalsDef.HP_TYPE) * 0.7 + (calHeroAttribute(hero, GlobalsDef.PhysicalDefence_TYPE) + calHeroAttribute(hero, GlobalsDef.MagicDefence_TYPE)) * 5 + calHeroAttribute(hero, GlobalsDef.ATTACK_TYPE) * 10; + Map heroAllAttribute = calHeroAllAttribute(hero); + double heroBaseForce = heroAllAttribute.get(GlobalsDef.HP_TYPE) * 0.7 + (heroAllAttribute.get(GlobalsDef.PhysicalDefence_TYPE) + heroAllAttribute.get(GlobalsDef.MagicDefence_TYPE)) * 5 + heroAllAttribute.get(GlobalsDef.ATTACK_TYPE) * 10; //todo 计算装备加成 float equipAddForce =0.0f; int result = (int) (heroBaseForce + equipAddForce); From 075b53abf47c2d2cecb5cb9707c80ca491986937 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 28 Jan 2019 17:11:35 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=BC=82=E5=A6=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/server/DifferDemonsComonpentsConfig.txt | 2 + conf/server/DifferDemonsConfig.txt | 58 +++++++++ conf/server/DifferDemonsStageConfig.txt | 2 + conf/server/EquipConfig.txt | 119 +++++++++++++++++- conf/server/EquipPropertyPool.txt | 77 +++++++++++- conf/server/PropertyConfig.txt | 84 ++++--------- .../config/SDifferDemonsComonpentsConfig.java | 67 ++++++++++ .../jieling/config/SDifferDemonsConfig.java | 43 +++++++ .../config/SDifferDemonsStageConfig.java | 63 ++++++++++ .../ljsd/jieling/config/SPropertyConfig.java | 32 +++-- .../com/ljsd/jieling/logic/dao/Pokemon.java | 49 ++++++++ .../jieling/logic/dao/PokemonManager.java | 20 +++ .../java/com/ljsd/jieling/logic/dao/User.java | 10 ++ .../ljsd/jieling/logic/fight/CombatLogic.java | 2 +- .../ljsd/jieling/logic/hero/HeroLogic.java | 94 +++++++++++++- 15 files changed, 648 insertions(+), 74 deletions(-) create mode 100644 conf/server/DifferDemonsComonpentsConfig.txt create mode 100644 conf/server/DifferDemonsConfig.txt create mode 100644 conf/server/DifferDemonsStageConfig.txt create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsComonpentsConfig.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsConfig.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Pokemon.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PokemonManager.java diff --git a/conf/server/DifferDemonsComonpentsConfig.txt b/conf/server/DifferDemonsComonpentsConfig.txt new file mode 100644 index 000000000..8f9255deb --- /dev/null +++ b/conf/server/DifferDemonsComonpentsConfig.txt @@ -0,0 +1,2 @@ +Id ComonpentsId Stage Cost BaseAttribute +int int int mut,int#int,2 mut,int#int,2 diff --git a/conf/server/DifferDemonsConfig.txt b/conf/server/DifferDemonsConfig.txt new file mode 100644 index 000000000..ba902608d --- /dev/null +++ b/conf/server/DifferDemonsConfig.txt @@ -0,0 +1,58 @@ +Id OpenRules ComonpentList +int mut,int#int,2 mut,int#int,1 +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null +0 null null diff --git a/conf/server/DifferDemonsStageConfig.txt b/conf/server/DifferDemonsStageConfig.txt new file mode 100644 index 000000000..756adf48d --- /dev/null +++ b/conf/server/DifferDemonsStageConfig.txt @@ -0,0 +1,2 @@ +Id DifferDemonsId SkillId Cost +int int int mut,int#int,2 diff --git a/conf/server/EquipConfig.txt b/conf/server/EquipConfig.txt index 73242e613..090e38bf2 100644 --- a/conf/server/EquipConfig.txt +++ b/conf/server/EquipConfig.txt @@ -1,4 +1,119 @@ Id ProfessionLimit Position PropertyMin PropertyMax Pool SecondNumMin SecondNumMax SkillId IfClear int int int mut,int#int,1 mut,int#int,1 int int int int int -3001 0 1 1#100 1#200 1 1 1 0 1 -3002 0 0 null null 0 0 0 0 0 +3001 1501 1 2#42 2#70 1 0 0 0 0 +3002 1501 1 2#42 2#70 1 0 0 0 0 +3003 1502 1 2#42 2#70 1 0 0 0 0 +3004 1502 1 2#42 2#70 1 0 0 0 0 +3005 1503 1 2#42 2#70 1 0 0 0 0 +3006 1503 1 2#42 2#70 1 0 0 0 0 +3007 1504 1 2#42 2#70 1 0 0 0 0 +3008 1504 1 2#42 2#70 1 0 0 0 0 +3009 1505 1 2#42 2#70 1 0 0 0 0 +3010 1505 1 2#42 2#70 1 0 0 0 0 +3011 0 2 3#43 3#72 1 0 0 0 0 +3012 0 2 3#43 3#72 1 0 0 0 0 +3013 0 2 4#40 4#67 1 0 0 0 0 +3014 0 2 4#40 4#67 1 0 0 0 0 +3015 0 4 5#24 5#28 1 0 0 0 0 +3016 0 4 5#24 5#28 1 0 0 0 0 +3017 0 3 1#460 1#767 1 0 0 0 0 +3018 0 3 1#460 1#767 1 0 0 0 0 +3101 1501 1 2#56 2#93 1 0 1 0 0 +3102 1501 1 2#56 2#93 1 0 1 0 0 +3103 1502 1 2#56 2#93 1 0 1 0 0 +3104 1502 1 2#56 2#93 1 0 1 0 0 +3105 1503 1 2#56 2#93 1 0 1 0 0 +3106 1503 1 2#56 2#93 1 0 1 0 0 +3107 1504 1 2#56 2#93 1 0 1 0 0 +3108 1504 1 2#56 2#93 1 0 1 0 0 +3109 1505 1 2#56 2#93 1 0 1 0 0 +3110 1505 1 2#56 2#93 1 0 1 0 0 +3111 0 2 3#58 3#96 2 0 1 0 0 +3112 0 2 3#58 3#96 2 0 1 0 0 +3113 0 2 4#54 4#90 2 0 1 0 0 +3114 0 2 4#54 4#90 2 0 1 0 0 +3115 0 4 5#48 5#56 3 0 1 0 0 +3116 0 4 5#48 5#56 3 0 1 0 0 +3117 0 3 1#616 1#1027 4 0 1 0 0 +3118 0 3 1#616 1#1027 4 0 1 0 0 +3201 1501 1 2#72 2#120 5 1 3 0 1 +3202 1501 1 2#72 2#120 5 1 3 0 1 +3203 1502 1 2#72 2#120 5 1 3 0 1 +3204 1502 1 2#72 2#120 5 1 3 0 1 +3205 1503 1 2#72 2#120 5 1 3 0 1 +3206 1503 1 2#72 2#120 5 1 3 0 1 +3207 1504 1 2#72 2#120 5 1 3 0 1 +3208 1504 1 2#72 2#120 5 1 3 0 1 +3209 1505 1 2#72 2#120 5 1 3 0 1 +3210 1505 1 2#72 2#120 5 1 3 0 1 +3211 0 2 3#74 3#124 6 1 3 0 1 +3212 0 2 3#74 3#124 6 1 3 0 1 +3213 0 2 4#70 4#116 6 1 3 0 1 +3214 0 2 4#70 4#116 6 1 3 0 1 +3215 0 4 5#72 5#84 7 1 3 0 1 +3216 0 4 5#72 5#84 7 1 3 0 1 +3217 0 3 1#792 1#1320 8 1 3 0 1 +3218 0 3 1#792 1#1320 8 1 3 0 1 +3301 1501 1 2#383 2#638 9 2 4 0 1 +3302 1501 1 2#383 2#638 9 2 4 0 1 +3303 1502 1 2#383 2#638 9 2 4 0 1 +3304 1502 1 2#383 2#638 9 2 4 0 1 +3305 1503 1 2#383 2#638 9 2 4 0 1 +3306 1503 1 2#383 2#638 9 2 4 0 1 +3307 1504 1 2#383 2#638 9 2 4 0 1 +3308 1504 1 2#383 2#638 9 2 4 0 1 +3309 1505 1 2#383 2#638 9 2 4 0 1 +3310 1505 1 2#383 2#638 9 2 4 0 1 +3311 0 2 3#396 3#659 10 2 4 0 1 +3312 0 2 3#396 3#659 10 2 4 0 1 +3313 0 2 4#370 4#617 10 2 4 0 1 +3314 0 2 4#370 4#617 10 2 4 0 1 +3315 0 4 5#96 5#113 11 2 4 0 1 +3316 0 4 5#96 5#113 11 2 4 0 1 +3317 0 3 1#4212 1#7020 12 2 4 0 1 +3318 0 3 1#4212 1#7020 12 2 4 0 1 +3319 1501 1 2#383 2#638 9 2 4 0 1 +3320 1501 1 2#383 2#638 9 2 4 0 1 +3321 1502 1 2#383 2#638 9 2 4 0 1 +3322 1502 1 2#383 2#638 9 2 4 0 1 +3323 1503 1 2#383 2#638 9 2 4 0 1 +3324 1503 1 2#383 2#638 9 2 4 0 1 +3325 1504 1 2#383 2#638 9 2 4 0 1 +3326 1504 1 2#383 2#638 9 2 4 0 1 +3327 1505 1 2#383 2#638 9 2 4 0 1 +3328 1505 1 2#383 2#638 9 2 4 0 1 +3329 0 2 3#396 3#659 10 2 4 0 1 +3330 0 2 3#396 3#659 10 2 4 0 1 +3331 0 2 4#370 4#617 10 2 4 0 1 +3332 0 2 4#370 4#617 10 2 4 0 1 +3333 0 4 5#96 5#113 11 2 4 0 1 +3334 0 4 5#96 5#113 11 2 4 0 1 +3335 0 3 1#4212 1#7020 12 2 4 0 1 +3336 0 3 1#4212 1#7020 12 2 4 0 1 +4001 1501 1 2#72 2#120 5 1 3 0 0 +4002 1502 1 2#72 2#120 5 1 3 0 0 +4003 1503 1 2#72 2#120 5 1 3 0 0 +4004 1504 1 2#72 2#120 5 1 3 0 0 +4005 1505 1 2#72 2#120 5 1 3 0 0 +4006 0 2 3#74 3#124 6 1 3 0 0 +4007 0 2 4#70 4#116 6 1 3 0 0 +4008 0 4 5#72 5#84 7 1 3 0 0 +4009 0 3 1#792 1#1320 8 1 3 0 0 +4101 1501 1 2#383 2#638 9 2 4 0 0 +4102 1501 1 2#383 2#638 9 2 4 0 0 +4103 1502 1 2#383 2#638 9 2 4 0 0 +4104 1502 1 2#383 2#638 9 2 4 0 0 +4105 1503 1 2#383 2#638 9 2 4 0 0 +4106 1503 1 2#383 2#638 9 2 4 0 0 +4107 1504 1 2#383 2#638 9 2 4 0 0 +4108 1504 1 2#383 2#638 9 2 4 0 0 +4109 1505 1 2#383 2#638 9 2 4 0 0 +4110 1505 1 2#383 2#638 9 2 4 0 0 +4111 0 2 3#396 3#659 10 2 4 0 0 +4112 0 2 3#396 3#659 10 2 4 0 0 +4113 0 2 4#370 4#617 10 2 4 0 0 +4114 0 2 4#370 4#617 10 2 4 0 0 +4115 0 4 5#96 5#113 11 2 4 0 0 +4116 0 4 5#96 5#113 11 2 4 0 0 +4117 0 3 1#4212 1#7020 12 2 4 0 0 +4118 0 3 1#4212 1#7020 12 2 4 0 0 diff --git a/conf/server/EquipPropertyPool.txt b/conf/server/EquipPropertyPool.txt index ff83784d8..96cbe6f71 100644 --- a/conf/server/EquipPropertyPool.txt +++ b/conf/server/EquipPropertyPool.txt @@ -1,3 +1,78 @@ id PropertyId Min Max PoolNum Weight int int int int int int -1 101 100 200 1 100 +1 5 11 18 1 100 +2 54 5 5 1 100 +3 53 5 5 1 100 +4 1 235 392 2 100 +5 2 19 32 2 100 +6 53 5 5 2 100 +7 54 5 5 2 100 +8 1 268 448 3 100 +9 2 17 29 3 100 +10 3 9 15 3 100 +11 4 12 20 3 100 +12 3 26 43 4 100 +13 4 27 45 4 100 +14 5 15 26 4 100 +15 5 16 19 5 100 +16 54 8 8 5 100 +17 53 8 8 5 100 +18 56 25 25 5 100 +19 55 5 5 5 100 +20 1 302 504 6 100 +21 2 25 42 6 100 +22 53 8 8 6 100 +23 54 8 8 6 100 +24 1 345 576 7 100 +25 2 22 38 7 100 +26 3 12 20 7 100 +27 4 15 26 7 100 +28 55 5 5 7 100 +29 56 10 10 7 100 +30 3 33 56 8 100 +31 4 34 58 8 100 +32 5 23 27 8 100 +33 56 10 10 8 100 +34 5 22 26 9 100 +35 54 10 10 9 100 +36 53 10 10 9 100 +37 56 40 40 9 100 +38 55 15 15 9 100 +39 101 8 15 9 100 +40 102 8 15 9 100 +41 103 8 15 9 100 +42 104 8 15 9 100 +43 105 8 15 9 100 +44 106 8 15 9 100 +45 1 1608 2680 10 100 +46 2 134 223 10 100 +47 53 10 10 10 100 +48 54 10 10 10 100 +49 107 8 15 10 100 +50 108 8 15 10 100 +51 109 8 15 10 100 +52 110 8 15 10 100 +53 111 8 15 10 100 +54 112 8 15 10 100 +55 1 1837 3063 11 100 +56 2 121 202 11 100 +57 3 63 106 11 100 +58 4 82 138 11 100 +59 55 5 5 11 100 +60 56 15 15 11 100 +61 107 5 5 11 100 +62 108 5 5 11 100 +63 109 5 5 11 100 +64 110 5 5 11 100 +65 111 5 5 11 100 +66 112 5 5 11 100 +67 3 5 5 12 100 +68 4 185 308 12 100 +69 5 31 36 12 100 +70 56 25 25 12 100 +71 101 5 10 12 100 +72 102 5 10 12 100 +73 103 5 10 12 100 +74 104 5 10 12 100 +75 105 5 10 12 100 +76 106 5 10 12 100 diff --git a/conf/server/PropertyConfig.txt b/conf/server/PropertyConfig.txt index 2c15ad1c4..0c339a78f 100644 --- a/conf/server/PropertyConfig.txt +++ b/conf/server/PropertyConfig.txt @@ -1,58 +1,26 @@ -Id PropertyId Name Info -int int string string -1 1 Hp 生命值 -2 2 Attack 攻击力 -3 3 PhysicalDefence 护甲 -4 4 MagicDefence 魔抗 -5 5 Speed 速度 -6 51 DamageBocusFactor 伤害加成百分比 -7 52 DamageReduceFactor 伤害减免百分比 -8 53 Hit 效果命中率 -9 54 Dodge 效果抵抗率 -10 55 CritFactor 暴击率 -11 56 CritDamageFactor 暴伤 -12 57 TreatFacter 回复系数 -13 101 FireDamageBonusFactor 火攻(%) -14 102 WindDamageBonusFactor 风攻(%) -15 103 WaterDamageBonusFactor 水攻(%) -16 104 LandDamageBonusFactor 地攻(%) -17 105 LightDamageBonusFactor 光攻(%) -18 106 DarkDamageBonusFactor 暗攻(%) -19 107 FireDamageReduceFactor 火抗(%) -20 108 WindDamageReduceFactor 风抗(%) -21 109 WaterDamageReduceFactor 水抗(%) -22 110 LandDamageReduceFactor 地抗(%) -23 111 LightDamageReduceFactor 光抗(%) -24 112 DarkDamageReduceFactor 暗抗(%) -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null -0 null +Id PropertyId Style Score +int int int float +1 1 1 0 +2 2 1 10 +3 3 1 5 +4 4 1 5 +5 5 1 5 +6 51 2 0 +7 52 2 0 +8 53 2 5 +9 54 2 5 +10 55 2 5 +11 56 2 0 +12 57 2 0 +13 101 2 30 +14 102 2 30 +15 103 2 30 +16 104 2 30 +17 105 2 30 +18 106 2 30 +19 107 2 30 +20 108 2 30 +21 109 2 30 +22 110 2 30 +23 111 2 30 +24 112 2 30 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsComonpentsConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsComonpentsConfig.java new file mode 100644 index 000000000..d1b69155d --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsComonpentsConfig.java @@ -0,0 +1,67 @@ +package com.ljsd.jieling.config; + +import com.ljsd.jieling.logic.STableManager; +import com.ljsd.jieling.logic.Table; + +import java.util.HashMap; +import java.util.Map; + +@Table(name ="DifferDemonsComonpentsConfig") +public class SDifferDemonsComonpentsConfig implements BaseConfig { + + private int id; + + private int comonpentsId; + + private int stage; + + private int[][] cost; + + private int[][] baseAttribute; + + private static Map> sDifferDemonsComonpentsConfig; + + + @Override + public void init() throws Exception { + Map> sDifferDemonsComonpentsConfigTmp = new HashMap<>(); + Map config = STableManager.getConfig(SDifferDemonsComonpentsConfig.class); + for(SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig : config.values()){ + int comonpentsId = sDifferDemonsComonpentsConfig.getComonpentsId(); + int stage = sDifferDemonsComonpentsConfig.getStage(); + + if(!sDifferDemonsComonpentsConfigTmp.containsKey(comonpentsId)){ + sDifferDemonsComonpentsConfigTmp.put(comonpentsId,new HashMap<>()); + } + sDifferDemonsComonpentsConfigTmp.get(comonpentsId).put(stage,sDifferDemonsComonpentsConfig); + } + sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigTmp; + + } + + public static Map getsDifferDemonsComonpentsConfigMap(int comonpentId) { + return sDifferDemonsComonpentsConfig.get(comonpentId); + } + + public int getId() { + return id; + } + + public int getComonpentsId() { + return comonpentsId; + } + + public int getStage() { + return stage; + } + + public int[][] getCost() { + return cost; + } + + public int[][] getBaseAttribute() { + return baseAttribute; + } + + +} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsConfig.java new file mode 100644 index 000000000..0a639da10 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsConfig.java @@ -0,0 +1,43 @@ +package com.ljsd.jieling.config; + +import com.ljsd.jieling.logic.STableManager; +import com.ljsd.jieling.logic.Table; + +import java.util.HashMap; +import java.util.Map; + +@Table(name ="DifferDemonsConfig") +public class SDifferDemonsConfig implements BaseConfig { + + private int id; + + private int[][] openRules; + + private int[] comonpentList; + + private static Map sDifferDemonsConfigMap; + + + @Override + public void init() throws Exception { + sDifferDemonsConfigMap= STableManager.getConfig(SDifferDemonsConfig.class); + } + + public static SDifferDemonsConfig getsDifferDemonsConfigByPokenID(int pokenmonId) { + return sDifferDemonsConfigMap.get(pokenmonId); + } + + public int getId() { + return id; + } + + public int[][] getOpenRules() { + return openRules; + } + + public int[] getComonpentList() { + return comonpentList; + } + + +} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java new file mode 100644 index 000000000..d80758fb2 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SDifferDemonsStageConfig.java @@ -0,0 +1,63 @@ +package com.ljsd.jieling.config; + +import com.ljsd.jieling.logic.STableManager; +import com.ljsd.jieling.logic.Table; + +import java.util.HashMap; +import java.util.Map; + +@Table(name ="DifferDemonsStageConfig") +public class SDifferDemonsStageConfig implements BaseConfig { + + private int id; + + private int differDemonsId; + + private int skillId; + + private int[][] cost; + + private int comonpentPreStage; + + private static Map> sDifferDemonsStageConfigMap; + + + @Override + public void init() throws Exception { + Map> sDifferDemonsStageConfigMapTmp = new HashMap<>(); + Map config = STableManager.getConfig(SDifferDemonsStageConfig.class); + for(SDifferDemonsStageConfig sDifferDemonsStageConfig : config.values()){ + int comonpentPreStage = sDifferDemonsStageConfig.getComonpentPreStage(); + int differDemonsId = sDifferDemonsStageConfig.getDifferDemonsId(); + if(!sDifferDemonsStageConfigMapTmp.containsKey(differDemonsId)){ + sDifferDemonsStageConfigMapTmp.put(differDemonsId,new HashMap<>()); + } + sDifferDemonsStageConfigMapTmp.get(differDemonsId).put(comonpentPreStage,sDifferDemonsStageConfig); + } + sDifferDemonsStageConfigMap = sDifferDemonsStageConfigMapTmp; + } + + public static Map getsDifferDemonsStageConfigMap(int pokenmonId) { + return sDifferDemonsStageConfigMap.get(pokenmonId); + } + + public int getId() { + return id; + } + + public int getDifferDemonsId() { + return differDemonsId; + } + + public int getSkillId() { + return skillId; + } + + public int[][] getCost() { + return cost; + } + + public int getComonpentPreStage() { + return comonpentPreStage; + } +} \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java index b00967509..e16e298b7 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java @@ -3,6 +3,7 @@ package com.ljsd.jieling.config; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; +import java.util.HashMap; import java.util.Map; @Table(name ="PropertyConfig") @@ -12,18 +13,31 @@ public class SPropertyConfig implements BaseConfig { private int propertyId; - private String name; + private int style; - private String info; + private float score; + + + private static Map sPropertyConfigByPIDMap; @Override public void init() throws Exception { - + Map sPropertyConfigByPIDMapTmp = new HashMap<>(); + Map config = STableManager.getConfig(SPropertyConfig.class); + for(SPropertyConfig sPropertyConfig : config.values()){ + int propertyId = sPropertyConfig.getPropertyId(); + sPropertyConfigByPIDMapTmp.put(propertyId,sPropertyConfig); + } + sPropertyConfigByPIDMapTmp = sPropertyConfigByPIDMap; + } + public static SPropertyConfig getsPropertyConfigByPID(int propertyId) { + return sPropertyConfigByPIDMap.get(propertyId); + } - public int getId() { + public int getId() { return id; } @@ -31,13 +45,11 @@ public class SPropertyConfig implements BaseConfig { return propertyId; } - public String getName() { - return name; + public int getStyle() { + return style; } - public String getInfo() { - return info; + public float getScore() { + return score; } - - } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Pokemon.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Pokemon.java new file mode 100644 index 000000000..cff6fe8a5 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Pokemon.java @@ -0,0 +1,49 @@ +package com.ljsd.jieling.logic.dao; + +import com.ljsd.common.mogodb.MongoBase; + +import java.util.HashMap; +import java.util.Map; + +public class Pokemon extends MongoBase { + + private int id; + + private Map comonpentsLevelMap; // 组件进阶信息 + + private int allStage; + + public Pokemon(){} + + public Pokemon(int id){ + this.id = id; + this.comonpentsLevelMap = new HashMap<>(); + } + + public void upComonpentLevel(int comonpentId) throws Exception { + int level =1; + Integer integer = this.comonpentsLevelMap.get(comonpentId); + if( integer != null){ + level = integer+1 ; + } + updateString("comonpentsLevelMap."+comonpentId,level); + this.comonpentsLevelMap.put(comonpentId,level); + } + + public int getAllStage() { + return allStage; + } + + public void setAllStage(int allStage) throws Exception { + updateString("allStage."+allStage,allStage); + this.allStage = allStage; + } + + public int getId() { + return id; + } + + public Map getComonpentsLevelMap() { + return comonpentsLevelMap; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PokemonManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PokemonManager.java new file mode 100644 index 000000000..347d0abae --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PokemonManager.java @@ -0,0 +1,20 @@ +package com.ljsd.jieling.logic.dao; + +import com.ljsd.common.mogodb.MongoBase; + +import java.util.Map; + +public class PokemonManager extends MongoBase { + private Map pokemonMap; + + + public void addPokemon(Pokemon pokemon) throws Exception { + updateString("pokemonMap." + pokemon.getId(),pokemon); + pokemonMap.put(pokemon.getId(),pokemon); + } + + + public Map getPokemonMap() { + return pokemonMap; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java index 9351ce3c9..5f1ce6811 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/User.java @@ -23,6 +23,8 @@ public class User extends MongoRoot { private AdventureManager adventureManager; + private PokemonManager pokemonManager; + public User(int uid, PlayerManager playerManager, ItemManager itemManager, @@ -37,6 +39,7 @@ public class User extends MongoRoot { this.mailManager = new MailManager(); this.equipManager = new EquipManager(); this.adventureManager = new AdventureManager(); + this.pokemonManager = new PokemonManager(); //綁定关系 this.playerManager.init(this, "playerManager", false); @@ -47,6 +50,7 @@ public class User extends MongoRoot { this.mailManager.init(this,"mailManager",false); this.equipManager.init(this,"equipManager",false); this.adventureManager.init(this,"adventureManager",false); + this.pokemonManager.init(this,"pokemonManager",false); } public User(){ @@ -57,6 +61,7 @@ public class User extends MongoRoot { this.mapManager = new MapManager(); this.equipManager = new EquipManager(); this.adventureManager = new AdventureManager(); + this.pokemonManager = new PokemonManager(); //綁定关系 playerManager.init(this, "playerManager", false); itemManager.init(this, "itemManager", false); @@ -64,6 +69,7 @@ public class User extends MongoRoot { mapManager.init(this, "mapManager", false); equipManager.init(this,"equipManager",false); adventureManager.init(this,"adventureManager",false); + adventureManager.init(this,"pokemonManager",false); } public static void init(LjsdMongoTemplate ljsdMongoTemplate) { @@ -134,4 +140,8 @@ public class User extends MongoRoot { public AdventureManager getAdventureManager() { return adventureManager; } + + public PokemonManager getPokemonManager() { + return pokemonManager; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java index 7ab486587..26bf38c22 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/fight/CombatLogic.java @@ -125,7 +125,7 @@ public class CombatLogic { cacheHeroTid.add(templateId); myRecommendHeroSize++; } - totalForce += HeroLogic.getInstance().calHeoForce(hero); + totalForce += HeroLogic.getInstance().calHeoForce(user,hero); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 14a000954..b35e3e3b4 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -446,11 +446,17 @@ public class HeroLogic { } - //todo 计算英雄战斗力 战斗力 = 生命*0.7 + (护甲 + 魔坑)*5 + 攻击 *10 + (暴击率 + 效果命中率 )*5 +(属性攻击率 + 属性防御率)*30 - public int calHeoForce(Hero hero){ + //todo 计算英雄战斗力 战斗力 = 生命*0.7 + (护甲 + 魔坑)*5 + 攻击 *10 + (暴击率 + 效果命中率 + 效果抵抗率 )*5 +(属性攻击率 + 属性防御率)*30 + public int calHeoForce(User user, Hero hero){ Map heroAllAttribute = calHeroAllAttribute(hero); double heroBaseForce = heroAllAttribute.get(GlobalsDef.HP_TYPE) * 0.7 + (heroAllAttribute.get(GlobalsDef.PHYSICAL_DEFENCE_TYPE) + heroAllAttribute.get(GlobalsDef.MAGIC_DEFENCE_TYPE)) * 5 + heroAllAttribute.get(GlobalsDef.ATTACK_TYPE) * 10; //todo 计算装备加成 + Collection values = hero.getEquipByPositionMap().values(); + EquipManager equipManager = user.getEquipManager(); + for(String equipId:values){ + Equip equip = equipManager.getEquipMap().get(equipId); + + } float equipAddForce =0.0f; int result = (int) (heroBaseForce + equipAddForce); return result; @@ -511,6 +517,90 @@ public class HeroLogic { } + //异妖相关 组件放置升级 + public void pokenmonUpLevel(ISession session,int pokemonId,int comonpentId) throws Exception { + int uid = session.getUid(); + User user = UserManager.getUser(uid); + PokemonManager pokemonManager = user.getPokemonManager(); + Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId); + if(pokemon == null){ + return; + } + Integer oldLevel = pokemon.getComonpentsLevelMap().get(comonpentId); + if (checkPokemonComonpent(pokemonId, comonpentId,oldLevel, user)){ + return; + } + pokemon.upComonpentLevel(comonpentId); + + //发送成功消息 + + } + + // 异妖进阶 + public void pokemonAdvanced(ISession session,int pokemonId) throws Exception { + int uid = session.getUid(); + User user = UserManager.getUser(uid); + PokemonManager pokemonManager = user.getPokemonManager(); + Pokemon pokemon = pokemonManager.getPokemonMap().get(pokemonId); + if(pokemon == null){ + return; + } + SDifferDemonsConfig sDifferDemonsConfig = SDifferDemonsConfig.getsDifferDemonsConfigByPokenID(pokemonId); + int[] comonpentList = sDifferDemonsConfig.getComonpentList(); + Map comonpentsLevelMap = pokemon.getComonpentsLevelMap(); + Map sDifferDemonsStageConfigMap = SDifferDemonsStageConfig.getsDifferDemonsStageConfigMap(pokemonId); + SDifferDemonsStageConfig sDifferDemonsStageConfig = sDifferDemonsStageConfigMap.get(pokemon.getAllStage() + 1); + int comonpentPreStage = sDifferDemonsStageConfig.getComonpentPreStage(); + + boolean isEnough = true; + for(int i=0;i sDifferDemonsComonpentsConfigMap = SDifferDemonsComonpentsConfig.getsDifferDemonsComonpentsConfigMap(comonpentId); + if(!sDifferDemonsComonpentsConfigMap.containsKey(oldLevel+1)){ + return true; + } + SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigMap.get(oldLevel + 1); + int[][] cost = sDifferDemonsComonpentsConfig.getCost(); + boolean enoughCost = ItemUtil.itemCost(user, cost); + if(!enoughCost){ + return true; + } + return false; + } } From b183dd664b319f29e61b54f3b8ff06af90332668 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 28 Jan 2019 17:36:07 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=8D=87=E6=98=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/server/HeroRankupConfig.txt | 36 ++++++++++++------- .../jieling/config/SCHeroRankUpConfig.java | 25 ++++++++----- .../ljsd/jieling/logic/hero/HeroLogic.java | 12 ++++--- 3 files changed, 48 insertions(+), 25 deletions(-) diff --git a/conf/server/HeroRankupConfig.txt b/conf/server/HeroRankupConfig.txt index e6d5cea14..aca6a3f09 100644 --- a/conf/server/HeroRankupConfig.txt +++ b/conf/server/HeroRankupConfig.txt @@ -1,12 +1,24 @@ -Id Type RankupPara LimitLevel OpenLevel LimitStar OpenStar ConsumeMaterial -int int float int int int int mut,int#int,2 -1 1 2000 30 40 3 3 14#10000|4#20 -2 1 5000 40 50 3 3 14#20000|4#40 -3 1 9000 50 60 3 3 14#30000|4#100 -4 1 14000 60 80 4 4 14#30000|4#300 -5 1 20000 80 100 5 5 14#70000|4#1000 -6 1 60000 100 140 5 6 14#120000|4#0 -7 2 2000 140 160 6 7 14#0|4#2000 -8 2 4000 160 180 7 8 14#0|4#3000 -9 2 7000 180 200 8 9 14#0|4#4000 -10 2 10000 200 250 9 10 14#0|4#10000 +Id Type RankupPara LimitLevel OpenLevel LimitStar OpenStar ConsumeMaterial Star +int int float int int int int mut,int#int,2 int +1 1 2000 30 40 5 5 14#10000|4#20 5 +2 1 5000 40 50 5 5 14#20000|4#40 5 +3 1 9000 50 60 5 5 14#30000|4#100 5 +4 1 14000 60 80 5 5 14#30000|4#300 5 +5 1 20000 80 100 5 5 14#70000|4#1000 5 +6 1 60000 100 140 5 6 14#120000|4#0 5 +7 2 2000 140 160 6 7 14#0|4#2000 5 +8 2 4000 160 180 7 8 14#0|4#3000 5 +9 2 7000 180 200 8 9 14#0|4#4000 5 +10 2 10000 200 250 9 10 14#0|4#10000 5 +51 1 2000 30 40 4 4 14#10000|4#20 4 +52 1 5000 40 50 4 4 14#20000|4#40 4 +53 1 9000 50 60 4 4 14#30000|4#100 4 +54 1 14000 60 80 4 4 14#30000|4#300 4 +55 1 20000 80 100 4 5 14#70000|4#1000 4 +56 1 60000 100 140 5 6 14#120000|4#0 4 +57 2 2000 140 160 6 7 14#0|4#2000 4 +58 2 4000 160 180 7 8 14#0|4#3000 4 +59 2 7000 180 200 8 9 14#0|4#4000 4 +101 1 2000 30 40 3 3 14#10000|4#20 3 +102 1 5000 40 50 3 3 14#20000|4#40 3 +103 1 9000 50 60 3 3 14#30000|4#100 3 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java index 7f5152f6e..aebc491ab 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SCHeroRankUpConfig.java @@ -10,7 +10,7 @@ import java.util.TreeMap; @Table(name = "HeroRankupConfig") public class SCHeroRankUpConfig implements BaseConfig{ - public static Map> scHeroRankUpConfigByType; + public static Map>> scHeroRankUpConfigByStar; private int id; @@ -28,25 +28,30 @@ public class SCHeroRankUpConfig implements BaseConfig{ private int consumeMaterial[][]; + private int star; + @Override public void init() throws Exception { - Map> result = new HashMap<>(); + Map>> result = new HashMap<>(); Map config = STableManager.getConfig(SCHeroRankUpConfig.class); for(SCHeroRankUpConfig scHeroRankUpConfig: config.values()){ int type = scHeroRankUpConfig.getType(); if(!result.containsKey(type)){ result.put(type,new TreeMap<>()); } - if(type == GlobalsDef.UP_STAR_TYPE){ - result.get(type).put(scHeroRankUpConfig.getLimitStar(),scHeroRankUpConfig); + if(!result.get(type).containsKey(scHeroRankUpConfig.getStar())){ + result.get(type).put(scHeroRankUpConfig.getStar(),new HashMap<>()); } - result.get(type).put(scHeroRankUpConfig.getLimitLevel(),scHeroRankUpConfig); + if(type == GlobalsDef.UP_STAR_TYPE){ + result.get(type).get(scHeroRankUpConfig.getStar()).put(scHeroRankUpConfig.getLimitStar(),scHeroRankUpConfig); + } + result.get(type).get(scHeroRankUpConfig.getStar()).put(scHeroRankUpConfig.getLimitLevel(),scHeroRankUpConfig); } - scHeroRankUpConfigByType = result; + scHeroRankUpConfigByStar = result; } - public static Map getScHeroRankUpConfigByType(int type) { - return scHeroRankUpConfigByType.get(type); + public static Map getScHeroRankUpConfigByType(int type,int heroInitStar) { + return scHeroRankUpConfigByStar.get(type).get(heroInitStar); } public int getId() { @@ -80,4 +85,8 @@ public class SCHeroRankUpConfig implements BaseConfig{ public int[][] getConsumeMaterial() { return consumeMaterial; } + + public int getStar() { + return star; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index b35e3e3b4..e1d18235f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -215,10 +215,11 @@ public class HeroLogic { MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.UP_HERO_LEVEL_RESPONSE_VALUE,""); return; } + SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); int oldLevel = hero.getLevel(); //判断需要进行升级还是进行突破 - Map scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE); + Map scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE,scHero.getStar()); SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(oldLevel); boolean isBreak =false; int[][] consume; @@ -270,13 +271,13 @@ public class HeroLogic { } int oldStar = targetHero.getStar(); - Map scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE); + SCHero scHero = SCHero.getsCHero().get(targetHero.getTemplateId()); + Map scHeroRankUpConfigByType = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE,scHero.getStar()); SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(oldStar); if( targetHero.getLevel() < scHeroRankUpConfig.getLimitLevel()){ MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,"等级不够"); return; } - SCHero scHero = SCHero.getsCHero().get(targetHero.getTemplateId()); Map consumeMaterialInfoByPosition = scHero.getConsumeMaterialInfoOfPositionByStar(oldStar + 1); boolean canUse = true; List removeHeroIds = new ArrayList<>(); @@ -399,7 +400,8 @@ public class HeroLogic { private Map getParaForHero(Hero hero){ Map result = new HashMap<>(2); - Map scHeroRankUpConfigByTypeOfStar = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE); + SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); + Map scHeroRankUpConfigByTypeOfStar = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE,scHero.getStar()); SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByTypeOfStar.get(hero.getStar()); float rankupPara =0.0f; if( scHeroRankUpConfig!=null ){ @@ -408,7 +410,7 @@ public class HeroLogic { //突破系数 float breakPara = 0.0f; int heroLevel = hero.getLevel(); - Map scHeroRankUpConfigByTypOfBreak = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE); + Map scHeroRankUpConfigByTypOfBreak = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE,scHero.getStar()); for( SCHeroRankUpConfig scHeroRankUpConfigTmp :scHeroRankUpConfigByTypOfBreak.values()){ if( heroLevel >= scHeroRankUpConfigTmp.getLimitLevel() ){ breakPara = scHeroRankUpConfigTmp.getRankupPara(); From ad3309189cb0c265a2f958272162fdd1b49e829e Mon Sep 17 00:00:00 2001 From: gaojie Date: Mon, 28 Jan 2019 17:49:01 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E9=81=93=E5=85=B7=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=81=93=E5=85=B7=E5=87=BA=E5=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/server/ItemConfig.txt | 317 +++++++++--------- conf/server/RewardGroup.txt | 55 ++- conf/server/RewardItemConfig.txt | 60 +++- .../java/com/ljsd/jieling/config/SItem.java | 26 +- .../com/ljsd/jieling/config/SRewardGroup.java | 3 + .../com/ljsd/jieling/config/SRewardItem.java | 18 +- .../ljsd/jieling/globals/GlobalItemType.java | 11 +- .../jieling/handler/GetAllMailHandler.java | 4 +- .../jieling/handler/HeroComposeHandler.java | 27 ++ .../ljsd/jieling/handler/ReadMailHandler.java | 5 +- .../ljsd/jieling/handler/TakeMailHandler.java | 4 +- .../handler/UseAndPriceItemHandler.java | 44 +++ .../Mail/MailLogic.java} | 15 +- .../logic/dao/MailingSystemManager.java | 4 +- .../ljsd/jieling/logic/hero/HeroLogic.java | 35 +- .../ljsd/jieling/logic/item/ItemLogic.java | 92 +++++ .../java/com/ljsd/jieling/util/ItemUtil.java | 174 +++++++--- .../main/java/network/client/NettyClient.java | 28 +- 18 files changed, 674 insertions(+), 248 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/HeroComposeHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/UseAndPriceItemHandler.java rename serverlogic/src/main/java/com/ljsd/jieling/{util/MailUtil.java => logic/Mail/MailLogic.java} (96%) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/item/ItemLogic.java diff --git a/conf/server/ItemConfig.txt b/conf/server/ItemConfig.txt index 40f06de93..46a0b693d 100644 --- a/conf/server/ItemConfig.txt +++ b/conf/server/ItemConfig.txt @@ -1,158 +1,159 @@ -Id BackpackOrNot ItemType ItemBaseType Quantity IsStacking -int bool int int int bool -1 false 0 0 1 true -2 false 0 0 2 true -3 false 0 0 3 true -4 true 0 4 4 true -5 true 0 4 5 true -6 true 0 4 1 true -7 true 0 3 2 true -8 true 0 3 3 true -9 true 0 3 4 true -10 true 0 3 5 true -11 true 0 3 1 true -12 true 0 3 2 true -13 true 0 3 3 true -14 false 0 0 4 true -15 false 0 0 5 true -16 false 0 0 1 true -17 false 0 0 2 true -18 false 0 0 3 true -19 true 0 4 4 true -20 true 0 4 5 true -1001 true 0 2 1 true -1002 true 0 2 2 true -1003 true 0 2 3 true -1004 true 0 2 4 true -1005 true 0 2 5 true -1006 true 0 2 1 true -1007 true 0 2 2 true -1008 true 0 2 3 true -1009 true 0 2 4 true -1010 true 0 4 5 true -1011 true 0 4 1 true -1012 true 0 4 2 true -1013 true 0 4 3 true -1014 true 0 4 4 true -1015 true 0 4 5 true -1016 true 0 4 1 true -1017 true 0 4 2 true -1018 true 0 4 3 true -1019 true 0 4 4 true -1020 true 0 4 5 true -1021 true 0 4 1 true -1501 true 0 2 2 true -1502 true 0 2 3 true -1503 true 0 2 4 true -1504 true 0 4 5 true -1505 true 0 4 1 true -1506 true 0 4 2 true -1507 true 0 4 3 true -2001 true 0 2 4 true -2002 true 0 2 5 true -2003 true 0 2 1 true -2004 true 0 2 2 true -10001 false 1 0 5 false -10002 false 1 0 5 false -10003 false 1 0 5 false -10004 false 1 0 5 false -10005 false 1 0 5 false -10006 false 1 0 5 false -10007 false 1 0 5 false -10008 false 1 0 5 false -10009 false 1 0 5 false -10010 false 1 0 5 false -10011 false 1 0 5 false -10012 false 1 0 5 false -10013 false 1 0 5 false -10014 false 1 0 5 false -10015 false 1 0 5 false -10016 false 1 0 5 false -10017 false 1 0 5 false -10018 false 1 0 5 false -10019 false 1 0 5 false -10020 false 1 0 5 false -10021 false 1 0 5 false -10022 false 1 0 5 false -10023 false 1 0 5 false -10024 false 1 0 5 false -10025 false 1 0 5 false -10026 false 1 0 5 false -10027 false 1 0 5 false -10028 false 1 0 5 false -10029 false 1 0 5 false -10030 false 1 0 5 false -10031 false 1 0 5 false -10032 false 1 0 5 false -10033 false 1 0 5 false -10034 false 1 0 5 false -10035 false 1 0 5 false -10036 false 1 0 5 false -10037 false 1 0 5 false -10038 false 1 0 5 false -10039 false 1 0 5 false -10040 false 1 0 5 false -10041 false 1 0 5 false -10042 false 1 0 5 false -10043 false 1 0 5 false -10044 false 1 0 5 false -10045 false 1 0 5 false -10046 false 1 0 5 false -10047 false 1 0 5 false -10048 false 1 0 5 false -10049 false 1 0 5 false -10050 false 1 0 5 false -10051 false 1 0 5 false -10052 false 1 0 5 false -11001 true 2 5 5 true -11002 true 2 5 5 true -11003 true 2 5 5 true -11004 true 2 5 5 true -11005 true 2 5 5 true -11006 true 2 5 5 true -11007 true 2 5 5 true -11008 true 2 5 5 true -11009 true 2 5 5 true -11010 true 2 5 5 true -11011 true 2 5 5 true -11012 true 2 5 5 true -11013 true 2 5 5 true -11014 true 2 5 5 true -11015 true 2 5 5 true -11016 true 2 5 5 true -11017 true 2 5 5 true -11018 true 2 5 5 true -11019 true 2 5 5 true -11020 true 2 5 5 true -11021 true 2 5 5 true -11022 true 2 5 5 true -11023 true 2 5 5 true -11024 true 2 5 5 true -11025 true 2 5 5 true -11026 true 2 5 5 true -11027 true 2 5 5 true -11028 true 2 5 5 true -11029 true 2 5 5 true -11030 true 2 5 5 true -11031 true 2 5 5 true -11032 true 2 5 5 true -11033 true 2 5 5 true -11034 true 2 5 5 true -11035 true 2 5 5 true -11036 true 2 5 5 true -11037 true 2 5 5 true -11038 true 2 5 5 true -11039 true 2 5 5 true -11040 true 2 5 5 true -11041 true 2 5 5 true -11042 true 2 5 5 true -11043 true 2 5 5 true -11044 true 2 5 5 true -11045 true 2 5 5 true -11046 true 2 5 5 true -11047 true 2 5 5 true -11048 true 2 5 5 true -11049 true 2 5 5 true -11050 true 2 5 5 true -11051 true 2 5 5 true -11052 true 2 5 5 true +Id BackpackOrNot ItemType ItemBaseType Quantity Isopen Price UseType RewardGroup UsePerCount +int bool int int int bool mut,int#int,1 int int int +1 false 0 0 1 false null 0 0 0 +2 false 0 0 2 false null 0 0 0 +3 false 0 0 3 false null 0 0 0 +4 true 0 4 4 false null 0 0 0 +5 true 0 4 5 false null 0 0 0 +6 true 0 4 1 false null 0 0 0 +7 true 0 3 2 false null 0 0 0 +8 true 0 3 3 false null 0 0 0 +9 true 0 3 4 false null 0 0 0 +10 true 0 3 5 false null 0 0 0 +11 true 0 3 1 false null 0 0 0 +12 true 0 3 2 false null 0 0 0 +13 true 0 3 3 false null 0 0 0 +14 false 0 0 4 false null 0 0 0 +15 false 0 0 5 false null 0 0 0 +16 false 0 0 1 false null 0 0 0 +17 false 0 0 2 false null 0 0 0 +18 false 0 0 3 false null 0 0 0 +19 true 0 4 4 false null 0 0 0 +20 true 0 4 5 false null 0 0 0 +1001 true 0 2 1 false null 0 0 0 +1002 true 0 2 2 false null 0 0 0 +1003 true 0 2 3 false null 0 0 0 +1004 true 0 2 4 false null 0 0 0 +1005 true 0 2 5 false null 0 0 0 +1006 true 0 2 1 false null 0 0 0 +1007 true 0 2 2 false null 0 0 0 +1008 true 0 2 3 false null 0 0 0 +1009 true 0 2 4 false null 0 0 0 +1010 true 0 4 5 false null 0 0 0 +1011 true 0 4 1 false null 0 0 0 +1012 true 0 4 2 false null 0 0 0 +1013 true 0 4 3 false null 0 0 0 +1014 true 0 4 4 false null 0 0 0 +1015 true 0 4 5 false null 0 0 0 +1016 true 0 4 1 false null 0 0 0 +1017 true 0 4 2 false null 0 0 0 +1018 true 0 4 3 false null 0 0 0 +1019 true 0 4 4 false null 0 0 0 +1020 true 0 4 5 false null 0 0 0 +1021 true 0 4 1 false null 0 0 0 +1501 true 0 2 2 false null 0 0 0 +1502 true 0 2 3 false null 0 0 0 +1503 true 0 2 4 false null 0 0 0 +1504 true 0 4 5 false null 0 0 0 +1505 true 0 4 1 false null 0 0 0 +1506 true 0 4 2 false null 0 0 0 +1507 true 0 4 3 false null 0 0 0 +2001 true 0 2 4 false null 0 0 0 +2002 true 0 2 5 false null 0 0 0 +2003 true 0 2 1 false null 0 0 0 +2004 true 0 2 2 false null 0 0 0 +10001 false 1 0 5 false null 0 0 0 +10002 false 1 0 5 false null 0 0 0 +10003 false 1 0 5 false null 0 0 0 +10004 false 1 0 5 false null 0 0 0 +10005 false 1 0 5 false null 0 0 0 +10006 false 1 0 5 false null 0 0 0 +10007 false 1 0 5 false null 0 0 0 +10008 false 1 0 5 false null 0 0 0 +10009 false 1 0 5 false null 0 0 0 +10010 false 1 0 5 false null 0 0 0 +10011 false 1 0 5 false null 0 0 0 +10012 false 1 0 5 false null 0 0 0 +10013 false 1 0 5 false null 0 0 0 +10014 false 1 0 5 false null 0 0 0 +10015 false 1 0 5 false null 0 0 0 +10016 false 1 0 5 false null 0 0 0 +10017 false 1 0 5 false null 0 0 0 +10018 false 1 0 5 false null 0 0 0 +10019 false 1 0 5 false null 0 0 0 +10020 false 1 0 5 false null 0 0 0 +10021 false 1 0 5 false null 0 0 0 +10022 false 1 0 5 false null 0 0 0 +10023 false 1 0 5 false null 0 0 0 +10024 false 1 0 5 false null 0 0 0 +10025 false 1 0 5 false null 0 0 0 +10026 false 1 0 5 false null 0 0 0 +10027 false 1 0 5 false null 0 0 0 +10028 false 1 0 5 false null 0 0 0 +10029 false 1 0 5 false null 0 0 0 +10030 false 1 0 5 false null 0 0 0 +10031 false 1 0 5 false null 0 0 0 +10032 false 1 0 5 false null 0 0 0 +10033 false 1 0 5 false null 0 0 0 +10034 false 1 0 5 false null 0 0 0 +10035 false 1 0 5 false null 0 0 0 +10036 false 1 0 5 false null 0 0 0 +10037 false 1 0 5 false null 0 0 0 +10038 false 1 0 5 false null 0 0 0 +10039 false 1 0 5 false null 0 0 0 +10040 false 1 0 5 false null 0 0 0 +10041 false 1 0 5 false null 0 0 0 +10042 false 1 0 5 false null 0 0 0 +10043 false 1 0 5 false null 0 0 0 +10044 false 1 0 5 false null 0 0 0 +10045 false 1 0 5 false null 0 0 0 +10046 false 1 0 5 false null 0 0 0 +10047 false 1 0 5 false null 0 0 0 +10048 false 1 0 5 false null 0 0 0 +10049 false 1 0 5 false null 0 0 0 +10050 false 1 0 5 false null 0 0 0 +10051 false 1 0 5 false null 0 0 0 +10052 false 1 0 5 false null 0 0 0 +11001 true 2 5 5 false 14#1000 1 101 50 +11002 true 2 5 5 false 14#1001 1 102 50 +11003 true 2 5 5 false 14#1002 1 103 50 +11004 true 2 5 5 false 14#1003 1 104 50 +11005 true 2 5 5 false 14#1004 1 105 50 +11006 true 2 5 5 false 14#1005 1 106 50 +11007 true 2 5 5 false 14#1006 1 107 50 +11008 true 2 5 5 false 14#1007 1 108 50 +11009 true 2 5 5 false 14#1008 1 109 50 +11010 true 2 5 5 false 14#1009 1 110 50 +11011 true 2 5 5 false 14#1010 1 111 50 +11012 true 2 5 5 false 14#1011 1 112 50 +11013 true 2 5 5 false 14#1012 1 113 50 +11014 true 2 5 5 false 14#1013 1 114 50 +11015 true 2 5 5 false 14#1014 1 115 50 +11016 true 2 5 5 false 14#1015 1 116 50 +11017 true 2 5 5 false 14#1016 1 117 50 +11018 true 2 5 5 false 14#1017 1 118 50 +11019 true 2 5 5 false 14#1018 1 119 50 +11020 true 2 5 5 false 14#1019 1 120 50 +11021 true 2 5 5 false 14#1020 1 121 50 +11022 true 2 5 5 false 14#1021 1 122 50 +11023 true 2 5 5 false 14#1022 1 123 50 +11024 true 2 5 5 false 14#1023 1 124 40 +11025 true 2 5 5 false 14#1024 1 125 40 +11026 true 2 5 5 false 14#1025 1 126 40 +11027 true 2 5 5 false 14#1026 1 127 40 +11028 true 2 5 5 false 14#1027 1 128 40 +11029 true 2 5 5 false 14#1028 1 129 40 +11030 true 2 5 5 false 14#1029 1 130 40 +11031 true 2 5 5 false 14#1030 1 131 40 +11032 true 2 5 5 false 14#1031 1 132 40 +11033 true 2 5 5 false 14#1032 1 133 40 +11034 true 2 5 5 false 14#1033 1 134 40 +11035 true 2 5 5 false 14#1034 1 135 40 +11036 true 2 5 5 false 14#1035 1 136 40 +11037 true 2 5 5 false 14#1036 1 137 40 +11038 true 2 5 5 false 14#1037 1 138 40 +11039 true 2 5 5 false 14#1038 1 139 40 +11040 true 2 5 5 false 14#1039 1 140 40 +11041 true 2 5 5 false 14#1040 1 141 40 +11042 true 2 5 5 false 14#1041 1 142 40 +11043 true 2 5 5 false 14#1042 1 143 40 +11044 true 2 5 5 false 14#1043 1 144 40 +11045 true 2 5 5 false 14#1044 1 145 40 +11046 true 2 5 5 false 14#1045 1 146 40 +11047 true 2 5 5 false 14#1046 1 147 30 +11048 true 2 5 5 false 14#1047 1 148 30 +11049 true 2 5 5 false 14#1048 1 149 30 +11050 true 2 5 5 false 14#1049 1 150 30 +11051 true 2 5 5 false 14#1050 1 151 30 +11052 true 2 5 5 false 14#1051 1 152 30 +400001 true 0 3 5 false 14#1000 1 2 1 diff --git a/conf/server/RewardGroup.txt b/conf/server/RewardGroup.txt index 66cdb99a6..d4c084a45 100644 --- a/conf/server/RewardGroup.txt +++ b/conf/server/RewardGroup.txt @@ -1,3 +1,56 @@ Id IsUpset RewardItem RewardMaxNum Loop int int mut,int#int,1 int int -1 2 1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#52#53#54#55#56 1 0 +1 2 1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#52 1 0 +2 2 1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#52 1 0 +101 1 101 1 0 +102 1 102 1 0 +103 1 103 1 0 +104 1 104 1 0 +105 1 105 1 0 +106 1 106 1 0 +107 1 107 1 0 +108 1 108 1 0 +109 1 109 1 0 +110 1 110 1 0 +111 1 111 1 0 +112 1 112 1 0 +113 1 113 1 0 +114 1 114 1 0 +115 1 115 1 0 +116 1 116 1 0 +117 1 117 1 0 +118 1 118 1 0 +119 1 119 1 0 +120 1 120 1 0 +121 1 121 1 0 +122 1 122 1 0 +123 1 123 1 0 +124 1 124 1 0 +125 1 125 1 0 +126 1 126 1 0 +127 1 127 1 0 +128 1 128 1 0 +129 1 129 1 0 +130 1 130 1 0 +131 1 131 1 0 +132 1 132 1 0 +133 1 133 1 0 +134 1 134 1 0 +135 1 135 1 0 +136 1 136 1 0 +137 1 137 1 0 +138 1 138 1 0 +139 1 139 1 0 +140 1 140 1 0 +141 1 141 1 0 +142 1 142 1 0 +143 1 143 1 0 +144 1 144 1 0 +145 1 145 1 0 +146 1 146 1 0 +147 1 147 1 0 +148 1 148 1 0 +149 1 149 1 0 +150 1 150 1 0 +151 1 151 1 0 +152 1 152 1 0 diff --git a/conf/server/RewardItemConfig.txt b/conf/server/RewardItemConfig.txt index ae0aa1b37..f3da5f155 100644 --- a/conf/server/RewardItemConfig.txt +++ b/conf/server/RewardItemConfig.txt @@ -1,5 +1,5 @@ -id itemId Chance GrowChance RandomMin RandomMax -int int int int int int +Id ItemId Chance GrowChance RandomMin RandomMax +int int int float int int 1 10001 100 0 1 1 2 10002 100 0 1 1 3 10003 100 0 1 1 @@ -52,7 +52,55 @@ int int int int int int 50 10050 100 0 1 1 51 10051 100 0 1 1 52 10052 100 0 1 1 -53 10053 100 0 1 1 -54 10054 100 0 1 1 -55 10055 100 0 1 1 -56 10056 100 0 1 1 +101 10001 100 0 1 1 +102 10002 100 0 1 1 +103 10003 100 0 1 1 +104 10004 100 0 1 1 +105 10005 100 0 1 1 +106 10006 100 0 1 1 +107 10007 100 0 1 1 +108 10008 100 0 1 1 +109 10009 100 0 1 1 +110 10010 100 0 1 1 +111 10011 100 0 1 1 +112 10012 100 0 1 1 +113 10013 100 0 1 1 +114 10014 100 0 1 1 +115 10015 100 0 1 1 +116 10016 100 0 1 1 +117 10017 100 0 1 1 +118 10018 100 0 1 1 +119 10019 100 0 1 1 +120 10020 100 0 1 1 +121 10021 100 0 1 1 +122 10022 100 0 1 1 +123 10023 100 0 1 1 +124 10024 100 0 1 1 +125 10025 100 0 1 1 +126 10026 100 0 1 1 +127 10027 100 0 1 1 +128 10028 100 0 1 1 +129 10029 100 0 1 1 +130 10030 100 0 1 1 +131 10031 100 0 1 1 +132 10032 100 0 1 1 +133 10033 100 0 1 1 +134 10034 100 0 1 1 +135 10035 100 0 1 1 +136 10036 100 0 1 1 +137 10037 100 0 1 1 +138 10038 100 0 1 1 +139 10039 100 0 1 1 +140 10040 100 0 1 1 +141 10041 100 0 1 1 +142 10042 100 0 1 1 +143 10043 100 0 1 1 +144 10044 100 0 1 1 +145 10045 100 0 1 1 +146 10046 100 0 1 1 +147 10047 100 0 1 1 +148 10048 100 0 1 1 +149 10049 100 0 1 1 +150 10050 100 0 1 1 +151 10051 100 0 1 1 +152 10052 100 0 1 1 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SItem.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SItem.java index 3433ba893..eb78873e9 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SItem.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SItem.java @@ -14,7 +14,11 @@ public class SItem implements BaseConfig { private int itemType; private int itemBaseType; //道具类型(该道具在哪个背包显示) private int quantity; - private boolean isStacking; + private int[] price; + private int useType; //使用类型0不使用 1掉落组 2N选1 + private int rewardGroup; + private int usePerCount; + private boolean isopen; @Override public void init() throws Exception { @@ -45,7 +49,23 @@ public class SItem implements BaseConfig { return quantity; } - public boolean isStacking() { - return isStacking; + public int[] getPrice() { + return price; + } + + public int getUseType() { + return useType; + } + + public int getRewardGroup() { + return rewardGroup; + } + + public int getUsePerCount() { + return usePerCount; + } + + public boolean isIsopen() { + return isopen; } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardGroup.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardGroup.java index de037bc0a..4227faf4e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardGroup.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardGroup.java @@ -2,6 +2,7 @@ package com.ljsd.jieling.config; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; +import com.ljsd.jieling.util.ItemUtil; import java.util.Map; @@ -26,6 +27,8 @@ public class SRewardGroup implements BaseConfig { @Override public void init() throws Exception { sRewardItemMap = STableManager.getConfig(SRewardGroup.class); + ItemUtil.initDropReward(); + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java index 35f2fc23c..e1062de0e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java @@ -2,22 +2,32 @@ package com.ljsd.jieling.config; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; +import com.ljsd.jieling.util.ItemUtil; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; @Table(name = "RewardItemConfig") public class SRewardItem implements BaseConfig { public static Map sDropMap; + public static Map sDropMapByItemId; private int id; private int itemId; private int chance; //获取概率 - private int growChance; //成长概率 针对特殊处理,如果不获取,则获取概率增加 + private float growChance; //成长概率 针对特殊处理,如果不获取,则获取概率增加 private int randomMin; //获取数量最小值 private int randomMax; //获取数量最大值 @Override public void init() throws Exception { sDropMap = STableManager.getConfig(SRewardItem.class); + Map sDropByItemMap= new ConcurrentHashMap<>(); + for (Map.Entry entry :sDropMap.entrySet()){ + SRewardItem sRewardItem = entry.getValue(); + sDropByItemMap.put(sRewardItem.getItemId(),sRewardItem); + } + sDropMapByItemId = sDropByItemMap; + ItemUtil.initDropReward(); } @@ -29,6 +39,10 @@ public class SRewardItem implements BaseConfig { return sDropMap; } + public static Map getsDropMapByItemId() { + return sDropMapByItemId; + } + public int getItemId() { return itemId; } @@ -37,7 +51,7 @@ public class SRewardItem implements BaseConfig { return chance; } - public int getGrowChance() { + public float getGrowChance() { return growChance; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/globals/GlobalItemType.java b/serverlogic/src/main/java/com/ljsd/jieling/globals/GlobalItemType.java index 66dd7345a..4baec5e89 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/globals/GlobalItemType.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/globals/GlobalItemType.java @@ -2,9 +2,9 @@ package com.ljsd.jieling.globals; public interface GlobalItemType { //掉落物品类型 - int ALL_DROP = 0; //全部掉落 - int WEIGHT_DROP = 1; //随机掉落 - int SUCCESSIVELY_RANDOM = 2; // 依次随机 + int ALL_DROP = 1; //全部掉落 + int WEIGHT_DROP = 2; //随机掉落 + int SUCCESSIVELY_RANDOM = 3; // 依次随机 // 物品类型 int GEM = 3; // 钻石Id(充值获得) @@ -12,5 +12,10 @@ public interface GlobalItemType { int CARD = 1; // 卡牌 int CARD_FRAGMENT = 2; // 卡牌碎片 int EQUIP = 3; //装备 + int RANDOM_ITME = 5; // 随机道具 + + //物品使用类型 + int NO_USE = 0 ; //不使用 + int RANDOM_USE = 1; // 随机使用 } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllMailHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllMailHandler.java index 5b20a1254..91d6e1aba 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllMailHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetAllMailHandler.java @@ -1,6 +1,6 @@ package com.ljsd.jieling.handler; -import com.ljsd.jieling.util.MailUtil; +import com.ljsd.jieling.logic.Mail.MailLogic; import com.ljsd.jieling.netty.cocdex.PacketNetData; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; @@ -31,7 +31,7 @@ public class GetAllMailHandler extends BaseHandler { int msgIndex = netData.getIndex(); LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={}", userId, token,msgId,msgIndex); - List allUserMail = MailUtil.getInstance().getAllUserMail(userId); + List allUserMail = MailLogic.getInstance().getAllUserMail(userId); PlayerInfoProto.GetAllMailInfoResponse getPlayerInfoResponse = PlayerInfoProto.GetAllMailInfoResponse.newBuilder() .addAllMialList(allUserMail) .build(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/HeroComposeHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/HeroComposeHandler.java new file mode 100644 index 000000000..c43138a77 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/HeroComposeHandler.java @@ -0,0 +1,27 @@ +package com.ljsd.jieling.handler; + +import com.ljsd.jieling.logic.hero.HeroLogic; +import com.ljsd.jieling.netty.cocdex.PacketNetData; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.CommonProto; +import com.ljsd.jieling.protocols.HeroInfoProto; +import com.ljsd.jieling.protocols.MessageTypeProto; +import org.springframework.stereotype.Component; + + +@Component +public class HeroComposeHandler extends BaseHandler{ + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.HERO_COMPOSE_REQUEST; + } + + @Override + public void process(ISession iSession, PacketNetData netData) throws Exception { + byte[] bytes = netData.parseClientProtoNetData(); + HeroInfoProto.HeroComposeRequest heroComposeRequest = HeroInfoProto.HeroComposeRequest.parseFrom(bytes); + CommonProto.Item item = heroComposeRequest.getItem(); + HeroLogic.getInstance().heroCompose(iSession,item); + + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/ReadMailHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/ReadMailHandler.java index 25ef1d0d8..62cd722b3 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/ReadMailHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/ReadMailHandler.java @@ -4,8 +4,7 @@ import com.ljsd.jieling.netty.cocdex.PacketNetData; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.PlayerInfoProto; -import com.ljsd.jieling.util.MailUtil; -import com.ljsd.jieling.util.MessageUtil; +import com.ljsd.jieling.logic.Mail.MailLogic; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -31,7 +30,7 @@ public class ReadMailHandler extends BaseHandler { userId, token,msgId,msgIndex); PlayerInfoProto.MailReadRequest mailReadRequest = PlayerInfoProto.MailReadRequest.parseFrom(message); String mailId = mailReadRequest.getMailId(); - MailUtil.getInstance().readMail(iSession,mailId); + MailLogic.getInstance().readMail(iSession,mailId); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/TakeMailHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/TakeMailHandler.java index 31acb7836..e5f1f95ef 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/TakeMailHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/TakeMailHandler.java @@ -5,7 +5,7 @@ import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.PlayerInfoProto; -import com.ljsd.jieling.util.MailUtil; +import com.ljsd.jieling.logic.Mail.MailLogic; import com.ljsd.jieling.util.MessageUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +34,7 @@ public class TakeMailHandler extends BaseHandler { userId, token,msgId,msgIndex); PlayerInfoProto.TakeMailRequest takeMailRequest = PlayerInfoProto.TakeMailRequest.parseFrom(message); List mailIdsList = takeMailRequest.getMailIdsList(); - CommonProto.Drop.Builder dropBuilder = MailUtil.getInstance().takeMail(mailIdsList, userId); + CommonProto.Drop.Builder dropBuilder = MailLogic.getInstance().takeMail(mailIdsList, userId); PlayerInfoProto.TakeMailResponse takeMailResponse = PlayerInfoProto.TakeMailResponse.newBuilder() .setDrop(dropBuilder) .buildPartial(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/UseAndPriceItemHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/UseAndPriceItemHandler.java new file mode 100644 index 000000000..f98038cd7 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/UseAndPriceItemHandler.java @@ -0,0 +1,44 @@ +package com.ljsd.jieling.handler; + +import com.ljsd.jieling.globals.Global; +import com.ljsd.jieling.logic.dao.User; +import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.item.ItemLogic; +import com.ljsd.jieling.netty.cocdex.PacketNetData; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.CommonProto; +import com.ljsd.jieling.protocols.MessageTypeProto; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import com.ljsd.jieling.util.ItemUtil; +import com.ljsd.jieling.util.MessageUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class UseAndPriceItemHandler extends BaseHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(UseAndPriceItemHandler.class); + + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_REQUEST; + } + + @Override + public void process(ISession iSession, PacketNetData netData) throws Exception { + PlayerInfoProto.UseAndPriceItemRequest useAndPriceItemRequest + = PlayerInfoProto.UseAndPriceItemRequest.parseFrom(netData.parseClientProtoNetData()); + int type = useAndPriceItemRequest.getType(); + CommonProto.Item item = useAndPriceItemRequest.getItem(); + if (type == 0){ + ItemLogic.getInstance().useItem(iSession,item); + }else{ + ItemLogic.getInstance().priceItem(iSession,item); + } + + + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/MailUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/Mail/MailLogic.java similarity index 96% rename from serverlogic/src/main/java/com/ljsd/jieling/util/MailUtil.java rename to serverlogic/src/main/java/com/ljsd/jieling/logic/Mail/MailLogic.java index 2c57ccc23..e4f2a64ce 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/MailUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/Mail/MailLogic.java @@ -1,27 +1,28 @@ -package com.ljsd.jieling.util; +package com.ljsd.jieling.logic.Mail; import com.ljsd.jieling.globals.Global; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.MessageTypeProto; +import com.ljsd.jieling.util.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; -public class MailUtil { - private static final Logger LOGGER = LoggerFactory.getLogger(MailUtil.class); +public class MailLogic { + private static final Logger LOGGER = LoggerFactory.getLogger(MailLogic.class); - private MailUtil(){} + private MailLogic(){} public static class Instance { - public final static MailUtil instance = new MailUtil(); + public final static MailLogic instance = new MailLogic(); } - public static MailUtil getInstance() { - return MailUtil.Instance.instance; + public static MailLogic getInstance() { + return MailLogic.Instance.instance; } /** diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailingSystemManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailingSystemManager.java index bc0f375ac..692e1016a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailingSystemManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/MailingSystemManager.java @@ -2,7 +2,7 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.LjsdMongoTemplate; -import com.ljsd.jieling.util.MailUtil; +import com.ljsd.jieling.logic.Mail.MailLogic; import com.ljsd.jieling.util.TimeUtils; import org.springframework.context.ConfigurableApplicationContext; @@ -28,7 +28,7 @@ public class MailingSystemManager { int nowTime = (int)(TimeUtils.now()/1000); mailingSystem.getSysMailManager().addSystemMail(new SysMail(1)); MailingSystemManager.ljsdMongoTemplate.lastUpdate(); - MailUtil.getInstance().sendSystemMail("开服邮件",new ArrayList<>(),"DSKGSD",nowTime,"1#5000|2#100",30*24*60*60,"IDIP",0,"0"); + MailLogic.getInstance().sendSystemMail("开服邮件",new ArrayList<>(),"DSKGSD",nowTime,"1#5000|2#100",30*24*60*60,"IDIP",0,"0"); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 6b308c541..f65b9d578 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -4,6 +4,7 @@ import com.ljsd.GameApplication; import com.ljsd.jieling.config.*; import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.logic.dao.*; +import com.ljsd.jieling.logic.item.ItemLogic; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; import com.ljsd.jieling.protocols.HeroInfoProto; @@ -13,6 +14,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; public class HeroLogic { private static final Logger LOGGER = LoggerFactory.getLogger(HeroLogic.class); @@ -113,12 +115,10 @@ public class HeroLogic { } if( itemType == 2) { Item item = itemManager.getItem(itemId); - if (item == null){ + if (item == null) { item = itemManager.newItem(itemId, itemNum); - }else{ - if(sItem.isStacking()){ - item.setItemNum(item.getItemNum() + itemNum); - } + } else { + item.setItemNum(item.getItemNum() + itemNum); } items.add(CBean2Proto.getItem(item)); } @@ -476,7 +476,30 @@ public class HeroLogic { MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.EQUIP_UNLOAD_OPT_RESPONSE_VALUE,null,true); } - + /** + * 英雄合成 + * @param iSession + * @param item + */ + public void heroCompose(ISession iSession, CommonProto.Item item) throws Exception { + int msgId = MessageTypeProto.MessageType.HERO_COMPOSE_RESPONSE_VALUE; + int uid = iSession.getUid(); + User user = UserManager.getUser(uid); + int itemId = item.getItemId(); + int itemNum = item.getItemNum(); + SItem sItem = SItem.getsItemMap().get(itemId); + boolean result = ItemUtil.checkCost(user, sItem, itemNum); + if (!result){ + MessageUtil.sendErrorResponse(iSession,0,msgId,""); + } + Map randomMap = new ConcurrentHashMap<>(); + randomMap.put(itemId,itemNum); + CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user,randomMap ); + HeroInfoProto.HeroComposeResponse heroComposeResponse = HeroInfoProto.HeroComposeResponse + .newBuilder() + .setDrop(drop) + .build(); + MessageUtil.sendMessage(iSession,1,msgId,heroComposeResponse,true); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/item/ItemLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/ItemLogic.java new file mode 100644 index 000000000..0c4b6f270 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/item/ItemLogic.java @@ -0,0 +1,92 @@ +package com.ljsd.jieling.logic.item; + +import com.ljsd.jieling.config.*; +import com.ljsd.jieling.globals.GlobalItemType; +import com.ljsd.jieling.logic.dao.*; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.CommonProto; +import com.ljsd.jieling.protocols.MessageTypeProto; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import com.ljsd.jieling.util.*; +import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class ItemLogic { + private static final Logger LOGGER = LoggerFactory.getLogger(ItemLogic.class); + + private ItemLogic(){} + + public static class Instance { + public final static ItemLogic instance = new ItemLogic(); + } + + public static ItemLogic getInstance() { + return ItemLogic.Instance.instance; + } + + /** + * 出售道具 + * @param iSession + * @param item + * @throws Exception + */ + public void priceItem(ISession iSession,CommonProto.Item item) throws Exception { + int uid = iSession.getUid(); + User user = UserManager.getUser(uid); + int msgId = MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE; + int itemId = item.getItemId(); + int itemNum = item.getItemNum(); + SItem sItem = SItem.getsItemMap().get(itemId); + if (sItem == null){ + MessageUtil.sendErrorResponse(iSession,0,msgId,""); + return; + } + String costItem = itemId + "#"+ itemNum; + int[][] costItemArr = StringUtil.parseFiledInt2(costItem); + boolean result = ItemUtil.itemCost(user, costItemArr); + if (!result){ + MessageUtil.sendErrorResponse(iSession,0,msgId,""); + return; + } + int[] prices = sItem.getPrice(); + int priceItemId = prices[0]; + int priceItemNum = prices[1] * itemNum; + String priceReward = priceItemId+"#"+priceItemNum; + int[][] ints = StringUtil.parseFiledInt2(priceReward); + CommonProto.Drop.Builder drop = ItemUtil.drop(user, ints); + sendUseAndPriceItemMessage(iSession, msgId, drop); + } + + private void sendUseAndPriceItemMessage(ISession iSession, int msgId, CommonProto.Drop.Builder drop) { + PlayerInfoProto.UseAndPriceItemResponse useAndPriceItemResponse = PlayerInfoProto.UseAndPriceItemResponse.newBuilder() + .setDrop(drop) + .build(); + MessageUtil.sendMessage(iSession, 1,msgId, useAndPriceItemResponse, true); + } + + /** + * 使用道具 + * @param iSession + * @param item + */ + public void useItem(ISession iSession, CommonProto.Item item) throws Exception { + int msgId = MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE; + int uid = iSession.getUid(); + User user = UserManager.getUser(uid); + int itemId = item.getItemId(); + int itemNum = item.getItemNum(); + SItem sItem = SItem.getsItemMap().get(itemId); + boolean result = ItemUtil.checkCost(user, sItem, itemNum); + if (!result){ + MessageUtil.sendErrorResponse(iSession,0,msgId,""); + } + Map randomMap = new ConcurrentHashMap<>(); + randomMap.put(itemId,itemNum); + CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user,randomMap); + sendUseAndPriceItemMessage(iSession, msgId, drop); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index 2c1c1c022..a13f9e221 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -10,9 +10,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; public class ItemUtil { + private static Map dropRewardMap = new ConcurrentHashMap<>(); private static final Logger LOGGER = LoggerFactory.getLogger(ItemUtil.class); //掉落 public static CommonProto.Drop.Builder drop(User user, int[][] itemArr) throws Exception { @@ -20,17 +22,21 @@ public class ItemUtil { Map itemMap = new HashMap<>(); Map cardMap = new HashMap<>(); Map equipMap = new HashMap<>(); - selectItemArr(itemArr,cardMap,itemMap,equipMap); + Map randomMap = new HashMap<>(); + selectItemArr(itemArr,cardMap,itemMap,equipMap,randomMap); + + useRandomItem(user,randomMap); addItem(user,itemMap,dropBuilder); addCard(user,cardMap,dropBuilder); addEquip(user,equipMap,dropBuilder); return dropBuilder; } - private static void selectItemArr(int[][] itemArr, Map cardMap, Map itemMap,Map equipMap) { + private static void selectItemArr(int[][] itemArr, Map cardMap, Map + itemMap,Map equipMap,Map randomMap) { for (int[] items : itemArr){ - getMap(items[0],items[1], itemMap, cardMap,equipMap,1); + getMap(items[0],items[1], itemMap, cardMap,equipMap,randomMap,1); } } @@ -40,15 +46,18 @@ public class ItemUtil { Map itemMap = new HashMap<>(); Map cardMap = new HashMap<>(); Map equipMap = new HashMap<>(); + Map randomMap = new HashMap<>(); for (int dropGroupId :dropGroupIds){ SRewardGroup sRewardGroup = SRewardGroup.getsRewardItemMap().get(dropGroupId); if (sRewardGroup == null){ continue; } - selectDrop(sRewardGroup,itemMap,cardMap,equipMap,dropRatio); + selectDrop(sRewardGroup,itemMap,cardMap,equipMap,randomMap,dropRatio); } + useRandomItem(user,randomMap); addItem(user,itemMap,dropBuilder); addCard(user,cardMap,dropBuilder); + addEquip(user,equipMap,dropBuilder); return dropBuilder; } public static CommonProto.Drop.Builder drop(User user, Map dropGroupAndRatioMap) throws Exception { @@ -60,45 +69,30 @@ public class ItemUtil { } return dropBuilder; } - private static void selectDrop(SRewardGroup sRewardGroup,Map itemMap, Map cardMap,Map equipMap,float dropRatio) { - int[] rewardItem = sRewardGroup.getRewardItem(); - StringBuilder rewardStr = new StringBuilder(); - StringBuilder weight = new StringBuilder(); - for (int dropId :rewardItem){ - SRewardItem sRewardItem = SRewardItem.getsDropMap().get(dropId); - if (sRewardItem == null){ - continue; - } - if (rewardStr.length() == 0){ - rewardStr = new StringBuilder(String.valueOf(sRewardItem.getItemId())); - }else{ - rewardStr.append("#").append(sRewardItem.getItemId()); - } - if (weight.length() == 0){ - weight = new StringBuilder(String.valueOf(sRewardItem.getChance())); - }else{ - weight.append("#").append(sRewardItem.getItemId()); - } - } + private static void selectDrop(SRewardGroup sRewardGroup,Map itemMap, Map cardMap,Map equipMap,Map randomMap , float dropRatio) { + String dropInfo = dropRewardMap.get(sRewardGroup.getId()); + String rewardStr = dropInfo.split("\\|")[0]; + String weight = dropInfo.split("\\|")[1]; switch (sRewardGroup.getIsUpset()) { case GlobalItemType.ALL_DROP: - getMap(StringUtil.parseFiledInt(rewardStr.toString()),itemMap,cardMap,equipMap,dropRatio); + getMap(StringUtil.parseFiledInt(rewardStr),itemMap,cardMap,equipMap,randomMap,dropRatio); break; case GlobalItemType.WEIGHT_DROP: - getRandomMap(sRewardGroup.getRewardMaxNum(),rewardStr.toString().split("#"),weight.toString().split("#"), - itemMap,equipMap,cardMap,dropRatio); + getRandomMap(sRewardGroup.getRewardMaxNum(),rewardStr.split("#"),weight.split("#"), + itemMap,equipMap,cardMap,randomMap,dropRatio); break; case GlobalItemType.SUCCESSIVELY_RANDOM: - getSuccessivelyRandmoMap(sRewardGroup,rewardStr.toString().split("#"),weight.toString().split("#"), - itemMap,cardMap,equipMap,dropRatio); + getSuccessivelyRandmoMap(sRewardGroup,rewardStr.split("#"),weight.split("#"), + itemMap,cardMap,equipMap,randomMap,dropRatio); break; default: break; } } - private static void getSuccessivelyRandmoMap(SRewardGroup sRewardGroup,String[] rewardArr,String[] weightArr, Map itemMap, - Map cardMap,Map equipMap,float dropRatio) { + private static void getSuccessivelyRandmoMap(SRewardGroup sRewardGroup,String[] + rewardArr,String[] weightArr, Map itemMap,Map + cardMap, Map equipMap,Map randomMap,float dropRatio) { for (int i = 0 ; i < sRewardGroup.getRewardMaxNum();i++){ int itemId = 0; for (int j = 0 ; j < sRewardGroup.getLoop();i++){ @@ -114,32 +108,33 @@ public class ItemUtil { } SRewardItem sRewardItem = SRewardItem.getsDropMap().get(itemId); int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); - getMap(itemId,itemNum ,itemMap, cardMap,equipMap,dropRatio); + getMap(itemId,itemNum ,itemMap, cardMap,equipMap,randomMap,dropRatio); } } private static void getRandomMap(int randomItemNum ,String[] rewardArr,String[] weightArr, Map itemMap, Map cardMap, - Map equipMap,float dropRatio) { + Map equipMap,Map randomMap ,float dropRatio) { for (int i = 0 ; i < randomItemNum;i++){ int index = MathUtils.randomForStrArray(weightArr); int itemId = Integer.parseInt(rewardArr[index]); - SRewardItem sRewardItem = SRewardItem.getsDropMap().get(itemId); + SRewardItem sRewardItem = SRewardItem.getsDropMapByItemId().get(itemId); int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); - getMap(itemId,itemNum, itemMap, cardMap,equipMap,dropRatio); + getMap(itemId,itemNum, itemMap, cardMap,equipMap,randomMap,dropRatio); } } - private static void getMap(int[] itemInfo, Map itemMap,Map cardMap,Map equipMap,float dropRatio) { + private static void getMap(int[] itemInfo, Map itemMap,Map cardMap,Map equipMap,Map randomMap ,float dropRatio) { for (int itemId :itemInfo){ - SRewardItem sRewardItem = SRewardItem.getsDropMap().get(itemId); + SRewardItem sRewardItem = SRewardItem.getsDropMapByItemId().get(itemId); int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); - getMap(itemId,itemNum,itemMap, cardMap,equipMap,dropRatio); + getMap(itemId,itemNum,itemMap, cardMap,equipMap,randomMap,dropRatio); } } - private static void getMap(int itemId ,int itemNum, Map itemMap, Map cardMap,Map equipMap,float dropRatio) { + private static void getMap(int itemId ,int itemNum, Map itemMap, + Map cardMap,Map equipMap ,Map randomMap,float dropRatio) { SItem sItem = SItem.getsItemMap().get(itemId); - int itemType =getItemType(sItem.getItemType()); + int itemType =getItemType(sItem); switch (itemType) { case GlobalItemType.ITEM: putcountMap(itemId,MathUtils.numRount((itemNum * dropRatio)) , itemMap); @@ -150,16 +145,25 @@ public class ItemUtil { case GlobalItemType.EQUIP: putcountMap(itemId, itemNum, cardMap); break; + case GlobalItemType.RANDOM_ITME: + putcountMap(itemId, itemNum, randomMap); + break; default: break; } } - private static int getItemType(int itemType) { - switch (itemType) { + private static int getItemType(SItem sItem) { + int itemType = sItem.getItemType(); + switch (sItem.getItemType()) { case GlobalItemType.CARD_FRAGMENT: itemType = GlobalItemType.ITEM; break; + case GlobalItemType.RANDOM_ITME: + if (!sItem.isIsopen()){ + itemType = GlobalItemType.ITEM; + } + break; default: break; } @@ -185,12 +189,10 @@ public class ItemUtil { continue; } Item item = itemManager.getItem(entry.getKey()); - if (item == null){ + if (item == null) { item = itemManager.newItem(entry.getKey(), entry.getValue()); - }else{ - if(sItem.isStacking()){ - item.setItemNum(item.getItemNum() + entry.getValue()); - } + } else { + item.setItemNum(item.getItemNum() + entry.getValue()); } itemProtoList.add(CBean2Proto.getItem(item)); } @@ -342,7 +344,7 @@ public class ItemUtil { int itemId = costItem[0]; int itemNum = costItem[1]; SItem sItem = SItem.getsItemMap().get(itemId); - int itemType = getItemType(sItem.getItemType()); + int itemType = getItemType(sItem); switch (itemType) { case GlobalItemType.GEM: putcountMap(itemId,itemNum,moneyMap); @@ -355,4 +357,80 @@ public class ItemUtil { } } } + + /** + * 使用随机物品 + * @param user + * @param randomMap + * @return + * @throws Exception + */ + public static CommonProto.Drop.Builder useRandomItem(User user,Map randomMap) throws Exception { + StringBuilder dropIds = new StringBuilder(); + for (Map.Entry entry : randomMap.entrySet()){ + int itemId = entry.getKey(); + int itemNum = entry.getValue(); + SItem sItem = SItem.getsItemMap().get(itemId); + for (int i = 0; i < itemNum; i++){ + if (dropIds.length() == 0){ + dropIds = new StringBuilder(String.valueOf(sItem.getRewardGroup())); + }else{ + dropIds.append("#").append(sItem.getRewardGroup()); + } + } + } + CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder(); + if (!dropIds.toString().isEmpty()){ + int[] ints = StringUtil.parseFiledInt(dropIds.toString()); + drop = ItemUtil.drop(user, ints, 1); + } + return drop; + } + public static boolean checkCost(User user ,SItem sItem , int itemNum) throws Exception { + if (sItem == null){ + return false; + } + if (sItem.getUseType() == GlobalItemType.NO_USE){ + return false; + } + String costItem = sItem.getId() +"#"+ itemNum; + int[][] ints = StringUtil.parseFiledInt2(costItem); + return ItemUtil.itemCost(user, ints); + } + + public static void initDropReward() { + Map sRewardGroupMap = SRewardGroup.getsRewardItemMap(); + Map sRewardItemMap = SRewardItem.getsDropMap(); + if (sRewardGroupMap == null){ + return; + } + if (sRewardItemMap == null){ + return; + } + Map dropMap = new ConcurrentHashMap<>(); + for (Map.Entry entry :sRewardGroupMap.entrySet()){ + SRewardGroup sRewardGroup = entry.getValue(); + int[] rewardItem = sRewardGroup.getRewardItem(); + StringBuilder rewardStr = new StringBuilder(); + StringBuilder weight = new StringBuilder(); + for (int dropId :rewardItem){ + SRewardItem sRewardItem =sRewardItemMap.get(dropId); + if (sRewardItem == null){ + continue; + } + if (rewardStr.length() == 0){ + rewardStr = new StringBuilder(String.valueOf(sRewardItem.getItemId())); + }else{ + rewardStr.append("#").append(sRewardItem.getItemId()); + } + if (weight.length() == 0){ + weight = new StringBuilder(String.valueOf(sRewardItem.getChance())); + }else{ + weight.append("#").append(sRewardItem.getChance()); + } + dropMap.put(sRewardGroup.getId(),rewardStr +"|"+weight); + } + } + dropRewardMap = dropMap; + } } diff --git a/test/src/main/java/network/client/NettyClient.java b/test/src/main/java/network/client/NettyClient.java index 3691ff8c8..9b02bf904 100644 --- a/test/src/main/java/network/client/NettyClient.java +++ b/test/src/main/java/network/client/NettyClient.java @@ -18,7 +18,7 @@ public class NettyClient { private static final Logger LOGGER = LoggerFactory.getLogger(NettyClient.class); - private static int uid = 10000026; + private static int uid = 10000061; private static int msgIndex = 1; private static int token=543242; @@ -41,15 +41,33 @@ public class NettyClient { LOGGER.info(gameMessage.toString()); //--------------------------------------------------------------------------------------------------------- - handler.sendRequest_jieling(makeFinalMessage(gameMessage, MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE)); + handler.sendRequest_jieling(makeFinalMessage(gameMessage, MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE)); // handler.sendRequest_jieling(makeFinalMessage(getHero(), MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE)); // handler.sendRequest_jieling(makeFinalMessage(getRandomHero(), MessageTypeProto.MessageType.HERO_RAND_REQQUEST_VALUE)); -// for (int i = 1000; i< 1500;i++){ - handler.sendRequest_jieling(makeFinalMessage(gmRequest(0), MessageTypeProto.MessageType.GM_REQUEST_VALUE)); +// handler.sendRequest_jieling(makeFinalMessage(gmRequest(11001), MessageTypeProto.MessageType.GM_REQUEST_VALUE)); + handler.sendRequest_jieling(makeFinalMessage(useAndPriceItemRequest(0,11001,2), MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_REQUEST_VALUE)); +// handler.sendRequest_jieling(makeFinalMessage(heroComperRequest(1001,10), MessageTypeProto.MessageType.HERO_COMPOSE_REQUEST_VALUE)); // } } + private static MessageLite heroComperRequest(int itemId, int itemNum) { + CommonProto.Item item = CommonProto.Item.newBuilder() + .setItemId(itemId) + .setItemNum(itemNum) + .build(); + return HeroInfoProto.HeroComposeRequest.newBuilder().setItem(item).build(); + } + + private static MessageLite useAndPriceItemRequest(int type ,int itemId , int itemNum) { + CommonProto.Item item = CommonProto.Item.newBuilder() + .setItemId(itemId) + .setItemNum(itemNum) + .build(); + return PlayerInfoProto.UseAndPriceItemRequest.newBuilder().setType(type).setItem(item).build(); + + } + public static HeroInfoProto.GetHeroListInfoRequest getHero(){ return HeroInfoProto.GetHeroListInfoRequest.newBuilder().setNum(1).setStr("111").build(); } @@ -73,7 +91,7 @@ public class NettyClient { } public static CommonProto.GMCommand gmRequest(int itemId){ - return CommonProto.GMCommand.newBuilder().setCommand("3#"+1+"#10000").build(); + return CommonProto.GMCommand.newBuilder().setCommand("1#"+itemId+"#10").build(); } From 74f93a4b597c828830a65fe7e5e96bbd5f9b851d Mon Sep 17 00:00:00 2001 From: gaojie Date: Mon, 28 Jan 2019 18:04:49 +0800 Subject: [PATCH 5/8] fix --- .../com/ljsd/jieling/config/SRewardItem.java | 12 -------- .../java/com/ljsd/jieling/util/ItemUtil.java | 30 +++++++++---------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java index e1062de0e..920cb7cd1 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SRewardItem.java @@ -5,12 +5,10 @@ import com.ljsd.jieling.logic.Table; import com.ljsd.jieling.util.ItemUtil; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; @Table(name = "RewardItemConfig") public class SRewardItem implements BaseConfig { public static Map sDropMap; - public static Map sDropMapByItemId; private int id; private int itemId; private int chance; //获取概率 @@ -21,12 +19,6 @@ public class SRewardItem implements BaseConfig { @Override public void init() throws Exception { sDropMap = STableManager.getConfig(SRewardItem.class); - Map sDropByItemMap= new ConcurrentHashMap<>(); - for (Map.Entry entry :sDropMap.entrySet()){ - SRewardItem sRewardItem = entry.getValue(); - sDropByItemMap.put(sRewardItem.getItemId(),sRewardItem); - } - sDropMapByItemId = sDropByItemMap; ItemUtil.initDropReward(); } @@ -39,10 +31,6 @@ public class SRewardItem implements BaseConfig { return sDropMap; } - public static Map getsDropMapByItemId() { - return sDropMapByItemId; - } - public int getItemId() { return itemId; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index a13f9e221..d0c55413d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -94,21 +94,21 @@ public class ItemUtil { rewardArr,String[] weightArr, Map itemMap,Map cardMap, Map equipMap,Map randomMap,float dropRatio) { for (int i = 0 ; i < sRewardGroup.getRewardMaxNum();i++){ - int itemId = 0; + int id = 0; for (int j = 0 ; j < sRewardGroup.getLoop();i++){ int index = MathUtils.randomForStrArray(weightArr); - itemId = Integer.parseInt(rewardArr[index]); - if (itemId ==Integer.parseInt(rewardArr[j])){ + id = Integer.parseInt(rewardArr[index]); + if (id ==Integer.parseInt(rewardArr[j])){ break; } } - if (0 == itemId){ + if (0 == id){ int index = MathUtils.randomForStrArray(weightArr); - itemId = Integer.parseInt(rewardArr[index]); + id = Integer.parseInt(rewardArr[index]); } - SRewardItem sRewardItem = SRewardItem.getsDropMap().get(itemId); + SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id); int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); - getMap(itemId,itemNum ,itemMap, cardMap,equipMap,randomMap,dropRatio); + getMap(sRewardItem.getItemId(),itemNum ,itemMap, cardMap,equipMap,randomMap,dropRatio); } } @@ -116,18 +116,18 @@ public class ItemUtil { Map equipMap,Map randomMap ,float dropRatio) { for (int i = 0 ; i < randomItemNum;i++){ int index = MathUtils.randomForStrArray(weightArr); - int itemId = Integer.parseInt(rewardArr[index]); - SRewardItem sRewardItem = SRewardItem.getsDropMapByItemId().get(itemId); + int id = Integer.parseInt(rewardArr[index]); + SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id); int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); - getMap(itemId,itemNum, itemMap, cardMap,equipMap,randomMap,dropRatio); + getMap(sRewardItem.getItemId(),itemNum, itemMap, cardMap,equipMap,randomMap,dropRatio); } } private static void getMap(int[] itemInfo, Map itemMap,Map cardMap,Map equipMap,Map randomMap ,float dropRatio) { - for (int itemId :itemInfo){ - SRewardItem sRewardItem = SRewardItem.getsDropMapByItemId().get(itemId); + for (int id :itemInfo){ + SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id); int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); - getMap(itemId,itemNum,itemMap, cardMap,equipMap,randomMap,dropRatio); + getMap(sRewardItem.getItemId(),itemNum,itemMap, cardMap,equipMap,randomMap,dropRatio); } } @@ -419,9 +419,9 @@ public class ItemUtil { continue; } if (rewardStr.length() == 0){ - rewardStr = new StringBuilder(String.valueOf(sRewardItem.getItemId())); + rewardStr = new StringBuilder(String.valueOf(sRewardItem.getId())); }else{ - rewardStr.append("#").append(sRewardItem.getItemId()); + rewardStr.append("#").append(sRewardItem.getId()); } if (weight.length() == 0){ weight = new StringBuilder(String.valueOf(sRewardItem.getChance())); From 8b14f4b978a74d8a05db62b8a88ea0cab5d043e9 Mon Sep 17 00:00:00 2001 From: gaojie Date: Mon, 28 Jan 2019 18:11:30 +0800 Subject: [PATCH 6/8] fix --- conf/server/RewardItemConfig.txt | 208 +++++++++--------- .../java/com/ljsd/jieling/util/ItemUtil.java | 15 +- 2 files changed, 116 insertions(+), 107 deletions(-) diff --git a/conf/server/RewardItemConfig.txt b/conf/server/RewardItemConfig.txt index f3da5f155..761740b93 100644 --- a/conf/server/RewardItemConfig.txt +++ b/conf/server/RewardItemConfig.txt @@ -1,106 +1,106 @@ Id ItemId Chance GrowChance RandomMin RandomMax int int int float int int -1 10001 100 0 1 1 -2 10002 100 0 1 1 -3 10003 100 0 1 1 -4 10004 100 0 1 1 -5 10005 100 0 1 1 -6 10006 100 0 1 1 -7 10007 100 0 1 1 -8 10008 100 0 1 1 -9 10009 100 0 1 1 -10 10010 100 0 1 1 -11 10011 100 0 1 1 -12 10012 100 0 1 1 -13 10013 100 0 1 1 -14 10014 100 0 1 1 -15 10015 100 0 1 1 -16 10016 100 0 1 1 -17 10017 100 0 1 1 -18 10018 100 0 1 1 -19 10019 100 0 1 1 -20 10020 100 0 1 1 -21 10021 100 0 1 1 -22 10022 100 0 1 1 -23 10023 100 0 1 1 -24 10024 100 0 1 1 -25 10025 100 0 1 1 -26 10026 100 0 1 1 -27 10027 100 0 1 1 -28 10028 100 0 1 1 -29 10029 100 0 1 1 -30 10030 100 0 1 1 -31 10031 100 0 1 1 -32 10032 100 0 1 1 -33 10033 100 0 1 1 -34 10034 100 0 1 1 -35 10035 100 0 1 1 -36 10036 100 0 1 1 -37 10037 100 0 1 1 -38 10038 100 0 1 1 -39 10039 100 0 1 1 -40 10040 100 0 1 1 -41 10041 100 0 1 1 -42 10042 100 0 1 1 -43 10043 100 0 1 1 -44 10044 100 0 1 1 -45 10045 100 0 1 1 -46 10046 100 0 1 1 -47 10047 100 0 1 1 -48 10048 100 0 1 1 -49 10049 100 0 1 1 -50 10050 100 0 1 1 -51 10051 100 0 1 1 -52 10052 100 0 1 1 -101 10001 100 0 1 1 -102 10002 100 0 1 1 -103 10003 100 0 1 1 -104 10004 100 0 1 1 -105 10005 100 0 1 1 -106 10006 100 0 1 1 -107 10007 100 0 1 1 -108 10008 100 0 1 1 -109 10009 100 0 1 1 -110 10010 100 0 1 1 -111 10011 100 0 1 1 -112 10012 100 0 1 1 -113 10013 100 0 1 1 -114 10014 100 0 1 1 -115 10015 100 0 1 1 -116 10016 100 0 1 1 -117 10017 100 0 1 1 -118 10018 100 0 1 1 -119 10019 100 0 1 1 -120 10020 100 0 1 1 -121 10021 100 0 1 1 -122 10022 100 0 1 1 -123 10023 100 0 1 1 -124 10024 100 0 1 1 -125 10025 100 0 1 1 -126 10026 100 0 1 1 -127 10027 100 0 1 1 -128 10028 100 0 1 1 -129 10029 100 0 1 1 -130 10030 100 0 1 1 -131 10031 100 0 1 1 -132 10032 100 0 1 1 -133 10033 100 0 1 1 -134 10034 100 0 1 1 -135 10035 100 0 1 1 -136 10036 100 0 1 1 -137 10037 100 0 1 1 -138 10038 100 0 1 1 -139 10039 100 0 1 1 -140 10040 100 0 1 1 -141 10041 100 0 1 1 -142 10042 100 0 1 1 -143 10043 100 0 1 1 -144 10044 100 0 1 1 -145 10045 100 0 1 1 -146 10046 100 0 1 1 -147 10047 100 0 1 1 -148 10048 100 0 1 1 -149 10049 100 0 1 1 -150 10050 100 0 1 1 -151 10051 100 0 1 1 -152 10052 100 0 1 1 +1 10001 100 1 1 1 +2 10002 100 1 1 1 +3 10003 100 1 1 1 +4 10004 100 1 1 1 +5 10005 100 1 1 1 +6 10006 100 1 1 1 +7 10007 100 1 1 1 +8 10008 100 1 1 1 +9 10009 100 1 1 1 +10 10010 100 1 1 1 +11 10011 100 1 1 1 +12 10012 100 1 1 1 +13 10013 100 1 1 1 +14 10014 100 1 1 1 +15 10015 100 1 1 1 +16 10016 100 1 1 1 +17 10017 100 1 1 1 +18 10018 100 1 1 1 +19 10019 100 1 1 1 +20 10020 100 1 1 1 +21 10021 100 1 1 1 +22 10022 100 1 1 1 +23 10023 100 1 1 1 +24 10024 100 1 1 1 +25 10025 100 1 1 1 +26 10026 100 1 1 1 +27 10027 100 1 1 1 +28 10028 100 1 1 1 +29 10029 100 1 1 1 +30 10030 100 1 1 1 +31 10031 100 1 1 1 +32 10032 100 1 1 1 +33 10033 100 1 1 1 +34 10034 100 1 1 1 +35 10035 100 1 1 1 +36 10036 100 1 1 1 +37 10037 100 1 1 1 +38 10038 100 1 1 1 +39 10039 100 1 1 1 +40 10040 100 1 1 1 +41 10041 100 1 1 1 +42 10042 100 1 1 1 +43 10043 100 1 1 1 +44 10044 100 1 1 1 +45 10045 100 1 1 1 +46 10046 100 1 1 1 +47 10047 100 1 1 1 +48 10048 100 1 1 1 +49 10049 100 1 1 1 +50 10050 100 1 1 1 +51 10051 100 1 1 1 +52 10052 100 1 1 1 +101 10001 100 1 1 1 +102 10002 100 1 1 1 +103 10003 100 1 1 1 +104 10004 100 1 1 1 +105 10005 100 1 1 1 +106 10006 100 1 1 1 +107 10007 100 1 1 1 +108 10008 100 1 1 1 +109 10009 100 1 1 1 +110 10010 100 1 1 1 +111 10011 100 1 1 1 +112 10012 100 1 1 1 +113 10013 100 1 1 1 +114 10014 100 1 1 1 +115 10015 100 1 1 1 +116 10016 100 1 1 1 +117 10017 100 1 1 1 +118 10018 100 1 1 1 +119 10019 100 1 1 1 +120 10020 100 1 1 1 +121 10021 100 1 1 1 +122 10022 100 1 1 1 +123 10023 100 1 1 1 +124 10024 100 1 1 1 +125 10025 100 1 1 1 +126 10026 100 1 1 1 +127 10027 100 1 1 1 +128 10028 100 1 1 1 +129 10029 100 1 1 1 +130 10030 100 1 1 1 +131 10031 100 1 1 1 +132 10032 100 1 1 1 +133 10033 100 1 1 1 +134 10034 100 1 1 1 +135 10035 100 1 1 1 +136 10036 100 1 1 1 +137 10037 100 1 1 1 +138 10038 100 1 1 1 +139 10039 100 1 1 1 +140 10040 100 1 1 1 +141 10041 100 1 1 1 +142 10042 100 1 1 1 +143 10043 100 1 1 1 +144 10044 100 1 1 1 +145 10045 100 1 1 1 +146 10046 100 1 1 1 +147 10047 100 1 1 1 +148 10048 100 1 1 1 +149 10049 100 1 1 1 +150 10050 100 1 1 1 +151 10051 100 1 1 1 +152 10052 100 1 1 1 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index d0c55413d..b14e5c431 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -107,7 +107,7 @@ public class ItemUtil { id = Integer.parseInt(rewardArr[index]); } SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id); - int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); + int itemNum = getItemNum(sRewardItem); getMap(sRewardItem.getItemId(),itemNum ,itemMap, cardMap,equipMap,randomMap,dropRatio); } } @@ -118,15 +118,24 @@ public class ItemUtil { int index = MathUtils.randomForStrArray(weightArr); int id = Integer.parseInt(rewardArr[index]); SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id); - int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); + int itemNum = getItemNum(sRewardItem); getMap(sRewardItem.getItemId(),itemNum, itemMap, cardMap,equipMap,randomMap,dropRatio); } } + /** + * 成长百分比 + * @param sRewardItem + * @return + */ + private static int getItemNum(SRewardItem sRewardItem) { + return MathUtils.numRount(MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()) * sRewardItem.getGrowChance()); + } + private static void getMap(int[] itemInfo, Map itemMap,Map cardMap,Map equipMap,Map randomMap ,float dropRatio) { for (int id :itemInfo){ SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id); - int itemNum = MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()); + int itemNum = getItemNum(sRewardItem); getMap(sRewardItem.getItemId(),itemNum,itemMap, cardMap,equipMap,randomMap,dropRatio); } } From 41a27bb260666c8d0f23959713c018247fedf2a1 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 28 Jan 2019 18:20:36 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E6=88=98=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/core/GlobalsDef.java | 4 ++ .../com/ljsd/jieling/logic/dao/Equip.java | 10 ++++- .../ljsd/jieling/logic/hero/HeroLogic.java | 37 +++++++++++++++---- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java index 9c8281c33..0f3cea282 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/core/GlobalsDef.java @@ -17,4 +17,8 @@ public interface GlobalsDef { int RANKUP_PARA_TYPE =1; int BREAK_PARA_TYPE =2; + // 属性加成类型 + int ABSOLUTE_TYPE =1; // 绝对值 + int PERCENT_TYPE =2; // 百分比 + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Equip.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Equip.java index cefb8a5cb..de57e1ef8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Equip.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Equip.java @@ -52,7 +52,7 @@ public class Equip extends MongoBase { this.secondValueByIdMap = getSecondValue(sEquipConfig.getPool(),secondValue); } - public Map getSecondValue(int poolId,int nums){ + private Map getSecondValue(int poolId,int nums){ Map result = new HashMap<>(); List sEquipPropertyPoolList = SEquipPropertyPool.getSEquipPropertyPool(poolId); int totalWeight = 0; @@ -114,4 +114,12 @@ public class Equip extends MongoBase { updateString("heroId",heroId); this.heroId = heroId; } + + public Map getPropertyValueByIdMap() { + return propertyValueByIdMap; + } + + public Map getSecondValueByIdMap() { + return secondValueByIdMap; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index e1d18235f..a018b89d5 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -3,6 +3,7 @@ package com.ljsd.jieling.logic.hero; import com.ljsd.GameApplication; import com.ljsd.jieling.config.*; import com.ljsd.jieling.core.GlobalsDef; +import com.ljsd.jieling.globals.Global; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.CommonProto; @@ -448,20 +449,42 @@ public class HeroLogic { } - //todo 计算英雄战斗力 战斗力 = 生命*0.7 + (护甲 + 魔坑)*5 + 攻击 *10 + (暴击率 + 效果命中率 + 效果抵抗率 )*5 +(属性攻击率 + 属性防御率)*30 public int calHeoForce(User user, Hero hero){ Map heroAllAttribute = calHeroAllAttribute(hero); - double heroBaseForce = heroAllAttribute.get(GlobalsDef.HP_TYPE) * 0.7 + (heroAllAttribute.get(GlobalsDef.PHYSICAL_DEFENCE_TYPE) + heroAllAttribute.get(GlobalsDef.MAGIC_DEFENCE_TYPE)) * 5 + heroAllAttribute.get(GlobalsDef.ATTACK_TYPE) * 10; - //todo 计算装备加成 Collection values = hero.getEquipByPositionMap().values(); EquipManager equipManager = user.getEquipManager(); for(String equipId:values){ Equip equip = equipManager.getEquipMap().get(equipId); - + Map propertyValueByIdMap = equip.getPropertyValueByIdMap(); + Map secondValueByIdMap = equip.getSecondValueByIdMap(); + combinedAttribute(propertyValueByIdMap,heroAllAttribute); + combinedAttribute(secondValueByIdMap,heroAllAttribute); + } + double result = 0; + for(Map.Entry item : heroAllAttribute.entrySet()){ + Integer propertyId = item.getKey(); + Integer propertyValue = item.getValue(); + SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(propertyId); + int style = sPropertyConfig.getStyle(); + float score = sPropertyConfig.getScore(); + if(style == GlobalsDef.PERCENT_TYPE){ + score = score/100; + } + result += propertyValue*score; + } + + return (int)result; + } + + private void combinedAttribute(Map otherAttriMaop,Map heroAttributeMap){ + for(Map.Entry item : otherAttriMaop.entrySet()){ + Integer propertyId = item.getKey(); + Integer propertyValue = item.getValue(); + if(heroAttributeMap.containsKey(propertyId)){ + propertyValue = heroAttributeMap.get(propertyId); + } + heroAttributeMap.put(propertyId,propertyValue); } - float equipAddForce =0.0f; - int result = (int) (heroBaseForce + equipAddForce); - return result; } From 741fa5d97db825b736398520d57f0f74c92bf9dd Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 28 Jan 2019 18:26:31 +0800 Subject: [PATCH 8/8] fix --- .../src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index d9e704182..a59636d75 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -413,7 +413,7 @@ public class HeroLogic { int heroLevel = hero.getLevel(); Map scHeroRankUpConfigByTypOfBreak = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE,scHero.getStar()); for( SCHeroRankUpConfig scHeroRankUpConfigTmp :scHeroRankUpConfigByTypOfBreak.values()){ - if( heroLevel >= scHeroRankUpConfigTmp.getLimitLevel() ){ + if( heroLevel >= scHeroRankUpConfigTmp.getLimitLevel() && hero.getBreakId()>= scHeroRankUpConfigTmp.getId()){ breakPara = scHeroRankUpConfigTmp.getRankupPara(); } if(heroLevel <= scHeroRankUpConfigTmp.getOpenLevel()){