Skip to content

Commit

Permalink
Method to create an action to increment quest completions slot index
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Apr 26, 2024
1 parent 50fd4e9 commit 55ec25a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/games/stendhal/server/maps/quests/AbstractQuest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<Integer, Integer> 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
Expand Down

0 comments on commit 55ec25a

Please sign in to comment.