pokemon-reverse-engineering.../tests/bootstrapping.py
Bryan Bishop 3868fb1e06 simplify the vba-related tests
The imports for the emulator-related tests are now simplified in the
tests/ folder. The bootstrapping.py file contains some shared functions
that multiple test files might choose to use. Those functions probably
belong in the actual module instead of in tests/.

The battle-related tests have been separated from the other emulator
tests.
2013-11-09 15:45:03 -06:00

52 lines
1.2 KiB
Python

"""
Functions to bootstrap the emulator state
"""
from setup_vba import (
vba,
autoplayer,
)
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
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)
# TODO: figure out a better way to start a trainer battle :(
runner.cry.start_trainer_battle_lamely()
return runner.cry.vba.state