TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
Entity.h
1#pragma once
2
3#include <string>
4#include <nlohmann/json.hpp>
5#include <tt/world/Value.h>
6
7#ifndef ENTITY_H
8#define ENTITY_H
9
10namespace tt {
17 class Entity : public Value {
18 public:
20 static constexpr std::string_view TYPE = "Entity";
21
23 int id;
25 std::string name;
26
27 // default constructor for json deserialization
28 Entity():id(0) {};
29
40 bool isPlayer() const;
41
47 const std::string& getDescription() const;
48
57 const std::string& getCode() const;
58
59 std::string toString() const override;
60 virtual const Entity * toEntity() const override;
61 virtual std::string_view getType() const override;
62
63 friend void from_json(const nlohmann::json& j, Entity& msg);
64 friend void to_json(nlohmann::json& j, const Entity& msg);
65
66 protected:
67 virtual bool equals(const Value& other) const override;
68
69 private:
71 std::string description;
73 std::string code;
74 };
75 void from_json(const nlohmann::json& j, Entity& msg);
76 void to_json(nlohmann::json& j, const Entity& msg);
77}
78
79#endif
An entity is an asset that represents a character, object, place, or idea in a story world.
Definition Entity.h:17
int id
This asset's ID number, which is unique among other assets of the same type.
Definition Entity.h:23
std::string name
This asset's name, which is unique among other assets of the same type.
Definition Entity.h:25
virtual const Entity * toEntity() const override
If this value represents an tt::Entity, this method returns a pointer to that entity; all other value...
Definition Entity.cpp:25
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 ...
Definition Entity.cpp:15
bool isPlayer() const
Returns true if this entity represents the player character in its story world.
Definition Entity.cpp:5
virtual bool equals(const Value &other) const override
Used for polymorphic ==.
Definition Entity.cpp:35
const std::string & getDescription() const
Returns a human-readable natural language description of the object.
Definition Entity.cpp:10
static constexpr std::string_view TYPE
Type identifier used for deserialization.
Definition Entity.h:20
virtual std::string_view getType() const override
Returns the type of value (either "Entity" or "Constant").
Definition Entity.cpp:30
std::string toString() const override
Returns a string representation of this object.
Definition Entity.cpp:20
A value is a logical expression which evaluates to itself.
Definition Value.h:17
Tandem Tales is a platform that enables short, paired storytelling exercises between two agents over ...
Definition Client.h:22