From 3868fb1e0622e5d3cda0c093ce3114c485fd0096 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sat, 9 Nov 2013 15:45:03 -0600 Subject: 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. --- tests/bootstrapping.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/bootstrapping.py (limited to 'tests/bootstrapping.py') diff --git a/tests/bootstrapping.py b/tests/bootstrapping.py new file mode 100644 index 0000000..17a2945 --- /dev/null +++ b/tests/bootstrapping.py @@ -0,0 +1,51 @@ +""" +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 -- cgit v1.2.3 From 9249ffd2d01ec38ace0caf8d5b3d0f0a7cad23f2 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 10 Nov 2013 23:14:42 -0600 Subject: bootstrap the battle tests with more mons Use the givepoke function to add a few more pokemon to the team before starting the battle-related tests. There are some features of the battle handling code that require more than one pokemon to be present in the party. --- tests/bootstrapping.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/bootstrapping.py') diff --git a/tests/bootstrapping.py b/tests/bootstrapping.py index 17a2945..986a20b 100644 --- a/tests/bootstrapping.py +++ b/tests/bootstrapping.py @@ -45,6 +45,10 @@ def bootstrap_trainer_battle(): # 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") + # TODO: figure out a better way to start a trainer battle :( runner.cry.start_trainer_battle_lamely() -- cgit v1.2.3 From 1d9ecfa00f91d602073b56a64f9aa129b95a8c2e Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 11 Nov 2013 00:04:32 -0600 Subject: switch tests to use new battle starter --- tests/bootstrapping.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/bootstrapping.py') diff --git a/tests/bootstrapping.py b/tests/bootstrapping.py index 986a20b..b71c19a 100644 --- a/tests/bootstrapping.py +++ b/tests/bootstrapping.py @@ -49,7 +49,6 @@ def bootstrap_trainer_battle(): cry.givepoke(224, 60, "OcTiLlErY") cry.givepoke(126, 87, "magmar") - # TODO: figure out a better way to start a trainer battle :( - runner.cry.start_trainer_battle_lamely() + cry.start_trainer_battle() return runner.cry.vba.state -- cgit v1.2.3