Ejemplo n.º 1
0
def cancelGuessResult(strMatchId,strGuessId,strChooseId,iBeginTime,iEndTime):
    objGuessData, objGuessDataLock = yield from classDataBaseMgr.getInstance().getGuessDataByLock(strGuessId)
    if objGuessData is None:
        # TODO release lock
        raise exceptionLogic(errorLogic.guess_data_not_found)

    yield from classDataBaseMgr.getInstance().setGuessDataByLock(objGuessData, objGuessDataLock)

    if len(strChooseId) <= 0:
        # 全部无效
        for var_key, var_value in objGuessData.dictCTR.items():
            yield from classDataBaseMgr.getInstance().resetResultRedisListByScore(strGuessId, var_value.strId,
                                                                                   iBeginTime)

        for var_key in objGuessData.dictCTR.keys():
            msgHead = dataHeaderDefine.classResultHead()
            msgHead.strMsgId = result_msgId.msg_cancel_result
            msgBody = CancelAwardReq()
            msgBody.strMatchId = strMatchId
            msgBody.strGuessId = strGuessId
            msgBody.strDictKey = var_key
            msgBody.iBeginTime = iBeginTime
            msgBody.iEndTime = iEndTime

            yield from classPubMgr.getInstance("resultPub").publish(msgHead, msgBody)

    else:
        if strChooseId in objGuessData.dictCTR:
            yield from classDataBaseMgr.getInstance().resetResultRedisListByScore(strGuessId, strChooseId, iBeginTime)

            msgHead = dataHeaderDefine.classResultHead()
            msgHead.strMsgId = result_msgId.msg_cancel_result
            msgBody = CancelAwardReq()
            msgBody.strMatchId = strMatchId
            msgBody.strGuessId = strGuessId
            msgBody.strDictKey = strChooseId
            msgBody.iBeginTime = iBeginTime
            msgBody.iEndTime = iEndTime

            yield from classPubMgr.getInstance("resultPub").publish(msgHead, msgBody)
Ejemplo n.º 2
0
def broadCastGuessData(guessDataList: list, pubInsName: str = None):

    objPushSSHead = classSSHead()
    objPushSSHead.iBroadCast = 1
    objPushSSHead.strMsgId = pushGuessList

    objResp = protoPushGuessData()
    for var_guess in guessDataList:
        objNewGuessResp = protoGuessItem(var_guess)
        objResp.listGuessList.append(objNewGuessResp)

    yield from classPubMgr.getInstance(pubInsName).publish(
        objPushSSHead, objResp)
Ejemplo n.º 3
0
def broadCastMatchBasicData(matchDataList: list, pubInsName: str = None):

    objPushSSHead = classSSHead()
    objPushSSHead.iBroadCast = 1
    objPushSSHead.strMsgId = pushMatchBasicList

    objResp = protoPushMatchBasicData()
    for var_match in matchDataList:
        objNewMatchResp = protoMatchItem(var_match)
        objResp.listMatchBasicList.append(objNewMatchResp)

    yield from classPubMgr.getInstance(pubInsName).publish(
        objPushSSHead, objResp)
Ejemplo n.º 4
0
def handleHttp(dict_param:dict):

    strMatchId = dict_param["strMatchId"]
    strGuessId = dict_param['strGuessId']
    strWinKey = dict_param['strWinKey']

    objGuessData, objGuessDataLock = yield from classDataBaseMgr.getInstance().getGuessDataByLock(strGuessId)
    if objGuessData is None:
        #TODO release lock
        raise exceptionLogic(errorLogic.guess_data_not_found)

    if strWinKey not in objGuessData.dictCTR:
        #TODO release lock
        raise exceptionLogic(errorLogic.guess_result_key_not_found)

    objGuessData.iGuessState = 4
    objGuessData.strGuessResult = strWinKey

    yield from classDataBaseMgr.getInstance().setGuessDataByLock(objGuessData,objGuessDataLock)

    yield from broadCastGuessData([objGuessData], "broadCastPub")

    for var_key in objGuessData.dictCTR.keys():
        msgHead = dataHeaderDefine.classResultHead()
        msgHead.strMsgId = result_msgId.msg_result if len(strWinKey) else result_msgId.msg_no_result
        msgBody = ResultReq()
        msgBody.strMatchId = strMatchId
        msgBody.strGuessId = strGuessId

        msgBody.strDictKey = var_key
        if var_key == strWinKey:
            msgBody.iWinOrLose = 1
        else:
            msgBody.iWinOrLose = 0

        yield from classPubMgr.getInstance("resultPub").publish(msgHead, msgBody)

    #判断比赛是否已经全部发奖
    objMatchData, objMatchDataLock = yield from classDataBaseMgr.getInstance().getMatchDataByLock(strMatchId)
    if objMatchData is None:
        # TODO release lock
        raise exceptionLogic(errorLogic.match_data_not_found)

    if strGuessId not in objMatchData.arrayAwardGuess:
        objMatchData.arrayAwardGuess.append(strGuessId)

    yield from classDataBaseMgr.getInstance().setMatchDataByLock(objMatchData,objMatchDataLock)
    if len(objMatchData.arrayAwardGuess) == len(objMatchData.arrayGuess):
        yield from classDataBaseMgr.getInstance().setMatchResultFinish(strMatchId,objMatchData.strMatchType,timeHelp.getNow())
Ejemplo n.º 5
0
def pushPlayerMsg(accountId, msgId, pubInsName=None):
    dictOnlineInfo = yield from classOnlineMgr.getInstance().getOnlineClient(
        accountId)
    if dictOnlineInfo is not None:
        # 没在线,不用推送了
        objPushSSHead = classSSHead()
        objPushSSHead.strAccountId = accountId
        objPushSSHead.strMsgId = pushMessage

        objResp = protoPushPlayerMsg()
        objResp.accountId = accountId
        objResp.msgId = msgId

        yield from classPubMgr.getInstance(pubInsName).publish(
            objPushSSHead, objResp)
Ejemplo n.º 6
0
def pushPinboRepairData(iEndTime,
                        iRepairFlag,
                        iSurplusTime,
                        iStartTime,
                        pubInsName=None):
    #推送pinbo维护状态信息
    objPushSSHead = classSSHead()
    objPushSSHead.iBroadCast = 1  # 全体
    objPushSSHead.strMsgId = pushPinboRepair

    objResp = protoPushPinboRepireData()
    objResp.end_time = iEndTime
    objResp.repairFlag = iRepairFlag
    objResp.surplus_time = iSurplusTime
    objResp.start_time = iStartTime

    yield from classPubMgr.getInstance(pubInsName).publish(
        objPushSSHead, objResp)
Ejemplo n.º 7
0
def handleHttp(dict_param: dict):

    strMarchId = dict_param['strMatchId']
    strGuessId = dict_param['strGuessId']

    msgHead = dataHeaderDefine.classResultHead()
    msgHead.strMsgId = result_msgId.msg_back
    msgBody = BackReq()
    msgBody.strMatchId = strMarchId
    msgBody.strGuessId = strGuessId

    objGuessData = yield from classDataBaseMgr.getInstance(
    ).getGuessDataByLock(strGuessId)
    if objGuessData is None:
        raise exceptionLogic(errorLogic.guess_data_not_found)

    for var_key, var_value in objGuessData.dictCTR.items():
        yield from classDataBaseMgr.getInstance().resetResultRedisList(
            strGuessId, var_value.strId)

    yield from classPubMgr.getInstance("resultPub").publish(msgHead, msgBody)
Ejemplo n.º 8
0
def broadCastMatchData(matchDataList: list,
                       guessDataDict: dict,
                       pubInsName: str = None):

    objPushSSHead = classSSHead()
    objPushSSHead.iBroadCast = 1
    objPushSSHead.strMsgId = pushMatchList

    objResp = protoPushMatchData()
    for var_match in matchDataList:
        objNewMatchResp = protoMatchItem(var_match)
        for var_round, var_guess_id_list in var_match.dictGuess.item():
            for var_guess_id in var_guess_id_list:
                objGuessData = guessDataDict.get(var_guess_id, None)
                if objGuessData is not None:

                    objNewMatchResp.buildRoundGuess(var_round, objGuessData)
        objResp.listMatchList.append(objNewMatchResp)

    yield from classPubMgr.getInstance(pubInsName).publish(
        objPushSSHead, objResp)
Ejemplo n.º 9
0
def handleHttp(dict_param: dict):

    strMatchId = dict_param["strMatchId"]
    iAwardNum = int(dict_param['iAwardNum'])
    iAwardType = int(dict_param['iAwardType'])
    iWinOrLose = int(dict_param['iWinOrLose'])

    objMatchData, objMatchDataLock = yield from classDataBaseMgr.getInstance(
    ).getMatchDataByLock(strMatchId)
    if objMatchData is None:
        # TODO release lock
        raise exceptionLogic(errorLogic.guess_data_not_found)

    objMatchData.iAwardFlag = 1
    objMatchData.iAwardType = iAwardType
    objMatchData.iAwardNum = iAwardNum
    objMatchData.iWinOrLose = iWinOrLose

    yield from classDataBaseMgr.getInstance().setMatchDataByLock(
        objMatchData, objMatchDataLock)

    #加入赠送列表
    yield from classDataBaseMgr.getInstance().delMatchCancelAwardedList(
        objMatchData.strMatchId, timeHelp.getNow())
    yield from classDataBaseMgr.getInstance().addMatchAwardedList(
        objMatchData.strMatchId, timeHelp.getNow())

    #全部奖励
    msgHead = dataHeaderDefine.classResultHead()
    msgHead.strMsgId = result_msgId.msg_award
    msgBody = AwardReq()
    msgBody.strMatchId = strMatchId
    msgBody.iWinOrLose = iWinOrLose
    msgBody.iAwardNum = iAwardNum
    msgBody.iAwardType = iAwardType

    yield from classPubMgr.getInstance("resultPub").publish(msgHead, msgBody)