Search in sources :

Example 1 with Quest

use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.

the class QuestDialogueCommands method questChoice.

/* 0=<questName>, 1=<response text> */
private void questChoice(CommandSender sender, String[] args) {
    if (args.length < 2) {
        return;
    }
    User user = user(sender);
    String questName = args[0];
    String response = StringUtil.concatArgs(args, 1);
    user.debug("Selected quest choice " + response + " for quest " + questName);
    // get the current quest action they're on
    Quest quest = questLoader.getQuestByName(questName);
    // invalid quest name
    if (quest == null)
        return;
    QuestStep progress = user.getQuestProgress().get(quest);
    // user has not begun quest
    if (progress == null)
        return;
    int actionIndex = user.getQuestActionIndex(quest) - 1;
    QuestAction action = progress.getActions().get(actionIndex);
    // not a stage where the user needs to input anything
    if (action.getActionType() != QuestAction.QuestActionType.CHOICES)
        return;
    // possible responses are mapped to a new quest stage
    Integer stage = action.getChoices().get(response);
    if (stage == null) {
        return;
    }
    sender.sendMessage(ChatColor.GRAY + "[1/1] " + ChatColor.DARK_GREEN + "You: " + ChatColor.GREEN + response);
    user.setQuestPaused(quest, false);
    user.updateQuestProgress(quest, quest.getSteps().get(stage), false);
}
Also used : User(mc.dragons.core.gameobject.user.User) QuestStep(mc.dragons.core.gameobject.quest.QuestStep) QuestAction(mc.dragons.core.gameobject.quest.QuestAction) Quest(mc.dragons.core.gameobject.quest.Quest)

Example 2 with Quest

use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.

the class StuckQuestCommand method selectQuest.

private void selectQuest(CommandSender sender) {
    User user = user(sender);
    boolean any = false;
    for (Entry<Quest, QuestStep> entry : user.getQuestProgress().entrySet()) {
        if (entry.getValue().getStepName().equalsIgnoreCase("Complete"))
            continue;
        any = true;
    }
    if (!any) {
        sender.sendMessage(ChatColor.RED + "You don't have any active quests!");
        return;
    }
    sender.sendMessage(" ");
    sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Please confirm the quest you are having issues with:");
    for (Entry<Quest, QuestStep> entry : user.getQuestProgress().entrySet()) {
        if (entry.getValue().getStepName().equalsIgnoreCase("Complete"))
            continue;
        sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + " • " + ChatColor.GREEN + entry.getKey().getQuestName(), "/stuckquest " + entry.getKey().getName(), ChatColor.GRAY + "Quest: " + ChatColor.RESET + entry.getKey().getQuestName()));
    }
    sender.sendMessage(" ");
    sender.sendMessage(ChatColor.GRAY + "Click on one of the quests above to continue with the report.");
    sender.sendMessage(" ");
}
Also used : User(mc.dragons.core.gameobject.user.User) QuestStep(mc.dragons.core.gameobject.quest.QuestStep) Quest(mc.dragons.core.gameobject.quest.Quest)

Example 3 with Quest

use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.

the class QuestCommand method displayQuest.

private void displayQuest(CommandSender sender, String[] args) {
    Quest quest = lookupQuest(sender, args[0]);
    if (quest == null)
        return;
    sender.sendMessage(ChatColor.GREEN + "=== Quest: " + quest.getName() + " ===");
    sender.sendMessage(ChatColor.GRAY + "Database identifier: " + ChatColor.GREEN + quest.getIdentifier().toString());
    if (quest.isLocked()) {
        sender.sendMessage(ChatColor.RED + "Currently locked to players");
    }
    sender.sendMessage(ChatColor.GRAY + "Full name: " + ChatColor.GREEN + quest.getQuestName());
    sender.sendMessage(ChatColor.GRAY + "Level min: " + ChatColor.GREEN + quest.getLevelMin());
    sender.sendMessage(ChatColor.GRAY + "# Stages: " + ChatColor.GREEN + quest.getSteps().size());
    sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "[Test Quest] ", "/testquest " + quest.getName(), true, "Click to test quest"), ObjectMetadataCommand.getClickableMetadataLink(GameObjectType.QUEST, quest.getUUID()));
    if (!quest.isValid()) {
        sender.sendMessage(ChatColor.RED + "Warning: Invalid or incomplete quest! To be valid, the final stage must be named \"Complete\", have trigger type INSTANT, and have no actions.");
    }
}
Also used : Quest(mc.dragons.core.gameobject.quest.Quest)

Example 4 with Quest

use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.

the class QuestCommand method insertAction.

private void insertAction(CommandSender sender, String[] args) {
    Quest quest = lookupQuest(sender, args[0]);
    Integer stepNo = parseInt(sender, args[2]);
    Integer actionNo = parseInt(sender, args[5]);
    if (quest == null || stepNo == null || actionNo == null)
        return;
    QuestStep step = quest.getSteps().get(stepNo);
    QuestAction action = makeAction(quest, sender, Arrays.copyOfRange(args, 6, args.length));
    step.insertAction(action, actionNo);
    Document base = Document.parse(quest.getData().toJson());
    sender.sendMessage(ChatColor.GREEN + "Inserted new action to quest stage successfully.");
    AUDIT_LOG.saveEntry(quest, user(sender), base, "Inserted action before " + args[5] + " to stage " + args[2]);
}
Also used : QuestStep(mc.dragons.core.gameobject.quest.QuestStep) QuestAction(mc.dragons.core.gameobject.quest.QuestAction) Document(org.bson.Document) Quest(mc.dragons.core.gameobject.quest.Quest)

Example 5 with Quest

use of mc.dragons.core.gameobject.quest.Quest in project DragonsOnline by UniverseCraft.

the class QuestCommand method updateLevelMin.

private void updateLevelMin(CommandSender sender, String[] args) {
    Quest quest = lookupQuest(sender, args[0]);
    if (quest == null)
        return;
    Document base = Document.parse(quest.getData().toJson());
    quest.setLevelMin(Integer.valueOf(args[2]));
    sender.sendMessage(ChatColor.GREEN + "Updated quest level min successfully.");
    AUDIT_LOG.saveEntry(quest, user(sender), base, "Set level min to " + args[2]);
}
Also used : Document(org.bson.Document) Quest(mc.dragons.core.gameobject.quest.Quest)

Aggregations

Quest (mc.dragons.core.gameobject.quest.Quest)30 Document (org.bson.Document)17 QuestStep (mc.dragons.core.gameobject.quest.QuestStep)15 User (mc.dragons.core.gameobject.user.User)9 QuestAction (mc.dragons.core.gameobject.quest.QuestAction)5 GameObject (mc.dragons.core.gameobject.GameObject)3 TriggerType (mc.dragons.core.gameobject.quest.QuestTrigger.TriggerType)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ItemClass (mc.dragons.core.gameobject.item.ItemClass)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 Dragons (mc.dragons.core.Dragons)1 GameObjectType (mc.dragons.core.gameobject.GameObjectType)1 ItemClassLoader (mc.dragons.core.gameobject.item.ItemClassLoader)1 NPCAction (mc.dragons.core.gameobject.npc.NPCAction)1 NPCActionType (mc.dragons.core.gameobject.npc.NPCAction.NPCActionType)1 ShopItem (mc.dragons.core.gameobject.npc.NPCAction.ShopItem)1 NPCCondition (mc.dragons.core.gameobject.npc.NPCCondition)1