From ec22c8f1286828831fb0ed41327d5d61a10851e0 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Fri, 9 Jul 2021 16:41:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0=E5=B0=BD=E5=89=AF=E6=9C=AC=E5=9B=9E?= =?UTF-8?q?=E8=A1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ljsd/jieling/handler/map/MapLogic.java | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index f43a61675..7f9dd0410 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -2583,34 +2583,46 @@ public class MapLogic { public void useAddHp(ISession session, String heroId, MessageTypeProto.MessageType messageType) throws Exception { User user =UserManager.getUser( session.getUid()); MapManager mapManager = user.getMapManager(); - TrialInfo trialInfo = mapManager.getTrialInfo(); - Map heroInfo = trialInfo.getHeroInfo(); - if(mapManager.getCurMapId()==0){ - throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); - } - if(heroInfo.size()<1||!heroInfo.containsKey(heroId)){ - throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); - } - int[] healing = STrialSetting.sTrialSetting.getHealingId(); - if(trialInfo.getAddHpCount()>=healing[1]){ - throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); - } - Map propertyMap = heroInfo.get(heroId).getProperty(); - long curHp = propertyMap.get(HeroAttributeEnum.CurHP.getPropertyId()); - if(curHp==0){ - throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + //如果是-1则是无尽副本的加血 + if(!heroId.equals("-1")){ + TrialInfo trialInfo = mapManager.getTrialInfo(); + Map heroInfo = trialInfo.getHeroInfo(); + if(mapManager.getCurMapId()==0){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + if(heroInfo.size()<1||!heroInfo.containsKey(heroId)){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + int[] healing = STrialSetting.sTrialSetting.getHealingId(); + if(trialInfo.getAddHpCount()>=healing[1]){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + Map propertyMap = heroInfo.get(heroId).getProperty(); + long curHp = propertyMap.get(HeroAttributeEnum.CurHP.getPropertyId()); + if(curHp==0){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + }else{ + boolean itemCost = ItemUtil.itemCost(user, new int[][]{{healing[0],1}}, BIReason.TRIAL_ADD_HP_CONSUME, 1); + if(!itemCost){ + throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); + } + //todo 加血逻辑 + long maxHp = propertyMap.get(HeroAttributeEnum.Hp.getPropertyId()); + long resultHp = Math.min(curHp+maxHp/2,maxHp); + propertyMap.put(HeroAttributeEnum.CurHP.getPropertyId(),resultHp); + trialInfo.getHeroInfo().get(heroId).setProperty(propertyMap); + mapManager.updateTrialAddHpCount(1); + mapManager.updateTrailHeroInfo(heroInfo); + } }else{ - boolean itemCost = ItemUtil.itemCost(user, new int[][]{{healing[0],1}}, BIReason.TRIAL_ADD_HP_CONSUME, 1); - if(!itemCost){ + boolean itemCost = ItemUtil.itemCost(user, new int[][]{{1227, 1}}, BIReason.TRIAL_ADD_HP_CONSUME, 1); + if(itemCost){ throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); } - //todo 加血逻辑 - long maxHp = propertyMap.get(HeroAttributeEnum.Hp.getPropertyId()); - long resultHp = Math.min(curHp+maxHp/2,maxHp); - propertyMap.put(HeroAttributeEnum.CurHP.getPropertyId(),resultHp); - trialInfo.getHeroInfo().get(heroId).setProperty(propertyMap); - mapManager.updateTrialAddHpCount(1); - mapManager.updateTrailHeroInfo(heroInfo); + EndlessMapInfo endlessMapInfo = mapManager.getEndlessMapInfo(); + Map endlessHeroInfo = endlessMapInfo.getEndlessHeroInfo(); + Set hero = endlessHeroInfo.keySet(); + hero.forEach(n->mapManager.updateEndlessHeroHp(n,10000)); } MessageUtil.sendMessage(session,1,messageType.getNumber(),null); }