diff --git a/README.md b/README.md
index 0e9d24a..e09eff2 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ ______ _____ _____ _____
-
+
diff --git a/cfg.js b/cfg.js
index 16d5ee0..6651135 100644
--- a/cfg.js
+++ b/cfg.js
@@ -1,3 +1,7 @@
+export const ASSET_DIGEST_PATH = "asset_digest";
+
+export const MINIMUM_CLIENT_VERSION = "0.33.0";
+
export const SERVER_PORT = 3000;
export const SERVER_HOST_IP = "127.0.0.1";
export const SERVER_GAME_MODE = 0;
@@ -10,18 +14,26 @@ export const SERVER_LOG_REQUESTS = true;
export const SERVER_DEFAULT_CONSOLE_COLOR = 32;
-export const ASSET_DIGEST_PATH = "asset_digest";
-
-export const MINIMUM_CLIENT_VERSION = "0.33.0";
+// Either mongo or mysql
+// Dont use mysql right now
+export const SERVER_USE_DATABASE = "MONGO";
+// MONGODB
export const SERVER_MONGO_PORT = 27017;
-export const SERVER_MONGO_HOST_IP = "localhost";
+export const SERVER_MONGO_HOST_IP = "127.0.0.1";
export const SERVER_MONGO_DB_NAME = "pokemongo";
export const SERVER_MONGO_COLLECTION_USERS = "users";
export const SERVER_MONGO_URL = `mongodb://${SERVER_MONGO_HOST_IP}:${SERVER_MONGO_PORT}/${SERVER_MONGO_DB_NAME}`;
-export const SERVER_GMAPS_API_KEY = "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM";
+// MYSQL
+export const SERVER_MYSQL_PORT = 3306;
+export const SERVER_MYSQL_HOST_IP = "127.0.0.1";
+export const SERVER_MYSQL_DB_NAME = "pogosql";
+export const SERVER_MYSQL_USERNAME = "USERNAME";
+export const SERVER_MYSQL_PASSWORD = "PASSWORD";
// account used for pogo-asset-downloader lib
export const SERVER_POGO_CLIENT_USERNAME = "USERNAME";
-export const SERVER_POGO_CLIENT_PASSWORD = "PASSWORD";
\ No newline at end of file
+export const SERVER_POGO_CLIENT_PASSWORD = "PASSWORD";
+
+export const SERVER_GMAPS_API_KEY = "AIzaSyDF9rkP8lhcddBtvH9gVFzjnNo13WtmJIM";
\ No newline at end of file
diff --git a/package.json b/package.json
index 3ddd487..d7736a0 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"nodemon": "^1.7.1",
"protobufjs": "^5.0.1",
"mongodb": "^2.2.5",
+ "mysql": "^2.11.1",
"jwt-decode": "^2.1.0",
"long": "^3.2.0",
"pogo-asset-downloader": "^0.1.0",
diff --git a/src/database.js b/src/db/mongo.js
similarity index 96%
rename from src/database.js
rename to src/db/mongo.js
index 7e6ee78..4f17e80 100644
--- a/src/database.js
+++ b/src/db/mongo.js
@@ -1,13 +1,13 @@
import mongodb from "mongodb";
-import * as CFG from "../cfg";
+import * as CFG from "../../cfg";
export function setupMongo() {
return new Promise((resolve) => {
mongodb.MongoClient.connect(CFG.SERVER_MONGO_URL, (error, db) => {
if (error) {
- this.print("Unable to connect to database", 31);
+ this.print(error, 31);
} else {
this.db.instance = db;
this.loadCollection(CFG.SERVER_MONGO_COLLECTION_USERS).then(() => {
diff --git a/src/db/mysql.js b/src/db/mysql.js
new file mode 100644
index 0000000..96c290d
--- /dev/null
+++ b/src/db/mysql.js
@@ -0,0 +1,26 @@
+import mysql from "mysql";
+
+import * as CFG from "../../cfg";
+
+export function setupMySQL() {
+
+ let connection = mysql.createConnection({
+ host : CFG.SERVER_MYSQL_HOST_IP,
+ port : CFG.SERVER_MYSQL_PORT,
+ database : CFG.SERVER_MYSQL_DB_NAME,
+ user : CFG.SERVER_MYSQL_USERNAME,
+ password : CFG.SERVER_MYSQL_PASSWORD
+ });
+
+ return new Promise((resolve) => {
+ connection.connect((error) => {
+ if (error) {
+ this.print(error, 31);
+ return void 0;
+ }
+ this.db.instance = connection;
+ resolve();
+ });
+ });
+
+}
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index 664f603..40da46a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -16,7 +16,8 @@ import * as _player from "./player";
import * as _request from "./request";
import * as _response from "./response";
import * as _process from "./process";
-import * as _database from "./database";
+import * as _mongo from "./db/mongo";
+import * as _mysql from "./db/mysql";
const greetMessage = fs.readFileSync(".greet", "utf8");
@@ -153,7 +154,8 @@ inherit(GameServer, _player);
inherit(GameServer, _request);
inherit(GameServer, _response);
inherit(GameServer, _process);
-inherit(GameServer, _database);
+inherit(GameServer, _mongo);
+inherit(GameServer, _mysql);
let server = new GameServer();
diff --git a/src/packets/Responses.GetMapObjects.js b/src/packets/Responses.GetMapObjects.js
index d80192b..c06f0b3 100644
--- a/src/packets/Responses.GetMapObjects.js
+++ b/src/packets/Responses.GetMapObjects.js
@@ -55,7 +55,7 @@ export default function GetMapObjects(request) {
longitude: -96.58502161502839,
spawn_point_id: "87bdd289c69",
pokemon_data: new proto.Data.PokemonData({
- pokemon_id: 19,
+ pokemon_id: 16,
cp: 277,
stamina: 41,
stamina_max: 41,
diff --git a/src/setup.js b/src/setup.js
index 09fbc38..384b215 100644
--- a/src/setup.js
+++ b/src/setup.js
@@ -8,7 +8,7 @@ export function setup() {
this.createAssetDownloadSession().then(() => {
this.print("Created asset download session");
- this.setupMongo().then(() => {
+ this.setupDatabaseConnection().then(() => {
this.print("Database connection established");
@@ -26,4 +26,28 @@ export function setup() {
});
});
+}
+
+export function setupDatabaseConnection() {
+
+ return new Promise((resolve) => {
+
+ let name = String(CFG.SERVER_USE_DATABASE).toUpperCase();
+
+ switch (name) {
+ case "MONGO":
+ case "MONGODB":
+ this.setupMongo().then(resolve);
+ break;
+ case "MYSQL":
+ this.setupMySQL().then(resolve);
+ break;
+ default:
+ this.print("Invalid database connection type!", 31);
+ return void 0;
+ break;
+ };
+
+ });
+
}
\ No newline at end of file