QuestWeaver
A procedural quest generator
|
Defines a blueprint from which a specific type of quest can be generated. More...
#include <QuestTemplate.h>
Public Member Functions | |
QuestTemplate (std::string title, std::vector< TemplateQuestProperty > properties, std::vector< TemplateQuestDescription > descriptions, FormatterType formatterType, int rarity=0) | |
Creates a new quest template. More... | |
virtual | ~QuestTemplate ()=default |
std::vector< TemplateQuestProperty > | GetProperties () const noexcept |
Returns a list of all the template parts that (mandatory) must be filled and (optional) can be filled with world entities. More... | |
virtual std::vector< PropertyCandidate > | GetPropertyCandidates (const TemplateQuestProperty &property, const WorldModel &worldModel) const =0 |
This method creates a list of possible candidates for a given template property. More... | |
int | GetRarity () const noexcept |
virtual bool | HasPriority () const noexcept |
virtual bool | IsValid (const WorldModel &worldModel, const QuestModel &questModel) const noexcept |
virtual std::shared_ptr< Quest > | ToQuest (const std::vector< QuestPropertyValue > &questPropertyValues, const std::string &questStory) const =0 |
Creates a new quest based on this template and the given parameters. More... | |
std::shared_ptr< Quest > | ToQuest (const std::vector< QuestPropertyValue > &questPropertyValues) const |
Creates a new quest based on this template and the given parameters. More... | |
Protected Member Functions | |
std::string | getBestFittingDescription (const std::vector< QuestPropertyValue > &questPropertyValues) const |
Returns the first description that supports all of the given property values. More... | |
std::string | getTitle (const std::vector< QuestPropertyValue > &questPropertyValues) const noexcept |
Returns the quest title and uses the given property values to replace any placeholders. More... | |
virtual std::map< std::string, std::string > | resolveAdditionalPlaceholders (QuestPropertyValue questPropertyValue) const noexcept |
Static Protected Member Functions | |
static ID | getEntityIdFromProperty (std::string propertyName, const std::vector< QuestPropertyValue > &questPropertyValues) noexcept |
Returns the ID of the entitiy referenced by the property with the given name or returns 0 if no property with such a name can be found. More... | |
Protected Attributes | |
FormatterType | formatterType |
Defines a blueprint from which a specific type of quest can be generated.
Each template contains the information necessary to create variations of a specific quest.
The template data itself is kept in JSON format in a file and loaded via the QuestTemplateFactory.
A template might define the variables and entities necessary to create a "fetch" quest. Some of these entities might be optional, e.g. who gave the player the quest. Some of them are mandatory, e.g. what the player has to fetch.
A quest generated from such a template might be "Get the king's crown from the dragon" or "fetch 10 eggs to make breakfast", depending on the entities the world model creates.
Definition at line 82 of file QuestTemplate.h.
weave::QuestTemplate::QuestTemplate | ( | std::string | title, |
std::vector< TemplateQuestProperty > | properties, | ||
std::vector< TemplateQuestDescription > | descriptions, | ||
FormatterType | formatterType, | ||
int | rarity = 0 |
||
) |
Creates a new quest template.
title | The quest title (can contain placeholders for mandatory properties). |
properties | The properties used by the quest system to select world entities for the quest. The names of these properties will also be used when substituting the placeholders in the title and description texts. |
descriptions | The possible description texts. One of these descriptions will be used to create the quest description, depending on the optional properties used by the quest system. |
formatterType | The format used when creating the texts for a new quest. |
|
virtualdefault |
|
protected |
Returns the first description that supports all of the given property values.
|
staticprotectednoexcept |
Returns the ID of the entitiy referenced by the property with the given name or returns 0 if no property with such a name can be found.
|
noexcept |
Returns a list of all the template parts that (mandatory) must be filled and (optional) can be filled with world entities.
Which entities can be used to fill a certain TemplateQuestProperty is determined by the template itself, by the GetPropertyCandidates() method.
|
pure virtual |
This method creates a list of possible candidates for a given template property.
Subclasses implementing this method may search the world model for fitting entities or they may use the world model to create new entities.
For every candidate, the template may add some metadata (e.g. relationship changes caused by the quest or markers to not choose the entity for another quest). If a candidate is chosen from the list, the corresponding WorldModelActions are executed in the world model.
|
noexcept |
|
protectednoexcept |
Returns the quest title and uses the given property values to replace any placeholders.
|
virtualnoexcept |
|
virtualnoexcept |
|
protectedvirtualnoexcept |
|
pure virtual |
Creates a new quest based on this template and the given parameters.
questPropertyValues | the values for the template's mandatory and optional properties. |
questStory | the quest's background story. |
std::shared_ptr<Quest> weave::QuestTemplate::ToQuest | ( | const std::vector< QuestPropertyValue > & | questPropertyValues | ) | const |
Creates a new quest based on this template and the given parameters.
The resulting quest has no background story.
questPropertyValues | the values for the template's mandatory and optional properties. |
|
protected |
Definition at line 167 of file QuestTemplate.h.