助战bug修改

back_recharge
duhui 2021-09-03 14:55:04 +08:00
parent 79936df349
commit d1815b4e8c
3 changed files with 15 additions and 14 deletions

View File

@ -14,6 +14,7 @@ import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import java.util.List;
import java.util.Set;
/**
* @author hj
@ -38,7 +39,7 @@ public class GetHelpHeroListHandler extends BaseHandler<PlayerInfoProto.GetHelpH
// 根据类型获取枚举对象
HelpTypeEnum type = HelpTypeEnum.getType(proto.getType());
List<CommonProto.HelpFightList> helpFightList = HelpHeroLogic.getInstance().getHelpFightList(user, type);
Set<CommonProto.HelpFightList> helpFightList = HelpHeroLogic.getInstance().getHelpFightList(user, type);
return PlayerInfoProto.GetHelpHeroListResponse.newBuilder().addAllHelpHeros(helpFightList).build();
}

View File

@ -67,9 +67,9 @@ public class HelpHeroLogic {
* @param typeEnum
* @return
*/
public List<CommonProto.HelpFightList> getHelpFightList(User user,HelpTypeEnum typeEnum) throws Exception{
public Set<CommonProto.HelpFightList> getHelpFightList(User user,HelpTypeEnum typeEnum) throws Exception{
List<CommonProto.HelpFightList> result = new ArrayList<>();
HashSet<CommonProto.HelpFightList> result = new HashSet<>();
// 如果类型是自己则使用uid
String subKey = typeEnum==Me?getSubKey(user.getId(),MY):String.valueOf(typeEnum.getPropertyId());
@ -130,6 +130,11 @@ public class HelpHeroLogic {
}
}
}
// 已选中的助战
HelpHero helpHero = getHelpHeroByType(user.getId(), typeEnum.getPropertyId());
if (helpHero != null){
result.add(CBean2Proto.helpHeroProto(helpHero));
}
break;
default:
return result;

View File

@ -225,21 +225,16 @@ public class CBean2Proto {
* @return
* @throws Exception
*/
public static List<CommonProto.HelpFightList> getHelpFightList(User user){
public static List<CommonProto.HelpFightList> getHelpFightList(User user) throws Exception {
List<CommonProto.HelpFightList> lists = new ArrayList<>();
// 助战英雄列表
Map<String, HelpHero> helpHeros = HelpHeroLogic.getHelpHeroMap(user.getId());
if (helpHeros == null || helpHeros.isEmpty()){
Map<String, HelpHero> helpHeroMap = HelpHeroLogic.getHelpHeroMap(user.getId());
if (helpHeroMap == null || helpHeroMap.isEmpty()){
return lists;
}
helpHeros.values().forEach(v-> {
try {
lists.add(helpHeroProto(v));
} catch (Exception e) {
LOGGER.error("助战英雄转换类型时报错:{}",e.getMessage());
}
});
for (HelpHero hero : helpHeroMap.values()) {
lists.add(helpHeroProto(hero));
}
return lists;
}