十绝阵跨服
parent
e26b239f1c
commit
6c56cba35f
|
@ -69,14 +69,13 @@ public class CrossDeathPathLogic {
|
|||
/**
|
||||
* 首页公会
|
||||
* @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;
|
||||
private String firstGuild(RedisUtil redisUtil, int pathId){
|
||||
AbstractRank totalGuild = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
Set<ZSetOperations.TypedTuple<String>> scores = redisUtil
|
||||
.getZsetreverseRangeWithScores(key, String.valueOf(pathId), 0, 0,false);
|
||||
.getZsetreverseRangeWithScores(totalGuild.getCrossRedisKey(), String.valueOf(pathId), 0, 0,false);
|
||||
return scores.iterator().hasNext()?scores.iterator().next().getValue():"";
|
||||
}
|
||||
|
||||
|
@ -85,13 +84,12 @@ public class CrossDeathPathLogic {
|
|||
* @param uid
|
||||
* @param damage
|
||||
* @param guildId
|
||||
* @param groupId
|
||||
* @param pathId
|
||||
*/
|
||||
void addCrossDeathPathRank(int uid, int damage, int guildId, int groupId, int pathId){
|
||||
void addCrossDeathPathRank(int uid, int damage, int guildId, int pathId){
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
//操作每个关的公会、个人数据
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(damage)).divide(new BigDecimal(String.valueOf(Math.pow(10,15))));
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(damage)).divide(new BigDecimal(String.valueOf(Math.pow(10,15))),6,BigDecimal.ROUND_HALF_UP);
|
||||
long everyGuildChangeScore = (long)damage*1000;
|
||||
AbstractRank everyPerson = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType());
|
||||
if(redisUtil.getZSetScore(everyPerson.getCrossRedisKey(),String.valueOf(pathId), String.valueOf(uid), false)==-1){
|
||||
|
@ -99,10 +97,10 @@ public class CrossDeathPathLogic {
|
|||
everyGuildChangeScore = everyGuildChangeScore+1;
|
||||
}
|
||||
|
||||
String before = firstGuild(redisUtil, groupId, pathId);
|
||||
String before = firstGuild(redisUtil, pathId);
|
||||
AbstractRank everyGuild = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
redisUtil.incrementZsetScore(everyGuild.getCrossRedisKey(),String.valueOf(pathId),String.valueOf(guildId), everyGuildChangeScore, false);
|
||||
String after = firstGuild(redisUtil, groupId, pathId);
|
||||
String after = firstGuild(redisUtil, pathId);
|
||||
AbstractRank totalGuild = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||
if(!before.equals(after)){
|
||||
decimal = decimal.add(new BigDecimal(1));
|
||||
|
|
|
@ -329,10 +329,10 @@ public class DeathPathLogic {
|
|||
}
|
||||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
int guildId = Integer.parseInt(next.getValue());
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
GuildInfoCache crossGuild = CrossDeathPathLogic.getCrossGuild(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();
|
||||
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(crossGuild.getGuildName()).setPathId(i).setGid(guildId).setServerName(serverName).build();
|
||||
response.addInfos(info);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
|
@ -431,53 +431,54 @@ public class DeathPathLogic {
|
|||
//跨服
|
||||
if(task.getGroupId()>0){
|
||||
try {
|
||||
CrossDeathPathLogic.getInstance().addCrossDeathPathRank(task.getUid(),task.getDamage(),task.getGuildId(),task.getGroupId(),task.getPathId());
|
||||
CrossDeathPathLogic.getInstance().addCrossDeathPathRank(task.getUid(),task.getDamage(),task.getGuildId(),task.getPathId());
|
||||
LOGGER.info("==================跨服十绝阵上榜处理:{}",task.toString());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("==================跨服十绝阵上榜异常:{}",e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
//操作每个关的公会数据
|
||||
task.setDamage(task.getDamage());
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
// 本地
|
||||
}else {
|
||||
LOGGER.info("==================本地十绝阵上榜处理:{}",task.toString());
|
||||
//操作每个关的公会数据
|
||||
task.setDamage(task.getDamage());
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||
|
||||
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType());
|
||||
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());
|
||||
//操作总的工会伤害
|
||||
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||
//操作总的个人伤害
|
||||
AbstractRank personTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType());
|
||||
personTotalRank.addRank(task.getUid(),"",task.getDamage());
|
||||
//操作总的工会伤害
|
||||
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||
|
||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||
int firstGuildId;
|
||||
Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
|
||||
if(!iterator.hasNext()){
|
||||
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage(),1);
|
||||
//操作每个关的个人数据
|
||||
doRankAdd(personRank,guildRank,task);
|
||||
//第一名推送
|
||||
sendChangeIndication(task.getGuildId(),task.getPathId());
|
||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||
int firstGuildId;
|
||||
Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
|
||||
if(!iterator.hasNext()){
|
||||
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage(),1);
|
||||
//操作每个关的个人数据
|
||||
doRankAdd(personRank,guildRank,task);
|
||||
//第一名推送
|
||||
sendChangeIndication(task.getGuildId(),task.getPathId());
|
||||
|
||||
}else{
|
||||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
firstGuildId = Integer.parseInt(next.getValue());
|
||||
doRankAdd(personRank,guildRank,task);
|
||||
Set<ZSetOperations.TypedTuple<String>> currScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||
Iterator<ZSetOperations.TypedTuple<String>> currIterator = currScores.iterator();
|
||||
ZSetOperations.TypedTuple<String> currNext = currIterator.next();
|
||||
int currFirstGuildId = Integer.parseInt(currNext.getValue());
|
||||
if(currFirstGuildId==firstGuildId){
|
||||
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage());
|
||||
}else{
|
||||
//第一名更改时推送
|
||||
sendChangeIndication(currFirstGuildId,task.getPathId());
|
||||
guildTotalRank.addRank(currFirstGuildId,"",task.getDamage(),1);
|
||||
guildTotalRank.addRank(firstGuildId,"",0,-1);
|
||||
ZSetOperations.TypedTuple<String> next = iterator.next();
|
||||
firstGuildId = Integer.parseInt(next.getValue());
|
||||
doRankAdd(personRank,guildRank,task);
|
||||
Set<ZSetOperations.TypedTuple<String>> currScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||
Iterator<ZSetOperations.TypedTuple<String>> currIterator = currScores.iterator();
|
||||
ZSetOperations.TypedTuple<String> currNext = currIterator.next();
|
||||
int currFirstGuildId = Integer.parseInt(currNext.getValue());
|
||||
if(currFirstGuildId==firstGuildId){
|
||||
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage());
|
||||
}else{
|
||||
//第一名更改时推送
|
||||
sendChangeIndication(currFirstGuildId,task.getPathId());
|
||||
guildTotalRank.addRank(currFirstGuildId,"",task.getDamage(),1);
|
||||
guildTotalRank.addRank(firstGuildId,"",0,-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void sendChangeIndication(int currFirstGuildId,int pathId){
|
||||
|
@ -610,9 +611,6 @@ public class DeathPathLogic {
|
|||
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(getGroupId() > 0){
|
||||
|
@ -624,52 +622,24 @@ public class DeathPathLogic {
|
|||
return;
|
||||
}
|
||||
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()){
|
||||
if(rewardEntry.getValue().getPosition()==0){
|
||||
MailLogic.getInstance().sendMail(rewardEntry.getKey(),mailTitle,mailContent,rewardByRank[0]+"#"+rewardByRank[1],TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
int[] rewardByRank = getRewardByRank(entry.getKey());
|
||||
deathPathSendMail(reward,rewardByRank);
|
||||
}
|
||||
}else {
|
||||
LOGGER.info("===================本地十绝阵排行榜结束处理,分组:{},区服:{}",getGroupId(),serverId);
|
||||
//本服发奖
|
||||
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType());
|
||||
Set<ZSetOperations.TypedTuple<String>> guildRankSet = guildRank.getRankByKey("", 0, -1);
|
||||
Set<ZSetOperations.TypedTuple<String>> personRankSet = personRank.getRankByKey("", 0, -1);
|
||||
if(guildRankSet.isEmpty()&&personRankSet.isEmpty()){
|
||||
if(guildRankSet.isEmpty()){
|
||||
return;
|
||||
}
|
||||
String[] removeGuildKey = new String[guildRankSet.size()];
|
||||
String[] removePersonKey = new String[personRankSet.size()];
|
||||
int index = 0;
|
||||
int index = 1;
|
||||
for(ZSetOperations.TypedTuple<String> item:guildRankSet){
|
||||
removeGuildKey[index] = RedisKey.getKey(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, item.getValue(),false);
|
||||
index++;
|
||||
}
|
||||
index = 0;
|
||||
for(ZSetOperations.TypedTuple<String> item:personRankSet){
|
||||
removePersonKey[index] = RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT, item.getValue(),false);
|
||||
index++;
|
||||
}
|
||||
|
||||
index = 1;
|
||||
for(String key:removeGuildKey){
|
||||
int[] rewardByRank = getRewardByRank(index);
|
||||
String key = RedisKey.getKey(RedisKey.DEATH_PATH_TOTAL_CHALLENGE_COUNT, item.getValue(),false);
|
||||
DeathChallengeCount reward = redisUtil.getObject(key, DeathChallengeCount.class);
|
||||
if(reward!=null&&reward.getUserReward().size()!=0){
|
||||
Map<Integer, DeathReward> userReward = reward.getUserReward();
|
||||
for(Map.Entry<Integer, DeathReward> rewardEntry:userReward.entrySet()){
|
||||
if(rewardEntry.getValue().getPosition()==0){
|
||||
MailLogic.getInstance().sendMail(rewardEntry.getKey(),mailTitle,mailContent,rewardByRank[0]+"#"+rewardByRank[1],TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
int[] rewardByRank = getRewardByRank(index);
|
||||
deathPathSendMail(reward,rewardByRank);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
@ -684,6 +654,20 @@ public class DeathPathLogic {
|
|||
cursor.close();
|
||||
}
|
||||
|
||||
private void deathPathSendMail(DeathChallengeCount reward,int[] rewardByRank) throws Exception {
|
||||
// 邮件标题和内容
|
||||
String mailTitle = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_title");
|
||||
String mailContent = SErrorCodeEerverConfig.getI18NMessage("guildwar_reward_txt");
|
||||
if(reward!=null&&reward.getUserReward().size()!=0){
|
||||
Map<Integer, DeathReward> userReward = reward.getUserReward();
|
||||
for(Map.Entry<Integer, DeathReward> rewardEntry:userReward.entrySet()){
|
||||
if(rewardEntry.getValue().getPosition()==0){
|
||||
MailLogic.getInstance().sendMail(rewardEntry.getKey(),mailTitle,mailContent,rewardByRank[0]+"#"+rewardByRank[1],TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int nextDiscrete(double[] probs) {
|
||||
double sum = 0.0;
|
||||
for (int i = 0; i < probs.length; i++)
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.world.handler;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.logic.dao.GuildInfoCache;
|
||||
import com.ljsd.jieling.util.MonsterUtil;
|
||||
import com.world.db.mongo.MongoUtil;
|
||||
import com.world.logic.rank.AbstractCrossRank;
|
||||
import com.world.logic.rank.DeathPathCrossEveryGuildRank;
|
||||
import com.world.redis.RedisKey;
|
||||
import com.world.redis.RedisUtil;
|
||||
|
@ -30,7 +27,7 @@ public class GetDeathPathFirstRequestHandler extends gtGBaseHandler<WorldProto.G
|
|||
|
||||
DeathPathCrossEveryGuildRank deathPathCrossEveryGuildRank = new DeathPathCrossEveryGuildRank(RedisKey.DEATH_PATH_EVERY_GUILD_RANK);
|
||||
WorldProto.GetDeathPathFirstResponse.Builder response = WorldProto.GetDeathPathFirstResponse.newBuilder();
|
||||
for(int i = 1 ;i<=10;i++){
|
||||
/*for(int i = 1 ;i<=10;i++){
|
||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(proto.getGroupId()+":"+ RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(i), 0, 0);
|
||||
Iterator<ZSetOperations.TypedTuple<String>> iterator = zSetReverseRangeWithScores.iterator();
|
||||
if(!iterator.hasNext()){
|
||||
|
@ -42,7 +39,7 @@ public class GetDeathPathFirstRequestHandler extends gtGBaseHandler<WorldProto.G
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue