bool NFCSLGBuildingModule::GetProduceDataCount( const NFGUID& self, const NFGUID& xBuilID, const std::string& strItemID, int& nCount )
{
    NF_SHARE_PTR<NFIRecord> pProduce = m_pKernelModule->FindRecord(self, "BuildingProduce");
    if (NULL == pProduce.get())
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingProduce] Record!", "", __FUNCTION__, __LINE__);
        return false;
    }

    NFDataList varProduce;
    pProduce->FindObject("BuildingGUID", xBuilID, varProduce);

    if(varProduce.GetCount() <= 0)
    {
        nCount = 0;
        return true;
    }

    for (int i = 0; i< varProduce.GetCount(); i++)
    {
        const std::string& strHasItemID = pProduce->GetString(i, "ItemID");
        if (strHasItemID  == strItemID)
        {
            const int nOldCount = pProduce->GetInt(i, "LeftCount");
            nCount = pProduce->GetInt(i, "LeftCount");

            return true;
        }
    }

    return false;
}
int NFCSLGBuildingModule::CheckProduceData( const NFGUID& self )
{
    NF_SHARE_PTR<NFIRecord> pProduce = m_pKernelModule->FindRecord(self, "BuildingProduce");
    if (NULL == pProduce.get())
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingProduce] Record!", "", __FUNCTION__, __LINE__);
        return false;
    }

    for (int i = 0; i < pProduce->GetRows(); i++)
    {
        if (!pProduce->IsUsed(i))
        {
            continue;
        }

        const int nNowTime = pPluginManager->GetNowTime();
        const NFGUID xBuildID = pProduce->GetObject(i, "BuildingGUID");
        const std::string strItemID = pProduce->GetString(i, "ItemID");
        const int nLeftCount = pProduce->GetInt(i, "LeftCount");
        const NFINT64 nLastOnceBeginTime = pProduce->GetInt(i, "OnceStartTime");
        const NFINT64 nOnceTime = pProduce->GetInt(i, "OnceTime");

        const int nPassTime = nNowTime - nLastOnceBeginTime;
        if (nPassTime <= 0)
        {
            continue;
        }

        const int nCount = nPassTime/nOnceTime;
        if (nCount >= nLeftCount)
        {
            //add Item
            //TO ADD

            pProduce->Remove(i);
        }
        else
        {
            //add Item
            //TO ADD

            pProduce->SetInt(i, "", nLeftCount - nCount);

            
            //NFDataList varHeart;
            //varHeart << xBuildID;
            //varHeart << strItemID;

            const std::string strHeartname = GetProduceHeartName(self, xBuildID, strItemID);
            const int nTime = (nCount + 1) * nOnceTime - nPassTime;
			m_pScheduleModule->AddSchedule(self, strHeartname, this, &NFCSLGBuildingModule::OnProduceHeartBeat, /*varHeart, */nTime, 1);
        }
    }

    return 0;
}
int NFCSLGBuildingModule::CheckBuildingStatusEnd( const NFGUID& self )
{
    NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, "BuildingList");
    if (NULL == pRecord.get())
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingList] Record!", "", __FUNCTION__, __LINE__);
        return 1;
    }

    const NFINT64 nNowTime = pPluginManager->GetNowTime();
    for (int i= 0; i < pRecord->GetRows(); i++)
    {
        if (!pRecord->IsUsed(i))
        {
            continue;
        }

        const NFINT64 nEndTime = pRecord->GetInt(i, "StateEndTime");
        const NFGUID& xBuildID = pRecord->GetObject(i, "BuildingGUID");
        const int& nStatus = pRecord->GetInt(i, "State");

        float fTime = nEndTime - nNowTime;
        if (fTime <= 0.0f)
        {
            fTime = 0.1f;
        }

        if (nStatus == NFMsg::EBS_IDLE)
        {
            continue;
        }
        else if(nStatus == NFMsg::EBS_UPGRADE)
        {
            //NFDataList varHeart;
            //varHeart << xBuildID;

			m_pScheduleModule->AddSchedule(self, "OnUpgradeHeartBeat", this, &NFCSLGBuildingModule::OnUpgradeHeartBeat, /*varHeart, */fTime, 1);
        }
        else if(nStatus == NFMsg::EBS_BOOST)
        {
            //NFDataList varHeart;
            //varHeart << xBuildID;

			m_pScheduleModule->AddSchedule(self, "OnUpgradeHeartBeat", this, &NFCSLGBuildingModule::OnUpgradeHeartBeat, /*varHeart, */fTime, 1);
        }
    }

    return 0;
}
Esempio n. 4
0
bool NFCTeamModule::GetMemberList(const NFGUID& self, const NFGUID& xTeam, std::vector<NFGUID>& xmemberList)
{
    NF_SHARE_PTR<NFIRecordManager> pRecordManager = m_pCommonRedisModule->GetCacheRecordInfo(xTeam, NFrame::Team::ThisName());
    if (!pRecordManager)
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pMemberRecord = pRecordManager->GetElement(NFrame::Team::MemberList::ThisName());
    if (!pMemberRecord.get())
    {
        return false;
    }

    for (int i = 0; i < pMemberRecord->GetRows(); i++)
    {
        if (!pMemberRecord->IsUsed(i))
        {
            continue;
        }

        const NFINT64 nOnline = pMemberRecord->GetInt(i, NFrame::Team::MemberList::Online);
        const NFINT64 nGameID = pMemberRecord->GetInt(i, NFrame::Team::MemberList::GameID);
        const NFGUID& xID = pMemberRecord->GetObject(i, NFrame::Team::MemberList::GUID);
        if (!xID.IsNull())
        {

            xmemberList.push_back(xID);
        }
    }

    return true;
}
Esempio n. 5
0
int NFCEquipModule::GetEquipElementLevel(const NFGUID & self, const NFGUID & id, NFrame::Player::BagEquipList eIndex)
{
	if (id.IsNull() || self.IsNull())
	{
		return -1;
	}

	if (eIndex > NFrame::Player::BagEquipList_ElementLevel5_POISON
		|| eIndex < NFrame::Player::BagEquipList_ElementLevel1_FIRE)
	{
		return -1;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return -1;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return -1;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return -1;
	}

	const int nRow = xDataList.Int(0);
	return pRecord->GetInt(nRow, eIndex);
}
Esempio n. 6
0
bool NFCEquipModule::AddEquipIntensifyLevel(const NFGUID& self, const NFGUID& id)
{
	if (id.IsNull() || self.IsNull())
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return false;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return false;
	}

	const int nRow = xDataList.Int(0);
	const int nLevel = pRecord->GetInt(nRow, NFrame::Player::BagEquipList_IntensifyLevel);
	pRecord->SetInt(nRow, NFrame::Player::BagEquipList_IntensifyLevel, nLevel + 1);

	return true;
}
Esempio n. 7
0
bool NFCGuildModule::DownGuildMmember( const NFGUID& self, const NFGUID& xGuildID, const NFGUID& xMmember )
{
    NF_SHARE_PTR<NFIObject> pGuildObject = m_pGuildDataModule->GetGuild(xGuildID);
    if (!pGuildObject.get())
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pMemberRecord = m_pKernelModule->FindRecord(xGuildID, NFrame::Guild::R_GuildMemberList());
    if (!pMemberRecord.get())
    {
        return false;
    }

    CheckPower(self, xGuildID, NFMsg::ReqAckOprGuildMember::EGAT_DOWN);

    NFDataList varList;
    pMemberRecord->FindObject(NFrame::Guild::GuildMemberList_GUID, self, varList);
    if (varList.GetCount() == 0)
    {
        return false;
    }

    const int nRow = varList.Int(0);

    const int nPower = pMemberRecord->GetInt(nRow, NFrame::Guild::GuildMemberList_Power);
    if (nPower == 0)
    {
        return false;
    }

    pMemberRecord->SetInt(nRow, NFrame::Guild::GuildMemberList_Power, (nPower - 1));
    return true;
}
Esempio n. 8
0
int NFCEquipModule::GetEquipHoleCount(const NFGUID & self, const NFGUID & id)
{
	if (id.IsNull() || self.IsNull())
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return false;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return false;
	}

	const int nRow = xDataList.Int(0);
	return pRecord->GetInt(nRow, NFrame::Player::BagEquipList_SlotCount);
}
Esempio n. 9
0
bool NFCPackModule::DeleteItem( const NFGUID& self, const std::string& strItemConfigID, const int nCount )
{
	if(nCount <= 0)
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self );
	if ( NULL == pObject )
	{
		return false;
	}

	//还得确定有这个装备
	if (!m_pElementModule->ExistElement(NFrame::Item::ThisName(), strItemConfigID))
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagItemList() );
	if (!pRecord)
	{
		return false;
	}

	NFCDataList varFindResult;
	int nFindRowCount = pRecord->FindString(NFrame::Player::BagItemList_ConfigID, strItemConfigID, varFindResult);
	if (nFindRowCount > 0)
	{
		int nNeedDelCount = nCount;
		for (int i = 0; i < varFindResult.GetCount(); ++i)
		{
			int nFindRow = varFindResult.Int(i);
			int nOldCount = pRecord->GetInt(nFindRow, NFrame::Player::BagItemList_ItemCount);
			if (nOldCount > nNeedDelCount)
			{
				int nNewCount = nOldCount - nNeedDelCount;
				pRecord->SetInt(nFindRow, NFrame::Player::BagItemList_ItemCount, nNewCount);
				nNeedDelCount = 0;
			}
			else if (nOldCount == nNeedDelCount)
			{
				pRecord->Remove(nFindRow);
				nNeedDelCount = 0;
			}
			else if (nOldCount < nNeedDelCount)
			{
				pRecord->Remove(nFindRow);
				nNeedDelCount -= nOldCount;
			}
		}

		if (nNeedDelCount <= 0)
		{
			return true;
		}
	}

	return false;
}
bool NFCWorldGuildModule::UpGuildMmember( const NFIDENTID& self, const NFIDENTID& xGuildID, const NFIDENTID& xMmember )
{
    NF_SHARE_PTR<NFIObject> pGuildObject = m_pWorldGuildDataModule->GetGuild(xGuildID);
    if (!pGuildObject.get())
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pMemberRecord = m_pKernelModule->FindRecord(xGuildID, "GuildMemberList");
    if (!pMemberRecord.get())
    {
        return false;
    }

    CheckPower(self, xGuildID, NFMsg::ReqAckOprGuildMember::EGAT_UP);

    NFCDataList varList;
    pMemberRecord->FindObject(NFMsg::GuildMemberList_GUID, self, varList);
    if (varList.GetCount() == 0)
    {
        return false;
    }

    const int nRow = varList.Int(0);

    const int nPower = pMemberRecord->GetInt(nRow, NFMsg::GuildMemberList_Power);

    if (nPower >= NFMsg::GUILD_POWER_TYPE_PRESIDENT)
    {
        return false;
    }

    pMemberRecord->SetInt(nRow, NFMsg::GuildMemberList_Power, (nPower + 1)) ;
	return true;
}
Esempio n. 11
0
bool NFCGuildModule::GetOnlineMember( const NFGUID& self, const NFGUID& xGuild, NFDataList& varMemberList, NFDataList& varGameList)
{
    NF_SHARE_PTR<NFIObject> pGuildObject = m_pGuildDataModule->GetGuild(xGuild);
    if (!pGuildObject.get())
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pMemberRecord = m_pKernelModule->FindRecord(xGuild, NFrame::Guild::R_GuildMemberList());
    if (!pMemberRecord.get())
    {
        return false;
    }

    for (int i = 0; i< pMemberRecord->GetRows(); i++)
    {
        if (!pMemberRecord->IsUsed(i))
        {
            continue;
        }

        const NFINT64 nOnline = pMemberRecord->GetInt(i, NFrame::Guild::GuildMemberList_Online);
        const NFINT64 nGameID = pMemberRecord->GetInt(i, NFrame::Guild::GuildMemberList_GameID);
        const NFGUID& xID = pMemberRecord->GetObject(i, NFrame::Guild::GuildMemberList_GUID);
        if (nOnline > 0 && !xID.IsNull())
        {

            varMemberList.Add(xID);
            varGameList.Add(nGameID);
        }
    }

    return true;
}
Esempio n. 12
0
NFINT64 NFCPropertyManager::GetPropertyInt(const std::string& strPropertyName)
{
    NF_SHARE_PTR<NFIProperty> pProperty = GetElement(strPropertyName);
    if (pProperty)
    {
        return pProperty->GetInt();
    }

    return 0;
}
NFINT64 NFCRecordManager::GetRecordInt(const std::string& strRecordName, const int nRow, const std::string& strColTag)
{
	NF_SHARE_PTR<NFIRecord> pRecord = GetElement(strRecordName);
	if (pRecord.get())
	{
		return pRecord->GetInt(nRow, strColTag);
	}

	return 0;
}
NFINT64 NFCElementInfoModule::GetPropertyInt(const std::string& strConfigName, const std::string& strPropertyName)
{
    NF_SHARE_PTR<NFIProperty> pProperty = GetProperty(strConfigName, strPropertyName);
    if (pProperty.get())
    {
        return pProperty->GetInt();
    }

    return 0;
}
const int NFCCommonConfigModule::GetFieldInt(const std::string& strStructName, const std::string& strStructItemName, const std::string& strAttribute)
{
	NF_SHARE_PTR<CStructInfo> pSDKInfo = mmData.GetElement(strStructName);
	if (pSDKInfo)
	{
		NF_SHARE_PTR<CAttributeList> pParam = pSDKInfo->GetElement(strStructItemName);
		if (pParam)
		{
			return pParam->GetInt(strAttribute);
		}
	}

	return 0;
}
Esempio n. 16
0
bool NFCEquipModule::SetEquipInlayStoneID(const NFGUID& self, const NFGUID& id, NFrame::Player::BagEquipList eIndex, const std::string& strStoneID)
{
	if (id.IsNull() || self.IsNull() || strStoneID.empty())
	{
		return false;
	}

	if (eIndex > NFrame::Player::BagEquipList_InlayStone10
		|| eIndex < NFrame::Player::BagEquipList_InlayStone1)
	{
		return false;
	}

	if (!m_pElementModule->ExistElement(strStoneID))
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return false;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return false;
	}

	const int nRow = xDataList.Int(0);
	const int nSoltCount = pRecord->GetInt(nRow, NFrame::Player::BagEquipList_SlotCount);
	if ((eIndex - NFrame::Player::BagEquipList_InlayStone1) <= nSoltCount)
	{
		return false;
	}

	pRecord->SetString(nRow, eIndex, strStoneID);

	return true;
}
Esempio n. 17
0
int NFCItemModule::AddItemEffectDataProperty(const NFGUID& self, const NFGUID& xTarget, const std::string& strItemID)
{
	if (strItemID.empty())
	{
		return 1;
	}

	//////////////////////////////////////////////////////////////////////////
	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(xTarget);
	if (NULL == pObject)
	{
		//m_pLogModule->LogObject(NFILogModule::NLL_ERROR_NORMAL, self, "There is no object", __FUNCTION__, __LINE__);
		return 1;
	}

	//////////////////////////////////////////////////////////////////////////
	NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementModule->GetPropertyManager(strItemID);
	if (!pPropertyManager)
	{
		return 1;
	}

	NF_SHARE_PTR<NFIProperty> pEffectDataProperty = pPropertyManager->GetElement("EffectData");
	if (!pEffectDataProperty)
	{
		return 1;
	}

	NF_SHARE_PTR<NFIPropertyManager> pEffectDataPropertyManager = m_pElementModule->GetPropertyManager(pEffectDataProperty->GetString());
	if (!pEffectDataPropertyManager)
	{
		return 1;
	}

	NF_SHARE_PTR<NFIProperty> pProperty = pEffectDataPropertyManager->First();
	while (pProperty)
	{
		if (pProperty->GetInt() != 0)
		{
			m_pPropertyModule->AddPropertyValue(xTarget, pProperty->GetKey(), NFIPropertyModule::NPG_EQUIP, pProperty->GetInt());
		}

		pProperty = pEffectDataPropertyManager->Next();
	}

	return 0;
}
int NFCSLGBuildingModule::AddProduceData(const NFGUID& self, const NFGUID& xBuilID, const std::string& strItemID, const int nCount)
{
    NF_SHARE_PTR<NFIRecord> pProduce = m_pKernelModule->FindRecord(self, "BuildingProduce");
    if (NULL == pProduce.get())
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "this is no [BuildingProduce] Record!", "", __FUNCTION__, __LINE__);
        return 1;
    }

    NFDataList varProduce;
    pProduce->FindObject("BuildingGUID", xBuilID, varProduce);

    int  nFindRow = -1;
    for (int i = 0; i< varProduce.GetCount(); i++)
    {
        const std::string& strHasItemID = pProduce->GetString(i, "ItemID");
        if (strHasItemID  == strItemID)
        {
            nFindRow = i;
            break;
        }
    }

    if (nFindRow < 0)
    {
        //already exit
        const int nOldCount = pProduce->GetInt(nFindRow, "LeftCount");
        pProduce->SetInt(nFindRow, "LeftCount", nOldCount + nCount);

    }
    else
    {
        const int nTime = 20;
        NFDataList varItem;

        varItem << xBuilID;
        varItem << strItemID;
        varItem << nCount;
        varItem << nTime;
        varItem << pPluginManager->GetNowTime();

        pProduce->AddRow(-1, varItem);
    }

    return 0;
}
Esempio n. 19
0
bool NFCPackModule::CreateItem( const NFGUID& self, const std::string& strConfigName, const int nCount )
{
	if (nCount <= 0)
	{
		return 0;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self );
	if ( NULL == pObject )
	{
		return 0;
	}

	//还得确定有这个装备
	bool bExist = m_pElementModule->ExistElement(NFrame::Item::ThisName(), strConfigName );
	if ( !bExist )
	{
		return 0;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagItemList() );
	if (!pRecord)
	{
		return 0;
	}

	NFCDataList varFindResult;
	int nFindRowCount = pRecord->FindString(NFrame::Player::BagItemList_ConfigID, strConfigName, varFindResult);
	if (nFindRowCount <= 0)
	{
		NF_SHARE_PTR<NFIDataList> xRowData = pRecord->GetInitData();

		xRowData->SetString(NFrame::Player::BagItemList_ConfigID, strConfigName);
		xRowData->SetInt(NFrame::Player::BagItemList_ItemCount, nCount);
		xRowData->SetInt(NFrame::Player::BagItemList_Date, NFTime::GetNowTime());
	}
	else
	{
		int nFindRow = varFindResult.Int(0);
		int nOldCount = pRecord->GetInt(nFindRow, NFrame::Player::BagItemList_ItemCount);
		int nNewCount = nOldCount + nCount;
		pRecord->SetInt(nFindRow, NFrame::Player::BagItemList_ItemCount, nNewCount);
	}

	return 0;
}
Esempio n. 20
0
bool NFCPackModule::EnoughItem( const NFGUID& self, const std::string& strItemConfigID, const int nCount )
{
    if(nCount <= 0)
    {
        return false;
    }

    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self );
    if ( NULL == pObject )
    {
        return false;
    }

    //还得确定有这个装备
    bool bExist = m_pElementModule->ExistElement(NFrame::Item::ThisName(), strItemConfigID );
    if ( !bExist )
    {
        return false;
    }

    NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagItemList() );
    if (!pRecord)
    {
        return false;
    }

	NFCDataList varFindResult;
	int nFindRowCount = pRecord->FindString(NFrame::Player::BagItemList_ConfigID, strItemConfigID, varFindResult);
	if (nFindRowCount > 0)
	{
		int nTotalCount = 0;
		for (int i = 0; i < varFindResult.GetCount(); ++i)
		{
			int nFindRow = varFindResult.Int(i);
			int nOldCount = pRecord->GetInt(nFindRow, NFrame::Player::BagItemList_ItemCount);
			nTotalCount += nOldCount;
		}

		if (nTotalCount > 0)
		{
			return true;
		}
	}

    return false;
}
int NFCPropertyModule::SubPropertyValue(const NFGUID& self, const std::string& strPropertyName, const NFPropertyGroup eGroupType, const int nValue)
{
    if (NFPropertyGroup::NPG_ALL != eGroupType)
    {
        NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
        if (pObject.get())
        {
            NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_CommPropertyValue());
            if (pRecord.get())
            {
                pRecord->SetUsed(eGroupType, true);
                int nPropertyValue = pRecord->GetInt(eGroupType, strPropertyName);

                return pRecord->SetInt(eGroupType, strPropertyName, nPropertyValue - nValue);
            }
        }
    }

    return 0;
}
int NFCPropertyModule::OnRecordPropertyEvent(const NFGUID& self, const RECORD_EVENT_DATA& xEventData, const NFIDataList::TData& oldVar, const NFIDataList::TData& newVar)
{
    //计算总值
    const std::string& strRecordName = xEventData.strRecordName;
    const int nOpType = xEventData.nOpType;
    const int nRow = xEventData.nRow;
    const int nCol = xEventData.nCol;

    int nAllValue = 0;
    NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_CommPropertyValue());
    for (int i = 0; i < (int)(NFPropertyGroup::NPG_ALL); i++)
    {
        if (i < pRecord->GetRows())
        {
            int nValue = pRecord->GetInt(i, nCol);
            nAllValue += nValue;
        }
    }

    m_pKernelModule->SetPropertyInt(self, pRecord->GetColTag(nCol), nAllValue);

    return 0;
}
Esempio n. 23
0
bool NFPropertyModule::CalculatePropertyValue(const NFGUID& self, const std::string& strPropertyName, const NFPropertyGroup eGroupType, const int64_t nValue, const bool bPositive)
{
	if (NFPropertyGroup::NPG_ALL == eGroupType)
	{
		int64_t nPropertyValue = m_pKernelModule->GetPropertyInt(self, strPropertyName);
		nPropertyValue = nPropertyValue + nValue;
		if (bPositive)
		{
			nPropertyValue = (nPropertyValue >= 0) ? nPropertyValue : 0;
		}

		m_pKernelModule->SetPropertyInt(self, strPropertyName, nPropertyValue);
	}
	else
    {
        NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
        if (pObject)
        {
            NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, NFrame::Player::CommValue::ThisName());
            if (pRecord)
            {
                pRecord->SetUsed(eGroupType, true);
				int64_t nPropertyValue = pRecord->GetInt(eGroupType, strPropertyName);
				nPropertyValue = nPropertyValue + nValue;
				if (bPositive)
				{
					nPropertyValue = (nPropertyValue >= 0) ? nPropertyValue : 0;
				}

                return pRecord->SetInt(eGroupType, strPropertyName, nPropertyValue);
            }
        }
    }

    return false;
}
Esempio n. 24
0
bool NFCGuildModule::CheckPower( const NFGUID& self, const NFGUID& xGuildID, int nPowerType )
{
    NF_SHARE_PTR<NFIObject> pGuildObject = m_pGuildDataModule->GetGuild(xGuildID);
    if (pGuildObject.get())
    {
        NF_SHARE_PTR<NFIRecord> pMemberRecord = m_pKernelModule->FindRecord(xGuildID, NFrame::Guild::R_GuildMemberList());
        if (pMemberRecord.get())
        {
            NFDataList varList;
            pMemberRecord->FindObject(NFrame::Guild::GuildMemberList_GUID, self, varList);
            if (varList.GetCount() == 1)
            {
                const int nRow = varList.Int(0);
                const int nPower = pMemberRecord->GetInt(nRow, NFrame::Guild::GuildMemberList_Power); 
                if (nPower >= NFMsg::GUILD_POWER_TYPE_PRESIDENT)
                {
                    return true;
                }
            }
        }
    }

    return false;
}
Esempio n. 25
0
int NFCSkillModule::OnRequireUseSkillEvent( const NFGUID& self, const int nEventID, const NFIDataList& var )
{
    if ( var.GetCount() < 3)
    {
        return 1;
    }

    //EGameErrorCode errorCode = EGameErrorCode::EGEC_INVALID_SKILL;
    NF_SHARE_PTR<NFIObject> pObejct = m_pKernelModule->GetObject( var.Object( 0 ) );
    if ( pObejct == NULL )
    {
        return 1;
    }

    NF_SHARE_PTR<NFIRecord> pRecordSkill = pObejct->GetRecordManager()->GetElement( NFrame::Player::R_SkillTable() );
    if ( pRecordSkill == NULL )
    {
        return 1;
    }

    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementInfoModule->GetPropertyManager( var.String( 2 ) );
    if ( pPropertyManager == NULL )
    {
        return 1;
    }

    NF_SHARE_PTR<NFIProperty> pItemTypeProperty = pPropertyManager->GetElement(NFrame::Skill::SkillType());
    if ( pItemTypeProperty == NULL )
    {
        return 1;
    }

    //配置表中真的有这么个技能类别
    EGameSkillType eItemType = ( EGameSkillType )pItemTypeProperty->GetInt();
    NFISkillConsumeProcessModule* pConsumeProcessModule = m_pSkillConsumeManagerModule->GetConsumeModule( EGameSkillType::EGST_JOBSKILL_BRIEF );
    if ( pConsumeProcessModule == NULL )
    {
        return 1;
    }

    NFCDataList valueOther;
    valueOther.Append( var, 3, var.GetCount() - 3 ); // 被攻击玩家数量 3表示从第几个参数开始是被攻击玩家
    //     if ( pConsumeProcessModule->ConsumeLegal( var.ObjectVal( 0 ), var.StringVal( 2 ), valueOther ) != 0 )
    //     {
    //         return 1;
    //     }
    // 
    //     if ( pConsumeProcessModule->ConsumeSelf( var.ObjectVal( 0 ), var.StringVal( 2 ) ) != 0 )
    //     {
    //         return 1;
    //     }
    // 
    NFCDataList damageValueList;
    NFCDataList damageResultList;
    int nResult = pConsumeProcessModule->ConsumeProcess( var.Object( 0 ), var.String( 2 ), valueOther, damageValueList, damageResultList );
    for (int i = 0; i < valueOther.GetCount(); i++)
    {
        m_pKernelModule->SetPropertyInt(valueOther.Object(i), NFrame::NPC::HP(), 0);
        damageValueList.AddInt(0);
        damageResultList.AddInt(0);
    }

    //结果事件--无论失败或者是成功,都会发下去--当然使用结果只对使用者下发--成果的结果,还得对被施放的人发
    if ( damageValueList.GetCount() == damageResultList.GetCount()
        && damageValueList.GetCount() == valueOther.GetCount() )
    {
        NFCDataList valueResult;
        valueResult.AddString( var.String( 2 ).c_str() );
        valueResult.AddInt( valueOther.GetCount() );
        valueResult.Append( valueOther, 0, valueOther.GetCount() ); //伤害对象
        valueResult.Append( damageValueList, 0, damageValueList.GetCount() ); //伤害值
        valueResult.Append( damageResultList, 0, damageResultList.GetCount() ); //击打效果

        //现在不需要反馈,杀了就杀了
        //m_pEventProcessModule->DoEvent( pObejct->Self(), NFED_ON_CLIENT_USE_SKILL_RESULT, valueResult );
    }

    return 0;
}
Esempio n. 26
0
bool NFCCreateRoleModule::ConvertRecordToPB(const NF_SHARE_PTR<NFIRecord>& pRecord, NFMsg::ObjectRecordBase * pRecordData)
{
	pRecordData->set_record_name(pRecord->GetName());

	for (int iRow = 0; iRow < pRecord->GetRows(); iRow++)
	{
		if (!pRecord->IsUsed(iRow))
		{
			continue;
		}

		NFMsg::RecordAddRowStruct* pRowData = pRecordData->add_row_struct();
		if (!pRowData)
		{
			continue;
		}

		pRowData->set_row(iRow);

		for (int iCol = 0; iCol < pRecord->GetCols(); iCol++)
		{
			const int nType = pRecord->GetColType(iCol);
			switch (nType)
			{
			case TDATA_INT:
			{
				NFMsg::RecordInt* pPropertyData = pRowData->add_record_int_list();
				const NFINT64 xPropertyValue = pRecord->GetInt(iRow, iCol);

				if (pPropertyData)
				{
					pPropertyData->set_col(iCol);
					pPropertyData->set_row(iRow);
					pPropertyData->set_data(xPropertyValue);
				}
			}
			break;
			case TDATA_FLOAT:
			{
				NFMsg::RecordFloat* pPropertyData = pRowData->add_record_float_list();
				const double xPropertyValue = pRecord->GetFloat(iRow, iCol);

				if (pPropertyData)
				{
					pPropertyData->set_col(iCol);
					pPropertyData->set_row(iRow);
					pPropertyData->set_data(xPropertyValue);
				}
			}
			break;
			case TDATA_STRING:
			{
				NFMsg::RecordString* pPropertyData = pRowData->add_record_string_list();
				const std::string& xPropertyValue = pRecord->GetString(iRow, iCol);

				if (pPropertyData)
				{
					pPropertyData->set_col(iCol);
					pPropertyData->set_row(iRow);
					pPropertyData->set_data(xPropertyValue);

				}
			}
			break;
			case TDATA_OBJECT:
			{
				NFMsg::RecordObject* pPropertyData = pRowData->add_record_object_list();
				const NFGUID xPropertyValue = pRecord->GetObject(iRow, iCol);

				if (pPropertyData)
				{
					pPropertyData->set_col(iCol);
					pPropertyData->set_row(iRow);
					*pPropertyData->mutable_data() = NFINetModule::NFToPB(xPropertyValue);
				}
			}
			break;
			case TDATA_VECTOR2:
			{
				NFMsg::RecordVector2* pPropertyData = pRowData->add_record_vector2_list();
				const NFVector2 xPropertyValue = pRecord->GetVector2(iRow, iCol);

				if (pPropertyData)
				{
					pPropertyData->set_col(iCol);
					pPropertyData->set_row(iRow);

					NFMsg::Vector2* pVec = pPropertyData->mutable_data();
					pVec->set_x(xPropertyValue.X());
					pVec->set_y(xPropertyValue.Y());
				}
			}
			break;
			case TDATA_VECTOR3:
			{
				NFMsg::RecordVector3* pPropertyData = pRowData->add_record_vector3_list();
				const NFVector3 xPropertyValue = pRecord->GetVector3(iRow, iCol);

				if (pPropertyData)
				{
					pPropertyData->set_col(iCol);
					pPropertyData->set_row(iRow);

					NFMsg::Vector3* pVec = pPropertyData->mutable_data();
					pVec->set_x(xPropertyValue.X());
					pVec->set_y(xPropertyValue.Y());
					pVec->set_z(xPropertyValue.Z());
				}
			}
			break;
			default:
				break;
			}
		}
	}

	return true;
}
Esempio n. 27
0
bool NFCCreateRoleModule::ConvertPropertyManagerToPB(const NF_SHARE_PTR<NFIPropertyManager>& pProps, NFMsg::ObjectPropertyList * pPropertyData)
{
	if (pProps)
	{
		NF_SHARE_PTR<NFIProperty> xPropert = pProps->First();
		while (xPropert)
		{
			if (xPropert->GetCache() || xPropert->GetSave())
			{

				switch (xPropert->GetType())
				{
				case NFDATA_TYPE::TDATA_INT:
				{
					NFMsg::PropertyInt* pData = pPropertyData->add_property_int_list();
					pData->set_property_name(xPropert->GetKey());
					pData->set_data(xPropert->GetInt());
				}
				break;

				case NFDATA_TYPE::TDATA_FLOAT:
				{
					NFMsg::PropertyFloat* pData = pPropertyData->add_property_float_list();
					pData->set_property_name(xPropert->GetKey());
					pData->set_data(xPropert->GetFloat());
				}
				break;

				case NFDATA_TYPE::TDATA_OBJECT:
				{
					NFMsg::PropertyObject* pData = pPropertyData->add_property_object_list();
					pData->set_property_name(xPropert->GetKey());
					*(pData->mutable_data()) = NFINetModule::NFToPB(xPropert->GetObject());
				}
				break;

				case NFDATA_TYPE::TDATA_STRING:
				{
					NFMsg::PropertyString* pData = pPropertyData->add_property_string_list();
					pData->set_property_name(xPropert->GetKey());
					pData->set_data(xPropert->GetString());

					std::cout << xPropert->GetKey() << " " << xPropert->GetString() << std::endl;
				}
				break;

				case NFDATA_TYPE::TDATA_VECTOR2:
				{
					NFMsg::PropertyVector2* pData = pPropertyData->add_property_vector2_list();
					pData->set_property_name(xPropert->GetKey());
					*(pData->mutable_data()) = NFINetModule::NFToPB(xPropert->GetVector2());
				}
				break;

				case NFDATA_TYPE::TDATA_VECTOR3:
				{
					NFMsg::PropertyVector3* pData = pPropertyData->add_property_vector3_list();
					pData->set_property_name(xPropert->GetKey());
					*(pData->mutable_data()) = NFINetModule::NFToPB(xPropert->GetVector3());
				}
				break;
				default:
					break;
				}
			}

			xPropert = pProps->Next();
		}
	}

	return false;
}
const bool NFCObjectSaveModule::SaveDataToNoSql( const NFIDENTID& self )
{
    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self );
    if ( pObject.get() )
    {
        NF_SHARE_PTR<NFIPropertyManager> pProManager = pObject->GetPropertyManager();
        NF_SHARE_PTR<NFIRecordManager> pRecordManager = pObject->GetRecordManager();

        std::vector<std::string> vFieldVec;
        std::vector<std::string> vValueVec;

        //witch property to save
        std::string strName;
        NF_SHARE_PTR<NFIProperty> xProperty = pProManager->First(strName);
        while (xProperty)
        {
            if (xProperty->GetSave())
            {
                vFieldVec.push_back(strName);
                vValueVec.push_back(xProperty->ToString());
            }

            strName.clear();
            xProperty = pProManager->Next(strName);
        }

        //witch Record to save
        NF_SHARE_PTR<NFIRecord> xRecord = pRecordManager->First(strName);
        while (xRecord)
        {
            if (xRecord->GetSave())
            {
                NFMsg::PlayerRecordBase xRecordData;
                xRecordData.set_record_name(strName);

                for (int i = 0; i < xRecord->GetRows(); ++i)
                {
                    if(xRecord->IsUsed(i))
                    {
                        for (int j = 0; j < xRecord->GetCols(); ++j)
                        {
                            switch (xRecord->GetColType(j))
                            {
                            case TDATA_INT:
                                {
                                    NFMsg::RecordInt* pRecordInt = xRecordData.add_record_int_list();
                                    pRecordInt->set_row(i);
                                    pRecordInt->set_col(j);
                                    pRecordInt->set_data(xRecord->GetInt(i, j));
                                }
                                break;
                            case TDATA_FLOAT:
                                {
                                    NFMsg::RecordFloat* xRecordFloat = xRecordData.add_record_float_list();
                                    xRecordFloat->set_row(i);
                                    xRecordFloat->set_col(j);
                                    xRecordFloat->set_data(xRecord->GetFloat(i, j));
                                }
                                break;
                            case TDATA_STRING:
                                {
                                    NFMsg::RecordString* xRecordString = xRecordData.add_record_string_list();
                                    xRecordString->set_row(i);
                                    xRecordString->set_col(j);
                                    xRecordString->set_data(xRecord->GetString(i, j));
                                }
                                break;
                            case TDATA_OBJECT:
                                {
                                    NFMsg::RecordObject* xRecordObejct = xRecordData.add_record_object_list();
                                    xRecordObejct->set_row(i);
                                    xRecordObejct->set_col(j);
                                    *xRecordObejct->mutable_data() = NFINetModule::NFToPB(xRecord->GetObject(i, j));
                                }
                                break;
                            default:
                                break;
                            }
                        }   
                    }
                }

                std::string strRecordValue;
                if(xRecordData.SerializeToString(&strRecordValue))
                {
                    vFieldVec.push_back(strName);
                    vValueVec.push_back(strRecordValue);
                }
            }

            strName.clear();
            xRecord = pRecordManager->Next(strName);
        }

        const std::string& strClass = m_pKernelModule->GetPropertyString(self, "ClassName");
        if(!m_pClusterSQLModule->Updata(strClass, self.ToString(), vFieldVec, vValueVec))
        {
            return false;
        }

        return true;
    }

    return false;
}