TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
Status.h
1#include <vector>
2#include <memory>
3#include <tt/Role.h>
4#include <tt/world/Turn.h>
5#include <tt/world/State.h>
6#include <tt/world/Ending.h>
7
8#pragma once
9
10#ifndef STATUS_H
11#define STATUS_H
12
13namespace tt {
22 class Status {
23 public:
26
27 // default constructor for json deserialization
28 Status(): state(nullptr), ending(nullptr), role(Role::NONE) {}
29
35 std::string toString() const;
36
43 const std::vector<const Turn *>& getHistory() const;
53 const std::vector<const Entity *>& getDescriptions() const;
61 const std::vector<const Turn *>& getChoices() const;
68 const State* getState() const;
75 const Ending* getEnding() const;
76
77 friend void from_json(const nlohmann::json& j, Status& obj);
78 friend void to_json(nlohmann::json& j, const Status& obj);
79 friend std::ostream& operator<<(std::ostream& os, const Status& a);
80
81 private:
83 std::vector<std::unique_ptr<Turn>> history;
85 std::vector<std::unique_ptr<Entity>> descriptions;
87 std::vector<std::unique_ptr<Turn>> choices;
89 std::unique_ptr<State> state;
94 std::unique_ptr<Ending> ending;
95
96 mutable std::vector<const Turn *> historyPtrs;
97 mutable std::vector<const Entity *> descriptionsPtrs;
98 mutable std::vector<const Turn *> choicesPtrs;
99 };
100
101 void from_json(const nlohmann::json& j, Status& obj);
102 void to_json(nlohmann::json& j, const Status& obj);
103
111 std::ostream& operator<<(std::ostream& os, const Status& a);
112}
113
114#endif
An ending is a signed asset that represents one of several possible ways a story can end.
Definition Ending.h:17
A state is an assignment of values to each variable in a story world.
Definition State.h:18
A status contains the full history of a session in a story world, a description of its current state,...
Definition Status.h:22
Role role
The role of the participant to whom this status is being described.
Definition Status.h:25
const std::vector< const Turn * > & getChoices() const
Returns an unmodifiable list of next turns that this role can take next in the session.
Definition Status.cpp:39
const State * getState() const
Returns a state that gives the current value of all the story world's variables.
Definition Status.cpp:51
const Ending * getEnding() const
Returns the ending the session's story has reached, or null if the story has not yet ended.
Definition Status.cpp:56
const std::vector< const Turn * > & getHistory() const
Returns an unmodifiable list of all turns that have happened so far in the session.
Definition Status.cpp:15
friend std::ostream & operator<<(std::ostream &os, const Status &a)
Override stream insertion operator to allow printing the Status class.
const std::vector< const Entity * > & getDescriptions() const
Returns an unmodifiable list of all the entities that this role can currently see.
Definition Status.cpp:27
std::string toString() const
Returns a string representation of this object.
Definition Status.cpp:7
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
@ 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