<s> """<STR_LIT>""" <EOL> import logging <EOL> logger = logging . getLogger ( ) <EOL> logger . setLevel ( logging . DEBUG ) <EOL> console_formatter = logging . Formatter ( '<STR_LIT>' , datefmt = '<STR_LIT>' ) <EOL> ch = logging . StreamHandler ( ) <EOL> ch . setFormatter ( console_formatter ) <EOL> logger . addHandler ( ch ) <EOL> from globals import * <EOL> from inputs import * <EOL> from player import * <EOL> import libtcodpy as tcod <EOL> import render_fast_los <EOL> import render_map <EOL> import graphics as gfx <EOL> import traceback <EOL> import cProfile <EOL> import maputils <EOL> import worldgen <EOL> import mainmenu <EOL> import language <EOL> import profiles <EOL> import missions <EOL> import threads <EOL> import network <EOL> import drawing <EOL> import weapons <EOL> import effects <EOL> import numbers <EOL> import dialog <EOL> import random <EOL> import numpy <EOL> import tiles <EOL> import menus <EOL> import logic <EOL> import locks <EOL> import items <EOL> import life <EOL> import time <EOL> import maps <EOL> import fov <EOL> import smp <EOL> import sys <EOL> CYTHON_ENABLED = True <EOL> def move_camera ( pos , scroll = False ) : <EOL> _orig_pos = CAMERA_POS [ : ] <EOL> if SETTINGS [ '<STR_LIT>' ] and SETTINGS [ '<STR_LIT>' ] == SETTINGS [ '<STR_LIT>' ] and locks . is_locked ( '<STR_LIT>' ) : <EOL> _life = LIFE [ SETTINGS [ '<STR_LIT>' ] ] <EOL> _top_left = MAP_SIZE [ : ] <EOL> _bot_right = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> _seen = False <EOL> for life_id in LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] : <EOL> if LIFE [ life_id ] [ '<STR_LIT>' ] : <EOL> continue <EOL> if brain . knows_alife_by_id ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] , life_id ) [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> continue <EOL> _seen = True <EOL> if LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] < _top_left [ <NUM_LIT:0> ] : <EOL> _top_left [ <NUM_LIT:0> ] = LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> if LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] < _top_left [ <NUM_LIT:1> ] : <EOL> _top_left [ <NUM_LIT:1> ] = LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] <EOL> if LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] > _bot_right [ <NUM_LIT:0> ] : <EOL> _bot_right [ <NUM_LIT:0> ] = LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> if LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] > _bot_right [ <NUM_LIT:1> ] : <EOL> _bot_right [ <NUM_LIT:1> ] = LIFE [ life_id ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] <EOL> _target_pos = numbers . lerp_velocity ( _top_left , _bot_right , <NUM_LIT:0.5> ) <EOL> pos = numbers . lerp_velocity ( pos , _target_pos , <NUM_LIT> ) [ : <NUM_LIT:2> ] <EOL> pos . append ( <NUM_LIT:2> ) <EOL> brain . flag ( _life , '<STR_LIT>' , value = _target_pos [ : ] ) <EOL> brain . flag ( _life , '<STR_LIT>' , value = WORLD_INFO [ '<STR_LIT>' ] ) <EOL> _future_time = brain . get_flag ( _life , '<STR_LIT>' ) <EOL> if not _future_time or WORLD_INFO [ '<STR_LIT>' ] > _future_time : <EOL> brain . flag ( _life , '<STR_LIT>' , value = WORLD_INFO [ '<STR_LIT>' ] + <NUM_LIT:30> ) <EOL> if brain . get_flag ( _life , '<STR_LIT>' ) : <EOL> if _seen : <EOL> _st = WORLD_INFO [ '<STR_LIT>' ] - ( brain . get_flag ( _life , '<STR_LIT>' ) - <NUM_LIT:30> ) <EOL> _et = brain . get_flag ( _life , '<STR_LIT>' ) - ( brain . get_flag ( _life , '<STR_LIT>' ) - <NUM_LIT:30> ) <EOL> _lerp = <NUM_LIT:1> - numbers . clip ( _st / float ( _et ) , <NUM_LIT:0> , <NUM_LIT:1.0> ) <EOL> pos = numbers . lerp_velocity ( pos , brain . get_flag ( _life , '<STR_LIT>' ) , _lerp ) [ : <NUM_LIT:2> ] <EOL> pos . append ( <NUM_LIT:2> ) <EOL> else : <EOL> if WORLD_INFO [ '<STR_LIT>' ] - brain . get_flag ( _life , '<STR_LIT>' ) <= <NUM_LIT:20> : <EOL> _lerp = <NUM_LIT> - numbers . clip ( ( WORLD_INFO [ '<STR_LIT>' ] - brain . get_flag ( _life , '<STR_LIT>' ) ) / <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> ) <EOL> pos = numbers . lerp_velocity ( pos , brain . get_flag ( _life , '<STR_LIT>' ) , _lerp ) [ : <NUM_LIT:2> ] <EOL> pos . append ( <NUM_LIT:2> ) <EOL> else : <EOL> brain . unflag ( _life , '<STR_LIT>' ) <EOL> brain . unflag ( _life , '<STR_LIT>' ) <EOL> CAMERA_POS [ <NUM_LIT:0> ] = int ( round ( numbers . clip ( pos [ <NUM_LIT:0> ] - ( MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> ) , <NUM_LIT:0> , MAP_SIZE [ <NUM_LIT:0> ] - MAP_WINDOW_SIZE [ <NUM_LIT:0> ] ) ) ) <EOL> CAMERA_POS [ <NUM_LIT:1> ] = int ( round ( numbers . clip ( pos [ <NUM_LIT:1> ] - ( MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> ) , <NUM_LIT:0> , MAP_SIZE [ <NUM_LIT:1> ] - MAP_WINDOW_SIZE [ <NUM_LIT:1> ] ) ) ) <EOL> CAMERA_POS [ <NUM_LIT:2> ] = int ( round ( pos [ <NUM_LIT:2> ] ) ) <EOL> if not _orig_pos == CAMERA_POS : <EOL> gfx . refresh_view ( '<STR_LIT>' ) <EOL> elif SETTINGS [ '<STR_LIT>' ] and not alife . brain . get_flag ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] , '<STR_LIT>' ) == pos : <EOL> gfx . refresh_view ( '<STR_LIT>' ) <EOL> if SETTINGS [ '<STR_LIT>' ] : <EOL> alife . brain . flag ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] , '<STR_LIT>' , value = pos [ : ] ) <EOL> def draw_targeting ( ) : <EOL> if SETTINGS [ '<STR_LIT>' ] and not SETTINGS [ '<STR_LIT>' ] == SETTINGS [ '<STR_LIT>' ] and LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT:path>' ] : <EOL> SELECTED_TILES [ <NUM_LIT:0> ] = [ ( p [ <NUM_LIT:0> ] , p [ <NUM_LIT:1> ] , <NUM_LIT:2> ) for p in LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT:path>' ] ] <EOL> if LIFE [ SETTINGS [ '<STR_LIT>' ] ] and LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] : <EOL> SELECTED_TILES [ <NUM_LIT:0> ] = [ ] <EOL> for pos in drawing . diag_line ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] , LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] ) : <EOL> SELECTED_TILES [ <NUM_LIT:0> ] . append ( ( pos [ <NUM_LIT:0> ] , pos [ <NUM_LIT:1> ] , LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] [ <NUM_LIT:2> ] ) ) <EOL> def death ( ) : <EOL> _player = LIFE [ SETTINGS [ '<STR_LIT>' ] ] <EOL> maps . reset_lights ( ) <EOL> FADE_TO_WHITE [ <NUM_LIT:0> ] += <NUM_LIT> <EOL> _time_since_death = FADE_TO_WHITE [ <NUM_LIT:0> ] <EOL> _time_alive = round ( numbers . clip ( ( _player [ '<STR_LIT>' ] - _player [ '<STR_LIT>' ] ) / float ( WORLD_INFO [ '<STR_LIT>' ] ) , <NUM_LIT:0.1> , <NUM_LIT> ) , <NUM_LIT:2> ) <EOL> _string = '<STR_LIT>' <EOL> _sub_string = _player [ '<STR_LIT>' ] <EOL> _col = int ( round ( <NUM_LIT:255> * numbers . clip ( ( _time_since_death / <NUM_LIT> ) - random . uniform ( <NUM_LIT:0> , <NUM_LIT> ) , <NUM_LIT:0> , <NUM_LIT:1> ) ) ) <EOL> if _time_alive == <NUM_LIT:1> : <EOL> _sub_sub_string = '<STR_LIT>' <EOL> else : <EOL> if _time_alive < <NUM_LIT:1> : <EOL> _sub_sub_string = '<STR_LIT>' <EOL> else : <EOL> _sub_sub_string = '<STR_LIT>' % ( _time_alive ) <EOL> gfx . fade_to_black ( <NUM_LIT:1> ) <EOL> gfx . blit_string ( ( MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> ) - len ( _string ) / <NUM_LIT:2> , <EOL> MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> , <EOL> _string , <EOL> '<STR_LIT>' , <EOL> fore_color = tcod . Color ( _col , <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> back_color = tcod . Color ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> gfx . blit_string ( ( MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> ) - len ( _sub_string ) / <NUM_LIT:2> , <EOL> ( MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> ) + <NUM_LIT:2> , <EOL> _sub_string , <EOL> '<STR_LIT>' , <EOL> fore_color = tcod . Color ( int ( round ( _col * <NUM_LIT> ) ) , int ( round ( _col * <NUM_LIT> ) ) , int ( round ( _col * <NUM_LIT> ) ) ) , <EOL> back_color = tcod . Color ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> gfx . blit_string ( ( MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> ) - len ( _sub_sub_string ) / <NUM_LIT:2> , <EOL> ( MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> ) + <NUM_LIT:4> , <EOL> _sub_sub_string , <EOL> '<STR_LIT>' , <EOL> fore_color = tcod . Color ( int ( round ( _col * <NUM_LIT> ) ) , int ( round ( _col * <NUM_LIT> ) ) , int ( round ( _col * <NUM_LIT> ) ) ) , <EOL> back_color = tcod . Color ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> if _time_since_death >= <NUM_LIT> : <EOL> worldgen . save_world ( ) <EOL> worldgen . reset_world ( ) <EOL> gfx . clear_scene ( ) <EOL> SETTINGS [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> return False <EOL> return True <EOL> def main ( ) : <EOL> _player_moved = False <EOL> _refresh_map = False <EOL> get_input ( ) <EOL> handle_input ( ) <EOL> if not LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] : <EOL> if LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] : <EOL> gfx . fade_to_black ( <NUM_LIT:255> ) <EOL> gfx . start_of_frame ( ) <EOL> gfx . end_of_frame ( ) <EOL> while LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] : <EOL> _played_moved = True <EOL> _refresh_map = True <EOL> gfx . title ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] ) <EOL> logic . tick_all_objects ( ignore_tickrate = True , ignore_pause = True ) <EOL> if LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] : <EOL> break <EOL> else : <EOL> _player_moved = True <EOL> if _refresh_map : <EOL> gfx . refresh_view ( '<STR_LIT>' ) <EOL> if not _player_moved : <EOL> if logic . tick_all_objects ( ignore_tickrate = True ) : <EOL> _player_moved = True <EOL> draw_targeting ( ) <EOL> move_camera ( SETTINGS [ '<STR_LIT>' ] ) <EOL> if SELECTED_TILES [ <NUM_LIT:0> ] : <EOL> gfx . refresh_view ( '<STR_LIT>' ) <EOL> if not SETTINGS [ '<STR_LIT>' ] == SETTINGS [ '<STR_LIT>' ] [ : ] : <EOL> if EVENTS or MENUS : <EOL> _visible_chunks = sight . scan_surroundings ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] , judge = False , get_chunks = True ) <EOL> alife . brain . flag ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] , '<STR_LIT>' , value = _visible_chunks ) <EOL> _cam_x = numbers . clip ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] - MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> , <NUM_LIT:0> , MAP_SIZE [ <NUM_LIT:0> ] - MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> ) <EOL> _cam_y = numbers . clip ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] - MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> , <NUM_LIT:0> , MAP_SIZE [ <NUM_LIT:1> ] - MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> ) <EOL> else : <EOL> _visible_chunks = sight . scan_surroundings ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] , judge = False , get_chunks = True ) <EOL> alife . brain . flag ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] , '<STR_LIT>' , value = _visible_chunks ) <EOL> SETTINGS [ '<STR_LIT>' ] = SETTINGS [ '<STR_LIT>' ] [ : ] <EOL> _cam_x = numbers . clip ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] - MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> , <NUM_LIT:0> , MAP_SIZE [ <NUM_LIT:0> ] - MAP_WINDOW_SIZE [ <NUM_LIT:0> ] / <NUM_LIT:2> ) <EOL> _cam_y = numbers . clip ( LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] - MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> , <NUM_LIT:0> , MAP_SIZE [ <NUM_LIT:1> ] - MAP_WINDOW_SIZE [ <NUM_LIT:1> ] / <NUM_LIT:2> ) <EOL> maps . render_lights ( ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> render_map . render_map ( WORLD_INFO [ '<STR_LIT>' ] , force_camera_pos = ( _cam_x , _cam_y , <NUM_LIT:2> ) ) <EOL> else : <EOL> render_map . render_map ( WORLD_INFO [ '<STR_LIT>' ] , los = LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] , force_camera_pos = ( _cam_x , _cam_y , <NUM_LIT:2> ) ) <EOL> items . draw_items ( ) <EOL> life . draw_life ( ) <EOL> if LIFE [ SETTINGS [ '<STR_LIT>' ] ] [ '<STR_LIT>' ] and not EVENTS : <EOL> if not death ( ) : <EOL> return False <EOL> if SETTINGS [ '<STR_LIT>' ] and SETTINGS [ '<STR_LIT>' ] : <EOL> life . draw_life_info ( ) <EOL> gfx . draw_message_box ( ) <EOL> menus . align_menus ( ) <EOL> menus . draw_menus ( ) <EOL> gfx . draw_status_line ( ) <EOL> gfx . draw_console ( ) <EOL> gfx . start_of_frame ( ) <EOL> gfx . end_of_frame ( ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> print tcod . sys_get_fps ( ) <EOL> if ( SETTINGS [ '<STR_LIT>' ] and _player_moved and not EVENTS and not MENUS ) or '<STR_LIT>' in sys . argv : <EOL> gfx . screenshot ( ) <EOL> if '<STR_LIT>' in sys . argv : <EOL> SETTINGS [ '<STR_LIT>' ] = False <EOL> def loop ( ) : <EOL> while SETTINGS [ '<STR_LIT>' ] : <EOL> if SETTINGS [ '<STR_LIT>' ] == <NUM_LIT:1> : <EOL> if not MENUS : <EOL> mainmenu . switch_to_main_menu ( ) <EOL> get_input ( ) <EOL> handle_input ( ) <EOL> mainmenu . draw_main_menu ( ) <EOL> elif SETTINGS [ '<STR_LIT>' ] == <NUM_LIT:2> : <EOL> main ( ) <EOL> elif SETTINGS [ '<STR_LIT>' ] == <NUM_LIT:3> : <EOL> mainmenu . draw_intro ( ) <EOL> worldgen . cleanup ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> profiles . version_check ( ) <EOL> try : <EOL> import render_map <EOL> import render_los <EOL> if render_map . VERSION == MAP_RENDER_VERSION : <EOL> CYTHON_ENABLED = True <EOL> else : <EOL> logging . error ( '<STR_LIT>' ) <EOL> logging . error ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> except ImportError , e : <EOL> CYTHON_ENABLED = False <EOL> logging . warning ( '<STR_LIT>' % e ) <EOL> logging . warning ( '<STR_LIT>' ) <EOL> logging . warning ( '<STR_LIT>' ) <EOL> logging . info ( WINDOW_TITLE ) <EOL> gfx . log ( WINDOW_TITLE ) <EOL> if os . path . exists ( '<STR_LIT>' ) : <EOL> with open ( '<STR_LIT>' , '<STR_LIT:r>' ) as ver : <EOL> logging . info ( '<STR_LIT>' % ver . readline ( ) . strip ( ) ) <EOL> logging . debug ( '<STR_LIT>' % tcod . sys_get_renderer ( ) ) <EOL> tiles . create_all_tiles ( ) <EOL> language . load_strings ( ) <EOL> missions . load_all_missions ( ) <EOL> alife . rawparse . create_function_map ( ) <EOL> locks . create_lock ( '<STR_LIT>' , locked = True ) <EOL> gfx . init_libtcod ( ) <EOL> threads . init ( ) <EOL> SETTINGS [ '<STR_LIT>' ] = True <EOL> SETTINGS [ '<STR_LIT>' ] = True <EOL> life . initiate_life ( '<STR_LIT>' ) <EOL> life . initiate_life ( '<STR_LIT>' ) <EOL> life . initiate_life ( '<STR_LIT>' ) <EOL> items . initiate_all_items ( ) <EOL> SETTINGS [ '<STR_LIT>' ] = <NUM_LIT:3> <EOL> if '<STR_LIT>' in sys . argv : <EOL> SETTINGS [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> elif '<STR_LIT>' in sys . argv : <EOL> for world in profiles . get_worlds ( ) : <EOL> worldgen . load_world ( world ) <EOL> break <EOL> if SETTINGS [ '<STR_LIT>' ] : <EOL> SETTINGS [ '<STR_LIT>' ] = <NUM_LIT:2> <EOL> gfx . prepare_map_views ( ) <EOL> else : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> SETTINGS [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> if '<STR_LIT>' in sys . argv : <EOL> _debug_host = network . DebugHost ( ) <EOL> _debug_host . start ( ) <EOL> WORLD_INFO [ '<STR_LIT>' ] = _debug_host <EOL> if '<STR_LIT>' in sys . argv : <EOL> logging . info ( '<STR_LIT>' ) <EOL> cProfile . run ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> sys . exit ( ) <EOL> try : <EOL> loop ( ) <EOL> except KeyboardInterrupt : <EOL> SETTINGS [ '<STR_LIT>' ] = False <EOL> except Exception , e : <EOL> traceback . print_exc ( file = sys . stdout ) <EOL> SETTINGS [ '<STR_LIT>' ] = False <EOL> if '<STR_LIT>' in WORLD_INFO : <EOL> WORLD_INFO [ '<STR_LIT>' ] . quit ( ) <EOL> if '<STR_LIT>' in WORLD_INFO : <EOL> WORLD_INFO [ '<STR_LIT>' ] . quit ( ) </s>
