跨服修改

lvxinran 2021-08-01 02:28:08 +08:00
parent 4639b612ea
commit b858575a71
4 changed files with 35 additions and 16 deletions

View File

@ -26,6 +26,7 @@ import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.FightUtil; import com.ljsd.jieling.logic.fight.FightUtil;
import com.ljsd.jieling.logic.fight.result.FightResult; import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.hero.HeroLogic;
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.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum; import com.ljsd.jieling.logic.rank.RankEnum;
@ -156,11 +157,12 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
} }
int defendForce = 0;
if (proto.getChallengeUid()>1000) { if (proto.getChallengeUid()>1000) {
ArenaOfUser arenaOfUser = CrossServiceLogic.getInstance().query(proto.getChallengeUid()); ArenaOfUser arenaOfUser = CrossServiceLogic.getInstance().query(proto.getChallengeUid());
teamInfo = FightUtil.makeCrossPersonData(arenaOfUser); teamInfo = FightUtil.makeCrossPersonData(arenaOfUser);
arenaEnemys =ArenaLogic.getInstance().getUserCrossArenaEnemy(crossGroup,arenaOfUser,proto.getChallengeRank(),false).build(); arenaEnemys =ArenaLogic.getInstance().getUserCrossArenaEnemy(crossGroup,arenaOfUser,proto.getChallengeRank(),false).build();
defendForce = arenaOfUser.getHeroManager().getTotalForce();
} else { } else {
//机器人 //机器人
@ -169,13 +171,15 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
teamInfo = FightUtil.makeRobotFightData(info.getEnemyId()); teamInfo = FightUtil.makeRobotFightData(info.getEnemyId());
// force = SArenaRobotConfig.getsArenaRobotConfigById(info.getEnemyId()).getTotalForce(); // force = SArenaRobotConfig.getsArenaRobotConfigById(info.getEnemyId()).getTotalForce();
arenaEnemys =ArenaLogic.getInstance().getRobotCrossArenaEnemy(crossGroup,proto.getChallengeRank(),proto.getChallengeUid()).build(); arenaEnemys =ArenaLogic.getInstance().getRobotCrossArenaEnemy(crossGroup,proto.getChallengeRank(),proto.getChallengeUid()).build();
defendForce = info.getTotalForce();
} }
arenaAttack = CommonProto.ArenaEnemy.newBuilder().setPersonInfo(CommonProto.ArenaPersonInfo.newBuilder().setUid(iSession.getUid()).setName(user.getPlayerInfoManager().getNickName()).setTotalForce(user.getPlayerInfoManager().getMaxForce()).setServername(CrossServiceLogic.getInstance().findServerName(GameApplication.serverId))).build(); arenaAttack = CommonProto.ArenaEnemy.newBuilder().setPersonInfo(CommonProto.ArenaPersonInfo.newBuilder().setUid(iSession.getUid()).setName(user.getPlayerInfoManager().getNickName()).setTotalForce(user.getPlayerInfoManager().getMaxForce()).setServername(CrossServiceLogic.getInstance().findServerName(GameApplication.serverId)).setPracticeLevel(user.getHeroManager().getPracticeLevel())).build();
int myForce = HeroLogic.getInstance().calTeamTotalForce(user, proto.getTeamId(), true);
// boolean isRevert = proto.getTotalForce() < force; // boolean isRevert = proto.getTotalForce() < force;
int teamId = proto.getTeamId(); int teamId = proto.getTeamId();
CommonProto.FightTeamInfo fightTeamInfo = FightUtil.makePersonFightData(UserManager.getUser(iSession.getUid()), teamId, null, null); CommonProto.FightTeamInfo fightTeamInfo = FightUtil.makePersonFightData(UserManager.getUser(iSession.getUid()), teamId, null, null);
FightResult fightResult = getFightForPVP(iSession.getUid(), proto.getChallengeUid(), fightTeamInfo, teamInfo, FightUtil.getFightSeed(), false); FightResult fightResult = getFightForPVP(iSession.getUid(), proto.getChallengeUid(), fightTeamInfo, teamInfo, FightUtil.getFightSeed(),myForce<defendForce);
builder1.setFightResult((int)fightResult.getCheckResult()[0]); builder1.setFightResult((int)fightResult.getCheckResult()[0]);
int seed = fightResult.getSeed(); int seed = fightResult.getSeed();
CommonProto.FightData build = CommonProto.FightData.newBuilder() CommonProto.FightData build = CommonProto.FightData.newBuilder()

View File

@ -146,6 +146,7 @@ public class GlobleSystemLogic implements IEventHandler {
int rankEndLine = 50; int rankEndLine = 50;
RedisUtil.getInstence().del(GameApplication.serverId+":"+RedisKey.WORLD_CALCUL_LEVE_RAND+":"); RedisUtil.getInstence().del(GameApplication.serverId+":"+RedisKey.WORLD_CALCUL_LEVE_RAND+":");
double sum=0; double sum=0;
int level = 1;
//缓存为null 从库里查 //缓存为null 从库里查
Query query = new Query(); Query query = new Query();
query.with(new Sort(Sort.Direction.DESC,"playerManager.level")); query.with(new Sort(Sort.Direction.DESC,"playerManager.level"));
@ -157,7 +158,7 @@ public class GlobleSystemLogic implements IEventHandler {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if(users.size()>=50) {
for (int j = 0; j <users.size() ; j++) { for (int j = 0; j <users.size() ; j++) {
String rankKey = RedisKey.getKey(RedisKey.WORLD_CALCUL_LEVE_RAND,"", false); String rankKey = RedisKey.getKey(RedisKey.WORLD_CALCUL_LEVE_RAND,"", false);
RedisUtil.getInstence().zsetAddOne(rankKey, String.valueOf(users.get(j).getId()), users.get(j).getPlayerInfoManager().getLevel()); RedisUtil.getInstence().zsetAddOne(rankKey, String.valueOf(users.get(j).getId()), users.get(j).getPlayerInfoManager().getLevel());
@ -174,7 +175,9 @@ public class GlobleSystemLogic implements IEventHandler {
// } // }
} }
int level = (int) Math.ceil(sum / (double) Math.min(rankInfo.size(), rankEndLine)); level = (int) Math.ceil(sum / (double) Math.min(rankInfo.size(), rankEndLine));
}
setGlobalWorldLevelCache(level); setGlobalWorldLevelCache(level);
LOGGER.info("计算了一次世界等级->{}",level); LOGGER.info("计算了一次世界等级->{}",level);
// if (rankInfo.size() > rankEndLine + 100) { // if (rankInfo.size() > rankEndLine + 100) {

View File

@ -47,6 +47,7 @@ import rpc.protocols.ArenaInfoProto;
import rpc.protocols.CommonProto; import rpc.protocols.CommonProto;
import rpc.protocols.FightInfoProto; import rpc.protocols.FightInfoProto;
import rpc.protocols.MessageTypeProto; import rpc.protocols.MessageTypeProto;
import rpc.world.WorldProto;
import util.MathUtils; import util.MathUtils;
import util.StringUtil; import util.StringUtil;
import util.TimeUtils; import util.TimeUtils;
@ -700,6 +701,10 @@ public class ArenaLogic {
private void b2r(){ private void b2r(){
if(state != RELAX_STATE){ if(state != RELAX_STATE){
if(state==BATTLE_STATE){ if(state==BATTLE_STATE){
Map<Integer, ISession> sessionMap = OnlineUserManager.sessionMap;
for(Map.Entry<Integer,ISession> entry:sessionMap.entrySet()){
MessageUtil.sendIndicationMessage(entry.getValue(),1,MessageTypeProto.MessageType.GetWorldArenaInfoIndication_VALUE,null,true);
}
LOGGER.info("罗浮争锋,发奖"); LOGGER.info("罗浮争锋,发奖");
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup(); int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
if(crossGroup==-1){ if(crossGroup==-1){
@ -734,13 +739,14 @@ public class ArenaLogic {
} }
try { try {
MongoUtil.getInstence().lastUpdate(); MongoUtil.getLjsdMongoTemplate().lastUpdate();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
LOGGER.info("罗浮争霸:转到休息状态,nowstate:{} to RELAX_STATE",state); LOGGER.info("罗浮争霸:转到休息状态,nowstate:{} to RELAX_STATE",state);
setState(RELAX_STATE); setState(RELAX_STATE);
} }
} }
@ -760,6 +766,10 @@ public class ArenaLogic {
return; return;
} }
initRank(); initRank();
Map<Integer, ISession> sessionMap = OnlineUserManager.sessionMap;
for(Map.Entry<Integer,ISession> entry:sessionMap.entrySet()){
MessageUtil.sendIndicationMessage(entry.getValue(),1,MessageTypeProto.MessageType.GetWorldArenaInfoIndication_VALUE,null,true);
}
} }
} }

View File

@ -65,6 +65,7 @@ public class CrossArenaRank extends AbstractRank {
.setLevel(100) .setLevel(100)
.setUserSkin(80012) .setUserSkin(80012)
.setRankInfo(everyRankInfo) .setRankInfo(everyRankInfo)
.setServerName(CrossServiceLogic.getInstance().findServerName(mapEntry.getServerID()))
.setSex(0); .setSex(0);
builder.addRanks(everyRank); builder.addRanks(everyRank);
}else{ }else{
@ -84,6 +85,7 @@ public class CrossArenaRank extends AbstractRank {
.setRankInfo(everyRankInfo) .setRankInfo(everyRankInfo)
.setForce(query.getHeroManager().getTotalForce()) .setForce(query.getHeroManager().getTotalForce())
.setPracticeLevel(query.getPlayerManager().getPracticeLevel()) .setPracticeLevel(query.getPlayerManager().getPracticeLevel())
.setServerName(query.getPlayerManager().getServerName())
.setSex(0); .setSex(0);
builder.addRanks(everyRank); builder.addRanks(everyRank);
} }