TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
Action.h
1#pragma once
2
3#include <string>
4#include <tt/world/Entity.h>
5#include <tt/world/Signature.h>
6#include <unordered_set>
7#include <tt/Role.h>
8
9#ifndef ACTION_H
10#define ACTION_H
11
12namespace tt {
21 class Action {
22 public:
24 int id;
26 std::string name;
27
28
32 Action():id(0), signature(nullptr) {};
33
48 const std::unordered_set<const Entity*>& getConsenting() const;
49
61 bool consents(Role role) const;
62
68 const std::string& toString() const;
69
75 const std::string& getDescription() const;
76
85 const std::string& getCode() const;
86
92 const Signature* getSignature() const;
93
94 friend std::ostream& operator<<(std::ostream& os, const Action& a);
95
96 friend void from_json(const nlohmann::json& j, Action& obj);
97 friend void to_json(nlohmann::json& j, const Action& obj);
98
99 bool operator==(const Action& rhs) const;
100 private:
105 std::vector<std::unique_ptr<Entity>> consenting;
107 mutable std::unordered_set<const Entity*> consentingSet;
108
110 std::string description;
112 std::string code;
114 std::unique_ptr<Signature> signature;
115 };
116
117 void from_json(const nlohmann::json& j, Action& obj);
118 void to_json(nlohmann::json& j, const Action& obj);
119
127 std::ostream& operator<<(std::ostream& os, const Action& a);
128}
129
130#endif
An action is a signed asset that causes a change in a story world's state.
Definition Action.h:21
const std::unordered_set< const Entity * > & getConsenting() const
Returns an unmodifiable set of entities in the story world representing the characters who need to ag...
Definition Action.cpp:9
bool consents(Role role) const
Returns true if the given story role controls one or more of the consenting characters for this actio...
Definition Action.cpp:19
std::string name
This asset's name, which is unique among other assets of the same type.
Definition Action.h:26
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 Action.cpp:46
const std::string & toString() const
Returns a string representation of this object.
Definition Action.cpp:36
const std::string & getDescription() const
Returns a human-readable natural language description of the object.
Definition Action.cpp:41
friend std::ostream & operator<<(std::ostream &os, const Action &a)
Override stream insertion operator to allow printing the Action class.
const Signature * getSignature() const
Returns the signature of this object.
Definition Action.cpp:51
Action()
Constructs a new blank action.
Definition Action.h:32
int id
This asset's ID number, which is unique among other assets of the same type.
Definition Action.h:24
A signature is a logical object that identifies a parameterized asset in a story world.
Definition Signature.h:22
Tandem Tales is a platform that enables short, paired storytelling exercises between two agents over ...
Definition Client.h:22
Role
Represents the two roles in a collaborative storytelling session: the Player, who typically controls ...
Definition Role.h:16
std::ostream & operator<<(std::ostream &os, const Client &a)
Override stream insertion operator to allow printing the Client class.
Definition Client.cpp:556