From: Alexandre Terrasa Date: Fri, 6 Feb 2015 22:49:43 +0000 (+0100) Subject: contrib/nitrpg: introduce Game::save_in X-Git-Tag: v0.7.2~14^2~4 X-Git-Url: http://nitlanguage.org?hp=4cbea9583b82cd5f6e96f55e59c9b6f6b8fb3688 contrib/nitrpg: introduce Game::save_in Also changes the Game::save documentation Signed-off-by: Alexandre Terrasa --- diff --git a/contrib/nitrpg/src/game.nit b/contrib/nitrpg/src/game.nit index 89c9655..9c71566 100644 --- a/contrib/nitrpg/src/game.nit +++ b/contrib/nitrpg/src/game.nit @@ -38,9 +38,18 @@ interface GameEntity # Uniq key used for data storage. fun key: String is abstract - # Save `self` as a json object. + # Saves the `self` state in game data. + # + # Date are stored under `self.key`. fun save do game.store.store_object(key, to_json) + # Saves `self` state into `target` key data. + # + # Data are stored under `target.key / self.key`. + fun save_in(target: GameEntity) do + game.store.store_object(target.key / key, to_json) + end + # Json representation of `self`. fun to_json: JsonObject do return new JsonObject