GithubHelp home page GithubHelp logo

Comments (6)

nabeelamjad avatar nabeelamjad commented on September 8, 2024

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.

nicolas-besnard avatar nicolas-besnard commented on September 8, 2024

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.

nabeelamjad avatar nabeelamjad commented on September 8, 2024

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.

nicolas-besnard avatar nicolas-besnard commented on September 8, 2024

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.

nabeelamjad avatar nabeelamjad commented on September 8, 2024

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.

nicolas-besnard avatar nicolas-besnard commented on September 8, 2024

Indeed, your solution works :)

from poke-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.