选拔赛添加竞猜阶段
parent
c4c03a12d8
commit
0caf4ddadc
|
@ -1,8 +1,6 @@
|
||||||
package com.ljsd.jieling.logic.championship;
|
package com.ljsd.jieling.logic.championship;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.googlecode.protobuf.format.JsonFormat;
|
|
||||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
|
@ -32,19 +30,19 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
import com.ljsd.jieling.thread.ThreadManager;
|
import com.ljsd.jieling.thread.ThreadManager;
|
||||||
import com.ljsd.jieling.util.*;
|
import com.ljsd.jieling.util.*;
|
||||||
import config.*;
|
import config.*;
|
||||||
;
|
|
||||||
import manager.STableManager;
|
import manager.STableManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.core.DefaultTypedTuple;
|
import org.springframework.data.redis.core.DefaultTypedTuple;
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
import util.MathUtils;
|
|
||||||
import util.StringUtil;
|
import util.StringUtil;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
public class ChampionshipLogic {
|
public class ChampionshipLogic {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HeroLogic.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(HeroLogic.class);
|
||||||
//启动服务器应该去redis获取
|
//启动服务器应该去redis获取
|
||||||
|
@ -428,7 +426,7 @@ public class ChampionshipLogic {
|
||||||
|
|
||||||
public static void getChampionBetInfo(ISession session,int type) throws Exception {
|
public static void getChampionBetInfo(ISession session,int type) throws Exception {
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
if(progress==-1 || schedule==1){
|
if(progress==-1){
|
||||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||||
}
|
}
|
||||||
String selectIdForRedis = getSelectIdForRedis();
|
String selectIdForRedis = getSelectIdForRedis();
|
||||||
|
@ -1112,11 +1110,8 @@ public class ChampionshipLogic {
|
||||||
int[][] itemNum = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getItemNum();
|
int[][] itemNum = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getItemNum();
|
||||||
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(functionId);
|
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(functionId);
|
||||||
Map<String,Integer> sendIds = new HashMap<>();
|
Map<String,Integer> sendIds = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
snapPlayFightInfo();
|
snapPlayFightInfo();
|
||||||
if(schedule==2){
|
OnlineUserManager.sessionMap.values().forEach(session->{
|
||||||
OnlineUserManager.sessionMap.values().forEach(session->{
|
|
||||||
try {
|
try {
|
||||||
sendIds.put(Integer.toString(session.getUid()),1);
|
sendIds.put(Integer.toString(session.getUid()),1);
|
||||||
User user = UserManager.getUser(session.getUid());
|
User user = UserManager.getUser(session.getUid());
|
||||||
|
@ -1146,9 +1141,9 @@ public class ChampionshipLogic {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_GUESSS_UIDS,"",sendIds);
|
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_GUESSS_UIDS,"",sendIds);
|
||||||
selectBetTeam();
|
selectBetTeam();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1265,25 +1260,19 @@ public class ChampionshipLogic {
|
||||||
long now = TimeUtils.now();
|
long now = TimeUtils.now();
|
||||||
long startTime = timeControllerOfFunction.getStartTime();
|
long startTime = timeControllerOfFunction.getStartTime();
|
||||||
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
|
||||||
int durationSelect = sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
|
int duration = sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
|
||||||
int durationFinal = durationSelect+ sChampionshipSetting.getGuessTime() ;
|
int progressState=getProgress((int)((now - startTime)/1000%duration +1));
|
||||||
int progressState=getProgress((int)((now - startTime)/1000%durationSelect +1));
|
long round = (now - startTime) /1000/ duration + 1;
|
||||||
long round = (now - startTime) /1000/ durationSelect + 1;
|
|
||||||
roundTimes = (int) round;
|
roundTimes = (int) round;
|
||||||
long diff = round - (sChampionshipSetting.getTrialsGroup() - 1);
|
long diff = round - (sChampionshipSetting.getTrialsGroup() - 1);
|
||||||
int progressTmp;
|
int progressTmp;
|
||||||
|
|
||||||
if(diff<=0){ //选拔赛
|
if(diff<=0){ //选拔赛
|
||||||
//竞猜阶段取消,改成直接战斗
|
// //竞猜阶段取消,改成直接战斗 fix 又改回来了
|
||||||
progressState = progressState==1?2:progressState;
|
// progressState = progressState==1?2:progressState;
|
||||||
progressTmp =100 + roundTimes*10 + progressState;
|
progressTmp =100 + roundTimes*10 + progressState;
|
||||||
schedule=1;
|
schedule=1;
|
||||||
}else {//决赛
|
}else {//决赛
|
||||||
long passTIme = (now - startTime - (sChampionshipSetting.getTrialsGroup() - 1) * 1000L * durationSelect )/1000;
|
|
||||||
round = passTIme / durationFinal + sChampionshipSetting.getTrialsGroup() ;
|
|
||||||
roundTimes = (int) round ;
|
|
||||||
diff = round - (sChampionshipSetting.getTrialsGroup() - 1);
|
|
||||||
progressState=getProgress((int)(passTIme%durationFinal +1));
|
|
||||||
int totalWiner =sChampionshipSetting.getChampionshipPlayer()/ sChampionshipSetting.getTrialsGroup() * sChampionshipSetting.getTrialsGroupWinner();
|
int totalWiner =sChampionshipSetting.getChampionshipPlayer()/ sChampionshipSetting.getTrialsGroup() * sChampionshipSetting.getTrialsGroupWinner();
|
||||||
if(diff>totalWiner || Math.pow(2,diff)>totalWiner){
|
if(diff>totalWiner || Math.pow(2,diff)>totalWiner){
|
||||||
schedule=2;
|
schedule=2;
|
||||||
|
@ -1305,11 +1294,13 @@ public class ChampionshipLogic {
|
||||||
if(progressTmp == progress){
|
if(progressTmp == progress){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(schedule ==1) {
|
|
||||||
endTime = (int)( startTime/1000 + (round-1)*durationSelect + getDuratimeByProgressState(progressState));
|
//todo
|
||||||
}else{
|
// if(schedule ==1) {
|
||||||
endTime = (int)( startTime/1000 + (sChampionshipSetting.getTrialsGroup()-1)*durationSelect + (round-sChampionshipSetting.getTrialsGroup())*durationFinal + getDuratimeByProgressState(progressState));
|
endTime = (int)( startTime/1000 + (round-1)*duration + getDuratimeByProgressState(progressState));
|
||||||
}
|
// }else{
|
||||||
|
// endTime = (int)( startTime/1000 + (sChampionshipSetting.getTrialsGroup()-1)*durationSelect + (round-sChampionshipSetting.getTrialsGroup())*durationFinal + getDuratimeByProgressState(progressState));
|
||||||
|
// }
|
||||||
progress = progressTmp;
|
progress = progressTmp;
|
||||||
if(isServerStart){
|
if(isServerStart){
|
||||||
return;
|
return;
|
||||||
|
@ -1323,7 +1314,7 @@ public class ChampionshipLogic {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(progress%10%4==1 || (schedule==1 && progress%10%4==2)){ //竞猜阶段 后台自动运行战斗
|
if(progress%10%4==1){ //竞猜阶段 后台自动运行战斗
|
||||||
ThreadManager.getScheduledExecutor().execute(new Runnable() {
|
ThreadManager.getScheduledExecutor().execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -1342,9 +1333,7 @@ public class ChampionshipLogic {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
scoreToRedis();
|
scoreToRedis();
|
||||||
if(schedule==2){
|
sendBetReward();
|
||||||
sendBetReward();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1367,12 +1356,12 @@ public class ChampionshipLogic {
|
||||||
return sChampionshipSetting.getPrepareTime();
|
return sChampionshipSetting.getPrepareTime();
|
||||||
}
|
}
|
||||||
if(progressState == 1){
|
if(progressState == 1){
|
||||||
return sChampionshipSetting.getPrepareTime() +(schedule==2? sChampionshipSetting.getGuessTime():0);
|
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime();
|
||||||
}
|
}
|
||||||
if(progressState == 2){
|
if(progressState == 2){
|
||||||
return sChampionshipSetting.getPrepareTime() + (schedule==2? sChampionshipSetting.getGuessTime():0) + sChampionshipSetting.getBattleTime();
|
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime();
|
||||||
}
|
}
|
||||||
return sChampionshipSetting.getPrepareTime() + (schedule==2? sChampionshipSetting.getGuessTime():0) + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
|
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue