-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track and persist various game stats. (#43)
* Track and persist various game stats. * Cleanup.
- Loading branch information
Showing
15 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace spaced { | ||
enum class Instigator { ePlayer, eEnemy, eOther }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <djson/json.hpp> | ||
#include <spaced/services/stats.hpp> | ||
|
||
namespace spaced { | ||
void Stats::from(dj::Json const& json) { | ||
from_json(json["run_count"], run_count); | ||
|
||
auto const& in_game = json["game"]; | ||
from_json(in_game["play_count"], game.play_count); | ||
|
||
auto const& in_player = json["player"]; | ||
from_json(in_player["powerups_collected"], player.powerups_collected); | ||
from_json(in_player["shots_fired"], player.shots_fired); | ||
from_json(in_player["enemies_poofed"], player.enemies_poofed); | ||
from_json(in_player["death_count"], player.death_count); | ||
} | ||
|
||
void Stats::to(dj::Json& out) const { | ||
to_json(out["run_count"], run_count); | ||
|
||
auto& out_game = out["game"]; | ||
to_json(out_game["play_count"], game.play_count); | ||
|
||
auto& out_player = out["player"]; | ||
to_json(out_player["powerups_collected"], player.powerups_collected); | ||
to_json(out_player["shots_fired"], player.shots_fired); | ||
to_json(out_player["enemies_poofed"], player.enemies_poofed); | ||
to_json(out_player["death_count"], player.death_count); | ||
} | ||
} // namespace spaced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <spaced/services/service.hpp> | ||
#include <cstdint> | ||
|
||
namespace dj { | ||
class Json; | ||
} | ||
|
||
namespace spaced { | ||
struct Stats : IService { | ||
struct { | ||
std::int64_t play_count{}; | ||
} game{}; | ||
|
||
struct { | ||
std::int64_t powerups_collected{}; | ||
std::int64_t shots_fired{}; | ||
std::int64_t enemies_poofed{}; | ||
std::int64_t death_count{}; | ||
} player{}; | ||
|
||
std::int64_t run_count{}; | ||
|
||
void from(dj::Json const& json); | ||
void to(dj::Json& out) const; | ||
}; | ||
} // namespace spaced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters