コード例 #1
0
ファイル: survival.py プロジェクト: flags/Reactor-3
def manage_inventory(life):
	if manage_hands(life):
		return False
	
	for weapon_uid in combat.get_equipped_weapons(life):
		if not combat.weapon_is_working(life, weapon_uid):
			if combat.weapon_is_in_preferred_working_condition(life, weapon_uid):
				if not len(lfe.find_action(life,matches=[{'action': 'refillammo'}])):
					combat.reload_weapon(life, weapon_uid)
				
					return True
	
	_item_to_wear = {'score': 0, 'item_uid': None}
	_item_to_equip = {'score': 0, 'item_uid': None}
		
	for item in [lfe.get_inventory_item(life, item) for item in lfe.get_all_unequipped_items(life)]:
		judgement.judge_item(life, item['uid'])
		_known_item = brain.get_remembered_item(life, item['uid'])
		
		if _known_item['score']:
			if lfe.can_wear_item(life, item['uid']):
				if _known_item['score'] > _item_to_wear['score']:
					_item_to_wear['score'] = _known_item['score']
					_item_to_wear['item_uid'] = item['uid']
			else:
				if rawparse.raw_has_section(life, 'items') and rawparse.raw_section_has_identifier(life, 'items', item['type']):
					_action = lfe.execute_raw(life, 'items', item['type'])
					
					if item['type'] == 'gun' and lfe.get_all_equipped_items(life, matches=[{'type': 'gun'}]):
						continue
					
					if _action == 'equip':
						if _known_item['score'] > _item_to_equip['score']:
							_item_to_equip['score'] = _known_item['score']
							_item_to_equip['item_uid'] = item['uid']
	
	_item = None
	if _item_to_wear['score'] > _item_to_equip['score']:
		_item = _item_to_wear['item_uid']
	elif _item_to_equip['item_uid']:
		_item = _item_to_equip['item_uid']
	
	if _item:
		_equip_action = {'action': 'equipitem', 'item': _item}
		
		if len(lfe.find_action(life, matches=[_equip_action])):
			return False
		
		lfe.add_action(life,
			_equip_action,
			401,
			delay=lfe.get_item_access_time(life, _item))
		
		return False
	
	return True
コード例 #2
0
ファイル: memory.py プロジェクト: athros/Reactor-3
def reflect(life):
	while life['unchecked_memories']:
		_memory = lfe.get_memory_via_id(life, life['unchecked_memories'].pop())
		
		if not rawparse.raw_section_has_identifier(life, 'memory', _memory['text']):
			continue
		
		_return_value = lfe.execute_raw(life, 'memory', _memory['text'])
		
		if _return_value == 'investigate_chunk':
			judgement.judge_chunk(life, _memory['chunk_key'], investigate=True)
コード例 #3
0
ファイル: survival.py プロジェクト: hovatterz/Reactor-3
def manage_inventory(life):
    if manage_hands(life):
        return False

    for weapon_uid in combat.get_equipped_weapons(life):
        if not combat.weapon_is_working(life, weapon_uid):
            if combat.weapon_is_in_preferred_working_condition(life, weapon_uid):
                combat.reload_weapon(life, weapon_uid)
                return True

    _item_to_wear = {"score": 0, "item_uid": None}
    _item_to_equip = {"score": 0, "item_uid": None}

    for item in [lfe.get_inventory_item(life, item) for item in lfe.get_all_unequipped_items(life)]:
        judgement.judge_item(life, item["uid"])
        _known_item = brain.get_remembered_item(life, item["uid"])

        if _known_item["score"]:
            if lfe.can_wear_item(life, item["uid"]):
                if _known_item["score"] > _item_to_wear["score"]:
                    _item_to_wear["score"] = _known_item["score"]
                    _item_to_wear["item_uid"] = item["uid"]
            else:
                if rawparse.raw_has_section(life, "items") and rawparse.raw_section_has_identifier(
                    life, "items", item["type"]
                ):
                    _action = lfe.execute_raw(life, "items", item["type"])

                    if _action == "equip":
                        if _known_item["score"] > _item_to_equip["score"]:
                            _item_to_equip["score"] = _known_item["score"]
                            _item_to_equip["item_uid"] = item["uid"]

    _item = None
    if _item_to_wear["score"] > _item_to_equip["score"]:
        _item = _item_to_wear["item_uid"]
    elif _item_to_equip["item_uid"]:
        _item = _item_to_equip["item_uid"]

    if _item:
        _equip_action = {"action": "equipitem", "item": _item}

        if len(lfe.find_action(life, matches=[_equip_action])):
            return False

        lfe.add_action(life, _equip_action, 401, delay=lfe.get_item_access_time(life, _item))

        return True

    return False
コード例 #4
0
ファイル: survival.py プロジェクト: penny64/Reactor-3
def manage_inventory(life):
    if manage_hands(life):
        return False

    for weapon_uid in combat.get_equipped_weapons(life):
        if not combat.weapon_is_working(life, weapon_uid):
            if combat.weapon_is_in_preferred_working_condition(
                    life, weapon_uid):
                if not len(
                        lfe.find_action(life,
                                        matches=[{
                                            'action': 'refillammo'
                                        }])):
                    combat.reload_weapon(life, weapon_uid)

                    return True

    _item_to_wear = {'score': 0, 'item_uid': None}
    _item_to_equip = {'score': 0, 'item_uid': None}

    for item in [
            lfe.get_inventory_item(life, item)
            for item in lfe.get_all_unequipped_items(life)
    ]:
        judgement.judge_item(life, item['uid'])
        _known_item = brain.get_remembered_item(life, item['uid'])

        if _known_item['score']:
            if lfe.can_wear_item(life, item['uid']):
                if _known_item['score'] > _item_to_wear['score']:
                    _item_to_wear['score'] = _known_item['score']
                    _item_to_wear['item_uid'] = item['uid']
            else:
                if rawparse.raw_has_section(
                        life, 'items') and rawparse.raw_section_has_identifier(
                            life, 'items', item['type']):
                    _action = lfe.execute_raw(life, 'items', item['type'])

                    if item['type'] == 'gun' and lfe.get_all_equipped_items(
                            life, matches=[{
                                'type': 'gun'
                            }]):
                        continue

                    if _action == 'equip':
                        if _known_item['score'] > _item_to_equip['score']:
                            _item_to_equip['score'] = _known_item['score']
                            _item_to_equip['item_uid'] = item['uid']

    _item = None
    if _item_to_wear['score'] > _item_to_equip['score']:
        _item = _item_to_wear['item_uid']
    elif _item_to_equip['item_uid']:
        _item = _item_to_equip['item_uid']

    if _item:
        _equip_action = {'action': 'equipitem', 'item': _item}

        if len(lfe.find_action(life, matches=[_equip_action])):
            return False

        lfe.add_action(life,
                       _equip_action,
                       401,
                       delay=lfe.get_item_access_time(life, _item))

        return False

    return True