1#include "gamestatistics.h"
3GameStatistics::GameStatistics() =
default;
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) {
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();
20 if (json.contains(AVERAGE_PLAYERS_COUNT) &&
21 json[AVERAGE_PLAYERS_COUNT].isDouble()) {
22 average_players_count = json[AVERAGE_PLAYERS_COUNT].toInt();
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();
28 if (json.contains(TOTAL_GAMES_PLAYED) &&
29 json[TOTAL_GAMES_PLAYED].isDouble()) {
30 total_games_played = json[TOTAL_GAMES_PLAYED].toInt();
34void GameStatistics::write(QJsonObject &json) {