From c015b1ea18845da4200d1f81121ac415afaf0da3 Mon Sep 17 00:00:00 2001 From: zhangshanxue Date: Thu, 11 Jun 2020 10:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=AE=A1=E7=AE=97=20?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E5=B1=9E=E6=80=A7=E4=B9=9F=E6=98=AF=E4=B8=87?= =?UTF-8?q?=E5=88=86=E6=AF=94=E8=AE=A1=E7=AE=97=20=EF=BC=88bug=E5=A4=9A?= =?UTF-8?q?=E4=BA=86=E4=B8=87=E5=88=86=E6=AF=94=E5=8A=A0=E6=88=90=E4=BA=8E?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E4=B8=AA=E4=B8=80=E7=BA=A7=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=20=E5=8F=AA=E4=BC=9A=E6=9C=89=E4=B8=80=E4=B8=AA=E7=94=9F?= =?UTF-8?q?=E6=95=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/logic/hero/HeroLogic.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) 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 2c462a6d0..7521afaea 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 @@ -1543,11 +1543,13 @@ public class HeroLogic{ /** * 属性数值计算 - * @param heroAllAttribute + * 先计算一级属性 + *绝对值直接加 百分比统一之后加 */ public void calInteractAdd(Map heroAllAttribute){ Map propertyPercentMap = new HashMap<>(); Iterator> iterator = heroAllAttribute.entrySet().iterator(); + Map newAddAttribute = new HashMap<>(); while (iterator.hasNext()){ Map.Entry item = iterator.next(); Integer propertyId = item.getKey(); @@ -1559,23 +1561,37 @@ public class HeroLogic{ if(targetPropertyId == 0){ continue; } + SPropertyConfig stargetPro = SPropertyConfig.getsPropertyConfigByPID(targetPropertyId); + if(stargetPro==null){ + continue; + } int style = sPropertyConfig.getStyle(); Integer effectValue = item.getValue(); - Integer targetValue = heroAllAttribute.get(targetPropertyId); - if(style == GlobalsDef.ABSOLUTE_TYPE){ - effectValue += targetValue; - heroAllAttribute.put(targetPropertyId,effectValue); + + //如果目标属性也是万分比 直接加 + if(style == GlobalsDef.ABSOLUTE_TYPE||stargetPro.getStyle()==GlobalsDef.PERCENT_TYPE){ + if(heroAllAttribute.containsKey(targetPropertyId)){ + Integer targetValue = heroAllAttribute.getOrDefault(targetPropertyId,0); + effectValue += targetValue; + heroAllAttribute.put(targetPropertyId,effectValue); + }else { + newAddAttribute.merge(targetPropertyId,effectValue,(a, b) -> a+b); + } }else{ propertyPercentMap.put(targetPropertyId,effectValue); } iterator.remove(); } + heroAllAttribute.putAll(newAddAttribute); + for(Map.Entry item : propertyPercentMap.entrySet()){ Integer propertyId = item.getKey(); - Integer propertyValue = heroAllAttribute.get(propertyId); + Integer propertyValue = heroAllAttribute.getOrDefault(propertyId,0); heroAllAttribute.put(propertyId,BigDecimal.valueOf(propertyValue).multiply(BigDecimal.valueOf(item.getValue()).divide(BigDecimal.valueOf(10000f))).intValue()+propertyValue); } + + Integer maxHp = heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId()); Integer curHp = heroAllAttribute.get(HeroAttributeEnum.CurHP.getPropertyId()); if(maxHp!=null && curHp!=null && curHp > maxHp){