一键助阵

master_xiyou
grimm 2024-07-29 18:28:31 +08:00
parent 5096e75c4a
commit 31ae65a99c
1 changed files with 34 additions and 47 deletions

View File

@ -132,59 +132,46 @@ public class AssistLogic {
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);
}
for (AssistBox box : assistBoxMap.values()) {
box.setHeroId("");
}
// 卸下
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);
// int operate = proto.getOperate();
List<CommonProto.AssistBox> boxsList = proto.getBoxsList();
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);
}
heroManager.setAssistBoxMap(assistBoxMap);
// 更新战力
Poster.getPoster().dispatchEvent(new SaveHeroForceEvent(user.getId(),""));
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.AssistUpDownResponse_VALUE, null, true);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.AssistBatchUpDownResponse_VALUE, null, true);
}
/**