Refactored to stop passing game around.
[realism.git] / realism.py
blob3002c34c3d132b2f341bb76861a1d1323d0f58f7
1 #!/usr/bin/env python
3 # We allow mods to exist in the user's home directory, path:
4 # ~/.realism-rpg/mods/<modname>/
5 # On Windows XP, this translates to:
6 # <drive>:\Documents and Settings\<user>\.realism-rpg\mods\<modname>\
7 import sys
8 from os import makedirs
9 from os.path import join, expanduser, isdir
10 user_dir = join(expanduser('~'),'.realism-rpg')
11 if not isdir(user_dir):
12 makedirs(user_dir)
13 sys.path.append(user_dir)
15 from game import game
17 from engine.party import HeroParty
18 game.party = HeroParty()
20 from ui.zork_ui import ZorkUI
21 game.ui = ui = ZorkUI()
23 # Import the maps, register the game object with them, and validate them.
24 from engine.maps import maps
25 for game_map in maps.values():
26 game_map.validate()
28 try:
29 from engine.maps import start_map
30 except ImportError:
31 if "start_map" not in maps.keys():
32 print "No start map found. Realism will exit."
33 sys.exit()
35 # maps["start"] guaranteed to exist.
36 start_map = maps["start_map"]
38 # start_map guaranteed to exist
39 ui.map_mode(start_map)
41 ui.main_loop()