app/game_recorder.h

turns a played game into an archived one (PLAN §4).

A GameSessionListener that accumulates the move list as the game runs and hands a finished GameRecord to a sink on game-over. Attach one to the session and every finished game is archived; attach none and nothing is.

Only finished games are recorded. A game abandoned mid-play (stopped, reset, the board unplugged) is dropped: a review list of half-games nobody chose to finish is noise, and an incomplete record would still claim a result.

namespace kirin
class GameRecorder : public kirin::GameSessionListener
#include <game_recorder.h>

Public Types

using Sink = std::function<void(const GameRecord&)>

Public Functions

GameRecorder(Sink sink, std::string deviceId = "", bool pendingUpload = false)
inline void setPendingUpload(bool on)
virtual void onGameStarted(const GameStartInfo&) override
virtual void onMovePlayed(const MoveEvent&) override
virtual void onGameOver(const GameOverInfo&) override
inline const GameRecord &current() const

Private Members

Sink sink_
std::string deviceId_
bool pendingUpload_
GameRecord current_
bool inGame_ = false