跨服分组第一版
parent
c4d6ee097b
commit
e47eaeb8bd
|
@ -118,6 +118,8 @@ public class GameLogicService implements IService {
|
|||
if(resource!=null){
|
||||
LOGGER.info(resource.getFile());
|
||||
}
|
||||
//跨服分一次组
|
||||
GlobleSystemLogic.getInstence().doSplit();
|
||||
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
|
|
|
@ -34,6 +34,8 @@ public class ServerProperties {
|
|||
|
||||
private String appId;
|
||||
|
||||
private boolean arenaCross;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -138,6 +140,14 @@ public class ServerProperties {
|
|||
this.appId = appId;
|
||||
}
|
||||
|
||||
public boolean isArenaCross() {
|
||||
return arenaCross;
|
||||
}
|
||||
|
||||
public void setArenaCross(boolean arenaCross) {
|
||||
this.arenaCross = arenaCross;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerProperties{" +
|
||||
|
|
|
@ -899,6 +899,17 @@ public class RedisUtil {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
//按分组来取,不需要加服务器和小key
|
||||
public Set<ZSetOperations.TypedTuple<String>> getZsetreverseRangeByRangeWithScores(String type, long start, long end){
|
||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||
try {
|
||||
return redisTemplate.opsForZSet().reverseRangeByScoreWithScores(type, start, end);
|
||||
} catch (Exception e) {
|
||||
TimeUtils.sleep(FAILED_SLEEP);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<ZSetOperations.TypedTuple<String>> getZsetRangeWithScores(String type,String key, long start, long end){
|
||||
String rkey = getKey(type, key);
|
||||
|
@ -1239,7 +1250,7 @@ public class RedisUtil {
|
|||
public String getKey(String type,String key){
|
||||
|
||||
if(RedisKey.BLOODY_RANK.equals(type) || RedisKey.BLOODY_TEAM.equals(type) || RedisKey.PLAYER_INFO_CACHE.equals(type) || RedisKey.BLOODY_PERSON_BATTLE_INFO.equals(type)
|
||||
||RedisKey.FAMILY_INFO.equals(type)||RedisKey.PIDGIDTEMP.equals(type)||RedisKey.SERVER_WORLDLEVE_INFO.equals(type)|| RedisKey.GUILD_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)) {
|
||||
return type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
// if(RedisKey.familyKey.contains(type)){
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.ljsd.jieling.logic.activity.ActivityLogic;
|
|||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.IEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.*;
|
||||
import com.ljsd.jieling.logic.dao.ServerConfig;
|
||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.InnerMessageUtil;
|
||||
|
@ -45,6 +46,7 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
*/
|
||||
private static volatile int GLOABLE_WORLD_LEVE_CACHE = 0;
|
||||
private static volatile int GLOABLE_WORLD_LEVE_CACHE_LINE = 0; // 名次基线 看配置
|
||||
private static int crossGroup = 0;
|
||||
|
||||
private GlobleSystemLogic() {
|
||||
Poster.getPoster().listenEvent(this, MinuteTaskEvent.class);
|
||||
|
@ -136,6 +138,11 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
* 2 高于50名
|
||||
*/
|
||||
public void calCulRank() {
|
||||
|
||||
//不参与跨服,不用计算世界等级
|
||||
if(!GameApplication.serverProperties.isArenaCross()){
|
||||
return;
|
||||
}
|
||||
//need cfg
|
||||
int rankEndLine = 50;
|
||||
RedisUtil.getInstence().del(GameApplication.serverId+":"+RedisKey.WORLD_CALCUL_LEVE_RAND+":");
|
||||
|
@ -212,10 +219,13 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
|
||||
}
|
||||
public void doSplit(){
|
||||
if(!GameApplication.serverProperties.isArenaCross()){
|
||||
return;
|
||||
}
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
//这里为所有服务器的世界等级
|
||||
Map<String,Integer> worldLevelMap = redisUtil.getMapValues(RedisKey.SERVER_WORLDLEVE_INFO+":","",String.class,Integer.class);
|
||||
Map<String,Integer> worldLevelMap = redisUtil.getMapValues(RedisKey.SERVER_WORLDLEVE_INFO,"",String.class,Integer.class);
|
||||
Object matched = redisUtil.get(RedisKey.MATCHED_SPLIT_KEY);
|
||||
if(matched!=null){
|
||||
return;
|
||||
|
@ -228,7 +238,7 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
//提前两分钟结算
|
||||
redisUtil.set(RedisKey.MATCHED_VERSION,TimeUtils.getTimeStampYMD(System.currentTimeMillis()),expireTime-120);
|
||||
worldLevelMap.forEach((k,v)->redisUtil.zsetAddOne(RedisKey.SERVER_LEVEL_RANK,k,v));
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetRevRangeWithScore = redisUtil.getZsetRangeWithScore(RedisKey.SERVER_LEVEL_RANK, setting.getWorldLevel(), 999);
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetRevRangeWithScore = redisUtil.getZsetreverseRangeByRangeWithScores(RedisKey.SERVER_LEVEL_RANK, setting.getWorldLevel(), 999);
|
||||
// int remain = zsetRevRangeWithScore.size() % 8;
|
||||
//如果只有一个服到达条件,则不进行分组
|
||||
if(zsetRevRangeWithScore.size()>1){
|
||||
|
@ -254,4 +264,13 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
// splitInfo = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO,"",String.class,Integer.class);
|
||||
}
|
||||
|
||||
//获取当前区服的跨服区组 -1为未在分组内
|
||||
public int getCrossGroup(){
|
||||
if(crossGroup==0){
|
||||
Integer group = RedisUtil.getInstence().getMapValue(RedisKey.SERVER_SPLIT_INFO, "", String.valueOf(GameApplication.serverId), Integer.class);
|
||||
crossGroup = group==null?-1:group;
|
||||
}
|
||||
return crossGroup;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class MinuteTask extends Thread {
|
|||
LOGGER.error("Exception::=>{}",e.toString());
|
||||
}
|
||||
try {
|
||||
everyMondyFiveClockTask();
|
||||
everyMondayZeroClockTask();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
LOGGER.error("Exception::=>{}",e.toString());
|
||||
|
@ -249,17 +249,17 @@ public class MinuteTask extends Thread {
|
|||
}
|
||||
|
||||
//每周一凌晨五点执行
|
||||
public void everyMondyFiveClockTask() throws Exception {
|
||||
public void everyMondayZeroClockTask() throws Exception {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
|
||||
if(w == 1 &&hour == 0 && minute ==0){
|
||||
LOGGER.info("everyMondyFiveClockTask start ...");
|
||||
LOGGER.info("everyMondayZeroClockTask start ...");
|
||||
// CombatLogic.getInstance().sendReward();
|
||||
GlobleSystemLogic.getInstence().doSplit();
|
||||
LOGGER.info("everyMondyFiveClockTask end ...");
|
||||
LOGGER.info("everyMondayZeroClockTask end ...");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,15 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
|
|||
|
||||
private String rechargeId6;
|
||||
|
||||
private String rechargeId7;
|
||||
|
||||
private String rechargeId8;
|
||||
|
||||
private String rechargeId9;
|
||||
|
||||
private String rechargeId10;
|
||||
|
||||
|
||||
private int[] forbid;
|
||||
|
||||
private String[][] condition;
|
||||
|
@ -181,4 +190,20 @@ public class SRechargeCommodityNewConfig implements BaseConfig {
|
|||
public void setCondition(String[][] condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getRechargeId7() {
|
||||
return rechargeId7;
|
||||
}
|
||||
|
||||
public String getRechargeId8() {
|
||||
return rechargeId8;
|
||||
}
|
||||
|
||||
public String getRechargeId9() {
|
||||
return rechargeId9;
|
||||
}
|
||||
|
||||
public String getRechargeId10() {
|
||||
return rechargeId10;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue