Example #1
0
def process(life):
    for need in life['needs'].values():
        if need['type'] == 'item':
            _has_items = []
            _potential_items = []

            for item in brain.get_matching_remembered_items(life,
                                                            need['match'],
                                                            no_owner=True):
                if brain.get_item_flag(life, ITEMS[item], 'ignore'):
                    continue

                _potential_items.append(item)

            for item in lfe.get_all_inventory_items(life,
                                                    matches=[need['match']]):
                _has_items.append(item['uid'])

            if len(_has_items) >= _get_need_amount(life, need):
                need['meet_with'] = _has_items
            elif _potential_items:
                need['could_meet_with'] = _potential_items
            else:
                need['meet_with'] = []
                need['could_meet_with'] = []
Example #2
0
def find_known_items(life, matches={}, only_visible=True):
	_match = []
	
	_could_meet_with = []
	for need in brain.retrieve_from_memory(life, 'needs_to_meet'):
		_could_meet_with.extend(need['could_meet_with'])
	
	for item_uid in brain.get_matching_remembered_items(life, matches, no_owner=True, only_visible=only_visible):
		#TODO: Offload?
		_item = ITEMS[item_uid]
		
		_match.append(item_uid)
	
	return _match
Example #3
0
def find_known_items(life, matches={}, only_visible=True):
    _match = []

    _could_meet_with = []
    for need in brain.retrieve_from_memory(life, 'needs_to_meet'):
        _could_meet_with.extend(need['could_meet_with'])

    for item_uid in brain.get_matching_remembered_items(
            life, matches, no_owner=True, only_visible=only_visible):
        #TODO: Offload?
        _item = ITEMS[item_uid]

        _match.append(item_uid)

    return _match
Example #4
0
def process(life):
    for need in life["needs"].values():
        if need["type"] == "item":
            _has_items = []
            _potential_items = []

            for item in brain.get_matching_remembered_items(life, need["match"], no_owner=True):
                if brain.get_item_flag(life, ITEMS[item], "ignore"):
                    continue

                _potential_items.append(item)

            for item in lfe.get_all_inventory_items(life, matches=[need["match"]]):
                _has_items.append(item["uid"])

            if len(_has_items) >= _get_need_amount(life, need):
                need["meet_with"] = _has_items
            elif _potential_items:
                need["could_meet_with"] = _potential_items
            else:
                need["meet_with"] = []
                need["could_meet_with"] = []
Example #5
0
def process(life):
	for need in life['needs'].values():
		if need['type'] == 'item':
			_has_items = []
			_potential_items = []
			
			for item in brain.get_matching_remembered_items(life, need['match'], no_owner=True):
				if brain.get_item_flag(life, ITEMS[item], 'ignore'):
					continue
				
				_potential_items.append(item)
				
			for item in lfe.get_all_inventory_items(life, matches=[need['match']]):
				_has_items.append(item['uid'])
			
			if len(_has_items) >= _get_need_amount(life, need):
				need['meet_with'] = _has_items
			elif _potential_items:
				need['could_meet_with'] = _potential_items
			else:
				need['meet_with'] = []
				need['could_meet_with'] = []