コード例 #1
0
  @Override
  public PlayerAttribute getPlayerAttribute(Player player) {
    PlayerAttribute att = new PlayerAttribute();
    List<String> removeList = new ArrayList<String>();

    for (String collectId : player.getCollect().getInfos().keySet()) {
      try {
        CollectItem item = player.getCollect().getInfos().get(collectId);
        Q_collectBean collectBean =
            DataManager.getInstance().q_collectContainer.getMap().get(Integer.valueOf(collectId));

        if (CollectManager.getInstance().isActivity(item, collectBean)) {
          Q_buffBean buffBean =
              ManagerPool.dataManager.q_buffContainer.getMap().get(collectBean.getQ_buff_id());
          if (buffBean != null) att.add(PlayerAttribute.getPlayerAttribute(buffBean));
        }
      } catch (Exception e) {
        removeList.add(collectId);
      }
    }

    for (String key : removeList) {
      player.getCollect().getInfos().remove(key);
    }

    return att;
  }
コード例 #2
0
  @Override
  public void gather(Player player, NPC npc) {
    // 根据npc判断采集物品
    Q_npcBean bean = ManagerPool.dataManager.q_npcContainer.getMap().get(npc.getModelId());
    if (bean == null) {
      return;
    }
    String itemModelIds = bean.getQ_acquisition_item();
    if (StringUtil.isBlank(itemModelIds)) {
      // player停止采集
      ManagerPool.npcManager.playerStopGather(player);
      return;
    }
    Map<Integer, Integer> gatherMap = new HashMap<Integer, Integer>();
    String[] split = itemModelIds.split(Symbol.FENHAO_REG);
    for (String str : split) {
      String[] split2 = str.split(Symbol.XIAHUAXIAN_REG);
      int id = Integer.parseInt(split2[0]);
      int num = 1;
      if (split2.length > 1) num = Integer.parseInt(split2[1]);
      String jobLimit = null;
      if (split2.length > 2) jobLimit = split2[2];
      if (PlayerManager.checkJob(player.getJob(), jobLimit)) gatherMap.put(id, num);
    }
    if (gatherMap.size() == 0) {
      log.error("没有物品可以采集了:" + bean.getQ_id());
      ManagerPool.npcManager.playerStopGather(player);
      return;
    }
    // 判断包裹是否能够放下此物品
    int num = ManagerPool.backpackManager.getEmptyGridNum(player);
    if (num < gatherMap.size()) {
      // 提示包裹空间不足
      MessageUtil.notify_player(
          player, Notifys.ERROR, ResManager.getInstance().getString("背包空间不足"));
      // player停止采集
      ManagerPool.npcManager.playerStopGather(player);
      return;
    }

    // 根据npc判断采集物品
    String taskModelId = bean.getQ_acquisition_task();
    if (StringUtil.isNotBlank(taskModelId)) {
      MainTask mainTask = null;
      for (MainTask task : player.getCurrentMainTasks()) {
        if (taskModelId.contains(String.valueOf(task.getModelid()))) {
          mainTask = task;
          break;
        }
      }
      if (mainTask == null) {
        return;
      }
      Q_task_mainBean taskModel =
          DataManager.getInstance().q_task_mainContainer.getMap().get(mainTask.getModelid());
      if (player.getLevel() < taskModel.getQ_accept_needmingrade()) {
        // 等级不足
        MessageUtil.notify_player(
            player, Notifys.ERROR, ResManager.getInstance().getString("采集需要的等级不足"));
        return;
      }
      // 增加player物品
      List<Item> item = new ArrayList<Item>();
      Iterator<Entry<Integer, Integer>> iterator = gatherMap.entrySet().iterator();
      while (iterator.hasNext()) {
        Entry<Integer, Integer> next = iterator.next();
        List<Item> item2 = Item.createItems(next.getKey(), next.getValue(), true, 0);
        if (CollectionUtil.isNotBlank(item2)) item.addAll(item2);
      }

      if (BackpackManager.getInstance().hasAddSpace(player, item)) {
        log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")检查物品有地儿放!");
      } else {
        log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")检查物品没地儿放!");
      }
      if (ManagerPool.backpackManager.addItems(player, item, Reasons.TAKEUP, Config.getId())) {
        log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")获得物品成功!");
        ;
      } else {
        log.error("玩家(" + player.getId() + ")完成任务(" + mainTask.getModelid() + ")获得物品失败!");
        ;
      }
      log.error("玩家(" + player.getId() + ")采集成功准备完成任务(" + mainTask.getModelid() + ")!");
      // 触发完成任务
      //			mainTask.changeTask();
      if (mainTask.checkFinsh(false, player)) {
        mainTask.finshTask(player);
        log.error("玩家(" + player.getId() + ")采集成功完成任务(" + taskModelId + ")了!");
      } else {

        log.error("玩家(" + player.getId() + ")采集成功未完成任务(" + taskModelId + ")了!");
      }
      //			ManagerPool.taskManager.finishMainTask(player, taskModelId);
    }

    // player停止采集
    ManagerPool.npcManager.playerStopGather(player);
  }
コード例 #3
0
 @Override
 public PlayerAttribute getPlayerAttribute(Player player) {
   PlayerAttribute patt = new PlayerAttribute();
   Iterator<Q_arrowBean> iterator =
       DataManager.getInstance().q_arrowContainer.getMap().values().iterator();
   while (iterator.hasNext()) {
     Q_arrowBean q_arrowBean = iterator.next();
     if (q_arrowBean != null
         && q_arrowBean.getQ_arrow_id() <= player.getArrowData().getArrowlv()) {
       patt.setAttack(patt.getAttack() + q_arrowBean.getQ_attack());
       patt.setDefense(patt.getDefense() + q_arrowBean.getQ_defence());
       patt.setCrit(patt.getCrit() + q_arrowBean.getQ_crit());
       patt.setDodge(patt.getDodge() + q_arrowBean.getQ_dodge());
       patt.setMaxHp(patt.getMaxHp() + q_arrowBean.getQ_maxhp());
       patt.setMaxMp(patt.getMaxMp() + q_arrowBean.getQ_maxmp());
       patt.setMaxSp(patt.getMaxSp() + q_arrowBean.getQ_maxsp());
       patt.setAttackSpeed(patt.getAttackSpeed() + q_arrowBean.getQ_attackspeed());
       patt.setSpeed(patt.getSpeed() + q_arrowBean.getQ_speed());
     }
   }
   Iterator<Q_arrow_starBean> iterator1 =
       DataManager.getInstance().q_arrow_starContainer.getMap().values().iterator();
   while (iterator1.hasNext()) {
     Q_arrow_starBean q_arrow_starBean = iterator1.next();
     if (q_arrow_starBean != null
         && ((q_arrow_starBean.getQ_mainlv() < player.getArrowData().getStarData().getStarmainlv())
             || (q_arrow_starBean.getQ_mainlv()
                     == player.getArrowData().getStarData().getStarmainlv()
                 && q_arrow_starBean.getQ_sublv()
                     <= player.getArrowData().getStarData().getStarsublv()))) {
       patt.setAttack(patt.getAttack() + q_arrow_starBean.getQ_attack());
       patt.setDefense(patt.getDefense() + q_arrow_starBean.getQ_defence());
       patt.setCrit(patt.getCrit() + q_arrow_starBean.getQ_crit());
       patt.setDodge(patt.getDodge() + q_arrow_starBean.getQ_dodge());
       patt.setMaxHp(patt.getMaxHp() + q_arrow_starBean.getQ_maxhp());
       patt.setMaxMp(patt.getMaxMp() + q_arrow_starBean.getQ_maxmp());
       patt.setMaxSp(patt.getMaxSp() + q_arrow_starBean.getQ_maxsp());
       patt.setAttackSpeed(patt.getAttackSpeed() + q_arrow_starBean.getQ_attackspeed());
       patt.setSpeed(patt.getSpeed() + q_arrow_starBean.getQ_speed());
     }
   }
   Iterator<Q_arrow_bowBean> iterator2 =
       DataManager.getInstance().q_arrow_bowContainer.getMap().values().iterator();
   while (iterator2.hasNext()) {
     Q_arrow_bowBean q_arrow_bowBean = iterator2.next();
     if (q_arrow_bowBean != null
         && ((q_arrow_bowBean.getQ_mainlv() < player.getArrowData().getBowData().getBowmainlv())
             || (q_arrow_bowBean.getQ_mainlv() == player.getArrowData().getBowData().getBowmainlv()
                 && q_arrow_bowBean.getQ_sublv()
                     <= player.getArrowData().getBowData().getBowsublv()))) {
       patt.setAttack(patt.getAttack() + q_arrow_bowBean.getQ_attack());
       patt.setDefense(patt.getDefense() + q_arrow_bowBean.getQ_defence());
       patt.setCrit(patt.getCrit() + q_arrow_bowBean.getQ_crit());
       patt.setDodge(patt.getDodge() + q_arrow_bowBean.getQ_dodge());
       patt.setMaxHp(patt.getMaxHp() + q_arrow_bowBean.getQ_maxhp());
       patt.setMaxMp(patt.getMaxMp() + q_arrow_bowBean.getQ_maxmp());
       patt.setMaxSp(patt.getMaxSp() + q_arrow_bowBean.getQ_maxsp());
       patt.setAttackSpeed(patt.getAttackSpeed() + q_arrow_bowBean.getQ_attackspeed());
       patt.setSpeed(patt.getSpeed() + q_arrow_bowBean.getQ_speed());
     }
   }
   return patt;
 }