From afb08fb8e93b5a451982cb6e74ac68754060fc78 Mon Sep 17 00:00:00 2001 From: JoshGlue Date: Tue, 20 Sep 2016 00:09:30 +0200 Subject: [PATCH 1/5] Added Pogo-Populate to POGOServer --- .gitignore | 1 + package.json | 3 ++- src/commands.js | 10 ++++++++++ src/db/tables/owned_pkmn.table | 34 +++++++++++++++++----------------- src/db/tables/users.table | 20 ++++++++++---------- src/models/Player/Bag/index.js | 12 ++++++------ 6 files changed, 46 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 3763473..c9937f5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ logs/ cfg.js .save npm-debug.* +.idea \ No newline at end of file diff --git a/package.json b/package.json index bc47872..948ff68 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,9 @@ "node-pogo-protos": "^1.4.0", "pcrypt": "git+https://github.com/laverdet/pcrypt.git", "pogo-asset-downloader": "^0.3.1", - "pokerare": "^0.1.1", + "pogo-populate": "0.0.6", "pokemongo-protobuf": "^1.11.0", + "pokerare": "^0.1.1", "prompt": "^1.0.0", "s2-geometry": "^1.2.9", "url": "^0.11.0" diff --git a/src/commands.js b/src/commands.js index cde59bb..6b27413 100644 --- a/src/commands.js +++ b/src/commands.js @@ -1,11 +1,21 @@ import print from "./print"; import CFG from "../cfg"; +import Populate from "pogo-populate" +let populate = new Populate(CFG); export function saveAllPlayers() { + + if (this.world.players.length > 0) { + CFG.RANDOM_SPAWNS_AT_PLAYERS && populate.db.connect(); for (let player of this.world.players) { + CFG.RANDOM_SPAWNS_AT_PLAYERS && populate.createRandomPokemon(player.latitude, player.longitude).then((res, rej)=>{ + if(rej){print(rej, 31)} + else{print(`(${player.player_name})` + res,33)} + }) this.savePlayer(player); }; + CFG.RANDOM_SPAWNS_AT_PLAYERS && populate.db.closeConnection(); } } diff --git a/src/db/tables/owned_pkmn.table b/src/db/tables/owned_pkmn.table index eda0526..3019b2d 100644 --- a/src/db/tables/owned_pkmn.table +++ b/src/db/tables/owned_pkmn.table @@ -1,22 +1,22 @@ id int(11) NOT NULL AUTO_INCREMENT, owner_id int(11) NOT NULL, -dex_number int(11) NOT NULL, -cp int(32) NOT NULL, -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, -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, +dex_number int(11) NULL, +cp int(32) NULL, +stamina int(11) NULL, +stamina_max int(11) NULL, +move_1 varchar(32) NULL, +move_2 varchar(32) NULL, +deployed_fort_id longtext NULL, +is_egg tinyint(1) NULL, +egg_km_walked_target double NULL, +egg_km_walked_start double NULL, +origin int(11) NULL, +height_m double NULL, +weight_kg double NULL, +individual_attack int(11) NULL, +individual_defense int(11) NULL, +individual_stamina int(11) NULL, +cp_multiplier double NULL, pokeball varchar(32) NOT NULL, captured_cell_id varchar(32) NOT NULL, battles_attacked int(11) NOT NULL, diff --git a/src/db/tables/users.table b/src/db/tables/users.table index 3689e8d..c06c8ce 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, +level smallint(11) NULL, +stardust int(11) NULL, +pokecoins int(11) NULL, +team tinyint(11) NULL, +latitude double NULL, +longitude double NULL, +altitude double NULL, +send_marketing_emails tinyint(1) NULL, +send_push_notifications tinyint(1) 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/Bag/index.js b/src/models/Player/Bag/index.js index e23d783..a4037e2 100644 --- a/src/models/Player/Bag/index.js +++ b/src/models/Player/Bag/index.js @@ -13,17 +13,17 @@ export default class Bag { this.player = player; - this.poke_ball = 0; - this.great_ball = 0; - this.ultra_ball = 0; - this.master_ball = 0; + this.poke_ball = 50; + this.great_ball = 20; + this.ultra_ball = 10; + this.master_ball = 1; this.potion = 0; this.super_potion = 0; this.hyper_potion = 0; - this.max_potion = 0; + this.max_potion = 1; - this.revive = 0; + this.revive = 10; this.max_revive = 0; this.lucky_egg = 0; From 6fb3e1e138df2fad9fc9f96924603c3f9a462886 Mon Sep 17 00:00:00 2001 From: JoshGlue Date: Tue, 20 Sep 2016 00:18:16 +0200 Subject: [PATCH 2/5] Revert some changes --- package.json | 2 +- src/db/tables/owned_pkmn.table | 34 +++++++++++++++++----------------- src/db/tables/users.table | 20 ++++++++++---------- src/models/Player/Bag/index.js | 12 ++++++------ 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 948ff68..34b96c4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "node-pogo-protos": "^1.4.0", "pcrypt": "git+https://github.com/laverdet/pcrypt.git", "pogo-asset-downloader": "^0.3.1", - "pogo-populate": "0.0.6", + "pogo-populate": "^0.0.6", "pokemongo-protobuf": "^1.11.0", "pokerare": "^0.1.1", "prompt": "^1.0.0", diff --git a/src/db/tables/owned_pkmn.table b/src/db/tables/owned_pkmn.table index 3019b2d..eda0526 100644 --- a/src/db/tables/owned_pkmn.table +++ b/src/db/tables/owned_pkmn.table @@ -1,22 +1,22 @@ id int(11) NOT NULL AUTO_INCREMENT, owner_id int(11) NOT NULL, -dex_number int(11) NULL, -cp int(32) NULL, -stamina int(11) NULL, -stamina_max int(11) NULL, -move_1 varchar(32) NULL, -move_2 varchar(32) NULL, -deployed_fort_id longtext NULL, -is_egg tinyint(1) NULL, -egg_km_walked_target double NULL, -egg_km_walked_start double NULL, -origin int(11) NULL, -height_m double NULL, -weight_kg double NULL, -individual_attack int(11) NULL, -individual_defense int(11) NULL, -individual_stamina int(11) NULL, -cp_multiplier double NULL, +dex_number int(11) NOT NULL, +cp int(32) NOT NULL, +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, +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 varchar(32) NOT NULL, captured_cell_id varchar(32) NOT NULL, battles_attacked int(11) NOT NULL, diff --git a/src/db/tables/users.table b/src/db/tables/users.table index c06c8ce..3689e8d 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) NULL, -level smallint(11) NULL, -stardust int(11) NULL, -pokecoins int(11) NULL, -team tinyint(11) NULL, -latitude double NULL, -longitude double NULL, -altitude double NULL, -send_marketing_emails tinyint(1) NULL, -send_push_notifications tinyint(1) 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, candies varchar(64) NOT NULL DEFAULT '{}', items varchar(255) NOT NULL DEFAULT '{}', avatar varchar(128) NOT NULL DEFAULT '{}', diff --git a/src/models/Player/Bag/index.js b/src/models/Player/Bag/index.js index a4037e2..e23d783 100644 --- a/src/models/Player/Bag/index.js +++ b/src/models/Player/Bag/index.js @@ -13,17 +13,17 @@ export default class Bag { this.player = player; - this.poke_ball = 50; - this.great_ball = 20; - this.ultra_ball = 10; - this.master_ball = 1; + this.poke_ball = 0; + this.great_ball = 0; + this.ultra_ball = 0; + this.master_ball = 0; this.potion = 0; this.super_potion = 0; this.hyper_potion = 0; - this.max_potion = 1; + this.max_potion = 0; - this.revive = 10; + this.revive = 0; this.max_revive = 0; this.lucky_egg = 0; From 34b6fd7186f5863d1a90ba18f9b5036209a5e8e5 Mon Sep 17 00:00:00 2001 From: JoshGlue Date: Tue, 20 Sep 2016 00:23:23 +0200 Subject: [PATCH 3/5] complemented cfg.js.example file --- cfg.js.example | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cfg.js.example b/cfg.js.example index 9022b4e..dd37cbf 100644 --- a/cfg.js.example +++ b/cfg.js.example @@ -36,6 +36,13 @@ export default { DEBUG_DUMP_TRAFFIC: true, DEBUG_LOG_REQUESTS: true, + //Populate map with Pokemon + RANDOM_SPAWNS_AT_PLAYERS: true, + DISTANCE: 2, //In kilometers + RARITY_RATE: 1.5, //The higher, the less likely rare Pokemon will appear + NUMBER_SPAWN: 100, + POKEMON_PER_SPAWN: 5, + // Choose a database type DATABASE_TYPE: "MYSQL", From 22b970cfd43da8812bd1f3d29b5524196740e618 Mon Sep 17 00:00:00 2001 From: JoshGlue Date: Tue, 20 Sep 2016 00:47:49 +0200 Subject: [PATCH 4/5] Fixed database problem --- package.json | 2 +- src/commands.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 34b96c4..9a60179 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "node-pogo-protos": "^1.4.0", "pcrypt": "git+https://github.com/laverdet/pcrypt.git", "pogo-asset-downloader": "^0.3.1", - "pogo-populate": "^0.0.6", + "pogo-populate": "^0.0.8", "pokemongo-protobuf": "^1.11.0", "pokerare": "^0.1.1", "prompt": "^1.0.0", diff --git a/src/commands.js b/src/commands.js index 6b27413..5e3be8d 100644 --- a/src/commands.js +++ b/src/commands.js @@ -1,21 +1,21 @@ import print from "./print"; import CFG from "../cfg"; -import Populate from "pogo-populate" +import Populate from "pogo-populate"; let populate = new Populate(CFG); export function saveAllPlayers() { if (this.world.players.length > 0) { - CFG.RANDOM_SPAWNS_AT_PLAYERS && populate.db.connect(); for (let player of this.world.players) { CFG.RANDOM_SPAWNS_AT_PLAYERS && populate.createRandomPokemon(player.latitude, player.longitude).then((res, rej)=>{ if(rej){print(rej, 31)} - else{print(`(${player.player_name})` + res,33)} + else { + print(`(${player.username})` + res, 33) + } }) this.savePlayer(player); }; - CFG.RANDOM_SPAWNS_AT_PLAYERS && populate.db.closeConnection(); } } From c7f65a03d347c26e6f41ec477c7a9ef343217f05 Mon Sep 17 00:00:00 2001 From: JoshGlue Date: Tue, 20 Sep 2016 10:26:50 +0200 Subject: [PATCH 5/5] Minor config change --- cfg.js.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cfg.js.example b/cfg.js.example index dd37cbf..98dbe0f 100644 --- a/cfg.js.example +++ b/cfg.js.example @@ -38,10 +38,10 @@ export default { //Populate map with Pokemon RANDOM_SPAWNS_AT_PLAYERS: true, - DISTANCE: 2, //In kilometers + RADIUS: 2, //In kilometers RARITY_RATE: 1.5, //The higher, the less likely rare Pokemon will appear - NUMBER_SPAWN: 100, - POKEMON_PER_SPAWN: 5, + NUMBER_SPAWNs: 500, + POKEMON_PER_SPAWN: 1, // Choose a database type DATABASE_TYPE: "MYSQL",