Esempio n. 1
0
 def GenNoShinyID(self):
     wNoShinyRand = random.randint(0, 0xFFFF) & 0xFFF8
     if wNoShinyRand == 0:
         wNoShinyRand = 8
     dwChar, dwID = self.Header['dwChar', 'dwID']
     dwNoShinyId = loword(dwID) ^ loword(dwChar) ^ hiword(dwChar)
     dwNoShinyId = ((dwNoShinyId ^ wNoShinyRand) << 16) | loword(dwID)
     return dwNoShinyId
Esempio n. 2
0
    def Decode(self):
        """解密 此操作应在local对象上执行"""
        if self.bEncoded:
            pdwPokemon = self.values
            Header = self.Header

            dwXorMask = Header.dwChar ^ Header.dwID
            wChecksum = 0

            for n in range(len(pdwPokemon)):
                temp = pdwPokemon[n]
                temp ^= dwXorMask
                pdwPokemon[n] = temp
                wChecksum += loword(temp) + hiword(temp)

            Header.wChecksum = loword(wChecksum)
            self.bEncoded = False
Esempio n. 3
0
    def Encode(self):
        """加密 此操作应在local对象上执行"""
        if self.bEncoded:
            return

        pdwPokemon = self.values
        Header = self.Header

        # make sure this pokemon is daycare-center-enbled, and not a bag egg
        if self.breedInfo and self.breedInfo.wBreed != 0:
            Header.bBadEgg |= 0x02
            Header.bBadEgg &= (~0x05) & 0xFF

        dwXorMask = Header.dwChar ^ Header.dwID
        wChecksum = 0

        for n in range(len(pdwPokemon)):
            temp = pdwPokemon[n]
            wChecksum += loword(temp) + hiword(temp)
            pdwPokemon[n] = temp ^ dwXorMask

        Header.wChecksum = loword(wChecksum)
        self.bEncoded = True
Esempio n. 4
0
 def GenShinyID(self):
     dwChar, dwID = self.Header['dwChar', 'dwID']
     dwShinyId = loword(dwID) ^ loword(dwChar) ^ hiword(dwChar) ^ random.randint(0, 7)
     dwShinyId = (dwShinyId << 16) | loword(dwID)
     return dwShinyId
Esempio n. 5
0
 def GetIsShiny(self):
     if self.bEncoded:
         return
     dwChar, dwID = self.Header['dwChar', 'dwID']
     wShiny = loword(dwChar) ^ hiword(dwChar) ^ loword(dwID) ^ hiword(dwID)
     return wShiny <= 0x07