Mercurial > pyntnclick
comparison gamelib/tests/game_logic_utils.py @ 254:ca0c2875ad8f
More test fixes.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 27 Aug 2010 17:35:15 +0200 |
parents | dfc89bc64fdb |
children | a1ffc919d0c1 |
comparison
equal
deleted
inserted
replaced
253:60a0757bee05 | 254:ca0c2875ad8f |
---|---|
17 CURRENT_SCENE = None | 17 CURRENT_SCENE = None |
18 | 18 |
19 def setUp(self): | 19 def setUp(self): |
20 self.state = state.initial_state() | 20 self.state = state.initial_state() |
21 self.state.set_current_scene(self.CURRENT_SCENE) | 21 self.state.set_current_scene(self.CURRENT_SCENE) |
22 | |
23 def tearDown(self): | |
24 for item in self.state.items.values(): | |
25 if isinstance(item, state.CloneableItem): | |
26 type(item)._counter = 0 | |
22 | 27 |
23 def set_game_data(self, key, value, thing=None): | 28 def set_game_data(self, key, value, thing=None): |
24 gizmo = self.state.current_scene | 29 gizmo = self.state.current_scene |
25 if thing is not None: | 30 if thing is not None: |
26 gizmo = gizmo.things[thing] | 31 gizmo = gizmo.things[thing] |
50 self.assertEquals(scene, self.state.current_scene.name) | 55 self.assertEquals(scene, self.state.current_scene.name) |
51 | 56 |
52 def interact_thing(self, thing, item=None): | 57 def interact_thing(self, thing, item=None): |
53 item_obj = None | 58 item_obj = None |
54 if item is not None: | 59 if item is not None: |
60 self.assert_inventory_item(item) | |
55 item_obj = self.state.items[item] | 61 item_obj = self.state.items[item] |
56 thing_container = self.state.current_detail or self.state.current_scene | 62 thing_container = self.state.current_detail or self.state.current_scene |
57 result = thing_container.things[thing].interact(item_obj) | 63 result = thing_container.things[thing].interact(item_obj) |
58 if result and result.detail_view: | 64 if result and result.detail_view: |
59 self.state.set_current_detail(result.detail_view) | 65 self.state.set_current_detail(result.detail_view) |
60 return result | 66 return result |
61 | 67 |
68 def interact_item(self, target_item, item): | |
69 self.assert_inventory_item(target_item) | |
70 item_obj = self.state.items[item] | |
71 target_obj = self.state.items[target_item] | |
72 result = target_obj.interact(item_obj, self.state) | |
73 if result and result.detail_view: | |
74 self.state.set_current_detail(result.detail_view) | |
75 return result | |
76 |