From 32fe4eedee350ddca0c66f2404967cc73f89d957 Mon Sep 17 00:00:00 2001 From: Eevee Date: Wed, 7 Jul 2010 22:29:30 -0700 Subject: [PATCH] =?utf8?q?Added=20an=20is=5Fshiny=20accessor=20to=20Pok?= =?utf8?q?=C3=A9mon=20structs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- pokedex/struct/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pokedex/struct/__init__.py b/pokedex/struct/__init__.py index d1142d0..d55dda7 100644 --- a/pokedex/struct/__init__.py +++ b/pokedex/struct/__init__.py @@ -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)) ) -- 2.7.4