TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
tt::Entity Class Reference

An entity is an asset that represents a character, object, place, or idea in a story world. More...

#include <tt/world/Entity.h>

Inheritance diagram for tt::Entity:
Collaboration diagram for tt::Entity:

Public Member Functions

bool isPlayer () const
 Returns true if this entity represents the player character in its story world.
const std::string & getDescription () const
 Returns a human-readable natural language description of the object.
const std::string & getCode () const
 Returns a string of 1's and 0's that uniquely represents this object among other objects of the same type in the same story world.
std::string toString () const override
 Returns a string representation of this object.
virtual const Entity * toEntity () const override
 If this value represents an tt::Entity, this method returns a pointer to that entity; all other values return nullptr.
virtual std::string_view getType () const override
 Returns the type of value (either "Entity" or "Constant").
Public Member Functions inherited from tt::Value
virtual ~Value ()=default
 Virtual destructor so Entity and Value can have their own.
virtual bool toBool () const
 If this value represents a Boolean, this method converts it into a bool; all other values are converted to false.
virtual double toNumber () const
 If this value represents a number, this method convert it into a double; all other values are converted to NaN.

Public Attributes

int id
 This asset's ID number, which is unique among other assets of the same type.
std::string name
 This asset's name, which is unique among other assets of the same type.

Static Public Attributes

static constexpr std::string_view TYPE = "Entity"
 Type identifier used for deserialization.

Protected Member Functions

virtual bool equals (const Value &other) const override
 Used for polymorphic ==.

Detailed Description

An entity is an asset that represents a character, object, place, or idea in a story world.

Author
Gage Birchmeier

Member Function Documentation

◆ equals()

bool tt::Entity::equals ( const Value & other) const
overrideprotectedvirtual

Used for polymorphic ==.

Parameters
otheranother value object
Returns
whether the two values are equivalent

Implements tt::Value.

◆ getCode()

const std::string & tt::Entity::getCode ( ) const

Returns a string of 1's and 0's that uniquely represents this object among other objects of the same type in the same story world.

Every encoded object of the same type should return a string of the same length, even if it must be padded with 0's.

Returns
a string of 1's and 0's

◆ getDescription()

const std::string & tt::Entity::getDescription ( ) const

Returns a human-readable natural language description of the object.

Returns
a human-readable natural language description of the object

◆ getType()

std::string_view tt::Entity::getType ( ) const
overridevirtual

Returns the type of value (either "Entity" or "Constant").

Used in JSON deserialization

Returns
a string describing the type of value

Reimplemented from tt::Value.

◆ isPlayer()

bool tt::Entity::isPlayer ( ) const

Returns true if this entity represents the player character in its story world.

By default, the entity with ID number 0 is assumed to be the player character.

Returns
true if this entity represents the player character, false otherwise

◆ toEntity()

const Entity * tt::Entity::toEntity ( ) const
overridevirtual

If this value represents an tt::Entity, this method returns a pointer to that entity; all other values return nullptr.

Returns
a pointer to an entity, or nullptr if this value is not an entity

Reimplemented from tt::Value.

◆ toString()

std::string tt::Entity::toString ( ) const
overridevirtual

Returns a string representation of this object.

Returns
a string describing this object

Reimplemented from tt::Value.


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