private StringBuilder getLogMessage(RoleInstance role, RoleHero hero) throws Exception { StringBuilder sb = new StringBuilder(); // keyId# sb.append(role.getRoleId()).append(UNDERLINE_CAT).append(hero.getHeroId()).append(CAT); // 英雄的战斗力 sb.append(GameContext.getHeroApp().getBattleScore(hero)).append(CAT); sb.append(hero.getLevel()).append(CAT); sb.append(hero.getExp()).append(CAT); sb.append(getRoleCreatTimeStr(role)).append(CAT); sb.append(hero.getHeroId()).append(CAT); // 英雄的名字 String heroName = GameContext.getGoodsApp().getGoodsTemplate(GoodsHero.class, hero.getHeroId()).getName(); sb.append(heroName).append(CAT); sb.append(getRoleBaseInfo(role)); return sb; }
@Override public Message execute(ActionContext context, C1261_HeroExchangeListReqMessage reqMsg) { RoleInstance role = this.getCurrentRole(context); if (null == role) { return null; } List<Integer> heroIdList = GameContext.getHeroApp().getHeroExchangeList(); C1261_HeroExchangeListRespMessage respMsg = new C1261_HeroExchangeListRespMessage(); if (Util.isEmpty(heroIdList)) { return respMsg; } List<HeroExchangeGoodsItem> heroList = Lists.newArrayList(); for (int goodsId : heroIdList) { GoodsHero hero = GameContext.getGoodsApp().getGoodsTemplate(GoodsHero.class, goodsId); if (null == hero) { continue; } RoleHero roleHero = GameContext.getUserHeroApp().getRoleHero(role.getRoleId(), goodsId); if (null != roleHero) { // 用户已经拥有的 continue; } HeroExchangeGoodsItem item = new HeroExchangeGoodsItem(); item.setGoodsId(goodsId); item.setName(hero.getName()); item.setQuality(hero.getQualityType()); item.setImageId(hero.getImageId()); item.setShadowId(hero.getShadowId()); item.setNeedShadowNum((short) hero.getShadowNum()); item.setStar(hero.getBornStar()); heroList.add(item); } respMsg.setHeroList(heroList); return respMsg; }