summaryrefslogtreecommitdiff
path: root/pokemontools
diff options
context:
space:
mode:
Diffstat (limited to 'pokemontools')
-rw-r--r--pokemontools/vba/battle.py6
-rw-r--r--pokemontools/vba/vba.py11
2 files changed, 12 insertions, 5 deletions
diff --git a/pokemontools/vba/battle.py b/pokemontools/vba/battle.py
index 824f27a..87cd7b1 100644
--- a/pokemontools/vba/battle.py
+++ b/pokemontools/vba/battle.py
@@ -67,8 +67,10 @@ class Battle(EmulatorController):
# 1) current pokemon hp is 0
# 2) game is polling for input
- # TODO: detect the mandatory switch menu
- return False
+ if "CANCEL Which ?" in self.emulator.get_text():
+ return True
+ else:
+ return False
def skip_start_text(self, max_loops=20):
"""
diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py
index 0dac63f..10513c6 100644
--- a/pokemontools/vba/vba.py
+++ b/pokemontools/vba/vba.py
@@ -431,12 +431,17 @@ class crystal(object):
# set CurSFX
self.vba.write_memory_at(0xc2bf, 0)
- self.vba.press("a", hold=10, after=1)
+ self.vba.press("a", hold=10, after=50)
# check if CurSFX is SFX_READ_TEXT_2
if self.vba.read_memory_at(0xc2bf) == 0x8:
- print "cursfx is set to SFX_READ_TEXT_2, looping.."
- return self.text_wait(step_size=step_size, max_wait=max_wait, debug=debug, callback=callback, sfx_limit=sfx_limit)
+ if "CANCEL Which" in self.get_text():
+ print "probably the 'switch pokemon' menu"
+ return
+ else:
+ print "cursfx is set to SFX_READ_TEXT_2, looping.."
+ print self.get_text()
+ return self.text_wait(step_size=step_size, max_wait=max_wait, debug=debug, callback=callback, sfx_limit=sfx_limit)
else:
if sfx_limit > 0:
sfx_limit = sfx_limit - 1