Mercurial > pyntnclick
annotate gamelib/tests/test_walkthrough.py @ 311:00eb7ea2b7ea
Make self._interact_hilight_colour = None disable rect (matches comments)
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sat, 28 Aug 2010 08:56:12 +0200 |
parents | ca0c2875ad8f |
children | bfb6c682b4fb |
rev | line source |
---|---|
252
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
1 import game_logic_utils |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
2 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
3 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
4 class TestWalkthrough(game_logic_utils.GameLogicTestCase): |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
5 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
6 CURRENT_SCENE = 'cryo' |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
7 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
8 def close_detail(self): |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
9 self.state.set_current_detail(None) |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
10 |
254 | 11 def move_to(self, target): |
12 self.interact_thing(self.state.current_scene.name + '.door') | |
252
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
13 self.assert_current_scene('map') |
254 | 14 self.interact_thing('map.to' + target) |
252
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
15 self.assert_current_scene(target) |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
16 |
254 | 17 def test_walkthrough_complete(self): |
18 self.fail("Walkthrough incomplete.") | |
19 | |
252
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
20 def test_walkthrough(self): |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
21 """A complete game walkthrough. |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
22 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
23 This should only contain interacts and assertions.""" |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
24 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
25 # TODO: Add flavour interactions, maybe? |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
26 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
27 # Partially open the door. |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
28 self.assert_game_data('door', 'shut', 'cryo.door') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
29 self.interact_thing('cryo.door') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
30 self.assert_game_data('door', 'ajar', 'cryo.door') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
31 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
32 # Get the titanium leg. |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
33 self.interact_thing('cryo.unit.1') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
34 self.assertEquals('cryo_detail', self.state.current_detail.name) |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
35 self.assert_detail_thing('cryo.titanium_leg') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
36 self.interact_thing('cryo.titanium_leg') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
37 self.assert_detail_thing('cryo.titanium_leg', False) |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
38 self.assert_inventory_item('titanium_leg') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
39 self.close_detail() |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
40 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
41 # Open the door the rest of the way. |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
42 self.interact_thing('cryo.door', 'titanium_leg') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
43 self.assert_game_data('door', 'open', 'cryo.door') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
44 self.assert_inventory_item('titanium_leg') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
45 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
46 # Go to the mess. |
254 | 47 self.move_to('mess') |
252
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
48 |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
49 # Get the cans. |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
50 self.assert_game_data('cans_available', 3, 'mess.cans') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
51 self.interact_thing('mess.cans') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
52 self.assert_inventory_item('full_can.0') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
53 self.interact_thing('mess.cans') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
54 self.assert_inventory_item('full_can.1') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
55 self.interact_thing('mess.cans') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
56 self.assert_inventory_item('full_can.2') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
57 self.assert_game_data('cans_available', 0, 'mess.cans') |
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
58 |
254 | 59 # Bash one of the cans. |
60 self.assert_item_exists('dented_can.0', False) | |
61 self.interact_item('full_can.1', 'titanium_leg') | |
62 self.assert_inventory_item('dented_can.0') | |
63 self.assert_inventory_item('full_can.1', False) | |
252
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
64 |
254 | 65 # Go to the machine room. |
66 self.move_to('machine') | |
67 | |
68 # Sharpen leg into machete. | |
69 self.interact_thing('machine.grinder', 'titanium_leg') | |
70 self.assert_inventory_item('titanium_leg', False) | |
71 self.assert_inventory_item('machete') | |
72 | |
73 # Go to the cryo room. | |
74 self.move_to('cryo') | |
252
dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
75 |
254 | 76 # Chop up some pipes. |
77 self.assert_game_data('fixed', True, 'cryo.pipe.left') | |
78 self.interact_thing('cryo.pipe.left', 'machete') | |
79 self.assert_game_data('fixed', False, 'cryo.pipe.left') | |
80 self.assert_inventory_item('cryo_pipe.0') | |
81 | |
82 self.assert_game_data('fixed', True, 'cryo.pipe.right') | |
83 self.interact_thing('cryo.pipe.right', 'machete') | |
84 self.assert_game_data('fixed', False, 'cryo.pipe.right') | |
85 self.assert_inventory_item('cryo_pipe.1') | |
86 | |
87 # Go to the mess. | |
88 self.move_to('mess') | |
89 | |
90 # Clear the broccoli. | |
91 self.assert_game_data('status', 'blocked', 'mess.tubes') | |
92 self.interact_thing('mess.tubes', 'machete') | |
93 self.assert_game_data('status', 'broken', 'mess.tubes') | |
94 |