战力排名

back_recharge
wangyuan 2019-12-27 15:17:20 +08:00
parent 176827eec6
commit f1cbb7b63e
1 changed files with 24 additions and 7 deletions

View File

@ -118,12 +118,7 @@ public class ChampionshipLogic {
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.CHAMPION_VIEW_FINAL_RESPONSE_VALUE,builder.build(),true);
}
public static String getRoleNameById(int uid,Map<Integer,SArenaRobotConfig> config ) throws Exception {
if(config.containsKey(uid)){
return config.get(uid).getRobotName();
}
return UserManager.getUser(uid).getPlayerInfoManager().getNickName();
}
public static class MemberInfo{
@ -625,7 +620,12 @@ public class ChampionshipLogic {
//这里将map.entrySet()转换成list
List<Map.Entry<Integer,Integer>> list = new ArrayList<Map.Entry<Integer,Integer>>(uidRankMap.entrySet());
//然后通过比较器来实现排序
Collections.sort(list, (o1,o2)-> o2.getValue().compareTo(o1.getValue()));
Collections.sort(list, (o1,o2)-> {
if( o2.getValue()==(o1.getValue())){
return getMaxForce(o2.getValue()) - getMaxForce(o1.getValue());
}
return o2.getValue().compareTo(o1.getValue());
});
int rank=1;
for(Map.Entry<Integer,Integer> mapping:list){
@ -1149,6 +1149,20 @@ public class ChampionshipLogic {
return RedisUtil.getInstence().get(key).toString();
}
private static int getMaxForce(int uid) {
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(uid);
if(sArenaRobotConfig!=null){
return sArenaRobotConfig.getTotalForce();
}
try {
return UserManager.getUser(uid).getPlayerInfoManager().getMaxForce();
} catch (Exception e) {
LOGGER.error("",e);
return 0;
}
}
/**
* n,100
*
@ -1164,6 +1178,9 @@ public class ChampionshipLogic {
Collections.sort(memberOfOneTeam, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
if( joinMembers.get(o2).getScore() == joinMembers.get(o1).getScore()){
return getMaxForce(o2) - getMaxForce(o1);
}
return joinMembers.get(o2).getScore() -joinMembers.get(o1).getScore();
}
});