跨服修改

lvxinran 2021-07-05 01:27:01 +08:00
parent bbaf6a1556
commit 24cc1fbbf1
6 changed files with 132 additions and 67 deletions

View File

@ -111,17 +111,34 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
//战斗
CommonProto.FightTeamInfo teamInfo = null;
CommonProto.ArenaEnemy arenaEnemys = null;
CommonProto.ArenaEnemy arenaAttack = null;
CommonProto.FightTeamInfo teamInfo ;
CommonProto.ArenaEnemy arenaEnemys ;
CommonProto.ArenaEnemy arenaAttack ;
int force;
//当前分组
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_SERVICE_ARENA.getType());
int challengeRank = proto.getChallengeRank();
Set<ZSetOperations.TypedTuple<String>> rankByKey = rank.getRankByKey(String.valueOf(crossGroup), challengeRank-1, challengeRank-1);
int myRank = rank.getRankIndexByKey(String.valueOf(crossGroup),iSession.getUid());
int challengeCurRank = rank.getRankIndexByKey(String.valueOf(crossGroup),proto.getChallengeUid());
int myCurrentRank = proto.getMyCurrentRank();
//自己的排名发生了变化
if(myCurrentRank!=9999&&myCurrentRank!=myRank){
builder1.setErr(-3);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GetWorldArenaChallengeResponse.getNumber(), builder1.build(), true);
return;
}
//对手的排名发生了变化
if(challengeRank!=challengeCurRank){
builder1.setErr(-2);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GetWorldArenaChallengeResponse.getNumber(), builder1.build(), true);
return;
}
int newRank = 0;
if(rankByKey==null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
@ -137,7 +154,7 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
if (proto.getChallengeUid()>1000) {
ArenaOfUser arenaOfUser = CrossServiceLogic.getInstance().query(proto.getChallengeUid());
teamInfo = FightUtil.makeCrossPersonData(arenaOfUser);
arenaEnemys =ArenaLogic.getInstance().getUserCrossArenaEnemy(crossGroup,arenaOfUser,proto.getChallengeRank()).build();
arenaEnemys =ArenaLogic.getInstance().getUserCrossArenaEnemy(crossGroup,arenaOfUser,proto.getChallengeRank(),false).build();
} else {
//机器人
@ -181,48 +198,41 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
if (fightResult.getCheckResult()[0] > 0) {
// if (proto.getChallengeUid() < 1000) {
RedisUtil.getInstence().set(RedisKey.WORLD_ARENA_RANK_MY_MATH, String.valueOf(iSession.getUid()), new HashSet<>());
List<CommonProto.ArenaEnemy> arenaEnemyList = ArenaLogic.randomRank(iSession.getUid(), proto.getChallengeRank(), crossGroup);
if(myRank==-1){
//第一次 没有上榜的时候
rank.removeOneRankByPiece(String.valueOf(crossGroup),String.valueOf(proto.getChallengeRank()));
rank.addRank(iSession.getUid(), String.valueOf(crossGroup), score);
newRank = rank.getRankIndexByKey(String.valueOf(crossGroup),iSession.getUid());
}else if(rank.getScoreById(iSession.getUid(),String.valueOf(crossGroup))<rank.getScoreById(proto.getChallengeUid(),String.valueOf(crossGroup))){
//在榜上 且排名要升高
rank.addRank(proto.getChallengeUid(),String.valueOf(crossGroup),rank.getScoreById(iSession.getUid(),String.valueOf(crossGroup)));
rank.addRank(iSession.getUid(), String.valueOf(crossGroup), score);
newRank = rank.getRankIndexByKey(String.valueOf(crossGroup),iSession.getUid());
if(proto.getChallengeUid()>1000){
RedisUtil.getInstence().set(RedisKey.WORLD_ARENA_RANK_MY_MATH, String.valueOf(proto.getChallengeUid()), new HashSet<>());
ArenaLogic.randomRank(proto.getChallengeUid(),myRank, crossGroup);
}
}else{
//排名不需升高,拿自己的排名重新匹配
newRank = myRank;
}
// }else{
// RedisUtil.getInstence().set(RedisKey.WORLD_ARENA_RANK_MY_MATH, String.valueOf(iSession.getUid()), new HashSet<>());
//
// if(myRank==-1){
// rank.removeOneRankByPiece(String.valueOf(crossGroup),String.valueOf(proto.getChallengeRank()));
// rank.addRank(iSession.getUid(), String.valueOf(crossGroup), score);
// newRank = rank.getRankIndexByKey(String.valueOf(crossGroup),iSession.getUid());
// }else if(rank.getScoreById(iSession.getUid(),String.valueOf(crossGroup))<rank.getScoreById(proto.getChallengeUid(),String.valueOf(crossGroup))){
// rank.addRank(proto.getChallengeUid(),String.valueOf(crossGroup),rank.getScoreById(iSession.getUid(),String.valueOf(crossGroup)));
// rank.addRank(iSession.getUid(), String.valueOf(crossGroup), score);
// newRank = rank.getRankIndexByKey(String.valueOf(crossGroup),iSession.getUid());
// }else{
// newRank = myRank;
// }
//
// }
List<CommonProto.ArenaEnemy> arenaEnemyList = ArenaLogic.randomRank(iSession.getUid(),newRank, crossGroup);
//新的匹配信息给前端
CommonProto.ArenaInfo.Builder newArenaBuilder = CommonProto.ArenaInfo.newBuilder();
newArenaBuilder.addAllArenaEnemys(arenaEnemyList);
newArenaBuilder.setScore(newRank);
builder1.setArenaInfo(newArenaBuilder.build());
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GetWorldArenaChallengeResponse.getNumber(), builder1.build(), true);
}else{
newRank = myRank;
}
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GetWorldArenaChallengeResponse.getNumber(), builder1.build(), true);
builder.setRank(newRank);
builder.setOldrank(myRank==-1?9999:myRank);
RedisUtil.getInstence().putMapEntry(RedisKey.WORLD_ARENA_RRECORD,Integer.toString(iSession.getUid()), s, builder.build().toByteArray());
builder.setRank(myRank==-1?9999:myRank);
builder.setOldrank(newRank);
RedisUtil.getInstence().putMapEntry(RedisKey.WORLD_ARENA_RRECORD, Integer.toString(proto.getChallengeUid()), s, builder.build().toByteArray());
}

View File

@ -35,6 +35,7 @@ public class GetPlayerOneTeamInfo extends BaseHandler<PlayerInfoProto.GetPlayerO
//本服其他功能
oneTeamInfo = PlayerLogic.getInstance().getOneTeamInfo( proto.getPlayerId(), proto.getTeamId());
}else{
//跨服
if(proto.getPlayerId()<1000){
//机器人
@ -46,9 +47,9 @@ public class GetPlayerOneTeamInfo extends BaseHandler<PlayerInfoProto.GetPlayerO
oneTeamInfo = PlayerLogic.getInstance().getOneTeamInfo(info.getEnemyId(),proto.getTeamId());
}else{
//真人
oneTeamInfo = PlayerLogic.getInstance().getCrossOneTeamInfo(proto.getPlayerId(),proto.getTeamId());
}
//跨服天梯
}
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.GET_PLAYER_ONE_TEAM_INFO_RESPONSE.getNumber(),oneTeamInfo,true);

View File

@ -687,39 +687,8 @@ public class ArenaLogic {
}
public void worldSendReward(){
TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.World_Arena);
if(null ==timeControllerOfFunction){
return;
}
checkState();
long diff = (System.currentTimeMillis() - timeControllerOfFunction.getStartTime())/1000;
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
TreeMap<Integer, SMServerArenaReward> rewardMapByRank = SMServerArenaReward.rewardMapByRank;
if(setting==null){
return;
}
if (diff >= setting.getBattleTime()[1] && diff < setting.getBattleTime()[1]+50) {
int myGroup = GlobalidHelper.getWorldInfo().getMyGroup();
if(myGroup==0){
return;
}
try {
WorldProto.GetArenaRankRewardResponse response = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.GetArenaRankRewardRequest.newBuilder().setGroupId(myGroup).build(), WorldProto.GetArenaRankRewardResponse.class);
if(response==null||response.getRankInfoList().size()==0){
return;
}
for(WorldProto.ArenaRank rank:response.getRankInfoList()){
int myRank = rank.getRank();
Map.Entry<Integer, SMServerArenaReward> entry = rewardMapByRank.floorEntry(myRank);
MailLogic.getInstance().sendMail(rank.getUid(),"","",StringUtil.parseArrayToString(entry.getValue().getSeasonReward()),TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ -733,6 +702,42 @@ public class ArenaLogic {
private void b2r(){
if(state != RELAX_STATE){
if(state==BATTLE_STATE){
LOGGER.info("罗浮争锋,发奖");
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
if(crossGroup==-1){
return;
}
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_SERVICE_ARENA.getType());
String title = SErrorCodeEerverConfig.getI18NMessage("mserverarena_reward_title");
TreeMap<Integer, SMServerArenaReward> rewardMapByRank = SMServerArenaReward.rewardMapByRank;
Set<ZSetOperations.TypedTuple<String>> rankInfo= rank.getRankByKey(String.valueOf(crossGroup), 0, -1);
int index = 0;
Iterator<ZSetOperations.TypedTuple<String>> iterator = rankInfo.iterator();
while (iterator.hasNext()){
index++;
ZSetOperations.TypedTuple<String> next = iterator.next();
int uid = Integer.valueOf(next.getValue());
if (uid<1000) {
continue;
}
try {
User user = UserManager.getUser(uid, true);
if(user==null){
continue;
}
Map.Entry<Integer, SMServerArenaReward> entry = rewardMapByRank.floorEntry(index);
String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("mserverarena_reward_content",new Object[]{index},new int[]{0});
MailLogic.getInstance().sendMail(uid,title,content,StringUtil.parseArrayToString(entry.getValue().getSeasonReward()),TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME);
} catch (Exception e) {
e.printStackTrace();
}
}
}
LOGGER.info("罗浮争霸:转到休息状态,nowstate:{} to RELAX_STATE",state);
setState(RELAX_STATE);
}
@ -748,9 +753,12 @@ public class ArenaLogic {
public void e2b(){
if(state != BATTLE_STATE){
// initRank();
LOGGER.info("罗浮争霸:转到战斗状态,nowstate:{} to BATTLE_STATE",state);
setState(BATTLE_STATE);
if(state==0){
return;
}
initRank();
}
}
@ -787,8 +795,12 @@ public class ArenaLogic {
}
//初始化机器人信息
private void initRank(){
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_SERVICE_ARENA.getType());
//todo 分布式锁
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
String key1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_ARENA_ROBOT_INFO, String.valueOf(crossGroup));
String key2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_SERVICE_ARENA, String.valueOf(crossGroup));
RedisUtil.getInstence().del(key1,key2);
AbstractRank rank = RankContext.getRankEnum(RankEnum.CROSS_SERVICE_ARENA.getType());
int robotIndex = 1000;
Random random = new Random();
Map<String,CrossArenaEnemy> robotInfo = new HashMap<>(1000);
@ -826,23 +838,23 @@ public class ArenaLogic {
if(Integer.parseInt(next.getValue())<1000){
CommonProto.ArenaEnemy.Builder robotCrossArenaEnemy = getRobotCrossArenaEnemy(groupId,rankIndex,Integer.parseInt(next.getValue()));
if(list!=null&&list.size()>0){
robotCrossArenaEnemy.setHadProud(list.contains(String.valueOf(robotCrossArenaEnemy.getPersonInfo().getUid())));
robotCrossArenaEnemy.setHadProud(list.contains(String.valueOf(rankIndex)));
}
arenaEnemyList.add(robotCrossArenaEnemy.build());
}else{
arenaEnemyList.add(getUserCrossArenaEnemy(groupId,rankIndex,Integer.valueOf(next.getValue())));
arenaEnemyList.add(getUserCrossArenaEnemy(groupId,rankIndex,Integer.valueOf(next.getValue()),list.contains(next.getValue())));
}
});
return arenaEnemyList;
}
//获取单个玩家信息(玩家)
public CommonProto.ArenaEnemy getUserCrossArenaEnemy(int crossGroup,int rank,int id) {
public CommonProto.ArenaEnemy getUserCrossArenaEnemy(int crossGroup,int rank,int id,boolean hadProud) {
ArenaOfUser user = null;
CommonProto.ArenaEnemy.Builder userCrossArenaEnemy = null;
try {
user = CrossServiceLogic.getInstance().query(id);
userCrossArenaEnemy = getUserCrossArenaEnemy(crossGroup,user,rank);
userCrossArenaEnemy = getUserCrossArenaEnemy(crossGroup,user,rank,hadProud);
} catch (UnknownHostException e) {
e.printStackTrace();
return null;
@ -931,7 +943,9 @@ public class ArenaLogic {
.setWorshipTime(proudTime)
.setTeam(teamBuild);
}
public CommonProto.ArenaEnemy.Builder getUserCrossArenaEnemy(int crossGroup,ArenaOfUser enemy,int rank){
public CommonProto.ArenaEnemy.Builder getUserCrossArenaEnemy(int crossGroup,ArenaOfUser enemy,int rank,boolean hadProud){
Object get = RedisUtil.getInstence().hget(RedisKey.ARENA_PROUD_COUNT, String.valueOf(enemy.getId()));
int proudTime = get==null?1:Integer.parseInt((String)get);
int enemyId = enemy.getId();
CommonProto.ArenaPersonInfo personInfoBuild = CommonProto.ArenaPersonInfo.newBuilder()
.setUid(enemyId)
@ -942,7 +956,7 @@ public class ArenaLogic {
.setRank(rank)
.build();
return CommonProto.ArenaEnemy.newBuilder()
.setPersonInfo(personInfoBuild);
.setPersonInfo(personInfoBuild).setHadProud(hadProud).setWorshipTime(proudTime);
// .setTeam(teamBuild)
}

View File

@ -64,10 +64,10 @@ public class ArenaWorldLogic {
public static void close() throws Exception {
int myGroup = GlobalidHelper.getWorldInfo().getMyGroup();
if(myGroup==0){
return;
}
// int myGroup = GlobalidHelper.getWorldInfo().getMyGroup();
// if(myGroup==0){
// return;
// }
//赛季结束清除排行
// PlayerInfoProto.RankResponse rankResponse = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.GetRankRequest.newBuilder().setUid(0).setAcitvityId(0).setType(28).setCrossId(myGroup).build(), PlayerInfoProto.RankResponse.class);
//

View File

@ -18,12 +18,15 @@ import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.ActivityType;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.activity.event.GuildForceChangeEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.UserForceChangeEvent;
import com.ljsd.jieling.logic.activity.event.UserMainTeamForceEvent;
import com.ljsd.jieling.logic.activity.eventhandler.UserForceUpEventHandler;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.gm.ArenaOfHero;
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.logic.fight.CombatLogic;
@ -638,6 +641,38 @@ public class PlayerLogic {
}
//获取跨服玩家信息
public PlayerInfoProto.GetPlayerOneTeamInfoResponse getCrossOneTeamInfo( int id,int teamId) throws Exception {
// if(id==0){
// throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
// }
// SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(id);
CommonProto.TeamOneInfo.Builder oneInfo=null;
// if(sArenaRobotConfig!=null){
// oneInfo=getRobotTeamInfo(sArenaRobotConfig);
// }else{
oneInfo = getUserTeamOneInfo(id, teamId);
ArenaOfUser query = CrossServiceLogic.getInstance().query(id);
if(query==null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder()
.setHead(query.getPlayerManager().getHead())
.setHeadFrame(query.getPlayerManager().getHeadFrame())
.setLevel(query.getPlayerManager().getLevel())
.setName(query.getPlayerManager().getName())
.setUid(id);
CommonProto.TeamOneTeamInfo.Builder teamOneTeamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
List<TeamPosHeroInfo> teamPosHeroInfos = query.getHeroManager().getTeams().get(teamId);
for (TeamPosHeroInfo heroInfo:teamPosHeroInfos) {
ArenaOfHero hero = query.getHeroManager().getHeros().get(heroInfo.getHeroId());
teamOneTeamInfo.addTeam(CBean2Proto.getCrossSimpleHero(hero,heroInfo.getPosition()));
}
builder.setTeam(teamOneTeamInfo.build());
PlayerInfoProto.GetPlayerOneTeamInfoResponse.Builder playerTeamInfo = PlayerInfoProto.GetPlayerOneTeamInfoResponse.newBuilder().setTeamInfo(oneInfo);
return playerTeamInfo.build();
}
public void viewRobotHeroInfo(ISession session, SArenaRobotConfig sArenaRobotConfig,String robotHeroId) throws Exception {
PlayerInfoProto.ViewHeroInfoResponse.Builder builder = PlayerInfoProto.ViewHeroInfoResponse.newBuilder();

View File

@ -9,6 +9,7 @@ import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.TowerBuff;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.gm.ArenaOfHero;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.CombatLogic;
@ -859,4 +860,8 @@ public class CBean2Proto {
});
return list;
}
public static CommonProto.TeamSimpleInfo getCrossSimpleHero(ArenaOfHero hero,int position){
return CommonProto.TeamSimpleInfo.newBuilder().setHeroid(hero.getId()).setHeroTid(hero.getTemplateId()).setLevel(hero.getLevel()).setStar(hero.getStar()).setPosition(position).build();
}
}