nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: Mock Github API tests
[nit.git]
/
contrib
/
nitrpg
/
src
/
game.nit
diff --git
a/contrib/nitrpg/src/game.nit
b/contrib/nitrpg/src/game.nit
index
6e04b18
..
5413f43
100644
(file)
--- a/
contrib/nitrpg/src/game.nit
+++ b/
contrib/nitrpg/src/game.nit
@@
-42,10
+42,10
@@
interface GameEntity
fun key: String is abstract
# Saves `self` in db.
fun key: String is abstract
# Saves `self` in db.
- fun save do game.db.collection(collection_name).save(to_json)
+ fun save do game.db.collection(collection_name).save(to_json_object)
# Json representation of `self`.
# Json representation of `self`.
- fun to_json: JsonObject do
+ fun to_json_object: JsonObject do
var json = new JsonObject
json["_id"] = key
return json
var json = new JsonObject
json["_id"] = key
return json
@@
-75,7
+75,7
@@
class Game
redef var key = name is lazy
# Mongo server url where this game data are stored.
redef var key = name is lazy
# Mongo server url where this game data are stored.
- var mongo_url = "mongodb://localhost:27017" is writable
+ var mongo_url = "mongodb://mongo:27017" is writable
# Mongo db client.
var client = new MongoClient(mongo_url) is lazy
# Mongo db client.
var client = new MongoClient(mongo_url) is lazy
@@
-102,7
+102,7
@@
class Game
# Used to load entities from saved data.
fun from_json(json: JsonObject) do end
# Used to load entities from saved data.
fun from_json(json: JsonObject) do end
- redef fun to_json do
+ redef fun to_json_object do
var json = super
json["name"] = name
return json
var json = super
json["name"] = name
return json
@@
-166,7
+166,7
@@
class Game
end
# Erase all saved data for this game.
end
# Erase all saved data for this game.
- fun clear do db.collection(collection_name).remove(to_json)
+ fun clear do db.collection(collection_name).remove(to_json_object)
# Verbosity level used fo stdout.
#
# Verbosity level used fo stdout.
#
@@
-232,11
+232,11
@@
class Player
#
# Used to load players from saved data.
init from_json(game: Game, json: JsonObject) do
#
# 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
nitcoins = json["nitcoins"].as(Int)
end
- redef fun to_json do
+ redef fun to_json_object do
var json = super
json["game"] = game.key
json["name"] = name
var json = super
json["game"] = game.key
json["name"] = name