功能开关
parent
fbc7c719e2
commit
891d6c0ece
|
@ -11,7 +11,7 @@ public class SGlobalSystemConfig implements BaseConfig {
|
|||
|
||||
private int id;
|
||||
|
||||
private int[] openRules;
|
||||
private int[] openRules; // 1:关卡 2: 等级
|
||||
|
||||
private static Map<Integer,SGlobalSystemConfig> sGlobalSystemConfigMap;
|
||||
|
||||
|
|
|
@ -4,12 +4,16 @@ import com.google.protobuf.GeneratedMessage;
|
|||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||
import com.ljsd.jieling.config.SGlobalSystemConfig;
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.LevelDifficulty;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
|
@ -131,7 +135,10 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
if (checkIndex(session,packetNetData) != 0){
|
||||
return;
|
||||
}
|
||||
|
||||
// boolean isOpen = checkFunctionIsOpen(packetNetData.getMsgId(), session);
|
||||
// if (!isOpen){
|
||||
// return;
|
||||
// }
|
||||
BaseHandler baseHandler = handlers.get(packetNetData.getMsgId());
|
||||
if (baseHandler == null) {
|
||||
LOGGER.info("request unknow commond : " + packetNetData.getMsgId());
|
||||
|
@ -147,6 +154,76 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean checkFunctionIsOpen(int msgId,ISession session ) {
|
||||
int uid = session.getUid();
|
||||
try {
|
||||
User user = UserManager.getUser(uid);
|
||||
switch (msgId){
|
||||
case MessageTypeProto.MessageType.HERO_RAND_REQQUEST_VALUE: // 招募
|
||||
SGlobalSystemConfig sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.Lottery);
|
||||
if (checkOpen(user,sGlobalSystemConfig)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MessageTypeProto.MessageType.TEAM_POS_SAVE_REQUEST_VALUE: //编队
|
||||
sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.Team);
|
||||
if (checkOpen(user,sGlobalSystemConfig)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MessageTypeProto.MessageType.GET_ALL_POKEMON_REQUEST_VALUE: //异妖
|
||||
case MessageTypeProto.MessageType.POKEMON_COMONPENT_LEVELUP_REQUEST_VALUE:
|
||||
case MessageTypeProto.MessageType.POKEMON_ADVANCED_REQUEST_VALUE:
|
||||
sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.DifferDemons);
|
||||
if (checkOpen(user, sGlobalSystemConfig)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MessageTypeProto.MessageType.WORKSHOP_FOUNDATION_REQUEST_VALUE: // 锻造
|
||||
case MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_REQUEST_VALUE:
|
||||
case MessageTypeProto.MessageType.WORKSHOP_EQUIP_CREATE_RESPONSE_VALUE:
|
||||
sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.WorkShop);
|
||||
if (checkOpen(user,sGlobalSystemConfig)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MessageTypeProto.MessageType.COOK_FOOD_REQUEST_VALUE:
|
||||
sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.Foods);
|
||||
if (checkOpen(user,sGlobalSystemConfig)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MessageTypeProto.MessageType.ADVENTURE_STATION_REQUEST_VALUE: //冒险
|
||||
case MessageTypeProto.MessageType.GET_ADVENTURE_INFO_REQUEST_VALUE:
|
||||
sGlobalSystemConfig = SGlobalSystemConfig.getsGlobalSystemConfigByFunctionId(FunctionIdEnum.Adventure);
|
||||
if (checkOpen(user,sGlobalSystemConfig)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkOpen(User user, SGlobalSystemConfig sGlobalSystemConfig) {
|
||||
int level = user.getPlayerInfoManager().getLevel();
|
||||
Map<Integer, LevelDifficulty> levelDifficultyInfosMap = user.getLevelDifficultyManager().getLevelDifficultyInfosMap();
|
||||
int type = sGlobalSystemConfig.getOpenRules()[0];
|
||||
int condition = sGlobalSystemConfig.getOpenRules()[1];
|
||||
if (type ==1){
|
||||
if (!levelDifficultyInfosMap.containsKey(condition) || levelDifficultyInfosMap.containsKey(condition) && levelDifficultyInfosMap.get(condition).getState() != Global.FIGHT_CLEARANCE) {
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
if (level < condition){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void refreshToken(ISession session) {
|
||||
int token = Math.abs(MathUtils.randomInt());
|
||||
session.setToken(token);
|
||||
|
|
Loading…
Reference in New Issue