evennia.contrib.tutorials.evadventure.quests

A simple quest system for EvAdventure.

A quest is represented by a quest-handler sitting as .quest on a Character. Individual Quests are objects that track the state and can have multiple steps, each of which are checked off during the quest’s progress.

The player can use the quest handler to track the progress of their quests.

A quest ending can mean a reward or the start of another quest.

class evennia.contrib.tutorials.evadventure.quests.EvAdventureQuest(quester, start_step=None)[source]

Bases: object

This represents a single questing unit of quest.

Properties:

name (str): Main identifier for the quest. category (str, optional): This + name must be globally unique.

it ends - it then pauses after the last completed step.

Each step of the quest is represented by a .step_<stepname> method. This should check the status of the quest-step and update the .current_step or call .complete(). There are also .help_<stepname> which is either a class-level help string or a method returning a help text. All properties should be stored on the quester.

Example: py class MyQuest(EvAdventureQuest):

‘’’A quest with two steps that ar’’’

start_step = “A”

help_A = “You need a ‘_quest_A_flag’ on yourself to finish this step!” help_B = “Finally, you need more than 4 items in your inventory!”

def step_A(self, *args, **kwargs):
if self.quester.db._quest_A_flag == True:

self.quester.msg(“Completed the first step of the quest.”) self.current_step = “end” self.progress()

def step_end(self, *args, **kwargs):
if len(self.quester.contents) > 4:

self.quester.msg(“Quest complete!”) self.complete()

key = 'basequest'
desc = 'This is the base quest class'
start_step = 'start'
completed_text = 'This quest is completed!'
abandoned_text = 'This quest is abandoned.'
help_start = 'You need to start first'
help_end = 'You need to end the quest'
__init__(quester, start_step=None)[source]

Initialize self. See help(type(self)) for accurate signature.

property questhandler
property current_step
abandon()[source]

Call when quest is abandoned.

complete()[source]

Call this to end the quest.

progress(*args, **kwargs)[source]

This is called whenever the environment expects a quest may need stepping. This will determine which quest-step we are on and run step_<stepname>, which in turn will figure out if the step is complete or not.

Parameters
  • *args – Will be passed into the step method.

  • **kwargs

    Will be passed into the step method.

help()[source]

This is used to get help (or a reminder) of what needs to be done to complete the current quest-step.

Returns

str – The help text for the current step.

step_start(*args, **kwargs)[source]

Example step that completes immediately.

cleanup()[source]

This is called both when completing the quest, or when it is abandoned prematurely. Make sure to cleanup any quest-related data stored when following the quest.

class evennia.contrib.tutorials.evadventure.quests.EvAdventureQuestHandler(obj)[source]

Bases: object

This sits on the Character, as .quests.

It’s initiated using a lazy property on the Character:

@lazy_property def quests(self):

return EvAdventureQuestHandler(self)

quest_storage_attribute_key = '_quests'
quest_storage_attribute_category = 'evadventure'
__init__(obj)[source]

Initialize self. See help(type(self)) for accurate signature.

has(quest_key)[source]

Check if a given quest is registered with the Character.

Parameters
  • quest_key (str) – The name of the quest to check for.

  • quest_category (str, optional) – Quest category, if any.

Returns

bool – If the character is following this quest or not.

get(quest_key)[source]

Get the quest stored on character, if any.

Parameters

quest_key (str) – The name of the quest to check for.

Returns

EvAdventureQuest or None

The quest stored, or None if

Character is not on this quest.

add(quest)[source]

Add a new quest

Parameters

quest (EvAdventureQuest) – The quest class to start.

remove(quest_key)[source]

Remove a quest. If not complete, it will be abandoned.

Parameters

quest_key (str) – The quest to remove.

get_help(quest_key=None)[source]

Get help text for a quest or for all quests. The help text is a combination of the description of the quest and the help-text of the current step.

Parameters

quest_key (str, optional) – The quest-key. If not given, get help for all quests in handler.

Returns

list – Help texts, one for each quest, or only one if quest_key is given.

progress(quest_key=None, *args, **kwargs)[source]

Check progress of a given quest or all quests.

Parameters
  • quest_key (str, optional) – If given, check the progress of this quest (if we have it), otherwise check progress on all quests.

  • *args – Will be passed into each quest’s progress call.

  • **kwargs

    Will be passed into each quest’s progress call.