grepolis-js
v1.3.10
Published
Grepolis api for node.js
Downloads
45
Maintainers
Readme
Require
var grepojs = require("grepolis-js");
Load Alliance Data $id, $name, $points, $towns, $members, $rank
grepojs.loadAllianceData(function () {
grepojs.data.each("SELECT points, name FROM alliances", function (err, row) {
console.log(row.points + ": " + row.name);
});
});
Load Player Data $id, $name, $alliance_id, $points, $rank, $towns
grepojs.loadPlayerData(function () {
grepojs.data.each("SELECT points, name FROM players WHERE rank < 15", function (err, row) {
console.log(row.points + ": " + row.name);
});
});
Load Island Data $id, $x, $y, $island_type, $available_towns, $good, $bad
grepojs.loadIslandData(function () {
grepojs.data.each("SELECT id, x, y FROM islands", function (err, row) {
console.log(row.id + ": " + row.x + "," + row.y);
});
});
Load Town Data $id, $player_id, $name, $island_x, $island_y, $number_on_island, $points
grepojs.loadTownData(function () {
grepojs.data.each("SELECT player_id, name FROM towns", function (err, row) {
console.log(row.player_id + ": " + row.name);
});
});
You can nest the load functions
grepojs.loadPlayerData(function () {
grepojs.loadTownData(function () {
grepojs.data.each("SELECT player_id, name FROM towns", function (err, row) {
grepojs.data.each("SELECT name FROM players WHERE id = " + row.player_id, function (err2, row2) {
console.log(row2.name + ": " + row.name);
})
});
});
});
You can also use grepojs.data outside of the load_data function call backs, as long as the data you want to read has already been loaded.
Load all data from the set data url
This will run he start function after all of the data has been loaded into the grepojs.data object.
function start() {
console.log("Done Loading");
}
grepojs.load(start);
Change Data URL
grepojs.WorldDataUrl = "https://us71.grepolis.com/data/";