コード例 #1
0
  protected boolean processConcludeQuest(QuestClient.ConcludeMessage msg) {
    Long mobOid = msg.getMobOid();
    if (!questOid.equals(msg.getQuestOid())) return true;
    if (Log.loggingDebug)
      log.debug("processConcludeQuest: player=" + getPlayerOid() + ", mob=" + mobOid);
    ArrayList<String> templateList = new ArrayList<String>();
    for (CollectionGoalStatus goalStatus : goalsStatus) {
      for (int i = 0; i < goalStatus.getTargetCount(); i++) {
        templateList.add(goalStatus.getTemplateName());
      }
    }

    boolean conclude = false;
    if (templateList.isEmpty()) {
      conclude = true;
    } else {
      List<Long> removeResult = InventoryClient.removeItems(getPlayerOid(), templateList);
      if (removeResult != null) {
        conclude = true;
        for (Long itemOid : removeResult) {
          ObjectManagerClient.deleteObject(itemOid);
        }
      }
    }
    if (conclude) {
      setConcluded(true);
      deactivate();
      updateQuestLog();
      sendStateStatusChange();
    }
    return true;
  }
コード例 #2
0
  /** generate delivery items and give them to the player */
  protected void makeDeliveryItems() {
    Long playerOid = getPlayerOid();
    Long bagOid = playerOid;
    if (Log.loggingDebug)
      log.debug("makeDeliveryItems: playerOid " + playerOid + ", bagOid + " + bagOid);

    // Normally the persistence flag is inherited from the enclosing
    // object, but all we have are OIDs.  Assume this is only used
    // for players and players are always persistent.
    Template overrideTemplate = new Template();
    overrideTemplate.put(Namespace.OBJECT_MANAGER, ObjectManagerClient.TEMPL_PERSISTENT, true);

    for (String templateName : deliveryItems) {
      Long itemOid = ObjectManagerClient.generateObject(templateName, overrideTemplate);
      InventoryClient.addItem(bagOid, playerOid, bagOid, itemOid);
    }
  }
コード例 #3
0
  public void updateObjectiveStatus() {
    for (CollectionGoalStatus goalStatus : goalsStatus) {
      ArrayList<String> templateList = new ArrayList<String>();
      for (int i = 0; i < goalStatus.getTargetCount(); i++) {
        templateList.add(goalStatus.getTemplateName());
      }
      if (templateList.size() > 0) {
        List<Long> findResult = InventoryClient.findItems(getPlayerOid(), templateList);
        goalStatus.currentCount = 0;
        for (Long itemOid : findResult) {
          if (itemOid != null) {
            goalStatus.currentCount++;
          }
        }
      }
    }

    updateQuestObjectives();

    // update quest completed flag
    for (CollectionGoalStatus goalStatus : goalsStatus) {
      if (goalStatus.currentCount < goalStatus.targetCount) {
        log.debug("updateObjectiveStatus: quest not completed");
        boolean wasComplete = getCompleted();
        setCompleted(false);
        if (wasComplete) {
          // we were complete, but no longer, so update
          sendStateStatusChange();
        }
        return;
      }
    }
    if (getCompleted()) {
      // already completed, ignore
      return;
    }
    log.debug("updateObjectiveStatus: quest is completed");
    setCompleted(true);
    sendStateStatusChange();
    WorldManagerClient.sendObjChatMsg(playerOid, 0, "You have completed quest " + getName());
  }