第一版

back_recharge
duhui 2021-09-10 15:57:48 +08:00
parent e819858d77
commit 393635b930
19 changed files with 1148 additions and 1159 deletions

View File

@ -419,17 +419,11 @@ public class AreaManager {
} }
public int getServerIdByUid(int uid, int defaultServerId) { public int getServerIdByUid(int uid, int defaultServerId) {
int serverId = defaultServerId; Integer serverIdByUid = RedisUtil.getInstence().getMapEntry(RedisKey.CUser_ServerId_Key,"",Integer.toString(uid),Integer.class);
Integer serverIdByUid = RedisUtil.getInstence().getMapEntry(RedisKey.CUser_ServerId_Key, "", Integer.toString(uid), if (serverIdByUid == null){
Integer.class); RedisUtil.getInstence().putMapEntry(RedisKey.CUser_ServerId_Key, "", Integer.toString(uid), defaultServerId);
// serverIdByUid = MongoUtil.getInstence().findCUserServerId(uid); serverIdByUid = defaultServerId;
if (serverIdByUid != null) {
serverId = serverIdByUid;
RedisUtil.getInstence().putMapEntry(RedisKey.CUser_ServerId_Key, "", Integer.toString(uid),
serverId);
} else {
return GameApplication.serverId;
} }
return serverId; return serverIdByUid;
} }
} }

View File

@ -188,20 +188,22 @@ public class RedisKey {
public static final String SESSION_OFFLINE = "SESSION_OFFLINE"; public static final String SESSION_OFFLINE = "SESSION_OFFLINE";
// 十绝阵rediskey
public static final String DEATH_PATH_EVERY_PERSON_RANK = "DEATH_PATH_EVERY_PERSON_RANK"; public static final String DEATH_PATH_EVERY_PERSON_RANK = "DEATH_PATH_EVERY_PERSON_RANK";
public static final String DEATH_PATH_EVERY_GUILD_RANK = "DEATH_PATH_EVERY_GUILD_RANK"; public static final String DEATH_PATH_EVERY_GUILD_RANK = "DEATH_PATH_EVERY_GUILD_RANK";
// 十绝阵单人挑战次数
public static final String DEATH_PATH_CHALLENGE_COUNT = "DEATH_PATH_CHALLENGE_COUNT"; public static final String DEATH_PATH_CHALLENGE_COUNT = "DEATH_PATH_CHALLENGE_COUNT";
public static final String DEATH_PATH_TOTAL_PERSON_RANK = "DEATH_PATH_TOTAL_PERSON_RANK"; public static final String DEATH_PATH_TOTAL_PERSON_RANK = "DEATH_PATH_TOTAL_PERSON_RANK";
public static final String DEATH_PATH_TOTAL_GUILD_RANK = "DEATH_PATH_TOTAL_GUILD_RANK"; public static final String DEATH_PATH_TOTAL_GUILD_RANK = "DEATH_PATH_TOTAL_GUILD_RANK";
// 结算标识
public static final String DEATH_PATH_EVERY_OVER_HASH = "DEATH_PATH_EVERY_OVER_HASH";//结算标识 public static final String DEATH_PATH_EVERY_OVER_HASH = "DEATH_PATH_EVERY_OVER_HASH";
// 十绝阵挑战第一名推送
// 死亡之旅挑战第一名推送
public static final String DEATH_PATH_CHALLENGE_FIRST_PUSH = "DEATH_PATH_CHALLENGE_FIRST_PUSH"; public static final String DEATH_PATH_CHALLENGE_FIRST_PUSH = "DEATH_PATH_CHALLENGE_FIRST_PUSH";
// 十绝阵挑战人数
public static final String DEATH_PATH_TOTAL_CHALLENGE_COUNT = "DEATH_PATH_TOTAL_CHALLENGE_COUNT";
//问卷调查 //问卷调查
public static final String QUESTION_FROMBACK = "QUESTION_FROMBACK"; public static final String QUESTION_FROMBACK = "QUESTION_FROMBACK";
@ -257,9 +259,6 @@ public class RedisKey {
public static final String HARD_STAGE_PASS_MIN_FORCE = "HARD_STAGE_PASS_MIN_FORCE"; public static final String HARD_STAGE_PASS_MIN_FORCE = "HARD_STAGE_PASS_MIN_FORCE";
public static final String TA_SUI_LING_XIAO_RANK = "TA_SUI_LING_XIAO_RANK"; public static final String TA_SUI_LING_XIAO_RANK = "TA_SUI_LING_XIAO_RANK";
public static final String DEATH_PATH_TOTAL_CHALLENGE_COUNT = "DEATH_PATH_TOTAL_CHALLENGE_COUNT";
public final static String CAR_CHALLENGE_RECORD = "CAR_CHALLENGE_RECORD"; //车迟玩法挑战记录 public final static String CAR_CHALLENGE_RECORD = "CAR_CHALLENGE_RECORD"; //车迟玩法挑战记录
public final static String USER_LEVEL_GUILD_INFO = "USER_LEVEL_GUILD_INFO"; //车迟玩法挑战记录 public final static String USER_LEVEL_GUILD_INFO = "USER_LEVEL_GUILD_INFO"; //车迟玩法挑战记录
@ -367,16 +366,20 @@ public class RedisKey {
* *
* *
* *
* key:id:HELP_FIGHT:MY:id * key: id:HELP_FIGHT:MY:id
* valuemap * valuemap
* *
* key:id:HELP_FIGHT:CHOOSE:id * key: id:HELP_FIGHT:CHOOSE:id
* valuemap * valuemap
* *
* key:id:HELP_FIGHT: * key: id:HELP_FIGHT:
* valuemapid * valuemapid
*/ */
public final static String HELP_FIGHT = "HELP_FIGHT"; public final static String HELP_FIGHT = "HELP_FIGHT";
/**
* key
*/
public final static String HELP_FIGHT_DELETE = "HELP_FIGHT_DELETE";
public static Set<String> familyKey = new HashSet<>(); public static Set<String> familyKey = new HashSet<>();
@ -420,7 +423,6 @@ public class RedisKey {
rankCacChe.add(SITUATION_RANK); rankCacChe.add(SITUATION_RANK);
rankCacChe.add(FOUR_CHALLENGE_TIER_RANK); rankCacChe.add(FOUR_CHALLENGE_TIER_RANK);
rankCacChe.add(HELP_FIGHT);
} }
static { static {
@ -448,31 +450,7 @@ public class RedisKey {
// familyKey.add(FAMILY_FIGHT_FINISH_MATCHING); // familyKey.add(FAMILY_FIGHT_FINISH_MATCHING);
} }
public static String getKey(String type, String key, boolean withoutServerId){ public static String getKey(String type, String key, boolean withoutServerId){
if(RedisKey.TOKEN.equals(type)||RedisKey.USER_SERVER_INFO.equals(type)||RedisKey.SERVER_WORLDLEVE_INFO.equals(type)){ return RedisUtil.getInstence().getKey(type,key);
return type + RedisKey.Delimiter_colon + key;
}
if(familyKey.contains(type)){
return type + RedisKey.Delimiter_colon+key;
}
if(!newAreaCacChe.contains(type)&&!rankCacChe.contains(type)){
if(key.length() == 8) {
Integer serverId = RedisUtil.getInstence().getMapEntry(RedisKey.CUser_ServerId_Key, "", key,
Integer.class);
if( serverId!=null && !AreaManager.getInstance().checkServerIdAllowPermit(serverId)){
return -1 + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
}
return serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
// }
}
}
// if (rankCacChe.contains(type)||withoutServerId) {
return AreaManager.areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
// } else {
// return GameApplication.serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
// }
} }
} }

View File

@ -24,6 +24,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@SuppressWarnings("ALL")
public class RedisUtil { public class RedisUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(RedisUtil.class); private static final Logger LOGGER = LoggerFactory.getLogger(RedisUtil.class);
@ -1342,38 +1343,58 @@ public class RedisUtil {
* @return * @return
*/ */
public String getKey(String type,String key,boolean judge){ public String getKey(String type,String key,boolean judge){
if (!judge){ String result = null;
return type + RedisKey.Delimiter_colon + key; if (!judge) {
result = type + RedisKey.Delimiter_colon + key;
} }
else if (
if(RedisKey.PLAYER_INFO_CACHE.equals(type) ||RedisKey.FAMILY_INFO.equals(type)|| RedisKey.PLAYER_INFO_CACHE.equals(type) || RedisKey.FAMILY_INFO.equals(type) ||
RedisKey.PIDGIDTEMP.equals(type)||RedisKey.SERVER_WORLDLEVE_INFO.equals(type)|| RedisKey.PIDGIDTEMP.equals(type) || RedisKey.SERVER_WORLDLEVE_INFO.equals(type) ||
RedisKey.GUILD_INFO_CACHE.equals(type)||RedisKey.SERVER_SPLIT_INFO.equals(type)|| RedisKey.GUILD_INFO_CACHE.equals(type) || RedisKey.SERVER_SPLIT_INFO.equals(type) ||
RedisKey.SERVER_SPLIT_MAIL_INFO.equals(type)||RedisKey.CROSS_ARENA_ROBOT_INFO.equals(type)|| RedisKey.SERVER_SPLIT_MAIL_INFO.equals(type) || RedisKey.CROSS_ARENA_ROBOT_INFO.equals(type) ||
RedisKey.CROSS_SERVICE_ARENA.equals(type)||RedisKey.WORLD_ARENA_RANK_MY_MATH.equals(type)|| RedisKey.CROSS_SERVICE_ARENA.equals(type) || RedisKey.WORLD_ARENA_RANK_MY_MATH.equals(type) ||
RedisKey.WORLD_ARENA_MY_PRON.equals(type)||RedisKey.WORLD_ARENA_RRECORD.equals(type)) { RedisKey.WORLD_ARENA_MY_PRON.equals(type) || RedisKey.WORLD_ARENA_RRECORD.equals(type) ||
return type + RedisKey.Delimiter_colon + key; RedisKey.TOKEN.equals(type) || RedisKey.USER_SERVER_INFO.equals(type) ||
RedisKey.CDKEY.equals(type) || RedisKey.ServerArenaJob.equals(type)
) {
result = type + RedisKey.Delimiter_colon + key;
} }
else if (!RedisKey.newAreaCacChe.contains(type) && !RedisKey.rankCacChe.contains(type)) {
if(RedisKey.TOKEN.equals(type)||RedisKey.USER_SERVER_INFO.equals(type)|| if (key.length() == 8) {
RedisKey.CDKEY.equals(type)||RedisKey.ServerArenaJob.equals(type)){ Integer serverId = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, key, Integer.class, -1);
return type + RedisKey.Delimiter_colon + key; if (serverId != null && !AreaManager.getInstance().checkServerIdAllowPermit(serverId)) {
} result = -1 + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
}
if(!RedisKey.newAreaCacChe.contains(type)&&!RedisKey.rankCacChe.contains(type)){ else if (serverId != null){
if(key.length() == 8) { result = serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
Integer serverId = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key,key,
Integer.class, -1);
if(serverId!=null && !AreaManager.getInstance().checkServerIdAllowPermit(serverId)){
return -1 + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
} }
return serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
} }
} }
if (result == null){
result = AreaManager.areaId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
}
return AreaManager.areaId+ RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key; helpHeroKeyHandler(result);
return result;
} }
/**
* rediskey
*/
private void deathPathKeyHandler(String key){
if(key.contains(RedisKey.HELP_FIGHT)){
RedisUtil.getInstence().sSet(RedisKey.HELP_FIGHT_DELETE,key);
}
}
/**
* rediskey
*/
private void helpHeroKeyHandler(String key){
if(key.contains(RedisKey.HELP_FIGHT)){
RedisUtil.getInstence().sSet(RedisKey.HELP_FIGHT_DELETE,key);
}
}
private static final String LOCK_SUCCESS = "OK"; private static final String LOCK_SUCCESS = "OK";
private static final byte[] SET_IF_NOT_EXIST = "NX".getBytes(); private static final byte[] SET_IF_NOT_EXIST = "NX".getBytes();

View File

@ -247,7 +247,7 @@ public class BehaviorUtil {
if (hero == null) { if (hero == null) {
// 四灵试炼,助战 // 四灵试炼,助战
if (FourChallengeLogic.isFourChallengeTeam(teamId)){ if (FourChallengeLogic.isFourChallengeTeam(teamId)){
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), teamPosHeroInfo.getHeroId()); HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), teamPosHeroInfo.getHeroId());
if (helpHero == null){ if (helpHero == null){
continue; continue;
} }

View File

@ -187,7 +187,7 @@ public class FourChallengeLogic {
for (TeamPosHeroInfo info : teamPosHeroInfos) { for (TeamPosHeroInfo info : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(info.getHeroId()); Hero hero = user.getHeroManager().getHero(info.getHeroId());
if (hero == null){ if (hero == null){
helpHero = HelpHeroLogic.getHelpHero(user.getId(), info.getHeroId()); helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), info.getHeroId());
if (helpHero == null){ if (helpHero == null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队英雄不存在"); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队英雄不存在");
} }
@ -229,7 +229,9 @@ public class FourChallengeLogic {
if (help == 1){ if (help == 1){
// 助战英雄使用状态修改 // 助战英雄使用状态修改
helpHero.setState(1); helpHero.setState(1);
HelpHeroLogic.addHelpHero(user.getId(),campId,helpHero); // redis存储
String subKey = HelpHeroLogic.subKey(user.getId(), HelpHeroLogic.CHOOSE);
HelpHeroLogic.addHelpHero(subKey,campId,helpHero);
// 发送奖励 // 发送奖励
HelpHeroLogic.getInstance().useHelpSendReward(helpHero); HelpHeroLogic.getInstance().useHelpSendReward(helpHero);
// 删除队伍中英雄id // 删除队伍中英雄id

View File

@ -128,7 +128,8 @@ public class TeamPosManager extends MongoBase {
* @param user * @param user
*/ */
public void clearTeamPosByFourChallenge(User user){ public void clearTeamPosByFourChallenge(User user){
Map<String, HelpHero> helpHero = HelpHeroLogic.getHelpHeroMap(user.getId()); String subKey = HelpHeroLogic.subKey(user.getId(),HelpHeroLogic.CHOOSE);
Map<String, HelpHero> helpHero = HelpHeroLogic.getHelpHeroMap(subKey);
helpHero.values().forEach(v->{ helpHero.values().forEach(v->{
removeTeamPosByHeroId(GlobalsDef.FOURCHALLENGE_PEOPLE_TEAM,v.getHero().getId()); removeTeamPosByHeroId(GlobalsDef.FOURCHALLENGE_PEOPLE_TEAM,v.getHero().getId());
removeTeamPosByHeroId(GlobalsDef.FOURCHALLENGE_BUDDHA_TEAM,v.getHero().getId()); removeTeamPosByHeroId(GlobalsDef.FOURCHALLENGE_BUDDHA_TEAM,v.getHero().getId());

View File

@ -303,7 +303,8 @@ public class DeathPathLogic {
*/ */
public void getBaseInfo(ISession session,MessageTypeProto.MessageType messageType){ public void getBaseInfo(ISession session,MessageTypeProto.MessageType messageType){
int uid = session.getUid(); int uid = session.getUid();
String changeString = GameApplication.serverProperties.getId() + RedisKey.Delimiter_colon + RedisKey.DEATH_PATH_CHALLENGE_COUNT + RedisKey.Delimiter_colon + String.valueOf(uid); String type = GameApplication.serverProperties.getId() + RedisKey.Delimiter_colon + RedisKey.DEATH_PATH_CHALLENGE_COUNT;
String changeString = RedisUtil.getInstence().getKey(type,String.valueOf(uid),false);
String count = (String) RedisUtil.getInstence().get(changeString); String count = (String) RedisUtil.getInstence().get(changeString);
int challengeCount = count==null?0:Integer.parseInt(count); int challengeCount = count==null?0:Integer.parseInt(count);
// 结束时间和挑战次数 // 结束时间和挑战次数

View File

@ -774,7 +774,7 @@ public class CombatLogic {
} }
}else if (FourChallengeLogic.isFourChallengeTeam(teamId)){ }else if (FourChallengeLogic.isFourChallengeTeam(teamId)){
// 四灵试炼,助战 // 四灵试炼,助战
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), teamPosHeroInfo.getHeroId()); HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), teamPosHeroInfo.getHeroId());
if (helpHero != null){ if (helpHero != null){
hero = helpHero.getHero(); hero = helpHero.getHero();
}else { }else {
@ -835,7 +835,7 @@ public class CombatLogic {
} }
// 四灵试炼 // 四灵试炼
if (FourChallengeLogic.isFourChallengeTeam(teamId)){ if (FourChallengeLogic.isFourChallengeTeam(teamId)){
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), key.getHeroId()); HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), key.getHeroId());
if (helpHero != null){ if (helpHero != null){
heroFind.add(helpHero.getHero().getTemplateId()); heroFind.add(helpHero.getHero().getTemplateId());
continue; continue;
@ -845,7 +845,6 @@ public class CombatLogic {
heroFind.add(hero.getTemplateId()); heroFind.add(hero.getTemplateId());
} }
Map<Integer,Integer> propertiesMap = new HashMap<>(); Map<Integer,Integer> propertiesMap = new HashMap<>();
for(Integer heroId:heroFind){ for(Integer heroId:heroFind){
if(null==SCHero.sCHero.get(heroId)){ if(null==SCHero.sCHero.get(heroId)){
@ -890,14 +889,9 @@ public class CombatLogic {
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueDescending(Map<K, V> map) public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueDescending(Map<K, V> map)
{ {
List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet()); List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() list.sort((o1, o2) -> {
{ int compare = (o1.getValue()).compareTo(o2.getValue());
@Override return -compare;
public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2)
{
int compare = (o1.getValue()).compareTo(o2.getValue());
return -compare;
}
}); });
Map<K, V> result = new LinkedHashMap<K, V>(); Map<K, V> result = new LinkedHashMap<K, V>();

View File

@ -23,6 +23,7 @@ import manager.STableManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto; import rpc.protocols.CommonProto;
import util.StringUtil;
import util.TimeUtils; import util.TimeUtils;
import java.util.*; import java.util.*;
@ -57,7 +58,7 @@ public class HelpHeroLogic {
*/ */
public static final String CHOOSE = "CHOOSE"; public static final String CHOOSE = "CHOOSE";
public static String getSubKey(int uid,String sub){ public static String subKey(int uid,String sub){
return sub+":"+uid; return sub+":"+uid;
} }
@ -72,10 +73,15 @@ public class HelpHeroLogic {
HashSet<CommonProto.HelpFightList> result = new HashSet<>(); HashSet<CommonProto.HelpFightList> result = new HashSet<>();
// 如果类型是自己则使用uid // 如果类型是自己则使用uid
String subKey = typeEnum==Me?getSubKey(user.getId(),MY):String.valueOf(typeEnum.getPropertyId()); String subKey;
if (typeEnum == Me){
subKey = subKey(user.getId(),MY);
}else {
subKey = String.valueOf(typeEnum.getPropertyId());
}
// redis获取对应类型的列表 map<uid助战英雄信息> // redis获取对应类型的列表 map<uid助战英雄信息>
Map<String, HelpHero> helpHeroMap = RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, subKey, String.class, HelpHero.class); Map<String, HelpHero> helpHeroMap = getHelpHeroMap(subKey);
if (helpHeroMap == null || helpHeroMap.isEmpty()){ if (helpHeroMap == null || helpHeroMap.isEmpty()){
return result; return result;
} }
@ -132,7 +138,10 @@ public class HelpHeroLogic {
} }
// 已选中的助战 // 已选中的助战
List<String> strings = result.stream().map(v -> v.getHero().getId()).collect(Collectors.toList()); List<String> strings = result.stream().map(v -> v.getHero().getId()).collect(Collectors.toList());
HelpHero helpHero = getHelpHeroByType(user.getId(), typeEnum.getPropertyId()); // 获取subkey拿到英雄数据
String subKey1 = HelpHeroLogic.subKey(user.getId(),HelpHeroLogic.CHOOSE);
HelpHero helpHero = getHelpHeroMap(subKey1).get(String.valueOf(typeEnum.getPropertyId()));
// 英雄不存在添加
if (helpHero != null && !strings.contains(helpHero.getHero().getId())){ if (helpHero != null && !strings.contains(helpHero.getHero().getId())){
result.add(CBean2Proto.helpHeroProto(helpHero)); result.add(CBean2Proto.helpHeroProto(helpHero));
} }
@ -159,16 +168,15 @@ public class HelpHeroLogic {
// 英雄类型 // 英雄类型
int propertyName = SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName(); int propertyName = SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName();
// 自己的助战列表 // 自己的助战列表
HelpHero helpHero = RedisUtil.getInstence().getMapEntry(RedisKey.HELP_FIGHT, getSubKey(user.getId(),MY), String.valueOf(propertyName), HelpHero.class); String subKey = subKey(user.getId(), MY);
HelpHero helpHero = getHelpHeroMap(subKey).get(String.valueOf(propertyName));
if (helpHero != null){ if (helpHero != null){
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"已选择其他神将!"); throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"已选择其他神将!");
} }
// 自己的助战列表添加 // 自己的助战列表添加
RedisUtil.getInstence().putMapEntry(RedisKey.HELP_FIGHT, getSubKey(user.getId(),MY), String.valueOf(propertyName), CBean2Proto.heroToHelpHero(user,hero)); addHelpHero(subKey(user.getId(),MY),propertyName,CBean2Proto.heroToHelpHero(user,hero));
// 类型助战列表添加,自己的助战列表没有该类型英雄,那么对应类型的助战列表也应该没有对应英雄,所以这里不再循环验证 // 类型助战列表添加,自己的助战列表没有该类型英雄,那么对应类型的助战列表也应该没有对应英雄,所以这里不再循环验证
RedisUtil.getInstence().putMapEntry(RedisKey.HELP_FIGHT, String.valueOf(propertyName), String.valueOf(user.getId()), CBean2Proto.heroToHelpHero(user,hero)); addHelpHero(String.valueOf(propertyName),user.getId(),CBean2Proto.heroToHelpHero(user,hero));
// 配置表,获取自己设置助战奖励 // 配置表,获取自己设置助战奖励
SCampTowerSetting campTowerSetting = STableManager.getConfig(SCampTowerSetting.class).get(1); SCampTowerSetting campTowerSetting = STableManager.getConfig(SCampTowerSetting.class).get(1);
@ -189,7 +197,8 @@ public class HelpHeroLogic {
*/ */
public void useHelpHero(User user,String heroId,int type,int status) throws Exception{ public void useHelpHero(User user,String heroId,int type,int status) throws Exception{
// 该类型的助战使用状态 // 该类型的助战使用状态
HelpHero helpHero = getHelpHeroByType(user.getId(), type); String subKey = subKey(user.getId(), CHOOSE);
HelpHero helpHero = getHelpHeroMap(subKey).get(String.valueOf(type));
// 选择助战 // 选择助战
if (status == 1) { if (status == 1) {
if (helpHero != null){ if (helpHero != null){
@ -199,7 +208,7 @@ public class HelpHeroLogic {
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"已选择其他助战英雄!"); throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"已选择其他助战英雄!");
} }
// 获取全部助战列表 // 获取全部助战列表
Map<String, HelpHero> helpMap = RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, String.valueOf(type), String.class, HelpHero.class); Map<String, HelpHero> helpMap = getHelpHeroMap(String.valueOf(type));
for (Map.Entry<String, HelpHero> data : helpMap.entrySet()) { for (Map.Entry<String, HelpHero> data : helpMap.entrySet()) {
// key // key
int key = Integer.parseInt(data.getKey()); int key = Integer.parseInt(data.getKey());
@ -211,7 +220,7 @@ public class HelpHeroLogic {
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE, "不能使用自己的助战英雄!"); throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE, "不能使用自己的助战英雄!");
} }
// 添加助战英雄 // 添加助战英雄
addHelpHero(user.getId(),type,data.getValue()); addHelpHero(subKey,type,data.getValue());
break; break;
} }
} }
@ -221,7 +230,7 @@ public class HelpHeroLogic {
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"助战已使用或不存在,无法取消助战!"); throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"助战已使用或不存在,无法取消助战!");
} }
// 删除助战英雄魂宝 // 删除助战英雄魂宝
removeHelpHero(user.getId(),type); removeHelpHero(subKey(user.getId(),CHOOSE),type);
} }
} }
@ -266,30 +275,20 @@ public class HelpHeroLogic {
user.getTeamPosManager().clearTeamPosByFourChallenge(user); user.getTeamPosManager().clearTeamPosByFourChallenge(user);
// 领取奖励次数 // 领取奖励次数
user.getPlayerInfoManager().setHelpRewardNum(0); user.getPlayerInfoManager().setHelpRewardNum(0);
} // 清理自己的助战信息
String myKey = RedisUtil.getInstence().getKey(RedisKey.HELP_FIGHT, subKey(user.getId(), MY));
/*** RedisUtil.getInstence().del(myKey);
* redis String chooseKey = RedisUtil.getInstence().getKey(RedisKey.HELP_FIGHT, subKey(user.getId(), CHOOSE));
*/ RedisUtil.getInstence().del(chooseKey);
public void zeroClearRedisHelp(){
// 不是零点
if (TimeUtils.getHourOfDay() != 0 || TimeUtils.getMiunte() != 0){
return;
}
String key = GameApplication.serverId +":" + RedisKey.HELP_FIGHT + "*";
// 模糊批量删除key
Set<String> keys = RedisUtil.getInstence().getDimKey(key, -1);
keys.forEach(k->RedisUtil.getInstence().del(k));
} }
/** /**
* *
* @param uid * @param subKey
* @return * @param type
*/ */
public static Map<String,HelpHero> getHelpHeroMap(int uid){ public static void removeHelpHero(String subKey, int type){
String subKey = getSubKey(uid,CHOOSE); RedisUtil.getInstence().removeMapEntrys(RedisKey.HELP_FIGHT, subKey, String.valueOf(type));
return RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, subKey, String.class, HelpHero.class);
} }
/** /**
@ -298,8 +297,9 @@ public class HelpHeroLogic {
* @param heroId * @param heroId
* @return * @return
*/ */
public static HelpHero getHelpHero(int uid,String heroId){ public static HelpHero getHelpHeroByHeroId(int uid,String heroId){
Map<String, HelpHero> helpHeroMap = getHelpHeroMap(uid); String subKey = HelpHeroLogic.subKey(uid,HelpHeroLogic.CHOOSE);
Map<String, HelpHero> helpHeroMap = getHelpHeroMap(subKey);
for (HelpHero value : helpHeroMap.values()) { for (HelpHero value : helpHeroMap.values()) {
if (value.getHero().getId().equals(heroId)){ if (value.getHero().getId().equals(heroId)){
return value; return value;
@ -309,37 +309,34 @@ public class HelpHeroLogic {
} }
/** /**
* *
* @param uid * @param subKey
* @param type
* @return * @return
*/ */
public static HelpHero getHelpHeroByType(int uid, int type){ public static Map<String,HelpHero> getHelpHeroMap(String subKey){
String subKey = getSubKey(uid,CHOOSE); return RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, subKey, String.class, HelpHero.class);
return RedisUtil.getInstence().getMapValue(RedisKey.HELP_FIGHT, subKey, String.valueOf(type), HelpHero.class);
}
/**
*
* @param uid
* @param type
*/
public static void removeHelpHero(int uid, int type){
String subKey = getSubKey(uid,CHOOSE);
RedisUtil.getInstence().removeMapEntrys(RedisKey.HELP_FIGHT, subKey, String.valueOf(type));
} }
/** /**
* *
* @param uid * @param subKey
* @param type * @param type
* @param helpHero * @param helpHero
*/ */
public static void addHelpHero(int uid,int type,HelpHero helpHero){ public static void addHelpHero(String subKey, int type,HelpHero helpHero){
String subKey = getSubKey(uid,CHOOSE);
RedisUtil.getInstence().putMapEntry(RedisKey.HELP_FIGHT, subKey, String.valueOf(type), helpHero); RedisUtil.getInstence().putMapEntry(RedisKey.HELP_FIGHT, subKey, String.valueOf(type), helpHero);
} }
/**
* redis
*/
public void zeroClearRedisHelp(){
Set<String> set = RedisUtil.getInstence().sGet(RedisKey.HELP_FIGHT_DELETE);
String[] keys = set.toArray(new String[0]);
RedisUtil.getInstence().del(keys);
RedisUtil.getInstence().setRemove(RedisKey.HELP_FIGHT_DELETE,keys);
}
/** /**
* *
* @param me * @param me

View File

@ -1120,7 +1120,7 @@ public class HeroLogic{
if(heroManager.getHeroMap().containsKey(heroId.getHeroId())){ if(heroManager.getHeroMap().containsKey(heroId.getHeroId())){
set.add(heroManager.getHero(heroId.getHeroId()).getTemplateId()); set.add(heroManager.getHero(heroId.getHeroId()).getTemplateId());
} }
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), heroId.getHeroId()); HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), heroId.getHeroId());
if (helpHero != null){ if (helpHero != null){
set.add(helpHero.getHero().getTemplateId()); set.add(helpHero.getHero().getTemplateId());
} }
@ -1222,7 +1222,7 @@ public class HeroLogic{
return "card not exists"; return "card not exists";
} }
}else if (FourChallengeLogic.isFourChallengeTeam(teamId)){ }else if (FourChallengeLogic.isFourChallengeTeam(teamId)){
if(user.getHeroManager().getHero(heroId) == null&&HelpHeroLogic.getHelpHero(user.getId(),heroId) == null){ if(user.getHeroManager().getHero(heroId) == null&&HelpHeroLogic.getHelpHeroByHeroId(user.getId(),heroId) == null){
return "card not exists"; return "card not exists";
} }
}else { }else {
@ -2367,7 +2367,7 @@ public class HeroLogic{
Map<String, PropertyItem> equipMap = new HashMap<>(); Map<String, PropertyItem> equipMap = new HashMap<>();
// 助战英雄 // 助战英雄
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), hero.getId()); HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), hero.getId());
if (helpHero!=null){ if (helpHero!=null){
for (Jewel jewel : helpHero.getJewels()) { for (Jewel jewel : helpHero.getJewels()) {
equipMap.put(jewel.getId(),jewel); equipMap.put(jewel.getId(),jewel);
@ -3063,7 +3063,7 @@ public class HeroLogic{
Hero hero = targetUser.getHeroManager().getHero(teamPosHeroInfo.getHeroId()); Hero hero = targetUser.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
if (hero == null) { if (hero == null) {
// 助战获取,随后最好加上编队验证 // 助战获取,随后最好加上编队验证
hero = HelpHeroLogic.getHelpHero(targetUser.getId(),teamPosHeroInfo.getHeroId()).getHero(); hero = HelpHeroLogic.getHelpHeroByHeroId(targetUser.getId(),teamPosHeroInfo.getHeroId()).getHero();
if (hero == null){ if (hero == null){
continue; continue;
} }

View File

@ -228,7 +228,8 @@ public class CBean2Proto {
public static List<CommonProto.HelpFightList> getHelpFightList(User user) throws Exception { public static List<CommonProto.HelpFightList> getHelpFightList(User user) throws Exception {
List<CommonProto.HelpFightList> lists = new ArrayList<>(); List<CommonProto.HelpFightList> lists = new ArrayList<>();
// 助战英雄列表 // 助战英雄列表
Map<String, HelpHero> helpHeroMap = HelpHeroLogic.getHelpHeroMap(user.getId()); String subKey = HelpHeroLogic.subKey(user.getId(),HelpHeroLogic.CHOOSE);
Map<String, HelpHero> helpHeroMap = HelpHeroLogic.getHelpHeroMap(subKey);
if (helpHeroMap == null || helpHeroMap.isEmpty()){ if (helpHeroMap == null || helpHeroMap.isEmpty()){
return lists; return lists;
} }

View File

@ -69,11 +69,11 @@ public class WorldServerApplication {
// NetManager.getInstance().init(); // NetManager.getInstance().init();
try { // try {
ArenaLogic.initRank(); // ArenaLogic.initRank();
}catch (Exception e){ // }catch (Exception e){
LOGGER.info("ArenaLogic err ->{}", e); // LOGGER.info("ArenaLogic err ->{}", e);
} // }
bean = ConfigurableApplicationContextManager.getBean(WorldCoreSettings.class); bean = ConfigurableApplicationContextManager.getBean(WorldCoreSettings.class);

View File

@ -1,69 +1,69 @@
package com.world.handler; //package com.world.handler;
//
import com.google.protobuf.GeneratedMessage; //import com.google.protobuf.GeneratedMessage;
import com.world.logic.rank.AbstractCrossRank; //import com.world.logic.rank.AbstractCrossRank;
import com.world.logic.rank.DeathPathCrossEveryPersonRank; //import com.world.logic.rank.DeathPathCrossEveryPersonRank;
import com.world.redis.RedisKey; //import com.world.redis.RedisKey;
import com.world.redis.RedisUtil; //import com.world.redis.RedisUtil;
import org.luaj.vm2.ast.Str; //import org.luaj.vm2.ast.Str;
import org.springframework.data.redis.core.ZSetOperations; //import org.springframework.data.redis.core.ZSetOperations;
import rpc.net.RpcMessage; //import rpc.net.RpcMessage;
import rpc.net.gtGBaseHandler; //import rpc.net.gtGBaseHandler;
import rpc.world.WorldProto; //import rpc.world.WorldProto;
//
import java.math.BigDecimal; //import java.math.BigDecimal;
import java.util.Set; //import java.util.Set;
//
/** ///**
* @author lvxinran // * @author lvxinran
* @date 2020/12/3 // * @date 2020/12/3
* @discribe // * @discribe
*/ // */
@Deprecated //@Deprecated
public class AddDeathPathRankRequestHandler extends gtGBaseHandler<WorldProto.AddDeathPathRankRequest>{ //public class AddDeathPathRankRequestHandler extends gtGBaseHandler<WorldProto.AddDeathPathRankRequest>{
//
@Override // @Override
public GeneratedMessage processWithProto(RpcMessage rpcMessage, WorldProto.AddDeathPathRankRequest proto) throws Exception { // public GeneratedMessage processWithProto(RpcMessage rpcMessage, WorldProto.AddDeathPathRankRequest proto) throws Exception {
RedisUtil redisUtil = RedisUtil.getInstence(); // RedisUtil redisUtil = RedisUtil.getInstence();
//操作每个关的公会、个人数据 // //操作每个关的公会、个人数据
BigDecimal decimal = new BigDecimal(String.valueOf(proto.getDamage())).divide(new BigDecimal(String.valueOf(Math.pow(10,15)))); // BigDecimal decimal = new BigDecimal(String.valueOf(proto.getDamage())).divide(new BigDecimal(String.valueOf(Math.pow(10,15))));
long everyGuildChangeScore = (long)proto.getDamage()*1000; // long everyGuildChangeScore = (long)proto.getDamage()*1000;
if(redisUtil.getZSetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(proto.getPathId()), String.valueOf(proto.getUid()))==-1){ // if(redisUtil.getZSetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(proto.getPathId()), String.valueOf(proto.getUid()))==-1){
// decimal = decimal.add(new BigDecimal(0)); //// decimal = decimal.add(new BigDecimal(0));
//记录人数操作 // //记录人数操作
everyGuildChangeScore = everyGuildChangeScore+1; // everyGuildChangeScore = everyGuildChangeScore+1;
} // }
//
String before= firstGuild(redisUtil, proto.getGroupId(), proto.getPathId()); // String before= firstGuild(redisUtil, proto.getGroupId(), proto.getPathId());
redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK,String.valueOf(proto.getPathId()),String.valueOf(proto.getGuildId()), everyGuildChangeScore); // redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK,String.valueOf(proto.getPathId()),String.valueOf(proto.getGuildId()), everyGuildChangeScore);
String after = firstGuild(redisUtil, proto.getGroupId(), proto.getPathId()); // String after = firstGuild(redisUtil, proto.getGroupId(), proto.getPathId());
if(!before.equals(after)){ // if(!before.equals(after)){
decimal = decimal.add(new BigDecimal(1)); // decimal = decimal.add(new BigDecimal(1));
if(!"".equals(before)){ // if(!"".equals(before)){
redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,"",before, -1); // redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,"",before, -1);
} // }
} // }
//
//
redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(proto.getPathId()),String.valueOf(proto.getUid()), proto.getDamage());
// redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(proto.getPathId()),String.valueOf(proto.getUid()), proto.getDamage()); // redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(proto.getPathId()),String.valueOf(proto.getUid()), proto.getDamage());
//
//操作总的个人伤害 //// redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(proto.getPathId()),String.valueOf(proto.getUid()), proto.getDamage());
redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,"",String.valueOf(proto.getUid()), proto.getDamage()); //
// //操作总的个人伤害
//操作总的工会伤害 // redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,"",String.valueOf(proto.getUid()), proto.getDamage());
//
redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,"",String.valueOf(proto.getGuildId()), decimal.doubleValue()); // //操作总的工会伤害
//
redisUtil.hset(RedisKey.DEATH_PATH_EVERY_OVER_HASH,String.valueOf(rpcMessage.getServerId()),1); // redisUtil.incrementZsetScore(proto.getGroupId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,"",String.valueOf(proto.getGuildId()), decimal.doubleValue());
//
return proto; // redisUtil.hset(RedisKey.DEATH_PATH_EVERY_OVER_HASH,String.valueOf(rpcMessage.getServerId()),1);
} //
// return proto;
private String firstGuild(RedisUtil redisUtil,int groupId,int pathId){ // }
Set<ZSetOperations.TypedTuple<String>> scores = redisUtil.getZsetreverseRangeWithScores(groupId + ":" + RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(pathId), 0, 0); //
return scores.iterator().hasNext()?scores.iterator().next().getValue():""; // private String firstGuild(RedisUtil redisUtil,int groupId,int pathId){
} // Set<ZSetOperations.TypedTuple<String>> scores = redisUtil.getZsetreverseRangeWithScores(groupId + ":" + RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(pathId), 0, 0);
// return scores.iterator().hasNext()?scores.iterator().next().getValue():"";
} // }
//
//}

View File

@ -1,45 +1,45 @@
package com.world.handler; //package com.world.handler;
//
import com.ljsd.jieling.logic.dao.GuildInfoCache; //import com.ljsd.jieling.logic.dao.GuildInfoCache;
import com.world.db.mongo.MongoUtil; //import com.world.db.mongo.MongoUtil;
import com.world.logic.rank.DeathPathCrossEveryGuildRank; //import com.world.logic.rank.DeathPathCrossEveryGuildRank;
import com.world.redis.RedisKey; //import com.world.redis.RedisKey;
import com.world.redis.RedisUtil; //import com.world.redis.RedisUtil;
import org.springframework.data.redis.core.ZSetOperations; //import org.springframework.data.redis.core.ZSetOperations;
import rpc.net.RpcMessage; //import rpc.net.RpcMessage;
import rpc.net.gtGBaseHandler; //import rpc.net.gtGBaseHandler;
import rpc.world.WorldProto; //import rpc.world.WorldProto;
//
import java.util.Iterator; //import java.util.Iterator;
import java.util.Set; //import java.util.Set;
//
/** ///**
* @author lvxinran // * @author lvxinran
* @date 2020/12/12 // * @date 2020/12/12
* @discribe // * @discribe
*/ // */
@Deprecated //@Deprecated
public class GetDeathPathFirstRequestHandler extends gtGBaseHandler<WorldProto.GetDeathPathFirstRequest> { //public class GetDeathPathFirstRequestHandler extends gtGBaseHandler<WorldProto.GetDeathPathFirstRequest> {
//
@Override // @Override
public WorldProto.GetDeathPathFirstResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetDeathPathFirstRequest proto) throws Exception { // public WorldProto.GetDeathPathFirstResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetDeathPathFirstRequest proto) throws Exception {
//
//
DeathPathCrossEveryGuildRank deathPathCrossEveryGuildRank = new DeathPathCrossEveryGuildRank(RedisKey.DEATH_PATH_EVERY_GUILD_RANK); // DeathPathCrossEveryGuildRank deathPathCrossEveryGuildRank = new DeathPathCrossEveryGuildRank(RedisKey.DEATH_PATH_EVERY_GUILD_RANK);
WorldProto.GetDeathPathFirstResponse.Builder response = WorldProto.GetDeathPathFirstResponse.newBuilder(); // WorldProto.GetDeathPathFirstResponse.Builder response = WorldProto.GetDeathPathFirstResponse.newBuilder();
/*for(int i = 1 ;i<=10;i++){ // /*for(int i = 1 ;i<=10;i++){
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(proto.getGroupId()+":"+ RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(i), 0, 0); // Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(proto.getGroupId()+":"+ RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(i), 0, 0);
Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator(); // Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
if(!iterator.hasNext()){ // if(!iterator.hasNext()){
continue; // continue;
} // }
ZSetOperations.TypedTuple<String> next = iterator.next(); // ZSetOperations.TypedTuple<String> next = iterator.next();
int guildId = Integer.parseInt(next.getValue()); // int guildId = Integer.parseInt(next.getValue());
GuildInfoCache crossGuild = deathPathCrossEveryGuildRank.getCrossGuild(guildId); // GuildInfoCache crossGuild = deathPathCrossEveryGuildRank.getCrossGuild(guildId);
String name = MongoUtil.getInstence().getServerNameById(crossGuild.getServerId()); // String name = MongoUtil.getInstence().getServerNameById(crossGuild.getServerId());
WorldProto.EvertDeathPath info = WorldProto.EvertDeathPath.newBuilder().setGuildName(crossGuild.getGuildName()).setPathId(i).setGid(guildId).setServerName(name).build(); // WorldProto.EvertDeathPath info = WorldProto.EvertDeathPath.newBuilder().setGuildName(crossGuild.getGuildName()).setPathId(i).setGid(guildId).setServerName(name).build();
response.addDeathPathInfo(info); // response.addDeathPathInfo(info);
}*/ // }*/
return response.build(); // return response.build();
} // }
} //}

View File

@ -1,38 +1,38 @@
package com.world.handler; //package com.world.handler;
//
import com.world.logic.arean.ArenaLogic; //import com.world.logic.arean.ArenaLogic;
import com.world.logic.rank.DeathPathCrossEveryGuildRank; //import com.world.logic.rank.DeathPathCrossEveryGuildRank;
import com.world.logic.rank.DeathPathCrossEveryPersonRank; //import com.world.logic.rank.DeathPathCrossEveryPersonRank;
import com.world.logic.rank.DeathPathCrossTotalGuildRank; //import com.world.logic.rank.DeathPathCrossTotalGuildRank;
import com.world.redis.RedisKey; //import com.world.redis.RedisKey;
import rpc.net.RpcMessage; //import rpc.net.RpcMessage;
import rpc.net.gtGBaseHandler; //import rpc.net.gtGBaseHandler;
import rpc.protocols.PlayerInfoProto; //import rpc.protocols.PlayerInfoProto;
import rpc.world.WorldProto; //import rpc.world.WorldProto;
//
/** ///**
* @author lvxinran // * @author lvxinran
* @date 2020/12/3 // * @date 2020/12/3
* @discribe // * @discribe
*/ // */
public class GetRankRequestHandler extends gtGBaseHandler<WorldProto.GetRankRequest> { //public class GetRankRequestHandler extends gtGBaseHandler<WorldProto.GetRankRequest> {
//
@Override // @Override
public PlayerInfoProto.RankResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetRankRequest proto) throws Exception { // public PlayerInfoProto.RankResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetRankRequest proto) throws Exception {
switch (proto.getType()){ // switch (proto.getType()){
// RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType(); // RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType();
case 15: // case 15:
return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1); // return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1);
case 16: // case 16:
return new DeathPathCrossEveryGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1); // return new DeathPathCrossEveryGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1);
case 17: // case 17:
return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK).getRank(proto.getUid(),"",1,-1); // return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK).getRank(proto.getUid(),"",1,-1);
case 18: // case 18:
return new DeathPathCrossTotalGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK).getRank(proto.getUid(),"",1,-1); // return new DeathPathCrossTotalGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK).getRank(proto.getUid(),"",1,-1);
case 28: // case 28:
return ArenaLogic.getInstance().getRank(rpcMessage.getUid(),rpcMessage.getServerId()); // return ArenaLogic.getInstance().getRank(rpcMessage.getUid(),rpcMessage.getServerId());
default: // default:
return null; // return null;
} // }
} // }
} //}

View File

@ -68,27 +68,27 @@ public class ArenaLogic {
public static void initRank() throws Exception { public static void initRank() throws Exception {
Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class); // Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
serverSplit.forEach((s, integer) -> { // serverSplit.forEach((s, integer) -> {
HashSet<String> strings = map.getOrDefault(integer, new HashSet<>()); // HashSet<String> strings = map.getOrDefault(integer, new HashSet<>());
strings.add(s); // strings.add(s);
map.put(integer, strings); // map.put(integer, strings);
}); // });
ArenaLogic.serverSplit = serverSplit; // ArenaLogic.serverSplit = serverSplit;
//
Set<String> keys = new HashSet<>(); // Set<String> keys = new HashSet<>();
Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK:*", 200); // Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK:*", 200);
while (cursor.hasNext()) { // while (cursor.hasNext()) {
//找到一次就添加一次 // //找到一次就添加一次
keys.add(cursor.next()); // keys.add(cursor.next());
} // }
cursor.close(); // cursor.close();
keys.forEach(k -> { // keys.forEach(k -> {
HashMap<Integer, ArenaEnemy> object = RedisUtil.getInstence().getObject(k, new TypeToken<HashMap<Integer, ArenaEnemy>>() { // HashMap<Integer, ArenaEnemy> object = RedisUtil.getInstence().getObject(k, new TypeToken<HashMap<Integer, ArenaEnemy>>() {
}.getType()); // }.getType());
//
ranInfo.put(Integer.valueOf(k.split(":")[1]), object); // ranInfo.put(Integer.valueOf(k.split(":")[1]), object);
}); // });
} }
public void minCheck() { public void minCheck() {
@ -139,27 +139,27 @@ public class ArenaLogic {
} }
private void onfinish(){ private void onfinish(){
map.clear(); // map.clear();
//
List<String> delKeys = new ArrayList<>(); // List<String> delKeys = new ArrayList<>();
//
delKeys.add(RedisUtil.getInstence().getKey(RedisKey.WORLD_ARENA_RANK_MY_MATH, "")); // delKeys.add(RedisUtil.getInstence().getKey(RedisKey.WORLD_ARENA_RANK_MY_MATH, ""));
delKeys.add(RedisUtil.getInstence().getKey(RedisKey.WORLD_ARENA_RRECORD, "")); // delKeys.add(RedisUtil.getInstence().getKey(RedisKey.WORLD_ARENA_RRECORD, ""));
delKeys.add(RedisUtil.getInstence().getKey(RedisKey.WORLD_ARENA_MY_PRON, "")); // delKeys.add(RedisUtil.getInstence().getKey(RedisKey.WORLD_ARENA_MY_PRON, ""));
//
Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK_MY_MATH:*", -1); // Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK_MY_MATH:*", -1);
while (cursor.hasNext()) { // while (cursor.hasNext()) {
String next = cursor.next(); // String next = cursor.next();
System.out.println("清除:"+next); // System.out.println("清除:"+next);
delKeys.add(next); // delKeys.add(next);
} // }
Cursor<String> curso1 = RedisUtil.getInstence().scan("WORLD_ARENA_RRECORD:*", -1); // Cursor<String> curso1 = RedisUtil.getInstence().scan("WORLD_ARENA_RRECORD:*", -1);
while (curso1.hasNext()) { // while (curso1.hasNext()) {
String next = curso1.next(); // String next = curso1.next();
System.out.println("清除:"+next); // System.out.println("清除:"+next);
delKeys.add(next); // delKeys.add(next);
} // }
RedisUtil.getInstence().del(delKeys.toArray(new String[0])); // RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
} }
@ -357,12 +357,12 @@ public class ArenaLogic {
* *
*/ */
public static void clearReidsInTime() { public static void clearReidsInTime() {
List<String> delKeys = new ArrayList<>(); // List<String> delKeys = new ArrayList<>();
Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_MY_PRON:*", -1); // Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_MY_PRON:*", -1);
while (cursor.hasNext()) { // while (cursor.hasNext()) {
delKeys.add(cursor.next()); // delKeys.add(cursor.next());
} // }
RedisUtil.getInstence().del(delKeys.toArray(new String[0])); // RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
} }

View File

@ -27,13 +27,13 @@ public class RedisKey {
public static final String WORLD_ARENA_RRECORD = "WORLD_ARENA_RRECORD";//竞技场记录 public static final String WORLD_ARENA_RRECORD = "WORLD_ARENA_RRECORD";//竞技场记录
public static final String DEATH_PATH_EVERY_PERSON_RANK = "DEATH_PATH_EVERY_PERSON_RANK"; // public static final String DEATH_PATH_EVERY_PERSON_RANK = "DEATH_PATH_EVERY_PERSON_RANK";
//
public static final String DEATH_PATH_TOTAL_PERSON_RANK = "DEATH_PATH_TOTAL_PERSON_RANK"; // public static final String DEATH_PATH_TOTAL_PERSON_RANK = "DEATH_PATH_TOTAL_PERSON_RANK";
//
public static final String DEATH_PATH_TOTAL_GUILD_RANK = "DEATH_PATH_TOTAL_GUILD_RANK"; // public static final String DEATH_PATH_TOTAL_GUILD_RANK = "DEATH_PATH_TOTAL_GUILD_RANK";
//
public static final String DEATH_PATH_EVERY_GUILD_RANK = "DEATH_PATH_EVERY_GUILD_RANK"; // public static final String DEATH_PATH_EVERY_GUILD_RANK = "DEATH_PATH_EVERY_GUILD_RANK";
public static final String PLAYER_INFO_CACHE = "PLAYER_INFO_CACHE"; public static final String PLAYER_INFO_CACHE = "PLAYER_INFO_CACHE";
@ -41,7 +41,7 @@ public class RedisKey {
public static final String WORLD_ARENA_MY_PRON = "WORLD_ARENA_MY_PRON";//我的膜拜记录 public static final String WORLD_ARENA_MY_PRON = "WORLD_ARENA_MY_PRON";//我的膜拜记录
public static final String DEATH_PATH_EVERY_OVER_HASH = "DEATH_PATH_EVERY_OVER_HASH";//结算标识 // public static final String DEATH_PATH_EVERY_OVER_HASH = "DEATH_PATH_EVERY_OVER_HASH";//结算标识
public static final String ARENA_PROUD_COUNT = "ARENA_PROUD_COUNT"; public static final String ARENA_PROUD_COUNT = "ARENA_PROUD_COUNT";
public static final String ARENA_PROUD_COUNT_ROBOT = "ARENA_PROUD_COUNT_ROBOT"; public static final String ARENA_PROUD_COUNT_ROBOT = "ARENA_PROUD_COUNT_ROBOT";

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ public class MinuteTask extends Thread {
} }
try { try {
LOGGER.info("MinuteTask start..."); LOGGER.info("MinuteTask start...");
ArenaLogic.getInstance().minCheck(); // ArenaLogic.getInstance().minCheck();
LOGGER.info("MinuteTask end..."); LOGGER.info("MinuteTask end...");
} catch (Exception e) { } catch (Exception e) {
@ -55,11 +55,11 @@ public class MinuteTask extends Thread {
}catch (Exception e){ }catch (Exception e){
LOGGER.info("MongoUtil err ->{}", e); LOGGER.info("MongoUtil err ->{}", e);
} }
try { // try {
ArenaLogic.clearReidsInTime(); // ArenaLogic.clearReidsInTime();
}catch (Exception e){ // }catch (Exception e){
LOGGER.info("clearReidsInTime err ->{}", e); // LOGGER.info("clearReidsInTime err ->{}", e);
} // }
LOGGER.info("DailyOfZeroTask end ..."); LOGGER.info("DailyOfZeroTask end ...");
} }