车迟斗法改为跨服玩法

duhui 2022-03-05 15:39:20 +08:00
parent 85b48640cd
commit 8d7b7bdeb3
21 changed files with 406 additions and 181 deletions

View File

@ -5,6 +5,7 @@ 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.globals.Global;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
import com.ljsd.jieling.logic.dao.UserManager;
@ -12,6 +13,9 @@ import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildFightLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
import config.SErrorCodeEerverConfig;
import config.SWorldBossRewardConfig;
import org.springframework.data.redis.core.ZSetOperations;
@ -24,12 +28,16 @@ public class CarDelayFunction implements FunctionManager {
@Override
public void startAction(TimeControllerOfFunction timeControllerOfFunction) throws Exception {
List<String> delKeys = new ArrayList<>();
String key = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_RANK, "");
String guildKey = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_GUILD_RANK, "");
String userLevelGuild = RedisUtil.getInstence().getKey(RedisKey.USER_LEVEL_GUILD_INFO, "");
delKeys.add(key);
AbstractRank personRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_RANK.getType());
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_GUILD_RANK.getType());
delKeys.add(RedisUtil.getInstence().getKey(personRank.getRedisKey(), ""));
String guildKey = RedisUtil.getInstence().getKey(guildRank.getRedisKey(), "");
delKeys.add(guildKey);
delKeys.add(userLevelGuild);
delKeys.add(RedisUtil.getInstence().getKey(personRank.getCrossRedisKey(), ""));
delKeys.add(RedisUtil.getInstence().getKey(guildRank.getCrossRedisKey(), ""));
// String userLevelGuild = RedisUtil.getInstence().getKey(RedisKey.USER_LEVEL_GUILD_INFO, "");
// delKeys.add(userLevelGuild);
Set<String> guildSet = RedisUtil.getInstence().getZset(guildKey, 0, -1);
guildSet.forEach(guildId->{
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(Integer.parseInt(guildId));
@ -52,7 +60,21 @@ public class CarDelayFunction implements FunctionManager {
TreeMap<Integer, String> personRewardConfigTreeMap = rewardByTypeAndRankMap.get(2);
TreeMap<Integer, String> guildRewardConfigTreeMap = rewardByTypeAndRankMap.get(1);
Set<ZSetOperations.TypedTuple<String>> personRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", 0, -1);
AbstractRank personRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_RANK.getType());
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_GUILD_RANK.getType());
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
Set<ZSetOperations.TypedTuple<String>> personRangeWithScores;
Set<ZSetOperations.TypedTuple<String>> guildRangeWithScores;
if (crossGroup > 0){
personRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getCrossRedisKey(), "", 0, -1, false);
guildRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getCrossRedisKey(), "", 0, -1, false);
}else {
personRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getRedisKey(), "", 0, -1);
guildRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), "", 0, -1);
}
int rank=0;
String personTitle = SErrorCodeEerverConfig.getI18NMessage("family_fight_rank_personreward_title");
@ -70,16 +92,15 @@ public class CarDelayFunction implements FunctionManager {
}
}
MongoUtil.getLjsdMongoTemplate().lastUpdate();
String guildTitle = SErrorCodeEerverConfig.getI18NMessage("family_fight_rank_familyreward_title");
Set<ZSetOperations.TypedTuple<String>> guildRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_GUILD_RANK, "", 0, -1);
rank=0;
Map<Integer, Integer> userLevelGuildMap = RedisUtil.getInstence().getMapValues(RedisKey.USER_LEVEL_GUILD_INFO, "", Integer.class, Integer.class);
Map<Integer,Set<Integer>> usersByGuildId = new HashMap<>();
userLevelGuildMap.forEach((userId,guildId)->{
usersByGuildId.putIfAbsent(guildId,new HashSet<>());
usersByGuildId.get(guildId).add(userId);
});
// Map<Integer, Integer> userLevelGuildMap = RedisUtil.getInstence().getMapValues(RedisKey.USER_LEVEL_GUILD_INFO, "", Integer.class, Integer.class);
// Map<Integer,Set<Integer>> usersByGuildId = new HashMap<>();
// userLevelGuildMap.forEach((userId,guildId)->{
// usersByGuildId.putIfAbsent(guildId,new HashSet<>());
// usersByGuildId.get(guildId).add(userId);
// });
rank=0;
String guildTitle = SErrorCodeEerverConfig.getI18NMessage("family_fight_rank_familyreward_title");
for(ZSetOperations.TypedTuple<String> item : guildRangeWithScores){
rank++;
@ -91,9 +112,9 @@ public class CarDelayFunction implements FunctionManager {
continue;
}
Collection<Set<Integer>> values = guildInfo.getMembers().values();
if(userLevelGuildMap.containsKey(guildId)){
values.add(usersByGuildId.get(guildId));
}
// if(userLevelGuildMap.containsKey(guildId)){
// values.add(usersByGuildId.get(guildId));
// }
String guildContent = SErrorCodeEerverConfig.getI18NMessageNeedConvert("family_fight_rank_familyreward_txt",new Object[]{rank},new int[0],"#");
for(Set<Integer> uids : values){
for(Integer uid:uids){

View File

@ -266,7 +266,8 @@ public class RedisKey {
public final static String CAR_CHALLENGE_RECORD = "CAR_CHALLENGE_RECORD"; //车迟玩法挑战记录
public final static String USER_LEVEL_GUILD_INFO = "USER_LEVEL_GUILD_INFO"; //车迟玩法挑战记录
// 未知参数看之前的逻辑应该时为了给退出工会的玩家发放奖励但是逻辑本身有bug而且找测试对过退出工会的成员不需要发奖励所以相关逻辑暂时废弃
public final static String USER_LEVEL_GUILD_INFO = "USER_LEVEL_GUILD_INFO";
public static final String CHAT_INFO_CACHE = "CHAT_INFO_CACHE";//聊天信息缓存gm后台使用
@ -306,8 +307,8 @@ public class RedisKey {
public static final String GUILD_RED_PACKAGE_RANK = "GUILD_RED_PACKAGE_RANK";
// 车迟斗法
public static final String CAR_DEALY_RANK = "CAR_DEALY_RANK";
public static final String CAR_DEALY_GUILD_RANK = "CAR_DEALY_GUILD_RANK";
//公会战进攻获得星数排行榜

View File

@ -1144,9 +1144,6 @@ public class RedisUtil {
}
public void removeZSetRangeByRank(String key,int start,int end){
for (int i = 0; i < MAX_TRY_TIMES; i++) {
try {

View File

@ -1,12 +1,17 @@
package com.ljsd.jieling.handler;
import com.ljsd.GameApplication;
import com.ljsd.fight.FightType;
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.ErrorCodeException;
import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildFightLogic;
@ -14,7 +19,9 @@ import com.ljsd.jieling.logic.fight.*;
import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.mission.GameEvent;
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.network.session.ISession;
import com.ljsd.jieling.util.MessageUtil;
import config.SErrorCodeEerverConfig;
@ -44,6 +51,7 @@ public class FastChallengeHandler extends BaseHandler<FightInfoProto.FastFightCh
SWorldBossSetting sWorldBossSetting = STableManager.getConfig(SWorldBossSetting.class).get(1);
GuildInfo guildInfo;
int privilege;
int teamId = TeamEnum.CAR_DELAY_TEAM.getTeamId();
if(type == 1 || type == 2){
guildInfo = GuilidManager.guildInfoMap.get(user.getPlayerInfoManager().getGuildId());
if(guildInfo == null){
@ -58,7 +66,7 @@ public class FastChallengeHandler extends BaseHandler<FightInfoProto.FastFightCh
if(user.getPlayerInfoManager().getGuildId() == 0){
throw new ErrorCodeException(ErrorCode.FAMILY_NO);
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(TeamEnum.CAR_DELAY_TEAM.getTeamId());
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
if(teamPosHeroInfos == null || teamPosHeroInfos.isEmpty()){
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE);
@ -79,10 +87,14 @@ public class FastChallengeHandler extends BaseHandler<FightInfoProto.FastFightCh
int battleRound = sWorldBossSetting.getBattleRound();
CommonProto.FightData fightData;
boolean isNew = !guildInfo.getCarFightSb().containsKey(uid);
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
AbstractRank personRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_RANK.getType());
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_GUILD_RANK.getType());
switch (type){
case 1:{
int monsterId = STableManager.getConfig(SWorldBossConfig.class).get(GuildFightLogic.carDelayProgressIndication.getBossIndexId()).getMonsterId();
PVEFightEvent pvpFightEvent = new PVEFightEvent(uid,TeamEnum.CAR_DELAY_TEAM.getTeamId(), battleRound,"", GameFightType.CarBossChallenge,monsterId,3);
PVEFightEvent pvpFightEvent = new PVEFightEvent(uid,teamId, battleRound,"", GameFightType.CarBossChallenge,monsterId,3);
FightResult fightResult = FightDispatcher.dispatcher(pvpFightEvent);
if(fightResult.getResult()==-1){
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
@ -91,18 +103,26 @@ public class FastChallengeHandler extends BaseHandler<FightInfoProto.FastFightCh
fightData = fightResult.getFightData();
gainScore = hurt*(sWorldBossSetting.getScorePercent()/10000F);
double myscore = gainScore;
// if(isNew){
// myscore+=TimeUtils.getDoubleTime();
// }
if(hurt!=0){
RankEnum.toRank(RankEnum.CAR_DEALY_RANK.getType()).incrementRankScore(uid,"",myscore);
RankEnum.toRank(RankEnum.CAR_DEALY_GUILD_RANK.getType()).incrementRankScore(guildInfo.getId(),"",gainScore,isNew?1:0);
if (crossGroup > 0){
personRank.incrementCrossRankScore(uid,"",myscore);
guildRank.incrementCrossRankScore(guildInfo.getId(),"",gainScore,isNew?1:0);
}else {
personRank.incrementRankScore(uid,"",myscore);
guildRank.incrementRankScore(guildInfo.getId(),"",gainScore,isNew?1:0);
}
}
user.getUserMissionManager().onGameEvent(user, GameEvent.CAR_PLAY,1);
}break;
case 2:{
PVPFightEvent pvpFightEvent = new PVPFightEvent(uid,TeamEnum.CAR_DELAY_TEAM.getTeamId(), battleRound,"", GameFightType.CarPersonChallenge,challengeId,TeamEnum.CAR_DELAY_TEAM.getTeamId());
FightResult fightResult = FightDispatcher.dispatcher(pvpFightEvent);
FightResult fightResult;
if (crossGroup > 0){
fightResult = FightUtil.getCrossFightForPVP(uid,challengeId,teamId,teamId, FightType.CarPersonFight,battleRound);
}else {
PVPFightEvent pvpFightEvent = new PVPFightEvent(uid,teamId,battleRound,"", GameFightType.CarPersonChallenge,challengeId,teamId);
fightResult = FightDispatcher.dispatcher(pvpFightEvent);
}
fightData = fightResult.getFightData();
int fight = fightResult.getResult();
String content;
@ -120,32 +140,82 @@ public class FastChallengeHandler extends BaseHandler<FightInfoProto.FastFightCh
}
if(fight == 1){
long challengeScore = RedisUtil.getInstence().getZSetScore(RankEnum.CAR_DEALY_RANK.getRedisKey(), "", String.valueOf(challengeId)).longValue();
long challengeScore;
if (crossGroup > 0){
challengeScore = RedisUtil.getInstence().getZSetScore(personRank.getCrossRedisKey(), "", String.valueOf(challengeId)).longValue();
}else {
challengeScore = RedisUtil.getInstence().getZSetScore(personRank.getRedisKey(), "", String.valueOf(challengeId)).longValue();
}
if(challengeScore !=-1){
gainScore = challengeScore*(sWorldBossSetting.getGrabPercent()/10000F);
if(gainScore!=0){
RankEnum.toRank(RankEnum.CAR_DEALY_RANK.getType()).incrementRankScore(uid,"",gainScore);
RankEnum.toRank(RankEnum.CAR_DEALY_RANK.getType()).incrementRankScore(challengeId,"",-gainScore);
RankEnum.toRank(RankEnum.CAR_DEALY_GUILD_RANK.getType()).incrementRankScore(guildInfo.getId(),"",gainScore,isNew?1:0);
int challengeGuild = playerInfoManager.getGuildId();
if(challengeGuild!=0){
RankEnum.toRank(RankEnum.CAR_DEALY_GUILD_RANK.getType()).incrementRankScore(challengeGuild,"",-gainScore,0);
if (crossGroup > 0){
personRank.incrementCrossRankScore(uid,"",gainScore);
personRank.incrementCrossRankScore(challengeId,"",-gainScore);
guildRank.incrementCrossRankScore(guildInfo.getId(),"",gainScore,isNew?1:0);
if(challengeGuild!=0){
guildRank.incrementCrossRankScore(challengeGuild,"",-gainScore,0);
}
}else {
personRank.incrementRankScore(uid,"",gainScore);
personRank.incrementRankScore(challengeId,"",-gainScore);
guildRank.incrementRankScore(guildInfo.getId(),"",gainScore,isNew?1:0);
if(challengeGuild!=0){
guildRank.incrementRankScore(challengeGuild,"",-gainScore,0);
}
}
}
}
content = SErrorCodeEerverConfig.getI18NMessage("worldboss_battle_win",
new Object[]{challengeNameColor,challengeName,gainScore});
challengeContent = SErrorCodeEerverConfig.getI18NMessage("worldboss_grab_win",
new Object[]{nameColor,user.getPlayerInfoManager().getNickName(),gainScore});
if (crossGroup > 0){
String otherServerName = null;
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(challengeId);
if (csPlayer != null){
otherServerName = CrossServiceLogic.simplifyServerName(csPlayer.getServerId());
}
content = SErrorCodeEerverConfig.getI18NMessage("mserver_worldboss_battle_win",
new Object[]{challengeNameColor,challengeName,gainScore,otherServerName});
String nowServerName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
challengeContent = SErrorCodeEerverConfig.getI18NMessage("mserver_worldboss_grab_win",
new Object[]{nameColor,user.getPlayerInfoManager().getNickName(),gainScore,nowServerName});
}else {
content = SErrorCodeEerverConfig.getI18NMessage("worldboss_battle_win",
new Object[]{challengeNameColor,challengeName,gainScore});
challengeContent = SErrorCodeEerverConfig.getI18NMessage("worldboss_grab_win",
new Object[]{nameColor,user.getPlayerInfoManager().getNickName(),gainScore});
}
}else{
content = SErrorCodeEerverConfig.getI18NMessage("worldboss_battle_lose",
new Object[]{challengeNameColor,challengeName,gainScore});
challengeContent = SErrorCodeEerverConfig.getI18NMessage("worldboss_grab_lose",
new Object[]{nameColor,user.getPlayerInfoManager().getNickName(),gainScore});
if (crossGroup > 0){
String otherServerName = null;
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(challengeId);
if (csPlayer != null){
otherServerName = CrossServiceLogic.simplifyServerName(csPlayer.getServerId());
}
content = SErrorCodeEerverConfig.getI18NMessage("mserver_worldboss_battle_lose",
new Object[]{challengeNameColor,challengeName,gainScore,otherServerName});
String nowServerName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
challengeContent = SErrorCodeEerverConfig.getI18NMessage("mserver_worldboss_grab_lose",
new Object[]{nameColor,user.getPlayerInfoManager().getNickName(),gainScore,nowServerName});
}else {
content = SErrorCodeEerverConfig.getI18NMessage("worldboss_battle_lose",
new Object[]{challengeNameColor, challengeName, gainScore});
challengeContent = SErrorCodeEerverConfig.getI18NMessage("worldboss_grab_lose",
new Object[]{nameColor, user.getPlayerInfoManager().getNickName(), gainScore});
}
}
hurt = fightResult.getDuration();
String key = RedisUtil.getInstence().getKey(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(uid));
String challengeKey = RedisUtil.getInstence().getKey(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(challengeId));
String key;
String challengeKey;
if (crossGroup > 0){
String originalKey = RedisUtil.getInstence().getKey(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(crossGroup), false);
key = RedisUtil.getInstence().getKey(originalKey, String.valueOf(uid), false);
challengeKey = RedisUtil.getInstence().getKey(originalKey, String.valueOf(challengeId), false);
}else {
key = RedisUtil.getInstence().getKey(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(uid));
challengeKey = RedisUtil.getInstence().getKey(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(challengeId));
}
if(hurt!=0){
int time = TimeUtils.nowInt();
RedisUtil.getInstence().zsetAddOne(key,content + "|" + challengeId+"|"+time,time);
@ -158,6 +228,8 @@ public class FastChallengeHandler extends BaseHandler<FightInfoProto.FastFightCh
}
CrossServiceLogic.getInstance().saveBasicPlayerToRedis(user);
fightData.toBuilder().setFightId(FightUtil.getFightId(uid,fightData.getFightType()));
// 记录战报
FightRecordLogic.getInstance().addRecordMap(user,fightData);

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.handler;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import rpc.protocols.CommonProto;
@ -29,8 +30,16 @@ public class GetCarGrapRecordHandler extends BaseHandler{
instance.set(Calendar.SECOND,0);
long timeInMillis = instance.getTimeInMillis();
int leatestTime = (int)(timeInMillis/1000);
RedisUtil.getInstence().removeZSetRangeByScore(RedisKey.CAR_CHALLENGE_RECORD,String.valueOf(iSession.getUid()),0,leatestTime);
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(iSession.getUid()), 0, -1);
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores;
if (crossGroup > 0){
String orginKey = RedisUtil.getInstence().getKey(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(crossGroup), false);
RedisUtil.getInstence().removeZSetRangeByScore(orginKey,String.valueOf(iSession.getUid()),0,leatestTime);
zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(orginKey, String.valueOf(iSession.getUid()), 0, -1, false);
}else {
RedisUtil.getInstence().removeZSetRangeByScore(RedisKey.CAR_CHALLENGE_RECORD,String.valueOf(iSession.getUid()),0,leatestTime);
zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_CHALLENGE_RECORD, String.valueOf(iSession.getUid()), 0, -1);
}
Family.CarGrapRecordResponse.Builder builder = Family.CarGrapRecordResponse.newBuilder();
for(ZSetOperations.TypedTuple<String> item : zsetreverseRangeWithScores ){
int time = item.getScore().intValue();

View File

@ -1,16 +1,27 @@
package com.ljsd.jieling.handler.family;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.GameApplication;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.GuildCache;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.CrossDeathPathLogic;
import com.ljsd.jieling.logic.hero.HeroLogic;
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.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.thrift.idl.ArenaOfHero;
import com.ljsd.jieling.thrift.idl.CrossArenaManager;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.MessageUtil;
import config.SWorldBossSetting;
@ -19,7 +30,10 @@ import org.springframework.data.redis.core.ZSetOperations;
import rpc.protocols.Family;
import rpc.protocols.MessageTypeProto;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class GetCarChallengeListHandler extends BaseHandler {
@Override
@ -35,15 +49,27 @@ public class GetCarChallengeListHandler extends BaseHandler {
if(guildId == 0){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int myRank = RedisUtil.getInstence().getZSetreverseRank(RedisKey.CAR_DEALY_RANK, "", String.valueOf(uid)).intValue();
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
AbstractRank personRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_RANK.getType());
// 我的排名
int myRank;
String key;
if (crossGroup > 0){
myRank = RedisUtil.getInstence().getZSetreverseRank(personRank.getCrossRedisKey(), "", String.valueOf(uid),false).intValue();
key = RedisUtil.getInstence().getKey(personRank.getCrossRedisKey(), "", false);
}else {
myRank = RedisUtil.getInstence().getZSetreverseRank(personRank.getRedisKey(), "", String.valueOf(uid)).intValue();
key = RedisUtil.getInstence().getKey(personRank.getRedisKey(), "");
}
int zsetSize = RedisUtil.getInstence().getZsetSize(key);
int[] matchSection = STableManager.getConfig(SWorldBossSetting.class).get(1).getMatchSection();
int matchNums = matchSection[0] + matchSection[1];
Set<ZsetTypedTupleWithRank> infos = new LinkedHashSet<>(matchNums);
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
Set<Integer> members = new HashSet<>();
guildInfo.getMembers().values().forEach(integers ->members.addAll(integers));
String key = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_RANK, "");
int zsetSize = RedisUtil.getInstence().getZsetSize(key);
List<ZsetTypedTupleWithRank> beforeList = new ArrayList<>(5);
List<ZsetTypedTupleWithRank> afterList = new ArrayList<>(5);
int maxWhile = 30;//最大匹配循环次数
@ -54,8 +80,12 @@ public class GetCarChallengeListHandler extends BaseHandler {
if(zsetSize<end){
break;
}
Set<ZSetOperations.TypedTuple<String>> beforeScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", zsetSize-end , zsetSize-end );
Set<ZSetOperations.TypedTuple<String>> beforeScore;
if (crossGroup > 0){
beforeScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getCrossRedisKey(), "", zsetSize-end, zsetSize-end, false);
}else {
beforeScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getRedisKey(), "", zsetSize-end , zsetSize-end);
}
if(!beforeScore.isEmpty()){
ZSetOperations.TypedTuple<String> beforeNext = beforeScore.iterator().next();
if(!members.contains(Integer.parseInt(beforeNext.getValue()))){
@ -64,16 +94,17 @@ public class GetCarChallengeListHandler extends BaseHandler {
}
end++;
}
// process(start,end,members,matchNums,infos);
}else{
int i = myRank-1;
int j = myRank+1;
while(i>0||j<=zsetSize){
if(i>0){
// Set<String> beforeSet = RedisUtil.getInstence().getReverseZset(key, i - 1, i);
Set<ZSetOperations.TypedTuple<String>> beforeScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", i-1 , i-1);
Set<ZSetOperations.TypedTuple<String>> beforeScore;
if (crossGroup > 0){
beforeScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getCrossRedisKey(), "", i-1 , i-1, false);
}else {
beforeScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getRedisKey(), "", i-1 , i-1);
}
ZSetOperations.TypedTuple<String> beforeNext = beforeScore.iterator().next();
if(!members.contains(Integer.parseInt(beforeNext.getValue()))){
if(beforeList.size()<matchSection[0]){
@ -88,8 +119,12 @@ public class GetCarChallengeListHandler extends BaseHandler {
}
if(j<=zsetSize){
// Set<String> afterSet = RedisUtil.getInstence().getReverseZset(key, j - 1, j);
Set<ZSetOperations.TypedTuple<String>> afterScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", j-1 , j-1);
Set<ZSetOperations.TypedTuple<String>> afterScore;
if (crossGroup > 0){
afterScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getCrossRedisKey(), "", j-1 , j-1, false);
}else {
afterScore = RedisUtil.getInstence().getZsetreverseRangeWithScores(personRank.getRedisKey(), "", j-1 , j-1);
}
ZSetOperations.TypedTuple<String> afterNext = afterScore.iterator().next();
if(!members.contains(Integer.parseInt(afterNext.getValue()))){
@ -113,74 +148,117 @@ public class GetCarChallengeListHandler extends BaseHandler {
}
}
beforeList.addAll(afterList);
// infos.addAll(beforeList);
// //取前面
// int topStart = myRank - matchSection[0];
// if(topStart<0){
// topStart=0;
// }
// int topEnd = myRank;
// process(topStart,topEnd,members,matchNums,infos);
// int downStart = myRank;
// if(downStart<0){
// downStart=0;
// }
// int downEnd = myRank+matchSection[1];
// process(downStart,downEnd,members,matchNums,infos);
}
int myscore = 0;
if(myRank!=-1){
myscore = RedisUtil.getInstence().getZSetScore(RedisKey.CAR_DEALY_RANK, "", String.valueOf(uid)).intValue();
if (crossGroup > 0){
myscore = RedisUtil.getInstence().getZSetScore(personRank.getCrossRedisKey(), "", String.valueOf(uid), false).intValue();
}else {
myscore = RedisUtil.getInstence().getZSetScore(personRank.getRedisKey(), "", String.valueOf(uid)).intValue();
}
}
Family.GetCarChallenegListResponse.Builder builder = Family.GetCarChallenegListResponse.newBuilder().setMyRank(myRank).setMyScore(myscore);
for(ZsetTypedTupleWithRank typedTupleWithRankitem: beforeList){
ZSetOperations.TypedTuple<String> item = typedTupleWithRankitem.getItem();
int challenegUid = Integer.parseInt(item.getValue());
int rank = typedTupleWithRankitem.getRank();
User challenegeUser = UserManager.getUser(challenegUid);
int challengeGuildId = challenegeUser.getPlayerInfoManager().getGuildId();
if (crossGroup > 0){
for(ZsetTypedTupleWithRank typedTupleWithRankitem: beforeList){
ZSetOperations.TypedTuple<String> item = typedTupleWithRankitem.getItem();
int challenegUid = Integer.parseInt(item.getValue());
Family.CarChallengeItem.Builder builder1 = Family.CarChallengeItem.newBuilder()
.setUid(challenegUid)
.setUserName(challenegeUser.getPlayerInfoManager().getNickName())
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(challenegUid);
if (csPlayer == null){
LOGGER.error("车迟斗法跨服获取数据报错玩家为null{}",challenegUid);
continue;
}
Family.CarChallengeItem.Builder builder1 = Family.CarChallengeItem.newBuilder();
int rank = typedTupleWithRankitem.getRank();
int challengeGuildId = csPlayer.getGuildId();
String serverName = CrossServiceLogic.simplifyServerName(csPlayer.getServerId());
int fore;
if(GameApplication.serverId == csPlayer.getServerId()){
User challengeUser = UserManager.getUserNotCache(challenegUid);
if (challengeUser == null){
throw new ErrorCodeException(ErrorCode.USE_NOT_EXIT);
}
fore = HeroLogic.getInstance().calTeamTotalForce(challengeUser, TeamEnum.CAR_DELAY_TEAM.getTeamId(),false);
for (TeamPosHeroInfo heroInfo:challengeUser.getTeamPosManager().getTeamPosForHero().get(TeamEnum.CAR_DELAY_TEAM.getTeamId())) {
Hero hero = challengeUser.getHeroManager().getHero(heroInfo.getHeroId());
builder1.addTeamInfo(CBean2Proto.getSimpleTeamInfoByHero(user, hero,heroInfo.getPosition()));
}
}else {
CrossArenaManager arenaManager = PlayerLogic.getInstance().getCrossArenaManagerData(csPlayer);
if (arenaManager == null){
throw new ErrorCodeException(ErrorCode.USE_NOT_EXIT);
}
fore = arenaManager.getTotalForceByTeam().get(TeamEnum.CAR_DELAY_TEAM.getTeamId());
List<com.ljsd.jieling.thrift.idl.TeamPosHeroInfo> teamPosHeroInfos = arenaManager.getTeams().get(TeamEnum.CAR_DELAY_TEAM.getTeamId());
for (com.ljsd.jieling.thrift.idl.TeamPosHeroInfo info : teamPosHeroInfos) {
ArenaOfHero arenaOfHero = arenaManager.getHeros().get(info.getHeroId());
builder1.addTeamInfo(CBean2Proto.getSimpleTeamInfoByHero(arenaOfHero,info.getPosition()));
}
}
builder1.setUid(challenegUid)
.setUserName(csPlayer.getName())
.setScore(item.getScore().intValue())
.setForce(HeroLogic.getInstance().calTeamTotalForce(challenegeUser, TeamEnum.CAR_DELAY_TEAM.getTeamId(),false))
.setForce(fore)
.setRank(rank)
.setPracticeLevel(challenegeUser.getHeroManager().getPracticeLevel());
for (TeamPosHeroInfo heroInfo:challenegeUser.getTeamPosManager().getTeamPosForHero().get(TeamEnum.CAR_DELAY_TEAM.getTeamId())) {
Hero hero = challenegeUser.getHeroManager().getHero(heroInfo.getHeroId());
builder1.addTeamInfo(CBean2Proto.getSimpleTeamInfoByHero(user, hero,heroInfo.getPosition()));
.setPracticeLevel(csPlayer.getPracticeLevel())
.setServerName(serverName);
if(challengeGuildId!=0){
GuildCache crossGuild = CrossDeathPathLogic.getCrossGuild(challengeGuildId);
builder1.setGuildName(crossGuild.getName());
}
builder.addCarChallengeItem(builder1);
}
if(challengeGuildId!=0){
GuildInfo challenegeGuildInfo = GuilidManager.guildInfoMap.get(challenegeUser.getPlayerInfoManager().getGuildId());
builder1.setGuildName(challenegeGuildInfo.getName());
}else {
for(ZsetTypedTupleWithRank typedTupleWithRankitem: beforeList){
ZSetOperations.TypedTuple<String> item = typedTupleWithRankitem.getItem();
int challenegUid = Integer.parseInt(item.getValue());
int rank = typedTupleWithRankitem.getRank();
User challenegeUser = UserManager.getUser(challenegUid);
int challengeGuildId = challenegeUser.getPlayerInfoManager().getGuildId();
Family.CarChallengeItem.Builder builder1 = Family.CarChallengeItem.newBuilder()
.setUid(challenegUid)
.setUserName(challenegeUser.getPlayerInfoManager().getNickName())
.setScore(item.getScore().intValue())
.setForce(HeroLogic.getInstance().calTeamTotalForce(challenegeUser, TeamEnum.CAR_DELAY_TEAM.getTeamId(),false))
.setRank(rank)
.setPracticeLevel(challenegeUser.getHeroManager().getPracticeLevel());
for (TeamPosHeroInfo heroInfo:challenegeUser.getTeamPosManager().getTeamPosForHero().get(TeamEnum.CAR_DELAY_TEAM.getTeamId())) {
Hero hero = challenegeUser.getHeroManager().getHero(heroInfo.getHeroId());
builder1.addTeamInfo(CBean2Proto.getSimpleTeamInfoByHero(user, hero,heroInfo.getPosition()));
}
if(challengeGuildId!=0){
GuildInfo challenegeGuildInfo = GuilidManager.guildInfoMap.get(challenegeUser.getPlayerInfoManager().getGuildId());
builder1.setGuildName(challenegeGuildInfo.getName());
}
builder.addCarChallengeItem(builder1);
}
builder.addCarChallengeItem(builder1);
}
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.GET_CAR_CHALLENEG_LIST_RESPONSE_VALUE,builder.build(),true);
}
private static void process(int start,int end,Set<Integer> members,int matchNums, Set<ZsetTypedTupleWithRank> infos){
while (start>=0 && infos.size()<matchNums){
int rank=start+1;
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", start, end);
for(ZSetOperations.TypedTuple<String> item : zsetreverseRangeWithScores){
if(!members.contains(Integer.parseInt(item.getValue()))){
infos.add(new ZsetTypedTupleWithRank(item,rank));
}
rank++;
}
end=start;
start-=matchNums;
if(end<=0){
break;
}
}
}
// private static void process(int start,int end,Set<Integer> members,int matchNums, Set<ZsetTypedTupleWithRank> infos){
// while (start>=0 && infos.size()<matchNums){
// int rank=start+1;
// Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.CAR_DEALY_RANK, "", start, end);
// for(ZSetOperations.TypedTuple<String> item : zsetreverseRangeWithScores){
// if(!members.contains(Integer.parseInt(item.getValue()))){
// infos.add(new ZsetTypedTupleWithRank(item,rank));
// }
// rank++;
// }
// end=start;
// start-=matchNums;
// if(end<=0){
// break;
// }
// }
// }
static class ZsetTypedTupleWithRank{
ZSetOperations.TypedTuple<String> item;

View File

@ -255,9 +255,12 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
PlayerLogic.getInstance().checkAndUpdate(user, VipPrivilegeType.WORLD_ARENA_CHALLENGE_TIMES, 1);
}
public static FightResult getFightForPVP(int attachId,int defUid,CommonProto.FightTeamInfo fightTeamInfo, CommonProto.FightTeamInfo deffightTeamInfo,int seed,boolean isRever
,FightType fightType) throws Exception {
LuaValue getFightData ;
public static FightResult getFightForPVP(int attachId,int defUid,CommonProto.FightTeamInfo fightTeamInfo, CommonProto.FightTeamInfo deffightTeamInfo,int seed,boolean isRever,FightType fightType) throws Exception {
return getFightForPVP(attachId,fightTeamInfo,deffightTeamInfo,seed,isRever,fightType,SArenaSetting.getSArenaSetting().getMostTime());
}
public static FightResult getFightForPVP(int attachId,CommonProto.FightTeamInfo fightTeamInfo, CommonProto.FightTeamInfo deffightTeamInfo,int seed,boolean isRever,FightType fightType,int mostTime) throws Exception {
LuaValue getFightData;
if(isRever){
deffightTeamInfo = CommonProto.FightTeamInfo.newBuilder().mergeFrom(deffightTeamInfo).setFirstCamp(1).build();
getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo,true);//对方先手
@ -265,7 +268,7 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
getFightData = FightDataUtil.getFinalPlayerFightData(fightTeamInfo, deffightTeamInfo);
}
LuaValue getOptionData = FightDataUtil.getOptionData(attachId+"");
long[] fightResult = CheckFight.getInstance().checkFight(seed, SArenaSetting.getSArenaSetting().getMostTime(), getFightData, getOptionData, fightType);
long[] fightResult = CheckFight.getInstance().checkFight(seed, mostTime, getFightData, getOptionData, fightType);
FightResult.Builder builder = FightResult.newBuilder();
builder.setCheckResult(fightResult);

View File

@ -8,6 +8,9 @@ import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.GuildLog;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.family.GuildLogic;
import com.ljsd.jieling.logic.rank.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank;
import com.mongodb.BasicDBObject;
import config.SGuildSetting;
import org.springframework.data.mongodb.core.MongoTemplate;
@ -72,7 +75,6 @@ public class GuilidManager {
Integer guilderverId = MongoUtil.getInstence().findGuilderverId(guildLog.getGuildId());
MongoTemplate otherMonogTemplate = MongoUtil.getInstence().getMonogTemplate(guilderverId);
otherMonogTemplate.save(guildLog);
// MongoUtil.getInstence().getMyMongoTemplate().save(guildLog);
if(!guildLogInfoMap.containsKey(guildLog.getGuildId())){
guildLogInfoMap.put(guildLog.getGuildId(),new ArrayList<>());
}
@ -114,8 +116,11 @@ public class GuilidManager {
needContinue=false;
break;
}
String carGuildDelay = RedisUtil.getInstence().getKey(RedisKey.CAR_DEALY_GUILD_RANK,"");
RedisUtil.getInstence().zsetRemoveOne(carGuildDelay,value);
// redis清理key
AbstractRank guildRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_GUILD_RANK.getType());
RedisUtil.getInstence().zsetRemoveOne(RedisUtil.getInstence().getKey(guildRank.getRedisKey(),""),value);
RedisUtil.getInstence().zsetRemoveOne(RedisUtil.getInstence().getKey(guildRank.getCrossRedisKey(),""),value);
GuildInfo guildInfo = guildInfoMap.get(Integer.parseInt(value));
if(guildInfo == null){
RedisUtil.getInstence().zsetRemoveOne(key,value);

View File

@ -20,7 +20,7 @@ public enum TeamEnum {
BLOODY_TEAM(701,"血战队伍"),
CHAMPION_ATTACK_TEAM(801,"巅峰赛进攻队伍(暂时不用)"),
EXPEDITION_TEAM(1001,"大闹天宫"),
CAR_DELAY_TEAM(1101,"车迟斗法",0,1),
CAR_DELAY_TEAM(1101,"车迟斗法",1,1),
DEATH_PATH_TEAM(1201,"十绝阵"),
CHAMPION_TEAM(1301,"巅峰赛",0,1),
WORLD_TEAM_ARENA_DEFENSE(1601,"跨服竞技场防御编队",1,1),

View File

@ -11,6 +11,7 @@ import java.util.Set;
* @Description:
* @Version 1.0
*/
@Deprecated
public class ArenaOfHero {
private String id;
private int templateId; //模板ID

View File

@ -13,6 +13,7 @@ import java.util.Map;
* @Description:
* @Version 1.0
*/
@Deprecated
public class ArenaOfHeroManager {
private Map<Integer, List<TeamPosHeroInfo>> teams = new HashMap<>();

View File

@ -6,6 +6,7 @@ package com.ljsd.jieling.logic.dao.gm;
* @Description: gm
* @Version 1.0
*/
@Deprecated
public class ArenaOfPlayerManager {
private int uId;

View File

@ -14,6 +14,7 @@ import java.util.Map;
* @Description:
* @Version 1.0
*/
@Deprecated
@Document(collection = "arenaOfUser")
public class ArenaOfUser {

View File

@ -607,7 +607,7 @@ public class GuildLogic {
RedisUtil.getInstence().putMapEntry(RedisKey.PLAYER_INFO_CACHE,"",String.valueOf(applyId),cache);
AyyncWorker ayyncWorker = new AyyncWorker(targetUser, true, new AynMissionWorker(GameEvent.JOIN_FAMILY));
ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker);
RedisUtil.getInstence().removeMapEntrys(RedisKey.USER_LEVEL_GUILD_INFO,"",String.valueOf(applyId));
// RedisUtil.getInstence().removeMapEntrys(RedisKey.USER_LEVEL_GUILD_INFO,"",String.valueOf(applyId));
Poster.getPoster().dispatchEvent(new GuildForceChangeEvent(targetUser.getId(),targetUser.getPlayerInfoManager().getGuildId(),1,targetUser.getPlayerInfoManager().getMaxForce()));
@ -1653,14 +1653,16 @@ public class GuildLogic {
* @throws Exception
*/
public static void OnUserLeveFamily(User user)throws Exception{
//TODO lock all 公会id清零之前调用
//退公会清除数据 补发奖励
sendGuildHelpRewardEmail(user);
int guildId = user.getPlayerInfoManager().getGuildId();
RedisUtil.getInstence().zsetRemoveOne(RedisKey.getKey(RedisKey.CAR_DEALY_RANK,"",false),String.valueOf(user.getId()));
RedisUtil.getInstence().zsetRemoveOne(RedisKey.getKey(RedisKey.CAR_DEALY_RANK,"",false),String.valueOf(user.getId()));
RedisUtil.getInstence().putMapEntry(RedisKey.USER_LEVEL_GUILD_INFO,"",String.valueOf(user.getId()),guildId);
// 车迟斗法个人排行清理
AbstractRank personRank = RankContext.getRankEnum(RankEnum.CAR_DEALY_RANK.getType());
RedisUtil.getInstence().zsetRemoveOne(personRank.getRedisKey(),String.valueOf(user.getId()));
RedisUtil.getInstence().zsetRemoveOne(personRank.getCrossRedisKey(),String.valueOf(user.getId()));
// RedisUtil.getInstence().putMapEntry(RedisKey.USER_LEVEL_GUILD_INFO,"",String.valueOf(user.getId()),guildId);
// 十绝阵
RedisUtil.getInstence().zsetRemoveOne(RedisUtil.getInstence().getKey(RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,""),String.valueOf(user.getId()));
//删除战力
Poster.getPoster().dispatchEvent(new GuildForceChangeEvent(user.getId(),user.getPlayerInfoManager().getGuildId(),3,0-user.getPlayerInfoManager().getMaxForce()));

View File

@ -5,32 +5,29 @@ import com.ljsd.GameApplication;
import com.ljsd.fight.ArenaRecord;
import com.ljsd.fight.CheckFight;
import com.ljsd.fight.DefFightSnapData;
import com.ljsd.jieling.config.json.CoreSettings;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.fight.FightType;
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.ErrorCodeException;
import com.ljsd.jieling.handler.gtw.GetWorldArenaChallengeRequestHandler;
import com.ljsd.jieling.handler.map.TrailHero;
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.blood.BloodLogic;
import com.ljsd.jieling.logic.dao.Hero;
import com.ljsd.jieling.logic.dao.TeamEnum;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.gm.ArenaOfHero;
import com.ljsd.jieling.logic.dao.gm.ArenaOfHeroManager;
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.result.FightResult;
import com.ljsd.jieling.logic.fight.robot.RobotInfo;
import com.ljsd.jieling.logic.fight.specialparm.SpecialForTeamBuildEnum;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.thrift.idl.CrossArenaManager;
import com.ljsd.jieling.thrift.idl.PurpleMansionSeal;
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
import com.ljsd.jieling.util.FightDataUtil;
import com.ljsd.jieling.util.MonsterUtil;
import config.*;
@ -41,7 +38,10 @@ import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto;
import util.TimeUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FightUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(FightUtil.class);
@ -174,7 +174,6 @@ public class FightUtil {
}
}
LuaValue getFightData;
if (((PVPFightEvent) fightEvent).isRever()) {
deffightTeamInfo = CommonProto.FightTeamInfo.newBuilder().mergeFrom(deffightTeamInfo).setFirstCamp(1).build();
@ -203,6 +202,55 @@ public class FightUtil {
return builder.build();
}
/**
* pvp
* @param attackId
* @param defendId
* @param attackTeam
* @param defendTeam
* @param fightType
* @param mostTime
* @return
* @throws Exception
*/
public static FightResult getCrossFightForPVP(int attackId, int defendId, int attackTeam, int defendTeam, FightType fightType, int mostTime) throws Exception {
CSPlayer mePlayer = CrossServiceLogic.getPlayerByRedis(attackId);
if (mePlayer == null){
throw new ErrorCodeException(ErrorCode.newDefineCode("当前玩家没有跨服数据:"+attackId));
}
CommonProto.FightTeamInfo meCrossFightTeam = getCrossFightTeam(mePlayer, attackTeam);
CSPlayer hePlayer = CrossServiceLogic.getPlayerByRedis(defendId);
if (hePlayer == null){
throw new ErrorCodeException(ErrorCode.newDefineCode("当前玩家没有跨服数据:"+defendId));
}
CommonProto.FightTeamInfo heCrossFightTeam = getCrossFightTeam(hePlayer, defendTeam);
return GetWorldArenaChallengeRequestHandler.getFightForPVP(attackId,
meCrossFightTeam, heCrossFightTeam, FightUtil.getFightSeed(), false, fightType, mostTime);
}
public static CommonProto.FightTeamInfo getCrossFightTeam(CSPlayer csPlayer, int teamId) throws Exception {
CommonProto.FightTeamInfo.Builder builder;
// 本服
if (csPlayer.getServerId() == GameApplication.serverId){
User user = UserManager.getUserNotCache(csPlayer.getUserId());
if (user == null){
throw new ErrorCodeException(ErrorCode.USE_NOT_EXIT);
}
builder = BehaviorUtil.getFightTeamInfo(user,teamId,true).toBuilder();
}else{
// 跨服
CrossArenaManager crossArenaManager = PlayerLogic.getInstance().getCrossArenaManagerData(csPlayer);
if (crossArenaManager == null){
throw new ErrorCodeException(ErrorCode.newDefineCode("服务器rpc失败:"+csPlayer.getUserId()));
}
builder = FightUtil.makeCrossPersonData(csPlayer, teamId, null, crossArenaManager).toBuilder();
}
return builder.build();
}
public static FightResult getFightForPVP(FightEvent fightEvent) throws Exception {
int fightSeed = getFightSeed();
return getFightForPVP(fightEvent, fightSeed);

View File

@ -28,7 +28,6 @@ import com.ljsd.jieling.logic.activity.eventhandler.PokemonFiveStarGetEventHandl
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
import com.ljsd.jieling.logic.fight.CombatLogic;
@ -2527,30 +2526,6 @@ public class HeroLogic {
return pokemonInfos;
}
public List<CommonProto.FightUnitInfo> getCrossPokemonSkills(ArenaOfUser user) {
//todo 灵兽
Map<Integer, Pokemon> pokemons = user.getPokemons();
List<CommonProto.FightUnitInfo> pokemonInfos = new ArrayList<>();
for (Map.Entry<Integer, Pokemon> entry : pokemons.entrySet()) {
Pokemon pokemon = entry.getValue();
if (pokemon == null) {
continue;
}
SSpiritAnimalSkill sSpiritAnimalSkill = SSpiritAnimalSkill.skillByAnimalAndStar.get(pokemon.getTmpId()).get(pokemon.getStar());
Map<Integer, Integer> map = calOnePokemonAttribute(pokemon.getTmpId(), pokemon.getStar(), pokemon.getLevel());
StringBuilder propertyBuilder = getOnePokemonProperty(map, pokemon.getLevel());
CommonProto.FightUnitInfo info = CommonProto.FightUnitInfo.newBuilder()
.setPosition(entry.getKey())
.setStar(pokemon.getStar())
.setProperty(propertyBuilder.toString())
.setUnitId(String.valueOf(pokemon.getTmpId())).setUnitSkillIds(String.valueOf(sSpiritAnimalSkill.getId())).build();
pokemonInfos.add(info);
}
return pokemonInfos;
}
public List<CommonProto.FightUnitInfo> getCrossPokemon(CrossArenaManager crossArenaManager, CSPlayer csPlayer) {
//todo 灵兽
Map<String, com.ljsd.jieling.thrift.idl.Pokemon> pokemonMap = crossArenaManager.getPokemons();

View File

@ -21,13 +21,16 @@ public enum RankEnum {
RANDOM_CARD_RANK(10,RedisKey.RANDOM_CARD_RANK, RandomCardRank::new,false),//param1抽取积分 param2无 param3:无
RANDOM_CARD_PERFECT_RANK(11,RedisKey.RANDOM_CARD_PERFECT_RANK,RandomCardPerfectRank::new,false),//param1时间 param2英雄tempId param3:uid
GUILD_BOSS_RANK(12,RedisKey.GUILD_BOSS_RANK,GuildBossRank::new,false),//param1时间 param2英雄tempId param3:uid
GUILD_RED_PACKAGE_RANK(13,RedisKey.GUILD_RED_PACKAGE_RANK,GuildRedPackageRank::new,false),//param1红包总价格 param2无 param3:无
CAR_DEALY_RANK(14,RedisKey.CAR_DEALY_RANK,CarDealyRank::new,false),//车迟斗法个人 param1伤害 param2无 param3:无
CAR_DEALY_GUILD_RANK(19,RedisKey.CAR_DEALY_GUILD_RANK,CarDealyGuildRank::new,false),//车迟斗法公会 param1伤害 param2无 param3:无
GUILD_RED_PACKAGE_RANK(13,RedisKey.GUILD_RED_PACKAGE_RANK,GuildRedPackageRank::new,true),//param1红包总价格 param2无 param3:无
CAR_DEALY_RANK(14,RedisKey.CAR_DEALY_RANK,CarDealyRank::new,true),//车迟斗法个人 param1伤害 param2无 param3:无
CAR_DEALY_GUILD_RANK(19,RedisKey.CAR_DEALY_GUILD_RANK,CarDealyGuildRank::new,true),//车迟斗法公会 param1伤害 param2无 param3:无
DEATH_PATH_EVERY_PERSON_RANK(15,RedisKey.DEATH_PATH_EVERY_PERSON_RANK,DeathPathEveryPersonRank::new,true),//param1当前阵玩家伤害 param2无 param3:无
DEATH_PATH_EVERY_GUILD_RANK(16,RedisKey.DEATH_PATH_EVERY_GUILD_RANK, DeathPathEveryGuildRank::new,true),//param1当前阵公会伤害 param2当前工会挑战人数 param3:无
DEATH_PATH_TOTAL_PERSON_RANK(17,RedisKey.DEATH_PATH_TOTAL_PERSON_RANK,DeathPathTotalPersonRank::new,true),//param1玩家总伤害 param2无 param3:无
DEATH_PATH_TOTAL_GUILD_RANK(18,RedisKey.DEATH_PATH_TOTAL_GUILD_RANK,DeathPathTotalGuildRank::new,true),//param1工会总伤害 param2无 param3:无
GUILD_FORCE_RANK(20,RedisKey.GUILD_FORCE_RANK,GuildForceRank::new,false),//param1公会总战力 param2无 param3:无
//达人排行榜
EXPERT_RANK(21,RedisKey.EXPERT_RANK,GoldRank::new,false),//param1活动进度 param2无 param3:无

View File

@ -114,6 +114,11 @@ public abstract class AbstractRank implements IRank {
public void incrementRankScore(int uid,String rkey,double... data){
RedisUtil.getInstence().incrementZsetScore(redisKey,rkey,String.valueOf(uid), getScore(data));
}
public void incrementCrossRankScore(int uid,String rkey,double... data){
RedisUtil.getInstence().incrementZsetScore(getCrossRedisKey(),rkey,String.valueOf(uid), getScore(data),false);
}
public void incrementRankScoreOnly(int uid,String rkey,double... data){
RedisUtil.getInstence().incrementZsetScore(redisKey,rkey,String.valueOf(uid), data[0]);
}

View File

@ -11,7 +11,7 @@ import rpc.protocols.PlayerInfoProto;
/**
* @author Administrator
*/
public class CarDealyGuildRank extends AbstractRank{
public class CarDealyGuildRank extends CrossGuildForceRank{
public CarDealyGuildRank(int type, String redisKey) {
super(type, redisKey);
}

View File

@ -37,6 +37,7 @@ public class CrossLingmaiSecretRank extends AbstractRank {
* @return
* @throws Exception
*/
@Override
public PlayerInfoProto.RankResponse getCrossRank(int uid, String rkey, int page, int rankEndLine) throws Exception {
if(rankEndLine==-1){
rankEndLine = 100;

View File

@ -12,7 +12,6 @@ import com.ljsd.jieling.handler.map.TowerBuff;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
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;
@ -1109,6 +1108,19 @@ public class CBean2Proto {
public static CommonProto.TeamSimpleInfo getSimpleTeamInfoByHero(User user, Hero hero,int position){
return CommonProto.TeamSimpleInfo.newBuilder().setHeroid(hero.getId()).setHeroTid(hero.getTemplateId()).setLevel(hero.getLevel(user.getHeroManager())).setStar(hero.getStar()).setPosition(position).setSkinId(hero.getSkin()).setGodSoulLv(hero.getGodSoulLv()).build();
}
public static CommonProto.TeamSimpleInfo getSimpleTeamInfoByHero(com.ljsd.jieling.thrift.idl.ArenaOfHero hero, int position){
return CommonProto.TeamSimpleInfo.newBuilder()
.setHeroid(hero.getId())
.setHeroTid(hero.getTemplateId())
.setLevel(hero.getLevel())
.setStar(hero.getStar())
.setPosition(position)
.setSkinId(hero.getSkin())
.setGodSoulLv(hero.getGodSoulLv())
.build();
}
public static CommonProto.TeamSimpleInfo getSimpleTeamInfoByPokeMon(Pokemon pokemon,int position){
return CommonProto.TeamSimpleInfo.newBuilder().setHeroid(pokemon.getId()).setHeroTid(pokemon.getTmpId()).setLevel(pokemon.getLevel()).setStar(pokemon.getStar()).setPosition(position).build();
}
@ -1188,17 +1200,6 @@ 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)
.setSkinId(hero.getSkin())
.setGodSoulLv(hero.getGodSoulLv())
.build();
}
/**
*
* @param user