新增助阵一键上阵功能

master_zzxx
grimm 2024-07-19 15:23:38 +08:00
parent bea00e3ecd
commit 95c68865d4
2 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.ljsd.jieling.handler.assist;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.hero.AssistLogic;
import com.ljsd.jieling.network.session.ISession;
import org.springframework.stereotype.Component;
import rpc.protocols.HeroInfoProto;
import rpc.protocols.MessageTypeProto;
/**
* @author hj
*
*/
@Component
public class AssistBatchUpDownHandler extends BaseHandler<HeroInfoProto.AssistBatchUpDownRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.AssistBatchUpDownRequest;
}
@Override
public void processWithProto(ISession iSession, HeroInfoProto.AssistBatchUpDownRequest proto) throws Exception {
AssistLogic.getInstance().assistBatchUpDown(iSession, proto);
}
}

View File

@ -122,6 +122,71 @@ public class AssistLogic {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.AssistUpDownResponse_VALUE, null, true);
}
/**
*
* @param iSession
* @param proto
* @throws Exception
*/
public void assistBatchUpDown(ISession iSession, HeroInfoProto.AssistBatchUpDownRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
HeroManager heroManager = user.getHeroManager();
Map<Integer, AssistBox> assistBoxMap = heroManager.getAssistBoxMap();
int operate = proto.getOperate();
List<CommonProto.AssistBox> boxsList = proto.getBoxsList();
// 穿戴
if (operate == 1){
for (CommonProto.AssistBox box : boxsList) {
int id = box.getId();
String heroId = box.getHeroId();
AssistBox assistBox = assistBoxMap.get(id);
if (assistBox == null || assistBox.getState() == 0){
throw new ErrorTableException(162);//格子未开启
}
if (heroManager.getAssistHeroIds().containsKey(heroId)){
throw new ErrorTableException(163);//英雄已助阵
}
if (!StringUtil.isEmpty(assistBox.getHeroId())){
throw new ErrorTableException(164);//格子有助阵
}
Hero hero = heroManager.getHero(heroId);
if (hero == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);//配置不存在
}
SCHero scHero = SCHero.getSCHero(hero.getTemplateId());
if (scHero == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);//配置不存在
}
SAssistanceConfig assistanceConfig = SAssistanceConfig.map.get(id);
if (assistanceConfig == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL);//配置不存在
}
if (scHero.getPropertyName() != assistanceConfig.getProfessionLimit() || scHero.getNatural() != assistanceConfig.getQuality()){
throw new ErrorTableException(167);//条件不满足
}
assistBox.setHeroId(heroId);
assistBoxMap.put(id, assistBox);
}
}
// 卸下
else {
for (CommonProto.AssistBox box : boxsList) {
int id = box.getId();
AssistBox assistBox = assistBoxMap.get(id);
if (assistBox == null || assistBox.getState() == 0){
throw new ErrorTableException(162);//格子未开启
}
assistBox.setHeroId("");
assistBoxMap.put(id, assistBox);
}
}
heroManager.setAssistBoxMap(assistBoxMap);
// 更新战力
Poster.getPoster().dispatchEvent(new SaveHeroForceEvent(user.getId(),""));
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.AssistUpDownResponse_VALUE, null, true);
}
/**
*
*/