back_recharge
mengchengzhen 2021-06-23 18:54:37 +08:00
parent a7ffcb435b
commit 966351e03c
3 changed files with 41 additions and 0 deletions

View File

@ -323,6 +323,8 @@ public class RedisKey {
//跨服机器人信息
public static final String CROSS_ARENA_ROBOT_INFO = "CROSS_ARENA_ROBOT_INFO";
public static final String WORLD_ARENA_RANK_MY_MATH = "WORLD_ARENA_RANK_MY_MATH";//我匹配到的数据
public static Set<String> familyKey = new HashSet<>();

View File

@ -212,6 +212,14 @@ public class RedisUtil {
return gson.fromJson(source,clazz);
}
public <T> T getObject(String key,java.lang.reflect.Type type){
String source = redisTemplate.opsForValue().get(key);
if(source == null){
return null;
}
return gson.fromJson(source,type);
}
/**
* Object
*

View File

@ -818,5 +818,36 @@ public class ArenaLogic {
return objects;
}
/**
*
*/
public static List<CrossArenaEnemy> randomRank(HashMap<Integer, CrossArenaEnemy> integerIntegerHashMap, int uid, int myRank) {
//缓存每次匹配结果
Set<Integer> hisRank = RedisUtil.getInstence().getObject(
RedisUtil.getInstence().getKey(RedisKey.WORLD_ARENA_RANK_MY_MATH, String.valueOf(uid))
, new TypeToken<Set<Integer>>() {}.getType());
List<CrossArenaEnemy> arenaEnemies = new ArrayList<>();
TreeSet<Integer> matchRank;
if (hisRank == null || hisRank.size() == 0) {
//获取匹配对手
matchRank = getMatchID(myRank==9999?1000:myRank);
} else {
matchRank = new TreeSet<>(hisRank);
}
matchRank.forEach(rank -> {
if (!integerIntegerHashMap.containsKey(rank)) {
return;
}
CrossArenaEnemy matchInfo = integerIntegerHashMap.get(rank);
matchInfo.setRank(rank);
arenaEnemies.add(matchInfo);
// matchRank.add(rank);
});
RedisUtil.getInstence().set(RedisKey.WORLD_ARENA_RANK_MY_MATH, String.valueOf(uid), matchRank);
return arenaEnemies;
}
}