Example #1
0
def judge_jobs(life):
	_tier = 0
	
	if life['task']:
		return life['job']
	
	_new_job = None
	_old_job = life['job']
	#life['job'] = None
		
	for job in [jobs.get_job(j) for j in life['jobs']]:
		if not jobs.get_free_tasks(job['id']):
			continue
		
		if not jobs.meets_job_requirements(life, job['id']):
			continue
		
		if life['group'] and job['gist'] == 'create_group':
			if not stats.wants_to_abandon_group(life, life['group']):
				jobs.reject_job(job['id'], life['id'])
				continue
			
			if life['group'] == jobs.get_flag(job['id'], 'group'):
				jobs.reject_job(job['id'], life['id'])
				continue
		
		if jobs.has_completed_or_rejected_job(life, job['id']):
			continue
		
		if job['tier'] >= _tier:
			#jobs.join_job(job['id'], life['id'])
			_new_job = job['id']
			_tier = job['tier']
	
	if not _old_job == _new_job:
		if _old_job:
			jobs.leave_job(_old_job, life['id'])
	
		if _new_job:
			jobs.join_job(_new_job, life['id'])
	
	if life['job']:
		life['task'] = jobs.get_next_task(life, life['job'])
	
	if not life['task']:
		if life['job']:
			jobs.leave_job(life['job'], life['id'], reject=True)
	
	if not life['job'] == _old_job:
		life['completed_tasks'] = []
	
	return life['job']
Example #2
0
def judge_jobs(life):
    _tier = 0

    if life["task"]:
        return life["job"]

    _new_job = None
    _old_job = life["job"]
    # life['job'] = None

    for job in [jobs.get_job(j) for j in life["jobs"]]:
        if not jobs.get_free_tasks(job["id"]):
            continue

        if not jobs.meets_job_requirements(life, job["id"]):
            continue

        if life["group"] and job["gist"] == "create_group":
            if not stats.wants_to_abandon_group(life, life["group"]):
                jobs.reject_job(job["id"], life["id"])
                continue

            if life["group"] == jobs.get_flag(job["id"], "group"):
                jobs.reject_job(job["id"], life["id"])
                continue

        if jobs.has_completed_or_rejected_job(life, job["id"]):
            continue

        if job["tier"] >= _tier:
            # jobs.join_job(job['id'], life['id'])
            _new_job = job["id"]
            _tier = job["tier"]

    if not _old_job == _new_job:
        if _old_job:
            jobs.leave_job(_old_job, life["id"])

        if _new_job:
            jobs.join_job(_new_job, life["id"])

    if life["job"]:
        life["task"] = jobs.get_next_task(life, life["job"])

    if not life["task"]:
        if life["job"]:
            jobs.leave_job(life["job"], life["id"], reject=True)

    if not life["job"] == _old_job:
        life["completed_tasks"] = []

    return life["job"]
Example #3
0
def reject_order(life, life_id):
	_orders = get_orders_for_target(life, life_id)

	if not _orders:
		return False
	
	_order = _orders[0]
	_order['active'] = False
	
	if 'job_id' in _order['args']:
		jobs.join_job(_order['args']['job_id'], life_id)
	
	return True
Example #4
0
def reject_order(life, life_id):
	_orders = get_orders_for_target(life, life_id)

	if not _orders:
		return False
	
	_order = _orders[0]
	_order['active'] = False
	
	if 'job_id' in _order['args']:
		jobs.join_job(_order['args']['job_id'], life_id)
	
	return True