Mercurial > pyntnclick
comparison gamelib/tests/game_logic_utils.py @ 190:30f2308c1efc
Fix tests and add a (currently unhooked) laser welder.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Wed, 25 Aug 2010 20:09:19 +0200 |
parents | 6b0f7364f3bf |
children | 0bad554d0926 |
comparison
equal
deleted
inserted
replaced
189:c18ef647ffe6 | 190:30f2308c1efc |
---|---|
8 from gamelib.constants import SCREEN | 8 from gamelib.constants import SCREEN |
9 | 9 |
10 | 10 |
11 # We need this stuff set up so we can load images and whatnot. | 11 # We need this stuff set up so we can load images and whatnot. |
12 pygame.display.init() | 12 pygame.display.init() |
13 pygame.font.init() | |
13 pygame.display.set_mode(SCREEN, SWSURFACE) | 14 pygame.display.set_mode(SCREEN, SWSURFACE) |
14 | 15 |
15 | 16 |
16 class GameLogicTestCase(unittest.TestCase): | 17 class GameLogicTestCase(unittest.TestCase): |
17 CURRENT_SCENE = None | 18 CURRENT_SCENE = None |
37 self.assertEquals(value, gizmo.get_data(key)) | 38 self.assertEquals(value, gizmo.get_data(key)) |
38 | 39 |
39 def assert_inventory_item(self, item, in_inventory=True): | 40 def assert_inventory_item(self, item, in_inventory=True): |
40 self.assertEquals(in_inventory, self.state.items[item] in self.state.inventory) | 41 self.assertEquals(in_inventory, self.state.items[item] in self.state.inventory) |
41 | 42 |
42 def interact_thing(self, thing, item=None): | 43 def assert_scene_thing(self, thing, in_scene=True): |
44 self.assertEquals(in_scene, thing in self.state.current_scene.things) | |
45 | |
46 def assert_detail_thing(self, thing, in_detail=True): | |
47 self.assertEquals(in_detail, thing in self.state.current_detail.things) | |
48 | |
49 def interact_thing(self, thing, item=None, detail=False): | |
43 item_obj = None | 50 item_obj = None |
44 if item is not None: | 51 if item is not None: |
45 item_obj = self.state.items[item] | 52 item_obj = self.state.items[item] |
46 self.state.scenes[self.CURRENT_SCENE].things[thing].interact(item_obj) | 53 thing_container = self.state.current_scene |
54 if detail: | |
55 thing_container = self.state.current_detail | |
56 return thing_container.things[thing].interact(item_obj) |