So even players can have stats.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
+ # Statistics for this entity.
+ fun stats: GameStats is abstract
+
# Load statistics for this `MEntity` if any.
fun load_statistics: nullable GameStats do
var key = self.key / "statistics"
# Load statistics for this `MEntity` if any.
fun load_statistics: nullable GameStats do
var key = self.key / "statistics"
var json = game.store.load_object(key)
return new GameStats.from_json(game, json)
end
var json = game.store.load_object(key)
return new GameStats.from_json(game, json)
end
-
- # Save statistics under this `MEntity`.
- fun save_statistics(stats: GameStats) do
- game.store.store_object(key / stats.key, stats.to_json)
- end
- # Statistics for this game instance.
- var stats: GameStats is lazy do
+ redef var stats is lazy do
return load_statistics or else new GameStats(game)
end
redef fun save do
super
return load_statistics or else new GameStats(game)
end
redef fun save do
super
- # Statistics for this player.
- var stats: GameStats is lazy do
+ redef var stats is lazy do
return load_statistics or else new GameStats(game)
end
redef fun save do
super
return load_statistics or else new GameStats(game)
end
redef fun save do
super
class StatisticsReactor
super GameReactor
class StatisticsReactor
super GameReactor
- redef fun react_event(game, e) do
- e.react_stats_event(game)
- end
+ redef fun react_event(game, e) do e.react_stats_event(game)
end
redef class GithubEvent
end
redef class GithubEvent