Cavoke  1.1.0
A Platform for creating and hosting multiplayer turn-based board games
Loading...
Searching...
No Matches
gamestatistics.cpp
1#include "gamestatistics.h"
2
3GameStatistics::GameStatistics() = default;
4
5GameStatistics::GameStatistics(int _average_duration_sec,
6 int _average_players_count,
7 int _total_time_played_sec,
8 int _total_games_played)
9 : average_duration_sec(_average_duration_sec),
10 average_players_count(_average_players_count),
11 total_time_played_sec(_total_time_played_sec),
12 total_games_played(_total_games_played) {
13}
14
15void GameStatistics::read(const QJsonObject &json) {
16 if (json.contains(AVERAGE_DURATION_SEC) &&
17 json[AVERAGE_DURATION_SEC].isDouble()) {
18 average_duration_sec = json[AVERAGE_DURATION_SEC].toInt();
19 }
20 if (json.contains(AVERAGE_PLAYERS_COUNT) &&
21 json[AVERAGE_PLAYERS_COUNT].isDouble()) {
22 average_players_count = json[AVERAGE_PLAYERS_COUNT].toInt();
23 }
24 if (json.contains(TOTAL_TIME_PLAYED_SEC) &&
25 json[TOTAL_TIME_PLAYED_SEC].isDouble()) {
26 total_time_played_sec = json[TOTAL_TIME_PLAYED_SEC].toInt();
27 }
28 if (json.contains(TOTAL_GAMES_PLAYED) &&
29 json[TOTAL_GAMES_PLAYED].isDouble()) {
30 total_games_played = json[TOTAL_GAMES_PLAYED].toInt();
31 }
32}
33
34void GameStatistics::write(QJsonObject &json) {
35 assert(false); // Should not be used
36}