evennia.contrib.tutorials.evadventure.quests¶
A simple quest system for EvAdventure.
A quest is represented by a quest-handler sitting as .quests on a Character. Individual Quests are child classes of EvAdventureQuest with methods for each step of the quest. The quest handler can add, remove, and track the progress by calling the progress method on the quest. Persistent changes are stored on the quester using the add_data and get_data methods with an Attribute as storage backend.
A quest ending can mean a reward or the start of another quest.
-
class
evennia.contrib.tutorials.evadventure.quests.
EvAdventureQuest
(quester)[源代码]¶ 基类:
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 ‘A_flag’ attribute on yourself to finish this step!” help_B = “Finally, you need more than 4 items in your inventory!”
-
key
= 'base quest'¶
-
desc
= 'This is the base quest class'¶
-
start_step
= 'start'¶
-
help_start
= 'You need to start first'¶
-
help_end
= 'You need to end the quest'¶
-
add_data
(key, value)[源代码]¶ Add data to the quest. This saves it permanently.
- 参数
key (str) – The key to store the data under.
value (any) – The data to store.
-
get_data
(key, default=None)[源代码]¶ Get data from the quest.
- 参数
key (str) – The key to get data for.
default (any, optional) – The default value to return if key is not found.
- 返回
any – The data stored under the key.
-
property
questhandler
¶
-
property
current_step
¶
-
property
status
¶
-
property
is_completed
¶
-
property
is_abandoned
¶
-
property
is_failed
¶
-
progress
(*args, **kwargs)[源代码]¶ 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.
- 参数
*args – Will be passed into the step method.
**kwargs –
Will be passed into the step method.
提示
self.quester is available as the character following the quest.
-
help
(*args, **kwargs)[源代码]¶ This is used to get help (or a reminder) of what needs to be done to complete the current quest-step. It will look for a help_<stepname> method or string attribute on the quest.
- 参数
*args – Will be passed into any help_* method.
**kwargs –
Will be passed into any help_* method.
- 返回
str – The help text for the current step.
-
class
evennia.contrib.tutorials.evadventure.quests.
EvAdventureQuestHandler
(obj)[源代码]¶ 基类:
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'¶
-
quest_data_attribute_template
= '_quest_data_{quest_key}'¶
-
quest_data_attribute_category
= 'evadventure'¶
-
has
(quest_key)[源代码]¶ Check if a given quest is registered with the Character.
- 参数
quest_key (str) – The name of the quest to check for.
quest_category (str, optional) – Quest category, if any.
- 返回
bool – If the character is following this quest or not.
-
get
(quest_key)[源代码]¶ Get the quest stored on character, if any.
- 参数
quest_key (str) – The name of the quest to check for.
- 返回
EvAdventureQuest or None –
- The quest stored, or None if
Character is not on this quest.
-
add
(quest_class)[源代码]¶ Add a new quest
- 参数
quest_class (EvAdventureQuest) – The quest class to start.
-
remove
(quest_key)[源代码]¶ Remove a quest. If not complete, it will be abandoned.
- 参数
quest_key (str) – The quest to remove.
-
-
class
evennia.contrib.tutorials.evadventure.quests.
CmdQuests
(**kwargs)[源代码]¶ 基类:
evennia.commands.command.Command
List all quests and their statuses as well as get info about the status of a specific quest.
- Usage:
quests quest <questname>
-
key
= 'quests'¶
-
aliases
= ['quest']¶
-
help_category
= 'general'¶
-
lock_storage
= 'cmd:all();'¶
-
search_index_entry
= {'aliases': 'quest', 'category': 'general', 'key': 'quests', 'no_prefix': ' quest', 'tags': '', 'text': '\n List all quests and their statuses as well as get info about the status of\n a specific quest.\n\n Usage:\n quests\n quest <questname>\n\n '}¶
-
parse
()[源代码]¶ Once the cmdhandler has identified this as the command we want, this function is run. If many of your commands have a similar syntax (for example ‘cmd arg1 = arg2’) you should simply define this once and just let other commands of the same form inherit from this. See the docstring of this module for which object properties are available to use (notably self.args).