自动切赛季
parent
b467cd23f2
commit
41ec525158
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.handler;
|
||||||
import com.ljsd.jieling.handler.map.MapLogic;
|
import com.ljsd.jieling.handler.map.MapLogic;
|
||||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||||
|
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||||
|
@ -54,6 +55,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
||||||
//商店刷新次数重置
|
//商店刷新次数重置
|
||||||
StoreLogic.resetStoreRefreshNum(userId);
|
StoreLogic.resetStoreRefreshNum(userId);
|
||||||
//竞技场免费次数刷新
|
//竞技场免费次数刷新
|
||||||
|
ArenaLogic.getInstance().flushFreeUseTimes(user);
|
||||||
|
|
||||||
}
|
}
|
||||||
user.getPlayerInfoManager().setLoginTime(TimeUtils.now());
|
user.getPlayerInfoManager().setLoginTime(TimeUtils.now());
|
||||||
|
|
|
@ -79,6 +79,9 @@ public class GlobalDataManaager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GlobalSystemControl globalSystemControl = MongoUtil.getInstence().getMyMongoTemplate().findById(GameApplication.serverId, GlobalSystemControl.class);
|
GlobalSystemControl globalSystemControl = MongoUtil.getInstence().getMyMongoTemplate().findById(GameApplication.serverId, GlobalSystemControl.class);
|
||||||
|
if(globalSystemControl == null){
|
||||||
|
globalSystemControl = new GlobalSystemControl(GameApplication.serverId);
|
||||||
|
}
|
||||||
Map<Integer, TimeControllerOfFunction> timeControllerOfFunctionMap = globalSystemControl.getTimeControllerOfFunctionMap();
|
Map<Integer, TimeControllerOfFunction> timeControllerOfFunctionMap = globalSystemControl.getTimeControllerOfFunctionMap();
|
||||||
List<Integer> reallyOpenList = new ArrayList<>();
|
List<Integer> reallyOpenList = new ArrayList<>();
|
||||||
List<Integer> reallyCloseList = new ArrayList<>();
|
List<Integer> reallyCloseList = new ArrayList<>();
|
||||||
|
@ -87,6 +90,12 @@ public class GlobalDataManaager {
|
||||||
TimeControllerOfFunction timeControllerOfFunction = timeControllerOfFunctionMap.get(id);
|
TimeControllerOfFunction timeControllerOfFunction = timeControllerOfFunctionMap.get(id);
|
||||||
if(timeControllerOfFunction == null || timeControllerOfFunction.getStartTime()!=openTimeOfFuntionCache.get(id).getStartTime()){
|
if(timeControllerOfFunction == null || timeControllerOfFunction.getStartTime()!=openTimeOfFuntionCache.get(id).getStartTime()){
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
|
TimeControllerOfFunction timeControllerOfFunctionCacheItem = openTimeOfFuntionCache.get(id);
|
||||||
|
if(timeControllerOfFunction!=null){
|
||||||
|
timeControllerOfFunctionCacheItem.setTimes(timeControllerOfFunction.getTimes()+1);
|
||||||
|
}else{
|
||||||
|
timeControllerOfFunctionCacheItem.setTimes(1);
|
||||||
|
}
|
||||||
globalSystemControl.updateTimeControllerOfFunction(openTimeOfFuntionCache.get(id));
|
globalSystemControl.updateTimeControllerOfFunction(openTimeOfFuntionCache.get(id));
|
||||||
reallyOpenList.add(id);
|
reallyOpenList.add(id);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +103,7 @@ public class GlobalDataManaager {
|
||||||
|
|
||||||
for(Integer id: closeList){
|
for(Integer id: closeList){
|
||||||
TimeControllerOfFunction timeControllerOfFunction = timeControllerOfFunctionMap.get(id);
|
TimeControllerOfFunction timeControllerOfFunction = timeControllerOfFunctionMap.get(id);
|
||||||
if(timeControllerOfFunction != null || timeControllerOfFunction.getStartTime()!=openTimeOfFuntionCache.get(id).getStartTime()){
|
if(timeControllerOfFunction != null && timeControllerOfFunction.getStartTime()!=openTimeOfFuntionCache.get(id).getStartTime()){
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
globalSystemControl.updateTimeControllerOfFunction(openTimeOfFuntionCache.get(id));
|
globalSystemControl.updateTimeControllerOfFunction(openTimeOfFuntionCache.get(id));
|
||||||
reallyCloseList.add(id);
|
reallyCloseList.add(id);
|
||||||
|
@ -111,7 +120,10 @@ public class GlobalDataManaager {
|
||||||
|
|
||||||
public void openAction(List<Integer> ids){
|
public void openAction(List<Integer> ids){
|
||||||
for(Integer openId : ids){
|
for(Integer openId : ids){
|
||||||
|
TimeControllerOfFunction timeControllerOfFunction = openTimeOfFuntionCache.get(openId);
|
||||||
switch (openId){
|
switch (openId){
|
||||||
|
case 8:
|
||||||
|
ArenaLogic.getInstance().updateArenaSeason(timeControllerOfFunction.getTimes());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +136,7 @@ public class GlobalDataManaager {
|
||||||
switch (closeId){
|
switch (closeId){
|
||||||
case 8:
|
case 8:
|
||||||
ArenaLogic.getInstance().sendReward(GlobalsDef.ARENA_SEASON_REWARD);
|
ArenaLogic.getInstance().sendReward(GlobalsDef.ARENA_SEASON_REWARD);
|
||||||
|
ArenaLogic.getInstance().updateArenaSeason(0);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +144,12 @@ public class GlobalDataManaager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void whenServerStart(){
|
public void whenServerStart(){
|
||||||
ActivityLogic.getInstance().checkSecretBoxSeason();
|
try {
|
||||||
|
ActivityLogic.getInstance().checkSecretBoxSeason();
|
||||||
|
checkSystemFunctioIsOpen();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("e",e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -401,10 +401,12 @@ public class ActivityLogic {
|
||||||
|
|
||||||
private void flushSecretBoxFreeTimes(User user){
|
private void flushSecretBoxFreeTimes(User user){
|
||||||
SecretBoxManager secretBoxManager = user.getSecretBoxManager();
|
SecretBoxManager secretBoxManager = user.getSecretBoxManager();
|
||||||
Map<Integer, Integer> freeUseInfos = secretBoxManager.getFreeUseInfos();
|
if(secretBoxManager!=null){
|
||||||
if(freeUseInfos!=null && !freeUseInfos.isEmpty()){
|
Map<Integer, Integer> freeUseInfos = secretBoxManager.getFreeUseInfos();
|
||||||
for(Integer key : freeUseInfos.keySet()){
|
if(freeUseInfos!=null && !freeUseInfos.isEmpty()){
|
||||||
freeUseInfos.put(key,0);
|
for(Integer key : freeUseInfos.keySet()){
|
||||||
|
freeUseInfos.put(key,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ public class ArenaLogic {
|
||||||
public static ArenaLogic getInstance() {
|
public static ArenaLogic getInstance() {
|
||||||
return ArenaLogic.Instance.instance;
|
return ArenaLogic.Instance.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int curSeason;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,9 +58,9 @@ public class ArenaLogic {
|
||||||
arenaManager.setArenaEnemies(arenaEnemies);
|
arenaManager.setArenaEnemies(arenaEnemies);
|
||||||
}
|
}
|
||||||
|
|
||||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,"1", Integer.toString(uid)).intValue();
|
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
||||||
if(score == -1){
|
if(score == -1){
|
||||||
score = 1000;
|
score = SArenaSetting.getSArenaSetting().getScore();
|
||||||
}
|
}
|
||||||
CommonProto.ArenaInfo build = CommonProto.ArenaInfo.newBuilder()
|
CommonProto.ArenaInfo build = CommonProto.ArenaInfo.newBuilder()
|
||||||
.setFailNums(arenaManager.getFailNums())
|
.setFailNums(arenaManager.getFailNums())
|
||||||
|
@ -108,7 +110,7 @@ public class ArenaLogic {
|
||||||
.setUid(enemyId)
|
.setUid(enemyId)
|
||||||
.setLevel(playerInfoManager.getLevel())
|
.setLevel(playerInfoManager.getLevel())
|
||||||
.setName(playerInfoManager.getNickName())
|
.setName(playerInfoManager.getNickName())
|
||||||
.setScore(RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,"1", Integer.toString(enemyId)).intValue())
|
.setScore(RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(enemyId)).intValue())
|
||||||
.setHead(0)
|
.setHead(0)
|
||||||
.setTotalForce(totalForce)
|
.setTotalForce(totalForce)
|
||||||
.build();
|
.build();
|
||||||
|
@ -123,6 +125,10 @@ public class ArenaLogic {
|
||||||
|
|
||||||
|
|
||||||
public void challenge(ISession session,int challengeUid,int teamId,int skipFight) throws Exception {
|
public void challenge(ISession session,int challengeUid,int teamId,int skipFight) throws Exception {
|
||||||
|
if(curSeason == 0){
|
||||||
|
MessageUtil.sendErrorResponse(session,1, MessageTypeProto.MessageType.ARENA_CHALLENGE_RESPONSE_VALUE,"season_close");
|
||||||
|
return;
|
||||||
|
}
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
String err = checkChallenge(user);
|
String err = checkChallenge(user);
|
||||||
|
@ -145,24 +151,24 @@ public class ArenaLogic {
|
||||||
int defScoreChange=0;
|
int defScoreChange=0;
|
||||||
|
|
||||||
if(arenaManager.getCount() != 0){
|
if(arenaManager.getCount() != 0){
|
||||||
myscore = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,"1", Integer.toString(challengeUid)).intValue();
|
myscore = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(challengeUid)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
setMyArenaEnemys(uid,user);
|
setMyArenaEnemys(uid,user);
|
||||||
RedisUtil.getInstence().incrementZsetScore(RedisKey.ARENA_RANK,"1",Integer.toString(uid),myscoreChange);
|
RedisUtil.getInstence().incrementZsetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason),Integer.toString(uid),myscoreChange);
|
||||||
ArenaInfoProto.ArenaChallengeResponse.Builder builder = ArenaInfoProto.ArenaChallengeResponse.newBuilder();
|
ArenaInfoProto.ArenaChallengeResponse.Builder builder = ArenaInfoProto.ArenaChallengeResponse.newBuilder();
|
||||||
if( enemyType == GlobalsDef.ARENA_PLAYER_TYPE){
|
if( enemyType == GlobalsDef.ARENA_PLAYER_TYPE){
|
||||||
ArenaRecord arenaRecord = new ArenaRecord();
|
ArenaRecord arenaRecord = new ArenaRecord();
|
||||||
User defUser = UserManager.getUser(challengeUid);
|
User defUser = UserManager.getUser(challengeUid);
|
||||||
fightResult = getFightResultByPersonToPerson(user, teamId, defUser, GlobalsDef.TEAM_ARENA_DEFENSE,arenaRecord,skipFight,builder);
|
fightResult = getFightResultByPersonToPerson(user, teamId, defUser, GlobalsDef.TEAM_ARENA_DEFENSE,arenaRecord,skipFight,builder);
|
||||||
defScore = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,"1", Integer.toString(challengeUid)).intValue();
|
defScore = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(challengeUid)).intValue();
|
||||||
defScoreChange = calScore(defScore, myscore,fightResult==1?0:1);
|
defScoreChange = calScore(defScore, myscore,fightResult==1?0:1);
|
||||||
myscoreChange = calScore(myscore, defScore,fightResult);
|
myscoreChange = calScore(myscore, defScore,fightResult);
|
||||||
arenaRecord.setAttackId(uid);
|
arenaRecord.setAttackId(uid);
|
||||||
arenaRecord.setCreateTime((int)(System.currentTimeMillis()/1000));
|
arenaRecord.setCreateTime((int)(System.currentTimeMillis()/1000));
|
||||||
arenaRecord.setId(KeyGenUtils.produceIdByModule(UUIDEnum.ARENARECORD,Integer.toString(uid)));
|
arenaRecord.setId(KeyGenUtils.produceIdByModule(UUIDEnum.ARENARECORD,Integer.toString(uid)));
|
||||||
RedisUtil.getInstence().putMapEntry(RedisKey.ARENA_RRECORD,Integer.toString(challengeUid),arenaRecord.getId(),arenaRecord);
|
RedisUtil.getInstence().putMapEntry(RedisKey.ARENA_RRECORD,Integer.toString(challengeUid),arenaRecord.getId(),arenaRecord);
|
||||||
RedisUtil.getInstence().incrementZsetScore(RedisKey.ARENA_RANK,"1",Integer.toString(challengeUid),defScoreChange);
|
RedisUtil.getInstence().incrementZsetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason),Integer.toString(challengeUid),defScoreChange);
|
||||||
}else{
|
}else{
|
||||||
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(challengeUid);
|
SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(challengeUid);
|
||||||
fightResult = getFightResultByPersonToRobot(user, teamId,sArenaRobotConfig,skipFight,builder);
|
fightResult = getFightResultByPersonToRobot(user, teamId,sArenaRobotConfig,skipFight,builder);
|
||||||
|
@ -171,7 +177,7 @@ public class ArenaLogic {
|
||||||
|
|
||||||
}
|
}
|
||||||
if(arenaManager.getCount() == 0){
|
if(arenaManager.getCount() == 0){
|
||||||
RedisUtil.getInstence().incrementZsetScore(RedisKey.ARENA_RANK,"1",Integer.toString(uid),myscoreChange + SArenaSetting.getSArenaSetting().getScore() );
|
RedisUtil.getInstence().incrementZsetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason),Integer.toString(uid),myscoreChange + SArenaSetting.getSArenaSetting().getScore() );
|
||||||
}
|
}
|
||||||
arenaManager.updateChallenge(fightResult);
|
arenaManager.updateChallenge(fightResult);
|
||||||
//组战斗数据
|
//组战斗数据
|
||||||
|
@ -186,7 +192,7 @@ public class ArenaLogic {
|
||||||
Set<Integer> robotIds = randomRobot(user.getPlayerInfoManager().getLevel(), 5);
|
Set<Integer> robotIds = randomRobot(user.getPlayerInfoManager().getLevel(), 5);
|
||||||
toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_ROBOT_TYPE);
|
toArenaEnemy(uid,robotIds,arenaEnemies,GlobalsDef.ARENA_ROBOT_TYPE);
|
||||||
}else{
|
}else{
|
||||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,"1", Integer.toString(uid)).intValue();
|
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
||||||
if(score == -1){
|
if(score == -1){
|
||||||
score = SArenaSetting.getSArenaSetting().getScore();
|
score = SArenaSetting.getSArenaSetting().getScore();
|
||||||
}
|
}
|
||||||
|
@ -259,6 +265,11 @@ public class ArenaLogic {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void flushFreeUseTimes(User user){
|
||||||
|
ArenaManager arenaManager = user.getArenaManager();
|
||||||
|
arenaManager.setUseFreeTimes(0);
|
||||||
|
}
|
||||||
|
|
||||||
private ArenaEnemy getEnemyInList(int challengeUid, List<ArenaEnemy> enemys) {
|
private ArenaEnemy getEnemyInList(int challengeUid, List<ArenaEnemy> enemys) {
|
||||||
for (ArenaEnemy data : enemys) {
|
for (ArenaEnemy data : enemys) {
|
||||||
if (data.getEnemyId() == challengeUid) {
|
if (data.getEnemyId() == challengeUid) {
|
||||||
|
@ -271,6 +282,10 @@ public class ArenaLogic {
|
||||||
|
|
||||||
|
|
||||||
public void randomEnemys(ISession session) throws Exception {
|
public void randomEnemys(ISession session) throws Exception {
|
||||||
|
if(curSeason == 0){
|
||||||
|
MessageUtil.sendErrorResponse(session,1, MessageTypeProto.MessageType.ARENA_RANDOM_ENEMY_RESPONSE_VALUE,"season_close");
|
||||||
|
return;
|
||||||
|
}
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
|
SArenaSetting sArenaSetting = SArenaSetting.getSArenaSetting();
|
||||||
if(sArenaSetting == null){
|
if(sArenaSetting == null){
|
||||||
|
@ -317,7 +332,7 @@ public class ArenaLogic {
|
||||||
for(int[] item: interval){
|
for(int[] item: interval){
|
||||||
int low = item[0];
|
int low = item[0];
|
||||||
int high = item[1];
|
int high = item[1];
|
||||||
Set<String> arenaRank = RedisUtil.getInstence().getZsetRange(RedisKey.ARENA_RANK,"1", myScore * low / 100.0f-1, myScore * high / 100.0f +1);
|
Set<String> arenaRank = RedisUtil.getInstence().getZsetRange(RedisKey.ARENA_RANK,Integer.toString(curSeason), myScore * low / 100.0f-1, myScore * high / 100.0f +1);
|
||||||
if(arenaRank!=null && !arenaRank.isEmpty()){
|
if(arenaRank!=null && !arenaRank.isEmpty()){
|
||||||
arenaRank.remove(Integer.toString(uid));
|
arenaRank.remove(Integer.toString(uid));
|
||||||
String s = randomSet(arenaRank);
|
String s = randomSet(arenaRank);
|
||||||
|
@ -351,13 +366,16 @@ public class ArenaLogic {
|
||||||
|
|
||||||
|
|
||||||
public void getWorldRankByPage(ISession session,int page) throws Exception {
|
public void getWorldRankByPage(ISession session,int page) throws Exception {
|
||||||
|
if(curSeason == 0){
|
||||||
|
MessageUtil.sendErrorResponse(session,1, MessageTypeProto.MessageType.ARENA_RANK_RESPONSE_VALUE,"season_close");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (page == 0) {
|
if (page == 0) {
|
||||||
page = 1;
|
page = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
int start = (page - 1) * 20, end = page * 20 - 1;
|
int start = (page - 1) * 20, end = page * 20 - 1;
|
||||||
List<CommonProto.ArenaEnemy> arenaRankMemberInfo = new ArrayList<>(20);
|
List<CommonProto.ArenaEnemy> arenaRankMemberInfo = new ArrayList<>(20);
|
||||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK,"1", start, end);
|
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK,Integer.toString(curSeason), start, end);
|
||||||
for(ZSetOperations.TypedTuple<String> item : arenaRankInfo){
|
for(ZSetOperations.TypedTuple<String> item : arenaRankInfo){
|
||||||
String value = item.getValue();
|
String value = item.getValue();
|
||||||
int score =item.getScore().intValue();
|
int score =item.getScore().intValue();
|
||||||
|
@ -387,12 +405,12 @@ public class ArenaLogic {
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
int uid = session.getUid();
|
int uid = session.getUid();
|
||||||
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,"1", Integer.toString(uid)).intValue();
|
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ARENA_RANK,Integer.toString(curSeason), Integer.toString(uid)).intValue();
|
||||||
int myRank =-1;
|
int myRank =-1;
|
||||||
if(score == -1){
|
if(score == -1){
|
||||||
score = SArenaSetting.getSArenaSetting().getScore();
|
score = SArenaSetting.getSArenaSetting().getScore();
|
||||||
}else{
|
}else{
|
||||||
myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.ARENA_RANK,"1",Integer.toString(uid)).intValue();
|
myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.ARENA_RANK,Integer.toString(curSeason),Integer.toString(uid)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArenaInfoProto.GetArenaRankInfoResponse buildResponse = ArenaInfoProto.GetArenaRankInfoResponse.newBuilder()
|
ArenaInfoProto.GetArenaRankInfoResponse buildResponse = ArenaInfoProto.GetArenaRankInfoResponse.newBuilder()
|
||||||
|
@ -407,6 +425,10 @@ public class ArenaLogic {
|
||||||
|
|
||||||
|
|
||||||
public void getArenaRecord(ISession iSession) throws Exception {
|
public void getArenaRecord(ISession iSession) throws Exception {
|
||||||
|
if(curSeason == 0){
|
||||||
|
MessageUtil.sendErrorResponse(iSession,1, MessageTypeProto.MessageType.ARENA_DEFENSE_RESPONSE_VALUE,"season_close");
|
||||||
|
return;
|
||||||
|
}
|
||||||
int uid = iSession.getUid();
|
int uid = iSession.getUid();
|
||||||
Map<String, ArenaRecord> result = RedisUtil.getInstence().getMapValues(RedisKey.ARENA_RRECORD, Integer.toString(uid), String.class, ArenaRecord.class);
|
Map<String, ArenaRecord> result = RedisUtil.getInstence().getMapValues(RedisKey.ARENA_RRECORD, Integer.toString(uid), String.class, ArenaRecord.class);
|
||||||
if(result!=null && !result.isEmpty()){
|
if(result!=null && !result.isEmpty()){
|
||||||
|
@ -503,6 +525,9 @@ public class ArenaLogic {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void sendReward(int type) throws Exception {
|
public void sendReward(int type) throws Exception {
|
||||||
|
if(curSeason == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
String title;
|
String title;
|
||||||
String content;
|
String content;
|
||||||
if(type == GlobalsDef.ARENA_DAILY_REWARD){
|
if(type == GlobalsDef.ARENA_DAILY_REWARD){
|
||||||
|
@ -512,7 +537,7 @@ public class ArenaLogic {
|
||||||
title = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_title");
|
title = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_title");
|
||||||
content = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_txt");
|
content = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_txt");
|
||||||
}
|
}
|
||||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK,"1", 0, -1);
|
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK,Integer.toString(curSeason), 0, -1);
|
||||||
int rank = 1;
|
int rank = 1;
|
||||||
int nowTime =(int) (TimeUtils.now()/1000);
|
int nowTime =(int) (TimeUtils.now()/1000);
|
||||||
for(ZSetOperations.TypedTuple<String> item : arenaRankInfo){
|
for(ZSetOperations.TypedTuple<String> item : arenaRankInfo){
|
||||||
|
@ -544,6 +569,10 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateArenaSeason(int curSeason){
|
||||||
|
this.curSeason = curSeason;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.ljsd.jieling.logic.dao;
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
import com.ljsd.common.mogodb.MongoBase;
|
|
||||||
|
|
||||||
public class TimeControllerOfFunction extends MongoBase {
|
public class TimeControllerOfFunction {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private int status;
|
private int status;
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private long endTime;
|
private long endTime;
|
||||||
|
private int times; //开了几次
|
||||||
|
|
||||||
public TimeControllerOfFunction(){}
|
public TimeControllerOfFunction(){}
|
||||||
|
|
||||||
|
@ -33,4 +33,12 @@ public class TimeControllerOfFunction extends MongoBase {
|
||||||
public long getEndTime() {
|
public long getEndTime() {
|
||||||
return endTime;
|
return endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimes() {
|
||||||
|
return times;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimes(int times) {
|
||||||
|
this.times = times;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ljsd.jieling.logic.dao.root;
|
package com.ljsd.jieling.logic.dao.root;
|
||||||
|
|
||||||
import com.ljsd.common.mogodb.MongoRoot;
|
|
||||||
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -14,6 +13,10 @@ public class GlobalSystemControl {
|
||||||
|
|
||||||
private Map<Integer, TimeControllerOfFunction> timeControllerOfFunctionMap = new HashMap<>();
|
private Map<Integer, TimeControllerOfFunction> timeControllerOfFunctionMap = new HashMap<>();
|
||||||
|
|
||||||
|
public GlobalSystemControl(int id){
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateTimeControllerOfFunction(TimeControllerOfFunction timeControllerOfFunction){
|
public void updateTimeControllerOfFunction(TimeControllerOfFunction timeControllerOfFunction){
|
||||||
timeControllerOfFunctionMap.put(timeControllerOfFunction.getId(),timeControllerOfFunction);
|
timeControllerOfFunctionMap.put(timeControllerOfFunction.getId(),timeControllerOfFunction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ljsd.jieling.thread;
|
package com.ljsd.jieling.thread;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.thread.task.DailyOfZeroTask;
|
||||||
import com.ljsd.jieling.thread.task.MinuteTask;
|
import com.ljsd.jieling.thread.task.MinuteTask;
|
||||||
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -59,12 +60,16 @@ public class ThreadManager {
|
||||||
|
|
||||||
|
|
||||||
public void go() {
|
public void go() {
|
||||||
long now = System.currentTimeMillis();
|
int now = (int)(System.currentTimeMillis()/1000);
|
||||||
scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
|
scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
|
||||||
|
|
||||||
// testTask 已秒为单位 延迟10s, 间隔30s为周期执行
|
// testTask 已秒为单位 延迟10s, 间隔30s为周期执行
|
||||||
|
int delayForMinute = 60 - (now%60);
|
||||||
|
int delayForDay = 3600*24 - (now%(3600*24));
|
||||||
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||||
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), 10, 60, TimeUnit.SECONDS);
|
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS);
|
||||||
|
scheduledExecutor.scheduleAtFixedRate(new DailyOfZeroTask(), delayForDay, 3600*24, TimeUnit.SECONDS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScheduledThreadPoolExecutor getScheduledExecutor() {
|
public ScheduledThreadPoolExecutor getScheduledExecutor() {
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.ljsd.jieling.thread.task;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
|
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class DailyOfZeroTask extends Thread {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(DailyOfZeroTask.class);
|
||||||
|
|
||||||
|
public DailyOfZeroTask() {
|
||||||
|
this.setName("DailyOfZeroTask");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
LOGGER.info("DailyOfZeroTask start ...");
|
||||||
|
ArenaLogic.getInstance().sendReward(GlobalsDef.ARENA_DAILY_REWARD);
|
||||||
|
LOGGER.info("DailyOfZeroTask end ...");
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.info("e",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ljsd.jieling.thread.task;
|
package com.ljsd.jieling.thread.task;
|
||||||
|
|
||||||
import com.ljsd.jieling.handler.map.MapLogic;
|
import com.ljsd.jieling.handler.map.MapLogic;
|
||||||
|
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -14,8 +15,15 @@ public class MinuteTask extends Thread {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ActivityLogic.getInstance().checkActiviyStatus();
|
try {
|
||||||
ActivityLogic.getInstance().checkSecretBoxSeason();
|
LOGGER.info("MinuteTask start...");
|
||||||
MapLogic.getInstance().minuteCheckAndRemoveMapRank();
|
ActivityLogic.getInstance().checkActiviyStatus();
|
||||||
|
ActivityLogic.getInstance().checkSecretBoxSeason();
|
||||||
|
MapLogic.getInstance().minuteCheckAndRemoveMapRank();
|
||||||
|
GlobalDataManaager.getInstance().checkSystemFunctioIsOpen();
|
||||||
|
LOGGER.info("MinuteTask end...");
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("e",e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue