From db8974a8c813f41f9ddbe6486690418a6dc73f6d Mon Sep 17 00:00:00 2001 From: duhui Date: Fri, 14 Apr 2023 15:26:04 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=B7=85=E5=B3=B0=E8=B5=9B=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=80=BB=E8=BE=91=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=202=E3=80=81=E5=B7=85=E5=B3=B0=E8=B5=9B=E5=86=97=E4=BD=99?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96=203=E3=80=81user=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E8=AE=A1=E6=95=B0=E5=8A=9F=E8=83=BD=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/champion/ChampinGetHandler.java | 98 +---- .../champion/ChampionBetInfoHandler.java | 41 +- .../logic/championship/ChampionshipLogic.java | 391 +++++++++--------- .../ljsd/jieling/logic/dao/UserManager.java | 42 +- .../jieling/logic/player/PlayerLogic.java | 2 +- .../com/ljsd/jieling/util/CBean2Proto.java | 16 + 6 files changed, 236 insertions(+), 354 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampinGetHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampinGetHandler.java index 84a5bcb12..91d73fead 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampinGetHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampinGetHandler.java @@ -61,7 +61,6 @@ public class ChampinGetHandler extends BaseHandler { Object latestKey = RedisUtil.getInstence().lGetIndex(key, -1); if(latestKey!=null) { ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", latestKey.toString(), ArenaRecord.class); - int enemyId = arenaRecord.getDefUid(); int attackId = arenaRecord.getAttackId(); int fightResult = arenaRecord.getFightResult(); int roundTims = arenaRecord.getRoundTims(); @@ -110,110 +109,31 @@ public class ChampinGetHandler extends BaseHandler { } if(ChampionshipLogic.getProgress()==-2){ if(arenaRecord.getRoundTims()-7==5){ - if(state==0&&attackId==uid){ - builder.setLoser(true); - }else { - builder.setLoser(false); - } + builder.setLoser(state == 0 && attackId == uid); }else { builder.setLoser(true); } }else { if(schedule==2){ - if( roundTims - 7 != realTimes) { - builder.setLoser(true); - }else { - builder.setLoser(false); - } + builder.setLoser(roundTims - 7 != realTimes); }else if(schedule==1){ - if(roundTims!=roundTimes){ - builder.setLoser(true); - }else { - builder.setLoser(false); - } + builder.setLoser(roundTims != roundTimes); } } builder.setProcess(state); - SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(arenaRecord.getAttackId()); - if (sArenaRobotConfig != null) { - builder1.setMyInfo( PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig)) ; - }else { - ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(arenaRecord.getAttackId()), ChampionshipLogic.MemberInfo.class); - FamilyFightInfo fightInfo = memberInfo.getFightInfo(); - if(fightInfo == null){ - builder1.setMyInfo( PlayerLogic.getInstance().getUserTeamOneInfo(arenaRecord.getAttackId(), TeamEnum.CHAMPION_TEAM.getTeamId())); - }else { - //fix 整个过程都不能调整编队 + CommonProto.TeamOneInfo.Builder myInfo = ChampionshipLogic.getUserTeam(arenaRecord.getAttackId()); + builder1.setMyInfo(myInfo); - User user = UserManager.getUser(arenaRecord.getAttackId()); - CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user); - CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder(); - teamInfo.setTotalForce(fightInfo.getForce()); - if (!fightInfo.getPokenmonIds().isEmpty()) { -// teamInfo.addAllPokemonInfos(fightInfo.getPokenmonIds()); - } + CommonProto.TeamOneInfo.Builder defInfo = ChampionshipLogic.getUserTeam(arenaRecord.getDefUid()); + builder1.setEnemyInfo(defInfo); - // int i = 1; - for (Map.Entry entry : fightInfo.getHeroAttribute().entrySet()) { - FamilyHeroInfo familyHeroInfo = entry.getValue(); - teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder() - .setHeroid(entry.getKey()) - .setHeroTid(familyHeroInfo.getTempleteId()) - .setStar(familyHeroInfo.getStar()) - .setLevel(familyHeroInfo.getLevel()) - .setPosition(familyHeroInfo.getPosition()) - .setGodSoulLv(familyHeroInfo.getGodSoulLv()) - .build() - ); - } - oneInfo.setTeam(teamInfo); - builder1.setMyInfo(oneInfo); - } - } + builder1.setResult(fightResult); - sArenaRobotConfig= SArenaRobotConfig.getsArenaRobotConfigById(arenaRecord.getDefUid()); - if (sArenaRobotConfig != null) { - builder1.setEnemyInfo( PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig)) ; - }else { - ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(arenaRecord.getDefUid()), ChampionshipLogic.MemberInfo.class); - FamilyFightInfo fightInfo = memberInfo.getFightInfo(); - if(fightInfo == null){ - builder1.setEnemyInfo( PlayerLogic.getInstance().getUserTeamOneInfo(arenaRecord.getDefUid(), TeamEnum.CHAMPION_TEAM.getTeamId())); - }else { - //fix 整个过程都不能调整编队 - - User user = UserManager.getUser(arenaRecord.getDefUid()); - CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user); - CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder(); - teamInfo.setTotalForce(fightInfo.getForce()); - if (!fightInfo.getPokenmonIds().isEmpty()) { -// teamInfo.addAllPokemonInfos(fightInfo.getPokenmonIds()); - } - - // int i = 1; - for (Map.Entry entry : fightInfo.getHeroAttribute().entrySet()) { - FamilyHeroInfo familyHeroInfo = entry.getValue(); - teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder() - .setHeroid(entry.getKey()) - .setHeroTid(familyHeroInfo.getTempleteId()) - .setStar(familyHeroInfo.getStar()) - .setLevel(familyHeroInfo.getLevel()) - .setPosition(familyHeroInfo.getPosition()) - .setGodSoulLv(familyHeroInfo.getGodSoulLv()) - .build() - ); - } - oneInfo.setTeam(teamInfo); - builder1.setEnemyInfo(oneInfo); - }} - builder.setChampionBattleInfo(builder1 - .setResult(fightResult) - .build()); + builder.setChampionBattleInfo(builder1.build()); } - } MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.CHAMPION_GET_RESPONSE_VALUE,builder.build(),true); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampionBetInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampionBetInfoHandler.java index 87f084af7..bf1cefef9 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampionBetInfoHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/champion/ChampionBetInfoHandler.java @@ -141,10 +141,10 @@ public class ChampionBetInfoHandler extends BaseHandler entry : fightInfo.getHeroAttribute().entrySet()) { - FamilyHeroInfo familyHeroInfo = entry.getValue(); - teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder() - .setHeroid(entry.getKey()) - .setHeroTid(familyHeroInfo.getTempleteId()) - .setStar(familyHeroInfo.getStar()) - .setLevel(familyHeroInfo.getLevel()) - .setPosition(familyHeroInfo.getPosition()) - .setGodSoulLv(familyHeroInfo.getGodSoulLv()) - .build() - ); - } - oneInfo.setTeam(teamInfo); - builder = oneInfo; - } - } - return builder; - } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java index e41ee563b..8603e2871 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java @@ -62,9 +62,9 @@ public class ChampionshipLogic { private static volatile int roundTimes; //比赛进行第几轮//时间轮 private static volatile int realTimes; //比赛进行第几轮 比赛轮 - private static Map fightAll = new ConcurrentHashMap<>(); - private static volatile int fightTime=1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束 - private static volatile int fightTime_temp=1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束 + private static Map fightAll = new ConcurrentHashMap<>(); + private static volatile int fightTime = 1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束 + private static volatile int fightTime_temp = 1; //本轮比赛是否打完 1 第一场 2 第二场 3第三场 0结束 private static volatile int schedule = 1;//1 选拔赛 public static final int PROCESS_PRE = 1;//准备竞猜 public static final int PROCESS_BATTLE = 3;//战斗结算 @@ -81,18 +81,19 @@ public class ChampionshipLogic { } - public static void init(){ + public static void init() { try { String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_SCHEDULE, ""); Object result = RedisUtil.getInstence().get(key); if (result != null) { schedule = Integer.parseInt((String) result); } - }catch (Exception e){ - LOGGER.info("Exception the init={}"); + } catch (Exception e) { + LOGGER.info("Exception the init={}", e); } } + public static int getProgress() { return progress; } @@ -181,26 +182,26 @@ public class ChampionshipLogic { //提前把分数缓存进来 - public static void setScoreForSuccess(int winnerUid, int failerUid,boolean result) { - MemberInfo memberInfo = getJoinMemberInfo(winnerUid); - if (schedule == 2 ) { - if(!result){//第二阶段没出结果直接返回 - return; - } -// if(3!=fightTime){ +// public static void setScoreForSuccess(int winnerUid, int failerUid,boolean result) { +// MemberInfo memberInfo = getJoinMemberInfo(winnerUid); +// if (schedule == 2 ) { +// if(!result){//第二阶段没出结果直接返回 // return; // } - memberInfo.setFinalScore(memberInfo.getFinalScore() + 1); - MemberInfo failMemberInfo = getJoinMemberInfo(failerUid); - failMemberInfo.setFinalScore(memberInfo.getFinalScore() * -1); - LOGGER.info("the falid={}", failerUid); - updateJoinMemberInfo(memberInfo); - updateJoinMemberInfo(failMemberInfo); - return; - } - memberInfo.setScore(memberInfo.getScore() + 1); - updateJoinMemberInfo(memberInfo); - } +//// if(3!=fightTime){ +//// return; +//// } +// memberInfo.setFinalScore(memberInfo.getFinalScore() + 1); +// MemberInfo failMemberInfo = getJoinMemberInfo(failerUid); +// failMemberInfo.setFinalScore(memberInfo.getFinalScore() * -1); +// LOGGER.info("the falid={}", failerUid); +// updateJoinMemberInfo(memberInfo); +// updateJoinMemberInfo(failMemberInfo); +// return; +// } +// memberInfo.setScore(memberInfo.getScore() + 1); +// updateJoinMemberInfo(memberInfo); +// } private static MemberInfo getJoinMemberInfo(int joinUid) { return RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_JOIN, "", Integer.toString(joinUid), MemberInfo.class); @@ -224,10 +225,10 @@ public class ChampionshipLogic { // } // } - if(schedule==2){ - // if(fightTime!=0||realTimes!=1){ - if(ChampionshipLogic.fightTime!=3) return; - // } + if (schedule == 2) { + // if(fightTime!=0||realTimes!=1){ + if (ChampionshipLogic.fightTime != 3) return; + // } } //胜利者积分排名 @@ -239,14 +240,14 @@ public class ChampionshipLogic { int winnerUid = v.getAttackId(); int failerUid = v.getDefUid(); - if(schedule==2){ - String key = String.valueOf(v.getAttackId() * 2222 + String.valueOf(v.getDefUid())); + if (schedule == 2) { + String key = v.getAttackId() * 2222 + String.valueOf(v.getDefUid()); Integer state = states.get(key); - if (null!=state&&state == 0) { + if (null != state && state == 0) { winnerUid = v.getDefUid(); failerUid = v.getAttackId(); } - }else { + } else { if (v.getFightResult() == 0) { winnerUid = v.getDefUid(); failerUid = v.getAttackId(); @@ -256,7 +257,7 @@ public class ChampionshipLogic { MemberInfo joinMemberInfo = getJoinMemberInfo(winnerUid); - int score ; + int score; if (schedule == 2) { joinMemberInfo.setFinalScore(joinMemberInfo.getFinalScore() + 1); MemberInfo failMemberInfo = getJoinMemberInfo(failerUid); @@ -265,16 +266,16 @@ public class ChampionshipLogic { updateJoinMemberInfo(failMemberInfo); score = joinMemberInfo.getFinalScore(); finalArenaIds.add(v.getId()); - }else { + } else { joinMemberInfo.setScore(joinMemberInfo.getScore() + 1); score = joinMemberInfo.getScore(); updateJoinMemberInfo(joinMemberInfo); } - integerIntegerHashMap.putIfAbsent(winnerUid,new DefaultTypedTuple(Integer.toString(winnerUid), (double) score)); + integerIntegerHashMap.putIfAbsent(winnerUid, new DefaultTypedTuple(Integer.toString(winnerUid), (double) score)); }); RedisUtil.getInstence().updateZsetScores(RedisKey.CHAMPION_RANK, "", new HashSet<>(integerIntegerHashMap.values())); if (schedule == 2) { - // RedisUtil.getInstence().lSet(RedisKey.CHAMPION_FINAL_RECODED_IDS, "", finalArenaIds); + // RedisUtil.getInstence().lSet(RedisKey.CHAMPION_FINAL_RECODED_IDS, "", finalArenaIds); } } @@ -300,9 +301,9 @@ public class ChampionshipLogic { for (ZSetOperations.TypedTuple item : arenaRankInfoInRedis) { String uidStr = item.getValue(); int uid = Integer.parseInt(uidStr); - // if (!robotConfigMap.containsKey(uid)) { - joinUids.add(uid); - // } + // if (!robotConfigMap.containsKey(uid)) { + joinUids.add(uid); + // } } clearReidsWhenEnd(joinUids); SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting(); @@ -312,18 +313,16 @@ public class ChampionshipLogic { //获取竞技场排行榜 Set> arenaRankInfo = new HashSet<>(championshipPlayer); //start-end为0 127 才能拿到第128 不然会多拿到129 - Set> arenaRankInfoOne = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, championshipPlayer-1); + Set> arenaRankInfoOne = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ARENA_RANK, Integer.toString(curSeason), 0, championshipPlayer - 1); if (arenaRankInfoOne != null && !arenaRankInfoOne.isEmpty()) { arenaRankInfo.addAll(arenaRankInfoOne); } Set> arenaRankInfoForChampion = new HashSet<>(); //存入排行榜 - List joinMembers = new ArrayList<>(championshipPlayer); //TODO 应该没用 List memberInfos = new ArrayList<>(championshipPlayer); arenaRankInfo.forEach(item -> { String uidStr = item.getValue(); MemberInfo memberInfo = new MemberInfo(Integer.parseInt(uidStr), 0); - joinMembers.add(memberInfo); ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(uidStr, 0D); arenaRankInfoForChampion.add(typedTuple); memberInfos.add(memberInfo); @@ -349,11 +348,10 @@ public class ChampionshipLogic { break; } MemberInfo memberInfo = new MemberInfo(sArenaRobotConfig.getId(), 1); - joinMembers.add(memberInfo); ZSetOperations.TypedTuple typedTuple = new DefaultTypedTuple(Integer.toString(sArenaRobotConfig.getId()), 0D); arenaRankInfoForChampion.add(typedTuple); memberInfos.add(memberInfo); - LOGGER.info("the end={},the robotID={},the size={}", end, sArenaRobotConfig.getId(), joinMembers.size()); + LOGGER.info("the end={},the robotID={},the size={}", end, sArenaRobotConfig.getId(), memberInfos.size()); } } @@ -415,17 +413,17 @@ public class ChampionshipLogic { user.getArenaManager().setTopMaxRank(rank); } user.getUserMissionManager().onGameEvent(user, GameEvent.CHAMPIONSHIP_RANK, rank); - if(rank == 1){ - Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.top_match_rank.getType(),1)); + if (rank == 1) { + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.top_match_rank.getType(), 1)); } rank++; String title = SErrorCodeEerverConfig.getI18NMessage("champion_reward_title"); - String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("champion_reward_txt", new Object[]{sChampionshipReward.getTitleDesc()},new int[]{1},"#"); + String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("champion_reward_txt", new Object[]{sChampionshipReward.getTitleDesc()}, new int[]{1}, "#"); MailLogic.getInstance().sendMail(user.getId(), title, content, ItemUtil.getMailReward(sChampionshipReward.getSeasonReward()), nowTime, Global.MAIL_EFFECTIVE_TIME); } - }catch (Exception e){ - LOGGER.info("Exception e = "+"size"+ arenaRankInfo.size()+ e.toString()); + } catch (Exception e) { + LOGGER.info("Exception e = " + "size" + arenaRankInfo.size() + e.toString()); } MongoUtil.getLjsdMongoTemplate().lastUpdate(); @@ -438,35 +436,29 @@ public class ChampionshipLogic { Item item = user.getItemManager().getItem(arenaItemId); int itemNum = 0; if (item != null) { - itemNum =(int)item.getItemNum(); + itemNum = (int) item.getItemNum(); } if (item != null && itemNum > 0) { int[][] costs = new int[1][]; costs[0] = new int[2]; costs[0][0] = arenaItemId; costs[0][1] = itemNum; -// Map itemReward = new HashMap<>(1); -// itemReward.put(rewardItemId, (long) (itemNum / sChampionshipSetting.getExchangeItem())); String title = SErrorCodeEerverConfig.getI18NMessage("champion_bet_title"); String content = SErrorCodeEerverConfig.getI18NMessage("champion_bet_content"); - MailLogic.getInstance().sendMail(user.getId(),title,content,rewardItemId+"#"+(itemNum / sChampionshipSetting.getExchangeItem()),TimeUtils.nowInt(),Global.MAIL_EFFECTIVE_TIME); + MailLogic.getInstance().sendMail(user.getId(), title, content, rewardItemId + "#" + (itemNum / sChampionshipSetting.getExchangeItem()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME); ItemUtil.itemCost(user, costs, BIReason.CHAMPIONM_EXCHANGE_CONSUME, sendId); -// ItemUtil.addItem(user, itemReward, null, BIReason.CHAMPIONM_EXCHANGE_REWARD); } - LOGGER.info("the uid={}, send rewardnum={}",user.getId(), itemNum / sChampionshipSetting.getExchangeItem()); + LOGGER.info("the uid={}, send rewardnum={}", user.getId(), itemNum / sChampionshipSetting.getExchangeItem()); } MongoUtil.getLjsdMongoTemplate().lastUpdate(); - //clearReidsWhenEnd(joinUids); - - } /** * 用于测试使用 */ - public static void whenStart() throws Exception { +// public static void whenStart() throws Exception { // schedule=1; // start(); // for(int i=1;i<8;i++){ @@ -491,9 +483,7 @@ public class ChampionshipLogic { // progress=-2; // // // close(); - - - } +// } /** @@ -525,56 +515,34 @@ public class ChampionshipLogic { } - public static CommonProto.TeamOneInfo.Builder getChampionBattleInfo(int uid) throws Exception { + public static CommonProto.TeamOneInfo.Builder getChampionBattleInfo(int uid) { + CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder(); SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(uid); if (sArenaRobotConfig != null) { - return CommonProto.TeamOneInfo.newBuilder() - .setLevel(sArenaRobotConfig.getRobotLevel()) - .setName(sArenaRobotConfig.getRobotName()) - .setUid(sArenaRobotConfig.getId()); - // return PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig); - } - MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(uid), MemberInfo.class); - FamilyFightInfo fightInfo = memberInfo.getFightInfo(); - if(fightInfo == null){ - return PlayerLogic.getInstance().getUserTeamOneInfo(uid,TeamEnum.CHAMPION_TEAM.getTeamId()); - } - //fix 整个过程都不能调整编队 - - User user = UserManager.getUser(uid); - return CBean2Proto.getTeamOneInfo(user); - // CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder(); -// teamInfo.setTotalForce(fightInfo.getForce()); -// if (!fightInfo.getPokenmonIds().isEmpty()) { -// teamInfo.addAllPokemonInfos(fightInfo.getPokenmonIds()); -// } -// -//// int i = 1; -// for (Map.Entry entry : fightInfo.getHeroAttribute().entrySet()) { -// FamilyHeroInfo familyHeroInfo = entry.getValue(); -// teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder() -// .setHeroid(entry.getKey()) -// .setHeroTid(familyHeroInfo.getTempleteId()) -// .setStar(familyHeroInfo.getStar()) -// .setLevel(familyHeroInfo.getLevel()) -// .setPosition(familyHeroInfo.getPosition()) -// .build() -// ); -// } -// oneInfo.setTeam(teamInfo); - } - - - private static String getMyCurJoinBattleId(int uid) { - List curArenaRecordList = getCurArenaRecordList(); - for (ArenaRecord arenaRecord : curArenaRecordList) { - if (arenaRecord.getDefUid() == uid || arenaRecord.getAttackId() == uid) { - return arenaRecord.getId(); + builder.setUid(sArenaRobotConfig.getId()).setLevel(sArenaRobotConfig.getRobotLevel()).setName(sArenaRobotConfig.getRobotName()); + }else { + MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(uid), MemberInfo.class); + FamilyFightInfo fightInfo = memberInfo.getFightInfo(); + if (fightInfo == null) { + builder = PlayerLogic.getInstance().getUserTeamOneInfo(uid, TeamEnum.CHAMPION_TEAM.getTeamId()); + }else { + //fix 整个过程都不能调整编队 + builder = CBean2Proto.getTeamOneInfo(uid); } } - return null; + return builder; } +// private static String getMyCurJoinBattleId(int uid) { +// List curArenaRecordList = getCurArenaRecordList(); +// for (ArenaRecord arenaRecord : curArenaRecordList) { +// if (arenaRecord.getDefUid() == uid || arenaRecord.getAttackId() == uid) { +// return arenaRecord.getId(); +// } +// } +// return null; +// } + /** * 获取我的队伍信息 * @@ -630,8 +598,7 @@ public class ChampionshipLogic { } - - public static void snapPlayFightInfo( boolean fight) throws Exception { + public static void snapPlayFightInfo(boolean fight) throws Exception { int snapTeamId = TeamEnum.CHAMPION_ATTACK_TEAM.getTeamId(); RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_FIGHT, "")); int warTime = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getWarTime(); @@ -643,7 +610,7 @@ public class ChampionshipLogic { snapOneFightInfo(attackId, memberInfoMap); snapOneFightInfo(defUid, memberInfoMap); - if(fight){ + if (fight) { long id = FightDispatcher.getFIghtId(); EndFightProcessor endFightProcessor = new AreFightPro(); ((AreFightPro) endFightProcessor).setArenaRecord(arenaRecord); @@ -657,30 +624,30 @@ public class ChampionshipLogic { if (defMemberInfo.getType() == 0) { FamilyFightInfo fightInfo = defMemberInfo.getFightInfo(); - pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(),defUid)); + pvpFightEvent.setDefFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), defUid)); defForce = fightInfo.getForce(); - }else { + } else { SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(defUid); - if(sArenaRobotConfig!=null){ + if (sArenaRobotConfig != null) { defForce = sArenaRobotConfig.getTotalForce(); } } if (attackMemberInfo.getType() == 0) { FamilyFightInfo fightInfo = attackMemberInfo.getFightInfo(); - pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(),attackId)); + pvpFightEvent.setAttackFightSnapData(new DefFightSnapData(fightInfo.getHeroAttribute(), fightInfo.getHeroSkills(), fightInfo.getPokenmonSkills(), fightInfo.getPassiveSkills(), attackId)); minForce = fightInfo.getForce(); - }else { + } else { SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(attackId); - if(sArenaRobotConfig!=null){ + if (sArenaRobotConfig != null) { minForce = sArenaRobotConfig.getTotalForce(); } } - if(minForce>defForce){ - if(arenaRecord.getTurn()==2){ + if (minForce > defForce) { + if (arenaRecord.getTurn() == 2) { pvpFightEvent.setRever(true); } - }else { - if(arenaRecord.getTurn()==1||arenaRecord.getTurn()==3){ + } else { + if (arenaRecord.getTurn() == 1 || arenaRecord.getTurn() == 3) { pvpFightEvent.setRever(true); } } @@ -761,6 +728,7 @@ public class ChampionshipLogic { RedisUtil.getInstence().incrementZsetScore(RedisKey.CHAMPION_BET_ALL, "", selectBetId + ":" + defUid, guessNum); String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_CUR_BETID, ""); RedisUtil.getInstence().set(key, selectBetId); + LOGGER.info("巅峰赛比赛队伍信息,竞赛id:{},攻击者:{},防御者:{}",selectBetId, attackId, defUid); } public static int getForce(MemberInfo memberInfo, Map config) { @@ -774,13 +742,6 @@ public class ChampionshipLogic { return force; } - -// public static void guess(ISession session, int winUid,int chip) throws Exception { -// -// -// } - - /** * 回收资源 */ @@ -816,8 +777,8 @@ public class ChampionshipLogic { delKeys.add(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(uid))); }); RedisUtil.getInstence().del(delKeys.toArray(new String[0])); - realTimes=1; - fightTime=1; + realTimes = 1; + fightTime = 1; fightAll.clear(); } @@ -828,7 +789,8 @@ public class ChampionshipLogic { */ public static void sendBetReward() { String selectUid = getSelectIdForRedis(); - if(selectUid.isEmpty()){ + LOGGER.info("巅峰赛开始发奖,轮次:{}",selectUid); + if (selectUid.isEmpty()) { return; } int[] arenaItem = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getArenaItem(); @@ -847,7 +809,7 @@ public class ChampionshipLogic { AtomicBoolean winner = new AtomicBoolean(true); if (schedule == 2) { Map states = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_ARENA_RECORD_THREE, "", String.class, Integer.class); - String key = String.valueOf(arenaRecord.getAttackId() * 2222 + String.valueOf(arenaRecord.getDefUid())); + String key = arenaRecord.getAttackId() * 2222 + String.valueOf(arenaRecord.getDefUid()); Integer state = states.get(key); if (null != state && state == 0) { winnerUid = arenaRecord.getDefUid(); @@ -871,23 +833,21 @@ public class ChampionshipLogic { betPersonInfoMap.forEach((betUid, coins) -> { try { User user = UserManager.getUser(betUid); - AyyncWorker ayyncWorker = new AyyncWorker(user, true, new AyncWorkerRunnable() { - @Override - public void work(User user) throws Exception { - int mineWinCoins = (int) (winRate * coins); - int[][] drop = new int[1][]; - drop[0] = new int[2]; - drop[0][0] = arenaItem[0]; - drop[0][1] = mineWinCoins; - ItemUtil.drop(user, drop, BIReason.CHAMPIION_BET_WIN_REWARD); - MongoUtil.getLjsdMongoTemplate().lastUpdate(); - ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId()); - if (sessionByUid != null) { - ArenaInfoProto.ChampionGuessSuccessIndication build = ArenaInfoProto.ChampionGuessSuccessIndication.newBuilder().setItemId(arenaItem[0]).setItemNum(mineWinCoins).setRoundTimes(roundTimes).build(); - MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.CHAMPION_GUESS_SUCCESS_INDICATION_VALUE, build, true); - } - ReportUtil.onReportEvent(user, ReportEventEnum.GUESS_OVER.getType(),openTimeOfFuntionCacheByType.getTimes(),getSchedule()==1?getRealTimes():getRealTimes()+7,winner.get()?1:2,mineWinCoins); + AyyncWorker ayyncWorker = new AyyncWorker(user, true, user1 -> { + int mineWinCoins = (int) (winRate * coins); + int[][] drop = new int[1][]; + drop[0] = new int[2]; + drop[0][0] = arenaItem[0]; + drop[0][1] = mineWinCoins; + LOGGER.info("巅峰赛结束,给玩家发奖,uid:{},奖品:{}",user1.getId(),drop); + ItemUtil.drop(user1, drop, BIReason.CHAMPIION_BET_WIN_REWARD); + MongoUtil.getLjsdMongoTemplate().lastUpdate(); + ISession sessionByUid = OnlineUserManager.getSessionByUid(user1.getId()); + if (sessionByUid != null) { + ArenaInfoProto.ChampionGuessSuccessIndication build = ArenaInfoProto.ChampionGuessSuccessIndication.newBuilder().setItemId(arenaItem[0]).setItemNum(mineWinCoins).setRoundTimes(roundTimes).build(); + MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.CHAMPION_GUESS_SUCCESS_INDICATION_VALUE, build, true); } + ReportUtil.onReportEvent(user1, ReportEventEnum.GUESS_OVER.getType(), openTimeOfFuntionCacheByType.getTimes(), getSchedule() == 1 ? getRealTimes() : getRealTimes() + 7, winner.get() ? 1 : 2, mineWinCoins); }); ProtocolsManager.getInstance().updateAyncWorker(ayyncWorker); @@ -899,7 +859,6 @@ public class ChampionshipLogic { } - public static CommonProto.ChampionBetInfo getBetOdds() { String selectUid = getSelectIdForRedis(); ArenaRecord arenaRecord = RedisUtil.getInstence().getMapValue(RedisKey.CHAMPION_ARENA_RECORD, "", selectUid, ArenaRecord.class); @@ -916,21 +875,53 @@ public class ChampionshipLogic { return RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_CHOSE_TEAM_INFO, "", Integer.class, type); } + public static CommonProto.TeamOneInfo.Builder getUserTeam(int robotId) { + CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder(); + SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(robotId); + if (sArenaRobotConfig != null) { + builder = PlayerLogic.getInstance().getRobotTeamInfo(sArenaRobotConfig); + } else { + ChampionshipLogic.MemberInfo memberInfo = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_JOIN, "", Integer.toString(robotId), ChampionshipLogic.MemberInfo.class); + FamilyFightInfo fightInfo = memberInfo.getFightInfo(); + if (fightInfo == null) { + builder = PlayerLogic.getInstance().getUserTeamOneInfo(robotId, TeamEnum.CHAMPION_TEAM.getTeamId()); + } else { + //fix 整个过程都不能调整编队 + CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(robotId); + CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder(); + teamInfo.setTotalForce(fightInfo.getForce()); + + // int i = 1; + for (Map.Entry entry : fightInfo.getHeroAttribute().entrySet()) { + FamilyHeroInfo familyHeroInfo = entry.getValue(); + teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder() + .setHeroid(entry.getKey()) + .setHeroTid(familyHeroInfo.getTempleteId()) + .setStar(familyHeroInfo.getStar()) + .setLevel(familyHeroInfo.getLevel()) + .setPosition(familyHeroInfo.getPosition()) + .setGodSoulLv(familyHeroInfo.getGodSoulLv()) + .build() + ); + } + oneInfo.setTeam(teamInfo); + builder = oneInfo; + } + } + return builder; + } /** * 1.选出参战人员 人永远是进攻方 - * + *

* arenaRecordMap 所有战斗双方记录对象 * CHAMPION_ARENA_RECORD 当前所有战斗双方记录 * CHAMPION_CUR_JOIN_IDS 当前所有战斗双方记录的id * CHAMPION_JOIN 参加的成员 - * - * */ public static void selectToBattle() { RedisUtil.getInstence().del(RedisUtil.getInstence().getKey(RedisKey.CHAMPION_CUR_JOIN_IDS, "")); Map arenaRecordMap = new HashMap<>(); - List arenaRecordIds = new ArrayList<>(); if (schedule == 1) { List joinIndexs = STableManager.getFigureConfig(CommonStaticConfig.class).getMatrixforGroupInfo().get(roundTimes); Map joinMembers = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, MemberInfo.class); @@ -975,12 +966,12 @@ public class ChampionshipLogic { } }); } - Map memberPerOfTeam = new HashMap<>(); - finalmemberOfTeam.forEach((k, v) -> { - v.forEach(memberId -> { - memberPerOfTeam.put(memberId, k); - }); - }); +// Map memberPerOfTeam = new HashMap<>(); +// finalmemberOfTeam.forEach((k, v) -> { +// v.forEach(memberId -> { +// memberPerOfTeam.put(memberId, k); +// }); +// }); int times = 0; int length = possibleJoin.size(); if (length < 8) { @@ -994,12 +985,12 @@ public class ChampionshipLogic { int attackUid = memberInfoAttack.getUid(); int defUid = memberInfoDef.getUid(); int type = memberInfoAttack.getType() + memberInfoDef.getType(); - ArenaRecord arenaRecord = new ArenaRecord(); + ArenaRecord arenaRecord = new ArenaRecord(); arenaRecord.setId(KeyGenUtils.produceIdByModule(UUIDEnum.ARENARECORD, memberInfoAttack.getUid())); arenaRecord.setAttackId(attackUid); arenaRecord.setDefUid(defUid); arenaRecord.setType(type); - arenaRecord.setRoundTims(realTimes+7); + arenaRecord.setRoundTims(realTimes + 7); arenaRecord.setTurn(fightTime); if (realTimes > 2) { arenaRecord.setNums(times++); @@ -1007,7 +998,7 @@ public class ChampionshipLogic { arenaRecord.setNums(times++ % length); } arenaRecordMap.put(arenaRecord.getId(), arenaRecord); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } @@ -1016,7 +1007,7 @@ public class ChampionshipLogic { } RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", arenaRecordMap); - arenaRecordIds.addAll(arenaRecordMap.keySet()); + List arenaRecordIds = new ArrayList<>(arenaRecordMap.keySet()); RedisUtil.getInstence().lSet(RedisKey.CHAMPION_CUR_JOIN_IDS, "", arenaRecordIds); if (schedule == 2) { //记录4强 8强的人 方便索引 @@ -1032,15 +1023,10 @@ public class ChampionshipLogic { arenaRecordMap.forEach((id, arenaRecord) -> { int defUid = arenaRecord.getDefUid(); int attackId = arenaRecord.getAttackId(); - // if (!robotConfigMap.containsKey(defUid)) { - String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(defUid)); - RedisUtil.getInstence().lSet(key, id); - // } - // if (!robotConfigMap.containsKey(attackId)) { - String key2 = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(attackId)); - RedisUtil.getInstence().lSet(key2, id); - - // } + String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(defUid)); + RedisUtil.getInstence().lSet(key, id); + String key2 = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_MY_BATTLLE_IDS, Integer.toString(attackId)); + RedisUtil.getInstence().lSet(key2, id); }); } @@ -1132,7 +1118,7 @@ public class ChampionshipLogic { Map sendIds = new HashMap<>(); snapPlayFightInfo(false); - if (schedule == 2 && fightTime!=1) { + if (schedule == 2 && fightTime != 1) { return; } OnlineUserManager.sessionMap.values().forEach(session -> { @@ -1151,7 +1137,7 @@ public class ChampionshipLogic { int[][] reward = new int[1][]; int[] temp2 = new int[2]; temp2[0] = itemNum[0][0]; - temp2[1] = item == null ? itemNum[0][1] : itemNum[0][1] - (int)item.getItemNum(); + temp2[1] = item == null ? itemNum[0][1] : itemNum[0][1] - (int) item.getItemNum(); reward[0] = temp2; // fix 发放代币 只补充到阈值 ItemUtil.drop(user, reward, BIReason.CHAMPIION_BET_REWARD); @@ -1166,9 +1152,7 @@ public class ChampionshipLogic { } }); RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_GUESSS_UIDS, "", sendIds); - selectBetTeam(); - - + selectBetTeam(); } @@ -1240,10 +1224,10 @@ public class ChampionshipLogic { return; } Map joinMembers = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_JOIN, "", Integer.class, MemberInfo.class); - if(joinMembers.size()==0){ + if (joinMembers.size() == 0) { return; } - if(progress == -2){ + if (progress == -2) { return; } long now = TimeUtils.now(); @@ -1252,8 +1236,8 @@ public class ChampionshipLogic { int duration = sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime(); //fix 只有竞猜和战斗 int progressState = getProgress((int) ((now - startTime) / 1000 % duration + 1)); //阶段 long round = (now - startTime) / 1000 / duration + 1;//轮数 - if(round>30){ - progress=-2; + if (round > 30) { + progress = -2; //sendAllProgressUpdate(); return; } @@ -1267,13 +1251,13 @@ public class ChampionshipLogic { // progressState = progressState==1?2:progressState; progressTmp = 100 + roundTimes * 10 + progressState; setSchedule(1); - fightTime=2; + fightTime = 2; if (progressTmp == progress) { return; } } else {//决赛 - if (realTimes>5) { + if (realTimes > 5) { setSchedule(2); if (progress != -2) { progress = -2; @@ -1286,8 +1270,8 @@ public class ChampionshipLogic { if (schedule == 1) { // 刚开始进入决赛,选拔出选手 scoreToRedis(); - realTimes=1; - fightTime=0; + realTimes = 1; + fightTime = 0; setSchedule(2); selectToJoinFinal(); } @@ -1306,18 +1290,18 @@ public class ChampionshipLogic { if (progressState == 1) { //竞猜阶段 后台自动运行战斗 - if(schedule == 2 ){ - if(fightTime==2&&fightTime_temp==3){ - fightTime=3; + if (schedule == 2) { + if (fightTime == 2 && fightTime_temp == 3) { + fightTime = 3; scoreToRedis(); realTimes++; - fightTime=0; + fightTime = 0; return; } - if(fightTime==3){ + if (fightTime == 3) { scoreToRedis(); realTimes++; - fightTime=0; + fightTime = 0; return; } } @@ -1332,7 +1316,7 @@ public class ChampionshipLogic { } catch (Exception e) { e.printStackTrace(); } - },0, TimeUnit.MILLISECONDS); + }, 0, TimeUnit.MILLISECONDS); sendAllProgressUpdate(); } else if (progressState == 3) { //结算阶段 @@ -1346,7 +1330,7 @@ public class ChampionshipLogic { List ids = new ArrayList<>(curArenaRecordIds); List arenaRecords = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", ids, ArenaRecord.class); - while (!battleIsFinish(arenaRecords)) { + while (!battleIsFinish(arenaRecords)) { try { Thread.sleep(1000); arenaRecords = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", ids, ArenaRecord.class); @@ -1355,33 +1339,32 @@ public class ChampionshipLogic { } } - ChampionshipLogic.fightTime_temp=1; - if(ChampionshipLogic.schedule==2&&(ChampionshipLogic.fightTime==2||ChampionshipLogic.fightTime==3)){ - boolean isAllWin=true; + ChampionshipLogic.fightTime_temp = 1; + if (ChampionshipLogic.schedule == 2 && (ChampionshipLogic.fightTime == 2 || ChampionshipLogic.fightTime == 3)) { + boolean isAllWin = true; Map states = RedisUtil.getInstence().getMapValues(RedisKey.CHAMPION_ARENA_RECORD_THREE, "", String.class, Integer.class); - for (int i = 0; i 1){ - isAllWin=false; + if (state != null && state > 1) { + isAllWin = false; break; } } - if(isAllWin){ - ChampionshipLogic.fightTime_temp=3; + if (isAllWin) { + ChampionshipLogic.fightTime_temp = 3; } } - if (schedule == 2 && (fightTime !=3&&fightTime_temp!=3)) { - }else { + if (schedule == 2 && (fightTime != 3 && fightTime_temp != 3)) { + } else { sendBetReward(); } sendAllProgressUpdate(); } catch (Exception e) { e.printStackTrace(); } - },0, TimeUnit.MILLISECONDS); + }, 0, TimeUnit.MILLISECONDS); sendAllProgressUpdate(); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/UserManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/UserManager.java index 74bd00c03..90f550b17 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/UserManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/UserManager.java @@ -91,27 +91,27 @@ public class UserManager { } public static void userClear(){ - try { - Iterator> iterator = userMap.entrySet().iterator(); - while (iterator.hasNext()){ - Map.Entry next = iterator.next(); - Integer uid = next.getKey(); - if (OnlineUserManager.checkUidOnline(uid)){ - continue; - } - Integer count = userCount.getOrDefault(uid, 0); - if (count-- <= 0){ - MongoUtil.getLjsdMongoTemplate().lastUpdate(); - LOGGER.info("离线玩家{}被请求次数为{},剔除缓存",uid,count); - iterator.remove(); - removeUser(uid); - }else { - userCount.put(uid,count); - } - } - }catch (Exception e){ - LOGGER.error("userClear报错{}",e); - } +// try { +// Iterator> iterator = userMap.entrySet().iterator(); +// while (iterator.hasNext()){ +// Map.Entry next = iterator.next(); +// Integer uid = next.getKey(); +// if (OnlineUserManager.checkUidOnline(uid)){ +// continue; +// } +// Integer count = userCount.getOrDefault(uid, 0); +// if (count-- <= 0){ +// MongoUtil.getLjsdMongoTemplate().lastUpdate(); +// LOGGER.info("离线玩家{}被请求次数为{},剔除缓存",uid,count); +// iterator.remove(); +// removeUser(uid); +// }else { +// userCount.put(uid,count); +// } +// } +// }catch (Exception e){ +// LOGGER.error("userClear报错{}",e); +// } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java index d2adf8e67..981c143b2 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java @@ -543,7 +543,7 @@ public class PlayerLogic { } - public CommonProto.TeamOneInfo.Builder getUserTeamOneInfo(int uid,int teamId) throws Exception { + public CommonProto.TeamOneInfo.Builder getUserTeamOneInfo(int uid,int teamId) { User user = PlayerLogic.getInstance().getUserByRpc(uid); CommonProto.TeamOneInfo.Builder oneInfo = CBean2Proto.getTeamOneInfo(user); TeamPosManager teamPosManager = user.getTeamPosManager(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java index 3ad799385..c2ae58526 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java @@ -893,6 +893,22 @@ public class CBean2Proto { .setUserTitle(user.getPlayerInfoManager().getUserTitle()); } + public static CommonProto.TeamOneInfo.Builder getTeamOneInfo(int uid){ + CommonProto.TeamOneInfo.Builder builder = CommonProto.TeamOneInfo.newBuilder(); + CSPlayer player = CrossServiceLogic.getPlayerByRedis(uid); + if (player == null){ + return builder; + } + builder.setHead(player.getHead()) + .setHeadFrame(player.getHeadFrame()) + .setLevel(player.getLevel()) + .setName(player.getName()) + .setUid(player.getUserId()) + .setPracticeLevel(player.getPracticeLevel()) + .setUserTitle(player.getUserTitle()); + return builder; + } + public static CommonProto.FamilyBaseInfo getFamilyBaseInfo(GuildInfo guildInfo){ CommonProto.FamilyContribute familyContribute = CommonProto.FamilyContribute.newBuilder() .setWin(guildInfo.getResult(1))