From 9905d6044172da5658c765218a738cf164c71943 Mon Sep 17 00:00:00 2001 From: Felix Date: Sun, 21 Aug 2016 21:13:26 +0200 Subject: [PATCH] Mega Update - Removed mongodb - Validate dumped assets (game master, asset digest, models) - Added pokemon_owned table - Added items to users table - Outsourced table structures into seperate folder - Added pokemongo-protobuf lib - Reworked mysql wrapper - Dump game master - Allow ptc connections, but alert, that progress wont be saved - Fixed https://github.com/maierfelix/POGOserver/issues/13 --- cfg.js.example | 11 +- package.json | 1 + src/db/create.js | 48 + src/db/get.js | 51 + src/db/index.js | 74 + src/db/mongo.js | 152 -- src/db/mysql.js | 204 --- src/db/query.js | 113 ++ src/db/tables/owned_pkmn.table | 30 + src/db/tables/users.table | 47 + src/index.js | 25 +- src/packets/Envelopes.AuthTicket.js | 15 +- src/packets/Responses.CheckAwardedBadges.js | 16 +- .../Responses.DownloadRemoteConfigVersion.js | 20 +- src/packets/Responses.DownloadSettings.js | 79 +- src/packets/Responses.Encounter.js | 103 +- src/packets/Responses.FortDetails.js | 40 +- src/packets/Responses.FortSearch.js | 42 +- src/packets/Responses.GetAssetDigest.js | 2 - src/packets/Responses.GetDownloadUrls.js | 21 +- src/packets/Responses.GetHatchedEggs.js | 20 +- src/packets/Responses.GetInventory.js | 1367 ++++++++++++++-- src/packets/Responses.GetMapObjects.js | 1406 +++++++++++++++-- src/packets/Responses.GetPlayer.js | 64 +- src/packets/Responses.GetPlayerProfile.js | 369 ++--- src/packets/Responses.ItemTemplates.js | 83 +- src/packets/Responses.LevelUpRewards.js | 16 +- src/packets/Responses.SetAvatar.js | 13 +- src/packets/Responses.SetFavoritePokemon.js | 11 +- src/packets/Responses.SfidaActionLog.js | 683 +++++++- src/player.js | 49 +- src/request.js | 44 +- src/response.js | 103 +- src/setup.js | 88 +- src/utils.js | 25 + 35 files changed, 4160 insertions(+), 1275 deletions(-) create mode 100644 src/db/create.js create mode 100644 src/db/get.js create mode 100644 src/db/index.js delete mode 100644 src/db/mongo.js delete mode 100644 src/db/mysql.js create mode 100644 src/db/query.js create mode 100644 src/db/tables/owned_pkmn.table create mode 100644 src/db/tables/users.table diff --git a/cfg.js.example b/cfg.js.example index 39b6ffe..a689706 100644 --- a/cfg.js.example +++ b/cfg.js.example @@ -19,13 +19,8 @@ export default { MYSQL_DB_NAME: "pogosql", MYSQL_USERNAME: "root", MYSQL_PASSWORD: "", - MYSQL_TABLE: "users", - - // MongoDB credentials - MONGO_PORT: 27017, - MONGO_HOST_IP: "127.0.0.1", - MONGO_DB_NAME: "pokemongo", - MONGO_COLLECTION_USERS: "users", + MYSQL_USERS_TABLE: "users", + MYSQL_OWNED_PKMN_TABLE: "owned_pkmn", // Used for asset download session DOWNLOAD_PROVIDER: "GOOGLE", @@ -36,7 +31,7 @@ export default { GMAPS_KEY: "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM", // Server debug options - DEBUG_DUMP_PATH: "./logs/", + DEBUG_DUMP_PATH: "logs/", DEBUG_DUMP_TRAFFIC: true, DEBUG_LOG_REQUESTS: true, diff --git a/package.json b/package.json index c691381..5d6ca1e 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "directory-tree": "^1.1.0", "nodegit": "^0.14.1", "fs-extra": "^0.30.0", + "pokemongo-protobuf": "^1.10.0", "pcrypt": "git+https://github.com/laverdet/pcrypt.git" }, "devDependencies": {} diff --git a/src/db/create.js b/src/db/create.js new file mode 100644 index 0000000..545d0d8 --- /dev/null +++ b/src/db/create.js @@ -0,0 +1,48 @@ +import fs from "fs"; +import CFG from "../../cfg"; + +export function createTableIfNoExists(name) { + return new Promise((resolve) => { + this.db.instance.query(`SHOW TABLES LIKE '${name}';`, (e, rows, fields) => { + if (e) console.log(e); + else { + // exists + if (rows && rows.length) resolve(); + // create user table + else this.createTables().then(resolve); + } + }); + }); +} + +/** + * @param {String} name + */ +export function createTables() { + return new Promise((resolve) => { + this.createTable(CFG.MYSQL_USERS_TABLE).then(() => { + this.createTable(CFG.MYSQL_OWNED_PKMN_TABLE).then(() => { + resolve(); + }); + }); + }); +} + +export function createTable(name) { + + this.print(`Creating table ${name}`, 36); + + let query = ` + CREATE TABLE ${name} ( + ${fs.readFileSync(__dirname + "/tables/" + name + ".table", "utf8")} + ) ENGINE=InnoDB; + `; + + return new Promise((resolve) => { + this.db.instance.query(query, (e, rows) => { + if (e) console.log(e); + else resolve(); + }); + }); + +} \ No newline at end of file diff --git a/src/db/get.js b/src/db/get.js new file mode 100644 index 0000000..bd84334 --- /dev/null +++ b/src/db/get.js @@ -0,0 +1,51 @@ +import CFG from "../../cfg"; + +/** + * @param {String} column + * @param {String} value + * @param {String} table + */ +export function getQueryByColumnFromTable(column, value, table) { + return new Promise((resolve) => { + this.db.instance.query(`SELECT * FROM ${table} WHERE ${column}=? LIMIT 1`, [value], (e, rows) => { + if (e) console.log(e); + if (rows && rows.length) resolve(rows[0]); + else resolve(void 0); + }); + }); +} + +/** + * @param {String} column + * @param {String} value + */ +export function getPkmnByColumn(column, value) { + return new Promise((resolve) => { + this.getQueryByColumnFromTable(column, value, CFG.MYSQL_OWNED_PKMN_TABLE).then((query) => { + resolve(query); + }); + }); +} + +/** + * @param {String} column + * @param {String} value + */ +export function getUserByColumn(column, value) { + return new Promise((resolve) => { + this.getQueryByColumnFromTable(column, value, CFG.MYSQL_USERS_TABLE).then((query) => { + resolve(query); + }); + }); +} + +/** + * @param {String} email + */ +export function getUserByEmail(email) { + return new Promise((resolve) => { + this.getQueryByColumnFromTable("email", email, CFG.MYSQL_USERS_TABLE).then((query) => { + resolve(query); + }); + }); +} diff --git a/src/db/index.js b/src/db/index.js new file mode 100644 index 0000000..217132b --- /dev/null +++ b/src/db/index.js @@ -0,0 +1,74 @@ +import fs from "fs"; +import mysql from "mysql"; + +import CFG from "../../cfg"; + +export function setupConnection() { + + let connection = mysql.createConnection({ + host : CFG.MYSQL_HOST_IP, + port : CFG.MYSQL_PORT, + database : CFG.MYSQL_DB_NAME, + user : CFG.MYSQL_USERNAME, + password : CFG.MYSQL_PASSWORD + }); + + return new Promise((resolve) => { + connection.connect((error) => { + if (error) { + this.print("MySQL " + error, 31); + this.retry("Retrying again in ", () => this.setupConnection().then(resolve), 5); + return void 0; + } + this.db.instance = connection; + this.createTableIfNoExists(CFG.MYSQL_USERS_TABLE).then(() => { + this.createTableIfNoExists(CFG.MYSQL_OWNED_PKMN_TABLE).then(() => { + this.print(`\x1b[36;1mMySQL\x1b[0m\x1b[32;1m connection established\x1b[0m`); + resolve(); + }); + }); + }); + connection.on("error", (error) => { + this.print("MySQL " + error, 31); + this.retry("Trying to reconnect in ", () => this.setupConnection().then(resolve), 5); + }); + }); + +} + +/** + * @param {Function} resolve + */ +export function closeConnection(resolve) { + this.db.instance.end(() => { + resolve(); + }); +} + +/** + * @param {Object} obj + */ +export function createUser(obj) { + + let query = this.getUserQuery("INSERT INTO", ""); + let data = this.getUserQueryData(obj); + + return new Promise((resolve) => { + this.db.instance.query(query, data, resolve); + }); + +} + +/** + * @param {Object} obj + */ +export function updateUser(obj) { + + let query = this.getUserQuery("UPDATE", "WHERE email=? LIMIT 1"); + let data = this.getUserQueryData(obj); + + return new Promise((resolve) => { + this.db.instance.query(query, data, resolve); + }); + +} \ No newline at end of file diff --git a/src/db/mongo.js b/src/db/mongo.js deleted file mode 100644 index da6c8d7..0000000 --- a/src/db/mongo.js +++ /dev/null @@ -1,152 +0,0 @@ -import mongodb from "mongodb"; - -import CFG from "../../cfg"; - -export function setupConnection() { - - let url = `mongodb://${CFG.MONGO_HOST_IP}:${CFG.MONGO_PORT}/${CFG.MONGO_DB_NAME}`; - - return new Promise((resolve) => { - mongodb.MongoClient.connect(url, (error, db) => { - if (error) { - this.print("MongoDB " + error, 31); - this.retry("Retrying again in ", () => this.setupConnection().then(resolve), 5); - return void 0; - } else { - this.db.instance = db; - this.loadCollection(CFG.MONGO_COLLECTION_USERS).then(() => { - this.print(`\x1b[36;1mMongoDB\x1b[0m\x1b[32;1m connection established\x1b[0m`); - resolve(); - }); - } - db.on("close", (error) => { - this.print("MongoDB " + error, 31); - this.retry("Trying to reconnect in ", () => this.setupConnection().then(resolve), 5); - }); - }); - }); - -} - -/** - * @param {Function} resolve - */ -export function closeConnection(resolve) { - this.db.instance.close(() => { - resolve(); - }); -} - -/** - * @param {String} name - */ -export function loadCollection(name) { - - return new Promise((resolve) => { - this.db.instance.listCollections({name: name}).next((err, exists) => { - if (!exists) this.createCollection(name).then((coll) => resolve()); - else { - this.db.instance.collection(name, (err, coll) => { - resolve(); - }); - } - }); - }); - -} - -/** - * @param {String} name - */ -export function createCollection(name) { - return new Promise((resolve) => { - this.db.instance.createCollection(name, {}, (err, coll) => { - resolve(); - }); - }); -} - -/** - * @param {String} email - */ -export function getUserByEmail(email) { - return new Promise((resolve) => { - let collection = this.getUserCollection(); - collection.find({email: email}).toArray((err, docs) => { - if (docs && docs.length) resolve(docs[0]); - else resolve(void 0); - }); - }); -} - -export function getUserCollection() { - return ( - this.db.instance.collection(CFG.MONGO_COLLECTION_USERS) - ); -} - -/** - * @param {Object} obj - */ -export function createUser(obj) { - - let collection = this.getUserCollection(); - - let user = this.getUserData(obj); - - return new Promise((resolve) => { - collection.insert([user], (error, result) => { - resolve(); - }); - }); - -} - -/** - * @param {Object} obj - */ -export function updateUser(obj) { - - let collection = this.getUserCollection(); - - let user = this.getUserData(obj); - - return new Promise((resolve) => { - collection.update({email: user.email}, user, (error, result) => { - resolve(); - }); - }); - -} - -/** - * @param {Object} obj - * @return {Object} - */ -export function getUserData(obj) { - return ({ - username: obj.username, - email: obj.email, - exp: obj.exp, - stardust: obj.stardust, - pokecoins: obj.pokecoins, - team: obj.team, - - skin: obj.skin, - hair: obj.hair, - shirt: obj.shirt, - pants: obj.pants, - hat: obj.hat, - shoes: obj.shoes, - eyes: obj.eyes, - gender: obj.gender, - backpack: obj.backpack, - - latitude: obj.latitude, - longitude: obj.latitude, - altitude: obj.latitude, - - send_marketing_emails: false, - send_push_notifications: false - }); -} \ No newline at end of file diff --git a/src/db/mysql.js b/src/db/mysql.js deleted file mode 100644 index e0a68a0..0000000 --- a/src/db/mysql.js +++ /dev/null @@ -1,204 +0,0 @@ -import mysql from "mysql"; - -import CFG from "../../cfg"; - -export function setupConnection() { - - let connection = mysql.createConnection({ - host : CFG.MYSQL_HOST_IP, - port : CFG.MYSQL_PORT, - database : CFG.MYSQL_DB_NAME, - user : CFG.MYSQL_USERNAME, - password : CFG.MYSQL_PASSWORD - }); - - return new Promise((resolve) => { - connection.connect((error) => { - if (error) { - this.print("MySQL " + error, 31); - this.retry("Retrying again in ", () => this.setupConnection().then(resolve), 5); - return void 0; - } - this.db.instance = connection; - this.createTableIfNoExists().then(() => { - this.print(`\x1b[36;1mMySQL\x1b[0m\x1b[32;1m connection established\x1b[0m`); - resolve(); - }); - }); - connection.on("error", (error) => { - this.print("MySQL " + error, 31); - this.retry("Trying to reconnect in ", () => this.setupConnection().then(resolve), 5); - }); - }); - -} - -/** - * @param {Function} resolve - */ -export function closeConnection(resolve) { - this.db.instance.end(() => { - resolve(); - }); -} - -export function createTableIfNoExists() { - return new Promise((resolve) => { - this.db.instance.query(`SHOW TABLES LIKE '${CFG.MYSQL_TABLE}';`, (e, rows, fields) => { - if (e) console.log(e); - else { - // exists - if (rows && rows.length) resolve(); - // create user table - else this.createTable(CFG.MYSQL_TABLE).then(resolve); - } - }); - }); -} - -/** - * @param {String} name - */ -export function createTable(name) { - this.print(`Creating table ${CFG.MYSQL_TABLE}`, 36); - return new Promise((resolve) => { - let query = ` - CREATE TABLE ${name} ( - id int(11) NOT NULL AUTO_INCREMENT, - username longtext NOT NULL, - email longtext NOT NULL, - exp int(255) NOT NULL, - stardust int(255) NOT NULL, - pokecoins int(255) NOT NULL, - team int(11) NOT NULL, - latitude double NOT NULL, - longitude double NOT NULL, - altitude int(255) NOT NULL, - send_marketing_emails tinyint(1) NOT NULL, - send_push_notifications tinyint(1) NOT NULL, - skin int(11) NOT NULL, - hair int(11) NOT NULL, - shirt int(11) NOT NULL, - pants int(11) NOT NULL, - hat int(11) NOT NULL, - shoes int(11) NOT NULL, - eyes int(11) NOT NULL, - gender int(11) NOT NULL, - backpack int(11) NOT NULL, - PRIMARY KEY (id) - ) ENGINE=InnoDB; - `; - this.db.instance.query(query, (e, rows, fields) => { - if (e) console.log(e); - else resolve(); - }); - }); -} - -/** - * @param {String} email - */ -export function getUserByEmail(email) { - return new Promise((resolve) => { - this.db.instance.query(`SELECT * FROM ${CFG.MYSQL_TABLE} WHERE email=? LIMIT 1`, [email], (e, rows, fields) => { - if (e) console.log(e); - if (rows && rows.length) resolve(rows[0]); - else resolve(void 0); - }); - }); -} - -/** - * @param {Object} obj - */ -export function createUser(obj) { - - let query = this.getUserQuery("INSERT INTO", ""); - let data = this.getUserQueryData(obj); - - return new Promise((resolve) => { - this.db.instance.query(query, data, resolve); - }); - -} - -/** - * @param {Object} obj - */ -export function updateUser(obj) { - - let query = this.getUserQuery("UPDATE", "WHERE email=? LIMIT 1"); - let data = this.getUserQueryData(obj); - - return new Promise((resolve) => { - this.db.instance.query(query, data, resolve); - }); - -} - -/** - * @return {String} - */ -export function getUserQuery(cmd, after) { - return (` - ${cmd} ${CFG.MYSQL_TABLE} - SET - username=?, - email=?, - exp=?, - stardust=?, - pokecoins=?, - team=?, - latitude=?, - longitude=?, - altitude=?, - send_marketing_emails=?, - send_push_notifications=?, - skin=?, - hair=?, - shirt=?, - pants=?, - hat=?, - shoes=?, - eyes=?, - gender=?, - backpack=? - ${after} - `); -} - -/** - * @param {Object} obj - * @return {Array} - */ -export function getUserQueryData(obj) { - - return ([ - obj.username, - obj.email, - obj.exp, - obj.stardust, - obj.pokecoins, - obj.team, - // position - obj.latitude, - obj.longitude, - obj.altitude, - // contact settings - obj.send_marketing_emails, - obj.send_push_notifications, - // avatar - obj.skin, - obj.hair, - obj.shirt, - obj.pants, - obj.hat, - obj.shoes, - obj.eyes, - obj.gender, - obj.backpack, - // where - obj.email - ]); - -} \ No newline at end of file diff --git a/src/db/query.js b/src/db/query.js new file mode 100644 index 0000000..1df5f98 --- /dev/null +++ b/src/db/query.js @@ -0,0 +1,113 @@ +import CFG from "../../cfg"; + +/** + * @return {String} + */ +export function getUserQuery(cmd, after) { + return (` + ${cmd} ${CFG.MYSQL_USERS_TABLE} + SET + username=?, + email=?, + exp=?, + stardust=?, + pokecoins=?, + team=?, + latitude=?, + longitude=?, + altitude=?, + send_marketing_emails=?, + send_push_notifications=?, + skin=?, + hair=?, + shirt=?, + pants=?, + hat=?, + shoes=?, + eyes=?, + gender=?, + backpack=? + ${after} + `); +} + +export function getUserItemQuery(cmd, after) { + return (` + ${cmd} ${CFG.MYSQL_USERS_TABLE} + SET + item_poke_ball=?, + item_great_ball=?, + item_ultra_ball=?, + item_master_ball=?, + item_potion=?, + item_super_potion=?, + item_hyper_potion=?, + item_max_potion=?, + item_revive=?, + item_max_revive=?, + item_lucky_egg=?, + item_incense_ordinary=?, + item_incense_spicy=?, + item_incense_cool=?, + item_incense_floral=?, + item_troy_disk=?, + item_razz_berry=?, + item_bluk_berry=?, + item_nanab_berry=?, + item_wepar_berry=?, + item_pinap_berry=?, + item_incubator_basic=?, + item_incubator_basic_unlimited=?, + item_pokemon_storage_upgrade=?, + item_item_storage_upgrade=? + ${after} + `); +} + +/** + * @param {Object} obj + * @return {Array} + */ +export function getUserItemQueryData(obj) { + + console.log(obj); + + return ([]); + +} + +/** + * @param {Object} obj + * @return {Array} + */ +export function getUserQueryData(obj) { + + return ([ + obj.username, + obj.email, + obj.exp, + obj.stardust, + obj.pokecoins, + obj.team, + // position + obj.latitude, + obj.longitude, + obj.altitude, + // contact settings + obj.send_marketing_emails, + obj.send_push_notifications, + // avatar + obj.skin, + obj.hair, + obj.shirt, + obj.pants, + obj.hat, + obj.shoes, + obj.eyes, + obj.gender, + obj.backpack, + // where + obj.email + ]); + +} \ No newline at end of file diff --git a/src/db/tables/owned_pkmn.table b/src/db/tables/owned_pkmn.table new file mode 100644 index 0000000..03582b7 --- /dev/null +++ b/src/db/tables/owned_pkmn.table @@ -0,0 +1,30 @@ +id int(11) NOT NULL AUTO_INCREMENT, +owner_id int(11) NOT NULL, +pokemon_id int(11) NOT NULL, +stamina int(11) NOT NULL, +stamina_max int(11) NOT NULL, +move_1 int(5) NOT NULL, +move_2 int(5) NOT NULL, +deployed_fort_id longtext NOT NULL, +is_egg tinyint(1) NOT NULL, +egg_km_walked_target double NOT NULL, +egg_km_walked_start double NOT NULL, +origin int(11) NOT NULL, +height_m double NOT NULL, +weight_kg double NOT NULL, +individual_attack int(11) NOT NULL, +individual_defense int(11) NOT NULL, +individual_stamina int(11) NOT NULL, +cp_multiplier double NOT NULL, +pokeball int(3) NOT NULL, +captured_cell_id int(11) NOT NULL, +battles_attacked int(11) NOT NULL, +battles_defended int(11) NOT NULL, +egg_incubator_id longtext NOT NULL, +creation_time_ms int(11) NOT NULL, +num_upgrades int(11) NOT NULL, +additional_cp_multiplier double NOT NULL, +favorite tinyint(1) NOT NULL, +nickname longtext NOT NULL, +from_fort int(11) NOT NULL, +PRIMARY KEY (id) \ No newline at end of file diff --git a/src/db/tables/users.table b/src/db/tables/users.table new file mode 100644 index 0000000..d787437 --- /dev/null +++ b/src/db/tables/users.table @@ -0,0 +1,47 @@ +id int(11) NOT NULL AUTO_INCREMENT, +username longtext NOT NULL, +email longtext NOT NULL, +exp int(255) NOT NULL, +stardust int(255) NOT NULL, +pokecoins int(255) NOT NULL, +team int(11) NOT NULL, +latitude double NOT NULL, +longitude double NOT NULL, +altitude int(255) NOT NULL, +send_marketing_emails tinyint(1) NOT NULL, +send_push_notifications tinyint(1) NOT NULL, +skin int(11) NOT NULL, +hair int(11) NOT NULL, +shirt int(11) NOT NULL, +pants int(11) NOT NULL, +hat int(11) NOT NULL, +shoes int(11) NOT NULL, +eyes int(11) NOT NULL, +gender int(11) NOT NULL, +backpack int(11) NOT NULL, +item_poke_ball int(11) NOT NULL, +item_great_ball int(11) NOT NULL, +item_ultra_ball int(11) NOT NULL, +item_master_ball int(11) NOT NULL, +item_potion int(11) NOT NULL, +item_super_potion int(11) NOT NULL, +item_hyper_potion int(11) NOT NULL, +item_max_potion int(11) NOT NULL, +item_revive int(11) NOT NULL, +item_max_revive int(11) NOT NULL, +item_lucky_egg int(11) NOT NULL, +item_incense_ordinary int(11) NOT NULL, +item_incense_spicy int(11) NOT NULL, +item_incense_cool int(11) NOT NULL, +item_incense_floral int(11) NOT NULL, +item_troy_disk int(11) NOT NULL, +item_razz_berry int(11) NOT NULL, +item_bluk_berry int(11) NOT NULL, +item_nanab_berry int(11) NOT NULL, +item_wepar_berry int(11) NOT NULL, +item_pinap_berry int(11) NOT NULL, +item_incubator_basic int(11) NOT NULL, +item_incubator_basic_unlimited int(11) NOT NULL, +item_pokemon_storage_upgrade int(11) NOT NULL, +item_item_storage_upgrade int(11) NOT NULL, +PRIMARY KEY (id) \ No newline at end of file diff --git a/src/index.js b/src/index.js index d065c40..d83b781 100644 --- a/src/index.js +++ b/src/index.js @@ -19,8 +19,10 @@ import * as _player from "./player"; import * as _request from "./request"; import * as _response from "./response"; import * as _process from "./process"; -import * as _mongo from "./db/mongo"; -import * as _mysql from "./db/mysql"; +import * as _mysql from "./db/index"; +import * as _mysql_get from "./db/get"; +import * as _mysql_query from "./db/query"; +import * as _mysql_create from "./db/create"; const greetMessage = fs.readFileSync(".greet", "utf8"); @@ -44,6 +46,7 @@ class GameServer { }; this.asset = null; + this.master = null; this.socket = null; this.cycleInstance = null; @@ -118,11 +121,6 @@ class GameServer { let name = String(CFG.DATABASE_TYPE).toUpperCase(); switch (name) { - case "MONGO": - case "MONGODB": - inherit(GameServer, _mongo); - this.setupConnection().then(resolve); - break; case "MYSQL": inherit(GameServer, _mysql); this.setupConnection().then(resolve); @@ -209,6 +207,15 @@ class GameServer { } } + fileExists(path) { + try { + fs.statSync(path); + } catch (e) { + return (false); + } + return (true); + } + greet() { console.log(greetMessage); } @@ -221,6 +228,10 @@ inherit(GameServer, _player); inherit(GameServer, _request); inherit(GameServer, _response); inherit(GameServer, _process); +inherit(GameServer, _mysql); +inherit(GameServer, _mysql_get); +inherit(GameServer, _mysql_query); +inherit(GameServer, _mysql_create); let server = new GameServer(); diff --git a/src/packets/Envelopes.AuthTicket.js b/src/packets/Envelopes.AuthTicket.js index ee9a35c..bab1458 100644 --- a/src/packets/Envelopes.AuthTicket.js +++ b/src/packets/Envelopes.AuthTicket.js @@ -1,16 +1,17 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @return {Object} */ export default function AuthTicket() { - return ( - new proto.Networking.Envelopes.AuthTicket({ - start: new Buffer(""), - expire_timestamp_ms: 9999999999999, - end: new Buffer("") - }) - ); + let buffer = ({ + start: new Buffer(""), + "expire_timestamp_ms": new Date.getTime(), + end: new Buffer("") + }); + + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Envelopes.AuthTicket")); } \ No newline at end of file diff --git a/src/packets/Responses.CheckAwardedBadges.js b/src/packets/Responses.CheckAwardedBadges.js index 238efb2..d5079b9 100644 --- a/src/packets/Responses.CheckAwardedBadges.js +++ b/src/packets/Responses.CheckAwardedBadges.js @@ -1,6 +1,7 @@ import CFG from "../../cfg"; import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @param {Object} obj @@ -8,12 +9,13 @@ import proto from "../proto"; */ export default function CheckAwardedBadges(obj) { - return ( - new proto.Networking.Responses.CheckAwardedBadgesResponse({ - success: true, - awarded_badges: [], - awarded_badge_levels: [] - }).encode() - ); + let buffer = { + "success": true, + "awarded_badges": [], + "awarded_badge_levels": [], + "$unknownFields": [] + } + + return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.CheckAwardedBadgesResponse"); } \ No newline at end of file diff --git a/src/packets/Responses.DownloadRemoteConfigVersion.js b/src/packets/Responses.DownloadRemoteConfigVersion.js index 8711578..0f2423f 100644 --- a/src/packets/Responses.DownloadRemoteConfigVersion.js +++ b/src/packets/Responses.DownloadRemoteConfigVersion.js @@ -1,19 +1,19 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** - * @param {Request} req + * @param {Object} obj * @return {Object} */ -export default function DownloadRemoteConfigVersion(req) { +export default function DownloadRemoteConfigVersion(obj) { - let data = proto.Networking.Requests.Messages.DownloadRemoteConfigVersionMessage.decode(req.request_message.toBuffer()); + let buffer = { + "result": "SUCCESS", + "item_templates_timestamp_ms": "1471650700946", + "asset_digest_timestamp_ms": "1467338276561000", + "$unknownFields": [] + } - return ( - new proto.Networking.Responses.DownloadRemoteConfigVersionResponse({ - result: 1, - item_templates_timestamp_ms: 1468540960537, - asset_digest_timestamp_ms: 1468540960527 - }).encode() - ); + return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.DownloadRemoteConfigVersionResponse"); } \ No newline at end of file diff --git a/src/packets/Responses.DownloadSettings.js b/src/packets/Responses.DownloadSettings.js index 417c419..44675a3 100644 --- a/src/packets/Responses.DownloadSettings.js +++ b/src/packets/Responses.DownloadSettings.js @@ -1,55 +1,44 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; import CFG from "../../cfg"; /** - * @param {Request} req - * @return {Object} + * @return {Buffer} */ -export default function DownloadSettings(req) { +export default function DownloadSettings() { - let data = proto.Networking.Requests.Messages.DownloadSettingsMessage.decode(req.request_message.toBuffer()); + let buffer = ({ + hash: "2788184af4004004d6ab0740f7632983332106f6", + settings: { + fort_settings: { + "interaction_range_meters": 40.25098039215686, + "max_total_deployed_pokemon": 10, + "max_player_deployed_pokemon": 1, + "deploy_stamina_multiplier": 8.062745098039215, + "deploy_attack_multiplier": 0, + "far_interaction_range_meters": 1000.0156862745098 + }, + map_settings: { + "pokemon_visible_range": 70.00196078431372, + "poke_nav_range_meters": 751.0156862745098, + "encounter_range_meters": 50.25098039215686, + "get_map_objects_min_refresh_seconds": 10.007843017578125, + "get_map_objects_max_refresh_seconds": 30.01568603515625, + "get_map_objects_min_distance_meters": 10.007843017578125, + "google_maps_api_key": CFG.GMAPS_KEY + }, + inventory_settings: { + "max_pokemon": 1000, + "max_bag_items": 1000, + "base_pokemon": 250, + "base_bag_items": 350, + "base_eggs": 9 + }, + minimum_client_version: CFG.MINIMUM_CLIENT_VERSION + } + }) - if (!data.hash.length) { - return ( - new proto.Networking.Responses.DownloadSettingsResponse({ - hash: "2788184af4004004d6ab0740f7632983332106f6", - settings: new proto.Settings.GlobalSettings({ - fort_settings: new proto.Settings.FortSettings({ - "interaction_range_meters": 40.25098039215686, - "max_total_deployed_pokemon": 10, - "max_player_deployed_pokemon": 1, - "deploy_stamina_multiplier": 8.062745098039215, - "deploy_attack_multiplier": 0, - "far_interaction_range_meters": 1000.0156862745098 - }), - map_settings: new proto.Settings.MapSettings({ - "pokemon_visible_range": 70.00196078431372, - "poke_nav_range_meters": 751.0156862745098, - "encounter_range_meters": 50.25098039215686, - "get_map_objects_min_refresh_seconds": 10.007843017578125, - "get_map_objects_max_refresh_seconds": 30.01568603515625, - "get_map_objects_min_distance_meters": 10.007843017578125, - "google_maps_api_key": CFG.GMAPS_KEY - }), - inventory_settings: new proto.Settings.InventorySettings({ - "max_pokemon": 1000, - "max_bag_items": 1000, - "base_pokemon": 250, - "base_bag_items": 350, - "base_eggs": 9 - }), - minimum_client_version: CFG.MINIMUM_CLIENT_VERSION - }) - }).encode() - ); - } - else { - return ( - new proto.Networking.Responses.DownloadSettingsResponse({ - hash: "2788184af4004004d6ab0740f7632983332106f6" - }).encode() - ); - } + return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.DownloadSettingsResponse"); } \ No newline at end of file diff --git a/src/packets/Responses.Encounter.js b/src/packets/Responses.Encounter.js index 7729398..01099e4 100644 --- a/src/packets/Responses.Encounter.js +++ b/src/packets/Responses.Encounter.js @@ -1,6 +1,7 @@ import CFG from "../../cfg"; import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; import { decodeLong } from "../utils"; @@ -9,71 +10,45 @@ import { decodeLong } from "../utils"; * @return {Object} */ export default function Encounter(req) { - - let id = decodeLong({ - "low": 0, - "high": 0, - "unsigned": true +console.log(req.encounter_id, req.player_latitude, req.player_longitude); + let buffer = ({ + "wild_pokemon": { + "encounter_id": req.encounter_id, + "last_modified_timestamp_ms": new Date().getTime(), + "latitude": req.player_latitude, + "longitude": req.player_longitude, + "spawn_point_id": "87bdcd8ec57", + "pokemon_data": { + "pokemon_id": "MEWTWO", + "cp": 164, + "stamina": 38, + "stamina_max": 38, + "move_1": "TACKLE_FAST", + "move_2": "BODY_SLAM", + "height_m": 0.36679142713546753, + "weight_kg": 9.639217376708984, + "individual_attack": 15, + "individual_defense": 1, + "individual_stamina": 9, + "cp_multiplier": 0.3210875988006592 + }, + "time_till_hidden_ms": 857876 + }, + "status": "ENCOUNTER_SUCCESS", + "capture_probability": { + "pokeball_type": [ + "ITEM_POKE_BALL", + "ITEM_GREAT_BALL", + "ITEM_ULTRA_BALL" + ], + "capture_probability": { + "0": 0.49830639362335205, + "1": 0.6446487903594971, + "2": 0.7483035326004028 + } + } }); - return ( - new proto.Networking.Responses.EncounterResponse({ - wild_pokemon: new proto.Map.Pokemon.WildPokemon({ - encounter_id: decodeLong({ - "low": -1477718883, - "high": -1178282273, - "unsigned": true - }), - last_modified_timestamp_ms: decodeLong({ - "low": 2047340539, - "high": 342, - "unsigned": false - }), - latitude: 39.19071817474392, - longitude: -96.58505386390713, - spawn_point_id: "87bdcd8e959", - pokemon_data: new proto.Data.PokemonData({ - id: id, - pokemon_id: 17, - cp: 48, - stamina: 22, - stamina_max: 22, - move_1: 210, - move_2: 45, - deployed_fort_id: "", - owner_name: "", - is_egg: false, - egg_km_walked_target: 0, - egg_km_walked_start: 0, - origin: 0, - height_m: 0.8371214866638184, - weight_kg: 19.039264678955078, - individual_attack: 6, - individual_defense: 12, - individual_stamina: 7, - cp_multiplier: 0.16639786958694458, - pokeball: 0, - captured_cell_id: id, - battles_attacked: 0, - battles_defended: 0, - egg_incubator_id: "", - creation_time_ms: id, - num_upgrades: 0, - additional_cp_multiplier: 0, - favorite: 0, - nickname: "", - from_fort: 0 - }), - time_till_hidden_ms: 336009 - }), - background: 0, - status: 1, - capture_probability: new proto.Data.Capture.CaptureProbability({ - pokeball_type: [1, 2, 3], - capture_probability: [0.6009692549705505, 0.7479367256164551, 0.8407744765281677], - reticle_difficulty_scale: 0 - }) - }).encode() - ); + return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.EncounterResponse"); } \ No newline at end of file diff --git a/src/packets/Responses.FortDetails.js b/src/packets/Responses.FortDetails.js index 0f47ba7..8c3e41d 100644 --- a/src/packets/Responses.FortDetails.js +++ b/src/packets/Responses.FortDetails.js @@ -1,6 +1,7 @@ import CFG from "../../cfg"; import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @param {Request} req @@ -8,32 +9,19 @@ import proto from "../proto"; */ export default function FortDetails(req) { - let data = proto.Networking.Requests.Messages.FortDetailsMessage.decode(req.request_message.toBuffer()); + let buffer = ({ + "fort_id": req.fort_id, + "name": "POGOserver v0.3.5", + "image_urls": [ + "http://thecatapi.com/api/images/get?format=src&type=png" + ], + "type": "CHECKPOINT", + "latitude": req.latitude, + "longitude": req.longitude, + "modifiers": [], + "$unknownFields": [] + }); - return ( - new proto.Networking.Responses.FortDetailsResponse({ - "fort_id": data.fort_id, - "team_color": 0, - "pokemon_data": null, - "name": "POGOserver v0.2.0", - "description": "Weird species below", - "image_urls": [ - "http://thecatapi.com/api/images/get?format=src&type=png" - ], - "fp": 0, - "stamina": 0, - "max_stamina": 0, - "type": 1, - "latitude": data.latitude, - "longitude": data.longitude, - "modifiers": [ - new proto.Map.Fort.FortModifier({ - item_id: proto.Inventory.Item.ItemId.ITEM_TROY_DISK, - expiration_timestamp_ms: (new Date().getTime() + 1e3) * 1e3, - deployer_player_codename: "The Big Lebowski" - }) - ] - }).encode() - ); + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.FortDetailsResponse")); } \ No newline at end of file diff --git a/src/packets/Responses.FortSearch.js b/src/packets/Responses.FortSearch.js index f09472f..5865059 100644 --- a/src/packets/Responses.FortSearch.js +++ b/src/packets/Responses.FortSearch.js @@ -1,6 +1,7 @@ import CFG from "../../cfg"; import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @param {Object} obj @@ -8,25 +9,26 @@ import proto from "../proto"; */ export default function FortSearch(obj) { - return ( - new proto.Networking.Responses.FortSearchResponse({ - result: proto.Networking.Responses.FortSearchResponse.Result.SUCCESS, - items_awarded: [ - new proto.Inventory.Item.ItemAward({ - item_id: proto.Inventory.Item.ItemId.ITEM_MASTER_BALL, - item_count: 3 - }), - new proto.Inventory.Item.ItemAward({ - item_id: proto.Inventory.Item.ItemId.ITEM_ULTRA_BALL, - item_count: 2 - }) - ], - gems_awarded: 0, - pokemon_data_egg: null, - experience_awarded: 99999, - cooldown_complete_timestamp_ms: 1470174535972, - chain_hack_sequence_number: 0 - }).encode() - ); + let ii = 0; + let amount = 5; + let items = []; + + while (++ii < amount) { + items.push({ + "item_id": "ITEM_MASTER_BALL", + "item_count": 1 + }) + }; + + let buffer = ({ + "result": "SUCCESS", + "items_awarded": items, + "experience_awarded": 50, + "cooldown_complete_timestamp_ms": "1471780158665", + "chain_hack_sequence_number": 2, + "$unknownFields": [] + }); + + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.FortSearchResponse")); } \ No newline at end of file diff --git a/src/packets/Responses.GetAssetDigest.js b/src/packets/Responses.GetAssetDigest.js index 2da7f6e..d2ee966 100644 --- a/src/packets/Responses.GetAssetDigest.js +++ b/src/packets/Responses.GetAssetDigest.js @@ -8,7 +8,5 @@ import CFG from "../../cfg"; * @return {Object} */ export default function GetAssetDigest(req) { - return (fs.readFileSync("data/asset_digest")); - } \ No newline at end of file diff --git a/src/packets/Responses.GetDownloadUrls.js b/src/packets/Responses.GetDownloadUrls.js index b24914a..91ad0d4 100644 --- a/src/packets/Responses.GetDownloadUrls.js +++ b/src/packets/Responses.GetDownloadUrls.js @@ -1,6 +1,5 @@ import proto from "../proto"; - -import DownloadUrlEntry from "./Data.DownloadUrlEntry"; +import POGOProtos from "pokemongo-protobuf"; import CFG from "../../cfg"; @@ -13,9 +12,7 @@ import { */ export default function GetDownloadUrls(asset, ip, req) { - let data = proto.Networking.Requests.Messages.GetDownloadUrlsMessage.decode(req.request_message.toBuffer()); - - let key = data.asset_id[0]; + let key = req.asset_id[0]; let download_urls = []; @@ -29,19 +26,17 @@ export default function GetDownloadUrls(asset, ip, req) { return new Promise((resolve) => { download_urls.push( - new proto.Data.DownloadUrlEntry({ + { asset_id: key, url: `http://${ip}:${CFG.PORT}/model/${node.bundle_name}`, size: node.size, checksum: node.checksum - }) + } ); - let output = ( - new proto.Networking.Responses.GetDownloadUrlsResponse({ - download_urls: download_urls - }).encode() - ); - resolve(output); + let buffer = ({ + download_urls: download_urls + }); + resolve(POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetDownloadUrlsResponse")); }); } \ No newline at end of file diff --git a/src/packets/Responses.GetHatchedEggs.js b/src/packets/Responses.GetHatchedEggs.js index 38e6688..a5dd156 100644 --- a/src/packets/Responses.GetHatchedEggs.js +++ b/src/packets/Responses.GetHatchedEggs.js @@ -1,4 +1,5 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @param {Object} obj @@ -6,14 +7,15 @@ import proto from "../proto"; */ export default function GetHatchedEggs(obj) { - return ( - new proto.Networking.Responses.GetHatchedEggsResponse({ - success: true, - pokemon_id: [], - experience_awarded: [], - candy_awarded: [], - stardust_awarded: [] - }).encode() - ); + let buffer = { + "success": true, + "pokemon_id": [], + "experience_awarded": [], + "candy_awarded": [], + "stardust_awarded": [], + "$unknownFields": [] + }; + + return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetHatchedEggsResponse"); } \ No newline at end of file diff --git a/src/packets/Responses.GetInventory.js b/src/packets/Responses.GetInventory.js index 6a7854c..9ec4f11 100644 --- a/src/packets/Responses.GetInventory.js +++ b/src/packets/Responses.GetInventory.js @@ -1,4 +1,7 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; + +let isFirst = false; /** * @param {Object} obj @@ -6,150 +9,1226 @@ import proto from "../proto"; */ export default function GetInventoryData(obj) { - // TODO: Start loading pkmn party from db - - return ( - new proto.Networking.Responses.GetInventoryResponse({ - success: true, - inventory_delta: new proto.Inventory.InventoryDelta({ - inventory_items: [ - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "candy": new proto.Inventory.Candy({ - "family_id": 48, - "candy": 3 - }) - }) - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "candy": new proto.Inventory.Candy({ - "family_id": 16, - "candy": 3 - }) - }) - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "player_stats": new proto.Data.Player.PlayerStats({ - level: 3, - experience: 4870, - prev_level_xp: 1000, - next_level_xp: 6000, - km_walked: 1.0598372220993042, - pokemons_encountered: 11, - unique_pokedex_entries: 5, - pokemons_captured: 5, - evolutions: 0, - poke_stop_visits: 37, - pokeballs_thrown: 22, - eggs_hatched: 0, - big_magikarp_caught: 0, - battle_attack_won: 0, - battle_attack_total: 0, - battle_defended_won: 0, - battle_training_won: 0, - battle_training_total: 0, - prestige_raised_total: 0, - prestige_dropped_total: 0, - pokemon_deployed: 0 - }) - }) - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "item": new proto.Inventory.Item.ItemData({ - "item_id": 901, - "count": 1, - "unseen": true - }) - }) - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "pokemon_data": new proto.Data.PokemonData({ - "id": 16, - "pokemon_id": proto.Enums.PokemonId.PIDGEY, - "cp": 10, - "stamina": 10, - "stamina_max": 10, - "move_1": 219, - "move_2": 121, - "deployed_fort_id": "", - "owner_name": "", - "is_egg": false, - "egg_km_walked_target": 0, - "egg_km_walked_start": 0, - "origin": 0, - "height_m": 0.29406625032424927, - "weight_kg": 2.070491313934326, - "individual_attack": 3, - "individual_defense": 5, - "individual_stamina": 10, - "cp_multiplier": 0.09399999678134918, - "pokeball": 1, - "captured_cell_id": 2277362944, - "battles_attacked": 0, - "battles_defended": 0, - "egg_incubator_id": "", - "creation_time_ms": 9029623884583797000, - "num_upgrades": 0, - "additional_cp_multiplier": 0, - "favorite": 0, - "nickname": "", - "from_fort": 0 - }) - }) - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "item": new proto.Inventory.Item.ItemData({ - "item_id": 1, - "count": 145, - "unseen": false - }) - }) - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": { - "candy": new proto.Inventory.Candy({ - "family_id": 7, - "candy": 3 - }) + let buffer = ({ + "success": true, + "inventory_delta": { + "new_timestamp_ms": new Date().getTime(), + "inventory_items": [ + { + "modified_timestamp_ms": "1471712450083", + "inventory_item_data": { + "pokemon_data": { + "id": "18084643178451338494", + "pokemon_id": "JIGGLYPUFF", + "cp": 132, + "stamina": 74, + "stamina_max": 74, + "move_1": "FEINT_ATTACK_FAST", + "move_2": "BODY_SLAM", + "height_m": 0.4980907142162323, + "weight_kg": 5.8239665031433105, + "individual_attack": 9, + "individual_defense": 8, + "individual_stamina": 1, + "cp_multiplier": 0.3210875988006592, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471692765854" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "FEAROW", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "15921933050191214559", + "pokemon_id": "RATTATA", + "cp": 37, + "stamina": 14, + "stamina_max": 14, + "move_1": "QUICK_ATTACK_FAST", + "move_2": "BODY_SLAM", + "height_m": 0.335340678691864, + "weight_kg": 3.9603395462036133, + "individual_attack": 15, + "individual_defense": 2, + "individual_stamina": 6, + "cp_multiplier": 0.21573247015476227, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471689904105" + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_SLOWPOKE", + "candy": 3 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "EKANS", + "times_encountered": 2, + "times_captured": 2 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "10181525078482818464", + "is_egg": true, + "egg_km_walked_target": 5, + "captured_cell_id": "9926767136558022656", + "creation_time_ms": "1471691580646" + } + } + }, + { + "inventory_item_data": { + "item": { + "item_id": "ITEM_REVIVE", + "count": 20 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "3728701318451962436", + "pokemon_id": "STARYU", + "cp": 13, + "stamina": 10, + "stamina_max": 10, + "move_1": "WATER_GUN_FAST", + "move_2": "BUBBLE_BEAM", + "height_m": 0.861968457698822, + "weight_kg": 41.78410720825195, + "individual_attack": 14, + "individual_defense": 15, + "individual_stamina": 15, + "cp_multiplier": 0.09399999678134918, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471692483936" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "NIDORAN_FEMALE", + "times_encountered": 2, + "times_captured": 2 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "12449080423906283031", + "pokemon_id": "PIDGEOTTO", + "cp": 80, + "stamina": 28, + "stamina_max": 28, + "move_1": "WING_ATTACK_FAST", + "move_2": "TWISTER", + "height_m": 1.24424409866333, + "weight_kg": 38.75220489501953, + "individual_attack": 10, + "individual_defense": 3, + "individual_stamina": 5, + "cp_multiplier": 0.21573247015476227, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471691535997" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "NIDORINO", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "CLEFAIRY", + "times_encountered": 2, + "times_captured": 2 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_MAGIKARP", + "candy": 19 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "JIGGLYPUFF", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "14072353163410837297", + "pokemon_id": "MAGIKARP", + "cp": 26, + "stamina": 13, + "stamina_max": 13, + "move_1": "SPLASH_FAST", + "move_2": "STRUGGLE", + "height_m": 0.797365128993988, + "weight_kg": 7.1520256996154785, + "individual_attack": 13, + "individual_defense": 13, + "individual_stamina": 14, + "cp_multiplier": 0.2557200491428375, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926593976904712192", + "creation_time_ms": "1471695195481", + "from_fort": 1 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "ZUBAT", + "times_encountered": 8, + "times_captured": 8 + } + } + }, + { + "inventory_item_data": { + "item": { + "item_id": "ITEM_RAZZ_BERRY", + "count": 21 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_KRABBY", + "candy": 7 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "GOLBAT", + "times_encountered": 2, + "times_captured": 2 + } + } + }, + { + "modified_timestamp_ms": "1471712450083", + "inventory_item_data": { + "pokemon_data": { + "id": "9506392224876742817", + "pokemon_id": "FEAROW", + "cp": 311, + "stamina": 22, + "stamina_max": 49, + "move_1": "STEEL_WING_FAST", + "move_2": "TWISTER", + "height_m": 1.0706182718276978, + "weight_kg": 35.038177490234375, + "individual_attack": 4, + "individual_defense": 10, + "individual_stamina": 11, + "cp_multiplier": 0.3492126762866974, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471693184039" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "PARAS", + "times_encountered": 3, + "times_captured": 3 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_CUBONE", + "candy": 3 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "VENONAT", + "times_encountered": 1 + } + } + }, + { + "modified_timestamp_ms": "1471712450083", + "inventory_item_data": { + "pokemon_data": { + "id": "18365393771243280355", + "pokemon_id": "NIDORINO", + "cp": 170, + "stamina": 38, + "stamina_max": 38, + "move_1": "POISON_STING_FAST", + "move_2": "HORN_ATTACK", + "height_m": 0.8500931262969971, + "weight_kg": 15.523972511291504, + "individual_attack": 11, + "individual_defense": 4, + "individual_stamina": 11, + "cp_multiplier": 0.29024988412857056, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471693450255" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "17518952308967699010", + "pokemon_id": "GROWLITHE", + "cp": 128, + "stamina": 28, + "stamina_max": 28, + "move_1": "BITE_FAST", + "move_2": "FLAMETHROWER", + "height_m": 0.7787603735923767, + "weight_kg": 28.37158966064453, + "individual_attack": 12, + "individual_defense": 14, + "individual_stamina": 1, + "cp_multiplier": 0.2557200491428375, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926594385212866560", + "creation_time_ms": "1471691371843" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "GROWLITHE", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_HORSEA", + "candy": 11 + } + } + }, + { + "modified_timestamp_ms": "1471712450083", + "inventory_item_data": { + "pokemon_data": { + "id": "15271685633708968048", + "pokemon_id": "GOLBAT", + "cp": 191, + "stamina": 41, + "stamina_max": 41, + "move_1": "BITE_FAST", + "move_2": "AIR_CUTTER", + "height_m": 1.7463443279266357, + "weight_kg": 65.05073547363281, + "individual_attack": 11, + "individual_defense": 10, + "individual_stamina": 11, + "cp_multiplier": 0.2557200491428375, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471692231329", + "from_fort": 1 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_GOLDEEN", + "candy": 7 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "796318518081224862", + "pokemon_id": "KRABBY", + "cp": 100, + "stamina": 21, + "stamina_max": 21, + "move_1": "MUD_SHOT_FAST", + "move_2": "VICE_GRIP", + "height_m": 0.26345697045326233, + "weight_kg": 2.924619197845459, + "individual_attack": 10, + "individual_defense": 14, + "individual_stamina": 13, + "cp_multiplier": 0.29024988412857056, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471694904167" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "12036095042499738126", + "pokemon_id": "NIDORAN_FEMALE", + "cp": 103, + "stamina": 36, + "stamina_max": 36, + "move_1": "POISON_STING_FAST", + "move_2": "POISON_FANG", + "height_m": 0.3868274390697479, + "weight_kg": 8.206711769104004, + "individual_attack": 2, + "individual_defense": 13, + "individual_stamina": 15, + "cp_multiplier": 0.29024988412857056, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471691674295" + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_STARYU", + "candy": 7 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "10747118668044541405", + "pokemon_id": "WEEDLE", + "cp": 29, + "stamina": 17, + "stamina_max": 17, + "move_1": "POISON_STING_FAST", + "move_2": "STRUGGLE", + "height_m": 0.3058975636959076, + "weight_kg": 3.337272882461548, + "individual_attack": 14, + "individual_defense": 12, + "individual_stamina": 1, + "cp_multiplier": 0.21573247015476227, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471693994993" + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_PINSIR", + "candy": 3 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_CHARMANDER", + "candy": 3 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "SLOWPOKE", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "modified_timestamp_ms": "1471712450083", + "inventory_item_data": { + "pokemon_data": { + "id": "9152935995874346712", + "pokemon_id": "SLOWPOKE", + "cp": 191, + "stamina": 59, + "stamina_max": 59, + "move_1": "WATER_GUN_FAST", + "move_2": "WATER_PULSE", + "height_m": 1.570439338684082, + "weight_kg": 60.640960693359375, + "individual_attack": 14, + "individual_defense": 11, + "individual_stamina": 5, + "cp_multiplier": 0.3210875988006592, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471692254852" + } + } + }, + { + "inventory_item_data": { + "egg_incubators": { + "egg_incubator": [ + { + "id": "EggIncubatorProto-1762299759591784113", + "item_id": "ITEM_INCUBATOR_BASIC_UNLIMITED", + "incubator_type": "INCUBATOR_DISTANCE" + }, + { + "id": "EggIncubatorProto-2555040734197054659", + "item_id": "ITEM_INCUBATOR_BASIC", + "incubator_type": "INCUBATOR_DISTANCE", + "uses_remaining": 3, + "pokemon_id": "11744424908786525656", + "start_km_walked": 2.1090078353881836, + "target_km_walked": 12.109007835388184 + } + ] + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_CATERPIE", + "candy": 19 + } + } + }, + { + "inventory_item_data": { + "item": { + "item_id": "ITEM_INCENSE_ORDINARY", + "count": 4 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_WEEDLE", + "candy": 19 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "6139375183589489982", + "pokemon_id": "GOLDEEN", + "cp": 68, + "stamina": 21, + "stamina_max": 21, + "move_1": "MUD_SHOT_FAST", + "move_2": "HORN_ATTACK", + "height_m": 0.6158193349838257, + "weight_kg": 17.450626373291016, + "individual_attack": 14, + "individual_defense": 15, + "individual_stamina": 8, + "cp_multiplier": 0.21573247015476227, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471691494377" + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_PIDGEY", + "candy": 50 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_RATTATA", + "candy": 27 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "15065989923603533398", + "is_egg": true, + "egg_km_walked_target": 2, + "captured_cell_id": "9926593978110574592", + "creation_time_ms": "1471690777343" + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_SPEAROW", + "candy": 10 + } + } + }, + { + "modified_timestamp_ms": "1471712450083", + "inventory_item_data": { + "pokemon_data": { + "id": "9068626531358460046", + "pokemon_id": "CLEFAIRY", + "cp": 150, + "stamina": 42, + "stamina_max": 42, + "move_1": "ZEN_HEADBUTT_FAST", + "move_2": "BODY_SLAM", + "height_m": 0.6027987003326416, + "weight_kg": 7.181642532348633, + "individual_attack": 14, + "individual_defense": 5, + "individual_stamina": 6, + "cp_multiplier": 0.29024988412857056, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471693717977" + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_EKANS", + "candy": 7 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "5410754902696943229", + "is_egg": true, + "egg_km_walked_target": 5, + "captured_cell_id": "9926767137919074304", + "creation_time_ms": "1471689786531" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "KRABBY", + "times_encountered": 2, + "times_captured": 2 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "14667551044177722023", + "is_egg": true, + "egg_km_walked_target": 2, + "captured_cell_id": "9926767136790806528", + "creation_time_ms": "1471691542366" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "130876558588413914", + "is_egg": true, + "egg_km_walked_target": 5, + "captured_cell_id": "9926767137394786304", + "creation_time_ms": "1471691424962" + } + } + }, + { + "inventory_item_data": { + "item": { + "item_id": "ITEM_INCUBATOR_BASIC_UNLIMITED", + "count": 1, + "unseen": true + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_NIDORAN_FEMALE", + "candy": 7 + } + } + }, + { + "modified_timestamp_ms": "1471779833610", + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "EEVEE", + "times_encountered": 2 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_NIDORAN_MALE", + "candy": 3 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "CUBONE", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "MAGIKARP", + "times_encountered": 4, + "times_captured": 4 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_CLEFAIRY", + "candy": 7 + } + } + }, + { + "modified_timestamp_ms": "1471779858667", + "inventory_item_data": { + "item": { + "item_id": "ITEM_POTION", + "count": 11 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "1568499254512618339", + "pokemon_id": "PARAS", + "cp": 39, + "stamina": 13, + "stamina_max": 13, + "move_1": "SCRATCH_FAST", + "move_2": "X_SCISSOR", + "height_m": 0.2907119691371918, + "weight_kg": 5.8927106857299805, + "individual_attack": 15, + "individual_defense": 13, + "individual_stamina": 12, + "cp_multiplier": 0.16639786958694458, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926594385212866560", + "creation_time_ms": "1471689715056" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "4260700134915739389", + "pokemon_id": "EKANS", + "cp": 96, + "stamina": 21, + "stamina_max": 21, + "move_1": "ACID_FAST", + "move_2": "SLUDGE_BOMB", + "height_m": 1.5886131525039673, + "weight_kg": 3.6353814601898193, + "individual_attack": 12, + "individual_defense": 6, + "individual_stamina": 3, + "cp_multiplier": 0.29024988412857056, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471692372606" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "10573494102072008253", + "pokemon_id": "PIDGEY", + "cp": 10, + "stamina": 10, + "stamina_max": 10, + "move_1": "TACKLE_FAST", + "move_2": "AERIAL_ACE", + "height_m": 0.27786242961883545, + "weight_kg": 1.1178309917449951, + "individual_attack": 15, + "individual_defense": 10, + "individual_stamina": 4, + "cp_multiplier": 0.09399999678134918, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471689794773" + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_JIGGLYPUFF", + "candy": 3 + } + } + }, + { + "inventory_item_data": { + "item": { + "item_id": "ITEM_TROY_DISK", + "count": 1, + "unseen": true + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_ZUBAT", + "candy": 38 + } + } + }, + { + "modified_timestamp_ms": "1471712379214", + "inventory_item_data": { + "pokemon_data": { + "id": "12039497356603358386", + "pokemon_id": "CUBONE", + "cp": 68, + "stamina": 1, + "stamina_max": 22, + "move_1": "MUD_SLAP_FAST", + "move_2": "BONE_CLUB", + "height_m": 0.4713166356086731, + "weight_kg": 7.497816562652588, + "individual_attack": 14, + "individual_defense": 5, + "individual_stamina": 3, + "cp_multiplier": 0.21573247015476227, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471694222080" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "4337346407444660281", + "is_egg": true, + "egg_km_walked_target": 10, + "captured_cell_id": "9926767133913513984", + "creation_time_ms": "1471695633095" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "HORSEA", + "times_encountered": 3, + "times_captured": 3 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_PARAS", + "candy": 11 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "GOLDEEN", + "times_encountered": 2, + "times_captured": 2 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "17588702568986129255", + "pokemon_id": "HORSEA", + "cp": 102, + "stamina": 21, + "stamina_max": 21, + "move_1": "BUBBLE_FAST", + "move_2": "FLASH_CANNON", + "height_m": 0.38454344868659973, + "weight_kg": 8.013751029968262, + "individual_attack": 15, + "individual_defense": 9, + "individual_stamina": 13, + "cp_multiplier": 0.29024988412857056, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471694597662" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "20428484146157110", + "pokemon_id": "SPEAROW", + "cp": 27, + "stamina": 15, + "stamina_max": 15, + "move_1": "PECK_FAST", + "move_2": "DRILL_PECK", + "height_m": 0.29344871640205383, + "weight_kg": 1.9293220043182373, + "individual_attack": 10, + "individual_defense": 5, + "individual_stamina": 13, + "cp_multiplier": 0.16639786958694458, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926594385212866560", + "creation_time_ms": "1471690326729" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "9844476046022103294", + "pokemon_id": "CHARMANDER", + "cp": 12, + "stamina": 10, + "stamina_max": 10, + "move_1": "SCRATCH_FAST", + "move_2": "FLAMETHROWER", + "height_m": 0.7560690641403198, + "weight_kg": 14.30856990814209, + "individual_attack": 10, + "individual_defense": 10, + "individual_stamina": 10, + "cp_multiplier": 0.09399999678134918, + "captured_cell_id": "10781478022840057856", + "creation_time_ms": "1471100247635" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "STARYU", + "times_encountered": 2, + "times_captured": 2 + } + } + }, + { + "modified_timestamp_ms": "1471779858667", + "inventory_item_data": { + "player_stats": { + "level": 8, + "experience": "32875", + "prev_level_xp": "21000", + "next_level_xp": "36000", + "km_walked": 3.921541213989258, + "pokemons_encountered": 75, + "unique_pokedex_entries": 25, + "pokemons_captured": 71, + "poke_stop_visits": 123, + "pokeballs_thrown": 74, + "eggs_hatched": 1, + "big_magikarp_caught": 1, + "pokemon_deployed": 1, + "pokemon_caught_by_type": { + "type": "Buffer", + "data": [ + 0, + 24, + 0, + 26, + 20, + 1, + 0, + 14, + 0, + 0, + 1, + 14, + 3, + 0, + 1, + 0, + 0, + 0, + 3 + ] } - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "pokedex_entry": new proto.Data.PokedexEntry({ - "pokemon_id": 16, - "times_encountered": 3, - "times_captured": 1, - "evolution_stone_pieces": 0, - "evolution_stones": 0 - }) - }) - }), - new proto.Inventory.InventoryItem({ - "modified_timestamp_ms": new Date().getTime() * 1e3, - "inventory_item_data": new proto.Inventory.InventoryItemData({ - "item": new proto.Inventory.Item.ItemData({ - "item_id": 401, - "count": 2, - "unseen": true - }) - }) - }) - ] - }) - }).encode() - ); + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "11744424908786525656", + "is_egg": true, + "egg_km_walked_target": 10, + "captured_cell_id": "9926593973010300928", + "egg_incubator_id": "EggIncubatorProto-2555040734197054659", + "creation_time_ms": "1471690023913" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "6969639762681983910", + "pokemon_id": "PINSIR", + "cp": 28, + "stamina": 13, + "stamina_max": 13, + "move_1": "FURY_CUTTER_FAST", + "move_2": "SUBMISSION", + "height_m": 1.304322361946106, + "weight_kg": 31.694673538208008, + "individual_attack": 13, + "individual_defense": 2, + "individual_stamina": 15, + "cp_multiplier": 0.09399999678134918, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471695906137" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "PINSIR", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "candy": { + "family_id": "FAMILY_GROWLITHE", + "candy": 3 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "CHARMANDER", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "item": { + "item_id": "ITEM_INCUBATOR_BASIC", + "count": 1, + "unseen": true + } + } + }, + { + "modified_timestamp_ms": new Date().getTime(), + "inventory_item_data": { + "item": { + "item_id": "ITEM_POKE_BALL", + "count": 209 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "5976745051113111367", + "pokemon_id": "CATERPIE", + "cp": 49, + "stamina": 26, + "stamina_max": 26, + "move_1": "BUG_BITE_FAST", + "move_2": "STRUGGLE", + "height_m": 0.24649560451507568, + "weight_kg": 1.6669996976852417, + "individual_attack": 11, + "individual_defense": 5, + "cp_multiplier": 0.29024988412857056, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471691567691" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "CATERPIE", + "times_encountered": 5, + "times_captured": 5 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "WEEDLE", + "times_encountered": 5, + "times_captured": 5 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "11858657374888779686", + "is_egg": true, + "egg_km_walked_target": 2, + "captured_cell_id": "9926593977120718848", + "creation_time_ms": "1471689730292" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "PIDGEY", + "times_encountered": 13, + "times_captured": 12 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "PIDGEOTTO", + "times_encountered": 1, + "times_captured": 1 + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "17367836743335105913", + "is_egg": true, + "egg_km_walked_target": 5, + "captured_cell_id": "9926593976665636864", + "creation_time_ms": "1471689736014" + } + } + }, + { + "inventory_item_data": { + "pokemon_data": { + "id": "276965584718075753", + "pokemon_id": "ZUBAT", + "cp": 62, + "stamina": 23, + "stamina_max": 23, + "move_1": "BITE_FAST", + "move_2": "SLUDGE_BOMB", + "height_m": 0.8217771649360657, + "weight_kg": 8.549221992492676, + "individual_attack": 11, + "individual_defense": 14, + "individual_stamina": 10, + "cp_multiplier": 0.2557200491428375, + "pokeball": "ITEM_POKE_BALL", + "captured_cell_id": "9926768108050055168", + "creation_time_ms": "1471694026807" + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "RATTATA", + "times_encountered": 7, + "times_captured": 7 + } + } + }, + { + "inventory_item_data": { + "pokedex_entry": { + "pokemon_id": "SPEAROW", + "times_encountered": 2, + "times_captured": 2 + } + } + } + ] + }, + "$unknownFields": [] +}); + + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetInventoryResponse")); } \ No newline at end of file diff --git a/src/packets/Responses.GetMapObjects.js b/src/packets/Responses.GetMapObjects.js index 8245212..9102c63 100644 --- a/src/packets/Responses.GetMapObjects.js +++ b/src/packets/Responses.GetMapObjects.js @@ -1,9 +1,10 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; import { decodeLong } from "../utils"; - + /** * @param {Player} player * @param {Request} request @@ -11,96 +12,1319 @@ import { */ export default function GetMapObjects(player, request) { - let cells = proto.Networking.Requests.Messages.GetMapObjectsMessage.decode(request.request_message.toBuffer()).cell_id; + let buffer = ({ + "map_cells": [ + { + "s2_cell_id": "9781205377482752000", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "080edcf9e1ef429f8b29cc30f7723bc4.16", + "last_modified_timestamp_ms": "1471051322524", + "latitude": 39.188289, + "longitude": -96.57824, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "5a19a585c135457ebd5db1e2601211b9.16", + "last_modified_timestamp_ms": "1470031346220", + "latitude": 39.189395, + "longitude": -96.577655, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781205371040301056", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "023e03844d3c470785bb7ead037cae56.16", + "last_modified_timestamp_ms": "1471744752632", + "latitude": 39.189764, + "longitude": -96.575858, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "1084eede227a4887864a60f3ac71b8e0.16", + "last_modified_timestamp_ms": "1471576408145", + "latitude": 39.189861, + "longitude": -96.577463, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "1e2e673e468f4165aea2c14fdab25a50.16", + "last_modified_timestamp_ms": "1470247256215", + "latitude": 39.189806, + "longitude": -96.57655, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "5b45ce2eb3424088b80188deabb2bf15.16", + "last_modified_timestamp_ms": "1471404572057", + "latitude": 39.192215, + "longitude": -96.577861, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "6cf8d564a7d14cb7a94b75e2bdd0e26c.16", + "last_modified_timestamp_ms": "1471795371065", + "latitude": 39.190364, + "longitude": -96.576983, + "enabled": true, + "owned_by_team": "RED", + "guard_pokemon_id": "GYARADOS", + "gym_points": "12426" + }, + { + "id": "7c59b05b095c48fabb19939fb2c81f85.16", + "last_modified_timestamp_ms": "1471576398808", + "latitude": 39.18987, + "longitude": -96.577752, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "a049481adfff40c0b8e69c270e87ec2d.16", + "last_modified_timestamp_ms": "1471795344448", + "latitude": 39.192228, + "longitude": -96.577043, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.19219872050884, + "longitude": -96.57746281751568 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199991593762816", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "280ff308f32c47389415a295bfa25570.16", + "last_modified_timestamp_ms": "1471644491787", + "latitude": 39.190921, + "longitude": -96.590022, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "5d5ff9103187497db10a2e78b601fb67.16", + "last_modified_timestamp_ms": "1471800441422", + "latitude": 39.189845, + "longitude": -96.58905, + "enabled": true, + "owned_by_team": "RED", + "guard_pokemon_id": "SNORLAX", + "gym_points": "24751", + "is_in_battle": true + }, + { + "id": "a3ac1ce89c4a4e688d96aa6edb0be076.16", + "last_modified_timestamp_ms": "1471792115365", + "latitude": 39.189731, + "longitude": -96.590123, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199985151311872", + "current_timestamp_ms": new Date().getTime(), + "forts": [], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199974413893632", + "current_timestamp_ms": new Date().getTime(), + "forts": [], + "spawn_points": [ + { + "latitude": 39.193469215706344, + "longitude": -96.5864720716297 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199967971442688", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "6d585fd260a14672a6c8e81a5ef1c00f.16", + "last_modified_timestamp_ms": "1471026510451", + "latitude": 39.192223, + "longitude": -96.584249, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "7eefc291c5684a58bd430d00bb4a02fa.16", + "last_modified_timestamp_ms": "1471782735236", + "latitude": 39.192495, + "longitude": -96.586269, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "93301f0081ba479195e2e8199d245319.16", + "last_modified_timestamp_ms": "1470677059027", + "latitude": 39.192929, + "longitude": -96.583742, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "9ef09b3d6de848bc85345a8ed87eaadd.16", + "last_modified_timestamp_ms": "1471557306995", + "latitude": 39.194114, + "longitude": -96.58532, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "ac607a7add254949b1793a333c14b5ee.16", + "last_modified_timestamp_ms": "1470754949012", + "latitude": 39.19312, + "longitude": -96.585216, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.19275534975167, + "longitude": -96.58622179738788 + }, + { + "latitude": 39.19327371754913, + "longitude": -96.5856378279749 + }, + { + "latitude": 39.19351638961815, + "longitude": -96.5856378279749 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199980856344576", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "0375a78fbe6d47d4a218835fb2cf2526.16", + "last_modified_timestamp_ms": "1471038056307", + "latitude": 39.188371, + "longitude": -96.584562, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "4cc6cfa975874931bf3377c999359c56.16", + "last_modified_timestamp_ms": "1470936587696", + "latitude": 39.186824, + "longitude": -96.584704, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "98ee4e63753347dca11ae6e6aa204867.16", + "last_modified_timestamp_ms": "1469037682295", + "latitude": 39.187161, + "longitude": -96.585232, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "9c7333626aff4c9a995ae8ae5b859bc0.11", + "last_modified_timestamp_ms": "1471757750681", + "latitude": 39.186809, + "longitude": -96.583773, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "ef51b905d9594d52a6c0df2bccfd7a40.16", + "last_modified_timestamp_ms": "1471749668125", + "latitude": 39.187588, + "longitude": -96.585254, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199983003828224", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "f25f5bb62ee74185b35180024f17434c.16", + "last_modified_timestamp_ms": "1471550764849", + "latitude": 39.186555, + "longitude": -96.586559, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199976561377280", + "current_timestamp_ms": new Date().getTime(), + "forts": [], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199978708860928", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "03a289706b324e5ca289e77d0f03733f.16", + "last_modified_timestamp_ms": "1471298173282", + "latitude": 39.190998, + "longitude": -96.584099, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "601d019e865b46e9a62934a4417dc4ee.16", + "last_modified_timestamp_ms": "1471555931903", + "latitude": 39.190639, + "longitude": -96.584886, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "614e1b214a1844849dfbc8d14ee9e443.11", + "last_modified_timestamp_ms": "1471651642493", + "latitude": 39.190475, + "longitude": -96.584527, + "enabled": true, + "type": "CHECKPOINT", + "cooldown_complete_timestamp_ms": "1471780158665" + }, + { + "id": "97dad10ec7c74b498e3ce449cf167fe8.16", + "last_modified_timestamp_ms": "1471732087850", + "latitude": 39.190583, + "longitude": -96.586108, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "ac4ab9e172c440f18ae0f37855d45efc.16", + "last_modified_timestamp_ms": "1471800306431", + "latitude": 39.19038, + "longitude": -96.584106, + "enabled": true, + "owned_by_team": "RED", + "guard_pokemon_id": "VAPOREON", + "gym_points": "22697" + }, + { + "id": "f810680ded144b9c9e258cad59584932.11", + "last_modified_timestamp_ms": "1470559731922", + "latitude": 39.189884, + "longitude": -96.584104, + "enabled": true, + "type": "CHECKPOINT", + "cooldown_complete_timestamp_ms": "1471780084584" + } + ], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199955086540800", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "14e9f2671f2a44f68011ad29f2207018.16", + "last_modified_timestamp_ms": "1470316275511", + "latitude": 39.191213, + "longitude": -96.581955, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "282d96b677a74610a4d5ee7815009411.16", + "last_modified_timestamp_ms": "1470487074907", + "latitude": 39.190158, + "longitude": -96.58178, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "53a79f5b2cdd44718e31b9c40013da7b.16", + "last_modified_timestamp_ms": "1471585616392", + "latitude": 39.192012, + "longitude": -96.581328, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "5999459ff2d340078828ef072ec0ef9c.16", + "last_modified_timestamp_ms": "1470234749934", + "latitude": 39.191629, + "longitude": -96.58323, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "99b7abe5c415420fa76eca762921a252.11", + "last_modified_timestamp_ms": "1471622037923", + "latitude": 39.190233, + "longitude": -96.58131, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "a4fa0dde26464b30b1cde9ab98be0918.11", + "last_modified_timestamp_ms": "1471718373154", + "latitude": 39.190089, + "longitude": -96.58322, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "ad6f130078154fbb922cc525ab30d106.11", + "last_modified_timestamp_ms": "1471405146419", + "latitude": 39.189808, + "longitude": -96.581257, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "c86bc747a0fe48bc96aa9008622540f8.16", + "last_modified_timestamp_ms": "1470561775245", + "latitude": 39.189609, + "longitude": -96.58247, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "f566caf28e1047a6bad2ac0d654239ac.16", + "last_modified_timestamp_ms": "1471529893584", + "latitude": 39.191381, + "longitude": -96.581713, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.1896124600141, + "longitude": -96.58171702892608 + }, + { + "latitude": 39.189726350923266, + "longitude": -96.58113310075188 + }, + { + "latitude": 39.19181546751814, + "longitude": -96.58138335502902 + }, + { + "latitude": 39.19198668072476, + "longitude": -96.58121651873516 + }, + { + "latitude": 39.19182960806035, + "longitude": -96.58113310075188 + }, + { + "latitude": 39.19196311246427, + "longitude": -96.58163361028815 + }, + { + "latitude": 39.191967826248934, + "longitude": -96.58155019175932 + }, + { + "latitude": 39.19198196720522, + "longitude": -96.58129993682753 + }, + { + "latitude": 39.19190578772032, + "longitude": -96.58121651873516 + }, + { + "latitude": 39.19150132114832, + "longitude": -96.58121651873516 + }, + { + "latitude": 39.191753428225304, + "longitude": -96.58104968287773 + }, + { + "latitude": 39.19126806675631, + "longitude": -96.58104968287773 + }, + { + "latitude": 39.19183432144186, + "longitude": -96.58104968287773 + }, + { + "latitude": 39.19134896059277, + "longitude": -96.58104968287773 + }, + { + "latitude": 39.19159164148224, + "longitude": -96.58104968287773 + }, + { + "latitude": 39.19109685199338, + "longitude": -96.58121651873516 + }, + { + "latitude": 39.19116831898037, + "longitude": -96.58138335502902 + }, + { + "latitude": 39.189811960033076, + "longitude": -96.58104968287773 + }, + { + "latitude": 39.18996432461859, + "longitude": -96.58121651873516 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199957234024448", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "155dc7e5f0054faa81ea56c6e8c54f68.16", + "last_modified_timestamp_ms": "1471458301136", + "latitude": 39.189603, + "longitude": -96.578715, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "217e9c24680541e89b8a432a7552ae1b.16", + "last_modified_timestamp_ms": "1471787760082", + "latitude": 39.1905, + "longitude": -96.579088, + "enabled": true, + "owned_by_team": "RED", + "guard_pokemon_id": "VAPOREON", + "gym_points": "18423" + }, + { + "id": "30f6dbee9eeb4e0e979a99741cf3304d.16", + "last_modified_timestamp_ms": "1471573445404", + "latitude": 39.191939, + "longitude": -96.578589, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "4807de0920154dabaadf0cad98b3d0b9.16", + "last_modified_timestamp_ms": "1471630498363", + "latitude": 39.190973, + "longitude": -96.580973, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "5408fa0fd76145c8a3c5c61b1ea2bceb.11", + "last_modified_timestamp_ms": "1471465165042", + "latitude": 39.190004, + "longitude": -96.579479, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "5b451cde8f18433f88414789ae7ce55f.11", + "last_modified_timestamp_ms": "1471719704625", + "latitude": 39.191467, + "longitude": -96.580898, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "62d85d9b92654a99aae85980d62aa895.16", + "last_modified_timestamp_ms": "1471411498696", + "latitude": 39.19141, + "longitude": -96.579584, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "6b8ac3edccc64837b9898b9a1029761a.16", + "last_modified_timestamp_ms": "1471650819287", + "latitude": 39.191529, + "longitude": -96.579846, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "a2710e9d1a3f440bb3796a8e0d0f7653.12", + "last_modified_timestamp_ms": "1471720350458", + "latitude": 39.190489, + "longitude": -96.580542, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "a319260fdfa04545b4d09c5f4d649d1a.11", + "last_modified_timestamp_ms": "1471463408586", + "latitude": 39.189828, + "longitude": -96.580015, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "f01cb9e600444afc8f4681977ce2930e.16", + "last_modified_timestamp_ms": "1471645573471", + "latitude": 39.192106, + "longitude": -96.579022, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.19008763820493, + "longitude": -96.58046576081381 + }, + { + "latitude": 39.18998789088006, + "longitude": -96.58079942990994 + }, + { + "latitude": 39.1913772393915, + "longitude": -96.58054917792418 + }, + { + "latitude": 39.191201312497725, + "longitude": -96.58079942990994 + }, + { + "latitude": 39.18999260393353, + "longitude": -96.58071601247224 + }, + { + "latitude": 39.189906995279046, + "longitude": -96.58079942990994 + }, + { + "latitude": 39.189559067794576, + "longitude": -96.57979842785916 + }, + { + "latitude": 39.190163820750165, + "longitude": -96.58054917792418 + }, + { + "latitude": 39.19135367389158, + "longitude": -96.58096626511268 + }, + { + "latitude": 39.19154373969393, + "longitude": -96.58046576081381 + }, + { + "latitude": 39.19122016447811, + "longitude": -96.58046576081381 + }, + { + "latitude": 39.19169138774681, + "longitude": -96.58071601247224 + }, + { + "latitude": 39.19169610079146, + "longitude": -96.58063259514365 + }, + { + "latitude": 39.191943493468735, + "longitude": -96.58054917792418 + }, + { + "latitude": 39.191372526424075, + "longitude": -96.58063259514365 + }, + { + "latitude": 39.1901732464041, + "longitude": -96.58038234381257 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199950791573504", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "3ddc92da8fba4e24b967d5216da68d8a.16", + "last_modified_timestamp_ms": "1470507065167", + "latitude": 39.189333, + "longitude": -96.58045, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "48715a49e53f406d96f77e22b5f91415.11", + "last_modified_timestamp_ms": "1471717500458", + "latitude": 39.187914, + "longitude": -96.580012, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "57b640b14e234607bfb04d3d66d841fd.16", + "last_modified_timestamp_ms": "1471039597671", + "latitude": 39.187895, + "longitude": -96.579301, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "88e61d1f13294c6098122e3213780f0b.16", + "last_modified_timestamp_ms": "1471525597252", + "latitude": 39.187657, + "longitude": -96.578385, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "c1ba5f8eda744d0aa49ca389c23c60d5.11", + "last_modified_timestamp_ms": "1471551825715", + "latitude": 39.188057, + "longitude": -96.58098, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "ce7fae6154004f21a986aa0483d829ae.16", + "last_modified_timestamp_ms": "1471790729135", + "latitude": 39.189402, + "longitude": -96.578673, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "d4547cbebd4f400dbf150af82347ef08.16", + "last_modified_timestamp_ms": "1470111292530", + "latitude": 39.189, + "longitude": -96.57907, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "d9a15d395b0e42efb8641af0f9070f7f.16", + "last_modified_timestamp_ms": "1469915007418", + "latitude": 39.188439, + "longitude": -96.580529, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.18870768769649, + "longitude": -96.58054917792418 + }, + { + "latitude": 39.189330515225215, + "longitude": -96.5795481798016 + }, + { + "latitude": 39.18877366101736, + "longitude": -96.57938134830886 + }, + { + "latitude": 39.18740389337131, + "longitude": -96.58071601247224 + }, + { + "latitude": 39.188307913149515, + "longitude": -96.58046576081381 + }, + { + "latitude": 39.188992791848875, + "longitude": -96.57979842785916 + }, + { + "latitude": 39.188017309051496, + "longitude": -96.57988184409656 + }, + { + "latitude": 39.18825529074279, + "longitude": -96.57996526044312 + }, + { + "latitude": 39.18826942753547, + "longitude": -96.57971501173085 + }, + { + "latitude": 39.188250578346015, + "longitude": -96.58004867689877 + }, + { + "latitude": 39.18863150324239, + "longitude": -96.58046576081381 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199952939057152", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "108dc9c703a94b619a53a3c29b5c676f.11", + "last_modified_timestamp_ms": "1471621873766", + "latitude": 39.188577, + "longitude": -96.583527, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "1391315b489f421abd52ce10b6da7dd3.16", + "last_modified_timestamp_ms": "1471776325164", + "latitude": 39.188351, + "longitude": -96.582561, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "33ad17c71fff4797b7f25dcfcdca48df.16", + "last_modified_timestamp_ms": "1470755536809", + "latitude": 39.189386, + "longitude": -96.581113, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "40f86138ca6f49cc9e98e18b77d6067a.16", + "last_modified_timestamp_ms": "1471748353301", + "latitude": 39.188351, + "longitude": -96.582209, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "560ef7ed6cb5469db29b543cce7677ae.16", + "last_modified_timestamp_ms": "1469923654520", + "latitude": 39.186848, + "longitude": -96.581267, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "60d2ffcfe9cf4003b4d94bcc9ee0c318.16", + "last_modified_timestamp_ms": "1471743176808", + "latitude": 39.188008, + "longitude": -96.582409, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "637941f1f2494276884ede4fc538c2b2.16", + "last_modified_timestamp_ms": "1471757787582", + "latitude": 39.186868, + "longitude": -96.583295, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "7c0154d02e4f4d91b9b74214eda75abc.16", + "last_modified_timestamp_ms": "1471483788730", + "latitude": 39.187991, + "longitude": -96.581251, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "8a94bf6cd17b43be8b5b42655d23e2f6.16", + "last_modified_timestamp_ms": "1471751252546", + "latitude": 39.187684, + "longitude": -96.583537, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "9b469dbd550f43b5a8e94f941d66bc43.16", + "last_modified_timestamp_ms": "1471243641146", + "latitude": 39.189051, + "longitude": -96.581804, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "bb0e515e3f554b398f1fa9c58435dc78.16", + "last_modified_timestamp_ms": "1471748285036", + "latitude": 39.188823, + "longitude": -96.582742, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.188870250798956, + "longitude": -96.58196728549451 + }, + { + "latitude": 39.1889464335866, + "longitude": -96.58205070456887 + }, + { + "latitude": 39.18887496474473, + "longitude": -96.58188386652927 + }, + { + "latitude": 39.18879406783625, + "longitude": -96.58188386652927 + }, + { + "latitude": 39.189284161630674, + "longitude": -96.58180044767312 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [ + { + "encounter_id": "15124390125922157165", + "last_modified_timestamp_ms": new Date().getTime(), + "latitude": 39.1882905753091, + "longitude": -96.58363568771144, + "spawn_point_id": "87bdcd88cb5", + "pokemon_data": { + "pokemon_id": "MEWTWO" + }, + "time_till_hidden_ms": 20000 + }, + { + "encounter_id": "15124390125922157169", + "last_modified_timestamp_ms": new Date().getTime(), + "latitude": 39.1884905743091, + "longitude": -96.58363568761144, + "spawn_point_id": "87bdcd88cb5", + "pokemon_data": { + "pokemon_id": "MEW" + }, + "time_till_hidden_ms": 30000 + }, + { + "encounter_id": "15124390125922157129", + "last_modified_timestamp_ms": new Date().getTime(), + "latitude": 39.1884905743091, + "longitude": -96.58343568761143, + "spawn_point_id": "87bdcd88cb5", + "pokemon_data": { + "pokemon_id": "ZAPDOS" + }, + "time_till_hidden_ms": 40000 + } + ], + "catchable_pokemons": [ + { + "spawn_point_id": "87bdcd88cb5", + "encounter_id": "15124390125922157165", + "pokemon_id": "MEWTWO", + "expiration_timestamp_ms": "1471800475092", + "latitude": 39.1882905753091, + "longitude": -96.58363568771144 + }, + { + "spawn_point_id": "87bdcd88cb5", + "encounter_id": "15124390125922157169", + "pokemon_id": "MEW", + "expiration_timestamp_ms": "1471800475092", + "latitude": 39.1884905743091, + "longitude": -96.58363568761144 + }, + { + "spawn_point_id": "87bdcd88cb5", + "encounter_id": "15124390125922157129", + "pokemon_id": "ZAPDOS", + "expiration_timestamp_ms": "1471800475092", + "latitude": 39.1884905743091, + "longitude": -96.58343568761143 + } + ], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199965823959040", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "2715ee21d0844c6fbb0fda3a2029e945.16", + "last_modified_timestamp_ms": "1471710797897", + "latitude": 39.192669, + "longitude": -96.583311, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "4cd3b930af1a4f248f6c01af748115bd.16", + "last_modified_timestamp_ms": "1471575743600", + "latitude": 39.192082, + "longitude": -96.582129, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "66fd7861f1794235a8b4ab9e75abdff8.16", + "last_modified_timestamp_ms": "1471364750124", + "latitude": 39.193544, + "longitude": -96.583396, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "80948d46cb744685b00f3f6923ac65bc.16", + "last_modified_timestamp_ms": "1471293569339", + "latitude": 39.194292, + "longitude": -96.582015, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "b54e269be87c49478d27d8bef6018f58.11", + "last_modified_timestamp_ms": "1470692404303", + "latitude": 39.192906, + "longitude": -96.581716, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "ded8ab4bc4a9473a9679d3c12f0ea852.16", + "last_modified_timestamp_ms": "1471585725951", + "latitude": 39.192085, + "longitude": -96.581052, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.192044005351725, + "longitude": -96.58163361028815 + }, + { + "latitude": 39.192020435420545, + "longitude": -96.58205070456887 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199959381508096", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "751ec666414247d78fd259028f701590.16", + "last_modified_timestamp_ms": "1471012618815", + "latitude": 39.194234, + "longitude": -96.579903, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "7f4aa8a610aa4d9db68a36bec83fd745.16", + "last_modified_timestamp_ms": "1471573864363", + "latitude": 39.192719, + "longitude": -96.579799, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "bbdf4444583546d9b2b729ec5d45537e.11", + "last_modified_timestamp_ms": "1471797235873", + "latitude": 39.193056, + "longitude": -96.579455, + "enabled": true, + "owned_by_team": "BLUE", + "guard_pokemon_id": "VAPOREON", + "gym_points": "4000" + }, + { + "id": "d7812fa64a4942d2ab6d7df3190cd0a6.11", + "last_modified_timestamp_ms": "1471645568026", + "latitude": 39.192212, + "longitude": -96.579514, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.1944071543913, + "longitude": -96.57846378290101 + }, + { + "latitude": 39.19441186573404, + "longitude": -96.5783803685187 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199937906671616", + "current_timestamp_ms": new Date().getTime(), + "forts": [], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199940054155264", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "116fe592ee124bc782189e3b236543b9.16", + "last_modified_timestamp_ms": "1471789051235", + "latitude": 39.186487, + "longitude": -96.585603, + "enabled": true, + "owned_by_team": "RED", + "guard_pokemon_id": "DRAGONITE", + "gym_points": "10034" + }, + { + "id": "7516ab5a89b2456fa3b3454d94308c2f.16", + "last_modified_timestamp_ms": "1471569169549", + "latitude": 39.185858, + "longitude": -96.585593, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "9315a6c61b294fffa453593262784d42.16", + "last_modified_timestamp_ms": "1470527342920", + "latitude": 39.186378, + "longitude": -96.584565, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "ca827e78a2514218ab70bb407ef0b798.16", + "last_modified_timestamp_ms": "1471781381973", + "latitude": 39.186659, + "longitude": -96.583743, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199948644089856", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "0c73510c66ed4bcfa92f77df2d7dc7f0.11", + "last_modified_timestamp_ms": "1470924273803", + "latitude": 39.186695, + "longitude": -96.580794, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "111a01218f71427482ef2afb4655110b.16", + "last_modified_timestamp_ms": "1471495631668", + "latitude": 39.185378, + "longitude": -96.578626, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "1af804d6d5214911913d88b33af581ad.16", + "last_modified_timestamp_ms": "1471799300878", + "latitude": 39.186628, + "longitude": -96.578443, + "enabled": true, + "owned_by_team": "YELLOW", + "guard_pokemon_id": "FLAREON", + "gym_points": "4000" + }, + { + "id": "77feee0994214897a3b6dce58a3ad4dd.16", + "last_modified_timestamp_ms": "1471765255682", + "latitude": 39.185924, + "longitude": -96.578763, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "7b1208b02f6843889c52fb7d1d569ecc.11", + "last_modified_timestamp_ms": "1470039557132", + "latitude": 39.186489, + "longitude": -96.579886, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "cc692d8b24f64244884d9481e9c83ebd.16", + "last_modified_timestamp_ms": "1468345908021", + "latitude": 39.186268, + "longitude": -96.579524, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + }, + { + "s2_cell_id": "9781199942201638912", + "current_timestamp_ms": new Date().getTime(), + "forts": [ + { + "id": "1e81f35de1f34fd994c320332497705f.16", + "last_modified_timestamp_ms": "1471781376676", + "latitude": 39.186289, + "longitude": -96.583305, + "enabled": true, + "type": "CHECKPOINT" + }, + { + "id": "cd1b34b754cb4a33add1dacb7f161177.16", + "last_modified_timestamp_ms": "1471726904495", + "latitude": 39.18591, + "longitude": -96.581364, + "enabled": true, + "type": "CHECKPOINT" + } + ], + "spawn_points": [ + { + "latitude": 39.18646686734363, + "longitude": -96.58155019175932 + } + ], + "deleted_objects": [], + "fort_summaries": [], + "decimated_spawn_points": [], + "wild_pokemons": [], + "catchable_pokemons": [], + "nearby_pokemons": [] + } + ], + "status": "SUCCESS", + "$unknownFields": [] +}); - let cellsRes = []; - - let pokemon_id = 121; - - cells.forEach((cell) => { - cellsRes.push(new proto.Map.MapCell({ - s2_cell_id: cell, - current_timestamp_ms: new Date().getTime() * 1e3, - forts: [], - spawn_points: [], - deleted_objects: [], - is_truncated_list: false, - fort_summaries: [], - decimated_spawn_points: [], - wild_pokemons: [], - catchable_pokemons: [], - nearby_pokemons: [] - })); - }); - - let latitude = player.latitude; - let longitude = player.longitude; - - let cell = cellsRes[0]; - - cell.forts = [ - new proto.Map.Fort.FortData({ - id: "roflcopter", - last_modified_timestamp_ms: 1470787552992, - //latitude: 39.1914, - //longitude: -96.5850, - latitude: latitude, - longitude: longitude, - enabled: true, - type: proto.Map.Fort.FortType.CHECKPOINT, - cooldown_complete_timestamp_ms: new Date().getTime(), - sponsor: proto.Map.Fort.FortSponsor.UNSET_SPONSOR - }) - ]; - - cell.wild_pokemons = [ - new proto.Map.Pokemon.WildPokemon({ - encounter_id: 11810991820755313517, - last_modified_timestamp_ms: 1470787552996, - latitude: latitude, - longitude: longitude, - spawn_point_id: "87bdd289c69", - pokemon_data: new proto.Data.PokemonData({ - pokemon_id: pokemon_id, - cp: 277, - stamina: 41, - stamina_max: 41, - move_1: 221, - move_2: 26, - height_m: 0.22802678267819977, - weight_kg: 1.3452539511871338, - individual_attack: 9, - individual_defense: 13, - individual_stamina: 14, - cp_multiplier: 0.5663545199394226 - }), - time_till_hidden_ms: 730176 - }) - ]; - - cell.catchable_pokemons = [ - new proto.Map.Pokemon.MapPokemon({ - spawn_point_id: "87bdd289c69", - encounter_id: 11810991820755313517, - pokemon_id: pokemon_id, - latitude: latitude, - longitude: longitude, - expiration_timestamp_ms: (new Date().getTime() + 1e6) * 1e3 - }) - ]; - - cell.nearby_pokemons = [ - new proto.Map.Pokemon.NearbyPokemon({ - distance_in_meters: 200.0, - pokemon_id: pokemon_id - }) - ]; - - return ( - new proto.Networking.Responses.GetMapObjectsResponse({ - status: 1, - map_cells: cellsRes - }).encode() - ); + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetMapObjectsResponse")); } \ No newline at end of file diff --git a/src/packets/Responses.GetPlayer.js b/src/packets/Responses.GetPlayer.js index 098ecc3..9a40a0c 100644 --- a/src/packets/Responses.GetPlayer.js +++ b/src/packets/Responses.GetPlayer.js @@ -1,4 +1,5 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @param {Object} obj @@ -7,20 +8,20 @@ import proto from "../proto"; function getPlayerDataPacket(obj) { return ( - new proto.Data.PlayerData({ + { creation_timestamp_ms: 1467936859925, username: obj.username, team: proto.Enums.TeamColor.YELLOW, tutorial_state: obj.tutorial_state, - avatar: new proto.Data.Player.PlayerAvatar(obj.avatar), + avatar: obj.avatar, max_pokemon_storage: 250, max_item_storage: 350, - daily_bonus: new proto.Data.Player.DailyBonus({ + daily_bonus: { next_defender_bonus_collect_timestamp_ms: 1470174535972 - }), - contact_settings: new proto.Data.Player.ContactSettings(obj.contact_settings), + }, + contact_settings: obj.contact_settings, currencies: obj.currencies - }) + } ); } @@ -63,14 +64,14 @@ function buildPlayerData(obj) { ]; let currencies = [ - new proto.Data.Player.Currency({ + { name: "POKECOIN", amount: pokecoins - }), - new proto.Data.Player.Currency({ + }, + { name: "STARDUST", amount: stardust - }) + } ]; return ({ @@ -91,14 +92,43 @@ function buildPlayerData(obj) { export default function GetPlayer(obj) { let data = buildPlayerData(obj); - let packet = getPlayerDataPacket(data); - return ( - new proto.Networking.Responses.GetPlayerResponse({ - success: true, - player_data: packet - }) - ); + let buffer = { + "success": true, + "player_data": { + "creation_timestamp_ms": "1471096437979", + "username": "Administrator", + "team": "YELLOW", + "tutorial_state": [ + "LEGAL_SCREEN", + "AVATAR_SELECTION", + "POKEMON_CAPTURE", + "NAME_SELECTION", + "FIRST_TIME_EXPERIENCE_COMPLETE" + ], + "avatar": {}, + "max_pokemon_storage": 250, + "max_item_storage": 350, + "daily_bonus": {}, + "equipped_badge": {}, + "contact_settings": { + "send_marketing_emails": true + }, + "currencies": [ + { + "name": "POKECOIN", + "amount": 1339 + }, + { + "name": "STARDUST", + "amount": 7681 + } + ] + }, + "$unknownFields": [] + }; + + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetPlayerResponse")); } \ No newline at end of file diff --git a/src/packets/Responses.GetPlayerProfile.js b/src/packets/Responses.GetPlayerProfile.js index ca82c22..5a373ee 100644 --- a/src/packets/Responses.GetPlayerProfile.js +++ b/src/packets/Responses.GetPlayerProfile.js @@ -1,4 +1,5 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @param {Object} obj @@ -6,216 +7,162 @@ import proto from "../proto"; */ export default function GetPlayerProfile(obj) { - return ( - new proto.Networking.Responses.GetPlayerProfileResponse({ - result: proto.Networking.Responses.GetPlayerProfileResponse.Result.SUCCESS, - start_time: new Date().getTime() * 1000, - badges: [ - new proto.Data.PlayerBadge({ - "badge_type": 1, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 1.0598372225667916 - }), - new proto.Data.PlayerBadge({ - "badge_type": 2, - "rank": 1, - "start_value": 5, - "end_value": 50, - "current_value": 5.031372549019608 - }), - new proto.Data.PlayerBadge({ - "badge_type": 3, - "rank": 0, - "start_value": 0, - "end_value": 30, - "current_value": 5.031372549019608 - }), - new proto.Data.PlayerBadge({ - "badge_type": 5, - "rank": 0, - "start_value": 0, - "end_value": 3, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 6, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 8, - "rank": 0, - "start_value": 0, - "end_value": 100, - "current_value": 37.00098039215686 - }), - new proto.Data.PlayerBadge({ - "badge_type": 11, - "rank": 0, - "start_value": 0, - "end_value": 3, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 13, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 14, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 18, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 8.062745098039215 - }), - new proto.Data.PlayerBadge({ - "badge_type": 19, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 20, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 8.062745098039215 - }), - new proto.Data.PlayerBadge({ - "badge_type": 21, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 1.007843137254902 - }), - new proto.Data.PlayerBadge({ - "badge_type": 22, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 23, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 24, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 8.062745098039215 - }), - new proto.Data.PlayerBadge({ - "badge_type": 25, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 26, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 27, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 28, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 29, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 30, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 31, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 32, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 33, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 34, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 35, - "rank": 0, - "start_value": 0, - "end_value": 10, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 36, - "rank": 0, - "start_value": 0, - "end_value": 3, - "current_value": 0 - }), - new proto.Data.PlayerBadge({ - "badge_type": 37, - "rank": 0, - "start_value": 0, - "end_value": 3, - "current_value": 0 - }) - ] - }).encode() - ); + let buffer = ({ + "result": "SUCCESS", + "start_time": "1471096437979", + "badges": [ + { + "badge_type": "BADGE_TRAVEL_KM", + "end_value": 10, + "current_value": 3.921541213989258 + }, + { + "badge_type": "BADGE_POKEDEX_ENTRIES", + "rank": 1, + "start_value": 5, + "end_value": 50, + "current_value": 25 + }, + { + "badge_type": "BADGE_CAPTURE_TOTAL", + "rank": 1, + "start_value": 30, + "end_value": 500, + "current_value": 71 + }, + { + "badge_type": "BADGE_EVOLVED_TOTAL", + "end_value": 3 + }, + { + "badge_type": "BADGE_HATCHED_TOTAL", + "end_value": 10, + "current_value": 1 + }, + { + "badge_type": "BADGE_POKESTOPS_VISITED", + "rank": 1, + "start_value": 100, + "end_value": 1000, + "current_value": 123 + }, + { + "badge_type": "BADGE_BIG_MAGIKARP", + "end_value": 3, + "current_value": 1 + }, + { + "badge_type": "BADGE_BATTLE_ATTACK_WON", + "end_value": 10 + }, + { + "badge_type": "BADGE_BATTLE_TRAINING_WON", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_NORMAL", + "rank": 1, + "start_value": 10, + "end_value": 50, + "current_value": 24 + }, + { + "badge_type": "BADGE_TYPE_FIGHTING", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_FLYING", + "rank": 1, + "start_value": 10, + "end_value": 50, + "current_value": 26 + }, + { + "badge_type": "BADGE_TYPE_POISON", + "rank": 1, + "start_value": 10, + "end_value": 50, + "current_value": 20 + }, + { + "badge_type": "BADGE_TYPE_GROUND", + "end_value": 10, + "current_value": 1 + }, + { + "badge_type": "BADGE_TYPE_ROCK", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_BUG", + "rank": 1, + "start_value": 10, + "end_value": 50, + "current_value": 14 + }, + { + "badge_type": "BADGE_TYPE_GHOST", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_STEEL", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_FIRE", + "end_value": 10, + "current_value": 1 + }, + { + "badge_type": "BADGE_TYPE_WATER", + "rank": 1, + "start_value": 10, + "end_value": 50, + "current_value": 14 + }, + { + "badge_type": "BADGE_TYPE_GRASS", + "end_value": 10, + "current_value": 3 + }, + { + "badge_type": "BADGE_TYPE_ELECTRIC", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_PSYCHIC", + "end_value": 10, + "current_value": 1 + }, + { + "badge_type": "BADGE_TYPE_ICE", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_DRAGON", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_DARK", + "end_value": 10 + }, + { + "badge_type": "BADGE_TYPE_FAIRY", + "end_value": 10, + "current_value": 3 + }, + { + "badge_type": "BADGE_SMALL_RATTATA", + "end_value": 3 + }, + { + "badge_type": "BADGE_PIKACHU", + "end_value": 3 + } + ], + "$unknownFields": [] + }); + + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.GetPlayerProfileResponse")); } diff --git a/src/packets/Responses.ItemTemplates.js b/src/packets/Responses.ItemTemplates.js index 01e24eb..1025763 100644 --- a/src/packets/Responses.ItemTemplates.js +++ b/src/packets/Responses.ItemTemplates.js @@ -1,87 +1,12 @@ import CFG from "../../cfg"; +import fs from "fs"; import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** - * @param {Object} obj * @return {Object} */ -export default function ItemTemplates(obj) { - - return ( - new proto.Networking.Responses.DownloadItemTemplatesResponse({ - success: true, - item_templates: new proto.Networking.Responses.DownloadItemTemplatesResponse.ItemTemplate({ - pokemon_settings: null, - item_settings: null, - move_settings: null, - move_sequence_settings: null, - camera: null, - iap_item_display: null, - equipped_badges: null, - type_effective: new proto.Settings.Master.TypeEffectiveSettings({ - "attack_scalar": [1, 0.800000011920929, 0.800000011920929, 0.800000011920929, 1, 1, 1, 0.800000011920929, 0.800000011920929, 0.800000011920929, 1, 1.25, 1, 1.25, 1, 1, 1.25, 0.800000011920929], - "attack_type": 7 - }), - badge_settings: new proto.Settings.Master.BadgeSettings({ - "badge_type": 13, - "badge_rank": 4, - "targets": [10, 100, 1000] - }), - player_level: new proto.Settings.Master.PlayerLevelSettings({ - "rank_num": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - "required_experience": [0, 1000, 3000, 6000, 10000, 15000, 21000, 28000, 36000, 45000, 55000, 65000, 75000, 85000, 100000, 120000, 140000, 160000, 185000, 210000, 260000, 335000, 435000, 560000, 710000, 900000, 1100000, 1350000, 1650000, 2000000, 2500000, 3000000, 3750000, 4750000, 6000000, 7500000, 9500000, 12000000, 15000000, 20000000], - "cp_multiplier": [0.09399999678134918, 0.16639786958694458, 0.21573247015476227, 0.2557200491428375, 0.29024988412857056, 0.3210875988006592, 0.3492126762866974, 0.37523558735847473, 0.39956727623939514, 0.42250001430511475, 0.443107545375824, 0.4627983868122101, 0.48168495297431946, 0.49985843896865845, 0.517393946647644, 0.5343543291091919, 0.5507926940917969, 0.5667545199394226, 0.5822789072990417, 0.5974000096321106, 0.6121572852134705, 0.6265671253204346, 0.6406529545783997, 0.6544356346130371, 0.667934000492096, 0.6811649203300476, 0.6941436529159546, 0.7068842053413391, 0.719399094581604, 0.7317000031471252, 0.7377694845199585, 0.7437894344329834, 0.7497610449790955, 0.7556855082511902, 0.7615638375282288, 0.7673971652984619, 0.7731865048408508, 0.7789327502250671, 0.7846369743347168, 0.7903000116348267], - "max_egg_player_level": 20, - "max_encounter_player_level": 30 - }), - gym_level: new proto.Settings.Master.GymLevelSettings({ - "required_experience": [0, 2000, 4000, 8000, 12000, 16000, 20000, 30000, 40000, 50000], - "leader_slots": [1, 1, 1, 2, 2, 2, 3, 3, 3, 4], - "trainer_slots": [0, 1, 2, 2, 3, 4, 4, 5, 6, 6], - "search_roll_bonus": [] - }), - battle_settings: new proto.Settings.Master.GymBattleSettings({ - "energy_per_sec": 0, - "dodge_energy_cost": 0, - "retarget_seconds": 0.5, - "enemy_attack_interval": 1.5, - "attack_server_interval": 5, - "round_duration_seconds": 99, - "bonus_time_per_ally_seconds": 10, - "maximum_attackers_per_battle": 20, - "same_type_attack_bonus_multiplier": 1.25, - "maximum_energy": 100, - "energy_delta_per_health_lost": 0.5, - "dodge_duration_ms": 500, - "minimum_player_level": 5, - "swap_duration_ms": 1000 - }), - encounter_settings: new proto.Settings.Master.EncounterSettings({ - "spin_bonus_threshold": 0.5, - "excellent_throw_threshold": 1.7000000476837158, - "great_throw_threshold": 1.2999999523162842, - "nice_throw_threshold": 1, - "milestone_threshold": 100 - }), - iap_settings: new proto.Settings.Master.IapSettings({ - "daily_bonus_coins": 0, - "daily_defender_bonus_per_pokemon": [500, 10], - "daily_defender_bonus_max_defenders": 10, - "daily_defender_bonus_currency": ["STARDUST", "POKECOIN"], - "min_time_between_claims_ms": 0, - "daily_bonus_enabled": false, - "daily_defender_bonus_enabled": true - }), - pokemon_upgrades: new proto.Settings.Master.PokemonUpgradeSettings({ - "upgrades_per_level": 2, - "allowed_levels_above_player": 2, - "candy_cost": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 15, 15], - "stardust_cost": [200, 200, 400, 400, 600, 600, 800, 800, 1000, 1000, 1300, 1300, 1600, 1600, 1900, 1900, 2200, 2200, 2500, 2500, 3000, 3000, 3500, 3500, 4000, 4000, 4500, 4500, 5000, 5000, 6000, 6000, 7000, 7000, 8000, 8000, 9000, 9000, 10000, 10000] - }) - }), - timestamp_ms: 1468540960537 - }).encode() - ); - +export default function ItemTemplates() { + return (fs.readFileSync("data/game_master")); } \ No newline at end of file diff --git a/src/packets/Responses.LevelUpRewards.js b/src/packets/Responses.LevelUpRewards.js index 74f0172..5768804 100644 --- a/src/packets/Responses.LevelUpRewards.js +++ b/src/packets/Responses.LevelUpRewards.js @@ -1,4 +1,5 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; import { GetPlayer } from "./"; @@ -8,12 +9,13 @@ import { GetPlayer } from "./"; */ export default function LevelUpRewards(obj) { - return ( - new proto.Networking.Responses.LevelUpRewardsResponse({ - result: 2, - items_awarded: [], - items_unlocked: [] - }).encode() - ); + let buffer = { + "result": "AWARDED_ALREADY", + "items_awarded": [], + "items_unlocked": [], + "$unknownFields": [] + } + + return POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.LevelUpRewardsResponse"); } \ No newline at end of file diff --git a/src/packets/Responses.SetAvatar.js b/src/packets/Responses.SetAvatar.js index 79adc87..5805aa3 100644 --- a/src/packets/Responses.SetAvatar.js +++ b/src/packets/Responses.SetAvatar.js @@ -1,4 +1,5 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; import { GetPlayer } from "./"; @@ -8,11 +9,11 @@ import { GetPlayer } from "./"; */ export default function SetAvatar(player) { - return ( - new proto.Networking.Responses.SetAvatarResponse({ - status: proto.Networking.Responses.SetAvatarResponse.Status.SUCCESS, - player_data: GetPlayer(player).player_data - }).encode() - ); + let buffer = ({ + status: proto.Networking.Responses.SetAvatarResponse.Status.SUCCESS, + player_data: GetPlayer(player).player_data + }); + + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.SetAvatarResponse")); } \ No newline at end of file diff --git a/src/packets/Responses.SetFavoritePokemon.js b/src/packets/Responses.SetFavoritePokemon.js index ca7322c..f295ba0 100644 --- a/src/packets/Responses.SetFavoritePokemon.js +++ b/src/packets/Responses.SetFavoritePokemon.js @@ -1,6 +1,7 @@ import CFG from "../../cfg"; import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; /** * @param {Request} req @@ -8,14 +9,12 @@ import proto from "../proto"; */ export default function SetFavoritePokemon(req) { - let data = proto.Networking.Requests.Messages.SetFavoritePokemonMessage.decode(req.request_message.toBuffer()); -console.log(data); - // TODO: save into db + buffer = ({ + result: proto.Networking.Responses.SetFavoritePokemonResponse.Result.ERROR_POKEMON_NOT_FOUND + }); return ( - new proto.Networking.Responses.SetFavoritePokemonResponse({ - result: proto.Networking.Responses.SetFavoritePokemonResponse.Result.ERROR_POKEMON_NOT_FOUND - }).encode() + POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.SetFavoritePokemonResponse") ); } \ No newline at end of file diff --git a/src/packets/Responses.SfidaActionLog.js b/src/packets/Responses.SfidaActionLog.js index e879396..5c107c9 100644 --- a/src/packets/Responses.SfidaActionLog.js +++ b/src/packets/Responses.SfidaActionLog.js @@ -1,4 +1,5 @@ import proto from "../proto"; +import POGOProtos from "pokemongo-protobuf"; import CFG from "../../cfg"; @@ -8,50 +9,642 @@ import CFG from "../../cfg"; */ export default function SfidaActionLog(obj) { - return ( - new proto.Networking.Responses.SfidaActionLogResponse({ - result: proto.Networking.Responses.SfidaActionLogResponse.Result.SUCCESS, - log_entries: [ - new proto.Data.Logs.ActionLogEntry({ - timestamp_ms: (new Date().getTime() - 1e4) * 1e3, - sfida: false, - catch_pokemon: null, - fort_search: new proto.Data.Logs.FortSearchLogEntry({ - result: proto.Data.Logs.FortSearchLogEntry.Result.SUCCESS, - fort_id: "", - items: [ - new proto.Inventory.Item.ItemData({ - item_id: proto.Inventory.Item.ItemId.ITEM_MASTER_BALL, - count: 2, - unseen: false - }), - new proto.Inventory.Item.ItemData({ - item_id: proto.Inventory.Item.ItemId.ITEM_ULTRA_BALL, - count: 2, - unseen: false - }) - ] - }) - }) - /*, - new proto.Data.Logs.ActionLogEntry({ - timestamp_ms: (new Date().getTime() - 1e3) * 1e3, - catch_pokemon: new proto.Data.Logs.CatchPokemonLogEntry({ - result: proto.Data.Logs.CatchPokemonLogEntry.Result.SUCCESS, - pokemon_id: proto.Enums.PokemonId.PIDGEY, - combat_points: 352 - }) - }), - new proto.Data.Logs.ActionLogEntry({ - timestamp_ms: (new Date().getTime() - 1e2) * 1e3, - catch_pokemon: new proto.Data.Logs.CatchPokemonLogEntry({ - result: proto.Data.Logs.CatchPokemonLogEntry.Result.SUCCESS, - pokemon_id: proto.Enums.PokemonId.CHARIZARD, - combat_points: 963 - }) - })*/ - ] - }).encode() - ); + let buffer = ({ + "result": "SUCCESS", + "log_entries": [ + { + "timestamp_ms": "1471694560585", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "HORSEA", + "combat_points": 110 + } + }, + { + "timestamp_ms": "1471694566830", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "HORSEA", + "combat_points": 73 + } + }, + { + "timestamp_ms": "1471694573468", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471694597662", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "HORSEA", + "combat_points": 102 + } + }, + { + "timestamp_ms": "1471694603880", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "CATERPIE", + "combat_points": 36 + } + }, + { + "timestamp_ms": "1471694610259", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "WEEDLE", + "combat_points": 15 + } + }, + { + "timestamp_ms": "1471694616586", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "PIDGEY", + "combat_points": 26 + } + }, + { + "timestamp_ms": "1471694632969", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 1 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471694739319", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 2 + } + ] + } + }, + { + "timestamp_ms": "1471694741772", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 4 + } + ] + } + }, + { + "timestamp_ms": "1471694904167", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "KRABBY", + "combat_points": 100 + } + }, + { + "timestamp_ms": "1471694925722", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 2 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 4 + } + ] + } + }, + { + "timestamp_ms": "1471695030964", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + }, + { + "timestamp_ms": "1471695071016", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695089887", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "SPEAROW", + "combat_points": 80 + } + }, + { + "timestamp_ms": "1471695096341", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + }, + { + "timestamp_ms": "1471695139926", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "EKANS", + "combat_points": 72 + } + }, + { + "timestamp_ms": "1471695148440", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695195481", + "catch_pokemon": { + "result": "UNKNOWN_ENUM_VALUE_Result_3", + "pokemon_id": "MAGIKARP", + "combat_points": 26 + } + }, + { + "timestamp_ms": "1471695197676", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "ZUBAT", + "combat_points": 41 + } + }, + { + "timestamp_ms": "1471695203917", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "MAGIKARP", + "combat_points": 46 + } + }, + { + "timestamp_ms": "1471695211919", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + } + ] + } + }, + { + "timestamp_ms": "1471695316895", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "ZUBAT", + "combat_points": 43 + } + }, + { + "timestamp_ms": "1471695323589", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + }, + { + "timestamp_ms": "1471695429795", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 1 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695487237", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + } + ] + } + }, + { + "timestamp_ms": "1471695522740", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + } + ] + } + }, + { + "timestamp_ms": "1471695577816", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 1 + }, + { + "item_id": "ITEM_POTION", + "count": 2 + } + ] + } + }, + { + "timestamp_ms": "1471695633092", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 1 + }, + { + "item_id": "ITEM_POTION", + "count": 2 + } + ], + "eggs": 1 + } + }, + { + "timestamp_ms": "1471695738726", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + } + ] + } + }, + { + "timestamp_ms": "1471695776746", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_REVIVE", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695790415", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_REVIVE", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 4 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695829422", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "MAGIKARP", + "combat_points": 40 + } + }, + { + "timestamp_ms": "1471695836445", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695838748", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695860629", + "catch_pokemon": { + "result": "POKEMON_FLED", + "pokemon_id": "VENONAT", + "combat_points": 174 + } + }, + { + "timestamp_ms": "1471695866223", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471695884419", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "STARYU", + "combat_points": 11 + } + }, + { + "timestamp_ms": "1471695889856", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + }, + { + "timestamp_ms": "1471695906137", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "PINSIR", + "combat_points": 28 + } + }, + { + "timestamp_ms": "1471695914356", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + }, + { + "timestamp_ms": "1471696008778", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + }, + { + "timestamp_ms": "1471696010713", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "CATERPIE", + "combat_points": 74 + } + }, + { + "timestamp_ms": "1471696050313", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471696052566", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + }, + { + "timestamp_ms": "1471696072147", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 1 + }, + { + "item_id": "ITEM_POTION", + "count": 2 + } + ] + } + }, + { + "timestamp_ms": "1471696074058", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "ZUBAT", + "combat_points": 40 + } + }, + { + "timestamp_ms": "1471696079308", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_RAZZ_BERRY", + "count": 1 + }, + { + "item_id": "ITEM_POKE_BALL", + "count": 2 + }, + { + "item_id": "ITEM_POTION", + "count": 1 + } + ] + } + }, + { + "timestamp_ms": "1471696081215", + "catch_pokemon": { + "result": "POKEMON_CAPTURED", + "pokemon_id": "ZUBAT", + "combat_points": 73 + } + }, + { + "timestamp_ms": "1471696235352", + "fort_search": { + "result": "SUCCESS", + "items": [ + { + "item_id": "ITEM_POKE_BALL", + "count": 3 + } + ] + } + } + ], + "$unknownFields": [] +}); + + return (POGOProtos.serialize(buffer, "POGOProtos.Networking.Responses.SfidaActionLogResponse")); } \ No newline at end of file diff --git a/src/player.js b/src/player.js index d8581ef..05b6842 100644 --- a/src/player.js +++ b/src/player.js @@ -113,33 +113,28 @@ class Player { } /** - * @param {Request} req + * @param {Object} obj */ - updatePosition(req) { - - let data = decodeRequestEnvelope(req.request_message.buffer); - - this.latitude = data.latitude; - this.longitude = data.longitude; - this.altitude = data.altitude; - + updatePosition(obj) { + this.latitude = obj.latitude; + this.longitude = obj.longitude; } updateAvatar(req) { - let data = proto.Networking.Requests.Messages.SetAvatarMessage.decode(req.request_message.toBuffer()).player_avatar; + let node = null; - if (!data) return void 0; - - this.skin = data.skin; - this.hair = data.hair; - this.shirt = data.shirt; - this.pants = data.pants; - this.hat = data.hat; - this.shoes = data.shoes; - this.eyes = data.eyes; - this.gender = data.gender; - this.backpack = data.backpack; + for (let key in req.player_avatar) { + node = req.player_avatar[key]; + if (key === "gender") { + this.gender = node === "FEMALE" ? 1 : 0; + } + else { + if (this.hasOwnProperty(key)) { + this[key] = node; + } + } + }; } @@ -345,7 +340,7 @@ export function loginPlayer(player) { return new Promise((resolve) => { this.getUserByEmail(player.email).then((doc) => { player.updateByObject(doc); - let buffer = GetPlayer(player).encode(); + let buffer = GetPlayer(player); resolve(buffer); }); }); @@ -409,9 +404,13 @@ export function authenticatePlayer(player) { else if (token.provider === "ptc") { let decoded = token.token.contents; player.isPTCAccount = true; - this.print("PTC auth isnt supported yet! Kicking..", 31); - this.removePlayer(player); - return void 0; + player.email = decoded.split("-")[1]; + player.email_verified = true; + player.isPTCAccount = true; + //console.log(decoded); + this.print("PTC auth isnt supported yet! Your progress wont get saved!", 33); + //this.removePlayer(player); + //return void 0; } else { this.print("Invalid provider! Kicking..", 31); diff --git a/src/request.js b/src/request.js index 58f935c..b624a21 100644 --- a/src/request.js +++ b/src/request.js @@ -1,6 +1,8 @@ import fs from "fs"; import url from "url"; import proto from "./proto"; +import pcrypt from "pcrypt"; +import POGOProtos from "pokemongo-protobuf"; import CFG from "../cfg"; @@ -66,6 +68,24 @@ export function getRequestType(req) { } +export function parseProtobuf(buffer, path) { + try { + return POGOProtos.parseWithUnknown(buffer, path); + } catch (e) { + this.print(e, 31); + } +} + +/** + * @param {Request} req + */ +export function parseSignature(req) { + let key = pcrypt.decrypt(req.unknown6.unknown2.encrypted_signature); + return ( + POGOProtos.parseWithUnknown(key, "POGOProtos.Networking.Envelopes.Signature") + ); +} + /** * @param {Request} req */ @@ -82,7 +102,7 @@ export function onRequest(req) { } } - let request = proto.Networking.Envelopes.RequestEnvelope.decode(req.body); + let request = this.parseProtobuf(req.body, "POGOProtos.Networking.Envelopes.RequestEnvelope"); if (!request.requests.length) { this.print("Received invalid request!", 31); @@ -92,7 +112,7 @@ export function onRequest(req) { if (CFG.DEBUG_LOG_REQUESTS) { console.log("#####"); request.requests.map((request) => { - console.log("Got request:", this.getRequestType(request)); + console.log("Got request:", request.request_type); }).join(","); } @@ -102,7 +122,7 @@ export function onRequest(req) { } this.processRequests(player, request.requests).then((answer) => { - let msg = this.envelopResponse(1, request.request_id, answer, !!request.auth_ticket); + let msg = this.envelopResponse(1, request.request_id, answer, !!request.auth_ticket, request); if (CFG.DEBUG_DUMP_TRAFFIC) { this.dumpTraffic(req.body, msg); } @@ -118,17 +138,19 @@ export function onRequest(req) { * @param {Boolean} auth * @return {Buffer} */ -export function envelopResponse(status, id, response, auth) { +export function envelopResponse(status, id, response, auth, req) { - let answer = ResponseEnvelope({ - id: id, - status: status, - response: response - }); + let buffer = req; - if (auth) answer.auth_ticket = AuthTicket(); + delete buffer.requests; - return (answer); + buffer.returns = response; + + buffer.status_code = 1; + + return ( + POGOProtos.serialize(buffer, "POGOProtos.Networking.Envelopes.ResponseEnvelope") + ); } diff --git a/src/response.js b/src/response.js index e459e1c..d04a05b 100644 --- a/src/response.js +++ b/src/response.js @@ -8,7 +8,6 @@ import { CheckAwardedBadges, DownloadSettings, DownloadRemoteConfigVersion, - GetPlayer, GetPlayerProfile, ItemTemplates, GetAssetDigest, @@ -29,6 +28,8 @@ import { ClaimCodeName } from "./packets"; +import { _toCC } from "./utils"; + const REQUEST = proto.Networking.Requests.RequestType; /** @@ -40,119 +41,127 @@ export function processResponse(player, req) { let buffer = null; + let cc = _toCC(req.request_type); + let msg = null; + let proto = `POGOProtos.Networking.Requests.Messages.${cc}Message`; + + if (req.request_message) { + try { + msg = this.parseProtobuf(req.request_message, proto); + } catch (e) { + this.print(`Failed to parse ${cc}: ${e}`, 31); + } + } + return new Promise((resolve) => { try { switch (req.request_type) { - case REQUEST.GET_PLAYER: + case "GET_PLAYER": this.forwardPlayer(player).then((res) => resolve(res)); return void 0; break; - case REQUEST.GET_HATCHED_EGGS: + case "GET_HATCHED_EGGS": buffer = GetHatchedEggs(); break; - case REQUEST.GET_INVENTORY: - buffer = GetInventory(); + case "GET_INVENTORY": + buffer = GetInventory(msg); break; - case REQUEST.CHECK_AWARDED_BADGES: + case "CHECK_AWARDED_BADGES": buffer = CheckAwardedBadges(); break; - case REQUEST.DOWNLOAD_SETTINGS: - buffer = DownloadSettings(req); + case "DOWNLOAD_SETTINGS": + buffer = DownloadSettings(); break; - case REQUEST.DOWNLOAD_ITEM_TEMPLATES: + case "DOWNLOAD_ITEM_TEMPLATES": buffer = ItemTemplates(); break; - case REQUEST.DOWNLOAD_REMOTE_CONFIG_VERSION: - buffer = DownloadRemoteConfigVersion(req); + case "DOWNLOAD_REMOTE_CONFIG_VERSION": + buffer = DownloadRemoteConfigVersion(msg); break; - case REQUEST.GET_ASSET_DIGEST: - buffer = GetAssetDigest(req); + case "GET_ASSET_DIGEST": + buffer = GetAssetDigest(msg); break; - case REQUEST.GET_PLAYER_PROFILE: + case "GET_PLAYER_PROFILE": buffer = GetPlayerProfile(); break; - case REQUEST.GET_MAP_OBJECTS: - player.updatePosition(req); - buffer = GetMapObjects(player, req); + case "GET_MAP_OBJECTS": + player.updatePosition(msg); + buffer = GetMapObjects(player, msg); this.savePlayer(player).then(() => { resolve(buffer); }); return void 0; break; - case REQUEST.GET_DOWNLOAD_URLS: - GetDownloadUrls(this.asset, this.getLocalIPv4(), req).then((res) => { + case "GET_DOWNLOAD_URLS": + GetDownloadUrls(this.asset, this.getLocalIPv4(), msg).then((res) => { resolve(res); }); return void 0; break; - case REQUEST.SET_AVATAR: - player.updateAvatar(req); + case "SET_AVATAR": + player.updateAvatar(msg); buffer = SetAvatar(player); this.savePlayer(player).then(() => { resolve(buffer); }); return void 0; break; - case REQUEST.SFIDA_ACTION_LOG: + case "SFIDA_ACTION_LOG": buffer = SfidaActionLog(); break; - case REQUEST.MARK_TUTORIAL_COMPLETE: + case "MARK_TUTORIAL_COMPLETE": buffer = MarkTutorialComplete(player); this.savePlayer(player).then(() => { resolve(buffer); }); return void 0; break; - case REQUEST.CLAIM_CODENAME: - buffer = ClaimCodeName(req, player); + case "CLAIM_CODENAME": + buffer = ClaimCodeName(msg, player); this.savePlayer(player).then(() => { resolve(buffer); }); return void 0; break; - case REQUEST.LEVEL_UP_REWARDS: + case "LEVEL_UP_REWARDS": buffer = LevelUpRewards(); break; - case REQUEST.FORT_DETAILS: - buffer = FortDetails(req); + case "FORT_DETAILS": + buffer = FortDetails(msg); break; - case REQUEST.FORT_SEARCH: + case "FORT_SEARCH": buffer = FortSearch(); break; - case REQUEST.SET_CONTACT_SETTINGS: - player.updateContactSettings(req); + case "SET_CONTACT_SETTINGS": + player.updateContactSettings(msg); buffer = SetContactSettings(player); this.savePlayer(player).then(() => { resolve(buffer); }); return void 0; break; - case REQUEST.ENCOUNTER: - buffer = Encounter(req); + case "ENCOUNTER": + buffer = Encounter(msg); break; - case REQUEST.NICKNAME_POKEMON: - buffer = NicknamePokemon(req); + case "NICKNAME_POKEMON": + buffer = NicknamePokemon(msg); break; - case REQUEST.UPGRADE_POKEMON: - buffer = UpgradePokemon(req); + case "UPGRADE_POKEMON": + buffer = UpgradePokemon(msg); break; - case REQUEST.EVOLVE_POKEMON: - buffer = EvolvePokemon(req); + case "EVOLVE_POKEMON": + buffer = EvolvePokemon(msg); break; - case REQUEST.SET_FAVORITE_POKEMON: - buffer = SetFavoritePokemon(req); - break; - case REQUEST.CATCH_POKEMON: - let data = proto.Networking.Requests.Messages.CatchPokemonMessage.decode(req.request_message.toBuffer()); - console.log(data); + case "SET_FAVORITE_POKEMON": + buffer = SetFavoritePokemon(msg); break; default: - this.print(`Unknown request: ${this.getRequestType(req)}`, 31); + this.print(`Unknown request: ${req.request_type}`, 31); break; }; } catch (e) { - console.log(e); + this.print(`Response error: ${e}`, 31); }; resolve(buffer); diff --git a/src/setup.js b/src/setup.js index aa891f1..cbe434d 100644 --- a/src/setup.js +++ b/src/setup.js @@ -5,6 +5,8 @@ import proto from "./proto"; import CFG from "../cfg"; +import { idToPkmnBundleName } from "./utils"; + export function setup() { let isFirstRun = !this.directoryExists(CFG.DUMP_ASSET_PATH); @@ -19,17 +21,63 @@ export function setup() { return void 0; } - this.asset = this.parseAssetDigest(); + // make sure all assets got loaded properly + this.validateAssets().then(() => { - this.setupDatabaseConnection().then(() => { - if (CFG.PORT < 1) { - this.print("Invalid port!", 31); - return void 0; + this.print(`Downloaded assets are valid! Proceeding..`); + + this.asset = this.parseAssetDigest(); + this.master = this.parseGameMaster(); + + this.setupDatabaseConnection().then(() => { + if (CFG.PORT < 1) { + this.print("Invalid port!", 31); + return void 0; + } + this.socket = this.createHTTPServer(); + setTimeout(this::this.cycle, 1); + let localIPv4 = this.getLocalIPv4(); + this.print(`Server running at ${localIPv4}:${CFG.PORT}`); + }); + + }).catch((e) => { + //fse.removeSync(CFG.DUMP_ASSET_PATH); + this.print("Error: " + e + " was not found!", 31); + }); + +} + +/** + * Make sure all required + * assets got loaded properly + */ +export function validateAssets() { + + let index = 0; + let max = CFG.MAX_POKEMON_NATIONAL_ID; + + return new Promise((resolve, reject) => { + + // validate asset digest + if (!this.fileExists(CFG.DUMP_ASSET_PATH + "asset_digest")) { + return reject("File asset_digest"); } - this.socket = this.createHTTPServer(); - setTimeout(this::this.cycle, 1); - let localIPv4 = this.getLocalIPv4(); - this.print(`Server running at ${localIPv4}:${CFG.PORT}`); + + // validate game master + if (!this.fileExists(CFG.DUMP_ASSET_PATH + "game_master")) { + return reject("File game_master"); + } + + // validate models + while (++index <= max) { + let id = idToPkmnBundleName(index); + if (!this.fileExists(CFG.DUMP_ASSET_PATH + id)) { + return reject("Model " + id); + } + }; + + resolve(); + }); } @@ -37,26 +85,42 @@ export function setup() { export function parseAssetDigest() { let asset = null; try { - asset = proto.Networking.Responses.GetAssetDigestResponse.decode(fs.readFileSync(CFG.DUMP_ASSET_PATH + "asset_digest")); + let data = fs.readFileSync(CFG.DUMP_ASSET_PATH + "asset_digest"); + asset = this.parseProtobuf(data, "POGOProtos.Networking.Responses.GetAssetDigestResponse"); } catch (e) { this.print(e, 31); } return (asset); } +export function parseGameMaster() { + let master = null; + try { + let data = fs.readFileSync(CFG.DUMP_ASSET_PATH + "game_master"); + master = this.parseProtobuf(data, "POGOProtos.Networking.Responses.DownloadItemTemplatesResponse"); + } catch (e) { + this.print(e, 31); + } + return (master); +} + export function onFirstRun(resolve) { pogo.login({ provider: CFG.DOWNLOAD_PROVIDER, // google or ptc username: CFG.DOWNLOAD_USERNAME, password: CFG.DOWNLOAD_PASSWORD - }).then((asset) => { + }).then((res) => { + let asset = res.asset; this.print(`Dumping asset digest..`, 35); // create data dir, if login successed fse.ensureDirSync(CFG.DUMP_ASSET_PATH); - fs.writeFileSync(CFG.DUMP_ASSET_PATH + "asset_digest", asset.toBuffer()); + fs.writeFileSync(CFG.DUMP_ASSET_PATH + "asset_digest", res.asset.toBuffer()); + fs.writeFileSync(CFG.DUMP_ASSET_PATH + "game_master", res.master.toBuffer()); this.dumpPkmnModels(() => { resolve(); }); + }).catch((e) => { + this.print(e, 31); }); } diff --git a/src/utils.js b/src/utils.js index 4474ca6..924db1e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -57,8 +57,33 @@ export function decodeLong(long) { } +/** + * @return {Number} + */ export function randomRequestId() { return ( 1e18 - Math.floor(Math.random() * 1e18) ); +} + +/** + * @param {String} key + * @return {String} + */ +export function _toCC(key) { + key = key.toLowerCase(); + let res = key[0].toUpperCase() + key.substring(1, key.length).replace(/_\s*([a-z])/g, function(d, e) { + return e.toUpperCase(); + }); + return (res); +} + +/** + * @param {Number} index + * @return {String} + */ +export function idToPkmnBundleName(index) { + return ( + "pm" + (index >= 10 ? index >= 100 ? "0" : "00" : "000") + index + ); } \ No newline at end of file