• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Pokedex Check

thor348

That's Oak to You
137
Posts
11
Years
I've been coding with C++ for years but can't seem to figure this out cause Ruby is different. My question is, how would I make professor Oaks Assistant check how many pokemon you've caught so he can give you an egg? or HM?
 
1,748
Posts
14
Years
Not really teh best then, usually in c++ when I handle arrays I do something like this:

Code:
bool seen[649];
int seen_amt=-1; // This could be 0 depending on how you build up you program.

now you can do the same for caught, and every time the play catches a pokemon just add 1 to caught_amt. OR you could use the longer (in terms of processing) way:

Code:
int pokemon_caught()
  int i, amt=0;
  for (i=0; i<649; i++){
    if (caught[i] == true){
      amt++;
    }
  }
  return amt;
}

Well anyways, depending on what your situation is, the one is better than the other.

NOTE: the 649 is just what I used because of regions 1-5 have 649 in total, you may obviously change this if you want to.
 

DaSpirit

Mad Programmer
240
Posts
16
Years
Not really the best then, usually in c++ when I handle arrays I do something like this:

Code:
bool seen[649];
int seen_amt=-1; // This could be 0 depending on how you build up you program.
Not the best C++.

Using booleans are a bad choice for something like this. Because you're using many booleans at once, it is better to use a bitset. You can just use 64bit variables, and use bitwise operations to set whether a Pokemon has been caught or not. Then, instead of looping through your variables, you can simply test whether they have reached the maximum amount (all bits are equal to 1) with a simple equal sign. Because you're using 64bits and you want to test for 649 Pokemon, you need 11 64bit variables.

It's a lot faster and uses less memory. 11 64 bit variables is equal to 88 bytes, compared to 649 bytes if you use a bool. I wouldn't know the implementation in Ruby, but that was sort of a pseudo-code for you.

Check out the Wikia, it shows how you can mark a Pokemon as seen in Essentials: http://pokemonessentials.wikia.com/wiki/Pokédex
Check the Pokedex script, as it lists how many Pokemon have been seen. Just copy that script.
 
Last edited:
Back
Top