Package horizons :: Module main
[hide private]
[frames] | no frames]

Module main

source code

This is the main game file. It has grown over the years from a collection of global variables (sic!) to something holding mainly the main gui and game session, as well as a reference to the engine object (fife). The functions below are used to start different kinds of games.

TUTORIAL: Continue to horizons.session for further ingame digging.

Functions [hide private]
 
start(_command_line_arguments)
Starts the horizons.
source code
 
setup_AI_settings(command_line_arguments) source code
 
setup_debug_mode(command_line_arguments) source code
 
setup_gui_logger(command_line_arguments)
Install gui logger, needs to be done before instantiating Gui, otherwise we miss the events of the main menu buttons
source code
 
quit()
Quits the game
source code
 
quit_session()
Quits the current game.
source code
 
start_singleplayer(options)
Starts a singleplayer game.
source code
 
prepare_multiplayer(game, trader_enabled=True, pirate_enabled=True, natural_resource_multiplier=1)
Starts a multiplayer game server TODO: actual game data parameter passing
source code
 
start_multiplayer(game) source code
 
_start_map(map_name, ai_players=0, is_scenario=False, pirate_enabled=True, trader_enabled=True, force_player_id=None, is_map=False)
Start a map specified by user
source code
 
_start_random_map(ai_players, seed=None, force_player_id=None) source code
 
_load_cmd_map(savegame, ai_players, force_player_id=None)
Load a map specified by user.
source code
 
_find_scenario(name_or_path, scenario_db)
Find a scenario by name or path specified by user.
source code
 
_find_map(name_or_path, map_db)
Find a map by name or path specified by user.
source code
 
_load_last_quicksave(currentSession=None, force_player_id=None)
Load last quicksave
source code
 
_edit_map(map_file)
Start editing the specified map file.
source code
 
edit_map(map_name)
Start editing the map file specified by the name.
source code
 
edit_game_map(saved_game_name)
Start editing the specified map.
source code
 
_create_main_db()
Returns a dbreader instance, that is connected to the main game data dbfiles.
source code
 
set_debug_log(enabled, startup=False) source code
Variables [hide private]
  gui = None
hash(x)
  session = None
hash(x)
  __string_previewer = None
hash(x)
  command_line_arguments = None
hash(x)
  preloader = None
hash(x)
Function Details [hide private]

start(_command_line_arguments)

source code 

Starts the horizons. Will drop you to the main menu.

Parameters:
  • _command_line_arguments - options object from optparse.OptionParser. see run_uh.py.

_start_map(map_name, ai_players=0, is_scenario=False, pirate_enabled=True, trader_enabled=True, force_player_id=None, is_map=False)

source code 

Start a map specified by user

Parameters:
  • map_name - name of map or path to map
Returns:
bool, whether loading succeeded

_load_cmd_map(savegame, ai_players, force_player_id=None)

source code 

Load a map specified by user.

Parameters:
  • savegame - either the displayname of a savegame or a path to a savegame
Returns:
bool, whether loading succeeded

_find_scenario(name_or_path, scenario_db)

source code 

Find a scenario by name or path specified by user.

Parameters:
  • name_or_path - scenario name or path to thereof
  • scenario_db - defaultdict of the format: { <scenario name> : [ (<locale 1>, <path 1>), (<locale 2>, <path 2>), ... ] }
Returns:
path to the scenario file as string

_find_map(name_or_path, map_db)

source code 

Find a map by name or path specified by user.

Parameters:
  • name_or_path - map name or path to thereof
  • map_db - tuple of the format: ( (<map path 1>, <map path 2>, ...), [ <map 1>, <map 2>, ...] )
Returns:
path to the map file as string

_load_last_quicksave(currentSession=None, force_player_id=None)

source code 

Load last quicksave

Parameters:
  • currentSession - value of currentSession
Returns:
bool, whether loading succeeded

_edit_map(map_file)

source code 

Start editing the specified map file.

Parameters:
  • map_file - path to the map file or a list of random island strings
Returns:
bool, whether loading succeeded

edit_map(map_name)

source code 

Start editing the map file specified by the name.

Parameters:
  • map_name - name of map or path to map
Returns:
bool, whether loading succeeded

edit_game_map(saved_game_name)

source code 

Start editing the specified map.

Parameters:
  • map_name - name of map or path to map
Returns:
bool, whether loading succeeded

_create_main_db()

source code 

Returns a dbreader instance, that is connected to the main game data dbfiles. NOTE: This data is read_only, so there are no concurrency issues.

set_debug_log(enabled, startup=False)

source code 
Parameters:
  • enabled - boolean if logging should be enabled
  • startup - True if on startup to apply settings. Won't show popup