第一版
parent
e819858d77
commit
393635b930
|
|
@ -419,17 +419,11 @@ public class AreaManager {
|
|||
}
|
||||
|
||||
public int getServerIdByUid(int uid, int defaultServerId) {
|
||||
int serverId = defaultServerId;
|
||||
Integer serverIdByUid = RedisUtil.getInstence().getMapEntry(RedisKey.CUser_ServerId_Key, "", Integer.toString(uid),
|
||||
Integer.class);
|
||||
// serverIdByUid = MongoUtil.getInstence().findCUserServerId(uid);
|
||||
if (serverIdByUid != null) {
|
||||
serverId = serverIdByUid;
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CUser_ServerId_Key, "", Integer.toString(uid),
|
||||
serverId);
|
||||
} else {
|
||||
return GameApplication.serverId;
|
||||
Integer serverIdByUid = RedisUtil.getInstence().getMapEntry(RedisKey.CUser_ServerId_Key,"",Integer.toString(uid),Integer.class);
|
||||
if (serverIdByUid == null){
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CUser_ServerId_Key, "", Integer.toString(uid), defaultServerId);
|
||||
serverIdByUid = defaultServerId;
|
||||
}
|
||||
return serverId;
|
||||
return serverIdByUid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,20 +188,22 @@ public class RedisKey {
|
|||
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_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_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_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_TOTAL_CHALLENGE_COUNT = "DEATH_PATH_TOTAL_CHALLENGE_COUNT";
|
||||
|
||||
//问卷调查
|
||||
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 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 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
|
||||
* value:map《助战类型,助战英雄》
|
||||
* 第二种
|
||||
* key:服务器id:HELP_FIGHT:CHOOSE:玩家id
|
||||
* key: 服务器id:HELP_FIGHT:CHOOSE:玩家id
|
||||
* value:map《助战类型,助战英雄》
|
||||
* 第三种
|
||||
* key:服务器id:HELP_FIGHT:助战类型
|
||||
* key: 服务器id:HELP_FIGHT:助战类型
|
||||
* value:map《玩家id,助战英雄》
|
||||
*/
|
||||
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<>();
|
||||
|
||||
|
|
@ -420,7 +423,6 @@ public class RedisKey {
|
|||
rankCacChe.add(SITUATION_RANK);
|
||||
|
||||
rankCacChe.add(FOUR_CHALLENGE_TIER_RANK);
|
||||
rankCacChe.add(HELP_FIGHT);
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
@ -448,31 +450,7 @@ public class RedisKey {
|
|||
// familyKey.add(FAMILY_FIGHT_FINISH_MATCHING);
|
||||
}
|
||||
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 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);
|
||||
// }
|
||||
return RedisUtil.getInstence().getKey(type,key);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.*;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class RedisUtil {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RedisUtil.class);
|
||||
|
|
@ -1342,38 +1343,58 @@ public class RedisUtil {
|
|||
* @return
|
||||
*/
|
||||
public String getKey(String type,String key,boolean judge){
|
||||
if (!judge){
|
||||
return type + RedisKey.Delimiter_colon + key;
|
||||
String result = null;
|
||||
if (!judge) {
|
||||
result = type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
|
||||
if(RedisKey.PLAYER_INFO_CACHE.equals(type) ||RedisKey.FAMILY_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.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.WORLD_ARENA_MY_PRON.equals(type)||RedisKey.WORLD_ARENA_RRECORD.equals(type)) {
|
||||
return type + RedisKey.Delimiter_colon + key;
|
||||
else if (
|
||||
RedisKey.PLAYER_INFO_CACHE.equals(type) || RedisKey.FAMILY_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.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.WORLD_ARENA_MY_PRON.equals(type) || RedisKey.WORLD_ARENA_RRECORD.equals(type) ||
|
||||
RedisKey.TOKEN.equals(type) || RedisKey.USER_SERVER_INFO.equals(type) ||
|
||||
RedisKey.CDKEY.equals(type) || RedisKey.ServerArenaJob.equals(type)
|
||||
) {
|
||||
result = type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
|
||||
if(RedisKey.TOKEN.equals(type)||RedisKey.USER_SERVER_INFO.equals(type)||
|
||||
RedisKey.CDKEY.equals(type)||RedisKey.ServerArenaJob.equals(type)){
|
||||
return type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
|
||||
if(!RedisKey.newAreaCacChe.contains(type)&&!RedisKey.rankCacChe.contains(type)){
|
||||
if(key.length() == 8) {
|
||||
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;
|
||||
else if (!RedisKey.newAreaCacChe.contains(type) && !RedisKey.rankCacChe.contains(type)) {
|
||||
if (key.length() == 8) {
|
||||
Integer serverId = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, key, Integer.class, -1);
|
||||
if (serverId != null && !AreaManager.getInstance().checkServerIdAllowPermit(serverId)) {
|
||||
result = -1 + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
else if (serverId != null){
|
||||
result = serverId + 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 byte[] SET_IF_NOT_EXIST = "NX".getBytes();
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ public class BehaviorUtil {
|
|||
if (hero == null) {
|
||||
// 四灵试炼,助战
|
||||
if (FourChallengeLogic.isFourChallengeTeam(teamId)){
|
||||
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), teamPosHeroInfo.getHeroId());
|
||||
HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), teamPosHeroInfo.getHeroId());
|
||||
if (helpHero == null){
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ public class FourChallengeLogic {
|
|||
for (TeamPosHeroInfo info : teamPosHeroInfos) {
|
||||
Hero hero = user.getHeroManager().getHero(info.getHeroId());
|
||||
if (hero == null){
|
||||
helpHero = HelpHeroLogic.getHelpHero(user.getId(), info.getHeroId());
|
||||
helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), info.getHeroId());
|
||||
if (helpHero == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"挑战编队英雄不存在");
|
||||
}
|
||||
|
|
@ -229,7 +229,9 @@ public class FourChallengeLogic {
|
|||
if (help == 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);
|
||||
// 删除队伍中英雄id
|
||||
|
|
|
|||
|
|
@ -128,7 +128,8 @@ public class TeamPosManager extends MongoBase {
|
|||
* @param 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->{
|
||||
removeTeamPosByHeroId(GlobalsDef.FOURCHALLENGE_PEOPLE_TEAM,v.getHero().getId());
|
||||
removeTeamPosByHeroId(GlobalsDef.FOURCHALLENGE_BUDDHA_TEAM,v.getHero().getId());
|
||||
|
|
|
|||
|
|
@ -303,7 +303,8 @@ public class DeathPathLogic {
|
|||
*/
|
||||
public void getBaseInfo(ISession session,MessageTypeProto.MessageType messageType){
|
||||
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);
|
||||
int challengeCount = count==null?0:Integer.parseInt(count);
|
||||
// 结束时间和挑战次数
|
||||
|
|
|
|||
|
|
@ -774,7 +774,7 @@ public class CombatLogic {
|
|||
}
|
||||
}else if (FourChallengeLogic.isFourChallengeTeam(teamId)){
|
||||
// 四灵试炼,助战
|
||||
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), teamPosHeroInfo.getHeroId());
|
||||
HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), teamPosHeroInfo.getHeroId());
|
||||
if (helpHero != null){
|
||||
hero = helpHero.getHero();
|
||||
}else {
|
||||
|
|
@ -835,7 +835,7 @@ public class CombatLogic {
|
|||
}
|
||||
// 四灵试炼
|
||||
if (FourChallengeLogic.isFourChallengeTeam(teamId)){
|
||||
HelpHero helpHero = HelpHeroLogic.getHelpHero(user.getId(), key.getHeroId());
|
||||
HelpHero helpHero = HelpHeroLogic.getHelpHeroByHeroId(user.getId(), key.getHeroId());
|
||||
if (helpHero != null){
|
||||
heroFind.add(helpHero.getHero().getTemplateId());
|
||||
continue;
|
||||
|
|
@ -845,7 +845,6 @@ public class CombatLogic {
|
|||
heroFind.add(hero.getTemplateId());
|
||||
}
|
||||
|
||||
|
||||
Map<Integer,Integer> propertiesMap = new HashMap<>();
|
||||
for(Integer heroId:heroFind){
|
||||
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)
|
||||
{
|
||||
List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet());
|
||||
Collections.sort(list, new Comparator<Map.Entry<K, V>>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2)
|
||||
{
|
||||
int compare = (o1.getValue()).compareTo(o2.getValue());
|
||||
return -compare;
|
||||
}
|
||||
list.sort((o1, o2) -> {
|
||||
int compare = (o1.getValue()).compareTo(o2.getValue());
|
||||
return -compare;
|
||||
});
|
||||
|
||||
Map<K, V> result = new LinkedHashMap<K, V>();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import manager.STableManager;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.CommonProto;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -57,7 +58,7 @@ public class HelpHeroLogic {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -72,10 +73,15 @@ public class HelpHeroLogic {
|
|||
HashSet<CommonProto.HelpFightList> result = new HashSet<>();
|
||||
|
||||
// 如果类型是自己,则使用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,助战英雄信息>
|
||||
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()){
|
||||
return result;
|
||||
}
|
||||
|
|
@ -132,7 +138,10 @@ public class HelpHeroLogic {
|
|||
}
|
||||
// 已选中的助战
|
||||
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())){
|
||||
result.add(CBean2Proto.helpHeroProto(helpHero));
|
||||
}
|
||||
|
|
@ -159,16 +168,15 @@ public class HelpHeroLogic {
|
|||
// 英雄类型
|
||||
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){
|
||||
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);
|
||||
|
|
@ -189,7 +197,8 @@ public class HelpHeroLogic {
|
|||
*/
|
||||
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 (helpHero != null){
|
||||
|
|
@ -199,7 +208,7 @@ public class HelpHeroLogic {
|
|||
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()) {
|
||||
// key
|
||||
int key = Integer.parseInt(data.getKey());
|
||||
|
|
@ -211,7 +220,7 @@ public class HelpHeroLogic {
|
|||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE, "不能使用自己的助战英雄!");
|
||||
}
|
||||
// 添加助战英雄
|
||||
addHelpHero(user.getId(),type,data.getValue());
|
||||
addHelpHero(subKey,type,data.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -221,7 +230,7 @@ public class HelpHeroLogic {
|
|||
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.getPlayerInfoManager().setHelpRewardNum(0);
|
||||
}
|
||||
|
||||
/***
|
||||
* 零点清理redis数据
|
||||
*/
|
||||
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));
|
||||
// 清理自己的助战信息
|
||||
String myKey = RedisUtil.getInstence().getKey(RedisKey.HELP_FIGHT, subKey(user.getId(), MY));
|
||||
RedisUtil.getInstence().del(myKey);
|
||||
String chooseKey = RedisUtil.getInstence().getKey(RedisKey.HELP_FIGHT, subKey(user.getId(), CHOOSE));
|
||||
RedisUtil.getInstence().del(chooseKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取选择得助战列表
|
||||
* @param uid
|
||||
* @return
|
||||
* 根据类型删除助战英雄
|
||||
* @param subKey
|
||||
* @param type
|
||||
*/
|
||||
public static Map<String,HelpHero> getHelpHeroMap(int uid){
|
||||
String subKey = getSubKey(uid,CHOOSE);
|
||||
return RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, subKey, String.class, HelpHero.class);
|
||||
public static void removeHelpHero(String subKey, int type){
|
||||
RedisUtil.getInstence().removeMapEntrys(RedisKey.HELP_FIGHT, subKey, String.valueOf(type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -298,8 +297,9 @@ public class HelpHeroLogic {
|
|||
* @param heroId
|
||||
* @return
|
||||
*/
|
||||
public static HelpHero getHelpHero(int uid,String heroId){
|
||||
Map<String, HelpHero> helpHeroMap = getHelpHeroMap(uid);
|
||||
public static HelpHero getHelpHeroByHeroId(int uid,String heroId){
|
||||
String subKey = HelpHeroLogic.subKey(uid,HelpHeroLogic.CHOOSE);
|
||||
Map<String, HelpHero> helpHeroMap = getHelpHeroMap(subKey);
|
||||
for (HelpHero value : helpHeroMap.values()) {
|
||||
if (value.getHero().getId().equals(heroId)){
|
||||
return value;
|
||||
|
|
@ -309,37 +309,34 @@ public class HelpHeroLogic {
|
|||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取助战英雄
|
||||
* @param uid
|
||||
* @param type
|
||||
* 获取选择得助战列表
|
||||
* @param subKey
|
||||
* @return
|
||||
*/
|
||||
public static HelpHero getHelpHeroByType(int uid, int type){
|
||||
String subKey = getSubKey(uid,CHOOSE);
|
||||
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));
|
||||
public static Map<String,HelpHero> getHelpHeroMap(String subKey){
|
||||
return RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, subKey, String.class, HelpHero.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加助战英雄
|
||||
* @param uid
|
||||
* @param subKey
|
||||
* @param type
|
||||
* @param helpHero
|
||||
*/
|
||||
public static void addHelpHero(int uid,int type,HelpHero helpHero){
|
||||
String subKey = getSubKey(uid,CHOOSE);
|
||||
public static void addHelpHero(String subKey, int type,HelpHero 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
|
||||
|
|
|
|||
|
|
@ -1120,7 +1120,7 @@ public class HeroLogic{
|
|||
if(heroManager.getHeroMap().containsKey(heroId.getHeroId())){
|
||||
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){
|
||||
set.add(helpHero.getHero().getTemplateId());
|
||||
}
|
||||
|
|
@ -1222,7 +1222,7 @@ public class HeroLogic{
|
|||
return "card not exists";
|
||||
}
|
||||
}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";
|
||||
}
|
||||
}else {
|
||||
|
|
@ -2367,7 +2367,7 @@ public class HeroLogic{
|
|||
|
||||
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){
|
||||
for (Jewel jewel : helpHero.getJewels()) {
|
||||
equipMap.put(jewel.getId(),jewel);
|
||||
|
|
@ -3063,7 +3063,7 @@ public class HeroLogic{
|
|||
Hero hero = targetUser.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
|
||||
if (hero == null) {
|
||||
// 助战获取,随后最好加上编队验证
|
||||
hero = HelpHeroLogic.getHelpHero(targetUser.getId(),teamPosHeroInfo.getHeroId()).getHero();
|
||||
hero = HelpHeroLogic.getHelpHeroByHeroId(targetUser.getId(),teamPosHeroInfo.getHeroId()).getHero();
|
||||
if (hero == null){
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,8 @@ public class CBean2Proto {
|
|||
public static List<CommonProto.HelpFightList> getHelpFightList(User user) throws Exception {
|
||||
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()){
|
||||
return lists;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,11 +69,11 @@ public class WorldServerApplication {
|
|||
// NetManager.getInstance().init();
|
||||
|
||||
|
||||
try {
|
||||
ArenaLogic.initRank();
|
||||
}catch (Exception e){
|
||||
LOGGER.info("ArenaLogic err ->{}", e);
|
||||
}
|
||||
// try {
|
||||
// ArenaLogic.initRank();
|
||||
// }catch (Exception e){
|
||||
// LOGGER.info("ArenaLogic err ->{}", e);
|
||||
// }
|
||||
|
||||
|
||||
bean = ConfigurableApplicationContextManager.getBean(WorldCoreSettings.class);
|
||||
|
|
|
|||
|
|
@ -1,69 +1,69 @@
|
|||
package com.world.handler;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.world.logic.rank.AbstractCrossRank;
|
||||
import com.world.logic.rank.DeathPathCrossEveryPersonRank;
|
||||
import com.world.redis.RedisKey;
|
||||
import com.world.redis.RedisUtil;
|
||||
import org.luaj.vm2.ast.Str;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import rpc.net.RpcMessage;
|
||||
import rpc.net.gtGBaseHandler;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/12/3
|
||||
* @discribe
|
||||
*/
|
||||
@Deprecated
|
||||
public class AddDeathPathRankRequestHandler extends gtGBaseHandler<WorldProto.AddDeathPathRankRequest>{
|
||||
|
||||
@Override
|
||||
public GeneratedMessage processWithProto(RpcMessage rpcMessage, WorldProto.AddDeathPathRankRequest proto) throws Exception {
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
//操作每个关的公会、个人数据
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(proto.getDamage())).divide(new BigDecimal(String.valueOf(Math.pow(10,15))));
|
||||
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){
|
||||
// decimal = decimal.add(new BigDecimal(0));
|
||||
//记录人数操作
|
||||
everyGuildChangeScore = everyGuildChangeScore+1;
|
||||
}
|
||||
|
||||
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);
|
||||
String after = firstGuild(redisUtil, proto.getGroupId(), proto.getPathId());
|
||||
if(!before.equals(after)){
|
||||
decimal = decimal.add(new BigDecimal(1));
|
||||
if(!"".equals(before)){
|
||||
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());
|
||||
|
||||
//package com.world.handler;
|
||||
//
|
||||
//import com.google.protobuf.GeneratedMessage;
|
||||
//import com.world.logic.rank.AbstractCrossRank;
|
||||
//import com.world.logic.rank.DeathPathCrossEveryPersonRank;
|
||||
//import com.world.redis.RedisKey;
|
||||
//import com.world.redis.RedisUtil;
|
||||
//import org.luaj.vm2.ast.Str;
|
||||
//import org.springframework.data.redis.core.ZSetOperations;
|
||||
//import rpc.net.RpcMessage;
|
||||
//import rpc.net.gtGBaseHandler;
|
||||
//import rpc.world.WorldProto;
|
||||
//
|
||||
//import java.math.BigDecimal;
|
||||
//import java.util.Set;
|
||||
//
|
||||
///**
|
||||
// * @author lvxinran
|
||||
// * @date 2020/12/3
|
||||
// * @discribe
|
||||
// */
|
||||
//@Deprecated
|
||||
//public class AddDeathPathRankRequestHandler extends gtGBaseHandler<WorldProto.AddDeathPathRankRequest>{
|
||||
//
|
||||
// @Override
|
||||
// public GeneratedMessage processWithProto(RpcMessage rpcMessage, WorldProto.AddDeathPathRankRequest proto) throws Exception {
|
||||
// RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
// //操作每个关的公会、个人数据
|
||||
// BigDecimal decimal = new BigDecimal(String.valueOf(proto.getDamage())).divide(new BigDecimal(String.valueOf(Math.pow(10,15))));
|
||||
// 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){
|
||||
//// decimal = decimal.add(new BigDecimal(0));
|
||||
// //记录人数操作
|
||||
// everyGuildChangeScore = everyGuildChangeScore+1;
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// String after = firstGuild(redisUtil, proto.getGroupId(), proto.getPathId());
|
||||
// if(!before.equals(after)){
|
||||
// decimal = decimal.add(new BigDecimal(1));
|
||||
// if(!"".equals(before)){
|
||||
// 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_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);
|
||||
|
||||
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():"";
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
//// 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_GUILD_RANK,"",String.valueOf(proto.getGuildId()), decimal.doubleValue());
|
||||
//
|
||||
// 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():"";
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,45 +1,45 @@
|
|||
package com.world.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.GuildInfoCache;
|
||||
import com.world.db.mongo.MongoUtil;
|
||||
import com.world.logic.rank.DeathPathCrossEveryGuildRank;
|
||||
import com.world.redis.RedisKey;
|
||||
import com.world.redis.RedisUtil;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import rpc.net.RpcMessage;
|
||||
import rpc.net.gtGBaseHandler;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/12/12
|
||||
* @discribe
|
||||
*/
|
||||
@Deprecated
|
||||
public class GetDeathPathFirstRequestHandler extends gtGBaseHandler<WorldProto.GetDeathPathFirstRequest> {
|
||||
|
||||
@Override
|
||||
public WorldProto.GetDeathPathFirstResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetDeathPathFirstRequest proto) throws Exception {
|
||||
|
||||
|
||||
DeathPathCrossEveryGuildRank deathPathCrossEveryGuildRank = new DeathPathCrossEveryGuildRank(RedisKey.DEATH_PATH_EVERY_GUILD_RANK);
|
||||
WorldProto.GetDeathPathFirstResponse.Builder response = WorldProto.GetDeathPathFirstResponse.newBuilder();
|
||||
/*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);
|
||||
Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
|
||||
if(!iterator.hasNext()){
|
||||
continue;
|
||||
}
|
||||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
int guildId = Integer.parseInt(next.getValue());
|
||||
GuildInfoCache crossGuild = deathPathCrossEveryGuildRank.getCrossGuild(guildId);
|
||||
String name = MongoUtil.getInstence().getServerNameById(crossGuild.getServerId());
|
||||
WorldProto.EvertDeathPath info = WorldProto.EvertDeathPath.newBuilder().setGuildName(crossGuild.getGuildName()).setPathId(i).setGid(guildId).setServerName(name).build();
|
||||
response.addDeathPathInfo(info);
|
||||
}*/
|
||||
return response.build();
|
||||
}
|
||||
}
|
||||
//package com.world.handler;
|
||||
//
|
||||
//import com.ljsd.jieling.logic.dao.GuildInfoCache;
|
||||
//import com.world.db.mongo.MongoUtil;
|
||||
//import com.world.logic.rank.DeathPathCrossEveryGuildRank;
|
||||
//import com.world.redis.RedisKey;
|
||||
//import com.world.redis.RedisUtil;
|
||||
//import org.springframework.data.redis.core.ZSetOperations;
|
||||
//import rpc.net.RpcMessage;
|
||||
//import rpc.net.gtGBaseHandler;
|
||||
//import rpc.world.WorldProto;
|
||||
//
|
||||
//import java.util.Iterator;
|
||||
//import java.util.Set;
|
||||
//
|
||||
///**
|
||||
// * @author lvxinran
|
||||
// * @date 2020/12/12
|
||||
// * @discribe
|
||||
// */
|
||||
//@Deprecated
|
||||
//public class GetDeathPathFirstRequestHandler extends gtGBaseHandler<WorldProto.GetDeathPathFirstRequest> {
|
||||
//
|
||||
// @Override
|
||||
// public WorldProto.GetDeathPathFirstResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetDeathPathFirstRequest proto) throws Exception {
|
||||
//
|
||||
//
|
||||
// DeathPathCrossEveryGuildRank deathPathCrossEveryGuildRank = new DeathPathCrossEveryGuildRank(RedisKey.DEATH_PATH_EVERY_GUILD_RANK);
|
||||
// WorldProto.GetDeathPathFirstResponse.Builder response = WorldProto.GetDeathPathFirstResponse.newBuilder();
|
||||
// /*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);
|
||||
// Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
|
||||
// if(!iterator.hasNext()){
|
||||
// continue;
|
||||
// }
|
||||
// ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
// int guildId = Integer.parseInt(next.getValue());
|
||||
// GuildInfoCache crossGuild = deathPathCrossEveryGuildRank.getCrossGuild(guildId);
|
||||
// String name = MongoUtil.getInstence().getServerNameById(crossGuild.getServerId());
|
||||
// WorldProto.EvertDeathPath info = WorldProto.EvertDeathPath.newBuilder().setGuildName(crossGuild.getGuildName()).setPathId(i).setGid(guildId).setServerName(name).build();
|
||||
// response.addDeathPathInfo(info);
|
||||
// }*/
|
||||
// return response.build();
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,38 +1,38 @@
|
|||
package com.world.handler;
|
||||
|
||||
import com.world.logic.arean.ArenaLogic;
|
||||
import com.world.logic.rank.DeathPathCrossEveryGuildRank;
|
||||
import com.world.logic.rank.DeathPathCrossEveryPersonRank;
|
||||
import com.world.logic.rank.DeathPathCrossTotalGuildRank;
|
||||
import com.world.redis.RedisKey;
|
||||
import rpc.net.RpcMessage;
|
||||
import rpc.net.gtGBaseHandler;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/12/3
|
||||
* @discribe
|
||||
*/
|
||||
public class GetRankRequestHandler extends gtGBaseHandler<WorldProto.GetRankRequest> {
|
||||
|
||||
@Override
|
||||
public PlayerInfoProto.RankResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetRankRequest proto) throws Exception {
|
||||
switch (proto.getType()){
|
||||
//package com.world.handler;
|
||||
//
|
||||
//import com.world.logic.arean.ArenaLogic;
|
||||
//import com.world.logic.rank.DeathPathCrossEveryGuildRank;
|
||||
//import com.world.logic.rank.DeathPathCrossEveryPersonRank;
|
||||
//import com.world.logic.rank.DeathPathCrossTotalGuildRank;
|
||||
//import com.world.redis.RedisKey;
|
||||
//import rpc.net.RpcMessage;
|
||||
//import rpc.net.gtGBaseHandler;
|
||||
//import rpc.protocols.PlayerInfoProto;
|
||||
//import rpc.world.WorldProto;
|
||||
//
|
||||
///**
|
||||
// * @author lvxinran
|
||||
// * @date 2020/12/3
|
||||
// * @discribe
|
||||
// */
|
||||
//public class GetRankRequestHandler extends gtGBaseHandler<WorldProto.GetRankRequest> {
|
||||
//
|
||||
// @Override
|
||||
// public PlayerInfoProto.RankResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetRankRequest proto) throws Exception {
|
||||
// switch (proto.getType()){
|
||||
// RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType();
|
||||
case 15:
|
||||
return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1);
|
||||
case 16:
|
||||
return new DeathPathCrossEveryGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1);
|
||||
case 17:
|
||||
return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK).getRank(proto.getUid(),"",1,-1);
|
||||
case 18:
|
||||
return new DeathPathCrossTotalGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK).getRank(proto.getUid(),"",1,-1);
|
||||
case 28:
|
||||
return ArenaLogic.getInstance().getRank(rpcMessage.getUid(),rpcMessage.getServerId());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// case 15:
|
||||
// return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1);
|
||||
// case 16:
|
||||
// return new DeathPathCrossEveryGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK).getRank(proto.getUid(),String.valueOf(proto.getAcitvityId()),1,-1);
|
||||
// case 17:
|
||||
// return new DeathPathCrossEveryPersonRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK).getRank(proto.getUid(),"",1,-1);
|
||||
// case 18:
|
||||
// return new DeathPathCrossTotalGuildRank(proto.getCrossId()+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK).getRank(proto.getUid(),"",1,-1);
|
||||
// case 28:
|
||||
// return ArenaLogic.getInstance().getRank(rpcMessage.getUid(),rpcMessage.getServerId());
|
||||
// default:
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -68,27 +68,27 @@ public class ArenaLogic {
|
|||
|
||||
public static void initRank() throws Exception {
|
||||
|
||||
Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
|
||||
serverSplit.forEach((s, integer) -> {
|
||||
HashSet<String> strings = map.getOrDefault(integer, new HashSet<>());
|
||||
strings.add(s);
|
||||
map.put(integer, strings);
|
||||
});
|
||||
ArenaLogic.serverSplit = serverSplit;
|
||||
|
||||
Set<String> keys = new HashSet<>();
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK:*", 200);
|
||||
while (cursor.hasNext()) {
|
||||
//找到一次就添加一次
|
||||
keys.add(cursor.next());
|
||||
}
|
||||
cursor.close();
|
||||
keys.forEach(k -> {
|
||||
HashMap<Integer, ArenaEnemy> object = RedisUtil.getInstence().getObject(k, new TypeToken<HashMap<Integer, ArenaEnemy>>() {
|
||||
}.getType());
|
||||
|
||||
ranInfo.put(Integer.valueOf(k.split(":")[1]), object);
|
||||
});
|
||||
// Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
|
||||
// serverSplit.forEach((s, integer) -> {
|
||||
// HashSet<String> strings = map.getOrDefault(integer, new HashSet<>());
|
||||
// strings.add(s);
|
||||
// map.put(integer, strings);
|
||||
// });
|
||||
// ArenaLogic.serverSplit = serverSplit;
|
||||
//
|
||||
// Set<String> keys = new HashSet<>();
|
||||
// Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK:*", 200);
|
||||
// while (cursor.hasNext()) {
|
||||
// //找到一次就添加一次
|
||||
// keys.add(cursor.next());
|
||||
// }
|
||||
// cursor.close();
|
||||
// keys.forEach(k -> {
|
||||
// HashMap<Integer, ArenaEnemy> object = RedisUtil.getInstence().getObject(k, new TypeToken<HashMap<Integer, ArenaEnemy>>() {
|
||||
// }.getType());
|
||||
//
|
||||
// ranInfo.put(Integer.valueOf(k.split(":")[1]), object);
|
||||
// });
|
||||
}
|
||||
|
||||
public void minCheck() {
|
||||
|
|
@ -139,27 +139,27 @@ public class ArenaLogic {
|
|||
}
|
||||
|
||||
private void onfinish(){
|
||||
map.clear();
|
||||
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
|
||||
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_MY_PRON, ""));
|
||||
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK_MY_MATH:*", -1);
|
||||
while (cursor.hasNext()) {
|
||||
String next = cursor.next();
|
||||
System.out.println("清除:"+next);
|
||||
delKeys.add(next);
|
||||
}
|
||||
Cursor<String> curso1 = RedisUtil.getInstence().scan("WORLD_ARENA_RRECORD:*", -1);
|
||||
while (curso1.hasNext()) {
|
||||
String next = curso1.next();
|
||||
System.out.println("清除:"+next);
|
||||
delKeys.add(next);
|
||||
}
|
||||
RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
|
||||
// map.clear();
|
||||
//
|
||||
// List<String> delKeys = new ArrayList<>();
|
||||
//
|
||||
// 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_MY_PRON, ""));
|
||||
//
|
||||
// Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_RANK_MY_MATH:*", -1);
|
||||
// while (cursor.hasNext()) {
|
||||
// String next = cursor.next();
|
||||
// System.out.println("清除:"+next);
|
||||
// delKeys.add(next);
|
||||
// }
|
||||
// Cursor<String> curso1 = RedisUtil.getInstence().scan("WORLD_ARENA_RRECORD:*", -1);
|
||||
// while (curso1.hasNext()) {
|
||||
// String next = curso1.next();
|
||||
// System.out.println("清除:"+next);
|
||||
// delKeys.add(next);
|
||||
// }
|
||||
// RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -357,12 +357,12 @@ public class ArenaLogic {
|
|||
* 零点重置
|
||||
*/
|
||||
public static void clearReidsInTime() {
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_MY_PRON:*", -1);
|
||||
while (cursor.hasNext()) {
|
||||
delKeys.add(cursor.next());
|
||||
}
|
||||
RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
|
||||
// List<String> delKeys = new ArrayList<>();
|
||||
// Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_MY_PRON:*", -1);
|
||||
// while (cursor.hasNext()) {
|
||||
// delKeys.add(cursor.next());
|
||||
// }
|
||||
// RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ public class RedisKey {
|
|||
|
||||
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_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_EVERY_GUILD_RANK = "DEATH_PATH_EVERY_GUILD_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_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 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 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_ROBOT = "ARENA_PROUD_COUNT_ROBOT";
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -33,7 +33,7 @@ public class MinuteTask extends Thread {
|
|||
}
|
||||
try {
|
||||
LOGGER.info("MinuteTask start...");
|
||||
ArenaLogic.getInstance().minCheck();
|
||||
// ArenaLogic.getInstance().minCheck();
|
||||
|
||||
LOGGER.info("MinuteTask end...");
|
||||
} catch (Exception e) {
|
||||
|
|
@ -55,11 +55,11 @@ public class MinuteTask extends Thread {
|
|||
}catch (Exception e){
|
||||
LOGGER.info("MongoUtil err ->{}", e);
|
||||
}
|
||||
try {
|
||||
ArenaLogic.clearReidsInTime();
|
||||
}catch (Exception e){
|
||||
LOGGER.info("clearReidsInTime err ->{}", e);
|
||||
}
|
||||
// try {
|
||||
// ArenaLogic.clearReidsInTime();
|
||||
// }catch (Exception e){
|
||||
// LOGGER.info("clearReidsInTime err ->{}", e);
|
||||
// }
|
||||
|
||||
LOGGER.info("DailyOfZeroTask end ...");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue