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; }
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()); }