From 33cca65938cb0f7ae5648ab6f9157e7c8d860288 Mon Sep 17 00:00:00 2001 From: Cronick Date: Sun, 9 Oct 2016 17:20:39 +0200 Subject: [PATCH] Update - Set username to first part of email, if it's unknown. - Setup ClaimCodename packet - MARK_TUTORIAL_COMPLETE error should be fixed - Fix for MySQL table error (Thanks to Badley187) - Fixed TypeError: _this2.print is not a function error. --- src/db/tables/owned_pkmn.table | 30 +++++++++++----------- src/db/tables/users.table | 20 +++++++-------- src/models/Player/index.js | 14 ++++++++-- src/models/Player/packets/ClaimCodename.js | 29 +++++++++++++++++++++ src/models/Player/packets/GetAuthTicket.js | 6 ++--- src/models/Player/packets/index.js | 3 ++- src/response.js | 1 + 7 files changed, 72 insertions(+), 31 deletions(-) create mode 100644 src/models/Player/packets/ClaimCodename.js diff --git a/src/db/tables/owned_pkmn.table b/src/db/tables/owned_pkmn.table index eda0526..0460aa7 100644 --- a/src/db/tables/owned_pkmn.table +++ b/src/db/tables/owned_pkmn.table @@ -6,11 +6,11 @@ stamina int(11) NOT NULL, stamina_max int(11) NOT NULL, move_1 varchar(32) NOT NULL, move_2 varchar(32) 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, +deployed_fort_id longtext NULL DEFAULT NULL, +is_egg tinyint(1) NULL DEFAULT NULL, +egg_km_walked_target double NULL DEFAULT NULL, +egg_km_walked_start double NULL DEFAULT NULL, +origin int(11) NULL DEFAULT NULL, height_m double NOT NULL, weight_kg double NOT NULL, individual_attack int(11) NOT NULL, @@ -18,14 +18,14 @@ individual_defense int(11) NOT NULL, individual_stamina int(11) NOT NULL, cp_multiplier double NOT NULL, pokeball varchar(32) NOT NULL, -captured_cell_id varchar(32) NOT NULL, -battles_attacked int(11) NOT NULL, -battles_defended int(11) NOT NULL, -egg_incubator_id longtext NOT NULL, -creation_time_ms bigint(20) 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, +captured_cell_id varchar(32) NULL DEFAULT NULL, +battles_attacked int(11) NULL DEFAULT NULL, +battles_defended int(11) NULL DEFAULT NULL, +egg_incubator_id longtext NULL DEFAULT NULL, +creation_time_ms bigint(20) NULL DEFAULT NULL, +num_upgrades int(11) NULL DEFAULT NULL, +additional_cp_multiplier double NULL DEFAULT NULL, +favorite tinyint(1) NULL DEFAULT NULL, +nickname longtext NULL DEFAULT NULL, +from_fort int(11) NULL DEFAULT NULL, PRIMARY KEY (id) \ No newline at end of file diff --git a/src/db/tables/users.table b/src/db/tables/users.table index 3689e8d..30ea09e 100644 --- a/src/db/tables/users.table +++ b/src/db/tables/users.table @@ -1,16 +1,16 @@ id int(11) NOT NULL AUTO_INCREMENT, username varchar(16) NOT NULL, email varchar(32) NOT NULL, -exp int(11) NOT NULL, -level smallint(11) NOT NULL, -stardust int(11) NOT NULL, -pokecoins int(11) NOT NULL, -team tinyint(11) NOT NULL, -latitude double NOT NULL, -longitude double NOT NULL, -altitude double NOT NULL, -send_marketing_emails tinyint(1) NOT NULL, -send_push_notifications tinyint(1) NOT NULL, +exp int(11) NULL DEFAULT NULL, +level smallint(11) NULL DEFAULT NULL, +stardust int(11) NULL DEFAULT NULL, +pokecoins int(11) NULL DEFAULT NULL, +team tinyint(11) NULL DEFAULT NULL, +latitude double NULL DEFAULT NULL, +longitude double NULL DEFAULT NULL, +altitude double NULL DEFAULT NULL, +send_marketing_emails tinyint(1) NULL DEFAULT NULL, +send_push_notifications tinyint(1) NULL DEFAULT NULL, candies varchar(64) NOT NULL DEFAULT '{}', items varchar(255) NOT NULL DEFAULT '{}', avatar varchar(128) NOT NULL DEFAULT '{}', diff --git a/src/models/Player/index.js b/src/models/Player/index.js index 276fcb5..5150dc7 100644 --- a/src/models/Player/index.js +++ b/src/models/Player/index.js @@ -86,7 +86,7 @@ export default class Player extends MapObject { } set email(value) { this._email = value; - this.username = value.replace("@gmail.com", ""); + if (this.username === "unknown") this.username = value.replace("@gmail.com", ""); } /** @@ -196,6 +196,9 @@ export default class Player extends MapObject { case "RECYCLE_INVENTORY_ITEM": resolve(this.RecycleInventoryItem(msg)); break; + case "CLAIM_CODENAME": + resolve(this.ClaimCodename(msg)); + break; }; }); } @@ -216,7 +219,7 @@ export default class Player extends MapObject { equipped_badge: {}, contact_settings: this.contact.serialize(), currencies: this.currency.serialize(), - remaining_codename_claims: 0 + remaining_codename_claims: 10 }); } @@ -349,6 +352,13 @@ export default class Player extends MapObject { }); } + /** + * @param {string} codename + */ + setUsername(codename) { + this.username = codename; + } + } inherit(Player, _packets); diff --git a/src/models/Player/packets/ClaimCodename.js b/src/models/Player/packets/ClaimCodename.js new file mode 100644 index 0000000..44f9556 --- /dev/null +++ b/src/models/Player/packets/ClaimCodename.js @@ -0,0 +1,29 @@ +import POGOProtos from "pokemongo-protobuf"; + +/** + * @param {Object} msg + * @return {Buffer} + */ +export default function ClaimCodename(msg) { + + let buffer = null; + let schema = "POGOProtos.Networking.Responses.ClaimCodenameResponse"; + + let codename = msg.codename; + if(codename) this.setUsername(codename); + + buffer = { + codename: codename, + "user_message": "Testing message", + "is_assignable": true, + status: null, + updated_player: null + }; + + buffer.status = codename ? "SUCCESS" : "CODENAME_NOT_AVAILABLE"; + buffer.updated_player = this.getPlayerData(); + + + return (POGOProtos.serialize(buffer, schema)); + +} \ No newline at end of file diff --git a/src/models/Player/packets/GetAuthTicket.js b/src/models/Player/packets/GetAuthTicket.js index 2925352..7426f6f 100644 --- a/src/models/Player/packets/GetAuthTicket.js +++ b/src/models/Player/packets/GetAuthTicket.js @@ -1,14 +1,14 @@ import POGOProtos from "pokemongo-protobuf"; -export default function GetAuthTicket(id) { +export default function GetAuthTicket(id, player) { let buffer = ({ status_code: 53, request_id: id, api_url: "pgorelease.nianticlabs.com/custom", auth_ticket: { - start: new Buffer(""), - expire_timestamp_ms: 9999999999999, + start: new Buffer(player.email), + expire_timestamp_ms: ((new Date).getTime() + (1000 * 60 * 30)), end: new Buffer("") } }); diff --git a/src/models/Player/packets/index.js b/src/models/Player/packets/index.js index 7ccd078..5a1fefc 100644 --- a/src/models/Player/packets/index.js +++ b/src/models/Player/packets/index.js @@ -11,4 +11,5 @@ export NicknamePokemon from "./NicknamePokemon"; export GetPlayerProfile from "./GetPlayerProfile"; export SetFavoritePokemon from "./SetFavoritePokemon"; export CheckAwardedBadges from "./CheckAwardedBadges"; -export RecycleInventoryItem from "./RecycleInventoryItem"; \ No newline at end of file +export RecycleInventoryItem from "./RecycleInventoryItem"; +export ClaimCodename from "./ClaimCodename"; \ No newline at end of file diff --git a/src/response.js b/src/response.js index 8bf83b0..f9e39f7 100644 --- a/src/response.js +++ b/src/response.js @@ -46,6 +46,7 @@ export function processResponse(player, req) { case "UPGRADE_POKEMON": case "GET_ASSET_DIGEST": case "NICKNAME_POKEMON": + case "CLAIM_CODENAME": case "GET_HATCHED_EGGS": case "LEVEL_UP_REWARDS": case "GET_PLAYER_PROFILE":