1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import containers
19 import doors
20 import actors
21 import items
22 import sys
23
24 OBJECT_MODULES = [containers, actors, doors, items]
25
27 """Returns a dictionary with the names of the concrete game object classes
28 mapped to the classes themselves"""
29 result = {}
30 for module in OBJECT_MODULES:
31 for class_name in module.__all__:
32 result[class_name] = getattr (module, class_name)
33 return result
34
36 """Called when we need to get an actual object.
37 @type info: dict
38 @param info: stores information about the object we want to create
39 @type extra: dict
40 @param extra: stores additionally required attributes
41 @return: the object"""
42
43 extra = extra or {}
44 try:
45 obj_type = info.pop('type')
46 ID = info.pop('id')
47 except KeyError:
48 sys.stderr.write("Error: Game object missing type or id.")
49 sys.exit(False)
50
51
52 for key, val in extra.items():
53 info[key] = val
54
55
56 return getAllObjects()[obj_type](ID, **info)
57