NicklasWallgren / PokemonGoAPI-PHP

Pokemon Go API PHP library
BSD 2-Clause "Simplified" License
130 stars 51 forks source link

IV Values #87

Closed baskettcase closed 8 years ago

baskettcase commented 8 years ago

Is there a way of getting the IV values of each of the pokemon a person has? I went through the "Issues" and closed ones and didn't see anything about it, so Im hoping that there is a way?

jaspervdm commented 8 years ago

Looking at NicklasW\PkmGoApi\Api\Pokemon in src/Api/Pokemon/Pokemon.php, you can get the IV values with getIndividualAttack(), getIndividualDefense() and getIndividualStamina()

baskettcase commented 8 years ago

Aha thank you @jaspervdm

NicklasWallgren commented 8 years ago

You can get the IV ratio directly with getIvRatio()

baskettcase commented 8 years ago

Thank you, I was able to figure that out once you gave me the direction to look, plus I did a sort by:

$pokemons = $pokeBank->getPokemonsByType(PokemonId::MAGIKARP)->sortByIVRatio(true);

My next question is how can I iterate through all my pokemon, instead of just one type. I've tried a couple different combinations, but I can't seem to find the right method.. seems like I can only work with a subset of the data?

Also.. every time I login, I believe my coordinates have to be set correct? If that's the case.. by default where is it setting me when I run any of the scripts?

lambasoft commented 8 years ago

@baskettcase To get your Pokemon as an array use $pokeBank->getPokemons()

    // Initialize the pokemon go application
    $application = new ApplicationKernel($manager);

    // Retrieve the pokemon go api instance
    $pokemonGoApi = $application->getPokemonGoApi();

    // Retrieve the inventory
    $inventory = $pokemonGoApi->getInventory();

    // Retrieve the poke bank
    $pokeBank = $inventory->getPokeBank();

    //Print your Pokemon as an Array
    echo '<pre>' . print_r( $pokeBank->getPokemons() ) . '</pre>';
lambasoft commented 8 years ago

And no, for the time being don't worry about setting your coordinates.

NicklasWallgren commented 8 years ago

Resolved.

baskettcase commented 8 years ago

Sorry to comment on a "Resolved" issue, but after all the bans that I've seen going around, the not worrying about setting my coordinates thing that @lambasoft mentioned.. I am starting to worry about it. Can you explain why I shouldn't worry about it? :)