新增助阵一键上阵功能
parent
bea00e3ecd
commit
95c68865d4
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除英雄刷新助阵
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue