Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ur_records.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPRECORDS_H
13#define ZOAPPRECORDS_H
14
15#include <toymaker/engine/sim_system.hpp>
16
19
20
26struct GameRecord {
27 GameScoreData mSummary;
28 PlayerData mPlayerA;
29 PlayerData mPlayerB;
30};
31
37class UrRecords: public ToyMaker::SimObjectAspect<UrRecords> {
38public:
39 UrRecords(): SimObjectAspect<UrRecords>{0} {}
40 inline static std::string getSimObjectAspectTypeName() { return "UrRecords"; }
41 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
42 std::shared_ptr<BaseSimObjectAspect> clone() const override;
43
44 void submitRecord(const GameRecord& gameRecord);
45
46 inline GameRecord getLatestRecord() const { return mLoadedRecords.back(); }
47 inline std::vector<GameRecord> getAllRecords() const { return mLoadedRecords; }
48
49private:
50 static void ApplyInvariants(const GameRecord& gameRecord);
51 void onActivated() override;
52 void onDeactivated() override;
53
54 std::vector<GameRecord> mLoadedRecords {};
55 std::string mRecordsPath {};
56};
57
58void from_json(const nlohmann::json& json, GameRecord& gameRecord);
59void to_json(nlohmann::json& json, const GameRecord& gameRecord);
60
61#endif
The class containing the interface to the data model for the whole game (Game of Ur).
Contains methods to convert data from its-in game representation to its JSON representation,...
The details of a single completed game.
Definition ur_records.hpp:26
Data returned by GameOfUrModel when queried for scores.
Definition model.hpp:151
Data returned by GameOfUrModel when queried about a player.
Definition model.hpp:229