From 2c21b1e9c4557a61f407b46eac3d79cd70ade3cd Mon Sep 17 00:00:00 2001 From: wangyuan Date: Thu, 7 Nov 2019 12:04:29 +0800 Subject: [PATCH] robot hero info --- .../jieling/logic/player/PlayerLogic.java | 64 ++++++++++++++++++- .../com/ljsd/jieling/util/CBean2Proto.java | 15 ++++- 2 files changed, 74 insertions(+), 5 deletions(-) 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 5fc9f9af2..9afe92a63 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 @@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.player; import com.ljsd.GameApplication; import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig; +import com.ljsd.jieling.config.clazzStaticCfg.SArenaRobotStaticConfig; import com.ljsd.jieling.config.clazzStaticCfg.TaskStaticConfig; import com.ljsd.jieling.core.VipPrivilegeType; import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType; @@ -437,14 +438,47 @@ public class PlayerLogic { } } + + public void getRobotTeamInfo(ISession session, SArenaRobotConfig sArenaRobotConfig, MessageTypeProto.MessageType messageType){ + CommonProto.TeamOneInfo.Builder oneInfo = CommonProto.TeamOneInfo.newBuilder() + .setLevel(sArenaRobotConfig.getRobotLevel()) + .setName(sArenaRobotConfig.getRobotName()) + .setUid(sArenaRobotConfig.getId()); + + CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder(); + if(sArenaRobotConfig.getDifferDemonsId()!=null){ + for(int pokenId:sArenaRobotConfig.getDifferDemonsId()){ + teamInfo.addPokemonInfos(pokenId); + } + } + teamInfo.setTotalForce(sArenaRobotConfig.getTotalForce()); + for(Map.Entry item : sArenaRobotConfig.getStarOfHeroMap().entrySet()){ + Integer heroTid = item.getKey(); + Integer heroStar = item.getValue(); + teamInfo.addTeam(CommonProto.TeamSimpleInfo.newBuilder().setHeroid(String.valueOf(heroTid)).setHeroTid(heroTid).setLevel(sArenaRobotConfig.getRobotLevel()).setStar(heroStar).build()); + } + oneInfo.setTeam(teamInfo); + + PlayerInfoProto.GetPlayerOneTeamInfoResponse.Builder playerTeamInfo = PlayerInfoProto.GetPlayerOneTeamInfoResponse.newBuilder().setTeamInfo(oneInfo); + + MessageUtil.sendMessage(session,1,messageType.getNumber(),playerTeamInfo.build(),true); + + } + public void getOneTeamInfo(ISession session, int id,int teamId,MessageTypeProto.MessageType messageType) throws Exception { + + SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(id); + if(sArenaRobotConfig!=null){ + getRobotTeamInfo(session,sArenaRobotConfig,messageType); + return; + } User user = UserManager.getUser(id); PlayerManager playerManager = user.getPlayerInfoManager(); CommonProto.TeamOneInfo.Builder oneInfo = CommonProto.TeamOneInfo.newBuilder() .setHead(playerManager.getHead()) .setHeadFrame(playerManager.getHeadFrame()) .setLevel(playerManager.getLevel()) - .setName(playerManager.getNickName()).setUid(session.getUid()); + .setName(playerManager.getNickName()).setUid(id); TeamPosManager teamPosManager = user.getTeamPosManager(); CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder(); teamInfo.setTotalForce(HeroLogic.getInstance().calTeamTotalForce(user,teamId,false)); @@ -477,11 +511,37 @@ public class PlayerLogic { } + private void viewRobotHeroInfo(ISession session, SArenaRobotConfig sArenaRobotConfig,String robotHeroId) throws Exception { + PlayerInfoProto.ViewHeroInfoResponse.Builder builder = PlayerInfoProto.ViewHeroInfoResponse.newBuilder(); + + int[] differDemonsId = sArenaRobotConfig.getDifferDemonsId(); + int differDemonsLv = sArenaRobotConfig.getDifferDemonsLv(); + int heroLevel = sArenaRobotConfig.getRoleLv(); + int heroBreakId = sArenaRobotConfig.getBreakId(); + + SCHero scHero = SCHero.getsCHero().get(Integer.parseInt(robotHeroId)); + Map robotHeroAttribute = HeroLogic.getInstance().calRobotHeroAttribute(scHero, heroLevel, heroBreakId, differDemonsId, differDemonsLv,true); + + for(Map.Entry item : robotHeroAttribute.entrySet()){ + builder.addSpecialEffects(CommonProto.SpecialEffects.newBuilder().setPropertyId(item.getKey()).setPropertyValue(item.getValue()).build()); + } + builder.setForce(HeroLogic.getInstance().calForce(robotHeroAttribute)); + builder.setHero(CBean2Proto.getRobotHero(scHero,sArenaRobotConfig)); + + int resMsgId = MessageTypeProto.MessageType.VIEW_HERO_INFO_RESPONSE_VALUE; + MessageUtil.sendMessage(session,1,resMsgId,builder.build(),true); + } + public void viewHeroInfo(ISession session,int uid,String heroId) throws Exception { + SArenaRobotConfig sArenaRobotConfig = SArenaRobotConfig.getsArenaRobotConfigById(uid); + if(sArenaRobotConfig!=null){ + viewRobotHeroInfo(session,sArenaRobotConfig,heroId); + return; + } User userInMem = UserManager.getUserInMem(uid); int resMsgId = MessageTypeProto.MessageType.VIEW_HERO_INFO_RESPONSE_VALUE; if(userInMem == null){ - throw new ErrorCodeException(ErrorCode.UNLOCK_SKIP_FIGHT); + throw new ErrorCodeException(ErrorCode.FRIENDS_USER_NULL); } Hero hero = userInMem.getHeroManager().getHeroMap().get(heroId); if(hero == null){ 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 6f8687a18..8812fbc9a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java @@ -15,9 +15,7 @@ import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.fight.CombatLogic; import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.protocols.*; -import config.SMainLevelConfig; -import config.SMonsterConfig; -import config.SSpecialConfig; +import config.*; import manager.STableManager; import util.StringUtil; import util.TimeUtils; @@ -107,6 +105,17 @@ public class CBean2Proto { .build(); } + public static CommonProto.Hero getRobotHero(SCHero scHero, SArenaRobotConfig sArenaRobotConfig) throws Exception { + return CommonProto.Hero + .newBuilder() + .setId(String.valueOf(scHero.getId())) + .setHeroId(scHero.getId()) + .setLevel(sArenaRobotConfig.getRoleLv()) + .setStar(scHero.getStar()) + .setBreakId(sArenaRobotConfig.getBreakId()) + .build(); + } + public static CommonProto.Mail getMail(Mail mail){ CommonProto.Mail.Builder mailProto = CommonProto.Mail .newBuilder()