Armax / Pokemon-GO-node-api

Pokemon GO api node.js library
MIT License
875 stars 198 forks source link

Compatibility with PokemonGo-Map JSON #72

Closed coolaj86 closed 8 years ago

coolaj86 commented 8 years ago

I'm trying to get this to work with the python client's web UI. The sample data looks like this:

I'm just poking around right now and trying to figure out where these values came from (and how they were converted from the binary formats and s2 formats, etc). If there's anything you can immediately comment on please do so. Otherwise I'll just be working my way through. :)

{
    "pokemons": [
        {
            "disappear_time": 1469159020156,
            "encounter_id": "MTUzMjQxMjY4NTg4NDUyMTExMTc=",
            "latitude": 40.36915523640919,
            "longitude": -111.75098587678943,
            "pokemon_id": 16,
            "pokemon_name": "Pidgey",
            "spawnpoint_id": "874d84035d7"
        }
    ],
    "gyms": [
        {
            "enabled": true,
            "guard_pokemon_id": 59,
            "gym_id": "ffb14e36c7344c289457faa20319681c.16",
            "gym_points": 10495,
            "last_modified": 1469146875398,
            "latitude": 40.360204,
            "longitude": -111.761231,
            "team_id": 2
        }
    ],
    "pokestops": [
        {
            "active_pokemon_id": 19,
            "enabled": true,
            "last_modified": 1469157300759,
            "latitude": 40.370669,
            "longitude": -111.755525,
            "lure_expiration": 1469158200716,
            "pokestop_id": "1ef6996b547746c69e22dbe73af6fbb0.16"
        },
        {
            "active_pokemon_id": null,
            "enabled": true,
            "last_modified": 1469156128717,
            "latitude": 40.364965,
            "longitude": -111.756411,
            "lure_expiration": null,
            "pokestop_id": "1494e52456d64e979fdee61437bfefa7.16"
        }
    ]
}
coolaj86 commented 8 years ago

Almost got pokemons figured out:

disappear_time: MapPokemon[i].ExpirationTimeMs // ??? how to convert from ProtoLong to int?
encounter_id: MapPokemon[i].EncounterId        // ??? how to convert from ProtoLong to base64?
                                               // also NearbyPokemon[i].EncounterId
latitude: MapPokemon[i].Latitude
longitude: MapPokemon[i].Longitude
pokemon_id: MapPokemon[i].PokedexTypeId        // how to convert from ProtoLong to base64?
                                               // also NearbyPokemon[i].PokedexNumber
pokemon_name: pokeio.pokemonlist[n - 1]
spawnpoint_id: MapPokemon[i].SpawnpointId
LASkuma commented 8 years ago

Both of ExpirationTimeMs and EncounterId should be protoLong. However, they can be fit into numbers. You can simply do parseInt(MapPokemon[i].ExpirationTimeMs.toString()) to transform it back into number.

ALawliet commented 8 years ago

The gym stuff comes from Fort in a self.Heartbeat cell. I am using an older version where it is missing some of the data, but it looks something like this:

Fort: [
{
FortId: "076c7d8c03634557bf9a90ce51028268.16",
LastModifiedMs: {
low: 162407318,
high: 342,
unsigned: false
},
Latitude: 38.898951,
Longitude: -77.038961,
Team: null,
GuardPokemonId: null,
GuardPokemonLevel: null,
Enabled: true,
FortType: 1,
GymPoints: null,
IsInBattle: null,
ActiveFortModifier: null,
LureInfo: null,
CooldownCompleteMs: null,
Sponsor: null,
RenderingType: null
}
...
]
coolaj86 commented 8 years ago

If you'd like to help I now have a working server (using this library) and client (forked from AHAAAAAAA) at https://github.com/Daplie/node-pokemap

Right now it only shows Pokémon, but with a little help massaging the data to match AHAAAAAAA's format, it'll show all the rest as well.