Example #1
0
const std::string& NFRecordManager::GetRecordString(const std::string& strRecordName, const int nRow, const int nCol)
{
    NF_SHARE_PTR<NFIRecord> pRecord = GetElement(strRecordName);
    if (pRecord)
    {
        return pRecord->GetString(nRow, nCol);
    }

    return NULL_STR;
}
bool NFCHeroPropertyModule::CalHeroTalentProperty(const NFGUID& self, const NFGUID& xHeroGUID, NFIDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_PlayerHero());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

	NFCDataList varFind;
	if (pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, xHeroGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int(0);

	NF_SHARE_PTR<NFIRecord> pHeroPropertyRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_HeroPropertyValue());
	if (nullptr == pHeroPropertyRecord)
	{
		return false;
	}

	////////////////////Talent//////////////////////////////////////////////////////
	xDataList.Clear();

	for (int i = 0; i < pHeroPropertyRecord->GetCols(); ++i)
	{
		xDataList.AddInt(0);
	}

	for (int i = NFrame::Player::PlayerHero_Talent1; i <= NFrame::Player::PlayerHero_Talent5; ++i)
	{
		const std::string& strTalentID = pHeroRecord->GetString(nRow, i);
		const std::string& strTalentEffectData = m_pElementModule->GetPropertyString(strTalentID, NFrame::Talent::EffectData());
		if (!strTalentEffectData.empty())
		{
			//one talent
			for (int j = 0; j < pHeroPropertyRecord->GetCols(); ++j)
			{
				const std::string& strColTag = pHeroPropertyRecord->GetColTag(j);
				int nValue = m_pElementModule->GetPropertyInt(strTalentEffectData, strColTag);
				int nOldValue = xDataList.Int(j);

				xDataList.SetInt(j, nOldValue + nValue);
			}
		}
	}

	return true;
}
const std::string& NFCCommonConfigModule::GetFieldString(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->GetString(strAttribute);
		}
	}

	return NULL_STR;
}
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;
}
bool NFCHeroModule::CreateHero(const NFGUID& self, const NFGUID& xHeroID)
{
	if (xHeroID.IsNull())
	{
		return false;
	}

	const int nSceneID = m_pKernelModule->GetPropertyInt32(self, NFrame::Player::SceneID());
	const int nGroupID = m_pKernelModule->GetPropertyInt32(self, NFrame::Player::GroupID());
	E_SCENE_TYPE eSceneType = (E_SCENE_TYPE)m_pElementModule->GetPropertyInt(std::to_string(nSceneID), NFrame::Scene::Type());
	if (eSceneType == E_SCENE_TYPE::SCENE_TYPE_ERROR)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName());
	if (nullptr == pHeroRecord.get())
	{
		return false;
	}

	int nRow = pHeroRecord->FindObject(NFrame::Player::PlayerHero::GUID, xHeroID);
	if (nRow < 0)
	{
		return false;
	}

	const std::string& strConfigID = pHeroRecord->GetString(nRow, NFrame::Player::PlayerHero::ConfigID);

    NFDataList varList;

    int nCamp = m_pKernelModule->GetPropertyInt32(self, NFrame::Player::Camp());
    varList << NFrame::NPC::Camp() << nCamp;
    varList << NFrame::NPC::MasterID() << self;

	NF_SHARE_PTR<NFIObject> pHero = m_pKernelModule->CreateObject(xHeroID, nSceneID, nGroupID, NFrame::NPC::ThisName(), strConfigID, NFDataList());
    if (!pHero)
    {
        return false;
    }
	return true;
}
bool NFCEquipPropertyModule::CalEquipRandomProperty(const NFGUID& self, const NFGUID& xEquipGUID, NFDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pBagRecord = m_pKernelModule->FindRecord(self, NFrame::Player::BagEquipList::ThisName());
	if (nullptr == pBagRecord)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pCommPropertyValueRecord = m_pKernelModule->FindRecord(self, NFrame::Player::CommValue::ThisName());
	if (nullptr == pCommPropertyValueRecord)
	{
		return false;
	}

	NFDataList varFind;
	if (pBagRecord->FindObject(NFrame::Player::BagEquipList::GUID, xEquipGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int32(0);
	xDataList.Clear();

	/////////////RandomBase/////////////////////////////////////////

	const std::string& strConfigID = pBagRecord->GetString(nRow, NFrame::Player::BagEquipList::BagEquipList::RandPropertyID);
	const std::string& strPropertyEffectData = m_pElementModule->GetPropertyString(strConfigID, NFrame::Equip::EffectData());
	if (!strPropertyEffectData.empty())
	{
		for (int i = 0; i < pCommPropertyValueRecord->GetCols(); ++i)
		{
			const std::string& strColTag = pCommPropertyValueRecord->GetColTag(i);
			int64_t nValue = m_pElementModule->GetPropertyInt(strPropertyEffectData, strColTag);
			xDataList.AddInt(nValue);
		}
	}

	return true;
}
bool NFCHeroPropertyModule::CalHeroBaseProperty(const NFGUID& self, const NFGUID& xHeroGUID, NFIDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_PlayerHero());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

	NFCDataList varFind;
	if (pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, xHeroGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int(0);

	NF_SHARE_PTR<NFIRecord> pHeroPropertyRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_HeroPropertyValue());
	if (nullptr == pHeroPropertyRecord)
	{
		return false;
	}

	/////////////PropertyBase/////////////////////////////////////////
	xDataList.Clear();

	const std::string& strConfigID = pHeroRecord->GetString(nRow, NFrame::Player::PlayerHero::PlayerHero_ConfigID);
	const std::string& strPropertyEffectData = m_pElementModule->GetPropertyString(strConfigID, NFrame::NPC::EffectData());
	if (!strPropertyEffectData.empty())
	{
		for (int i = 0; i < pHeroPropertyRecord->GetCols(); ++i)
		{
			const std::string& strColTag = pHeroPropertyRecord->GetColTag(i);
			int nValue = m_pElementModule->GetPropertyInt(strPropertyEffectData, strColTag);
			xDataList.AddInt(nValue);
		}
	}

	return true;
}
bool NFCHeroModule::HeroWearSkill(const NFGUID& self, const NFGUID& xHeroID, const std::string& xSkillID)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName());
	if (nullptr == pHeroRecord.get())
	{
		return false;
	}

	if (xHeroID.IsNull())
	{
		return false;
	}

	int nRow = pHeroRecord->FindObject(NFrame::Player::PlayerHero::GUID, xHeroID);
	if (nRow < 0)
	{
		return false;
	}

	bool bOwner = false;
	for (int i = NFrame::Player::PlayerHero::Skill1; i < NFrame::Player::PlayerHero::Skill5; ++i)
	{
		const std::string& strOwnerSkillID = pHeroRecord->GetString(nRow, i);
		if (strOwnerSkillID == xSkillID)
		{
			bOwner = true;
			break;
		}
	}

	if (bOwner)
	{
		pHeroRecord->SetString(nRow, NFrame::Player::PlayerHero::FightSkill, xSkillID);
		return true;
	}

	return false;
}
int NFCSLGBuildingModule::CostProduceData( 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);

    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");
            pProduce->SetInt(i, "LeftCount", nOldCount - nCount);
        }
    }

    return 0;
}
bool NFCHeroModule::HeroTalentUp(const NFGUID& self, const NFGUID& xHeroID, const int nIndex)
{
	if (xHeroID.IsNull())
	{
		return false;
	}

	if (nIndex > NFrame::Player::PlayerHero::Talent5 && nIndex < NFrame::Player::PlayerHero::Talent1)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

	int nRow = pHeroRecord->FindObject(NFrame::Player::PlayerHero::GUID, xHeroID);
	if (nRow < 0)
	{
		return false;
	}

	const std::string& strTalentID = pHeroRecord->GetString(nRow, nIndex);
	const std::string& strNextTalentID = m_pElementModule->GetPropertyString(strTalentID, NFrame::Talent::NextID());
	if (strNextTalentID.empty())
	{
		//no next talent id, this skill is the best talent
		return false;
	}

	pHeroRecord->SetString(nRow, nIndex, strNextTalentID);

	return true;
}
bool NFCEquipPropertyModule::CalEquipIntensifyProperty(const NFGUID& self, const NFGUID& xEquipGUID, NFDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pBagRecord = m_pKernelModule->FindRecord(self, NFrame::Player::BagEquipList::ThisName());
	if (nullptr == pBagRecord)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pCommPropertyValueRecord = m_pKernelModule->FindRecord(self, NFrame::Player::CommValue::ThisName());
	if (nullptr == pCommPropertyValueRecord)
	{
		return false;
	}

	NFDataList varFind;
	if (pBagRecord->FindObject(NFrame::Player::BagEquipList::GUID, xEquipGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int32(0);
	xDataList.Clear();

	/////////////GemBase/////////////////////////////////////////
	const int nIntensify = pBagRecord->GetInt32(nRow, NFrame::Player::BagEquipList::IntensifyLevel);
	if (nIntensify <= 0)
	{
		return false;
	}

	const std::string& strEquipConfig = pBagRecord->GetString(nRow, NFrame::Player::BagEquipList::ConfigID);
	//const int nHeroType = m_pElementModule->GetPropertyInt32(strEquipConfig, NFrame::Item::HeroTye());
	const int nItemType = m_pElementModule->GetPropertyInt32(strEquipConfig, NFrame::Item::ItemType());
	const int nItemSubType = m_pElementModule->GetPropertyInt32(strEquipConfig, NFrame::Item::ItemSubType());
	if (nItemType != NFMsg::EItemType::EIT_EQUIP)
	{
		return false;
	}

	for (int i = 0; i < pCommPropertyValueRecord->GetCols(); ++i)
	{
		xDataList.AddInt(0);
	}

	//conditional the item type to define what property to give
	double dwCoefficientAtk = 2.0;
	double dwCoefficientDef = 1.0;
	int nMAXHPValue = nIntensify * nIntensify;
	int nAttackValue = nIntensify * nIntensify;
	int nDefValue = nIntensify * nIntensify;

	if (nItemSubType == NFMsg::EGameEquipSubType::EQUIPTYPE_WEAPON)
	{
		nAttackValue *= dwCoefficientAtk;
	}
	else
	{
		nDefValue *= dwCoefficientDef;
	}

	xDataList.SetInt(NFrame::Player::CommValue::MAXHP, nMAXHPValue);
	xDataList.SetInt(NFrame::Player::CommValue::ATK_VALUE, nAttackValue);
	xDataList.SetInt(NFrame::Player::CommValue::DEF_VALUE, nDefValue);

	return true;
}
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;
}
Example #13
0
bool NFCTeamModule::GetTeamInfo(const NFGUID& self, const NFGUID& xTeam, NFMsg::TeamInfo& xTeamInfo)
{
    if (xTeam.IsNull())
    {
        return false;
    }

    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pCommonRedisModule->GetCachePropertyInfo(xTeam, NFrame::Team::ThisName());
    NF_SHARE_PTR<NFIRecordManager> pRecordManager = m_pCommonRedisModule->GetCacheRecordInfo(xTeam, NFrame::Team::ThisName());

    if (!pPropertyManager)
    {
        return false;
    }

    if (!pRecordManager)
    {
        return false;
    }

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

    NFGUID xCaptain = pPropertyManager->GetPropertyObject(NFrame::Team::Captain());
    if (!xCaptain.IsNull())
    {
        return false;
    }

    *xTeamInfo.mutable_team_id() = NFINetModule::NFToPB(xTeam);
    *xTeamInfo.mutable_captain_id() = NFINetModule::NFToPB(xCaptain);

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

        NFMsg::TeammemberInfo* pMemberinfo = xTeamInfo.add_teammemberinfo();
        if (!pMemberinfo)
        {
            continue;
        }


        std::string strName = pMemberRecord->GetString(i, NFrame::Team::MemberList::Name);
        const int nLevel = pMemberRecord->GetInt32(i, NFrame::Team::MemberList::Level);
        const int nJob = pMemberRecord->GetInt32(i, NFrame::Team::MemberList::Job);
        const NFGUID xPlayerID = pMemberRecord->GetObject(i, NFrame::Team::MemberList::GUID);

        pMemberinfo->set_name(strName);
        pMemberinfo->set_nlevel(nLevel);
        pMemberinfo->set_job(nJob);
        pMemberinfo->set_headicon("");
        *pMemberinfo->mutable_player_id() = NFINetModule::NFToPB(xPlayerID);
    }

    return true;
}
int NFCPotionItemConsumeProcessModule::ConsumeProcess( const NFIDENTID& self, const std::string& strItemName, const NFIDataList& other )
{
    //附加效果

    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementInfoModule->GetPropertyManager( strItemName );
    if ( pPropertyManager )
    {
        NF_SHARE_PTR<NFIProperty> pItemEffectProperty = pPropertyManager->GetElement( "EffectProperty" );
        NF_SHARE_PTR<NFIProperty> pItemEffectValue = pPropertyManager->GetElement( "EffectValue" );
        if ( pItemEffectProperty && pItemEffectValue )
        {
            NFCDataList valueEffectProperty( pItemEffectProperty->GetString().c_str(), "," );
            NFCDataList valueEffectValue( pItemEffectValue->GetString().c_str(), "," );
            if ( valueEffectProperty.GetCount() == valueEffectValue.GetCount() )
            {
                for ( int i = 0; i < valueEffectProperty.GetCount(); i++ )
                {
                    //先测定目标是否有此属性(其实是担心配错了)
                    for ( int j = 0; j < other.GetCount(); j++ )
                    {
                        NFIDENTID identOther = other.Object( j );
                        if ( !identOther.IsNull() )
                        {
                            NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( identOther );
                            if ( pObject )
                            {
                                std::string strCurProperty = valueEffectProperty.String( i );
                                std::string strMaxProperty = "MAX" + strCurProperty;
                                NF_SHARE_PTR<NFIProperty> pOtherCurProperty = pObject->GetPropertyManager()->GetElement( strCurProperty );
                                NF_SHARE_PTR<NFIProperty> pOtherMaxProperty = pObject->GetPropertyManager()->GetElement( strMaxProperty );
                                if ( pOtherCurProperty && pOtherMaxProperty )
                                {
                                    //药物,只能是绝对值,百分比不要了,百分比让BUFF去做
                                    //而且,只有最大值的那种,才能使用,因此,这里只能有 HP MP CSP 3样属性
                                    //重要的是,不能超过最大值,这几个属性那个都是整型数据
                                    //类似最大HP之类的,不能通过药剂直接修改属性,而是通过BUFF来修改,只要是分层属性都通过BUFF修改
                                    int nAddValue = boost::lexical_cast<int>( valueEffectValue.String( i ) );

                                    if ( "EXP" == strCurProperty )
                                    {
                                        m_pLevelModule->AddExp( self, nAddValue );
                                    }
                                    else if ( "HP" == strCurProperty )
                                    {
                                        m_pPropertyModule->AddHP( self, nAddValue );
                                    }
                                    else if ( "MP" == strCurProperty )
                                    {
                                        m_pPropertyModule->AddMP( self, nAddValue );
                                    }
                                }
                                else
                                {
                                    m_pLogModule->LogProperty(NFILogModule::NLL_ERROR_NORMAL, self, strCurProperty, "", __FUNCTION__, __LINE__);
                                    return 0;
                                }
                            }
                        }
                    }
                }

                return other.GetCount();
            }
        }
    }

    m_pLogModule->LogProperty(NFILogModule::NLL_ERROR_NORMAL, self, strItemName, "", __FUNCTION__, __LINE__);


    return 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;
}
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;
}
bool NFCEquipPropertyModule::CalEquipGemProperty(const NFGUID& self, const NFGUID& xEquipGUID, NFDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pBagRecord = m_pKernelModule->FindRecord(self, NFrame::Player::BagEquipList::ThisName());
	if (nullptr == pBagRecord)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pCommPropertyValueRecord = m_pKernelModule->FindRecord(self, NFrame::Player::CommValue::ThisName());
	if (nullptr == pCommPropertyValueRecord)
	{
		return false;
	}

	NFDataList varFind;
	if (pBagRecord->FindObject(NFrame::Player::BagEquipList::GUID, xEquipGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int32(0);
	xDataList.Clear();

	/////////////GemBase/////////////////////////////////////////
	int nSlotCount = pBagRecord->GetInt32(nRow, NFrame::Player::BagEquipList::SlotCount);
	if (nSlotCount <= 0)
	{
		return false;
	}

	for (int i = 0; i < pCommPropertyValueRecord->GetCols(); ++i)
	{
		xDataList.AddInt(0);
	}

	for (int i = NFrame::Player::BagEquipList::InlayStone1; i <= NFrame::Player::BagEquipList::InlayStone10; ++i)
	{
		int nIndex = i - NFrame::Player::BagEquipList::InlayStone1;
		if (nIndex > nSlotCount)
		{
			break;
		}

		const std::string& strGemID = pBagRecord->GetString(nRow, i);
		if (strGemID.empty())
		{
			continue;
		}

		const std::string& strGemEffectData = m_pElementModule->GetPropertyString(strGemID, NFrame::Item::EffectData());
		if (strGemEffectData.empty())
		{
			continue;
		}

		//one gem
		for (int j = 0; j < pCommPropertyValueRecord->GetCols(); ++j)
		{
			const std::string& strColTag = pCommPropertyValueRecord->GetColTag(j);
			int64_t nValue = m_pElementModule->GetPropertyInt(strGemEffectData, strColTag);
			int64_t nOldValue = xDataList.Int(j);

			xDataList.SetInt(j, nOldValue + nValue);
		}
	}

	return true;
}
bool NFCEquipPropertyModule::CalEquipElementProperty(const NFGUID& self, const NFGUID& xEquipGUID, NFDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pBagRecord = m_pKernelModule->FindRecord(self, NFrame::Player::BagEquipList::ThisName());
	if (nullptr == pBagRecord)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pCommPropertyValueRecord = m_pKernelModule->FindRecord(self, NFrame::Player::CommValue::ThisName());
	if (nullptr == pCommPropertyValueRecord)
	{
		return false;
	}

	NFDataList varFind;
	if (pBagRecord->FindObject(NFrame::Player::BagEquipList::GUID, xEquipGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int32(0);
	xDataList.Clear();

	/////////////element/////////////////////////////////////////
	const std::string& strEquipConfig = pBagRecord->GetString(nRow, NFrame::Player::BagEquipList::ConfigID);
	//const int nHeroType = m_pElementModule->GetPropertyInt32(strEquipConfig, NFrame::Item::HeroTye());
	const int nItemType = m_pElementModule->GetPropertyInt32(strEquipConfig, NFrame::Item::ItemType());
	const int nItemSubType = m_pElementModule->GetPropertyInt32(strEquipConfig, NFrame::Item::ItemSubType());
	if (nItemType != NFMsg::EItemType::EIT_EQUIP)
	{
		return false;
	}

	for (int i = 0; i < pCommPropertyValueRecord->GetCols(); ++i)
	{
		xDataList.AddInt(0);
	}

	//conditional the item type to define what property to give
	double dwCoefficientAtk = 2.0;
	double dwCoefficientDef = 1.0;
	int nFireLevel = pBagRecord->GetInt32(nRow, NFrame::Player::BagEquipList::ElementLevel1_FIRE);
	int nLightLevel = pBagRecord->GetInt32(nRow, NFrame::Player::BagEquipList::ElementLevel2_LIGHT);
	int nWindLevel = pBagRecord->GetInt32(nRow, NFrame::Player::BagEquipList::ElementLevel3_Wind);
	int nIceLevel = pBagRecord->GetInt32(nRow, NFrame::Player::BagEquipList::ElementLevel4_ICE);
	int nPoisonLevel = pBagRecord->GetInt32(nRow, NFrame::Player::BagEquipList::ElementLevel5_POISON);

	int nWindValue = nWindLevel * nWindLevel;
	int nFireValue = nFireLevel * nFireLevel;
	int nLightValue = nLightLevel * nLightLevel;
	int nIceValue = nIceLevel * nIceLevel;
	int nPoisonValue = nPoisonLevel * nPoisonLevel;

	if (nItemSubType == NFMsg::EGameEquipSubType::EQUIPTYPE_WEAPON)
	{
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nWindValue * dwCoefficientAtk);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nFireValue * dwCoefficientAtk);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nLightValue * dwCoefficientAtk);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nIceValue * dwCoefficientAtk);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nPoisonValue * dwCoefficientAtk);
	}
	else
	{
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nWindValue * dwCoefficientDef);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nFireValue * dwCoefficientDef);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nLightValue * dwCoefficientDef);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nIceValue * dwCoefficientDef);
		xDataList.SetInt(NFrame::Player::CommValue::ATK_FIRE, nPoisonValue * dwCoefficientDef);
	}



	return true;

	return true;
}
Example #19
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;
}