예제 #1
0
  /**
   * 随机一个藏宝图
   *
   * @param treasureId
   * @return
   */
  private TreasureConfig randomTreasure(int treasureId) {
    List<TreasureConfig> list =
        resourceService.listByIndex(IndexName.TREASURE_REWARDID, TreasureConfig.class, treasureId);
    if (list != null && list.size() > 0) {
      int rndRate = 0;
      int rate = 0;
      for (TreasureConfig config : list) {
        if (rndRate <= 0) {
          rndRate = Tools.getRandomInteger(config.getFullRate());
        }
        rate += config.getRate();
        if (rndRate < rate) {
          return config;
        }
      }

    } else {
      logger.error("藏宝图id[{}]没有对应的品质刷新数据", treasureId);
    }
    return null;
  }
예제 #2
0
 /**
  * 刷新品质
  *
  * @param treasureId
  * @return
  */
 public int refreshQuality(int treasureId) {
   TreasureConfig treasureConfig = randomTreasure(treasureId);
   return treasureConfig != null ? treasureConfig.getQuality() : 0;
 }