TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
Turn.h
1#include <string>
2#include <tt/Role.h>
3#include <tt/world/Action.h>
4
5#pragma once
6
7#ifndef TURN_H
8#define TURN_H
9
10namespace tt {
26 class Turn {
27 public:
29 enum Type {
35
41
46
52 };
53
58
59 Turn(): role(NONE), type(PASS), action(nullptr) {};
60
66 std::string toString() const;
67
73 const std::string& getDescription() const;
74
83 const std::string& getCode() const;
84
90 const Action* getAction() const;
91
92 friend std::ostream& operator<<(std::ostream& os, const Turn& a);
93
94 friend void from_json(const nlohmann::json& j, Turn& obj);
95 friend void to_json(nlohmann::json& j, const Turn& obj);
96
97 private:
99 std::unique_ptr<Action> action;
100
102 std::string description;
103
105 std::string code;
106 };
107
108 void from_json(const nlohmann::json& j, Turn& obj);
109 void to_json(nlohmann::json& j, const Turn& obj);
110
118 std::ostream& operator<<(std::ostream& os, const Turn& a);
119
126 std::string ttos(Turn::Type type);
127
135 Turn::Type stot(std::string s);
136}
137
138#endif
An action is a signed asset that causes a change in a story world's state.
Definition Action.h:21
A turn is one participant in a session communicating their intentions for an action to the other part...
Definition Turn.h:26
const Action * getAction() const
Returns the action associated with this turn.
Definition Turn.cpp:24
Type
The kind of turn being taken.
Definition Turn.h:29
@ FAIL
Used to reject a proposed action.
Definition Turn.h:45
@ PROPOSE
Used when one participant wants to suggest taking an action that requires the approval of their partn...
Definition Turn.h:34
@ SUCCEED
Used when one participant agrees to take a proposed action, or when a participant can take an action ...
Definition Turn.h:40
@ PASS
Used when one participant does not want to act and wants to allow their partner to act instead.
Definition Turn.h:51
std::string toString() const
Returns a string representation of this object.
Definition Turn.cpp:6
Type type
The kind of turn being taken.
Definition Turn.h:57
const std::string & getDescription() const
Returns a human-readable natural language description of the object.
Definition Turn.cpp:14
Role role
The role of the participant taking this turn.
Definition Turn.h:55
friend std::ostream & operator<<(std::ostream &os, const Turn &a)
Override stream insertion operator to allow printing the Turn class.
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 Turn.cpp:19
Tandem Tales is a platform that enables short, paired storytelling exercises between two agents over ...
Definition Client.h:22
std::string ttos(Turn::Type type)
Utility function to get the string representation of a tt::Turn type.
Definition Turn.cpp:59
Turn::Type stot(std::string s)
Utility function to get the correct tt::Turn type enum from the string representation.
Definition Turn.cpp:76
Role
Represents the two roles in a collaborative storytelling session: the Player, who typically controls ...
Definition Role.h:16
@ NONE
No role, used as a "null" value.
Definition Role.h:32
std::ostream & operator<<(std::ostream &os, const Client &a)
Override stream insertion operator to allow printing the Client class.
Definition Client.cpp:556