KEYS updated, signed copy.
[realism.git] / realism.py
blobe36623c332feb873cdd4cdb103bde2de479acde3
1 #!/usr/bin/env python
2 # This file is part of Realism, which is Copyright FunnyMan3595 (Charlie Nolan)
3 # and licensed under the GNU GPL v3. For more details, see LICENSE in the main
4 # Realism directory.
6 '''The main file of the Realism RPG engine. Runs the main game, or whatever mod is specified. This file is not meant to be imported, doing so may have strange effects.'''
8 # Realism separates the code into three main pieces: UI, engine, and game/mod.
9 # The ui used will be one of the modules in the ui subdirectory. It handles all
10 # direct interaction with the user.
11 # The engine is stored in the engine subdirectory and consistes of all of the
12 # generic code that doesn't deal directly with the game and its story, such as
13 # the combat mechanics. It also has virtual modules that load data from the
14 # game and mod.
15 # Everything that can be changed by a mod is stored in the main_game
16 # subdirectory. This includes monsters, spells, maps, and items. Actual mods
17 # can be put in a mods subdirectory of Realism's main directory, or in the
18 # user's home directory (as explained below).
21 # We allow mods to exist in the user's home directory, path:
22 # ~/.realism-rpg/mods/<modname>/
23 # On Windows XP, this translates to:
24 # <drive>:\Documents and Settings\<user>\.realism-rpg\mods\<modname>\
25 import sys
26 from os import makedirs
27 from os.path import join, expanduser, isdir
28 user_dir = join(expanduser('~'),'.realism-rpg')
29 if not isdir(user_dir):
30 makedirs(user_dir)
31 sys.path.append(user_dir)
33 from game import game
35 # Initialize the party.
36 from engine.party import HeroParty
37 game.party = HeroParty()
39 # Initialize the UI.
40 from ui.zork_ui import ZorkUI
41 game.ui = ui = ZorkUI()
43 # Import the maps, register the game object with them, and validate them.
44 from engine.maps import maps
45 for game_map in maps.values():
46 game_map.validate()
48 try:
49 from engine.maps import start_map
50 except ImportError:
51 if "start_map" not in maps.keys():
52 print "No start map found. Realism will exit."
53 sys.exit()
55 # maps["start"] guaranteed to exist.
56 start_map = maps["start_map"]
58 # start_map guaranteed to exist
60 # Tell the UI to use start_map.
61 ui.map_mode(start_map)
63 # Start the UI.
64 ui.main_loop()