contrib/nitrpg: introduce Game::save_in
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 6 Feb 2015 22:49:43 +0000 (23:49 +0100)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 11 Feb 2015 01:10:04 +0000 (02:10 +0100)
Also changes the Game::save documentation

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

contrib/nitrpg/src/game.nit

index 89c9655..9c71566 100644 (file)
@@ -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