nitrpg: fix warnings
authorAlexandre Terrasa <alexandre@moz-code.org>
Sun, 29 Nov 2015 08:59:40 +0000 (03:59 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 3 Dec 2015 04:09:01 +0000 (23:09 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

contrib/nitrpg/src/achievements.nit
contrib/nitrpg/src/events.nit
contrib/nitrpg/src/game.nit

index c1a8036..24fac20 100644 (file)
@@ -113,7 +113,11 @@ class Achievement
        #
        # Used to load achievements from storage.
        init from_json(game: Game, json: JsonObject) do
-               init(game, json["id"].to_s, json["name"].to_s, json["desc"].to_s, json["reward"].as(Int))
+               init(game,
+                       json["id"].as(String),
+                       json["name"].as(String),
+                       json["desc"].as(String),
+                       json["reward"].as(Int))
        end
 
        redef fun to_json do
@@ -123,6 +127,7 @@ class Achievement
                json["desc"] = desc
                json["reward"] = reward
                json["game"] = game.key
+               var owner = self.owner
                if owner != null then json["owner"] = owner.key
                return json
        end
index 2573a58..c540dc5 100644 (file)
@@ -24,6 +24,7 @@ import game
 
 redef class GameEntity
 
+       # Register a new game event for this entity.
        fun add_event(event: GameEvent) do
                event.owner = self
                event.save
@@ -98,9 +99,9 @@ class GameEvent
        #
        # Used to load events from json storage.
        init from_json(game: Game, json: JsonObject) do
-               init(game, json["kind"].to_s, json["data"].as(JsonObject))
-               internal_id = json["internal_id"].to_s
-               time = new ISODate.from_string(json["time"].to_s)
+               init(game, json["kind"].as(String), json["data"].as(JsonObject))
+               internal_id = json["internal_id"].as(String)
+               time = new ISODate.from_string(json["time"].as(String))
        end
 
        redef fun to_json do
@@ -110,6 +111,7 @@ class GameEvent
                json["time"] = time.to_s
                json["data"] = data
                json["game"] = game.key
+               var owner = self.owner
                if owner != null then json["owner"] = owner.key
                return json
        end
index 6e04b18..504c445 100644 (file)
@@ -232,7 +232,7 @@ class Player
        #
        # Used to load players from saved data.
        init from_json(game: Game, json: JsonObject) do
-               init(game, json["name"].to_s)
+               init(game, json["name"].as(String))
                nitcoins = json["nitcoins"].as(Int)
        end