10. Quest

10. The Quest Class

10.1 Quest Initialization

Quests are initialized by creating an instance of the Quest class. This is the main quest. Within the class, tasks can be created. Tasks are the events that must be satisfied. Once all tasks are satisfied, the quest is marked as completed, and the rewards are given to the player. When creating an instance of Quest, two parameters are required:

  • name

    • the name of the quest

  • reward

    • reward that is given to the player after the quest is complete.

reward parameter MUST be a list

Quests are created as such:

rewards = [sharp_sword, sharper_sword]
get_sword = TARBSengine.Quest("Collect a sword", rewards)

10.2 Quest.add_task

Quest.add_task(task)

Quests must contain tasks. The addtask() function is used to create tasks the user must complete to complete the quest.

Tasks are created as such:

get_sword.add_task("Obtain a sword")
# Debugger: Task: Collect a sword added to quest Collect a sword
# DEBUG:root: 12:57:41: Debugger: Task: Obtain a sword added to quest Collect a sword

10.3 Quest.complete_task

Quest.complete_task(task)

Task completion checking is completely up to the developer. The reason for this being is so that any complexity of tasks can be checked in any way you desire. Once the Quest.completetask() is called, the task specified in the parameters is marked as completed. If there are no remaining tasks in the quest, the reward will be given.

Usage:

get_sword.complete_task("Obtain a sword")
# Debugger: Task: Collect a sword completed in quest Collect a sword
# DEBUG:root: 01:14:38: Debugger: Task: Collect a sword completed in quest Collect a sword

Last updated