Know where you are
In this chapter you will learn how to find out where you are and your surroundings.
After each function call, the server returns your current location and available items at that location. The data is the return value of that function call:
Python
game = CodeVille()
response = game.connect("your_name", "")
location = response["location"]
x = location["x"]
y = location["y"]
response = game.execute("move", {"direction": "east"})
print (response)
Java
CodeVilleResponse response = game.connect("your_name", "");
int x = response.location.x;
int y = response.location.y;
response = game.execute("move direction:east");
Sample data contained in game response:
{
"location":{
"x":8,
"y":3
},
"stats":{
"experience":2,
"level":1,
"attack":11,
"defense":11,
"health":110
},
"items":[
{
"type":"coin",
"count":1,
}
],
"monsters":[
{
"type":"chicken",
"attack":1,
"defense":1,
"health":1,
"coins":1
},
{
"type":"bat",
"attack":1,
"defense":1,
"health":2,
"coins":2
}
]
}