예제 #1
0
 def __init__(self, filepath_or_save=None, box=None, pos=None):
     '''
     Creates a new Pokemon object.
     If filepath_or_save is None, creates a new, blank pokemon.
     If filepath_or_save is a Savefile object, reads a pokemon from
         the supplied savefile. The arguments box and pos are required.
     If filepath_or_save is a filepath, reads the pokemon from a file.
     '''
     self.filepath_or_save = filepath_or_save
     self.box = box
     self.pos = pos
     self._pokemon = c_void_p(None)
     if filepath_or_save is None:
         # create a new, blank pokemon
         ec = epsf_new_pokemon(byref(self._pokemon))
     elif isinstance(filepath_or_save, Savefile):
         # read from opened savefile
         if box is None or pos is None:
             raise ValueError("If the pokemon object gets passed a savefile, the arguments "
                              " box and pos are required!")
         ec = epsf_read_pokemon_from_save(filepath_or_save._save, box, pos, byref(self._pokemon))
     else:
         # read from file
         ec = epsf_read_pokemon_from_file(filepath_or_save.encode(), byref(self._pokemon))
     check_throw_error(ec)
     self._effort_values = Stats(self, EPSK_EFFORT_VALUE)
     self._individual_values = Stats(self, EPSK_INDIVIDUAL_VALUE)
     self._moves = tuple(Move(self, i+1) for i in range(4))
예제 #2
0
 def __init__(self, filepath):
     '''
     Creates a new Savefile object by reading the file from the supplied filepath.
     '''
     self.filepath = filepath
     self._save = c_void_p(None)
     ec = epsf_read_save_from_file(filepath.encode(), byref(self._save))
     check_throw_error(ec)
예제 #3
0
 def save(self, filepath=None):
     '''
     Saves the Savefile to file. If filepath is specified, saves it to that file.
     Otherwise it overwrites the file this Savefile object was created from.
     '''
     if filepath is None:
         filepath = self.filepath
     ec = epsf_write_save_to_file(self._save, filepath.encode())
     check_throw_error(ec)
예제 #4
0
 def save(self, filepath_or_save=None, box=None, pos=None):
     '''
     Saves the pokemon. If filepath_or_save is None, uses whatever was used to create
     this pokemon object. Same goes for box and pos.
     If filepath_or_save is a Savefile object, saves the pokemon to that savefile.
     Otherwise, if it is a filepath, saves the pokemon to that file.'''
     if filepath_or_save is None:
         filepath_or_save = self.filepath_or_save
     if box is None:
         box = self.box
     if pos is None:
         pos = self.pos
     if isinstance(filepath_or_save, Savefile):
         ec = epsf_write_pokemon_to_save(filepath_or_save._save, box, pos, self._pokemon)
     else:
         ec = epsf_write_pokemon_to_file(self._pokemon, filepath_or_save.encode())
     check_throw_error(ec)
예제 #5
0
 def save_slot(self):
     ec = epsf_current_save_slot(self._save)
     check_throw_error(ec)
     return ec
예제 #6
0
 def is_slot_empty(self, slot):
     ec = epsf_is_save_slot_empty(self._save, slot)
     check_throw_error(ec)
     return bool(ec)
예제 #7
0
 def erase_pokemon(self, box, pos):
     ec = epsf_erase_pokemon_from_save(self._save, box, pos)
     check_throw_error(ec)
예제 #8
0
 def copy_slot(self, from_, to):
     ec = epsf_copy_save_slot(self._save, from_, to)
     check_throw_error(ec)
예제 #9
0
 def erase_slot(self, slot):
     ec = epsf_erase_save_slot(self._save, slot)
     check_throw_error(ec)
예제 #10
0
 def operation_mode(self):
     ec = epsf_current_operation_mode(self._save)
     check_throw_error(ec)
     return ec
예제 #11
0
 def operation_mode(self, mode):
     ec = epsf_select_operation_mode(self._save, mode)
     check_throw_error(ec)
     return ec
예제 #12
0
 def fix_checksum(self):
     ec = epsf_fix_pokemon_checksum(self._pokemon)
     check_throw_error(ec)
예제 #13
0
 def save_slot(self, slot):
     ec = epsf_select_save_slot(self._save, slot)
     check_throw_error(ec)
예제 #14
0
 def _get_pokemon_name(self, ot=False):
     name = create_string_buffer(12)
     ec = epsf_get_pokemon_name(self._pokemon, int(ot), name)
     check_throw_error(ec)
     return name.value.decode("ascii").replace("<", "\u2642").replace(">", "\u2640")
예제 #15
0
 def _set_value(self, kind, index, value):
     ec = epsf_set_pokemon_value(self._pokemon, kind, index, value)
     check_throw_error(ec)
예제 #16
0
 def _get_value(self, kind, index):
     value = c_uint(0)
     ec = epsf_get_pokemon_value(self._pokemon, kind, index, byref(value))
     check_throw_error(ec)
     return value.value
예제 #17
0
 def ot_name(self, name):
     ec = epsf_set_pokemon_name(self._pokemon, 1, name.encode())
     check_throw_error(ec)
예제 #18
0
 def name(self, name):
     name = name.replace("\u2642", "<").replace("\u2640", ">")
     ec = epsf_set_pokemon_name(self._pokemon, 0, name.encode())
     check_throw_error(ec)