From 966985411f01b799fa71f4823da7a8cd6d9cc47b Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 11 Nov 2013 00:55:54 -0600 Subject: detect the "mandatory switch" menu This requires a slightly slower text_wait function. There is probably a way to refactor that function in a way that doesn't cause cancer. --- tests/test_vba_battle.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/test_vba_battle.py') diff --git a/tests/test_vba_battle.py b/tests/test_vba_battle.py index e86b53c..61c0297 100644 --- a/tests/test_vba_battle.py +++ b/tests/test_vba_battle.py @@ -56,6 +56,25 @@ class BattleTests(unittest.TestCase): # should not be asking for a switch so soon in the battle self.assertFalse(self.battle.is_mandatory_switch()) + def test_is_mandatory_switch(self): + self.battle.skip_start_text() + self.battle.skip_until_input_required() + + # press "FIGHT" + self.vba.press(["a"], after=20) + + # press the first move ("SCRATCH") + self.vba.press(["a"], after=20) + + # set partymon1 hp to very low + self.vba.write_memory_at(0xc63c, 0) + self.vba.write_memory_at(0xc63d, 1) + + # let the enemy attack and kill the pokemon + self.battle.skip_until_input_required() + + self.assertTrue(self.battle.is_mandatory_switch()) + def test_attack_loop(self): self.battle.skip_start_text() self.battle.skip_until_input_required() -- cgit v1.2.3