예제 #1
0
    def test_moving_back_and_forth(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)

        runner.cry.move("l")
        runner.cry.move("l")
        runner.cry.move("l")
        runner.cry.move("d")
        runner.cry.move("d")

        for x in range(0, 10):
            runner.cry.move("l")
            runner.cry.move("d")
            runner.cry.move("r")
            runner.cry.move("u")

        # must still be in New Bark Town
        self.assertEqual(self.get_wram_value("MapGroup"), 24)
        self.assertEqual(self.get_wram_value("MapNumber"), 4)
예제 #2
0
def bootstrap_trainer_battle():
    """
    Start a trainer battle.
    """
    # setup
    cry = vba.crystal(config=None)
    runner = autoplayer.SpeedRunner(cry=cry)

    runner.skip_intro(skip=True)
    runner.handle_mom(skip=True)
    runner.walk_into_new_bark_town(skip=True)
    runner.handle_elm("totodile", skip=True)

    # levelgrind a pokemon
    # TODO: make new_bark_level_grind able to figure out how to construct its
    # initial state if none is provided.
    runner.new_bark_level_grind(17, skip=True)

    cry.givepoke(64, 31, "kAdAbRa")
    cry.givepoke(224, 60, "OcTiLlErY")
    cry.givepoke(126, 87, "magmar")

    cry.start_trainer_battle()

    return runner.cry.vba.state
예제 #3
0
    def test_speedrunner_handle_mom(self):
        # TODO: why can't i pass in the current state of the emulator?
        runner = autoplayer.SpeedRunner(cry=None)
        runner.setup()
        runner.skip_intro(skip=True)
        runner.handle_mom(skip=False)

        # confirm that handle_mom is done by attempting to move on the map
        self.assertTrue(self.check_movement("d"))
예제 #4
0
    def bootstrap_name_prompt(self):
        runner = autoplayer.SpeedRunner(cry=None)
        runner.setup()
        runner.skip_intro(stop_at_name_selection=True, skip=False, override=False)

        self.cry.vba.press("a", hold=20)

        # wait for "Your name?" to show up
        while "YOUR NAME?" not in self.cry.get_text():
            self.cry.step(count=50)
예제 #5
0
    def test_speedrunner_walk_into_new_bark_town(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)

        # test that the game is in a state such that the player can walk
        self.assertTrue(self.check_movement("d"))

        # check that the map is correct
        self.assertEqual(self.get_wram_value("MapGroup"), 24)
        self.assertEqual(self.get_wram_value("MapNumber"), 4)
예제 #6
0
    def test_speedrunner_handle_elm(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)

        # go through the Elm's Lab sequence
        runner.handle_elm("cyndaquil", skip=False)

        # test again if the game is in a state where the player can walk
        self.assertTrue(self.check_movement("u"))

        # check that the map is correct
        self.assertEqual(self.get_wram_value("MapGroup"), 24)
        self.assertEqual(self.get_wram_value("MapNumber"), 5)
예제 #7
0
def bootstrap():
    """
    Every test needs to be run against a certain minimum context. That context
    is constructed by this function.
    """

    cry = vba.crystal(config=None)
    runner = autoplayer.SpeedRunner(cry=cry)

    # skip=False means run the skip_intro function instead of just skipping to
    # a saved state.
    runner.skip_intro(skip=True)

    state = cry.vba.state

    # clean everything up again
    cry.vba.shutdown()

    return state
예제 #8
0
    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)
예제 #9
0
 def test_speedrunner_constructor(self):
     runner = autoplayer.SpeedRunner(cry=self.cry)