Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- flatten = lambda x: list(itertools.chain(*x))
- def bytesplit2(n):
- return [n>>8,n&0xFF]
- def bytesplit3(n):
- x = list(bytesplit2(n))
- x[0] = bytesplit2(x[0])
- x[1] = [x[1]] # need to do this for flatten to work
- return flatten(x)
- class Pokemon:
- def __init__(self):
- self.species = 0x00 # Species ID
- self.hp = 0x0000 # HP (16-bit big endian (the rest of the system uses little-endian???))
- self.boxlevel = 0x00 # Box Level (Pretty sure this is always 0 unless the 'mon's in the box, but oh well)
- self.status = 0x00 # Status Conditions (bitfield)
- self.types = [0x00,0x00] # Type 1 and Type 2 (same in single-typed 'mons)
- self.catchrate = 0x00 # Catch rate of original species (co-opted in Gen 2 for held item)
- self.moves = [0x00,0x00,0x00,0x00] # Move IDs
- self.otid = 0x0000 # ID of OT
- self.xp = 0x000000 # Main XP
- self.sxp = [0x0000 for x in range(5)] # Stat XP (HP, ATK, DEF, SPD, Special)
- self.dv = [0x00,0x00] # DVs (one nibble for each of Attack, Defense, Speed, Special)
- self.pp = [0x00,0x00,0x00,0x00] # PP for each move
- self.level = 0x00
- self.stathp = 0x0000 # max HP
- self.statatk = 0x0000 # attack stat
- self.statdef = 0x0000 # defense stat
- self.statspd = 0x0000 # speed stat
- self.statspl = 0x0000 # special stat
- def getBytes(self):
- return [self.species]+bytesplit2(self.hp)+[self.boxlevel,self.status]+self.types+[self.catchrate]+self.moves+bytesplit2(self.otid)+bytesplit3(self.xp)+[bytesplit2(x) for x in self.sxp]+self.dv+self.pp+[self.level]
- def stats(self):
- return flatten([bytesplit2(x) for x in (self.stathp,self.statatk,self.statdef,self.statspd,self.statspl)])
Advertisement
Add Comment
Please, Sign In to add comment