diff options
Diffstat (limited to 'pokemontools/vba/vba.py')
-rw-r--r-- | pokemontools/vba/vba.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index 02fd99d..57e5e1b 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -523,6 +523,13 @@ class crystal(object): self.vba.write_memory_at(0xd216, 0) self.vba.write_memory_at(0xd217, 1) + def set_battle_mon_hp(self, hp): + """ + Set the BattleMonHP variable to the given hp. + """ + self.vba.write_memory_at(0xc63c, hp / 0x100) + self.vba.write_memory_at(0xc63c + 1, hp % 0x100) + def nstep(self, steplimit=500): """ Steps the CPU forward and calls some functions in between each step. @@ -592,6 +599,50 @@ class crystal(object): def is_in_link_battle(self): return self.vba.read_memory_at(0xc2dc) != 0 + def is_trainer_switch_prompt(self): + """ + Checks if the game is currently displaying the yes/no prompt for + whether or not to switch pokemon. This happens when the trainer is + switching pokemon out. + """ + # TODO: this method should return False if the game options have been + # set to not use the battle switching style. + + # get on-screen text + text = self.get_text() + + requirements = [ + "YES", + "NO", + "Will ", + "change POKMON?", + ] + + return all([requirement in text for requirement in requirements]) + + def is_wild_switch_prompt(self): + """ + Detects if the battle is waiting for the player to choose whether or + not to continue to fight the wild pokemon. + """ + # get on-screen text + screen_text = self.get_text() + + requirements = [ + "YES", + "NO", + "Use next POKMON?", + ] + + return all([requirement in text for requirement in requirements]) + + def is_switch_prompt(self): + """ + Detects both the trainer-style switch prompt and the wild-style switch + prompt. This is the yes/no prompt for whether to switch pokemon. + """ + return self.is_trainer_switch_prompt() or self.is_wild_switch_prompt() + def unlock_flypoints(self): """ Unlocks different destinations for flying. @@ -604,6 +655,12 @@ class crystal(object): self.vba.write_memory_at(0xDCA7, 0xFF) self.vba.write_memory_at(0xDCA8, 0xFF) + def set_battle_type(self, battle_type): + """ + Changes the battle type value. + """ + self.vba.write_memory_at(0xd230, battle_type) + def get_gender(self): """ Returns 'male' or 'female'. |