예제 #1
0
def getcompatibleitemfromqueue(botrunnername, sessionid):
    archiveoldrequests()

    botrunner = botrunnerhelper.getBotRunner( botrunnername )
    botrunnersession = botrunnerhelper.getBotRunnerSession( botrunnername, sessionid )
    # now we've archived the old requests, we just pick a request
    # in the future, we'll pick a compatible request.  In the future ;-)
    # also, we need to handle options.  In the future ;-)
    matchrequests = Session.query(MatchRequest).filter(MatchRequest.matchrequestinprogress == None).filter(MatchRequest.matchresult == None).all()
    for matchrequest in matchrequests:
        mapok = False
        modok = False
        ai0ok = False
        ai1ok = False
        for map in botrunner.supportedmaps:
            if map.map_name == matchrequest.map.map_name:
                mapok = True
        for mod in botrunner.supportedmods:
            if mod.mod_name == matchrequest.mod.mod_name:
                modok = True
        for ai in botrunner.supportedais:
            if ai.ai_base.ai_base_name == matchrequest.ai0.ai_base.ai_base_name and ai.ai_version == matchrequest.ai0.ai_version:
                ai0ok = True
            if ai.ai_base.ai_base_name == matchrequest.ai1.ai_base.ai_base_name and ai.ai_version == matchrequest.ai1.ai_version:
                ai1ok = True
        if mapok and modok and ai0ok and ai1ok:
            # mark request in progress:
            matchrequest.matchrequestinprogress = MatchRequestInProgress(botrunner, botrunnersession, datetime.datetime.now())

            return matchrequest

    # didn't find any compatible match
    return None
def getcompatibleitemfromqueue(botrunnername, sessionid):
    archiveoldrequests()

    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    botrunnersession = botrunnerhelper.getBotRunnerSession(botrunnername, sessionid)

    # Also, remove any requests that this engine was supposedly processing
    # for which there are no results
    matchrequests = (
        sqlalchemysetup.session.query(MatchRequest)
        .filter(MatchRequest.matchresult == None)
        .filter(MatchRequest.matchrequestinprogress != None)
    )
    for matchrequest in matchrequests:
        if matchrequest.matchrequestinprogress.botrunner is botrunner:
            if matchrequest.matchrequestinprogress.botrunnersession is botrunnersession:
                sqlalchemysetup.session.delete(matchrequest.matchrequestinprogress)
    sqlalchemysetup.session.commit()

    # now we've archived the old requests, we just pick a request
    # in the future, we'll pick a compatible request.  In the future ;-)
    # also, we need to handle options.  In the future ;-)
    matchrequests = (
        sqlalchemysetup.session.query(MatchRequest)
        .filter(MatchRequest.matchrequestinprogress == None)
        .filter(MatchRequest.matchresult == None)
        .all()
    )
    for matchrequest in matchrequests:
        mapok = False
        modok = False
        ai0ok = False
        ai1ok = False
        for map in botrunner.supportedmaps:
            if map.map_name == matchrequest.map.map_name:
                mapok = True
        for mod in botrunner.supportedmods:
            if mod.mod_name == matchrequest.mod.mod_name:
                modok = True
        for ai in botrunner.supportedais:
            if ai.ai_name == matchrequest.ai0.ai_name and ai.ai_version == matchrequest.ai0.ai_version:
                ai0ok = True
            if ai.ai_name == matchrequest.ai1.ai_name and ai.ai_version == matchrequest.ai1.ai_version:
                ai1ok = True
        if mapok and modok and ai0ok and ai1ok:
            # mark request in progress:
            matchrequest.matchrequestinprogress = MatchRequestInProgress(
                botrunner, botrunnersession, dates.dateTimeToDateString(datetime.datetime.now())
            )

            return matchrequest

    # didn't find any compatible match
    return None
예제 #3
0
def getcompatibleitemfromqueue(botrunnername, sessionid):
    archiveoldrequests()

    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    botrunnersession = botrunnerhelper.getBotRunnerSession(
        botrunnername, sessionid)

    # Also, remove any requests that this engine was supposedly processing
    # for which there are no results
    matchrequests = sqlalchemysetup.session.query(MatchRequest).filter(
        MatchRequest.matchresult == None).filter(
            MatchRequest.matchrequestinprogress != None)
    for matchrequest in matchrequests:
        if matchrequest.matchrequestinprogress.botrunner is botrunner:
            if matchrequest.matchrequestinprogress.botrunnersession is botrunnersession:
                sqlalchemysetup.session.delete(
                    matchrequest.matchrequestinprogress)
    sqlalchemysetup.session.commit()

    # now we've archived the old requests, we just pick a request
    # in the future, we'll pick a compatible request.  In the future ;-)
    # also, we need to handle options.  In the future ;-)
    matchrequests = sqlalchemysetup.session.query(MatchRequest).filter(
        MatchRequest.matchrequestinprogress == None).filter(
            MatchRequest.matchresult == None).all()
    for matchrequest in matchrequests:
        mapok = False
        for map in botrunner.supportedmaps:
            if map.map.map_name == matchrequest.map.map_name:
                mapok = True
        modok = False
        for mod in botrunner.supportedmods:
            if mod.mod.mod_name == matchrequest.mod.mod_name:
                modok = True
        if mapok and modok:
            # mark request in progress:
            matchrequest.matchrequestinprogress = MatchRequestInProgress(
                botrunner, botrunnersession,
                dates.dateTimeToDateString(datetime.datetime.now()))

            return matchrequest

    # didn't find any compatible match
    return None