选拔赛添加竞猜阶段

back_recharge
zhangshanxue 2020-06-29 17:38:26 +08:00
parent c4c03a12d8
commit 0caf4ddadc
1 changed files with 25 additions and 36 deletions

View File

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