mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Added an is_shiny accessor to Pokémon structs.
This commit is contained in:
parent
b4539aa346
commit
5cd4fe7f2c
1 changed files with 18 additions and 0 deletions
|
@ -76,6 +76,24 @@ class SaveFilePokemon(object):
|
|||
return struct.pack(struct_def, *shuffled)
|
||||
|
||||
|
||||
### Delicious data
|
||||
|
||||
@property
|
||||
def is_shiny(self):
|
||||
u"""Returns true iff this Pokémon is shiny."""
|
||||
# See http://bulbapedia.bulbagarden.net/wiki/Personality#Shininess
|
||||
# But don't see it too much, because the above is super over
|
||||
# complicated. Do this instead!
|
||||
personality_msdw = self.structure.personality >> 16
|
||||
personality_lsdw = self.structure.personality & 0xffff
|
||||
return (
|
||||
self.structure.original_trainer_id
|
||||
^ self.structure.original_trainer_secret_id
|
||||
^ personality_msdw
|
||||
^ personality_lsdw
|
||||
) < 8
|
||||
|
||||
|
||||
### Utility methods
|
||||
|
||||
shuffle_orders = list( permutations(range(4)) )
|
||||
|
|
Loading…
Reference in a new issue