跨服第一版
parent
af83955bd5
commit
040a412069
|
@ -320,6 +320,9 @@ public class RedisKey {
|
||||||
|
|
||||||
// 跨服 排行
|
// 跨服 排行
|
||||||
public static final String CROSS_SERVICE_ARENA = "CROSS_SERVICE_ARENA";
|
public static final String CROSS_SERVICE_ARENA = "CROSS_SERVICE_ARENA";
|
||||||
|
//跨服机器人信息
|
||||||
|
public static final String CROSS_ARENA_ROBOT_INFO = "CROSS_ARENA_ROBOT_INFO";
|
||||||
|
|
||||||
|
|
||||||
public static Set<String> familyKey = new HashSet<>();
|
public static Set<String> familyKey = new HashSet<>();
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,7 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
|
||||||
TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.World_Arena);
|
TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.World_Arena);
|
||||||
long diff = (System.currentTimeMillis() - timeControllerOfFunction.getStartTime())/1000;
|
long diff = (System.currentTimeMillis() - timeControllerOfFunction.getStartTime())/1000;
|
||||||
|
|
||||||
if (diff > setting.getBattleTime()[0] && diff < setting.getBattleTime()[1]) {
|
if (diff < setting.getBattleTime()[0] || diff > setting.getBattleTime()[1]) {
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
|
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF);
|
||||||
}
|
}
|
||||||
User user = UserManager.getUser(iSession.getUid());
|
User user = UserManager.getUser(iSession.getUid());
|
||||||
|
|
|
@ -2,22 +2,35 @@ package com.ljsd.jieling.handler.gtw;
|
||||||
|
|
||||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||||
import com.ljsd.jieling.core.HandlerLogicThread;
|
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||||
|
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.ErrorCode;
|
||||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||||
|
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||||
|
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||||
|
import com.ljsd.jieling.logic.arenaworld.ArenaWorldLogic;
|
||||||
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.network.server.GlobalidHelper;
|
import com.ljsd.jieling.logic.rank.RankContext;
|
||||||
import com.ljsd.jieling.network.server.WorldHelper;
|
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||||
|
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
import config.SGlobalSystemConfig;
|
import config.SGlobalSystemConfig;
|
||||||
import config.SMServerArenaSetting;
|
import config.SMServerArenaSetting;
|
||||||
import manager.STableManager;
|
import manager.STableManager;
|
||||||
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
|
import rpc.protocols.CommonProto;
|
||||||
import rpc.protocols.MessageTypeProto;
|
import rpc.protocols.MessageTypeProto;
|
||||||
import rpc.world.WorldProto;
|
import rpc.world.WorldProto;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description: gs 继承basehandler 做消息拦截 然后再转发到w
|
* Description: gs 继承basehandler 做消息拦截 然后再转发到w
|
||||||
|
@ -28,7 +41,7 @@ public class GetWorldArenaInfoRequestHandler extends BaseHandler<WorldProto.GetW
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MessageTypeProto.MessageType getMessageCode() {
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
return null;
|
return MessageTypeProto.MessageType.GetWorldArenaInfoRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,16 +67,108 @@ public class GetWorldArenaInfoRequestHandler extends BaseHandler<WorldProto.GetW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WorldProto.GetWorldArenaInfoResponse.Builder builder = WorldProto.GetWorldArenaInfoResponse.newBuilder();
|
||||||
GlobalidHelper.WorldInfo worldInfo = GlobalidHelper.getWorldInfo();
|
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
if (null == worldInfo){
|
builder.setIsGroup(crossGroup==-1?0:1);
|
||||||
throw new ErrorCodeException("world unavailable or play not open");
|
builder.setStage(ArenaLogic.getState());
|
||||||
|
if (diff > setting.getRestTime()[0] && diff < setting.getRestTime()[1]) {
|
||||||
|
//多加1分钟 周期间隔后 client再发起请求
|
||||||
|
builder.setEndTime((int)(timeControllerOfFunction.getStartTime()/1000+setting.getRestTime()[1])+61);
|
||||||
|
} else if (diff > setting.getBattleTime()[0] && diff < setting.getBattleTime()[1]) {
|
||||||
|
builder.setEndTime((int)(timeControllerOfFunction.getStartTime()/1000+setting.getBattleTime()[1])+10);
|
||||||
|
} else {
|
||||||
|
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
|
||||||
}
|
}
|
||||||
//转发到world服
|
if (!ArenaWorldLogic.checkJoin(String.valueOf(iSession.getUid()))) {
|
||||||
boolean b = WorldHelper.sendMessageToWord(iSession.getUid(),proto);
|
builder.setEnterable(-1);
|
||||||
if(!b){
|
|
||||||
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
|
||||||
}
|
}
|
||||||
|
CommonProto.ArenaInfo.Builder builder1 = CommonProto.ArenaInfo.newBuilder();
|
||||||
|
// try {
|
||||||
|
//// Lockeys.getInstance().lock("arena", rpcMessage.getServerId());
|
||||||
|
// int serverId = rpcMessage.getServerId();
|
||||||
|
// Integer integer = ArenaLogic.serverSplit.get(String.valueOf(serverId));
|
||||||
|
// HashMap<Integer, ArenaEnemy> integerIntegerHashMap = ArenaLogic.ranInfo.get(integer);
|
||||||
|
// if (integerIntegerHashMap == null) {
|
||||||
|
// builder.setStage(1);
|
||||||
|
// return builder.build();
|
||||||
|
// }
|
||||||
|
//获取我的排名
|
||||||
|
// Map.Entry<Integer, ArenaEnemy> myRank = ArenaLogic.getKey(integerIntegerHashMap, rpcMessage.getUid());
|
||||||
|
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_SERVICE_ARENA.getType());
|
||||||
|
double score = rank.getRankIndexByKey(String.valueOf(crossGroup),iSession.getUid());
|
||||||
|
builder1.setScore(score==-1?9999:(int)score);
|
||||||
|
|
||||||
|
//如果是攻击阶段
|
||||||
|
if(ArenaLogic.getState()==ArenaLogic.BATTLE_STATE){
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//拿前4个
|
||||||
|
Set<ZSetOperations.TypedTuple<String>> rankByKey = rank.getRankByKey(String.valueOf(crossGroup), 0, 4);
|
||||||
|
Set<Integer> keys = new HashSet<>(4);
|
||||||
|
rankByKey.forEach(n->keys.add(Integer.parseInt(n.getValue())));
|
||||||
|
List<CommonProto.ArenaEnemy> arenaEnemyList = ArenaLogic.getInstance().getCrossArenaEnemyList(keys);
|
||||||
|
builder1.addAllArenaEnemys(arenaEnemyList);
|
||||||
|
|
||||||
|
}
|
||||||
|
// List<String> strings = RedisUtil.getInstence().lGet(RedisKey.WORLD_ARENA_MY_PRON,String.valueOf(iSession.getUid()), 0, -1);
|
||||||
|
builder.setArenaInfo(builder1.build());
|
||||||
|
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.GetWorldArenaInfoResponse.getNumber(),builder.build(),true);
|
||||||
|
// List<CommonProto.ArenaEnemy> arenaEnemyList = ArenaLogic.getInstance().getArenaEnemyList(new LinkedList<>(arenaEnemies),strings);
|
||||||
|
// builder1.setScore(myIndex)
|
||||||
|
// .addAllArenaEnemys(arenaEnemyList)
|
||||||
|
// .build();
|
||||||
|
|
||||||
|
// //根据我的排名获取
|
||||||
|
// int myIndex = 9999;
|
||||||
|
// if (myRank != null) {
|
||||||
|
// myIndex = myRank.getKey();
|
||||||
|
// }
|
||||||
|
// List<ArenaEnemy> arenaEnemies;
|
||||||
|
// if(proto.getIsPro()){
|
||||||
|
// //获取前4名
|
||||||
|
// arenaEnemies = new LinkedList<>();
|
||||||
|
// for (int i = 1; i <=4 ; i++) {
|
||||||
|
// ArenaEnemy arenaEnemy = integerIntegerHashMap.get(i);
|
||||||
|
// if(arenaEnemy.getRank()==0){
|
||||||
|
// arenaEnemy.setRank(i);
|
||||||
|
// }
|
||||||
|
// arenaEnemies.add(arenaEnemy);
|
||||||
|
// }
|
||||||
|
// }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);
|
||||||
|
// builder1.setScore(myIndex)
|
||||||
|
// .addAllArenaEnemys(arenaEnemyList)
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// LOGGER.error(e.toString());
|
||||||
|
// } finally {
|
||||||
|
// // Lockeys.getInstance().reset();
|
||||||
|
// }
|
||||||
|
// builder.setArenaInfo(builder1)
|
||||||
|
// return builder.build();
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
// TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.World_Arena);
|
||||||
|
// long diff = (System.currentTimeMillis() - timeControllerOfFunction.getStartTime())/1000;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (!ArenaWorldLogic.checkJoin(String.valueOf(rpcMessage.getUid()))) {
|
||||||
|
// builder.setEnterable(-1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// proto = builder.build();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ 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.activity.IEventHandler;
|
import com.ljsd.jieling.logic.activity.IEventHandler;
|
||||||
import com.ljsd.jieling.logic.activity.event.*;
|
import com.ljsd.jieling.logic.activity.event.*;
|
||||||
import com.ljsd.jieling.logic.dao.ServerConfig;
|
|
||||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.util.InnerMessageUtil;
|
import com.ljsd.jieling.util.InnerMessageUtil;
|
||||||
|
@ -189,6 +188,7 @@ public class GlobleSystemLogic implements IEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getGlobalWorldLevelCache() {
|
public static int getGlobalWorldLevelCache() {
|
||||||
|
GLOABLE_WORLD_LEVE_CACHE = 120;
|
||||||
if (GLOABLE_WORLD_LEVE_CACHE!=0)
|
if (GLOABLE_WORLD_LEVE_CACHE!=0)
|
||||||
return GLOABLE_WORLD_LEVE_CACHE;
|
return GLOABLE_WORLD_LEVE_CACHE;
|
||||||
Integer level = RedisUtil.getInstence().getMapValue(RedisKey.SERVER_WORLDLEVE_INFO, "",String.valueOf(GameApplication.serverId),Integer.class);
|
Integer level = RedisUtil.getInstence().getMapValue(RedisKey.SERVER_WORLDLEVE_INFO, "",String.valueOf(GameApplication.serverId),Integer.class);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.ljsd.jieling.globals.BIReason;
|
||||||
import com.ljsd.jieling.globals.Global;
|
import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||||
|
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||||
import com.ljsd.jieling.logic.dao.*;
|
import com.ljsd.jieling.logic.dao.*;
|
||||||
|
@ -25,6 +26,9 @@ import com.ljsd.jieling.logic.mail.MailLogic;
|
||||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||||
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||||
|
import com.ljsd.jieling.logic.rank.RankContext;
|
||||||
|
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||||
|
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
|
||||||
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
|
import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent;
|
||||||
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
|
import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
|
||||||
import com.ljsd.jieling.network.server.GlobalidHelper;
|
import com.ljsd.jieling.network.server.GlobalidHelper;
|
||||||
|
@ -66,9 +70,9 @@ public class ArenaLogic {
|
||||||
private int curSeason;
|
private int curSeason;
|
||||||
private int viewSeason;
|
private int viewSeason;
|
||||||
|
|
||||||
private static int state = 0;
|
private static int state = 1;
|
||||||
private final static int BATTLE_STATE = 1;
|
public final static int BATTLE_STATE = 2;
|
||||||
private final static int RELAX_STATE = 2;
|
public final static int RELAX_STATE = 3;
|
||||||
|
|
||||||
public int getCurSeason() {
|
public int getCurSeason() {
|
||||||
return curSeason;
|
return curSeason;
|
||||||
|
@ -727,11 +731,13 @@ public class ArenaLogic {
|
||||||
|
|
||||||
public void r2e(){
|
public void r2e(){
|
||||||
LOGGER.info("罗浮争霸:休息状态转到未开始状态");
|
LOGGER.info("罗浮争霸:休息状态转到未开始状态");
|
||||||
setState(0);
|
setState(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void e2b(){
|
public void e2b(){
|
||||||
|
if(state==BATTLE_STATE)return;
|
||||||
LOGGER.info("罗浮争霸:未开始状态转到战斗状态");
|
LOGGER.info("罗浮争霸:未开始状态转到战斗状态");
|
||||||
|
initRank();
|
||||||
setState(BATTLE_STATE);
|
setState(BATTLE_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,23 +749,43 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
long diff = (System.currentTimeMillis() - timeControllerOfFunction.getStartTime())/1000;
|
long diff = (System.currentTimeMillis() - timeControllerOfFunction.getStartTime())/1000;
|
||||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||||
switch(state){
|
if (diff > setting.getBattleTime()[0] && diff <= setting.getBattleTime()[1]) {
|
||||||
case 0:
|
e2b();
|
||||||
if (diff > setting.getBattleTime()[0] && diff <= setting.getBattleTime()[1]) {
|
}else if (diff > setting.getBattleTime()[1] && diff <= setting.getRestTime()[0]) {
|
||||||
e2b();
|
b2r();
|
||||||
}
|
} else if (diff > setting.getRestTime()[1]) {
|
||||||
break;
|
r2e();
|
||||||
case 1:
|
|
||||||
if (diff > setting.getBattleTime()[1] && diff <= setting.getRestTime()[0]) {
|
|
||||||
b2r();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (diff > setting.getRestTime()[1]) {
|
|
||||||
r2e();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//初始化机器人信息
|
||||||
|
private void initRank(){
|
||||||
|
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_SERVICE_ARENA.getType());
|
||||||
|
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
|
int robotIndex = 1000;
|
||||||
|
Random random = new Random();
|
||||||
|
Map<String,CrossArenaEnemy> robotInfo = new HashMap<>(1000);
|
||||||
|
Map<Integer, Integer> groupValues = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, "", Integer.class, Integer.class);
|
||||||
|
|
||||||
|
List<Integer> groupList = new ArrayList<>(8);
|
||||||
|
|
||||||
|
groupValues.forEach((k,v)->{
|
||||||
|
if(v==crossGroup) groupList.add(k);
|
||||||
|
});
|
||||||
|
|
||||||
|
while(--robotIndex>0){
|
||||||
|
int server = random.nextInt(groupList.size());
|
||||||
|
rank.addRank(robotIndex,String.valueOf(crossGroup),robotIndex);
|
||||||
|
robotInfo.put(String.valueOf(robotIndex),new CrossArenaEnemy(robotIndex,groupList.get(server),0,0,random.nextBoolean(),PlayerLogic.getInstance().getRandomName2()));
|
||||||
|
}
|
||||||
|
RedisUtil.getInstence().putMapEntrys(RedisKey.CROSS_ARENA_ROBOT_INFO,String.valueOf(crossGroup),robotInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取跨服信息
|
||||||
|
public List<CommonProto.ArenaEnemy> getCrossArenaEnemyList(Set<Integer> ids){
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lvxinran
|
||||||
|
* @date 2021/6/26
|
||||||
|
* @discribe
|
||||||
|
*/
|
||||||
|
public class CrossArenaEnemy {
|
||||||
|
private int enemyId;
|
||||||
|
private int enemyId_UUid;//机器人唯一ID
|
||||||
|
private int serverID;
|
||||||
|
// 0:机器人
|
||||||
|
private int enemyType;
|
||||||
|
// 0:未挑战,1:挑战成功,2:挑战失败
|
||||||
|
private int enemyStatus;
|
||||||
|
private int rank;//排名
|
||||||
|
private boolean gender;
|
||||||
|
private String randomName;
|
||||||
|
|
||||||
|
public CrossArenaEnemy(int enemyId, int enemyId_UUid, int serverID, int enemyType, int enemyStatus, int rank) {
|
||||||
|
this.enemyId = enemyId;
|
||||||
|
this.enemyId_UUid = enemyId_UUid;
|
||||||
|
this.serverID = serverID;
|
||||||
|
this.enemyType = enemyType;
|
||||||
|
this.enemyStatus = enemyStatus;
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CrossArenaEnemy(int enemyId, int serverID, int enemyType, int enemyStatus,boolean gender,String randomName) {
|
||||||
|
|
||||||
|
this(enemyId,serverID,enemyType,enemyStatus);
|
||||||
|
this.gender=gender;
|
||||||
|
this.randomName = randomName;
|
||||||
|
}
|
||||||
|
public CrossArenaEnemy(int enemyId, int serverID, int enemyType, int enemyStatus) {
|
||||||
|
this.enemyId = enemyId;
|
||||||
|
this.enemyId_UUid=enemyId;
|
||||||
|
this.serverID = serverID;
|
||||||
|
this.enemyType = enemyType;
|
||||||
|
this.enemyStatus = enemyStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CrossArenaEnemy(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnemyId_UUid() {
|
||||||
|
return enemyId_UUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnemyId_UUid(int enemyId_UUid) {
|
||||||
|
this.enemyId_UUid = enemyId_UUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRank() {
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRank(int rank) {
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getServerID() {
|
||||||
|
return serverID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnemyId() {
|
||||||
|
return enemyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnemyType() {
|
||||||
|
return enemyType>0?1:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public int getEnemyStatus() {
|
||||||
|
return enemyStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGender() {
|
||||||
|
return gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRandomName() {
|
||||||
|
return randomName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ public enum RankEnum {
|
||||||
SHAN_HE_SHE_JI_STAR_RANK(30,RedisKey.SHAN_HE_SHE_JI_STAR_RANK,ShanHeSheJiTuStarRank::new,false),//山河社稷星星排行榜
|
SHAN_HE_SHE_JI_STAR_RANK(30,RedisKey.SHAN_HE_SHE_JI_STAR_RANK,ShanHeSheJiTuStarRank::new,false),//山河社稷星星排行榜
|
||||||
TA_SUI_LING_XIAO_RANK(31,RedisKey.TA_SUI_LING_XIAO_RANK,TaSuiLingXiaoRank::new,false),
|
TA_SUI_LING_XIAO_RANK(31,RedisKey.TA_SUI_LING_XIAO_RANK,TaSuiLingXiaoRank::new,false),
|
||||||
|
|
||||||
CROSS_SERVICE_ARENA(32,RedisKey.CROSS_SERVICE_ARENA,ArenaRank::new,false)
|
CROSS_SERVICE_ARENA(32,RedisKey.CROSS_SERVICE_ARENA,ArenaRank::new,true)
|
||||||
;
|
;
|
||||||
|
|
||||||
private int type;
|
private int type;
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
package com.world.handler;
|
|
||||||
|
|
||||||
import com.google.protobuf.GeneratedMessage;
|
|
||||||
import com.world.logic.arean.ArenaEnemy;
|
|
||||||
import com.world.logic.arean.ArenaLogic;
|
|
||||||
import com.world.redis.RedisKey;
|
|
||||||
import com.world.redis.RedisUtil;
|
|
||||||
import rpc.net.RpcMessage;
|
|
||||||
import rpc.net.gtGBaseHandler;
|
|
||||||
import rpc.protocols.CommonProto;
|
|
||||||
import rpc.world.WorldProto;
|
|
||||||
import util.Lockeys;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description: 获取跨服竞技场信息
|
|
||||||
* Author: zsx
|
|
||||||
* CreateDate: 2020/11/19 10:51
|
|
||||||
*/
|
|
||||||
public class GetWorldArenaInfoRequestHandler extends gtGBaseHandler<WorldProto.GetWorldArenaInfoRequest> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GeneratedMessage processWithProto(RpcMessage rpcMessage, WorldProto.GetWorldArenaInfoRequest proto) throws Exception {
|
|
||||||
WorldProto.GetWorldArenaInfoResponse.Builder builder = WorldProto.GetWorldArenaInfoResponse.newBuilder();
|
|
||||||
CommonProto.ArenaInfo.Builder builder1 = CommonProto.ArenaInfo.newBuilder();
|
|
||||||
try {
|
|
||||||
// Lockeys.getInstance().lock("arena", rpcMessage.getServerId());
|
|
||||||
int serverId = rpcMessage.getServerId();
|
|
||||||
Integer integer = ArenaLogic.serverSplit.get(String.valueOf(serverId));
|
|
||||||
HashMap<Integer, ArenaEnemy> integerIntegerHashMap = ArenaLogic.ranInfo.get(integer);
|
|
||||||
if (integerIntegerHashMap == null) {
|
|
||||||
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;
|
|
||||||
if(proto.getIsPro()){
|
|
||||||
//获取前4名
|
|
||||||
arenaEnemies = new LinkedList<>();
|
|
||||||
for (int i = 1; i <=4 ; i++) {
|
|
||||||
ArenaEnemy arenaEnemy = integerIntegerHashMap.get(i);
|
|
||||||
if(arenaEnemy.getRank()==0){
|
|
||||||
arenaEnemy.setRank(i);
|
|
||||||
}
|
|
||||||
arenaEnemies.add(arenaEnemy);
|
|
||||||
}
|
|
||||||
}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);
|
|
||||||
builder1.setScore(myIndex)
|
|
||||||
.addAllArenaEnemys(arenaEnemyList)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOGGER.error(e.toString());
|
|
||||||
} finally {
|
|
||||||
// Lockeys.getInstance().reset();
|
|
||||||
}
|
|
||||||
return builder.setArenaInfo(builder1).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue