Exemplo n.º 1
0
void NFCPVPMatchModule::OnReqPVPApplyMatchProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS_NO_OBJECT(nSockIndex, nMsgID, msg, nLen, NFMsg::ReqPVPApplyMatch);

    NFMsg::AckPVPApplyMatch xAck;
    *xAck.mutable_self_id() = xMsg.self_id();
    xAck.set_applytype(xMsg.applytype());
    xAck.set_nresult(0);

    switch (xMsg.applytype())
    {
    case NFMsg::ReqPVPApplyMatch::EApplyType_Single:
    {
        if (ApplyPVP(nPlayerID, xMsg.npvpmode(), xMsg.score()))
        {
            xAck.set_nresult(1);
        }

        NFGUID xRoomID;
        if (m_pPVPMatchRedisModule->GetPlayerRoomID(nPlayerID, xRoomID))
        {
            NFMsg::PVPRoomInfo xRoomInfo;
            if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo))
            {
                xAck.mutable_xroominfo()->CopyFrom(xRoomInfo);
            }
        }

        m_pWorldNet_ServerModule->GetNetModule()->SendMsgPB(NFMsg::EGMI_ACK_PVPAPPLYMACTCH, xAck, nSockIndex, nPlayerID);
    }
    break;
    case NFMsg::ReqPVPApplyMatch::EApplyType_Team:
    {
        if (xMsg.has_team_id())
        {
            NFGUID xTeamID = NFINetModule::PBToNF(xMsg.team_id());
            if (!xTeamID.IsNull())
            {
                std::vector<NFGUID> xPlayerList;
                if (m_pTeamModule->GetMemberList(nPlayerID, xTeamID, xPlayerList))
                {
                    NFCDataList varMember;
                    for (size_t i = 0; i < xPlayerList.size(); i++)
                    {
                        varMember.AddObject(xPlayerList[i]);
                    }

                    if (TeamApplyPVP(xTeamID, varMember, xMsg.npvpmode(), xMsg.score()))
                    {
                        xAck.set_nresult(1);

                        NFGUID xRoomID;
                        if (m_pPVPMatchRedisModule->GetPlayerRoomID(nPlayerID, xRoomID))
                        {
                            NFMsg::PVPRoomInfo xRoomInfo;
                            if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo))
                            {
                                xAck.mutable_xroominfo()->CopyFrom(xRoomInfo);
                            }
                        }

                        m_pTeamModule->BroadcastMsgToTeam(nPlayerID, xTeamID, NFMsg::EGMI_ACK_PVPAPPLYMACTCH, xAck);


                        return;
                    }
                }
            }
        }

        m_pWorldNet_ServerModule->GetNetModule()->SendMsgPB(NFMsg::EGMI_ACK_PVPAPPLYMACTCH, xAck, nSockIndex, nPlayerID);

    }
    break;
    default:
        break;
    }
}
Exemplo n.º 2
0
int NFCBuffModule::ProcessBuffValuePropertyReferAbsoluteValue( const NFIDENTID& self, NFIBuffConfigModule::NFCBuffConfig* pBuffConfig, const NFIDENTID& releaserIdent )
{
    //buff group property
    int nBuffGroup = 0;
    //RUNTIME_BUFF_INFO
    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self );
    NF_SHARE_PTR<NFIRecord> pBuffRecord = pObject->GetRecordManager()->GetElement( mstrRunTimeEffectTable );
    if ( pBuffRecord )
    {
        NF_SHARE_PTR<NFIRecord> pPropertyGroupRecord = pObject->GetRecordManager()->GetElement( mstrPropertyTable );

        std::string strPropertyList;
        std::string strPropertyName;
        int* pnEffectValue = pBuffConfig->First( strPropertyName );
        while ( pnEffectValue )
        {
            NF_SHARE_PTR<NFIProperty> pProperty = pObject->GetPropertyManager()->GetElement( strPropertyName );
            if ( pProperty )
            {
                char szEffectValue[MAX_PATH] = {0};
                printf( szEffectValue, "%d", *pnEffectValue );

                strPropertyList.append( strPropertyName );
                strPropertyList.append( "," );
                strPropertyList.append( szEffectValue );
                strPropertyList.append( ";" );

                //相继设置属性到buff group,增值
                //从属性系统得到属性应该在的col函数
                int nPropertyGroupCol = 0;
                int nPropertyBuffGroupRow = 0;
                TDATA_TYPE eColType = pPropertyGroupRecord->GetColType( nPropertyGroupCol );

                if ( NFIBuffConfigModule::BuffReverseType::ERT_NEED_REVERSE == pBuffConfig->NeedReverseType )
                {
                    //需要还原
                    switch ( eColType )
                    {
                        case TDATA_INT:
                            pPropertyGroupRecord->SetInt( nPropertyBuffGroupRow, nPropertyGroupCol, *pnEffectValue );
                            break;

                        case TDATA_FLOAT:
                            pPropertyGroupRecord->SetFloat( nPropertyBuffGroupRow, nPropertyGroupCol, float( *pnEffectValue ) );
                            break;

                        case TDATA_DOUBLE:
                            pPropertyGroupRecord->SetDouble( nPropertyBuffGroupRow, nPropertyGroupCol, double( *pnEffectValue ) );
                            break;

                        default:
                            break;
                    }
                }
                else if ( NFIBuffConfigModule::BuffReverseType::ERT_NO_REVERSE == pBuffConfig->NeedReverseType )
                {
                    //不需要还原
                    NFIDataList::TData valueEffectValue;
                    switch ( eColType )
                    {
                        case TDATA_INT:
                            valueEffectValue.nType = TDATA_INT;
                            valueEffectValue.variantData =  NFINT64( *pnEffectValue );
                            break;

                        case TDATA_FLOAT:
                            valueEffectValue.nType = TDATA_FLOAT;
                            valueEffectValue.variantData =  float( *pnEffectValue );
                            break;

                        case TDATA_DOUBLE:
                            valueEffectValue.nType = TDATA_DOUBLE;
                            valueEffectValue.variantData = double( *pnEffectValue );
                            break;

                        default:
                            break;
                    }

                    //const NFIDataList& oldValue = pProperty->GetValue();
                    pObject->GetPropertyManager()->SetProperty( strPropertyName, valueEffectValue );
                }

                pnEffectValue = pBuffConfig->Next( strPropertyName );
            }

            //还原与否,都需要保存在runtimebuff表
            NFCDataList valueBuffProperty;
            valueBuffProperty.AddString( strPropertyName.c_str() );
            valueBuffProperty.AddObject( releaserIdent );
            valueBuffProperty.AddFloat( pBuffConfig->EffectTimeInterval );
            valueBuffProperty.AddInt( pBuffConfig->EffectTimeValue );
            valueBuffProperty.AddString( strPropertyName.c_str() );

            pBuffRecord->AddRow( -1, valueBuffProperty );
        }
    }

    return 0;
}