Merge branch 'master_test_gn_arena' into master_test_gn_zbh
commit
f96554fee5
|
@ -836,6 +836,28 @@ public class TimeUtils {
|
|||
return c.getTimeInMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定时间周星期几的0点时间
|
||||
* @param hour
|
||||
* @param targetWeekday
|
||||
* @return
|
||||
*/
|
||||
public static long getCurWeekdayByTime(int targetWeekday,int hour,long time) {
|
||||
if(targetWeekday<1||targetWeekday>7){
|
||||
return -1;
|
||||
}
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTimeInMillis(time);
|
||||
int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (day_of_week == 0)
|
||||
day_of_week = 7;
|
||||
c.add(Calendar.DATE, -day_of_week + targetWeekday);
|
||||
c.set(Calendar.HOUR_OF_DAY,hour);
|
||||
c.set(Calendar.SECOND,0);
|
||||
c.set(Calendar.MINUTE,0);
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前月份第几天0点时间戳
|
||||
*/
|
||||
|
@ -1565,7 +1587,24 @@ public class TimeUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间相差的几个月
|
||||
* 是否经过指定时间的几周
|
||||
* 指定时间距离指定时间周末为一周
|
||||
* @param before
|
||||
* @param after
|
||||
* @param week
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAfterTimeByWeek(long before, long after, int week) {
|
||||
// 开始时间
|
||||
long startTime = getCurWeekdayByTime(1, 0, before);
|
||||
// 当前时间
|
||||
long nowTime = getCurWeekdayByTime(1, 0, after);
|
||||
// 间隔时间
|
||||
long weekTime = week * WEEK;
|
||||
// 结果
|
||||
return nowTime - startTime >= weekTime;
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static long getGapMonthsByTwoTime(String startTime,String endTime){
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.io.*;
|
|||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -43,7 +45,7 @@ public class Utils {
|
|||
return b;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* MD5 加密
|
||||
* */
|
||||
public static String MD5(String inStr) {
|
||||
|
@ -74,8 +76,7 @@ public class Utils {
|
|||
return hexValue.toString();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* 获取随机字符串
|
||||
* */
|
||||
public static String getRandStr(int num){
|
||||
|
@ -93,7 +94,18 @@ public class Utils {
|
|||
}
|
||||
|
||||
/**
|
||||
* 对象拷贝 只要实现了Serializable接口都可以
|
||||
* 取出字符串中的数字
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
public static String getIntByString(String string){
|
||||
String regEx = "[^0-9]";
|
||||
Pattern pattern = Pattern.compile(regEx);
|
||||
Matcher matcher = pattern.matcher(string);
|
||||
return matcher.replaceAll("").trim();
|
||||
}
|
||||
|
||||
/** 对象拷贝 只要实现了Serializable接口都可以
|
||||
* @param obj
|
||||
* @param <T>
|
||||
* @return
|
||||
|
|
|
@ -13,6 +13,9 @@ public class CServerInfo {
|
|||
@Field(value = "server_id")
|
||||
private int serverId;
|
||||
|
||||
@Field(value = "name")
|
||||
private String name;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -28,4 +31,12 @@ public class CServerInfo {
|
|||
public void setServerId(int serverId) {
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,6 +198,8 @@ public class RedisKey {
|
|||
|
||||
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 QUESTION_FROMBACK = "QUESTION_FROMBACK";
|
||||
|
||||
|
|
|
@ -921,17 +921,22 @@ public class RedisUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Set<ZSetOperations.TypedTuple<String>> getZsetreverseRangeWithScores(String type,String key, long start, long end){
|
||||
String rkey = getKey(type, key);
|
||||
public Set<ZSetOperations.TypedTuple<String>> getZsetreverseRangeWithScores(String type,String key, long start, long end, boolean judge){
|
||||
String rkey = getKey(type, key, judge);
|
||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||
try {
|
||||
return redisTemplate.opsForZSet().reverseRangeWithScores(rkey, start, end);
|
||||
return redisTemplate.opsForZSet().reverseRangeWithScores(rkey, start, end);
|
||||
} catch (Exception e) {
|
||||
TimeUtils.sleep(FAILED_SLEEP);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<ZSetOperations.TypedTuple<String>> getZsetreverseRangeWithScores(String type,String key, long start, long end){
|
||||
return getZsetreverseRangeWithScores(type,key,start,end,true);
|
||||
}
|
||||
|
||||
//按分组来取,不需要加服务器和小key
|
||||
public Set<ZSetOperations.TypedTuple<String>> getZsetreverseRangeByRangeWithScores(String type, long start, long end){
|
||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||
|
@ -1032,6 +1037,7 @@ public class RedisUtil {
|
|||
public void incrementZsetScore(String type,String key, String value, int changeScore){
|
||||
incrementZsetScore(type,key,value,(double)(changeScore));
|
||||
}
|
||||
|
||||
public void incrementZsetScore(String type,String key, String value, double changeScore){
|
||||
String rkey = getKey(type, key);
|
||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||
|
@ -1278,35 +1284,41 @@ public class RedisUtil {
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getKey(String type,String key){
|
||||
return getKey(type,key,true);
|
||||
}
|
||||
|
||||
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)) {
|
||||
public String getKey(String type,String key,boolean judge){
|
||||
if (!judge){
|
||||
return type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
// if(RedisKey.familyKey.contains(type)){
|
||||
// return GameApplication.serverProperties.getAreaId()+ RedisKey.Delimiter_colon+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;
|
||||
}
|
||||
|
||||
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)){
|
||||
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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return AreaManager.areaId+ RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
return AreaManager.areaId+ RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
* @Date 2021/7/28 16:36:26
|
||||
* @Description: 跨服信息
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class GetCrossServerHandler extends BaseHandler<PlayerInfoProto.IsCrossRequert> {
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GetCrossServerRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratedMessage processWithProto(int uid, PlayerInfoProto.IsCrossRequert proto) throws Exception {
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
int result = crossGroup == -1 ? 0 : 1;
|
||||
return PlayerInfoProto.IsCrossResponse.newBuilder().setIsCross(result).build();
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,6 @@ public class RankHandler extends BaseHandler<PlayerInfoProto.RankRequest> {
|
|||
@Override
|
||||
public void processWithProto(ISession iSession, PlayerInfoProto.RankRequest proto) throws Exception {
|
||||
RankLogic.getInstance().getRank(iSession,proto.getType(),proto.getActiviteId(),
|
||||
proto.getIndex(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
|
||||
proto.getIndex(),proto.getIsCross(),MessageTypeProto.MessageType.GET_ONE_RANK_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ public class PlayWithSbHandler extends BaseHandler<ArenaInfoProto.PlayWithSbRequ
|
|||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, ArenaInfoProto.PlayWithSbRequest proto) throws Exception {
|
||||
ArenaLogic.getInstance().playWithSb(iSession,proto.getChallengeUid(),proto.getMyteamId());
|
||||
ArenaLogic.getInstance().playWithSb(iSession,proto.getChallengeUid(),proto.getMyteamId(),proto.getCross());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.ljsd.jieling.logic.dao.*;
|
|||
import com.ljsd.jieling.logic.dao.gm.*;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.CrossDeathPathLogic;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -38,12 +39,8 @@ public class CrossServiceLogic {
|
|||
return CrossServiceLogic.Instance.instance;
|
||||
}
|
||||
|
||||
public String findServerName(int serverId) throws UnknownHostException {
|
||||
MongoTemplate core = MongoUtil.getCoreMongoTemplate();
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("server_id").is(String.valueOf(serverId)));
|
||||
CoreOfServerInfo one = core.findOne(query, CoreOfServerInfo.class);
|
||||
return one==null?String.valueOf(serverId):one.getName();
|
||||
public String findServerName(int serverId) {
|
||||
return CrossDeathPathLogic.getInstance().getServerName(serverId);
|
||||
}
|
||||
|
||||
public void insert(ArenaOfUser arenaOfUser) throws UnknownHostException {
|
||||
|
@ -146,11 +143,7 @@ public class CrossServiceLogic {
|
|||
arenaOfPlayerManager.setGender(player.getSex());
|
||||
arenaOfPlayerManager.setSkin(player.getUserSkin());
|
||||
arenaOfPlayerManager.setUserMount(player.getUserMount());
|
||||
try {
|
||||
arenaOfPlayerManager.setServerName(CrossServiceLogic.getInstance().findServerName(GameApplication.serverId));
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
arenaOfPlayerManager.setServerName(CrossServiceLogic.getInstance().findServerName(GameApplication.serverId));
|
||||
return arenaOfPlayerManager;
|
||||
}
|
||||
private ArenaOfHeroManager buildArenaOfHeroManager(User user){
|
||||
|
@ -200,4 +193,23 @@ public class CrossServiceLogic {
|
|||
return arenaOfHero;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据uid获取服务器名称
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
public String getServerNameByUId(int uid){
|
||||
String name = "";
|
||||
try {
|
||||
ArenaOfUser query = query(uid);
|
||||
if (query != null){
|
||||
int serverId = query.getPlayerManager().getServerId();
|
||||
return CrossDeathPathLogic.getInstance().getServerNameByDeathPath(serverId);
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
LOGGER.error("===========获取跨服玩家信息报错=======:{}",e.getMessage());
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -626,18 +626,27 @@ public class ArenaLogic {
|
|||
}
|
||||
}
|
||||
|
||||
public void playWithSb(ISession session,int challengeUid,int myteamId) throws Exception {
|
||||
//0为本服 1为跨服
|
||||
public void playWithSb(ISession session,int challengeUid,int myteamId,int cross) throws Exception {
|
||||
User mine = UserManager.getUser(session.getUid());
|
||||
User defUser = UserManager.getUser(challengeUid);
|
||||
if(!defUser.getTeamPosManager().getTeamPosForHero().containsKey(1)){
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("对方未设置阵容"));
|
||||
}
|
||||
|
||||
int myforce = HeroLogic.getInstance().calTeamTotalForce(mine, myteamId, false);
|
||||
int deforce = HeroLogic.getInstance().calTeamTotalForce(defUser, 1, false);
|
||||
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(mine,myteamId,true);
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = BehaviorUtil.getFightTeamInfo(defUser,1,false);
|
||||
CommonProto.FightTeamInfo deffightTeamInfo = null;
|
||||
int deforce;
|
||||
if(cross==0){
|
||||
User defUser = UserManager.getUser(challengeUid);
|
||||
if(!defUser.getTeamPosManager().getTeamPosForHero().containsKey(1)){
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("对方未设置阵容"));
|
||||
}
|
||||
deforce = HeroLogic.getInstance().calTeamTotalForce(defUser, 1, false);
|
||||
deffightTeamInfo= BehaviorUtil.getFightTeamInfo(defUser,1,false);
|
||||
|
||||
}else{
|
||||
//跨服切磋
|
||||
ArenaOfUser user = CrossServiceLogic.getInstance().query(challengeUid);
|
||||
deforce= user.getHeroManager().getTotalForce();
|
||||
deffightTeamInfo = FightUtil.makeCrossPersonData(user);
|
||||
}
|
||||
if(myforce<deforce){
|
||||
deffightTeamInfo = CommonProto.FightTeamInfo.newBuilder().mergeFrom(deffightTeamInfo).setFirstCamp(1).build();
|
||||
}
|
||||
|
@ -984,22 +993,17 @@ public class ArenaLogic {
|
|||
int enemyId = enemy.getEnemyId();
|
||||
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(enemyId);
|
||||
CommonProto.Team teamBuild = CommonProto.Team.newBuilder().addAllHeroTid(sArenaRobotConfig.getHeroList()).build();
|
||||
CommonProto.ArenaPersonInfo personInfoBuild = null;
|
||||
try {
|
||||
personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
.setUid(enemy.getEnemyId_UUid())
|
||||
.setLevel(sArenaRobotConfig.getRobotLevel())
|
||||
.setName(enemy.getRandomName()==null?"":enemy.getRandomName())
|
||||
.setScore(sArenaRobotConfig.getRobotScore())
|
||||
.setTotalForce(sArenaRobotConfig.getTotalForce())
|
||||
.setServername(CrossServiceLogic.getInstance().findServerName(enemy.getServerID()))
|
||||
.setUserSkin(80012)
|
||||
.setGender(enemy.isGender()?1:0)
|
||||
.setRank(rank)
|
||||
.build();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
.setUid(enemy.getEnemyId_UUid())
|
||||
.setLevel(sArenaRobotConfig.getRobotLevel())
|
||||
.setName(enemy.getRandomName()==null?"":enemy.getRandomName())
|
||||
.setScore(sArenaRobotConfig.getRobotScore())
|
||||
.setTotalForce(sArenaRobotConfig.getTotalForce())
|
||||
.setServername(CrossServiceLogic.getInstance().findServerName(enemy.getServerID()))
|
||||
.setUserSkin(80012)
|
||||
.setGender(enemy.isGender()?1:0)
|
||||
.setRank(rank)
|
||||
.build();
|
||||
return CommonProto.ArenaEnemy.newBuilder()
|
||||
.setPersonInfo(personInfoBuild)
|
||||
.setWorshipTime(proudTime)
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.mongo.core.CServerInfo;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.dao.GuildInfoCache;
|
||||
import com.ljsd.jieling.tools.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
* @Date 2021/7/16 18:01
|
||||
* @Description: 跨服十绝阵
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class CrossDeathPathLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CrossDeathPathLogic.class);
|
||||
|
||||
private CrossDeathPathLogic(){}
|
||||
|
||||
public static class CrossDeathPathLogicInstance {
|
||||
public final static CrossDeathPathLogic instance = new CrossDeathPathLogic();
|
||||
}
|
||||
|
||||
public static CrossDeathPathLogic getInstance() {
|
||||
return CrossDeathPathLogic.CrossDeathPathLogicInstance.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跨服公会缓存
|
||||
*/
|
||||
private static Map<Integer, GuildInfoCache> crossGuildMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 服务器列表缓存
|
||||
*/
|
||||
private volatile Map<Integer, CServerInfo> cServerInfoMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 服务器初始化
|
||||
*/
|
||||
public void serverInit() {
|
||||
try {
|
||||
MongoTemplate core = MongoUtil.getCoreMongoTemplate();
|
||||
List<CServerInfo> cServerInfos = core.findAll(CServerInfo.class);
|
||||
Map<Integer,CServerInfo> serverInfoMap = new HashMap<>(cServerInfos.size());
|
||||
cServerInfos.forEach(n->serverInfoMap.put(n.getServerId(),n));
|
||||
cServerInfoMap = serverInfoMap;
|
||||
} catch (UnknownHostException e) {
|
||||
LOGGER.error("=========跨服服务器列表获取失败=======:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页公会
|
||||
* @param redisUtil
|
||||
* @param groupId
|
||||
* @param pathId
|
||||
* @return
|
||||
*/
|
||||
private String firstGuild(RedisUtil redisUtil, int groupId, int pathId){
|
||||
String key = groupId + ":" + RedisKey.DEATH_PATH_EVERY_GUILD_RANK;
|
||||
Set<ZSetOperations.TypedTuple<String>> scores = redisUtil
|
||||
.getZsetreverseRangeWithScores(key, String.valueOf(pathId), 0, 0,false);
|
||||
return scores.iterator().hasNext()?scores.iterator().next().getValue():"";
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加跨服排行
|
||||
* @param uid
|
||||
* @param damage
|
||||
* @param guildId
|
||||
* @param groupId
|
||||
* @param pathId
|
||||
*/
|
||||
void addCrossDeathPathRank(int uid, int damage, int guildId, int groupId, int pathId){
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
//操作每个关的公会、个人数据
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(damage)).divide(new BigDecimal(String.valueOf(Math.pow(10,15))));
|
||||
long everyGuildChangeScore = (long)damage*1000;
|
||||
if(redisUtil.getZSetScore(groupId+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(pathId), String.valueOf(uid))==-1){
|
||||
//记录人数操作
|
||||
everyGuildChangeScore = everyGuildChangeScore+1;
|
||||
}
|
||||
|
||||
String before = firstGuild(redisUtil, groupId, pathId);
|
||||
redisUtil.incrementZsetScore(groupId+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK,String.valueOf(pathId),String.valueOf(guildId), everyGuildChangeScore);
|
||||
String after = firstGuild(redisUtil, groupId, pathId);
|
||||
if(!before.equals(after)){
|
||||
decimal = decimal.add(new BigDecimal(1));
|
||||
if(!"".equals(before)){
|
||||
redisUtil.incrementZsetScore(groupId+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,"",before, -1);
|
||||
}
|
||||
}
|
||||
// 个人单个排行
|
||||
redisUtil.incrementZsetScore(groupId+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK,String.valueOf(pathId),String.valueOf(uid), damage);
|
||||
//操作总的个人伤害
|
||||
redisUtil.incrementZsetScore(groupId+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,"",String.valueOf(uid), damage);
|
||||
//操作总的工会伤害
|
||||
redisUtil.incrementZsetScore(groupId+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,"",String.valueOf(guildId), decimal.doubleValue());
|
||||
// 结算标识设置
|
||||
redisUtil.hset(RedisKey.DEATH_PATH_EVERY_OVER_HASH,String.valueOf(GameApplication.serverId),1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公会缓存
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static GuildInfoCache getCrossGuild(int id){
|
||||
GuildInfoCache crossGuild = crossGuildMap.get(id);
|
||||
if(crossGuild==null){
|
||||
crossGuild = RedisUtil.getInstence().getMapEntry(RedisKey.GUILD_INFO_CACHE, "", String.valueOf(id), GuildInfoCache.class);
|
||||
crossGuildMap.put(id,crossGuild);
|
||||
}
|
||||
return crossGuild;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器名字
|
||||
* @param serverId
|
||||
* @return
|
||||
*/
|
||||
public String getServerName(int serverId){
|
||||
CServerInfo cServerInfo = cServerInfoMap.get(serverId);
|
||||
if(cServerInfo==null){
|
||||
return String.valueOf(serverId);
|
||||
}
|
||||
return cServerInfo.getName();
|
||||
}
|
||||
|
||||
public String getServerNameByDeathPath(int serverId){
|
||||
String name = getServerName(serverId);
|
||||
return Utils.getIntByString(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 跨服排行奖励
|
||||
* @param groupId
|
||||
* @param serverId
|
||||
* @return
|
||||
*/
|
||||
public Map<Integer,Integer> crossDeathPathReward(int groupId,int serverId){
|
||||
if(TimeUtils.getHourOfDay()!=0){
|
||||
return new HashMap<>();
|
||||
}
|
||||
Set<ZSetOperations.TypedTuple<String>> values = RedisUtil.getInstence().getZsetreverseRangeWithScores(groupId+":" + RedisKey.DEATH_PATH_TOTAL_GUILD_RANK, "", 0, -1);
|
||||
HashMap<Integer, Integer> hashMap = new HashMap<>();
|
||||
int rank =0;
|
||||
for(ZSetOperations.TypedTuple<String> value:values){
|
||||
rank++;
|
||||
int guildId = Integer.valueOf(value.getValue());
|
||||
GuildInfoCache guild = getCrossGuild(guildId);
|
||||
if(guild==null||guild.getServerId()!=serverId){
|
||||
continue;
|
||||
}
|
||||
hashMap.put(rank,guildId);
|
||||
}
|
||||
RedisUtil.getInstence().hdel(RedisKey.DEATH_PATH_EVERY_OVER_HASH,String.valueOf(serverId));
|
||||
|
||||
Map<Object, Object> hmget = RedisUtil.getInstence().hmget(RedisKey.DEATH_PATH_EVERY_OVER_HASH);
|
||||
if (hmget == null || hmget.size() < 1) {
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan(groupId + ":DEATH_PATH*", -1);
|
||||
while (cursor.hasNext()) {
|
||||
//找到一次就添加一次
|
||||
String next = cursor.next();
|
||||
LOGGER.info("=================删除跨服十绝阵排行:{}", next);
|
||||
RedisUtil.getInstence().del(next);
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import com.ljsd.jieling.exception.ErrorCodeException;
|
|||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
|
@ -24,7 +25,6 @@ import com.ljsd.jieling.logic.mission.GameEvent;
|
|||
import com.ljsd.jieling.logic.rank.RankContext;
|
||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
|
||||
import com.ljsd.jieling.network.server.WorldHelper;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
@ -40,7 +40,6 @@ import org.springframework.data.redis.core.ZSetOperations;
|
|||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.Family;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.world.WorldProto;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
|
@ -72,10 +71,11 @@ public class DeathPathLogic {
|
|||
|
||||
private Thread taskExecutor = null;
|
||||
|
||||
//是否跨服
|
||||
/**
|
||||
* 是否跨服
|
||||
*/
|
||||
private int groupId;
|
||||
|
||||
|
||||
private BlockingQueue<DeathPathTask> tasks = new BlockingUniqueQueue<>();
|
||||
|
||||
public static class DeathPathLogicInstance {
|
||||
|
@ -86,6 +86,12 @@ public class DeathPathLogic {
|
|||
return DeathPathLogic.DeathPathLogicInstance.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 0: 未开启
|
||||
* 1: 开启
|
||||
* 2: 领奖
|
||||
*/
|
||||
private int status = 0;
|
||||
|
||||
public int getStatus() {
|
||||
|
@ -172,6 +178,10 @@ public class DeathPathLogic {
|
|||
}
|
||||
this.firstStartTime = firstStartTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启
|
||||
*/
|
||||
private void isOpen(){
|
||||
int dayOfWeek = TimeUtils.getDayOfWeek();
|
||||
int currStatus=0;
|
||||
|
@ -180,9 +190,10 @@ public class DeathPathLogic {
|
|||
if(dayStats==-1){
|
||||
//领奖阶段
|
||||
currStatus = 2;
|
||||
// if(groupId==0&&GlobalidHelper.getWorldInfo().getMyGroup()!=-1){
|
||||
// groupId = GlobalidHelper.getWorldInfo().getMyGroup();
|
||||
// }
|
||||
if(groupId==0 && isOpenCrossDeathPath()){
|
||||
groupId = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
LOGGER.info("========================跨服十绝阵开启:{}",groupId);
|
||||
}
|
||||
}else if (dayStats==1){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hourOfDay = TimeUtils.getHourOfDay();
|
||||
|
@ -192,7 +203,6 @@ public class DeathPathLogic {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
int tempSmall = guildWarTime[0][0]*100+guildWarTime[0][1];
|
||||
|
||||
int tempBig = guildWarTime[1][0]*100+guildWarTime[1][1];
|
||||
|
@ -207,10 +217,12 @@ public class DeathPathLogic {
|
|||
if(currStatus!=status){
|
||||
status = currStatus;
|
||||
switch (status){
|
||||
// 活动结束
|
||||
case 0:
|
||||
try {
|
||||
deleteDeathPathInfo();
|
||||
groupId = 0;
|
||||
LOGGER.info("========================跨服十绝阵关闭:{}",groupId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -223,7 +235,10 @@ public class DeathPathLogic {
|
|||
taskExecutor = new DeathPathExecutor(tasks);
|
||||
taskExecutor.start();
|
||||
}
|
||||
// groupId = GlobalidHelper.getWorldInfo().getMyGroup();
|
||||
if(isOpenCrossDeathPath()){
|
||||
groupId = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
LOGGER.info("========================跨服十绝阵开启:{}",groupId);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
long appointTime = TimeUtils.getAppointTime(0, 0)+TimeUtils.DAY;
|
||||
|
@ -234,17 +249,16 @@ public class DeathPathLogic {
|
|||
overTime = (int)(appointTime/1000);
|
||||
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||
Set<ZSetOperations.TypedTuple<String>> firstGuild = guildTotalRank.getRankByKey("", 0, 1);
|
||||
if(firstGuild.isEmpty()||firstGuild.size()>1){
|
||||
if(firstGuild.size() != 1){
|
||||
break;
|
||||
}
|
||||
String gid = firstGuild.iterator().next().getValue();
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(Integer.parseInt(gid));
|
||||
String message = SErrorCodeEerverConfig.getI18NMessageNeedConvert("guildwar_content", new Object[]{guildInfo.getName()},new int[]{0});
|
||||
ChatLogic.getInstance().sendSysChatMessage(message, Global.DEATH_PATH_FIRST, "", 0, 0, 0, 0, 0);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
LOGGER.info("十绝阵状态修改-------");
|
||||
//阶段信息改变发送推送
|
||||
|
@ -282,33 +296,34 @@ public class DeathPathLogic {
|
|||
int uid = session.getUid();
|
||||
String count = (String) RedisUtil.getInstence().get(RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT, String.valueOf(uid), false));
|
||||
int challengeCount = count==null?0:Integer.parseInt(count);
|
||||
Family.GetDeathPathInfoResponse.Builder response = Family.GetDeathPathInfoResponse.newBuilder().setOverTime(overTime)
|
||||
.setChallengeCount(challengeCount);
|
||||
if(groupId>0){
|
||||
//如果是跨服
|
||||
WorldProto.GetDeathPathFirstResponse worldResponse = WorldHelper.sendMessageToWorldWithResult(uid, WorldProto.GetDeathPathFirstRequest.newBuilder().setGroupId(groupId).build(), WorldProto.GetDeathPathFirstResponse.class);
|
||||
if(worldResponse==null||worldResponse.getDeathPathInfoList()==null){
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
return;
|
||||
// 结束时间和挑战次数
|
||||
Family.GetDeathPathInfoResponse.Builder response = Family.GetDeathPathInfoResponse.newBuilder()
|
||||
.setOverTime(overTime).setChallengeCount(challengeCount);
|
||||
// 排行榜抽象类
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
// 取前十
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
String key;
|
||||
// 是否是跨服
|
||||
if (groupId > 0) {
|
||||
key = groupId + ":" + guildRank.getRedisKey();
|
||||
LOGGER.info("========================获取十绝阵内部信息,跨服:{}",uid);
|
||||
} else {
|
||||
key = guildRank.getRedisKey();
|
||||
LOGGER.info("========================获取十绝阵内部信息,本地:{}",uid);
|
||||
}
|
||||
for(WorldProto.EvertDeathPath every :worldResponse.getDeathPathInfoList()){
|
||||
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(every.getGuildName()).setPathId(every.getPathId()).setGid(every.getGid()).setServerName(every.getServerName()).build();
|
||||
response.addInfos(info);
|
||||
}
|
||||
}else{
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
for(int i = 1 ;i<=10;i++){
|
||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), 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());
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(guildInfo.getName()).setPathId(i).setGid(guildId).build();
|
||||
response.addInfos(info);
|
||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(key, 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());
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
Integer serverId = Optional.ofNullable(CrossDeathPathLogic.getCrossGuild(guildId)).map(GuildInfoCache::getServerId).orElse(0);
|
||||
String serverName = CrossDeathPathLogic.getInstance().getServerNameByDeathPath(serverId);
|
||||
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(guildInfo.getName()).setPathId(i).setGid(guildId).setServerName(serverName).build();
|
||||
response.addInfos(info);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
|
||||
|
@ -353,13 +368,13 @@ public class DeathPathLogic {
|
|||
RedisUtil.getInstence().increment(RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT,String.valueOf(uid),false));
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
|
||||
// 跨服十绝阵添加
|
||||
GuildInfoCache guildInfoCache = new GuildInfoCache();
|
||||
|
||||
guildInfoCache.setGuildId(guildId);
|
||||
guildInfoCache.setGuildName(guildInfo.getName());
|
||||
guildInfoCache.setServerId(GameApplication.serverId);
|
||||
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.GUILD_INFO_CACHE,"",String.valueOf(guildId),guildInfoCache);
|
||||
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, config.getReward(), BIReason.DEATH_PATH_CHALLENGE);
|
||||
Map<Integer, Integer> deathMaxDamage = user.getGuildMyInfo().getDeathMaxDamage();
|
||||
int maxDamage = deathMaxDamage.getOrDefault(pathId, 0);
|
||||
|
@ -394,7 +409,6 @@ public class DeathPathLogic {
|
|||
}
|
||||
private void taskDoExecute(DeathPathTask task){
|
||||
|
||||
|
||||
DeathChallengeCount countInfo = RedisUtil.getInstence().get(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, String.valueOf(task.getGuildId()), DeathChallengeCount.class);
|
||||
if (countInfo==null){
|
||||
countInfo = new DeathChallengeCount();
|
||||
|
@ -407,10 +421,10 @@ public class DeathPathLogic {
|
|||
//跨服
|
||||
if(task.getGroupId()>0){
|
||||
try {
|
||||
WorldHelper.sendMessageToWorldWithResult(task.getUid(), WorldProto.AddDeathPathRankRequest.newBuilder()
|
||||
.setDamage(task.getDamage()).setGroupId(task.getGroupId()).setPathId(task.getPathId()).setUid(task.getUid())
|
||||
.setGuildId(task.getGuildId()).build(), WorldProto.AddDeathPathRankResponse.class);
|
||||
CrossDeathPathLogic.getInstance().addCrossDeathPathRank(task.getUid(),task.getDamage(),task.getGuildId(),task.getGroupId(),task.getPathId());
|
||||
LOGGER.info("==================跨服十绝阵上榜处理:{}",task.toString());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("==================跨服十绝阵上榜异常:{}",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
|
@ -421,7 +435,6 @@ public class DeathPathLogic {
|
|||
|
||||
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType());
|
||||
|
||||
|
||||
//操作总的个人伤害
|
||||
AbstractRank personTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType());
|
||||
personTotalRank.addRank(task.getUid(),"",task.getDamage());
|
||||
|
@ -536,17 +549,17 @@ public class DeathPathLogic {
|
|||
//您已领取过奖励
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
// 根据排名进行随机奖励
|
||||
//根据排名进行随机奖励
|
||||
int rank;
|
||||
String key;
|
||||
if(groupId>0){
|
||||
WorldProto.GetDeathPathRewardResponse worldResponse = WorldHelper.sendMessageToWorldWithResult(uid, WorldProto.GetDeathPathRewardRequest.newBuilder().setGroupId(groupId).setGuildId(user.getPlayerInfoManager().getGuildId()).build(), WorldProto.GetDeathPathRewardResponse.class);
|
||||
if(worldResponse==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
rank = worldResponse.getRankTotal();
|
||||
key = groupId + ":" + RedisKey.DEATH_PATH_TOTAL_GUILD_RANK;
|
||||
LOGGER.info("==================获取十绝阵奖励,跨服,分组:{},玩家:{}",groupId,uid);
|
||||
}else {
|
||||
rank = RedisUtil.getInstence().getZSetreverseRank(RedisKey.DEATH_PATH_TOTAL_GUILD_RANK, "", String.valueOf(user.getPlayerInfoManager().getGuildId())).intValue();
|
||||
key = RedisKey.DEATH_PATH_TOTAL_GUILD_RANK;
|
||||
LOGGER.info("==================获取十绝阵奖励,本地,分组:{},玩家:{}",groupId,uid);
|
||||
}
|
||||
rank = RedisUtil.getInstence().getZSetreverseRank(key, "", String.valueOf(user.getPlayerInfoManager().getGuildId())).intValue();
|
||||
if(rank==-1||rank==0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
@ -579,24 +592,30 @@ public class DeathPathLogic {
|
|||
int[] reward= rewardArray[nextDiscrete(randomArray)];
|
||||
return new int[]{reward[0],reward[1]};
|
||||
}
|
||||
//清除排行信息
|
||||
|
||||
/**
|
||||
* 清除排行信息
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deleteDeathPathInfo() throws Exception {
|
||||
// redis工具
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
// 邮件标题和内容
|
||||
String mailTitle = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_title");
|
||||
String mailContent = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_txt");
|
||||
|
||||
// 本服id
|
||||
int serverId = GameApplication.serverId;
|
||||
if(groupId>0){
|
||||
if(groupId > 0){
|
||||
//是否跨服
|
||||
WorldProto.DeathPathWorldRewardResponse rewardResponse = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.DeathPathWorldRewardRequest.newBuilder().setGroupId(groupId).build(), WorldProto.DeathPathWorldRewardResponse.class);
|
||||
|
||||
if(rewardResponse==null){
|
||||
LOGGER.error("无排行信息");
|
||||
LOGGER.info("===================跨服十绝阵排行榜结束处理,分组:{},区服:{}",groupId,serverId);
|
||||
Map<Integer, Integer> map = CrossDeathPathLogic.getInstance().crossDeathPathReward(groupId, serverId);
|
||||
if(map.isEmpty()){
|
||||
LOGGER.error("===================无跨服十绝阵排行信息");
|
||||
return;
|
||||
}
|
||||
for(WorldProto.GuildRank rank:rewardResponse.getRanksList()){
|
||||
int[] rewardByRank = getRewardByRank(rank.getRank());
|
||||
DeathChallengeCount reward = redisUtil.getObject(serverId+":"+RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT+":"+String.valueOf(rank.getGuildId()), DeathChallengeCount.class);
|
||||
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
|
||||
int[] rewardByRank = getRewardByRank(entry.getKey());
|
||||
DeathChallengeCount reward = redisUtil.getObject(serverId+":"+RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT+":"+entry.getValue(), DeathChallengeCount.class);
|
||||
if(reward!=null&&reward.getUserReward().size()!=0){
|
||||
Map<Integer, DeathReward> userReward = reward.getUserReward();
|
||||
for(Map.Entry<Integer, DeathReward> rewardEntry:userReward.entrySet()){
|
||||
|
@ -607,6 +626,7 @@ public class DeathPathLogic {
|
|||
}
|
||||
}
|
||||
}else {
|
||||
LOGGER.info("===================本地十绝阵排行榜结束处理,分组:{},区服:{}",groupId,serverId);
|
||||
//本服发奖
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType());
|
||||
|
@ -642,15 +662,6 @@ public class DeathPathLogic {
|
|||
}
|
||||
index++;
|
||||
}
|
||||
// redisUtil.del(removeGuildKey);
|
||||
// redisUtil.del(removePersonKey);
|
||||
// for(int i = 1; i <=10;i++){
|
||||
// redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getRedisKey(),String.valueOf(i),false));
|
||||
// redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getRedisKey(),String.valueOf(i),false));
|
||||
// }
|
||||
// redisUtil.del(RedisKey.getKey(guildRank.getRedisKey(),"",false));
|
||||
// redisUtil.del(RedisKey.getKey(personRank.getRedisKey(),"",false));
|
||||
|
||||
}
|
||||
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan(serverId +":DEATH_PATH*", -1);
|
||||
|
@ -677,4 +688,20 @@ public class DeathPathLogic {
|
|||
}
|
||||
return probs.length - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否开启跨服世界阵
|
||||
* @return
|
||||
*/
|
||||
public boolean isOpenCrossDeathPath(){
|
||||
// 时间验证
|
||||
String openTime = GameApplication.serverConfig.getOpenTime();
|
||||
long before = TimeUtils.stringToTimeLong2(openTime);
|
||||
long after = TimeUtils.now();
|
||||
int week = SGuildSetting.sGuildSetting.getCrossServerOpenWeek();
|
||||
boolean byWeek = TimeUtils.isAfterTimeByWeek(before, after, week);
|
||||
// 分组验证
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
return byWeek && crossGroup != -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,4 +63,15 @@ public class DeathPathTask {
|
|||
public void setGroupId(int groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeathPathTask{" +
|
||||
"uid=" + uid +
|
||||
", guildId=" + guildId +
|
||||
", damage=" + damage +
|
||||
", pathId=" + pathId +
|
||||
", groupId=" + groupId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -429,7 +429,6 @@ public class GuildLogic {
|
|||
Integer position = memberEntry.getKey();
|
||||
Set<Integer> value = memberEntry.getValue();
|
||||
for(Integer uidTmp : value){
|
||||
LOGGER.info("family有问题的uid:{}",uidTmp);
|
||||
User userTmp = UserManager.getUser(uidTmp);
|
||||
builder.addFamilyUserInfo(CBean2Proto.getFamilyUserInfo(userTmp,position));
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ public class FriendLogic {
|
|||
List<Integer> friends = friendManager.getFriends();
|
||||
List<CommonProto.Friend> friendList = new CopyOnWriteArrayList<>();
|
||||
for (Integer friendId :friends){
|
||||
LOGGER.info("有问题的Uid:{}",friendId);
|
||||
CommonProto.Friend friend = CBean2Proto.getFriendInfo(friendId,friendManager);
|
||||
friendList.add(friend);
|
||||
}
|
||||
|
|
|
@ -1169,6 +1169,7 @@ public class HeroLogic{
|
|||
}
|
||||
if (teamId == GlobalsDef.FORMATION_NORMAL) {
|
||||
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(iSession.getUid()));
|
||||
CrossServiceLogic.getInstance().dispose(user);
|
||||
}
|
||||
|
||||
// 跨服 更新编队信息
|
||||
|
|
|
@ -213,6 +213,9 @@ public class MissionLoigc {
|
|||
int jadeMissionType = GameMisionType.JADE_DYNASTY_MISSION.getType();
|
||||
for(Integer id:jadeDynastyMissionType.getDoingMissionIds()){
|
||||
SThemeActivityTaskConfig config = SThemeActivityTaskConfig.idTaskConfig.get(id);
|
||||
if(config==null){
|
||||
continue;
|
||||
}
|
||||
int progress = config.getTaskValue()[1][0];
|
||||
switch (config.getType()){
|
||||
case 1:
|
||||
|
|
|
@ -24,10 +24,10 @@ public enum RankEnum {
|
|||
GUILD_RED_PACKAGE_RANK(13,RedisKey.GUILD_RED_PACKAGE_RANK,GuildRedPackageRank::new,false),//param1:红包总价格 param2:无 param3:无
|
||||
CAR_DEALY_RANK(14,RedisKey.CAR_DEALY_RANK,CarDealyRank::new,false),//param1:伤害 param2:无 param3:无
|
||||
CAR_DEALY_GUILD_RANK(19,RedisKey.CAR_DEALY_GUILD_RANK,CarDealyGuildRank::new,false),//param1:伤害 param2:无 param3:无
|
||||
DEATH_PATH_EVERY_PERSON_RANK(15,RedisKey.DEATH_PATH_EVERY_PERSON_RANK,DeathPathEveryPersonRank::new,false),//param1:当前阵玩家伤害 param2:无 param3:无
|
||||
DEATH_PATH_EVERY_GUILD_RANK(16,RedisKey.DEATH_PATH_EVERY_GUILD_RANK, DeathPathEveryGuildRank::new,false),//param1:当前阵公会伤害 param2:当前工会挑战人数 param3:无
|
||||
DEATH_PATH_TOTAL_PERSON_RANK(17,RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,DeathPathTotalPersonRank::new,false),//param1:玩家总伤害 param2:无 param3:无
|
||||
DEATH_PATH_TOTAL_GUILD_RANK(18,RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,DeathPathTotalGuildRank::new,false),//param1:工会总伤害 param2:无 param3:无
|
||||
DEATH_PATH_EVERY_PERSON_RANK(15,RedisKey.DEATH_PATH_EVERY_PERSON_RANK,DeathPathEveryPersonRank::new,true),//param1:当前阵玩家伤害 param2:无 param3:无
|
||||
DEATH_PATH_EVERY_GUILD_RANK(16,RedisKey.DEATH_PATH_EVERY_GUILD_RANK, DeathPathEveryGuildRank::new,true),//param1:当前阵公会伤害 param2:当前工会挑战人数 param3:无
|
||||
DEATH_PATH_TOTAL_PERSON_RANK(17,RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,DeathPathTotalPersonRank::new,true),//param1:玩家总伤害 param2:无 param3:无
|
||||
DEATH_PATH_TOTAL_GUILD_RANK(18,RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,DeathPathTotalGuildRank::new,true),//param1:工会总伤害 param2:无 param3:无
|
||||
GUILD_FORCE_RANK(20,RedisKey.GUILD_FORCE_RANK,GuildForceRank::new,false),//param1:公会总战力 param2:无 param3:无
|
||||
//达人排行榜
|
||||
EXPERT_RANK(21,RedisKey.EXPERT_RANK,GoldRank::new,false),//param1:活动进度 param2:无 param3:无
|
||||
|
|
|
@ -66,20 +66,19 @@ public class RankLogic {
|
|||
public static class Instance {
|
||||
public final static RankLogic instance = new RankLogic();
|
||||
}
|
||||
public void getRank(ISession session, int type, int activityId,int index,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
public void getRank(ISession session, int type, int activityId,int index,int isCross,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
LOGGER.info("获取排行榜信息type={},activityId={}",type,activityId);
|
||||
int page = 1;
|
||||
String rkey = "";
|
||||
if(activityId != 0){
|
||||
rkey = String.valueOf(activityId);
|
||||
}
|
||||
PlayerInfoProto.RankResponse rankResponse=null;
|
||||
AbstractRank rank = RankContext.getRankEnum(type);
|
||||
if(RankContext.isCrossRank(type)){
|
||||
if(RankContext.isCrossRank(type) || isCross == 1){
|
||||
//跨服
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if(crossGroup>0){
|
||||
rankResponse = rank.getRank(session.getUid(),String.valueOf(crossGroup),index/20+1, 20);
|
||||
rankResponse = rank.getCrossRank(session.getUid(),String.valueOf(crossGroup),index/20+1, 20);
|
||||
}
|
||||
}else{
|
||||
rankResponse = rank.getRank(session.getUid(),rkey,index/20+1, 20);
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.ljsd.jieling.logic.rank.rankImpl;
|
|||
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.rank.IRank;
|
||||
|
@ -36,7 +38,7 @@ public abstract class AbstractRank implements IRank {
|
|||
* @return 当前排行榜数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public PlayerInfoProto.RankResponse getRank(int uid, String rkey, int page, int rankEndLine) throws Exception {
|
||||
public PlayerInfoProto.RankResponse getRank(int uid, String rkey, int page, int rankEndLine) throws Exception {
|
||||
if(rankEndLine==-1){
|
||||
rankEndLine = 100;
|
||||
}
|
||||
|
@ -55,6 +57,16 @@ public abstract class AbstractRank implements IRank {
|
|||
return allUserResponse.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 跨服排行数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public PlayerInfoProto.RankResponse getCrossRank(int uid, String rkey, int page, int rankEndLine) throws Exception {
|
||||
int groupId = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
redisKey = RedisUtil.getInstence().getKey(String.valueOf(groupId),redisKey,false);
|
||||
return getRank(uid,rkey,page,rankEndLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向排行榜添加或修改某条数据
|
||||
* @param uid 修改用户id
|
||||
|
@ -129,7 +141,6 @@ public abstract class AbstractRank implements IRank {
|
|||
}
|
||||
|
||||
protected void getOptional(int index,ZSetOperations.TypedTuple<String> data,PlayerInfoProto.RankResponse.Builder builder) throws Exception {
|
||||
LOGGER.info("获取排行榜信息===================玩家id:{}"+data.getValue());
|
||||
User everyUser = UserManager.getUser(Integer.parseInt(data.getValue()), true);
|
||||
if (everyUser == null){
|
||||
return;
|
||||
|
@ -142,8 +153,10 @@ public abstract class AbstractRank implements IRank {
|
|||
CommonProto.UserRank.Builder oneUserRank = getOneUserRank(everyUser, everyRankInfo);
|
||||
builder.addRanks(oneUserRank);
|
||||
}
|
||||
public CommonProto.UserRank.Builder getOneUserRank(User everyUser,CommonProto.RankInfo.Builder everyRankInfo) throws Exception {
|
||||
CommonProto.UserRank.Builder everyRank = CommonProto.UserRank.newBuilder()
|
||||
|
||||
private CommonProto.UserRank.Builder getOneUserRank(User everyUser,CommonProto.RankInfo.Builder everyRankInfo){
|
||||
String serverName = CrossServiceLogic.getInstance().getServerNameByUId(everyUser.getId());
|
||||
return CommonProto.UserRank.newBuilder()
|
||||
.setUid(everyUser.getId())
|
||||
.setUserName(everyUser.getPlayerInfoManager().getNickName())
|
||||
.setHead(everyUser.getPlayerInfoManager().getHead())
|
||||
|
@ -155,8 +168,8 @@ public abstract class AbstractRank implements IRank {
|
|||
.setUserSkin(everyUser.getPlayerInfoManager().getUserSkin())
|
||||
.setUserTitle(everyUser.getPlayerInfoManager().getUserTitle())
|
||||
.setUserMount(everyUser.getPlayerInfoManager().getUserMount())
|
||||
.setPracticeLevel(everyUser.getHeroManager().getPracticeLevel());
|
||||
return everyRank;
|
||||
.setPracticeLevel(everyUser.getHeroManager().getPracticeLevel())
|
||||
.setServerName(serverName);
|
||||
}
|
||||
|
||||
protected void getMyInfo(User user,String rkey,PlayerInfoProto.RankResponse.Builder allUserResponse){
|
||||
|
|
|
@ -105,4 +105,9 @@ public class CrossArenaRank extends AbstractRank {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerInfoProto.RankResponse getCrossRank(int uid, String rkey, int page, int rankEndLine) throws Exception {
|
||||
return getRank(uid,rkey,page,rankEndLine);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ public class DeathPathEveryPersonRank extends AbstractRank {
|
|||
return data[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRank(int uid,String rkey,double... data){
|
||||
RedisUtil.getInstence().incrementZsetScore(redisKey,rkey,String.valueOf(uid), Double.valueOf(getScore(data)).intValue());
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ljsd.jieling.logic.dao.GuilidManager;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.CrossDeathPathLogic;
|
||||
import com.ljsd.jieling.logic.family.DeathPathLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
|
@ -244,6 +245,8 @@ public class MinuteTask extends Thread {
|
|||
});
|
||||
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
|
||||
}
|
||||
// 跨服服务器刷新
|
||||
CrossDeathPathLogic.getInstance().serverInit();
|
||||
// LOGGER.info("{}更新公会援助完毕",guildInfoEntry.getValue().getName());
|
||||
|
||||
// //统一清除
|
||||
|
@ -265,12 +268,10 @@ public class MinuteTask extends Thread {
|
|||
MongoUtil.getInstence().lastUpdate();
|
||||
}
|
||||
}catch (Exception e){
|
||||
LOGGER.error("Exception everyFiveTask" );
|
||||
LOGGER.error("Exception everyFiveTask,{}",e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
LOGGER.info("DailyOfFiveTask start ...");
|
||||
|
||||
GlobalDataManaager.everTask(0);
|
||||
ThreadManager.commitGeneralTask(new GuildCheckOfflineTask());
|
||||
LOGGER.info("DailyOfFiveTask end ...");
|
||||
|
|
|
@ -78,6 +78,8 @@ public class SGuildSetting implements BaseConfig {
|
|||
|
||||
private int challengeMaxTime;
|
||||
|
||||
private int crossServerOpenWeek;
|
||||
|
||||
public static SGuildSetting sGuildSetting;
|
||||
|
||||
|
||||
|
@ -231,4 +233,8 @@ public class SGuildSetting implements BaseConfig {
|
|||
public int getChallengeMaxTime() {
|
||||
return challengeMaxTime;
|
||||
}
|
||||
|
||||
public int getCrossServerOpenWeek() {
|
||||
return crossServerOpenWeek;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import java.util.Set;
|
|||
* @date 2020/12/3
|
||||
* @discribe
|
||||
*/
|
||||
@Deprecated
|
||||
public class AddDeathPathRankRequestHandler extends gtGBaseHandler<WorldProto.AddDeathPathRankRequest>{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.*;
|
|||
* @date 2020/12/15
|
||||
* @discribe
|
||||
*/
|
||||
@Deprecated
|
||||
public class DeathPathWorldRewardRequestHandler extends gtGBaseHandler<WorldProto.DeathPathWorldRewardRequest> {
|
||||
private static Set<Integer> groupIds = new HashSet<>();
|
||||
@Override
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Set;
|
|||
* @date 2020/12/12
|
||||
* @discribe
|
||||
*/
|
||||
@Deprecated
|
||||
public class GetDeathPathFirstRequestHandler extends gtGBaseHandler<WorldProto.GetDeathPathFirstRequest> {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import rpc.world.WorldProto;
|
|||
* @date 2020/12/14
|
||||
* @discribe
|
||||
*/
|
||||
@Deprecated
|
||||
public class GetDeathPathRewardRequestHandler extends gtGBaseHandler<WorldProto.GetDeathPathRewardRequest> {
|
||||
@Override
|
||||
public WorldProto.GetDeathPathRewardResponse processWithProto(RpcMessage rpcMessage, WorldProto.GetDeathPathRewardRequest proto) throws Exception {
|
||||
|
|
Loading…
Reference in New Issue