Exemplo n.º 1
0
int NFCEctypeModule::AddEctypeAward(const NFIDENTID& self, const int nSceneID)
{
    std::string strSceneID = boost::lexical_cast<std::string>(nSceneID);
    int nType = m_pElementInfoModule->GetPropertyInt(strSceneID, "SceneType");

    int nAddMoney = 0;
	int nAddExp = 0;
	int nAddDiamnod = 0;
    NFCDataList xItemList;
    NFCDataList xCountList;

    // 掉落奖励
    m_pPackModule->DrawDropAward(self, nAddMoney, nAddExp, xItemList, xCountList);

    // 通关奖励

    // 通知客户端
    NFCDataList xAwardInfoList;
    xAwardInfoList << nAddMoney;
	xAwardInfoList << nAddExp;
	xAwardInfoList << nAddDiamnod;

    if (xItemList.GetCount() == xCountList.GetCount())
    {
        for (int i = 0; i < xItemList.GetCount(); ++i)
        {
            xAwardInfoList << xItemList.String(i);
            xAwardInfoList << xCountList.Int(i);
        }
    }

    m_pEventProcessModule->DoEvent(self, NFED_ON_NOTICE_ECTYPE_AWARD, xAwardInfoList);

    return 0;
}
Exemplo n.º 2
0
bool NFCProperty::DeSerialization()
{
	bool bRet = false;

	const TDATA_TYPE eType = GetType();
	if (eType == TDATA_STRING && nullptr != mxData && !mxData->IsNullValue())
	{
		NFCDataList xDataList;
		const std::string& strData = mxData->GetString();

		xDataList.Split(strData.c_str(), ";");
		if (xDataList.GetCount() <= 0)
		{
			return bRet;
		}

		NFCDataList xTemDataList;
		xTemDataList.Split(xDataList.String(0).c_str(), ",");
		const int nSubDataLength = xTemDataList.GetCount();

		if (xDataList.GetCount() == 1 && nSubDataLength == 1)
		{
			//most of property value only one value
			return bRet;
		}

		if (nullptr == mxEmbeddedList)
		{
			mxEmbeddedList = NF_SHARE_PTR<NFList<std::string>>(NF_NEW NFList<std::string>());
		}
		else
		{
			mxEmbeddedList->ClearAll();
		}

		for (int i = 0; i < xDataList.GetCount(); ++i)
		{
			if (xDataList.String(i).empty())
			{
				NFASSERT(0, strData, __FILE__, __FUNCTION__);
			}

			mxEmbeddedList->Add(xDataList.String(i));
		}



		////////////////////////////////////////

		if (nSubDataLength < 2 || nSubDataLength > 2)
		{
			return bRet;
		}

		if (nullptr == mxEmbeddedMap)
		{
			mxEmbeddedMap = NF_SHARE_PTR<NFMapEx<std::string, std::string>>(NF_NEW NFMapEx<std::string, std::string>());
		}
		else
		{
			mxEmbeddedMap->ClearAll();
		}

		for (int i = 0; i < xDataList.GetCount(); ++i)
		{
			NFCDataList xTemDataList;
			const std::string& strTemData = xDataList.String(i);
			xTemDataList.Split(strTemData.c_str(), ",");
			{
				if (xTemDataList.GetCount() != nSubDataLength)
				{
					NFASSERT(0, strTemData, __FILE__, __FUNCTION__);
				}

				const std::string& strKey = xTemDataList.String(0);
				const std::string& strValue = xTemDataList.String(1);

				if (strKey.empty() || strValue.empty())
				{
					NFASSERT(0, strTemData, __FILE__, __FUNCTION__);
				}

				mxEmbeddedMap->AddElement(strKey, NF_SHARE_PTR<std::string>(NF_NEW std::string(strValue)));
			}
		}

		bRet = true;
	}

	return bRet;
}