diff --git a/src/games/stendhal/server/maps/quests/AbstractQuest.java b/src/games/stendhal/server/maps/quests/AbstractQuest.java index 825320fb4a..232e458fef 100644 --- a/src/games/stendhal/server/maps/quests/AbstractQuest.java +++ b/src/games/stendhal/server/maps/quests/AbstractQuest.java @@ -17,6 +17,7 @@ import games.stendhal.server.core.engine.SingletonRepository; import games.stendhal.server.entity.npc.NPCList; +import games.stendhal.server.entity.npc.action.IncrementQuestAction; import games.stendhal.server.entity.player.Player; import marauroa.common.Pair; @@ -166,6 +167,33 @@ public int getCompletedCount(final Player player) { return completed ? 1 : 0; } + /** + * Retrieves action to execute when completions count should be incremented. + * + * NOTE: quest completions indexes should be set to use this method + * + * @param complete + * `true` to use "done" state index, `false` to use "active" state index. + * @return + * `IncrementQuestAction` to increment slot where completions indexes are stored. + */ + protected IncrementQuestAction incrementCompletionsAction(final boolean complete) { + final Pair indexes = questInfo.getCompletionsIndexes(); + return new IncrementQuestAction(getSlotName(), complete ? indexes.second() : indexes.first(), 1); + } + + /** + * Retrieves action to execute when completions count should be incremented. + * + * NOTE: quest completions indexes should be set to use this method + * + * @return + * `IncrementQuestAction` to increment slot where completions indexes are stored. + */ + protected IncrementQuestAction incrementCompletionsAction() { + return incrementCompletionsAction(true); + } + @Override public boolean isRepeatable(final Player player) { // TODO implement