Ejemplo n.º 1
0
def get_known_group(life, life_id):
    _target = brain.knows_alife_by_id(life, life_id)
    _dialog_id = lfe.has_dialog_with(life, life_id)

    if 'player' in life:
        _menu_items = []

        for group_id in life['known_groups']:
            if _target['group'] == group_id:
                continue

            _menu_items.append(
                menus.create_item('single',
                                  group_id,
                                  None,
                                  group=group_id,
                                  dialog_id=_dialog_id))

        if not _menu_items:
            gfx.message('You don\'t know of any other groups.')
            return False

        _menu = menus.create_menu(menu=_menu_items,
                                  title='Inform of Group',
                                  format_str='$k',
                                  on_select=confirm_inform_of_group,
                                  close_on_select=True)
        menus.activate_menu(_menu)
    else:
        raise Exception('Dead end.')
Ejemplo n.º 2
0
def create_maps_menu(build_test):
    _menu_items = []

    if build_test:
        for building_type in mapgen.BUILDINGS:
            _menu_items.append(menus.create_item('single', building_type,
                                                 None))

        _m = menus.create_menu(title='Buildings',
                               menu=_menu_items,
                               padding=(1, 1),
                               position=(0, 0),
                               on_select=building_type_selected,
                               format_str='$k')
    else:
        for map_file in profiles.get_maps():
            _menu_items.append(menus.create_item('single', map_file, None))

        if not _menu_items:
            logging.error('No maps found.')
            sys.exit(1)

        _m = menus.create_menu(title='Maps',
                               menu=_menu_items,
                               padding=(1, 1),
                               position=(0, 0),
                               on_select=menu_item_selected,
                               format_str='$k')

    menus.activate_menu(_m)
    menu_align()
Ejemplo n.º 3
0
def switch_to_main_menu():
    while MENUS:
        MENUS.pop(0)

    _menu_items = []
    _menu_items.append(
        menus.create_item('single', 'Start', None, enabled=WORLD_INFO['id']))
    _menu_items.append(
        menus.create_item('single',
                          'Select World',
                          None,
                          enabled=profiles.get_worlds()))
    _menu_items.append(menus.create_item('single', 'World Generation', None))
    _menu_items.append(menus.create_item('single', 'Quit', None))

    _i = menus.create_menu(title='Reactor 3',
                           menu=_menu_items,
                           padding=(1, 1),
                           position=(0, 0),
                           format_str='$k',
                           on_select=main_menu_select,
                           on_change=None,
                           on_close=clear)

    menus.activate_menu(_i)
    clear()
Ejemplo n.º 4
0
def create_maps_menu(build_test):
	_menu_items = []
	
	if build_test:
		for building_type in mapgen.BUILDINGS:
			_menu_items.append(menus.create_item('single', building_type, None))
		
		_m = menus.create_menu(title='Buildings',
			                  menu=_menu_items,
			                  padding=(1,1),
			                  position=(0, 0),
			                  on_select=building_type_selected,
			                  format_str='$k')
	else:
		for map_file in profiles.get_maps():
			_menu_items.append(menus.create_item('single', map_file, None))
		
		if not _menu_items:
			logging.error('No maps found.')
			sys.exit(1)
		
		_m = menus.create_menu(title='Maps',
			                  menu=_menu_items,
			                  padding=(1,1),
			                  position=(0, 0),
			                  on_select=menu_item_selected,
			                  format_str='$k')
	
	menus.activate_menu(_m)
	menu_align()
Ejemplo n.º 5
0
def switch_to_start_game():
    while menus.delete_active_menu():
        continue

    _menu_items = []
    _menu_items.append(
        menus.create_item('single',
                          'Existing Character',
                          None,
                          enabled=SETTINGS['controlling']))
    _menu_items.append(menus.create_item('single', 'New Character', None))
    _menu_items.append(
        menus.create_item('single',
                          'New Character (Advanced)',
                          None,
                          enabled=False))
    _menu_items.append(menus.create_item('single', 'Back', None))

    _i = menus.create_menu(title='Scenario',
                           menu=_menu_items,
                           padding=(1, 1),
                           position=(0, 0),
                           format_str='$k',
                           on_select=start_menu_select,
                           on_change=None,
                           on_close=clear)

    menus.activate_menu(_i)
    clear()
Ejemplo n.º 6
0
def switch_to_spawn_point():
    #TODO: List of camps
    _menu_items = []
    _menu_items.append(
        menus.create_item('single', 'Random', 'Randomized story'))
    _menu_items.append(
        menus.create_item('single',
                          'Zone Entry Point',
                          'Near Rookie camp',
                          enabled=False))
    _menu_items.append(
        menus.create_item('single',
                          'Chase',
                          'You are being trailed!',
                          enabled=False))
    _menu_items.append(menus.create_item('single', 'Back', None))

    _i = menus.create_menu(title='Spawn Point',
                           menu=_menu_items,
                           padding=(1, 1),
                           position=(0, 0),
                           format_str='$k ($v)',
                           on_select=spawn_menu_select,
                           on_change=None,
                           on_close=clear)

    menus.activate_menu(_i)
    clear()
Ejemplo n.º 7
0
def get_known_group(life, life_id):
	_target = brain.knows_alife_by_id(life, life_id)
	_dialog_id = lfe.has_dialog_with(life, life_id)
	
	if 'player' in life:
		_menu_items = []
		
		for group_id in life['known_groups']:
			if _target['group'] == group_id:
				continue
			
			_menu_items.append(menus.create_item('single', group_id, None, group=group_id, dialog_id=_dialog_id))
		
		if not _menu_items:
			gfx.message('You don\'t know of any other groups.')
			return False
		
		_menu = menus.create_menu(menu=_menu_items,
		                          title='Inform of Group',
		                          format_str='$k',
		                          on_select=confirm_inform_of_group,
		                          close_on_select=True)
		menus.activate_menu(_menu)
	else:
		raise Exception('Dead end.')
Ejemplo n.º 8
0
def get_target(life, dialog_id, gist):
    if 'player' in life:
        _targets = menus.create_target_list()

        _menu = menus.create_menu(menu=_targets,
                                  title='Select Target',
                                  format_str='$k',
                                  on_select=confirm_target,
                                  close_on_select=True)
        menus.activate_menu(_menu)
    else:
        dialog.get_dialog(dialog_id)['flags']['target'] = random.choice(
            judgement.get_threats(life))
        dialog.say_via_gist(life, dialog_id,
                            dialog.get_flag(dialog_id, 'NEXT_GIST'))
Ejemplo n.º 9
0
def get_target(life, dialog_id, gist):
	if 'player' in life:
		_targets = menus.create_target_list()
		
		_menu = menus.create_menu(menu=_targets,
		                          title='Select Target',
		                          format_str='$k',
		                          on_select=confirm_target,
		                          close_on_select=True)
		menus.activate_menu(_menu)
	else:
		dialog.get_dialog(dialog_id)['flags']['target'] = random.choice(judgement.get_threats(life))
		dialog.say_via_gist(life,
			                dialog_id,
			                dialog.get_flag(dialog_id, 'NEXT_GIST'))
Ejemplo n.º 10
0
def inform_of_group_members(life, life_id, group_id):
    if 'player' in life:
        _dialog_id = lfe.has_dialog_with(life, life_id)
        _menu_items = []

        for target_id in life['know']:
            if target_id == life['id'] or target_id == life_id:
                continue

            if groups.is_member(life, group_id, target_id):
                _colors = (tcod.green, tcod.white)
                _values = ['Member', 'Not Member']
            else:
                _colors = (tcod.red, tcod.white)
                _values = ['Not Member', 'Member']

            _menu_items.append(
                menus.create_item('list',
                                  ' '.join(LIFE[target_id]['name']),
                                  _values,
                                  group=group_id,
                                  target_id=target_id,
                                  members=_menu_items,
                                  color=_colors,
                                  dialog_id=_dialog_id))

        if not _menu_items:
            return False

        _menu = menus.create_menu(menu=_menu_items,
                                  title='Inform of Group Members',
                                  format_str='$k: $v',
                                  on_select=confirm_inform_of_group_members,
                                  close_on_select=True)
        menus.activate_menu(_menu)
    else:
        for target_id in groups.get_group(life, group_id)['members']:
            if life['id'] == target_id:
                continue

            memory.create_question(life,
                                   target_id,
                                   'group_list',
                                   group_id=group_id,
                                   group_list=groups.get_group(
                                       life, group_id)['members'])
Ejemplo n.º 11
0
def switch_to_select_world():
	_menu_items = []
	
	for world in profiles.get_worlds():
		_menu_items.append(menus.create_item('single', 'World %s' % world, None, world=world, enabled=(not world == WORLD_INFO['id'])))
	_menu_items.append(menus.create_item('single', 'Back', None))
	
	_i = menus.create_menu(title='Select World',
		menu=_menu_items,
		padding=(1,1),
		position=(0,0),
		format_str='$k',
		on_select=world_select_select,
		on_change=None,
		on_close=clear)
	
	menus.activate_menu(_i)
	clear()
Ejemplo n.º 12
0
def switch_to_spawn_point():
	#TODO: List of camps
	_menu_items = []
	_menu_items.append(menus.create_item('single', 'Zone Entry Point', 'Near Rookie camp'))
	_menu_items.append(menus.create_item('single', 'Chase', 'You are being trailed!'))
	_menu_items.append(menus.create_item('single', 'Back', None))
	
	_i = menus.create_menu(title='Spawn Point',
		menu=_menu_items,
		padding=(1,1),
		position=(0,0),
		format_str='$k ($v)',
		on_select=spawn_menu_select,
		on_change=None,
		on_close=clear)
	
	menus.activate_menu(_i)
	clear()
Ejemplo n.º 13
0
def switch_to_select_world():
	_menu_items = []
	
	for world in profiles.get_worlds():
		_menu_items.append(menus.create_item('single', 'World %s' % world, None, world=world, enabled=(not world == WORLD_INFO['id'])))
	_menu_items.append(menus.create_item('single', 'Back', None))
	
	_i = menus.create_menu(title='Select World',
		menu=_menu_items,
		padding=(1,1),
		position=(0,0),
		format_str='$k',
		on_select=world_select_select,
		on_change=None,
		on_close=clear)
	
	menus.activate_menu(_i)
	clear()
Ejemplo n.º 14
0
def switch_to_start_game():
	_menu_items = []
	_menu_items.append(menus.create_item('single', 'Existing Character', None, enabled=SETTINGS['controlling']))
	_menu_items.append(menus.create_item('single', 'New Character', None))
	_menu_items.append(menus.create_item('single', 'New Character (Advanced)', None, enabled=False))
	_menu_items.append(menus.create_item('single', 'Back', None))
	
	_i = menus.create_menu(title='Scenario',
		menu=_menu_items,
		padding=(1,1),
		position=(0,0),
		format_str='$k',
		on_select=start_menu_select,
		on_change=None,
		on_close=clear)
	
	menus.activate_menu(_i)
	clear()
Ejemplo n.º 15
0
def create_maps_menu():
	_menu_items = []
	
	for map_file in profiles.get_maps():
		_menu_items.append(menus.create_item('single', map_file, None))
	
	if not _menu_items:
		logging.error('No maps found.')
		sys.exit(1)
	
	_m = menus.create_menu(title='Maps',
		menu=_menu_items,
		padding=(1,1),
		position=(0, 0),
		on_select=menu_item_selected,
	    format_str='$k')
	
	menus.activate_menu(_m)
	menu_align()
Ejemplo n.º 16
0
def inform_of_group_members(life, life_id, group_id):
	if 'player' in life:
		_dialog_id = lfe.has_dialog_with(life, life_id)
		_menu_items = []
		
		for target_id in life['know']:
			if target_id == life['id'] or target_id == life_id:
				continue
			
			if groups.is_member(life, group_id, target_id):
				_colors = (tcod.green, tcod.white)
				_values = ['Member', 'Not Member']
			else:
				_colors = (tcod.red, tcod.white)
				_values = ['Not Member', 'Member']
			
			_menu_items.append(menus.create_item('list',
			                                     ' '.join(LIFE[target_id]['name']),
			                                     _values,
			                                     group=group_id,
			                                     target_id=target_id,
			                                     members=_menu_items,
			                                     color=_colors,
			                                     dialog_id=_dialog_id))
		
		if not _menu_items:
			return False
		
		_menu = menus.create_menu(menu=_menu_items,
		                          title='Inform of Group Members',
		                          format_str='$k: $v',
		                          on_select=confirm_inform_of_group_members,
		                          close_on_select=True)
		menus.activate_menu(_menu)
	else:
		for target_id in groups.get_group(life, group_id)['members']:
			if life['id'] == target_id:
				continue
			
			memory.create_question(life, target_id, 'group_list',
				                   group_id=group_id,
				                   group_list=groups.get_group(life, group_id)['members'])
Ejemplo n.º 17
0
def get_needs(life, dialog_id, gist):
	if 'player' in life:
		_items = []
		
		for item_type in ITEM_TYPES:
			_items.append(menus.create_item('list',
			                                item_type.title(),
			                                ['Skip', 'Need'],
			                                icon=ITEM_TYPES[item_type]['icon'],
			                                item_name=item_type))
		
		_menu = menus.create_menu(menu=_items,
		                          title='Select Items',
		                          format_str='[$i] $k: $v',
		                          padding=[1, 1],
		                          on_select=lambda entry: confirm_items(dialog_id, _items),
		                          close_on_select=True)
		menus.activate_menu(_menu)
	else:
		raise Exception('Dead end.')
Ejemplo n.º 18
0
def switch_to_world_gen():
    _maps = ['Generate Map']
    _maps.extend(profiles.get_maps())

    _menu_items = []
    _menu_items.append(menus.create_item('list', 'Map', _maps))
    _menu_items.append(
        menus.create_item(
            'list',
            'World Age',
            ['Day 0', '1 Week', '2 Weeks', '3 Weeks', '4 Weeks', '5 Weeks'],
            enabled=False))
    _menu_items.append(
        menus.create_item('list', 'Dynamic Spawns',
                          ['None', 'Sparse', 'Medium', 'Heavy']))
    _menu_items.append(
        menus.create_item('list',
                          'Wildlife Density',
                          ['None', 'Sparse', 'Medium', 'Heavy'],
                          enabled=False))
    _menu_items.append(
        menus.create_item('list',
                          'Artifacts', ['Few', 'Normal', 'Many'],
                          enabled=False))
    _menu_items.append(
        menus.create_item('list',
                          'Economy', ['Weak', 'Stable', 'Strong'],
                          enabled=False))
    _menu_items.append(menus.create_item('spacer', '-', None))
    _menu_items.append(menus.create_item('single', 'Generate', None))
    _menu_items.append(menus.create_item('single', 'Back', None))

    _i = menus.create_menu(title='World Generation',
                           menu=_menu_items,
                           padding=(1, 1),
                           position=(0, 0),
                           on_select=worldgen_menu_select,
                           on_close=clear)

    menus.activate_menu(_i)
    clear()
Ejemplo n.º 19
0
def get_needs(life, dialog_id, gist):
    if 'player' in life:
        _items = []

        for item_type in ITEM_TYPES:
            _items.append(
                menus.create_item('list',
                                  item_type.title(), ['Skip', 'Need'],
                                  icon=ITEM_TYPES[item_type]['icon'],
                                  item_name=item_type))

        _menu = menus.create_menu(
            menu=_items,
            title='Select Items',
            format_str='[$i] $k: $v',
            padding=[1, 1],
            on_select=lambda entry: confirm_items(dialog_id, _items),
            close_on_select=True)
        menus.activate_menu(_menu)
    else:
        raise Exception('Dead end.')
Ejemplo n.º 20
0
def switch_to_main_menu():
	while MENUS:
		MENUS.pop(0)
	
	_menu_items = []
	_menu_items.append(menus.create_item('single', 'Start', None, enabled=WORLD_INFO['id']))
	_menu_items.append(menus.create_item('single', 'Select World', None, enabled=profiles.get_worlds()))
	_menu_items.append(menus.create_item('single', 'World Generation', None))
	_menu_items.append(menus.create_item('single', 'Quit', None))
	
	_i = menus.create_menu(title='Reactor 3',
		menu=_menu_items,
		padding=(1,1),
		position=(0,0),
		format_str='$k',
		on_select=main_menu_select,
		on_change=None,
		on_close=clear)
	
	menus.activate_menu(_i)
	clear()
Ejemplo n.º 21
0
def switch_to_world_gen():
	_maps = ['Generate Map']
	_maps.extend(profiles.get_maps())
	
	_menu_items = []
	_menu_items.append(menus.create_item('list', 'Map', _maps))
	_menu_items.append(menus.create_item('list', 'World Age', ['Day 0','1 Week', '2 Weeks', '3 Weeks', '4 Weeks', '5 Weeks'], enabled=False))
	_menu_items.append(menus.create_item('list', 'Dynamic Spawns', ['None', 'Sparse', 'Medium', 'Heavy']))
	_menu_items.append(menus.create_item('list', 'Wildlife Density', ['None', 'Sparse', 'Medium', 'Heavy'], enabled=False))
	_menu_items.append(menus.create_item('list', 'Artifacts', ['Few', 'Normal', 'Many'], enabled=False))
	_menu_items.append(menus.create_item('list', 'Economy', ['Weak', 'Stable', 'Strong'], enabled=False))
	_menu_items.append(menus.create_item('spacer', '-', None))
	_menu_items.append(menus.create_item('single', 'Generate', None))
	_menu_items.append(menus.create_item('single', 'Back', None))
	
	_i = menus.create_menu(title='World Generation',
		menu=_menu_items,
		padding=(1,1),
		position=(0,0),
		on_select=worldgen_menu_select,
		on_close=clear)
	
	menus.activate_menu(_i)
	clear()
Ejemplo n.º 22
0
def examine_possible_moves(p, targets):
	#TODO: Cancel move?
	_moves = {}
	
	#if p['next_stance']['stance']:
	#	return False
	
	for _target in targets:
		target = LIFE[_target]
		if target == p:
			continue
		
		if sum([abs(i) for i in target['velocity']]):
			continue
		
		if 'player' in p:
			_moves[_target] = {'moves': [], 'counters': []}
		
		_next_stance = p['next_stance']['stance']
		_next_target_stance = target['next_stance']['stance']
		_incoming_attack = False
		
		#Target is attacking
		if target['stance'] in target['moves']:
			_incoming_attack = target['stance']
		elif _next_target_stance in target['moves']:
			_incoming_attack = _next_target_stance
		
		if _incoming_attack:
			if not _next_stance in p['moves'][_incoming_attack]['counters']:
				if 'player' in p:
					_moves[_target]['counters'].extend(p['moves'][_incoming_attack]['counters'])
				elif p['moves'][_incoming_attack]['counters']:
					assume_stance(p, random.choice(p['moves'][_incoming_attack]['counters']), towards=_target)
					return False
			
			elif p['stance'] in p['moves'][_incoming_attack]['counters']:
				return True
		
		if 'player' in p:
			_moves[_target]['moves'].extend(p['moves'].keys())
		else:
			assume_stance(p, random.choice(p['moves'].keys()), towards=_target)
			return True
		
		#if _next_stance and _next_stance in p['moves'] and not p['stance'] in p['moves'][_next_stance]['counters']:
		#	assume_stance(p, p['moves'][_next_stance]['counters'][0], towards=_target)
		#	return False
		#elif (not _next_stance or not target['stance'] in p['moves']):
		#	assume_stance(p, random.choice(p['moves'].keys()), towards=_target)
		#	return True
	
	if _moves and menus.get_menu_by_name('Advanced Movement')==-1 and not sum([abs(i) for i in p['velocity']]):
		_menu = []
		
		for target_id in _moves:
			if _moves[target_id]['moves']:
				_menu.append(menus.create_item('title', '%s (Attacks)' % ' '.join(LIFE[target_id]['name']), None))
				
				for move in _moves[target_id]['moves']:
					_menu.append(menus.create_item('single', move, None, move=move, target=target_id))
			
			if _moves[target_id]['counters']:
				_menu.append(menus.create_item('title', '%s (Counters)' % ' '.join(LIFE[target_id]['name']), None))
				
				for move in _moves[target_id]['counters']:
					_menu.append(menus.create_item('single', move, None, move=move, target=target_id))
		
		_m = menus.create_menu(menu=_menu,
		                       position=[1, 1],
		                       title='Advanced Movement',
		                       format_str='$k',
		                       on_select=lambda entry: assume_stance(LIFE[SETTINGS['controlling']],
		                                                             entry['move'],
		                                                             towards=entry['target']),
		                       close_on_select=True)
		menus.activate_menu(_m)
Ejemplo n.º 23
0
def examine_possible_moves(p, targets):
    #TODO: Cancel move?
    _moves = {}

    #if p['next_stance']['stance']:
    #	return False

    for _target in targets:
        target = LIFE[_target]
        if target == p:
            continue

        if sum([abs(i) for i in target['velocity']]):
            continue

        if 'player' in p:
            _moves[_target] = {'moves': [], 'counters': []}

        _next_stance = p['next_stance']['stance']
        _next_target_stance = target['next_stance']['stance']
        _incoming_attack = False

        #Target is attacking
        if target['stance'] in target['moves']:
            _incoming_attack = target['stance']
        elif _next_target_stance in target['moves']:
            _incoming_attack = _next_target_stance

        if _incoming_attack:
            if not _next_stance in p['moves'][_incoming_attack]['counters']:
                if 'player' in p:
                    _moves[_target]['counters'].extend(
                        p['moves'][_incoming_attack]['counters'])
                elif p['moves'][_incoming_attack]['counters']:
                    assume_stance(
                        p,
                        random.choice(
                            p['moves'][_incoming_attack]['counters']),
                        towards=_target)
                    return False

            elif p['stance'] in p['moves'][_incoming_attack]['counters']:
                return True

        if 'player' in p:
            _moves[_target]['moves'].extend(p['moves'].keys())
        else:
            assume_stance(p, random.choice(p['moves'].keys()), towards=_target)
            return True

        #if _next_stance and _next_stance in p['moves'] and not p['stance'] in p['moves'][_next_stance]['counters']:
        #	assume_stance(p, p['moves'][_next_stance]['counters'][0], towards=_target)
        #	return False
        #elif (not _next_stance or not target['stance'] in p['moves']):
        #	assume_stance(p, random.choice(p['moves'].keys()), towards=_target)
        #	return True

    if _moves and menus.get_menu_by_name(
            'Advanced Movement') == -1 and not sum(
                [abs(i) for i in p['velocity']]):
        _menu = []

        for target_id in _moves:
            if _moves[target_id]['moves']:
                _menu.append(
                    menus.create_item(
                        'title',
                        '%s (Attacks)' % ' '.join(LIFE[target_id]['name']),
                        None))

                for move in _moves[target_id]['moves']:
                    _menu.append(
                        menus.create_item('single',
                                          move,
                                          None,
                                          move=move,
                                          target=target_id))

            if _moves[target_id]['counters']:
                _menu.append(
                    menus.create_item(
                        'title',
                        '%s (Counters)' % ' '.join(LIFE[target_id]['name']),
                        None))

                for move in _moves[target_id]['counters']:
                    _menu.append(
                        menus.create_item('single',
                                          move,
                                          None,
                                          move=move,
                                          target=target_id))

        _m = menus.create_menu(menu=_menu,
                               position=[1, 1],
                               title='Advanced Movement',
                               format_str='$k',
                               on_select=lambda entry: assume_stance(
                                   LIFE[SETTINGS['controlling']],
                                   entry['move'],
                                   towards=entry['target']),
                               close_on_select=True)
        menus.activate_menu(_m)