Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/platform/StarStatisticsService.hpp
blob: 16f5cceb0d8d4ec29c4b4d244751d4ab70e48a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include "StarJson.hpp"

namespace Star {

STAR_CLASS(StatisticsService);

class StatisticsService {
public:
  virtual ~StatisticsService() = default;

  virtual bool initialized() const = 0;
  virtual Maybe<String> error() const = 0;

  // The functions below aren't valid unless initialized() returns true and
  // error() is empty.

  // setStat should return false for stats or types that aren't known by the
  // service, without reporting an error.
  // By sending all stats to the StatisticsService, we can configure collection
  // of new stats entirely on the service, without any modifications to the game.
  virtual bool setStat(String const& name, String const& type, Json const& value) = 0;
  virtual Json getStat(String const& name, String const& type, Json def = {}) const = 0;

  // reportEvent should return false if the service doesn't handle this event.
  virtual bool reportEvent(String const& name, Json const& fields) = 0;

  virtual bool unlockAchievement(String const& name) = 0;
  virtual StringSet achievementsUnlocked() const = 0;

  virtual void refresh() = 0;
  virtual void flush() = 0;
  virtual bool reset() = 0;
};

}