Mercurial > pyntnclick
comparison gamelib/tests/test_walkthrough.py @ 252:dfc89bc64fdb
Start of walkthrough "unit test" and associated fixes and tweaks.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 27 Aug 2010 16:45:47 +0200 |
parents | |
children | ca0c2875ad8f |
comparison
equal
deleted
inserted
replaced
251:602fe654bd37 | 252:dfc89bc64fdb |
---|---|
1 import game_logic_utils | |
2 | |
3 | |
4 class TestWalkthrough(game_logic_utils.GameLogicTestCase): | |
5 | |
6 CURRENT_SCENE = 'cryo' | |
7 | |
8 def close_detail(self): | |
9 self.state.set_current_detail(None) | |
10 | |
11 def move(self, source, target): | |
12 self.interact_thing(source+'.door') | |
13 self.assert_current_scene('map') | |
14 self.interact_thing('map.to'+target) | |
15 self.assert_current_scene(target) | |
16 | |
17 def test_walkthrough(self): | |
18 """A complete game walkthrough. | |
19 | |
20 This should only contain interacts and assertions.""" | |
21 | |
22 # TODO: Add flavour interactions, maybe? | |
23 | |
24 # Partially open the door. | |
25 self.assert_game_data('door', 'shut', 'cryo.door') | |
26 self.interact_thing('cryo.door') | |
27 self.assert_game_data('door', 'ajar', 'cryo.door') | |
28 | |
29 # Get the titanium leg. | |
30 self.interact_thing('cryo.unit.1') | |
31 self.assertEquals('cryo_detail', self.state.current_detail.name) | |
32 self.assert_detail_thing('cryo.titanium_leg') | |
33 self.interact_thing('cryo.titanium_leg') | |
34 self.assert_detail_thing('cryo.titanium_leg', False) | |
35 self.assert_inventory_item('titanium_leg') | |
36 self.close_detail() | |
37 | |
38 # Open the door the rest of the way. | |
39 self.interact_thing('cryo.door', 'titanium_leg') | |
40 self.assert_game_data('door', 'open', 'cryo.door') | |
41 self.assert_inventory_item('titanium_leg') | |
42 | |
43 # Go to the machine room. | |
44 self.move('cryo', 'machine') | |
45 | |
46 # Sharpen leg into machete. | |
47 self.interact_thing('machine.grinder', 'titanium_leg') | |
48 self.assert_inventory_item('titanium_leg', False) | |
49 self.assert_inventory_item('machete') | |
50 | |
51 # Go to the mess. | |
52 self.move('machine', 'mess') | |
53 | |
54 # Clear the broccoli. | |
55 self.assert_game_data('status', 'blocked', 'mess.tubes') | |
56 self.interact_thing('mess.tubes', 'machete') | |
57 self.assert_game_data('status', 'broken', 'mess.tubes') | |
58 | |
59 # Get the cans. | |
60 self.assert_game_data('cans_available', 3, 'mess.cans') | |
61 self.interact_thing('mess.cans') | |
62 self.assert_inventory_item('full_can.0') | |
63 self.interact_thing('mess.cans') | |
64 self.assert_inventory_item('full_can.1') | |
65 self.interact_thing('mess.cans') | |
66 self.assert_inventory_item('full_can.2') | |
67 self.assert_game_data('cans_available', 0, 'mess.cans') | |
68 | |
69 | |
70 self.fail("Walkthrough incomplete.") | |
71 |