bool NFCHeroModule::HeroStarUp(const NFGUID& self, const NFGUID& xHeroID)
{
	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;
	}

	const int nBeforeStar = pHeroRecord->GetInt32(nRow, NFrame::Player::PlayerHero::Star);

	int nAfterStar = nBeforeStar + 1;
	if (nAfterStar > ECONSTDEFINE_HERO_MAXSTAR)
	{
		nAfterStar = ECONSTDEFINE_HERO_MAXSTAR;
	}

	pHeroRecord->SetInt(nRow, NFrame::Player::PlayerHero::Star, nAfterStar);

	return true;
}
bool NFCHeroModule::SetFightHero(const NFGUID& self, const NFGUID& xHeroID, const int nPos)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

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

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

	int nActivite = pHeroRecord->GetInt32(nRow, NFrame::Player::PlayerHero::Activated);
	if (nActivite <= 0)
	{
		return false;
	}

	AddToFightList(self, xHeroID, nPos);


	return false;
}
示例#3
0
bool NFCPackModule::CreateItemInTempBag(const NFGUID & self, const std::string & strConfigName, const int nCount)
{
	NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord(self, NFrame::Player::TempItemList::ThisName());
	if (nullptr == pRecord)
	{
		return false;
	}

	NFDataList varFindResult;
	int nFindRowCount = pRecord->FindString(NFrame::Player::TempItemList::ConfigID, strConfigName, varFindResult);
	if (nFindRowCount <= 0)
	{
		NF_SHARE_PTR<NFDataList> xRowData = pRecord->GetInitData();

		xRowData->SetString(NFrame::Player::TempItemList::ConfigID, strConfigName);
		xRowData->SetInt(NFrame::Player::TempItemList::ItemCount, nCount);

		pRecord->AddRow(-1, *xRowData);
	}
	else
	{
		int nFindRow = varFindResult.Int32(0);
		int nOldCount = pRecord->GetInt32(nFindRow, NFrame::Player::TempItemList::ItemCount);
		int nNewCount = nOldCount + nCount;
		pRecord->SetInt(nFindRow, NFrame::Player::TempItemList::ItemCount, nNewCount);
	}

	return true;
}
示例#4
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::BagItemList::ThisName() );
	if (!pRecord)
	{
		return false;
	}

	NFDataList 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.Int32(i);
			int nOldCount = pRecord->GetInt32(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;
}
示例#5
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::BagItemList::ThisName() );
    if (!pRecord)
    {
        return false;
    }

	NFDataList 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.Int32(i);
			int nOldCount = pRecord->GetInt32(nFindRow, NFrame::Player::BagItemList::ItemCount);
			nTotalCount += nOldCount;
		}

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

    return false;
}
示例#6
0
int NFPropertyModule::OnRecordEvent(const NFGUID& self, const RECORD_EVENT_DATA& xEventData, const NFData& oldVar, const NFData& 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::CommValue::ThisName());
    for (int i = 0; i < (int)(NFPropertyGroup::NPG_ALL); i++)
    {
        if (i < pRecord->GetRows())
        {
            int nValue = pRecord->GetInt32(i, nCol);
            nAllValue += nValue;
        }
    }

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

    return 0;
}
示例#7
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;
}
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;
}
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;
}
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;
}