forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highscores.h
46 lines (38 loc) · 1.05 KB
/
highscores.h
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
38
39
40
41
42
43
44
45
46
#ifndef _HIGHSCORES_H
#define _HIGHSCORES_H
#include "util.h"
class View;
class FileSharing;
class Options;
class Highscores {
public:
Highscores(const string& localPath, FileSharing&, Options*);
struct Score {
static optional<Score> parse(const string& buf);
bool operator == (const Score&) const;
string toString() const;
string gameId;
string playerName;
string worldName;
string gameResult;
bool gameWon;
int points;
int turns;
enum GameType { KEEPER, ADVENTURER } gameType;
};
void present(View*, optional<Score> lastAdded = none) const;
void add(Score);
private:
static vector<Score> fromStream(istream&);
static vector<Score> fromFile(const string& path);
static vector<Score> fromSync(FileSharing&);
static vector<Score> fromString(const string&);
static void saveToFile(const vector<Score>&, const string& path);
static void sortScores(vector<Score>&);
string localPath;
FileSharing& fileSharing;
vector<Score> localScores;
vector<Score> remoteScores;
Options* options;
};
#endif