parent
f5eb45b65e
commit
cf2e4e939e
|
@ -71,7 +71,7 @@ public class GetWorldArenaInfoRequestHandler extends BaseHandler<WorldProto.GetW
|
||||||
else if (luofuState == LuofuLogic.INIT_RANK) {
|
else if (luofuState == LuofuLogic.INIT_RANK) {
|
||||||
throw new ErrorTableException(176);//准备阶段
|
throw new ErrorTableException(176);//准备阶段
|
||||||
}
|
}
|
||||||
else if (luofuState == LuofuLogic.SENDR_EWARD) {
|
else if (luofuState == LuofuLogic.SEND_REWARD) {
|
||||||
throw new ErrorTableException(177);//发奖阶段
|
throw new ErrorTableException(177);//发奖阶段
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class LuofuLogic {
|
||||||
public static final int REGISTER = 1; // 报名
|
public static final int REGISTER = 1; // 报名
|
||||||
public static final int INIT_RANK = 2; // 初始化排行榜
|
public static final int INIT_RANK = 2; // 初始化排行榜
|
||||||
public static final int FIGHT = 3; // 战斗
|
public static final int FIGHT = 3; // 战斗
|
||||||
public static final int SENDR_EWARD = 4; //发奖
|
public static final int SEND_REWARD = 4; // 发奖
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取罗浮状态
|
* 获取罗浮状态
|
||||||
|
@ -69,34 +69,47 @@ public class LuofuLogic {
|
||||||
|
|
||||||
private static int getState(){
|
private static int getState(){
|
||||||
long now = TimeUtils.now();
|
long now = TimeUtils.now();
|
||||||
SMServerArenaSetting luofuSetting = SMServerArenaSetting.map.get(1);
|
SMServerArenaSetting setting = SMServerArenaSetting.map.get(1);
|
||||||
Long[] timeLong = luofuSetting.getTimeLong();
|
if (setting == null) {
|
||||||
// 每个阶段的初始时间
|
// Handle the situation when the setting is null, possibly return an error or throw an exception.
|
||||||
long registerStart = timeLong[0], registerEnd = timeLong[1];
|
return -1;
|
||||||
long initRankStart = timeLong[2], initRankEnd = timeLong[3];
|
}
|
||||||
long fightStart = timeLong[4], fightEnd = timeLong[5];
|
|
||||||
long sendRewardStart = timeLong[6], sendRewardEnd = timeLong[7];
|
Long[] timeIntervals = setting.getTimeLong();
|
||||||
// 每个阶段的间隔时间
|
if (timeIntervals.length < 8) {
|
||||||
|
// Handle the situation when the timeIntervals array is too short, possibly return an error or throw an exception.
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Each phase's start and end times
|
||||||
|
long registerStart = timeIntervals[0], registerEnd = timeIntervals[1];
|
||||||
|
long initRankStart = timeIntervals[2], initRankEnd = timeIntervals[3];
|
||||||
|
long fightStart = timeIntervals[4], fightEnd = timeIntervals[5];
|
||||||
|
long sendRewardStart = timeIntervals[6], sendRewardEnd = timeIntervals[7];
|
||||||
|
|
||||||
|
// Each phase's duration
|
||||||
long registerInterval = registerEnd - registerStart;
|
long registerInterval = registerEnd - registerStart;
|
||||||
long initRankInterval = initRankEnd - initRankStart;
|
long initRankInterval = initRankEnd - initRankStart;
|
||||||
long fightInterval = fightEnd - fightStart;
|
long fightInterval = fightEnd - fightStart;
|
||||||
long sendRewardInterval = sendRewardEnd - sendRewardStart;
|
long sendRewardInterval = sendRewardEnd - sendRewardStart;
|
||||||
// 最近的开始时间
|
|
||||||
|
// The most recent start time
|
||||||
long startTime = TimeUtils.getLatelyTime(registerStart, sendRewardEnd - registerStart, now);
|
long startTime = TimeUtils.getLatelyTime(registerStart, sendRewardEnd - registerStart, now);
|
||||||
|
|
||||||
if (now >= startTime && now < startTime + registerInterval){
|
if (now >= startTime && now < startTime + registerInterval){
|
||||||
return REGISTER;//报名阶段
|
return REGISTER; // Registration phase
|
||||||
}
|
}
|
||||||
else if (now >= startTime + registerInterval && now < startTime + registerInterval + initRankInterval){
|
else if (now >= startTime + registerInterval && now < startTime + registerInterval + initRankInterval){
|
||||||
return INIT_RANK;//初始化排行榜阶段
|
return INIT_RANK; // Initial ranking phase
|
||||||
}
|
}
|
||||||
else if (now >= startTime + registerInterval + initRankInterval && now < startTime + registerInterval + initRankInterval + fightInterval){
|
else if (now >= startTime + registerInterval + initRankInterval && now < startTime + registerInterval + initRankInterval + fightInterval){
|
||||||
return FIGHT;//战斗阶段
|
return FIGHT; // Fighting phase
|
||||||
}
|
}
|
||||||
else if (now >= startTime + registerInterval + initRankInterval + fightInterval && now < startTime + registerInterval + initRankInterval + fightInterval + sendRewardInterval){
|
else if (now >= startTime + registerInterval + initRankInterval + fightInterval && now < startTime + registerInterval + initRankInterval + fightInterval + sendRewardInterval){
|
||||||
return SENDR_EWARD;//发奖阶段
|
return SEND_REWARD; // Reward sending phase (fixed the typo)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;//未在功能时间内
|
return 0; // Not within the functional time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +122,7 @@ public class LuofuLogic {
|
||||||
LOGGER.info("罗浮争锋 准备时间到......");
|
LOGGER.info("罗浮争锋 准备时间到......");
|
||||||
TaskKit.scheduleOne(this::initRankRobot,0);
|
TaskKit.scheduleOne(this::initRankRobot,0);
|
||||||
}
|
}
|
||||||
else if (state == SENDR_EWARD){
|
else if (state == SEND_REWARD){
|
||||||
LOGGER.info("罗浮争锋 发奖时间到......");
|
LOGGER.info("罗浮争锋 发奖时间到......");
|
||||||
TaskKit.scheduleOne(this::luoFuSendReward,0);
|
TaskKit.scheduleOne(this::luoFuSendReward,0);
|
||||||
}
|
}
|
||||||
|
@ -237,8 +250,8 @@ public class LuofuLogic {
|
||||||
* 罗浮争锋 初始化排行榜机器人信息
|
* 罗浮争锋 初始化排行榜机器人信息
|
||||||
*/
|
*/
|
||||||
public void initRankRobot() {
|
public void initRankRobot() {
|
||||||
Thread.currentThread().setName("luofu_arena_init_rank");
|
|
||||||
long start = TimeUtils.now();
|
long start = TimeUtils.now();
|
||||||
|
LOGGER.info("罗浮争锋,初始化排行榜开始......当前时间:{} ",TimeUtils.getTimeStamp2(start));
|
||||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
if (crossGroup == -1) {
|
if (crossGroup == -1) {
|
||||||
LOGGER.error("罗浮争锋初始化退出, 服务器未分组!耗时:{} ms, 当前时间:{}", TimeUtils.now() - start, TimeUtils.getTimeStamp2(TimeUtils.now()));
|
LOGGER.error("罗浮争锋初始化退出, 服务器未分组!耗时:{} ms, 当前时间:{}", TimeUtils.now() - start, TimeUtils.getTimeStamp2(TimeUtils.now()));
|
||||||
|
@ -332,8 +345,8 @@ public class LuofuLogic {
|
||||||
* 罗浮发奖
|
* 罗浮发奖
|
||||||
*/
|
*/
|
||||||
public void luoFuSendReward() {
|
public void luoFuSendReward() {
|
||||||
Thread.currentThread().setName("luofu_arena_send_reward");
|
|
||||||
long start = TimeUtils.now();
|
long start = TimeUtils.now();
|
||||||
|
LOGGER.info("罗浮争锋,发奖开始......当前时间:{} ",TimeUtils.getTimeStamp2(start));
|
||||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
if (crossGroup == -1) {
|
if (crossGroup == -1) {
|
||||||
LOGGER.error("罗浮争锋发奖退出, 服务器未分组!耗时:{} ms, 当前时间:{}", TimeUtils.now() - start, TimeUtils.getTimeStamp2(TimeUtils.now()));
|
LOGGER.error("罗浮争锋发奖退出, 服务器未分组!耗时:{} ms, 当前时间:{}", TimeUtils.now() - start, TimeUtils.getTimeStamp2(TimeUtils.now()));
|
||||||
|
@ -431,21 +444,32 @@ public class LuofuLogic {
|
||||||
* 实时随机 暂时不缓存
|
* 实时随机 暂时不缓存
|
||||||
*/
|
*/
|
||||||
private TreeSet<Integer> getMatchID(int index) {
|
private TreeSet<Integer> getMatchID(int index) {
|
||||||
//玩家排名 获取配置
|
// 玩家排名 获取配置
|
||||||
TreeMap<Integer, Integer> rank2miss = SMServerArenaMatchConfig.rank2miss;
|
TreeMap<Integer, Integer> rank2miss = SMServerArenaMatchConfig.rank2miss;
|
||||||
Integer integer = rank2miss.floorKey(index);
|
Integer configIndex = rank2miss.floorKey(index);
|
||||||
Integer integer1 = rank2miss.get(integer);
|
if (configIndex == null) {
|
||||||
TreeSet<Integer> objects = new TreeSet<>();
|
// 处理configIndex为空的情况,可以根据实际需求抛出异常或返回默认值
|
||||||
|
return new TreeSet<>();
|
||||||
|
}
|
||||||
|
Integer missType = rank2miss.get(configIndex);
|
||||||
|
|
||||||
|
SMServerArenaMatchConfig config = STableManager.getConfig(SMServerArenaMatchConfig.class).get(missType);
|
||||||
|
if (config == null) {
|
||||||
|
// 处理serverArenaMatchConfig为空的情况
|
||||||
|
return new TreeSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
//分配对手
|
//分配对手
|
||||||
SMServerArenaMatchConfig serverArenaMatchConfig = STableManager.getConfig(SMServerArenaMatchConfig.class).get(integer1);
|
TreeSet<Integer> objects = new TreeSet<>();
|
||||||
int blockID1 = index - (int) (Math.random() * (serverArenaMatchConfig.getBlock1()[1] - serverArenaMatchConfig.getBlock1()[0]) + serverArenaMatchConfig.getBlock1()[0]);
|
int blockID1 = index - (int) (Math.random() * (config.getBlock1()[1] - config.getBlock1()[0]) + config.getBlock1()[0]);
|
||||||
int blockID2 = index - (int) (Math.random() * (serverArenaMatchConfig.getBlock2()[1] - serverArenaMatchConfig.getBlock2()[0]) + serverArenaMatchConfig.getBlock2()[0]);
|
|
||||||
int blockID3 = index - (int) (Math.random() * (serverArenaMatchConfig.getBlock3()[1] - serverArenaMatchConfig.getBlock3()[0]) + serverArenaMatchConfig.getBlock3()[0]);
|
|
||||||
int blockID4 = index - (int) (Math.random() * (serverArenaMatchConfig.getBlock4()[1] - serverArenaMatchConfig.getBlock4()[0]) + serverArenaMatchConfig.getBlock4()[0]);
|
|
||||||
objects.add(blockID1);
|
objects.add(blockID1);
|
||||||
|
int blockID2 = index - (int) (Math.random() * (config.getBlock2()[1] - config.getBlock2()[0]) + config.getBlock2()[0]);
|
||||||
objects.add(blockID2);
|
objects.add(blockID2);
|
||||||
|
int blockID3 = index - (int) (Math.random() * (config.getBlock3()[1] - config.getBlock3()[0]) + config.getBlock3()[0]);
|
||||||
objects.add(blockID3);
|
objects.add(blockID3);
|
||||||
|
int blockID4 = index - (int) (Math.random() * (config.getBlock4()[1] - config.getBlock4()[0]) + config.getBlock4()[0]);
|
||||||
objects.add(blockID4);
|
objects.add(blockID4);
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue