Peoplemon  0.1.0
Peoplemon 3 game source documentation
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
core::file::Conversation::Node Class Reference

Building block of conversations. A conversation is a tree of nodes and each node is an action that happens in the conversation. More...

#include <Conversation.hpp>

Classes

struct  Item
 

Public Types

enum  Type : std::uint8_t {
  Talk = 0 , Prompt = 1 , GiveItem = 2 , TakeItem = 3 ,
  GiveMoney = 4 , TakeMoney = 5 , RunScript = 6 , CheckSaveFlag = 7 ,
  SetSaveFlag = 8 , CheckInteracted = 9 , _LEGACY_Label , _LEGACY_Jump
}
 Represents the different effects that nodes can have. More...
 

Public Member Functions

 Node ()
 Creates an empty talk node. More...
 
 Node (Type type)
 Construct an empty Node of the given type. More...
 
void setType (Type type)
 Clears node data and updates to a new type. More...
 
Type getType () const
 Returns the type of this node. More...
 
std::string & message ()
 Returns the message or prompt for this node. More...
 
std::string & script ()
 Returns the script file of this node. More...
 
std::string & saveFlag ()
 Returns the save flag of this node. More...
 
std::vector< std::pair< std::string, std::uint32_t > > & choices ()
 Returns the choices if this is a prompt node. Undefined behavior if not. More...
 
std::uint32_t & money ()
 Returns the money requested or given, undefined behavior if not a money node. More...
 
Itemitem ()
 Returns the item to give or take. Undefined behavior if not an item node. More...
 
std::uint32_t & next ()
 Returns the index of the next node in the case of a Talk, Give, and Script nodes. More...
 
std::uint32_t & nextOnPass ()
 Returns the next node if a check passes (ie take item or money) More...
 
std::uint32_t & nextOnReject ()
 Returns the next node if a check is rejected (ie not taking money or item) More...
 
const std::string & message () const
 Returns the message or prompt for this node. More...
 
const std::string & script () const
 Returns the script file of this node. More...
 
const std::string & saveFlag () const
 Returns the save flag of this node. More...
 
bool & runConcurrently ()
 Returns whether or not the launched script should be executed concurrently. More...
 
bool runConcurrently () const
 Returns whether or not the launched script should be executed concurrently. More...
 
const std::vector< std::pair< std::string, std::uint32_t > > & choices () const
 Returns the choices if this is a prompt node. Undefined behavior if not. More...
 
unsigned int money () const
 Returns the money requested or given, undefined behavior if not a money node. More...
 
const Itemitem () const
 Returns the item to give or take. Undefined behavior if not an item node. More...
 
std::uint32_t next () const
 Returns the index of the next node in the case of a Talk, Give, and Script nodes. More...
 
std::uint32_t nextOnPass () const
 Returns the next node if a check passes (ie take item or money) More...
 
std::uint32_t nextOnReject () const
 Returns the next node if a check is rejected (ie not taking money or item) More...
 

Static Public Member Functions

static std::string typeToString (Type type)
 Converts a node type to a human readable string. More...
 

Friends

struct bl::serial::SerializableObject< Node >
 
struct bl::serial::SerializableObject< core::file::Conversation::Node::Item >
 

Detailed Description

Building block of conversations. A conversation is a tree of nodes and each node is an action that happens in the conversation.

Definition at line 29 of file Conversation.hpp.

Member Enumeration Documentation

◆ Type

Represents the different effects that nodes can have.

Enumerator
Talk 

This just outputs a message.

Prompt 

This will output a message then prompt the player for a choice.

GiveItem 

This unconditionally gives the player an item.

TakeItem 

This will ask the player for an item. They may refuse or not have it.

GiveMoney 

This will unconditionally give money to the player.

TakeMoney 

This will ask the player for money. They may refuse or not have enough.

RunScript 

This will run a script. Must be a file.

CheckSaveFlag 

This will check if a flag exists and jump to the next node accordingly.

SetSaveFlag 

This will check if a flag exists and jump to the next node accordingly.

CheckInteracted 

This will check if interacted with the talking NPC and jump accordingly.

_LEGACY_Label 
_LEGACY_Jump 

Definition at line 35 of file Conversation.hpp.

Constructor & Destructor Documentation

◆ Node() [1/2]

core::file::Conversation::Node::Node ( )

Creates an empty talk node.

Definition at line 100 of file Conversation.cpp.

◆ Node() [2/2]

core::file::Conversation::Node::Node ( Type  type)

Construct an empty Node of the given type.

Parameters
typeThe type to be

Definition at line 102 of file Conversation.cpp.

Member Function Documentation

◆ choices() [1/2]

std::vector< std::pair< std::string, std::uint32_t > > & core::file::Conversation::Node::choices ( )

Returns the choices if this is a prompt node. Undefined behavior if not.

Definition at line 156 of file Conversation.cpp.

◆ choices() [2/2]

const std::vector< std::pair< std::string, std::uint32_t > > & core::file::Conversation::Node::choices ( ) const

Returns the choices if this is a prompt node. Undefined behavior if not.

Definition at line 192 of file Conversation.cpp.

◆ getType()

Conversation::Node::Type core::file::Conversation::Node::getType ( ) const

Returns the type of this node.

Definition at line 133 of file Conversation.cpp.

◆ item() [1/2]

Conversation::Node::Item & core::file::Conversation::Node::item ( )

Returns the item to give or take. Undefined behavior if not an item node.

Definition at line 172 of file Conversation.cpp.

◆ item() [2/2]

const Conversation::Node::Item & core::file::Conversation::Node::item ( ) const

Returns the item to give or take. Undefined behavior if not an item node.

Definition at line 208 of file Conversation.cpp.

◆ message() [1/2]

std::string & core::file::Conversation::Node::message ( )

Returns the message or prompt for this node.

Definition at line 135 of file Conversation.cpp.

◆ message() [2/2]

const std::string & core::file::Conversation::Node::message ( ) const

Returns the message or prompt for this node.

Definition at line 186 of file Conversation.cpp.

◆ money() [1/2]

std::uint32_t & core::file::Conversation::Node::money ( )

Returns the money requested or given, undefined behavior if not a money node.

Definition at line 164 of file Conversation.cpp.

◆ money() [2/2]

unsigned int core::file::Conversation::Node::money ( ) const

Returns the money requested or given, undefined behavior if not a money node.

Definition at line 200 of file Conversation.cpp.

◆ next() [1/2]

std::uint32_t & core::file::Conversation::Node::next ( )

Returns the index of the next node in the case of a Talk, Give, and Script nodes.

Definition at line 180 of file Conversation.cpp.

◆ next() [2/2]

std::uint32_t core::file::Conversation::Node::next ( ) const

Returns the index of the next node in the case of a Talk, Give, and Script nodes.

Definition at line 216 of file Conversation.cpp.

◆ nextOnPass() [1/2]

std::uint32_t & core::file::Conversation::Node::nextOnPass ( )

Returns the next node if a check passes (ie take item or money)

Definition at line 182 of file Conversation.cpp.

◆ nextOnPass() [2/2]

std::uint32_t core::file::Conversation::Node::nextOnPass ( ) const

Returns the next node if a check passes (ie take item or money)

Definition at line 218 of file Conversation.cpp.

◆ nextOnReject() [1/2]

std::uint32_t & core::file::Conversation::Node::nextOnReject ( )

Returns the next node if a check is rejected (ie not taking money or item)

Definition at line 184 of file Conversation.cpp.

◆ nextOnReject() [2/2]

std::uint32_t core::file::Conversation::Node::nextOnReject ( ) const

Returns the next node if a check is rejected (ie not taking money or item)

Definition at line 220 of file Conversation.cpp.

◆ runConcurrently() [1/2]

bool & core::file::Conversation::Node::runConcurrently ( )

Returns whether or not the launched script should be executed concurrently.

Definition at line 141 of file Conversation.cpp.

◆ runConcurrently() [2/2]

bool core::file::Conversation::Node::runConcurrently ( ) const

Returns whether or not the launched script should be executed concurrently.

Definition at line 149 of file Conversation.cpp.

◆ saveFlag() [1/2]

std::string & core::file::Conversation::Node::saveFlag ( )

Returns the save flag of this node.

Definition at line 139 of file Conversation.cpp.

◆ saveFlag() [2/2]

const std::string & core::file::Conversation::Node::saveFlag ( ) const

Returns the save flag of this node.

Definition at line 190 of file Conversation.cpp.

◆ script() [1/2]

std::string & core::file::Conversation::Node::script ( )

Returns the script file of this node.

Definition at line 137 of file Conversation.cpp.

◆ script() [2/2]

const std::string & core::file::Conversation::Node::script ( ) const

Returns the script file of this node.

Definition at line 188 of file Conversation.cpp.

◆ setType()

void core::file::Conversation::Node::setType ( Type  type)

Clears node data and updates to a new type.

Parameters
typeThe type to be

Definition at line 104 of file Conversation.cpp.

◆ typeToString()

std::string core::file::Conversation::Node::typeToString ( Type  type)
static

Converts a node type to a human readable string.

Parameters
typeThe type to convert
Returns
std::string A string for that type

Definition at line 236 of file Conversation.cpp.

Friends And Related Function Documentation

◆ bl::serial::SerializableObject< core::file::Conversation::Node::Item >

friend struct bl::serial::SerializableObject< core::file::Conversation::Node::Item >
friend

Definition at line 242 of file Conversation.hpp.

◆ bl::serial::SerializableObject< Node >

friend struct bl::serial::SerializableObject< Node >
friend

Definition at line 242 of file Conversation.hpp.


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