function control
parent
d9e33c228a
commit
77f1968fba
|
@ -1,16 +1,23 @@
|
||||||
package com.ljsd.jieling.core;
|
package com.ljsd.jieling.core;
|
||||||
|
|
||||||
import com.ljsd.GameApplication;
|
import com.ljsd.GameApplication;
|
||||||
|
import com.ljsd.jieling.config.SGlobalSystemConfig;
|
||||||
|
import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
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.logic.mission.event.MissionEventDistributor;
|
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +52,11 @@ public class HandlerLogicThread extends Thread{
|
||||||
LOGGER.info("request uid=>{} , msgId=>{}, not find the baseHandler",userId,msgId);
|
LOGGER.info("request uid=>{} , msgId=>{}, not find the baseHandler",userId,msgId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
boolean b = checkFunctionIsOpen(msgId, session);
|
||||||
|
if(!b){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,msgId+1,"funciton not");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.info("doWork->uid={},mType={};start", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
LOGGER.info("doWork->uid={},mType={};start", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
||||||
MissionEventDistributor.requestStart();
|
MissionEventDistributor.requestStart();
|
||||||
|
@ -57,6 +69,84 @@ public class HandlerLogicThread extends Thread{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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_INFO_REQUEST_VALUE: //冒险
|
||||||
|
case MessageTypeProto.MessageType.ADVENTURE_CHALLENGE_REQUEST_VALUE:
|
||||||
|
case MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_REQUEST_VALUE:
|
||||||
|
case MessageTypeProto.MessageType.ADVENTURE_REWARD_REQUEST_VALUE:
|
||||||
|
case MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_REQEUST_VALUE:
|
||||||
|
case MessageTypeProto.MessageType.ADVENTURE_BOSS_CHALLENGE_REQEUST_VALUE:
|
||||||
|
case MessageTypeProto.MessageType.ADVENTURE_BOSS_RANK_REQUEST_VALUE:
|
||||||
|
case MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addEntry(PacketNetData packetNetData){
|
public void addEntry(PacketNetData packetNetData){
|
||||||
handlerLinkedQueue.offer(packetNetData);
|
handlerLinkedQueue.offer(packetNetData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,81 +198,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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_INFO_REQUEST_VALUE: //冒险
|
|
||||||
case MessageTypeProto.MessageType.ADVENTURE_CHALLENGE_REQUEST_VALUE:
|
|
||||||
case MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_REQUEST_VALUE:
|
|
||||||
case MessageTypeProto.MessageType.ADVENTURE_REWARD_REQUEST_VALUE:
|
|
||||||
case MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_REQEUST_VALUE:
|
|
||||||
case MessageTypeProto.MessageType.ADVENTURE_BOSS_CHALLENGE_REQEUST_VALUE:
|
|
||||||
case MessageTypeProto.MessageType.ADVENTURE_BOSS_RANK_REQUEST_VALUE:
|
|
||||||
case MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_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) {
|
private void refreshToken(ISession session) {
|
||||||
int token = Math.abs(MathUtils.randomInt());
|
int token = Math.abs(MathUtils.randomInt());
|
||||||
|
|
Loading…
Reference in New Issue