예제 #1
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;
 }
예제 #2
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();
    }
  }
예제 #3
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;
 }
예제 #4
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;
 }
예제 #5
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;
 }
예제 #6
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;
 }
예제 #7
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);
 }
예제 #8
0
 /** 永久物品 */
 public static boolean isForever(RoleGoods roleGoods) {
   GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
   if (null == gb) {
     return false;
   }
   return gb.getDeadline() == 0;
 }
예제 #9
0
 /**
  * 下线是否消失
  *
  * @return
  */
 public static boolean isOfflineDie(RoleGoods roleGoods) {
   GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
   if (goodsBase == null) {
     return false;
   }
   return goodsBase.hasOfflineDie();
 }
예제 #10
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;
 }
예제 #11
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();
   }
 }
예제 #12
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);
 }
예제 #13
0
 /** 过期删除物品 */
 public static boolean isExpiredDel(RoleGoods roleGoods) {
   try {
     GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
     if (null == gb) {
       return false;
     }
     return gb.getExpireType() == 1;
   } catch (Exception e) {
     logger.error("RoleGoodsHelper.isExpiredDel:", e);
   }
   return false;
 }
예제 #14
0
 private void addItemData(int itemId, int num, int weight, int bindType) {
   if (weight <= 0 || itemId <= 0 || num <= 0) {
     return;
   }
   GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(itemId);
   if (null == gb) {
     Log4jManager.CHECK.error(
         "LootGroup config error,goods not exist,groupId=" + this.groupId + " goodsId=" + itemId);
     Log4jManager.checkFail();
   }
   BindingType bt = this.getBindingType(itemId, bindType);
   this.groupList.add(new ItemData(itemId, num, weight, bt.getType()));
 }
예제 #15
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;
 }
  @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;
  }
예제 #17
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;
 }
  private C0540_GoodsStrengthenRespMessage buildStrengthenRespMesage(
      RoleInstance role, RoleGoods equRG, GoodsEquipment goodsTemplate) {
    C0540_GoodsStrengthenRespMessage respMsg = new C0540_GoodsStrengthenRespMessage();
    respMsg.setStatus(RespTypeStatus.FAILURE);
    try {
      int targetStrengThenNum = equRG.getStrengthenLevel() + 1;
      // int qualityType = goodsTemplate.getQualityType();
      EquipStrengthenConfig strengthenObj =
          GameContext.getGoodsApp().getEquipStrengthenConfig(targetStrengThenNum);
      if (null == strengthenObj) {
        respMsg.setStatus(RespTypeStatus.FAILURE);
        respMsg.setInfo(GameContext.getI18n().getText(TextId.GOODS_MAX_STRENGTHEN_LV));
        return respMsg;
      }
      respMsg.setFee(strengthenObj.getGameMoney());
      // respMsg.setMaxRelegation((byte)strengthenObj.getMaxRelegation());

      if (strengthenObj.getMaterialId() > 0) {
        GoodsLiteNamedItem mitem = strengthenObj.getMaterialGoods().getGoodsLiteNamedItem();
        mitem.setNum((short) strengthenObj.getMaterialNum());
        respMsg.setMaterialItem(mitem);
      }
      /*if(strengthenObj.getStoneId()>0){
      	GoodsLiteNamedItem sitem = strengthenObj.getStoneGoods().getGoodsLiteNamedItem();
      	sitem.setNum((short)strengthenObj.getStoneNum());
      	respMsg.setStoneItem(sitem);
      }*/
      // 成功率从配置中获取
      respMsg.setAttriList(
          GameContext.getEquipApp().getStrengthenAttriDifferent(equRG, goodsTemplate, 1));
      respMsg.setSuccessRate(strengthenObj.getShowHitProb());
      // 开启vip等级
      respMsg.setOneKeyVipLevel(
          (byte)
              GameContext.getVipApp()
                  .getOpenVipLevel(VipPrivilegeType.EQUIP_ONEKEY_STRENGTHEN.getType(), ""));
      respMsg.setStatus(RespTypeStatus.SUCCESS);
      return respMsg;
    } catch (Exception e) {
      logger.error("buildStrengthenRespMesage ", e);
      return respMsg;
    }
  }
예제 #19
0
 private void calculateNeedGoodsGridCount() {
   int needCount;
   for (GoodsOperateBean bean : this.mustList) {
     int goodsId = bean.getGoodsId();
     int num = bean.getGoodsNum();
     GoodsBase base = GameContext.getGoodsApp().getGoodsBase(goodsId);
     if (base == null) {
       continue;
     }
     int maxOverlapCount = base.getOverlapCount();
     needCount = num / maxOverlapCount;
     if ((num % maxOverlapCount) > 0) {
       needCount++;
     }
     this.needGoodsGridCount += needCount;
   }
   if (this.randomPesheList.size() > 0) {
     this.needGoodsGridCount++;
   }
 }
예제 #20
0
  private AddGoodsBeanResult fallMail(
      RoleInstance role, List<GoodsOperateBean> addList, OutputConsumeType ocType) {
    if (role == null) {
      return new AddGoodsBeanResult().setInfo(GameContext.getI18n().getText(TextId.SYSTEM_ERROR));
    }

    if (Util.isEmpty(addList)) {
      return new AddGoodsBeanResult().success();
    }

    // 大于等于此品质发邮件
    byte mailQualityType = GameContext.getParasConfig().getSendMailQualityType();
    AddGoodsBeanResult result = new AddGoodsBeanResult();
    List<GoodsOperateBean> sendMailList = new ArrayList<GoodsOperateBean>();
    for (GoodsOperateBean bean : addList) {
      if (null == bean) {
        continue;
      }
      GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(bean.getGoodsId());
      if (null == gb) {
        continue;
      }
      if (gb.getQualityType() >= mailQualityType) {
        sendMailList.add(bean);
        continue;
      }
      result.getPutFailureList().add(bean);
    }

    if (Util.isEmpty(sendMailList)) {
      return result;
    }
    // 发送邮件
    this.sendGoodsByMail(role, sendMailList, ocType);

    C0003_TipNotifyMessage tipNotifyMsg = new C0003_TipNotifyMessage();
    tipNotifyMsg.setMsgContext(GameContext.getI18n().getText(TextId.FALL_MAIL_TIPS));
    role.getBehavior().sendMessage(tipNotifyMsg);

    return result;
  }
예제 #21
0
 /**
  * 统计镶嵌在装备身上等级超过level的个数
  *
  * @param level
  * @return
  */
 public static int countGemLevel(RoleGoods roleGoods, int level) {
   MosaicRune[] mosaicRunes = roleGoods.getMosaicRune();
   if (null == mosaicRunes || 0 == mosaicRunes.length) {
     return 0;
   }
   int total = 0;
   for (MosaicRune hole : mosaicRunes) {
     if (null == hole || hole.getGoodsId() <= 0) {
       continue;
     }
     GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(hole.getGoodsId());
     if (null == gb) {
       continue;
     }
     if (gb.getLevel() < level) {
       continue;
     }
     total++;
   }
   return total;
 }
  @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;
  }
예제 #23
0
  /**
   * roll点分配
   *
   * @param itemList
   * @param sameMapMembers
   * @return
   */
  public Map<String, List<GoodsOperateBean>> roll(
      List<GoodsOperateBean> itemList, List<AbstractRole> sameMapMembers) {
    Map<String, List<GoodsOperateBean>> result = Maps.newHashMap();
    if (Util.isEmpty(itemList)) {
      return result;
    }
    int size = sameMapMembers.size();
    if (1 == size) {
      result.put(sameMapMembers.get(0).getRoleId(), itemList);
      return result;
    }
    for (GoodsOperateBean agb : itemList) {
      try {
        int goodsId = agb.getGoodsId();
        int goodsNum = agb.getGoodsNum();
        GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(goodsId);
        if (null == goodsBase) {
          continue;
        }
        int[] points = new int[size];
        int maxIndex = 0;
        int maxPoint = -1;
        int prePoint = -1; // 前一次随机分数
        for (int index = 0; index < size; index++) {
          int point = 0;
          if (goodsBase.getCareer() < 0
              || goodsBase.getCareer() == ((RoleInstance) sameMapMembers.get(index)).getCareer()) {
            // 职业匹配额外+50分,确保物品被匹配的职业roll到
            point = 50;
          }
          int thisPoint = RandomUtil.randomIntWithoutZero(50) + point;
          if (prePoint == thisPoint) {
            // 随机的点数与上次相同,再随机一次
            thisPoint = RandomUtil.randomIntWithoutZero(50) + point;
          }
          if (maxPoint < thisPoint) {
            maxPoint = thisPoint;
            maxIndex = index;
          } else if (maxPoint == thisPoint && RandomUtil.randomBoolean()) {
            // 点数相同,随机处理一下是否替换,否则一直是第一个分数相同的人
            maxIndex = index;
          }
          points[index] = thisPoint;
          prePoint = thisPoint;
        }

        AbstractRole winner = sameMapMembers.get(maxIndex);
        String maxRoleId = winner.getRoleId();
        if (!result.containsKey(maxRoleId)) {
          result.put(maxRoleId, new ArrayList<GoodsOperateBean>());
        }
        result.get(maxRoleId).add(agb);
        // 蓝色(含)品质的物品需要发送roll结构
        boolean sendRollResult = goodsBase.getQualityType() >= QualityType.blue.getType();
        if (sendRollResult) {
          sendRollInfo(sameMapMembers, points, goodsBase, goodsNum, winner, maxIndex);
        }
      } catch (Exception ex) {
        logger.error("", ex);
      }
    }
    return result;
  }
예제 #24
0
 /** 获得该物品模板信息 */
 public static GoodsBase getGoodsBase(RoleGoods roleGoods) {
   return GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId());
 }