跨服服务器
parent
95870b74d5
commit
6ef71dc4b5
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -63,6 +63,7 @@ public enum FunctionIdEnum {
|
|||
DeathPath(72,null),
|
||||
Car_Delay(73,new CarDelayFunction()),
|
||||
Situation_challenge(74,null),
|
||||
World_Arena(82,new WorldArenaFunction()),
|
||||
;
|
||||
|
||||
private int functionType;
|
||||
|
|
|
@ -47,5 +47,5 @@ public interface VipPrivilegeType {
|
|||
int ADVENTURE_ADD_TIME = 2002;//挂机时常增加
|
||||
|
||||
int DRAGON_TREASURE_SUPPLY = 1007;//青龙宝藏每周补给
|
||||
|
||||
int WORLD_ARENA_CHALLENGE_TIMES = 2010; //跨服天梯
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.ljsd.jieling.core.function;
|
||||
|
||||
import com.ljsd.jieling.core.FunctionManager;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
||||
import config.SMServerArenaSetting;
|
||||
import manager.STableManager;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 跨服竞技场 初始化参赛人员
|
||||
*/
|
||||
public class WorldArenaFunction implements FunctionManager {
|
||||
@Override
|
||||
public void startAction(TimeControllerOfFunction timeControllerOfFunction) throws Exception {
|
||||
if(TimeUtils.now() - timeControllerOfFunction.getStartTime()>1000*60*3 ){
|
||||
return;
|
||||
}
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
if(setting!=null){
|
||||
//获取竞技场排行榜
|
||||
int curSeason = ArenaLogic.getInstance().getCurSeason();
|
||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfo = new HashSet<>(setting.getJoinRank());
|
||||
Set<ZSetOperations.TypedTuple<String>> arenaRankInfoOne = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, setting.getJoinRank());
|
||||
if (arenaRankInfoOne != null && !arenaRankInfoOne.isEmpty()) {
|
||||
arenaRankInfo.addAll(arenaRankInfoOne);
|
||||
}
|
||||
//join
|
||||
Map<String, Integer> memberInfoMap = new HashMap<>();
|
||||
int i=1;
|
||||
for (ZSetOperations.TypedTuple<String> item:arenaRankInfo) {
|
||||
memberInfoMap.put(item.getValue(), i);
|
||||
i+=1;
|
||||
}
|
||||
RedisUtil.getInstence().putMapEntrys(RedisKey.WORLD_ARE_JOIN, "", memberInfoMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAction() throws Exception {
|
||||
// ChampionshipLogic.close();
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ public class AreaManager {
|
|||
public static ServerAreaInfoManager serverArenaInfoManagerCache;
|
||||
public AtomicBoolean isInit = new AtomicBoolean(false);
|
||||
|
||||
|
||||
public void init() {
|
||||
initParm();
|
||||
isInit.set(true);
|
||||
|
|
|
@ -300,6 +300,8 @@ public class RedisKey {
|
|||
//排行前几名 世界等级排行 时间等级排行 要不要加个时间向量?开服一定深度 世界等级没变化
|
||||
public static final String WORLD_CALCUL_LEVE_RAND = "WORLD_CALCUL_LEVE_RAND";
|
||||
|
||||
public final static String WORLD_ARE_JOIN = "WORLD_ARE_JOIN";//跨服参与人员
|
||||
|
||||
|
||||
public static Set<String> familyKey = new HashSet<>();
|
||||
|
||||
|
|
|
@ -156,7 +156,10 @@ public enum ErrorCode implements IErrorCode {
|
|||
NOT_IN_TAKE_TIME(126, "不在领取期间"),
|
||||
USER_LEVE_DOWN(127,"玩家等级不够"),
|
||||
HAS_AWAKE(130,"已达最大星级"),
|
||||
SERVER_DEFINE_SELF(20000,"操作失败")
|
||||
SERVER_DEFINE_SELF(20000,"操作失败"),
|
||||
|
||||
RANKLIMIT(20000, "不在榜单"),
|
||||
|
||||
|
||||
;
|
||||
private static final Set<Integer> CodeSet = new HashSet<>();
|
||||
|
|
|
@ -160,7 +160,7 @@ public interface BIReason {
|
|||
int SUB_ACTIVITY_FINISH = 91;//易经宝库活动结束补发
|
||||
|
||||
int WORLD_CHANGE_DROP =100;//跨服天梯
|
||||
|
||||
int WORLD_PRO_DROP =101;//跨服天梯膜拜
|
||||
|
||||
|
||||
int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级
|
||||
|
@ -299,4 +299,6 @@ public interface BIReason {
|
|||
int SKIN_USE_CONSUME = 1073;//激活皮肤消耗
|
||||
int SUB_ACTIVITY_CONSUME = 1074;//易经宝库
|
||||
int SUB_ACTIVITY_CONSUME_FINISH = 1075;//易经宝库活动结束补发消耗
|
||||
|
||||
int WORLD_ARENA = 1090;//跨服竞技场
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.ljsd.jieling.handler.map.MapManager;
|
|||
import com.ljsd.jieling.ktbeans.ReportEventEnum;
|
||||
import com.ljsd.jieling.ktbeans.ReportUtil;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.event.NewWelfareEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum;
|
||||
|
@ -223,6 +224,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
try {
|
||||
//hotfix
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.DAILY_TASK_TYPE,0,user);
|
||||
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.WorldLevelIndication_VALUE, PlayerInfoProto.WorldLevelIndication.newBuilder().setWorldLeve(GlobleSystemLogic.getGloableWorldLeveCache()).build(), true);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);
|
||||
|
||||
// DoFix.getInstance().loginFix(user);
|
||||
|
|
|
@ -8,6 +8,7 @@ import rpc.world.WorldProto;
|
|||
|
||||
/**
|
||||
* rpc get userinfo
|
||||
* 世界服请求逻辑服玩家信息
|
||||
*/
|
||||
public class GetGSUserArenaInfoRequestHandler extends gtGBaseHandler<WorldProto.GetGSUserArenaInfoRequest> {
|
||||
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
package com.ljsd.jieling.handler.gtw;
|
||||
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.arenaworld.ArenaWorldLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.network.server.GlobalidHelper;
|
||||
import com.ljsd.jieling.network.server.WorldHelper;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import config.SGlobalSystemConfig;
|
||||
import config.SMServerArenaSetting;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
|
@ -30,6 +41,53 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
|
|||
if (null == worldInfo) {
|
||||
throw new ErrorCodeException("world unavailable or play not open");
|
||||
}
|
||||
|
||||
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(FunctionIdEnum.World_Arena.getFunctionType());
|
||||
if (!ArenaWorldLogic.checkOpen(String.valueOf(iSession.getUid()))) {
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||
}
|
||||
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
if(setting==null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
long diff = System.currentTimeMillis() - sGlobalSystemConfig.getSeasonOpenLong();
|
||||
|
||||
if (diff > setting.getBattleTime()[0] && diff < setting.getBattleTime()[1]) {
|
||||
|
||||
} else {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
|
||||
}
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
|
||||
//tiem limit
|
||||
// if(user.getArenaManager().getCostDallyTime()>=setting.getCostMax()){
|
||||
// throw new ErrorCodeException(ErrorCode.NOTIME2);
|
||||
// }
|
||||
boolean check = PlayerLogic.getInstance().check(user, VipPrivilegeType.WORLD_ARENA_CHALLENGE_TIMES, 1);
|
||||
if(!check){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
//rank limit
|
||||
if (!ArenaWorldLogic.checkJoin(String.valueOf(iSession.getUid()))) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
|
||||
}
|
||||
|
||||
|
||||
//走特权
|
||||
// if(user.getArenaManager().getWorldFreeChallengeTime()>0){
|
||||
// //free
|
||||
// user.getArenaManager().setWorldFreeChallengeTime(user.getArenaManager().getWorldFreeChallengeTime() -1);
|
||||
// }else {
|
||||
//check costs
|
||||
int[][] costItems = new int[1][];
|
||||
costItems[0]=setting.getCost();
|
||||
boolean enough = ItemUtil.itemCost(user, costItems, BIReason.WORLD_ARENA, 0);
|
||||
if (!enough) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
// }
|
||||
|
||||
boolean b;
|
||||
if (proto.getSkipFight() == 0) {
|
||||
WorldProto.GetWorldArenaChallengeRequest.Builder builder = WorldProto.GetWorldArenaChallengeRequest.newBuilder()
|
||||
|
@ -38,13 +96,15 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
|
|||
.setChallengeRank(proto.getChallengeRank())
|
||||
.setSkipFight(proto.getSkipFight())
|
||||
.setArenaEnemys(ArenaLogic.getInstance().getUserArenaEnemy(iSession.getUid(), proto.getTeamId()))
|
||||
.setFightTeamInfo(FightUtil.getFightTeamInfo(UserManager.getUser(iSession.getUid()), proto.getTeamId()));
|
||||
.setFightTeamInfo(FightUtil.getFightTeamInfo(user, proto.getTeamId()));
|
||||
//转发到world服
|
||||
b = WorldHelper.sendMessageToWord(iSession.getUid(), builder.build());
|
||||
} else {
|
||||
b =WorldHelper.sendMessageToWord(iSession.getUid(), proto);
|
||||
b = WorldHelper.sendMessageToWord(iSession.getUid(), proto);
|
||||
}
|
||||
|
||||
user.getArenaManager().setCostDallyTime(user.getArenaManager().getCostDallyTime()+1);
|
||||
|
||||
if (!b) {
|
||||
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ public class GetWorldArenaChallengeResponseHandler extends gtGBaseHandler<WorldP
|
|||
WorldProto.GetWorldArenaChallengeResponse.Builder builder = WorldProto.GetWorldArenaChallengeResponse.newBuilder(proto);
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
int[][] reward = new int[1][];
|
||||
reward[0]=setting.getBattleWinReward();
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(UserManager.getUser(rpcMessage.getUid()), reward, BIReason.WORLD_CHANGE_DROP);
|
||||
reward[0]=setting.getRespectReward();
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(UserManager.getUser(rpcMessage.getUid()), reward, BIReason.WORLD_PRO_DROP);
|
||||
builder.setDrop(drop);
|
||||
MessageUtil.sendIndicationMessage(rpcMessage.getUid(),rpcMessage.getProtpId(),builder.build().toByteArray());
|
||||
return super.processWithProto(rpcMessage, proto);
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package com.ljsd.jieling.handler.gtw;
|
||||
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.network.server.GlobalidHelper;
|
||||
import com.ljsd.jieling.network.server.WorldHelper;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import config.SGlobalSystemConfig;
|
||||
import config.SMServerArenaSetting;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
|
@ -23,11 +29,26 @@ public class GetWorldArenaInfoRequestHandler extends BaseHandler<WorldProto.GetW
|
|||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, WorldProto.GetWorldArenaInfoRequest proto) throws Exception {
|
||||
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(FunctionIdEnum.World_Arena.getFunctionType());
|
||||
if (!HandlerLogicThread.checkOpen(UserManager.getUser(iSession.getUid()),sGlobalSystemConfig)) {
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||
}
|
||||
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
if(setting==null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
long diff = System.currentTimeMillis() - sGlobalSystemConfig.getSeasonOpenLong();
|
||||
|
||||
if(diff>setting.getRestTime()[0]&&diff<setting.getRestTime()[1]){
|
||||
WorldProto.GetWorldArenaInfoRequest.Builder builder = WorldProto.GetWorldArenaInfoRequest.newBuilder(proto);
|
||||
builder.setIsPro(true);
|
||||
}
|
||||
|
||||
GlobalidHelper.WorldInfo worldInfo = GlobalidHelper.getWorldInfo();
|
||||
if (null == worldInfo){
|
||||
throw new ErrorCodeException("world unavailable or play not open");
|
||||
}
|
||||
|
||||
//转发到world服
|
||||
boolean b = WorldHelper.sendMessageToWord(iSession.getUid(),proto);
|
||||
if(!b){
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.ljsd.jieling.handler.gtw;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SGlobalSystemConfig;
|
||||
import config.SMServerArenaSetting;
|
||||
import manager.STableManager;
|
||||
import rpc.net.RpcMessage;
|
||||
import rpc.net.gtGBaseHandler;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
/**
|
||||
* Description: des
|
||||
* Author: zsx
|
||||
* CreateDate: 2020/12/4 14:53
|
||||
*/
|
||||
public class GetWorldArenaInfoResponseHandler extends gtGBaseHandler<WorldProto.GetWorldArenaInfoResponse> {
|
||||
|
||||
@Override
|
||||
public GeneratedMessage processWithProto(RpcMessage rpcMessage, WorldProto.GetWorldArenaInfoResponse proto) throws Exception {
|
||||
|
||||
//检查一下 没有定义handler 世界服回传的消息不拦截则透传
|
||||
|
||||
if (proto.getStage() != 1) {
|
||||
WorldProto.GetWorldArenaInfoResponse.Builder builder = WorldProto.GetWorldArenaInfoResponse.newBuilder(proto);
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
if (setting == null) {
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(FunctionIdEnum.World_Arena.getFunctionType());
|
||||
long seasonOpenLong = sGlobalSystemConfig.getSeasonOpenLong();
|
||||
long diff = System.currentTimeMillis() - seasonOpenLong;
|
||||
|
||||
if (diff > setting.getRestTime()[0] && diff < setting.getRestTime()[1]) {
|
||||
builder.setStage(3);
|
||||
builder.setEndTime((int)(seasonOpenLong/1000+setting.getRestTime()[1]));
|
||||
} else if (diff > setting.getBattleTime()[0] && diff < setting.getBattleTime()[1]) {
|
||||
builder.setStage(2);
|
||||
builder.setEndTime((int)(seasonOpenLong/1000+setting.getBattleTime()[1]));
|
||||
} else {
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||
}
|
||||
proto = builder.build();
|
||||
}
|
||||
|
||||
MessageUtil.sendIndicationMessage(rpcMessage.getUid(), rpcMessage.getProtpId(), proto.toByteArray());
|
||||
return super.processWithProto(rpcMessage, proto);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,18 @@
|
|||
package com.ljsd.jieling.handler.gtw;
|
||||
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.arenaworld.ArenaWorldLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.network.server.GlobalidHelper;
|
||||
import com.ljsd.jieling.network.server.WorldHelper;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import config.SGlobalSystemConfig;
|
||||
import config.SMServerArenaSetting;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.world.WorldCommonProto;
|
||||
|
||||
|
@ -24,10 +31,31 @@ public class GetWorldArenaProudRequestHandler extends BaseHandler<WorldCommonPro
|
|||
@Override
|
||||
public void processWithProto(ISession iSession, WorldCommonProto.GetWorldArenaProudRequest proto) throws Exception {
|
||||
|
||||
|
||||
GlobalidHelper.WorldInfo worldInfo = GlobalidHelper.getWorldInfo();
|
||||
if (null == worldInfo){
|
||||
throw new ErrorCodeException("world unavailable or play not open");
|
||||
}
|
||||
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(FunctionIdEnum.World_Arena.getFunctionType());
|
||||
if (!HandlerLogicThread.checkOpen(UserManager.getUser(iSession.getUid()),sGlobalSystemConfig)) {
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||
}
|
||||
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
if(setting==null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
long diff = System.currentTimeMillis() - sGlobalSystemConfig.getSeasonOpenLong();
|
||||
|
||||
if(diff>setting.getRestTime()[0]&&diff<setting.getRestTime()[1]){
|
||||
}else {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
|
||||
}
|
||||
|
||||
//rank limit
|
||||
if (!ArenaWorldLogic.checkJoin(String.valueOf(iSession.getUid()))) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
|
||||
}
|
||||
|
||||
//转发到world服
|
||||
boolean b = WorldHelper.sendMessageToWord(iSession.getUid(),proto);
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.ljsd.jieling.handler.gtw;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SGlobalSystemConfig;
|
||||
import config.SMServerArenaSetting;
|
||||
import manager.STableManager;
|
||||
import rpc.net.RpcMessage;
|
||||
import rpc.net.gtGBaseHandler;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
/**
|
||||
* Description: des
|
||||
* Author: zsx
|
||||
* CreateDate: 2020/12/4 14:53
|
||||
*/
|
||||
public class GetWorldArenaProudResponseHandler extends gtGBaseHandler<WorldProto.GetWorldArenaProudResponse> {
|
||||
|
||||
@Override
|
||||
public GeneratedMessage processWithProto(RpcMessage rpcMessage, WorldProto.GetWorldArenaProudResponse proto) throws Exception {
|
||||
|
||||
//检查一下 没有定义handler 世界服回传的消息不拦截则透传
|
||||
if (proto.getErr() != -1) {
|
||||
WorldProto.GetWorldArenaProudResponse.Builder builder = WorldProto.GetWorldArenaProudResponse.newBuilder(proto);
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
int[][] reward = new int[1][];
|
||||
reward[0] = setting.getBattleWinReward();
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(UserManager.getUser(rpcMessage.getUid()), reward, BIReason.WORLD_CHANGE_DROP);
|
||||
builder.setDrop(drop);
|
||||
proto = builder.build();
|
||||
}
|
||||
|
||||
MessageUtil.sendIndicationMessage(rpcMessage.getUid(), rpcMessage.getProtpId(),proto.toByteArray());
|
||||
return super.processWithProto(rpcMessage, proto);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,18 @@
|
|||
package com.ljsd.jieling.handler.gtw;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.network.server.GlobalidHelper;
|
||||
import com.ljsd.jieling.network.server.WorldHelper;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import config.SGlobalSystemConfig;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.world.WorldProto;
|
||||
|
||||
|
@ -23,6 +29,12 @@ public class GetWorldArenaRecordInfoRequestHandler extends BaseHandler<WorldProt
|
|||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, WorldProto.GetWorldArenaRecordInfoRequest proto) throws Exception {
|
||||
|
||||
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(FunctionIdEnum.World_Arena.getFunctionType());
|
||||
if (!HandlerLogicThread.checkOpen(UserManager.getUser(iSession.getUid()),sGlobalSystemConfig)) {
|
||||
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||
}
|
||||
|
||||
GlobalidHelper.WorldInfo worldInfo = GlobalidHelper.getWorldInfo();
|
||||
if (null == worldInfo){
|
||||
throw new ErrorCodeException("world unavailable or play not open");
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.ljsd.jieling.db.redis.RedisKey;
|
|||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.kefu.GmRoleAbstract;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
||||
|
@ -13,6 +14,8 @@ import com.ljsd.jieling.logic.activity.IEventHandler;
|
|||
import com.ljsd.jieling.logic.activity.event.*;
|
||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.InnerMessageUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SGlobalActivity;
|
||||
import config.SGodSacrificeSetting;
|
||||
import manager.STableManager;
|
||||
|
@ -21,6 +24,8 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -186,8 +191,14 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
}
|
||||
|
||||
private static void setGloableWorldLeveCache(int gloableWorldLeveCache) {
|
||||
GLOABLE_WORLD_LEVE_CACHE = gloableWorldLeveCache;
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.SERVER_WORLDLEVE_INFO,"",String.valueOf(GameApplication.serverId),gloableWorldLeveCache);
|
||||
if(gloableWorldLeveCache!=GLOABLE_WORLD_LEVE_CACHE){
|
||||
GLOABLE_WORLD_LEVE_CACHE = gloableWorldLeveCache;
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.SERVER_WORLDLEVE_INFO,"",String.valueOf(GameApplication.serverId),gloableWorldLeveCache);
|
||||
InnerMessageUtil.broadcastWithRandom(user->{
|
||||
MessageUtil.sendIndicationMessage(OnlineUserManager.getSessionByUid(user.getId()), 1, MessageTypeProto.MessageType.WorldLevelIndication_VALUE, PlayerInfoProto.WorldLevelIndication.newBuilder().setWorldLeve(GlobleSystemLogic.getGloableWorldLeveCache()).build(), true);
|
||||
}, new LinkedList<>(OnlineUserManager.sessionMap.keySet()),10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getGloableWorldLeveCacheLine() {
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.ljsd.jieling.logic.arenaworld;
|
||||
|
||||
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import config.SGlobalSystemConfig;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Description: des
|
||||
* Author: zsx
|
||||
* CreateDate: 2020/12/14 14:51
|
||||
*/
|
||||
public class ArenaWorldLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArenaWorldLogic.class);
|
||||
private ArenaWorldLogic(){}
|
||||
|
||||
public static class Instance {
|
||||
public final static ArenaWorldLogic instance = new ArenaWorldLogic();
|
||||
}
|
||||
|
||||
public static ArenaWorldLogic getInstance() {
|
||||
return ArenaWorldLogic.Instance.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩法检查
|
||||
*/
|
||||
public static boolean checkJoin(String uid){
|
||||
Map<String, Integer> joinMembers = RedisUtil.getInstence().getMapValues(RedisKey.WORLD_ARE_JOIN, "", String.class, Integer.class);
|
||||
return joinMembers.keySet().contains(uid);
|
||||
}
|
||||
|
||||
|
||||
public static boolean checkOpen(String uid) throws Exception{
|
||||
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(FunctionIdEnum.World_Arena.getFunctionType());
|
||||
return HandlerLogicThread.checkOpen(UserManager.getUser(Integer.valueOf(uid)),sGlobalSystemConfig);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,10 @@ public class ArenaManager extends MongoBase {
|
|||
|
||||
private int topMaxRank=0; // 我的历史最高排名
|
||||
|
||||
public int worldFreeChallengeTime=0;
|
||||
|
||||
public int costDallyTime=0;
|
||||
|
||||
|
||||
private List<ArenaEnemy> arenaEnemies;
|
||||
private List<Integer> hadTakeReward;
|
||||
|
@ -113,4 +117,21 @@ public class ArenaManager extends MongoBase {
|
|||
return hadTakeReward;
|
||||
}
|
||||
|
||||
public int getWorldFreeChallengeTime() {
|
||||
return worldFreeChallengeTime;
|
||||
}
|
||||
|
||||
public void setWorldFreeChallengeTime(int worldFreeChallengeTime) {
|
||||
updateString("worldFreeChallengeTime",worldFreeChallengeTime);
|
||||
this.worldFreeChallengeTime = worldFreeChallengeTime;
|
||||
}
|
||||
|
||||
public int getCostDallyTime() {
|
||||
return costDallyTime;
|
||||
}
|
||||
|
||||
public void setCostDallyTime(int costDallyTime) {
|
||||
updateString("costDallyTime",costDallyTime);
|
||||
this.costDallyTime = costDallyTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,25 @@ public class GetWorldArenaInfoRequestHandler extends gtGBaseHandler<WorldProto.G
|
|||
builder.setStage(1);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
//获取我的排名
|
||||
Map.Entry<Integer, ArenaEnemy> myRank = ArenaLogic.getKey(integerIntegerHashMap, rpcMessage.getUid());
|
||||
//根据我的排名获取
|
||||
int myIndex = 9999;
|
||||
if (myRank != null) {
|
||||
myIndex = myRank.getKey();
|
||||
}
|
||||
List<ArenaEnemy> arenaEnemies = ArenaLogic.randomRank(integerIntegerHashMap, rpcMessage.getUid(), myIndex);
|
||||
List<ArenaEnemy> arenaEnemies;
|
||||
if(proto.getIsPro()){
|
||||
//获取前4名
|
||||
arenaEnemies = new LinkedList<>();
|
||||
for (int i = 1; i <=4 ; i++) {
|
||||
arenaEnemies.add(integerIntegerHashMap.get(i));
|
||||
}
|
||||
}else {
|
||||
arenaEnemies = ArenaLogic.randomRank(integerIntegerHashMap, rpcMessage.getUid(), myIndex);
|
||||
}
|
||||
|
||||
builder.setStage(2);
|
||||
List<String> strings = RedisUtil.getInstence().lGet(RedisKey.WORLD_ARENA_MY_PRON,String.valueOf(rpcMessage.getUid()), 0, -1);
|
||||
List<CommonProto.ArenaEnemy> arenaEnemyList = ArenaLogic.getInstance().getArenaEnemyList(new LinkedList<>(arenaEnemies),strings);
|
||||
|
|
|
@ -29,12 +29,11 @@ public class GetWorldArenaProudRequestHandler extends gtGBaseHandler<WorldProto.
|
|||
//check 膜拜 在逻辑服做
|
||||
Lockeys.getInstance().lock("arena", rpcMessage.getServerId());
|
||||
|
||||
|
||||
|
||||
Integer integer = ArenaLogic.serverSplit.get(String.valueOf(rpcMessage.getServerId()));
|
||||
HashMap<Integer, ArenaEnemy> integerIntegerHashMap = ArenaLogic.ranInfo.get(integer);
|
||||
ArenaEnemy arenaEnemy = integerIntegerHashMap.get(proto.getChallengeRank());
|
||||
if(arenaEnemy==null||arenaEnemy.getEnemyId()!=proto.getChallengeUid()){
|
||||
builder.setErr(-1);
|
||||
return builder.build();
|
||||
}
|
||||
RedisUtil.getInstence().lSet(RedisKey.WORLD_ARENA_MY_PRON+":"+rpcMessage.getUid(),String.valueOf(arenaEnemy.getEnemyId_UUid()));
|
||||
|
|
|
@ -106,9 +106,10 @@ public class ArenaLogic {
|
|||
//为每组生成排行榜
|
||||
ArenaLogic.serverSplit = serverSplit;
|
||||
int[] fightArea = STableManager.getConfig(SMServerArenaSetting.class).get(1).getFightArea();
|
||||
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
int robotNum = setting.getRobotNum();
|
||||
map.forEach((integer, strings) -> {
|
||||
List<Integer> robotIds = randomRobot(fightArea[0], fightArea[1], 1000);
|
||||
List<Integer> robotIds = randomRobot(fightArea[0], fightArea[1], robotNum);
|
||||
HashMap<Integer, ArenaEnemy> orDefault = ranInfo.getOrDefault(integer, new HashMap<>());
|
||||
for (int i = 1; i <= robotIds.size(); i++) {
|
||||
orDefault.put(i, new ArenaEnemy(robotIds.get(i - 1), 0, 0, 0));
|
||||
|
@ -414,4 +415,18 @@ public class ArenaLogic {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 零点重置
|
||||
*/
|
||||
public static void clearReidsInTime() {
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
Cursor<String> cursor = RedisUtil.getInstence().scan("WORLD_ARENA_MY_PRON:*", -1);
|
||||
while (cursor.hasNext()) {
|
||||
delKeys.add(cursor.next());
|
||||
}
|
||||
RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -748,12 +748,17 @@ public class RedisUtil {
|
|||
}
|
||||
|
||||
public Cursor<String> scan(String match, int count){
|
||||
ScanOptions scanOptions = ScanOptions.scanOptions().match(match).count(count).build();
|
||||
ScanOptions.ScanOptionsBuilder scanOptionsBuilder = ScanOptions.scanOptions();
|
||||
scanOptionsBuilder.match(match);
|
||||
if(count!=-1){
|
||||
scanOptionsBuilder.count(count);
|
||||
}
|
||||
RedisSerializer<String> redisSerializer = (RedisSerializer<String>) redisTemplate.getKeySerializer();
|
||||
return (Cursor) redisTemplate.executeWithStickyConnection((RedisCallback) redisConnection ->
|
||||
new ConvertingCursor<>(redisConnection.scan(scanOptions), redisSerializer::deserialize));
|
||||
new ConvertingCursor<>(redisConnection.scan(scanOptionsBuilder.build()), redisSerializer::deserialize));
|
||||
}
|
||||
|
||||
|
||||
private final static String UNLOCK_SCRIPT = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
|
||||
//requestId:加锁者,才能解锁
|
||||
public boolean releaseDistributedLock(String type, String key, String requestId) {
|
||||
|
|
|
@ -25,6 +25,7 @@ public class MinuteTask extends Thread {
|
|||
try {
|
||||
LOGGER.info("MinuteTask start...");
|
||||
ArenaLogic.getInstance().minCheck();
|
||||
everyZeroTask();
|
||||
LOGGER.info("MinuteTask end...");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
|
@ -45,6 +46,12 @@ public class MinuteTask extends Thread {
|
|||
}catch (Exception e){
|
||||
LOGGER.info("MongoUtil err ->{}", e);
|
||||
}
|
||||
try {
|
||||
ArenaLogic.clearReidsInTime();
|
||||
}catch (Exception e){
|
||||
LOGGER.info("clearReidsInTime err ->{}", e);
|
||||
}
|
||||
|
||||
LOGGER.info("DailyOfZeroTask end ...");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue