Source

Lost Sky Project (Public) / Story of a Lost Sky / lostsky / __init__.py

Full commit
# Lost Sky Project Main Program

import pygame
import os
import sys
import time
from lostsky.missions import mission_catalog
from lostsky.worldmap.worldmap import Worldmap
from lostsky.core.engine import Engine
from lostsky.core import xmlreader


def bootstrap():
    # Diagonstic print to text file mode
    if len(sys.argv) > 1:
        if sys.argv[1] == "-p":
            print "Enabled Diagnostic Printing to output.txt!"
            output_file = file('output.txt', 'w')
            sys.stdout = output_file
            sys.stderr = output_file
            print "Started a run on %s" % (time.asctime())
        else:
            print "Invalid Debug Flag"
            print "   -p : Enable printing to a text file"

    os.environ['SDL_VIDEO_CENTERED'] = '1'

    pygame.init()
    tilesize = 35
    size_x = 24
    size_y = 18
    size_window = (size_x, size_y)
    screen_size = (tilesize * size_x, tilesize * size_y)
    screen = pygame.display.set_mode(screen_size, 0, 32)

    # Engine Intialization
    #   Initialize player units catalog
    #   Initialize trait catalog
    #   Initialize the spell catalog
    #   Initialize unit animations catalog
    engine = Engine(screen, tilesize, size_window)
#    engine.player_units_catalog = xmlreader.get_player_unit_catalog()
#    engine.trait_catalog = xmlreader.get_trait_catalog()
#    engine.trait_learning_catalog = xmlreader.get_trait_learning_catalog()
#    for unit in
#    engine.spell_catalog = xmlreader.SpellCatalog()
#    engine.unit_anim_catalog = xmlreader.UnitAnimCatalog()
#    engine.enemynpc_units_catalog = xmlreader.EnemyNPCTemplatesCatalog()
#    engine.terrain_types, engine.terrain_data_by_symbol = xmlreader.get_terrain_data()
#    engine.layer_2_terrain_data = xmlreader.get_layer_2_data()
#    # Assigns character battle animations
#    for unit in engine.player_units_catalog.values():
#        if unit.animation_enable:
#            unit.anim_frames = engine.unit_anim_catalog[unit.anim_id_string]

    ####################################################
    # Initialization of the world map
    ####################################################
    region_list, region_paths_list, engine.region_backgrounds, engine.active_location_images, engine.inactive_location_images, engine.hidden_location_images = xmlreader.get_world_map(engine)
    wm = Worldmap(engine, region_list, region_paths_list)


    ##################################
    # Unit starting units initialization
    ##################################
    xmlreader.initialize_units(engine, 'initialize.xml')

    ##################################
    # Get Important Engine data
    ##################################
    mission_list = mission_catalog.get_catalog()
    engine.add_event_master(mission_list)
    engine.landmark_catalog = xmlreader.get_landmark_data()
    engine.hint_list = xmlreader.get_hint_list()
    engine.news_reports_list = xmlreader.get_news_reports()
    engine.treasure_catalog = xmlreader.TreasureCatalog()
    engine.music_catalog = xmlreader.get_music()
    engine.trading_catalog = xmlreader.TradingCatalog()
    engine.spell_recipes_catalog = xmlreader.get_spell_recipes()
    engine.portrait_catalog = xmlreader.get_portrait_catalog()
    engine.emotion_bubbles, engine.effect_animations = xmlreader.get_effects_catalog()

    ##################################
    # OTHER CUSTOM SETTINGS GO HERE
    ##################################

    engine.game_version = "0.9.0"

    # Debug Flags
    engine.enable_prologue = True
    engine.single_turn_win = False
    engine.enable_splash = False
    engine.enable_wm_tutorial = False
    engine.unlock_wm = False
    engine.unlock_shops = False

    ############################
    # Main Program
    ###########################
    pygame.display.set_caption("Story of a Lost Sky v%s" % engine.game_version)
    engine.title_screen()
    wm.navigate_loop()