diff options
-rw-r--r-- | pokemontools/vba/vba.py | 18 | ||||
-rw-r--r-- | tests/test_vba.py | 23 |
2 files changed, 34 insertions, 7 deletions
diff --git a/pokemontools/vba/vba.py b/pokemontools/vba/vba.py index 81b27a3..81ffe4e 100644 --- a/pokemontools/vba/vba.py +++ b/pokemontools/vba/vba.py @@ -557,15 +557,19 @@ class crystal(object): """ Attempt to move the player. """ - self.vba.press(cmd, hold=10, after=0) - self.vba.press([]) + if isinstance(cmd, list): + for command in cmd: + self.move(cmd) + else: + self.vba.press(cmd, hold=10, after=0) + self.vba.press([]) - memory = self.vba.memory - #while memory[0xd4e1] == 2 and memory[0xd042] != 0x3e: - while memory[0xd043] in [0, 1, 2, 3]: - #while memory[0xd043] in [0, 1, 2, 3] or memory[0xd042] != 0x3e: - self.vba.step(count=10) memory = self.vba.memory + #while memory[0xd4e1] == 2 and memory[0xd042] != 0x3e: + while memory[0xd043] in [0, 1, 2, 3]: + #while memory[0xd043] in [0, 1, 2, 3] or memory[0xd042] != 0x3e: + self.vba.step(count=10) + memory = self.vba.memory def get_enemy_hp(self): """ diff --git a/tests/test_vba.py b/tests/test_vba.py index f8bdaa6..b68e24b 100644 --- a/tests/test_vba.py +++ b/tests/test_vba.py @@ -223,6 +223,29 @@ class VbaTests(unittest.TestCase): self.assertEqual(self.get_wram_value("MapGroup"), 24) self.assertEqual(self.get_wram_value("MapNumber"), 4) + def test_crystal_move_list(self): + runner = autoplayer.SpeedRunner(cry=None) + runner.setup() + runner.skip_intro(skip=True) + runner.handle_mom(skip=True) + runner.walk_into_new_bark_town(skip=False) + + # must be in New Bark Town + self.assertEqual(self.get_wram_value("MapGroup"), 24) + self.assertEqual(self.get_wram_value("MapNumber"), 4) + + first_map_x = self.get_wram_value("MapX") + + runner.cry.move(["l", "l", "l"]) + + # x location should be different + second_map_x = self.get_wram_value("MapX") + self.assertNotEqual(first_map_x, second_map_x) + + # must still be in New Bark Town + self.assertEqual(self.get_wram_value("MapGroup"), 24) + self.assertEqual(self.get_wram_value("MapNumber"), 4) + def test_keyboard_typing_dumb_name(self): self.bootstrap_name_prompt() |