Exemplo n.º 1
0
 /**
  * 获得道具全部属性,包含模板属性
  *
  * @return
  */
 public static AttriBuffer getAttriBuffer(RoleGoods roleGoods) {
   AttriBuffer buffer = AttriBuffer.createAttriBuffer();
   // 模板属性
   int goodsId = roleGoods.getGoodsId();
   GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(goodsId);
   if (goodsBase == null) {
     return buffer;
   }
   buffer.append(goodsBase.getAttriItemList());
   if (GoodsType.GoodsRune.getType() == goodsBase.getGoodsType()) {
     buffer.append(buildRandomAttri(roleGoods));
     return buffer;
   }
   if (!goodsBase.isEquipment()) {
     // 非装备
     return buffer;
   }
   buffer.append(
       GameContext.getEquipApp()
           .getBaseAttriBuffer(goodsId, roleGoods.getQuality(), roleGoods.getStar()));
   // 获得强化属性
   buffer.append(
       GameContext.getEquipApp()
           .getStrengthenAttriBuffer(
               goodsId,
               roleGoods.getQuality(),
               roleGoods.getStar(),
               roleGoods.getStrengthenLevel()));
   buffer.append(buildRandomAttri(roleGoods));
   // 获得镶嵌宝石属性
   buffer.append(getMosaicArrti(roleGoods));
   return buffer;
 }
Exemplo n.º 2
0
  @Override
  public void initLogData(RankInfo rankInfo) {
    List<RoleHero> roleHeroList =
        GameContext.getRankDAO()
            .selectHeroRole("campId", rankInfo.getSubType(), "limit", getRecordLimit(rankInfo));
    if (Util.isEmpty(roleHeroList)) {
      return;
    }
    for (RoleHero roleHero : roleHeroList) {
      if (null == roleHero) {
        continue;
      }

      RoleInstance role = GameContext.getRankDAO().selectRole("roleId", roleHero.getRoleId() + "");
      if (null == role) {
        continue;
      }
      try {
        StringBuilder sb = getLogMessage(role, roleHero);
        doWriteLogFile(rankInfo, false, null, sb.toString());
      } catch (Exception e) {
        continue;
      }
    }
  }
 @Override
 public Message execute(ActionContext context, C1209_SocialBlackListReqMessage reqMsg) {
   RoleInstance role = this.getCurrentRole(context);
   String selfRoleId = role.getRoleId();
   List<SocialBlackItem> blackList = new ArrayList<SocialBlackItem>();
   for (RoleSocialRelation relation : GameContext.getSocialApp().getBlackList(role)) {
     if (null == relation) {
       continue;
     }
     SocialBlackItem item = new SocialBlackItem();
     String otherRoleId = relation.getOtherRoleId(selfRoleId);
     item.setRoleId(Integer.valueOf(otherRoleId));
     item.setRoleName(relation.getRoleName(otherRoleId));
     item.setSex(relation.getSex(otherRoleId));
     item.setCamp(relation.getCamp(otherRoleId));
     item.setCareer(relation.getCareer(otherRoleId));
     RoleInstance otherRole = GameContext.getOnlineCenter().getRoleInstanceByRoleId(otherRoleId);
     if (null != otherRole) {
       item.setRoleLevel((byte) otherRole.getLevel());
       // 角色名从在线角色上取
       item.setRoleName(otherRole.getRoleName());
       item.setOnline((byte) 1);
     }
     blackList.add(item);
   }
   this.sortFriendList(blackList);
   C1209_SocialBlackListRespMessage resp = new C1209_SocialBlackListRespMessage();
   resp.setBlackList(blackList);
   return resp;
 }
 @Override
 public Message execute(ActionContext context, C1753_QualifyChallengeReqMessage reqMsg) {
   RoleInstance role = this.getCurrentRole(context);
   if (null == role) {
     return null;
   }
   String[] infos = this.getHeroInfos(reqMsg.getInfo());
   if (null == infos || infos.length < INFO_LENGTH) {
     C0002_ErrorRespMessage message = new C0002_ErrorRespMessage();
     message.setInfo(GameContext.getI18n().getText(TextId.ERROR_INPUT));
     return message;
   }
   Result result =
       GameContext.getQualifyApp().qualifyChallenge(role, infos[0], this.isConfirm(infos[1]));
   if (result.isIgnore()) {
     return null;
   }
   if (!result.isSuccess()) {
     C0002_ErrorRespMessage message = new C0002_ErrorRespMessage();
     message.setInfo(result.getInfo());
     return message;
   }
   C0003_TipNotifyMessage message = new C0003_TipNotifyMessage();
   message.setMsgContext(result.getInfo());
   return message;
 }
Exemplo n.º 5
0
  @Override
  public C3863_Arena3V3DetailRespMessage getArena3V3DetailRespMessage(RoleInstance role) {
    C3863_Arena3V3DetailRespMessage resp = new C3863_Arena3V3DetailRespMessage();
    ArenaType arenaType = ArenaType._3V3;
    if (this.isOpenDarkDoor) {
      arenaType = ArenaType._3V3_DARK_DOOR;
    }
    ArenaConfig config = GameContext.getArenaApp().getArenaConfig(arenaType);
    if (null == config) {
      return null;
    }
    Reward3V3Config lastReward =
        this.getReward3V3Config(role.getRoleArena().getLastArenaLevel3v3());
    if (null == lastReward) {
      return null;
    }
    RoleArena roleArena = role.getRoleArena();
    if (null == roleArena) {
      return null;
    }
    float currentArenaLevel3v3 = roleArena.getArenaLevel3v3();
    Reward3V3Config currentReward = this.getReward3V3Config(currentArenaLevel3v3);
    if (null == currentReward) {
      return null;
    }
    resp.setActiveId(config.getActiveId());
    resp.setCurrentArenaLevel3v3((int) currentArenaLevel3v3);
    resp.setCurrentArenaLevel3v3Name(currentReward.getName());

    Reward3V3Config nextReward = this.getNextReward3V3Config(currentArenaLevel3v3);
    resp.setNextArenaLevel3v3(nextReward.getArenaMinLevel());
    resp.setNextArenaLevel3v3Name(nextReward.getName());

    resp.setCycle3v3Score(roleArena.getCycle3v3Score());
    resp.setMaxCycle3v3Score(lastReward.getMaxCycleScore());
    resp.setWin(roleArena.getCycleWin3v3());
    resp.setFail(roleArena.getCycleFail3v3());
    resp.setArenaScore(role.getArena3v3Score());
    resp.setMaxArenaScore(lastReward.getMaxRoleScore());
    resp.setDesc(config.getDesc());
    // 兑换参数
    resp.setExchangeParam(config.getExchangeMenuId());
    ApplyInfo info = GameContext.getArenaApp().getApplyInfo(role.getRoleId());
    if (null == info) {
      return resp;
    }
    Team team = role.getTeam();
    if (team == null || team.isLeader(role)) {
      resp.setArenaType(ApplyState.had_apply.getType());
    } else {
      resp.setArenaType((byte) 2);
    }
    Date applyDate = new Date(info.getCreateDate());
    resp.setTime(DateUtil.dateDiffSecond(applyDate, new Date()));
    return resp;
  }
Exemplo n.º 6
0
 public static int getEquipScore(RoleGoods roleGoods) {
   GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
   if (null == goodsBase || !goodsBase.isEquipment()) {
     return 0;
   }
   AttriBuffer buffer = getAttriBuffer(roleGoods);
   if (null == buffer || buffer.isEmpty()) {
     return 0;
   }
   return GameContext.getAttriApp().getAttriBattleScore(buffer);
 }
Exemplo n.º 7
0
  public GoodsBaseItem getGoodsBaseInfo(RoleGoods roleGoods) {
    GoodsBaseEquItem item = new GoodsBaseEquItem();
    this.setGoodsBaseItem(roleGoods, item);
    item.setStar(this.star);
    item.setSecondType(this.secondType);
    item.setStrengthenLevel((byte) 0);
    item.setMaxStrengthenLevel((byte) this.maxStrengthenLevel);
    item.setQualityType(this.getQualityType());
    item.setLvLimit((byte) this.getLvLimit());
    item.setDesc(this.getDesc());
    item.setActivateType(this.getActivateType());
    item.setResId((short) this.getResId());
    item.setDeadline(this.getDeadline());
    item.setSex((byte) this.getSex());
    item.setExpireType(this.getExpireType());
    item.setMaxAttriNum((byte) this.attriNum);
    // 装备评分
    item.setGs(this.calculateScore(roleGoods));
    // 基本属性+强化属性
    item.setBaseAttriItem(GameContext.getEquipApp().getBaseAttriItem(roleGoods, this));
    if (null == roleGoods) {
      // 装备模板信息
      return item;
    }
    item.setQualityType(roleGoods.getQuality());
    item.setStar(roleGoods.getStar());
    // 实例存在
    if (!Util.isEmpty(roleGoods.getExpiredTime())) {
      item.setExpiredTime(DateUtil.getMinFormat(roleGoods.getExpiredTime()));
    }
    if (roleGoods.getDeadline() > 0) {
      item.setDeadline(roleGoods.getDeadline());
    }
    item.setExpired((byte) (RoleGoodsHelper.isExpired(roleGoods) ? 1 : 0));
    item.setStrengthenLevel((byte) roleGoods.getStrengthenLevel());

    // 获得衍生属性
    item.setDerivativeItems(this.getRecatingAttriList(roleGoods));
    // 镶嵌 相关
    // 装备开启孔位
    item.setMaxHole(GameContext.getEquipApp().getEquipMaxHole(roleGoods));
    // 装备镶嵌的符文
    List<GoodsEquRuneItem> runeItems = this.getMosaicItem(roleGoods);
    if (!Util.isEmpty(runeItems)) {
      item.setRuneItems(runeItems);
    }
    // 设置英雄id
    if (StorageType.hero.getType() == roleGoods.getStorageType()) {
      item.setHeroId(Integer.parseInt(roleGoods.getOtherParm()));
    }
    return item;
  }
Exemplo n.º 8
0
 private void sendGoodsByMail(
     RoleInstance role, List<GoodsOperateBean> addList, OutputConsumeType ocType) {
   String title = GameContext.getI18n().getText(TextId.FALL_MAIL_TITLE);
   String content = GameContext.getI18n().getText(TextId.FALL_MAIL_CONTENT);
   GameContext.getMailApp()
       .sendMail(
           role.getRoleId(),
           title,
           content,
           MailSendRoleType.System.getName(),
           ocType.getType(),
           addList);
 }
Exemplo n.º 9
0
 @Override
 public Message execute(ActionContext context, C2349_TitleDetailReqMessage reqMsg) {
   RoleInstance role = this.getCurrentRole(context);
   if (null == role) {
     return null;
   }
   int titleId = reqMsg.getTitleId();
   GoodsTitle title = GameContext.getGoodsApp().getGoodsTemplate(GoodsTitle.class, titleId);
   if (null == title) {
     return new C0002_ErrorRespMessage(reqMsg.getCommandId(), Status.Title_Goods_Null.getTips());
   }
   TitleRecord roleTitle = GameContext.getTitleApp().getRoleTitle(role, titleId);
   C2349_TitleDetailRespMessage respMsg = new C2349_TitleDetailRespMessage();
   TitleWearingItem wearingItem = Converter.getTitleWearingItem(title);
   respMsg.setItem(wearingItem);
   respMsg.setDesc(title.getDesc());
   respMsg.setPay(title.getPay());
   respMsg.setForever(title.isForever() ? (byte) 1 : (byte) 0);
   List<AttriTypeStrValueItem> attrList = new ArrayList<AttriTypeStrValueItem>();
   for (AttriItem ai : title.getAttriItemList()) {
     if (null == ai) {
       continue;
     }
     int value = (int) ai.getValue();
     if (value > 0) {
       AttriTypeStrValueItem item = new AttriTypeStrValueItem();
       item.setType(ai.getAttriTypeValue());
       item.setValue(String.valueOf(value));
       attrList.add(item);
     }
     value = (int) (ai.getPrecValue() * 100);
     if (value > 0) {
       AttriTypeStrValueItem item = new AttriTypeStrValueItem();
       item.setType(ai.getAttriTypeValue());
       item.setValue(value + "%");
       attrList.add(item);
     }
   }
   respMsg.setAttrList(attrList);
   if (null == roleTitle) {
     respMsg.setStatus(TitleStatus.Lack.getType());
     return respMsg;
   }
   respMsg.setStatus(roleTitle.getActivateState());
   respMsg.setExpired(roleTitle.isTimeout() ? (byte) 1 : (byte) 0);
   respMsg.setExpiredTime(roleTitle.getStrDueTime());
   return respMsg;
 }
Exemplo n.º 10
0
 private List<GoodsDerivativeAttriItem> getRecatingAttriList(RoleGoods roleGoods) {
   if (Util.isEmpty(roleGoods.getAttrVarList())) {
     return null;
   }
   int quality = this.getQualityType();
   int star = this.star;
   if (null != roleGoods) {
     quality = roleGoods.getQuality();
     star = roleGoods.getStar();
   }
   List<GoodsDerivativeAttriItem> derivativeItems = new ArrayList<GoodsDerivativeAttriItem>();
   for (AttriItem ai : roleGoods.getAttrVarList()) {
     if (null == ai) {
       continue;
     }
     byte attriType = ai.getAttriTypeValue();
     EquipRecatingAttrWeightConfig awc =
         GameContext.getGoodsApp().getEquipRecatingAttrWeightConfig(attriType, quality, star);
     if (null == awc) {
       continue;
     }
     int value = (int) ai.getValue();
     RecatingBoundBean bean = awc.getRecatingBoundBean(value);
     if (null == bean) {
       continue;
     }
     GoodsDerivativeAttriItem rii = new GoodsDerivativeAttriItem();
     rii.setType(attriType);
     rii.setValue(value);
     rii.setQuality((byte) bean.getQualityType());
     derivativeItems.add(rii);
   }
   return derivativeItems;
 }
Exemplo n.º 11
0
 /** 永久物品 */
 public static boolean isForever(RoleGoods roleGoods) {
   GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
   if (null == gb) {
     return false;
   }
   return gb.getDeadline() == 0;
 }
Exemplo n.º 12
0
 /**
  * 下线是否消失
  *
  * @return
  */
 public static boolean isOfflineDie(RoleGoods roleGoods) {
   GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
   if (goodsBase == null) {
     return false;
   }
   return goodsBase.hasOfflineDie();
 }
 @Override
 public Message execute(ActionContext context, C1008_MailTruePickReqMessage req) {
   C1003_MailAccessoryRespMessage resp = new C1003_MailAccessoryRespMessage();
   resp.setType(Status.FAILURE.getInnerCode());
   try {
     RoleInstance role = this.getCurrentRole(context);
     if (role == null) {
       return null;
     }
     String params = req.getParams();
     String mailId = params.split(Cat.comma)[1];
     resp.setMailId(mailId);
     Result result = GameContext.getMailApp().pickTrueMailAccessory(role, params);
     if (result.isIgnore()) {
       return null;
     }
     if (!result.isSuccess()) {
       resp.setInfo(result.getInfo());
       return resp;
     }
     resp.setType(Status.SUCCESS.getInnerCode());
     resp.setInfo(Status.Mail_Goods_Success.getTips());
   } catch (Exception e) {
     logger.error("MailTrueAccessoryAction", e);
   }
   return resp;
 }
Exemplo n.º 14
0
 private void loadBuffConfig() {
   // 加载擂台赛配置
   String fileName = XlsSheetNameType.arena_buff_config.getXlsName();
   String sheetName = XlsSheetNameType.arena_buff_config.getSheetName();
   try {
     String sourceFile = GameContext.getPathConfig().getXlsPath() + fileName;
     List<ArenaBuffConfig> list =
         XlsPojoUtil.sheetToList(sourceFile, sheetName, ArenaBuffConfig.class);
     if (Util.isEmpty(list)) {
       return;
     }
     for (ArenaBuffConfig config : list) {
       if (null == config) {
         continue;
       }
       int arenaType = config.getArenaType();
       if (!buffConfigMap.containsKey(arenaType)) {
         buffConfigMap.put(arenaType, new ArrayList<ArenaBuffConfig>());
       }
       buffConfigMap.get(arenaType).add(config);
     }
   } catch (Exception ex) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "loadExel error : sourceFile = " + fileName + " sheetName =" + sheetName, ex);
   }
 }
Exemplo n.º 15
0
  // 容错过期时间(单写一方法在此调用)
  public static void checkGoodsExpiredTime(RoleGoods roleGoods) {
    try {
      GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
      if (null == goodsBase) {
        return;
      }
      if (goodsBase.isForever()) {
        return;
      }

      int bagType = roleGoods.getStorageType();
      boolean on = bagType == StorageType.hero.getType();

      boolean mustActive =
          (goodsBase.getActivateType() == 1) || (goodsBase.getActivateType() == 0 && on);
      if (mustActive) {
        if (!Util.isEmpty(roleGoods.getExpiredTime())) {
          return;
        }
        Date endDate = DateUtil.add(new Date(), Calendar.MINUTE, goodsBase.getDeadline());
        roleGoods.setExpiredTime(endDate);
        return;
      }
      if (roleGoods.getDeadline() > 0) {
        return;
      }
      roleGoods.setDeadline(goodsBase.getDeadline());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 16
0
 /**
  * 统计洗练属性品质>=quality的个数
  *
  * @param roleGoods
  * @param quality
  * @return
  */
 public static int countRecastingAttribute(RoleGoods roleGoods, int quality) {
   int total = 0;
   for (AttriItem ai : roleGoods.getAttrVarList()) {
     if (null == ai) {
       continue;
     }
     byte attriType = ai.getAttriTypeValue();
     EquipRecatingAttrWeightConfig awc =
         GameContext.getGoodsApp()
             .getEquipRecatingAttrWeightConfig(
                 attriType, roleGoods.getQuality(), roleGoods.getStar());
     if (null == awc) {
       continue;
     }
     int value = (int) ai.getValue();
     RecatingBoundBean bean = awc.getRecatingBoundBean(value);
     if (null == bean) {
       continue;
     }
     if (bean.getQualityType() < quality) {
       continue;
     }
     total++;
   }
   return total;
 }
Exemplo n.º 17
0
 public static GoodsEquipment getGoodsEquipment(RoleGoods roleGoods) {
   GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
   if (null == gb || !(gb instanceof GoodsEquipment)) {
     return null;
   }
   return (GoodsEquipment) gb;
 }
Exemplo n.º 18
0
 /**
  * 获取镶嵌的item
  *
  * @param roleGoods
  * @return
  */
 private List<GoodsEquRuneItem> getMosaicItem(RoleGoods roleGoods) {
   // 获得宝石镶嵌属性
   MosaicRune[] runes = roleGoods.getMosaicRune();
   if (null == runes || runes.length <= 0) {
     return null;
   }
   List<GoodsEquRuneItem> runeItemList = new ArrayList<GoodsEquRuneItem>();
   for (int index = 0; index < runes.length; index++) {
     MosaicRune rune = runes[index];
     if (null == rune) {
       continue;
     }
     int runeId = rune.getGoodsId();
     GoodsRune gb = GameContext.getGoodsApp().getGoodsTemplate(GoodsRune.class, runeId);
     if (null == gb) {
       continue;
     }
     GoodsEquRuneItem runeItem = new GoodsEquRuneItem();
     runeItem.setHole(rune.getHole());
     runeItem.setGoodsLiteItem(rune.getGoodsLiteItem());
     runeItem.setRuneName(gb.getName());
     runeItem.setAttriItems(rune.getAttriStrValueList());
     runeItemList.add(runeItem);
   }
   return runeItemList;
 }
Exemplo n.º 19
0
 private void notifyPass() {
   String passTips = this.copyLineConfig.getPassTips();
   if (!Util.isEmpty(passTips)) {
     GameContext.getChatApp()
         .sendSysMessage(ChatSysName.System, ChannelType.Map, passTips, null, this);
   }
 }
Exemplo n.º 20
0
 /** 初始化状态的逻辑 找到刷怪规则,切换到刷怪状态 */
 private void do_mapState_init() {
   RoleInstance role = this.getFirstRole();
   if (null == role) {
     return;
   }
   CopyMapRoleRule rule =
       GameContext.getCopyLogicApp().getCopyMapRoleRule(role, this.map.getMapId());
   // 如果没有找到合适的规则,有可能是地图里种怪了
   if (null != rule) {
     this.ruleId = rule.getRuleId();
     this.ruleMaxSize =
         GameContext.getRefreshRuleApp().getRefreshMax(Integer.parseInt(this.ruleId));
   }
   // 必须切换到刷怪状态,里面会发副本倒计时
   this.change_mapState_init_to_refresh();
 }
Exemplo n.º 21
0
 @Override
 public Message execute(ActionContext arg0, C10030_MailRecoupListReqMessage reqMsg) {
   C10030_MailRecoupListRespMessage resp = new C10030_MailRecoupListRespMessage();
   Collection<Recoup> collection = GameContext.getRecoupApp().getAllRecoup();
   if (Util.isEmpty(collection)) {
     return resp;
   }
   List<MailRecoupItem> recoupList = new ArrayList<MailRecoupItem>();
   for (Recoup recoup : collection) {
     if (null == recoup) {
       continue;
     }
     MailRecoupItem item = new MailRecoupItem();
     item.setId(recoup.getId());
     item.setSenderName(recoup.getSenderName());
     item.setTitle(recoup.getTitle());
     item.setContent(recoup.getContext());
     item.setBindMoney(recoup.getBindMoney());
     item.setSilverMoney(recoup.getGameMoney());
     item.setGoodsInfo(recoup.getGoodsInfo());
     item.setStartTime(recoup.getStartTime());
     item.setEndTime(recoup.getEndTime());
     recoupList.add(item);
   }
   resp.setRecoupList(recoupList);
   return resp;
 }
Exemplo n.º 22
0
 private BindingType getBindingType(int goodsId, int bindType) {
   if (bindType == DEF_BIND_TYPE) {
     GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(goodsId);
     return gb.getBindingType();
   }
   return BindingType.get(bindType);
 }
Exemplo n.º 23
0
  @Override
  public Message execute(ActionContext context, C0540_GoodsStrengthenReqMessage reqMsg) {
    C0540_GoodsStrengthenRespMessage resp = new C0540_GoodsStrengthenRespMessage();
    resp.setStatus(RespTypeStatus.FAILURE);
    try {
      RoleInstance role = this.getCurrentRole(context);
      if (null == role) {
        return null;
      }

      byte positionType = reqMsg.getPositionType();
      String instanceId = reqMsg.getInstanceId();
      int targetId = reqMsg.getTargetId();

      StorageType storageType = StorageType.get(positionType);
      RoleGoods equipGoods =
          GameContext.getUserGoodsApp().getRoleGoods(role, storageType, instanceId, targetId);
      if (equipGoods == null) {
        resp.setInfo(this.getText(TextId.NO_GOODS));
        return resp;
      }

      GoodsType goodsType = GameContext.getGoodsApp().getGoodsType(equipGoods.getGoodsId());
      AbstractGoodsBehavior goodsBehavior =
          goodsType.getGoodsBehavior(GoodsBehaviorType.Strengthen);

      StrengthenParam param = new StrengthenParam(role);
      param.setEquipGoods(equipGoods);
      param.setOperateType(StrengthenParam.STRENGTHEN_INFO);
      param.setTargetId(targetId);

      Result result = goodsBehavior.operate(param);
      if (!result.isSuccess()) {
        resp.setInfo(result.getInfo());
        return resp;
      }

      StrengthenResult stResult = (StrengthenResult) result;
      // 构建-540
      return this.buildStrengthenRespMesage(role, equipGoods, stResult.getGoodsTemplate());
    } catch (Exception e) {
      logger.error("GoodsDeriveStrengthenAction ", e);
      resp.setStatus(RespTypeStatus.FAILURE);
      resp.setInfo(this.getText(TextId.SYSTEM_ERROR));
    }
    return resp;
  }
 @Override
 public Message execute(ActionContext context, C0270_CopyLineCurrPanelReqMessage reqMsg) {
   RoleInstance role = this.getCurrentRole(context);
   if (role == null) {
     return null;
   }
   return GameContext.getCopyLineApp().getCopyLinePanelRespMessage(role, (byte) 0);
 }
Exemplo n.º 25
0
 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;
 }
Exemplo n.º 26
0
 /**
  * 获得任务掉落
  *
  * @param npcTemplateId
  * @param role
  * @return
  */
 private List<GoodsOperateBean> getQuestLootList(String npcTemplateId, RoleInstance role) {
   try {
     return GameContext.getUserQuestApp().getQuestFall(role, npcTemplateId);
   } catch (Exception e) {
     logger.error("", e);
     return null;
   }
 }
Exemplo n.º 27
0
 @Override
 public boolean canEnter(AbstractRole role) {
   if (role instanceof RoleInstance) {
     Result result = GameContext.getCopyLineApp().canEnter((RoleInstance) role, this.copyId);
     return result.isSuccess();
   }
   return false;
 }
Exemplo n.º 28
0
  @Override
  public Message execute(ActionContext context, C2341_TitleListSelfReqMessage reqMsg) {
    RoleInstance role = this.getCurrentRole(context);
    if (null == role) {
      return null;
    }
    C2341_TitleListSelfRespMessage respMsg = new C2341_TitleListSelfRespMessage();
    Map<Integer, TitleRecord> titleMap = role.getTitleMap();
    if (Util.isEmpty(titleMap)) {
      return respMsg;
    }
    int titleNum = titleMap.size();

    Map<Integer, TitleCategory> categoryMap = GameContext.getTitleApp().getTitleCategoryMap();
    if (Util.isEmpty(categoryMap)) {
      return respMsg;
    }

    int titleNowNum = 0;
    List<TitleCategoryItem> itemList = new ArrayList<TitleCategoryItem>();
    for (TitleCategory c : categoryMap.values()) {
      List<GoodsTitle> titleList = c.getTitleList();
      if (Util.isEmpty(titleList)) {
        continue;
      }
      TitleCategoryItem citem = null;
      for (GoodsTitle title : titleList) {
        int titleId = title.getId();
        TitleRecord record = titleMap.get(titleId);
        if (null == record) {
          continue;
        }
        if (null == citem) {
          citem = new TitleCategoryItem();
          citem.setCategoryName(c.getCategoryName());
        }
        TitleItem titleItem = new TitleItem();
        titleItem.setTitleId(titleId);
        titleItem.setTitleName(title.getName());
        titleItem.setStatus(record.getActivateState());
        citem.getTitles().add(titleItem);
        titleNowNum++;
        // 提前结束循环
        if (titleNowNum >= titleNum) {
          break;
        }
      }
      if (null != citem) {
        itemList.add(citem);
      }
      // 提前结束循环
      if (titleNowNum >= titleNum) {
        break;
      }
    }
    respMsg.setItemList(itemList);
    return respMsg;
  }
Exemplo n.º 29
0
 private void checkGoods(int goodsId) {
   // 验证物品ID是否存在
   GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(goodsId);
   if (null == gb) {
     Log4jManager.CHECK.error(
         "goods not exist(GoodsBox),goodsId=" + goodsId + " goodsBoxId=" + this.id);
     Log4jManager.checkFail();
   }
 }
Exemplo n.º 30
0
 public static int getEquipLocation(RoleGoods roleGoods) {
   int goodsId = roleGoods.getGoodsId();
   GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(goodsId);
   if (goodsBase instanceof GoodsEquipment) {
     GoodsEquipment equipment = (GoodsEquipment) goodsBase;
     return equipment.getEquipslotType();
   }
   return -1;
 }