move() can now take a list of movements to make

This commit is contained in:
Bryan Bishop
2013-10-12 16:41:50 -05:00
parent e13cdeab11
commit 5fdd27030e
2 changed files with 34 additions and 7 deletions

View File

@@ -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):
"""

View File

@@ -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()