Comments (6)
Which request(s) is this needed for? The way protobufs works is that the request needs to have the pokemon_id
linked to that Protobuf, though it might be confusing because pokemon_id
doesn't always refer to the Pokedex number.
Take for example ReleasePokemon, pokemon_id
refers to your unique pokemon id (obtained via get_inventory
, example here).
However if you look at EncounterTutorialComplete it refers to the Pokedex entry directly (working as intended) as it does not refer to your unique Pokemon.
from poke-api.
For instance with get_inventory
, you will get a JSON with the following hash for each Pokemon in your inventory
{:id=>17999104379928447950, :pokemon_id=>:ONIX
What I want to do, is getting the Pokemon's Pokedex ID (instead of :ONIX
).
from poke-api.
Aha, this actually seems intended by the protobufs (https://github.com/nabeelamjad/poke-api/blob/master/lib/poke-api/POGOProtos/Data/PokemonData.rb#L12). It maps the given number to a name by default, you may have to use custom conversion to change it back (I can provide a sample code on how to do that if you wish).
from poke-api.
The mapping already exists with the protobufs, It seems strange to have to
redefine my own enum.
On Thu, 28 Jul 2016 at 11:03, nabeelamjad [email protected] wrote:
Aha, this actually seems intended by the protobufs (
https://github.com/nabeelamjad/poke-api/blob/master/lib/poke-api/POGOProtos/Data/PokemonData.rb#L12).
It maps it to a name by default, you may have to use custom conversion to
change it back.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#15 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABNAZkX7d7c_ofmLsuhwd8-7mrj9AfR3ks5qaNLFgaJpZM4JW1cG
.Nicolas
from poke-api.
Here is how you could use it, unfortunately unless you want to change the Protobufs or fork it and remove the reference to PokemonID this is the only workaround I know of.
require 'poke-api'
require 'poke-api/POGOProtos/Enums/PokemonId' # You don't have to load this file after your response as it will be loaded.
def fetch_pokemon_id(name)
POGOProtos::Enums::PokemonId.const_get(name)
end
fetch_pokemon_id(:ONIX)
=> 95
To give you an insight what's happening internally, the protobufs are returning the ID 95 but because we (the protobufs for pokego) have an enum mapped to the ID it will map that like so:
POGOProtos::Enums::PokemonId.lookup(95)
=> :ONIX
Which then returns :ONIX instead of your ID because of the enum mapping.
from poke-api.
Indeed, your solution works :)
from poke-api.
Related Issues (20)
- Does not re-set api_url HOT 5
- syntax error in gpsoauth HOT 1
- Adding proxy support to HTTPClient HOT 7
- Encryption HOT 5
- Is it possible to set the location to a specific latitude and longitude? HOT 1
- Revamp README into a proper Wiki HOT 1
- get_map_objects always returns with empty pokemon arrays HOT 5
- Trying to understand fetch_ticket HOT 7
- Whats the difference between wild and catchable pokemons? HOT 11
- Locating pokestops
- Update signature and allow custom data HOT 6
- Getting unknown type: size_t input_size HOT 1
- Unkown proto fault when using @client.call or @client.login method HOT 8
- gpsoauth is not compatible with ruby 2.0.0 HOT 16
- undefined method `to_h' for [["error", "invalid_grant"]]:Array HOT 6
- Create a chat at Gitter? HOT 2
- 403 HOT 2
- Any chance of a 0.43.x API update? HOT 2
- S2 geometry library porting HOT 1
- wrong S2 cell ID for given latitude and longitude HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poke-api.