def load_game(core, species=0x611): core.autoload_save() core.reset() run(core, 300) press(core, A) run(core, 50) press(core, A) run(core, 50) press(core, A) run(core, 100) press(core, A) run(core, 200) mon = BoxMon.from_buffer(read_mon(core)) mon.decrypt() growth = mon.sub(0).type0 if species != growth.species: growth.species = species mon.checksum = mon.calc_checksum() mon.encrypt() write_mon(core, mon) with open(f'fuzz/{species:04X}.pk3', 'wb') as f: f.write(bytes(mon)) print(f'Species: {species:04X}') press(core, DOWN, duration=40) run(core, 30) press(core, A) run(core, 1000) save_png()
def open_mon(self): options = QtWidgets.QFileDialog.Options() options |= QtWidgets.QFileDialog.DontUseNativeDialog tup = QtWidgets.QFileDialog.getOpenFileName(self.centralwidget, 'Open pokemon', options=options, directory=self.last_mon_dir, filter='Decrypted pokemon (*.pkm *.pk3);;Binary file (*)') path, filetype = tup if not path: return self.last_mon_dir = os.path.dirname(path) with open(path, 'rb') as f: buffer = f.read(80) if len(buffer) != 80: # TODO: Show alert return buffer = bytearray(buffer[:80]) if '*.pk3' in filetype: # Convert PKHeX .pk3 self.mon = BoxMon.from_pk3(buffer) else: self.mon = BoxMon.from_buffer(buffer) # Test if mon is already decrypted self.encrypted = not (self.mon.checksum == self.mon.calc_checksum()) # If equal, mon is already decrypted self.show_mon()
def load_raw(self): buffer = bytearray.fromhex(self.raw.text()) self.mon = BoxMon.from_buffer(buffer) self.encrypted = True self.show_mon()