QuestWeaver
A procedural quest generator
weave::QuestTemplateFactory Class Referenceabstract

A factory that is able to create different "types" of quests (quest templates) on demand. More...

#include <QuestTemplateFactory.h>

Public Member Functions

virtual ~QuestTemplateFactory ()=default
 
std::shared_ptr< QuestTemplateCreateTemplate (const std::string &templateKey)
 Creates a new template with the given template key. More...
 
virtual std::vector< std::string > GetTemplateKeys ()
 Returns a list of all valid template keys, whereas each key represents a different kind of quest template. More...
 

Protected Member Functions

virtual std::shared_ptr< QuestTemplatecreateFromJsonValues (const Json::Value &root) const =0
 Creates a new quest template from the given JSON parameters. More...
 
virtual std::vector< const char * > getTemplateFiles () const =0
 

Static Protected Member Functions

static std::vector< TemplateQuestDescriptionextractDescriptions (const Json::Value &root)
 Helper function to extract quest descriptions from a JSON object. More...
 
static std::vector< TemplateQuestProperty > extractProperties (const Json::Value &root)
 Helper function to extract quest properties from a JSON object. More...
 
static int extractRarity (const Json::Value &root)
 Helper function to extract quest rarity from a JSON object. More...
 
static std::string extractTitle (const Json::Value &root, std::shared_ptr< RandomStream > randomStream)
 Helper function to extract a random quest title from a JSON object. More...
 

Protected Attributes

FormatterType formatterType
 The format to use when creating texts for the quest. More...
 
std::shared_ptr< RandomStreamrandomStream
 The random stream instance to use for any random choices regarding the quest template. More...
 

Detailed Description

A factory that is able to create different "types" of quests (quest templates) on demand.

Since all the quest templates are created by the user of the QuestWeaver library, they have to be created somewhere. Subclasses of the QuestTemplateFactory can be registered with QuestWeaver instances which uses them to generate new quests.

The factory is not serialized along with the quest system and has to be re-registered on deserialization.

Definition at line 25 of file QuestTemplateFactory.h.

Constructor & Destructor Documentation

virtual weave::QuestTemplateFactory::~QuestTemplateFactory ( )
virtualdefault

Member Function Documentation

virtual std::shared_ptr<QuestTemplate> weave::QuestTemplateFactory::createFromJsonValues ( const Json::Value &  root) const
protectedpure virtual

Creates a new quest template from the given JSON parameters.

std::shared_ptr<QuestTemplate> weave::QuestTemplateFactory::CreateTemplate ( const std::string &  templateKey)

Creates a new template with the given template key.

See also
GetTemplateKeys()
static std::vector<TemplateQuestDescription> weave::QuestTemplateFactory::extractDescriptions ( const Json::Value &  root)
staticprotected

Helper function to extract quest descriptions from a JSON object.

static std::vector<TemplateQuestProperty> weave::QuestTemplateFactory::extractProperties ( const Json::Value &  root)
staticprotected

Helper function to extract quest properties from a JSON object.

static int weave::QuestTemplateFactory::extractRarity ( const Json::Value &  root)
staticprotected

Helper function to extract quest rarity from a JSON object.

static std::string weave::QuestTemplateFactory::extractTitle ( const Json::Value &  root,
std::shared_ptr< RandomStream randomStream 
)
staticprotected

Helper function to extract a random quest title from a JSON object.

virtual std::vector<const char *> weave::QuestTemplateFactory::getTemplateFiles ( ) const
protectedpure virtual
virtual std::vector<std::string> weave::QuestTemplateFactory::GetTemplateKeys ( )
virtual

Returns a list of all valid template keys, whereas each key represents a different kind of quest template.

Member Data Documentation

FormatterType weave::QuestTemplateFactory::formatterType
protected

The format to use when creating texts for the quest.

Definition at line 76 of file QuestTemplateFactory.h.

std::shared_ptr<RandomStream> weave::QuestTemplateFactory::randomStream
protected

The random stream instance to use for any random choices regarding the quest template.

Definition at line 71 of file QuestTemplateFactory.h.


The documentation for this class was generated from the following file: