无尽副本回血
parent
391c7f3cbe
commit
ec22c8f128
|
@ -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<String, TrailHero> 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<Integer, Long> 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<String, TrailHero> 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<Integer, Long> 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<String, Integer> endlessHeroInfo = endlessMapInfo.getEndlessHeroInfo();
|
||||
Set<String> hero = endlessHeroInfo.keySet();
|
||||
hero.forEach(n->mapManager.updateEndlessHeroHp(n,10000));
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue