6#include <nlohmann/json.hpp>
7#include <tt/world/Value.h>
24 static constexpr std::string_view
TYPE =
"Constant";
34 std::variant<std::monostate, bool, std::int64_t, double>
value;
67 std::string
toString()
const override;
68 bool toBool()
const override;
70 virtual std::string_view
getType()
const override;
73 virtual bool equals(
const Value& other)
const override;
76 void from_json(
const nlohmann::json& j,
Constant& obj);
77 void to_json(nlohmann::json& j,
const Constant& obj);
A constant is a logical value that always exists in all story worlds, such as the boolean concepts of...
Definition Constant.h:21
Constant(float value)
Constructs a new constant that represents a decimal number.
Definition Constant.h:62
static constexpr std::string_view TYPE
Type identifier used for deserialization.
Definition Constant.h:24
virtual bool equals(const Value &other) const override
Used for polymorphic ==.
Definition Constant.cpp:35
double toNumber() const override
If this value represents a number, this method convert it into a double; all other values are convert...
Definition Constant.cpp:22
Constant(std::int64_t value)
Constructs a new constant that represents an integer.
Definition Constant.h:55
Constant(std::monostate value)
Constructs a new constant equivalent to NULL_CONSTANT.
Definition Constant.h:41
std::variant< std::monostate, bool, std::int64_t, double > value
The value object associated with this constant.
Definition Constant.h:34
static const Constant NULL_CONSTANT
A constant representing nothing or the absence of a value.
Definition Constant.h:27
virtual std::string_view getType() const override
Returns the type of value (either "Entity" or "Constant").
Definition Constant.cpp:30
static const Constant TRUE
A constant representing Boolean true.
Definition Constant.h:29
Constant(bool value)
Constructs a new constant that represents a Boolean value.
Definition Constant.h:48
static const Constant FALSE
A constant representing Boolean false.
Definition Constant.h:31
bool toBool() const override
If this value represents a Boolean, this method converts it into a bool; all other values are convert...
Definition Constant.cpp:17
std::string toString() const override
Returns a string representation of this object.
Definition Constant.cpp:9
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