summaryrefslogtreecommitdiff
path: root/tests/bootstrapping.py
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-11-11 10:36:33 -0800
committerBryan Bishop <kanzure@gmail.com>2013-11-11 10:36:33 -0800
commita11b084a2824dbe9c1df84d9ea205b8495f3da13 (patch)
treebe94d8ec6e86db5e883db5ebe9edffc2bdc951ff /tests/bootstrapping.py
parentff55a23ece3f74ad30ef2f10d81c54f464d5988b (diff)
parent966985411f01b799fa71f4823da7a8cd6d9cc47b (diff)
Merge pull request #39 from kanzure/vba-automation
More VBA automation
Diffstat (limited to 'tests/bootstrapping.py')
-rw-r--r--tests/bootstrapping.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/bootstrapping.py b/tests/bootstrapping.py
new file mode 100644
index 0000000..b71c19a
--- /dev/null
+++ b/tests/bootstrapping.py
@@ -0,0 +1,54 @@
+"""
+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)
+
+ cry.givepoke(64, 31, "kAdAbRa")
+ cry.givepoke(224, 60, "OcTiLlErY")
+ cry.givepoke(126, 87, "magmar")
+
+ cry.start_trainer_battle()
+
+ return runner.cry.vba.state