bool HelloWorld3Module::AfterInit() { //初始化完毕 std::cout << "Hello, world3, AfterInit" << std::endl; m_pKernelModule = dynamic_cast<NFIKernelModule*>(pPluginManager->FindModule("NFCKernelModule")); m_pEventProcessModule = dynamic_cast<NFIEventProcessModule*>(pPluginManager->FindModule("NFCEventProcessModule")); m_pElementInfoModule = dynamic_cast<NFIElementInfoModule*>(pPluginManager->FindModule("NFCElementInfoModule")); //创建容器,所有的对象均需在容器中 m_pKernelModule->CreateContainer(1, ""); m_pEventProcessModule->AddClassCallBack("Player", this, &HelloWorld3Module::OnClassCallBackEvent); //创建对象,挂类回调和属性回调,然后事件处理对象 NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->CreateObject(NFIDENTID(0, 10), 1, 0, "Player", "", NFCDataList()); if (!pObject.get()) { return false; } pObject->GetPropertyManager()->AddProperty(pObject->Self(), "Hello", TDATA_STRING, true, true, true, true, 0, ""); pObject->GetPropertyManager()->AddProperty(pObject->Self(), "World", TDATA_INT, true, true, true, true, 0, ""); pObject->AddPropertyCallBack("Hello", this, &HelloWorld3Module::OnPropertyStrCallBackEvent); pObject->AddPropertyCallBack("World", this, &HelloWorld3Module::OnPropertyCallBackEvent); pObject->SetPropertyString("Hello", "hello,World"); pObject->SetPropertyInt("World", 1111); m_pEventProcessModule->DoEvent(pObject->Self(), 11111111, NFCDataList() << int(100) << "200"); return true; }
bool NFCClassModule::AddPropertys(rapidxml::xml_node<>* pPropertyRootNode, NF_SHARE_PTR<NFIClass> pClass) { for (rapidxml::xml_node<>* pPropertyNode = pPropertyRootNode->first_node(); pPropertyNode; pPropertyNode = pPropertyNode->next_sibling()) { if (pPropertyNode) { const char* strPropertyName = pPropertyNode->first_attribute("Id")->value(); if (pClass->GetPropertyManager()->GetElement(strPropertyName)) { //error NFASSERT(0, strPropertyName, __FILE__, __FUNCTION__); continue; } const char* pstrType = pPropertyNode->first_attribute("Type")->value(); const char* pstrPublic = pPropertyNode->first_attribute("Public")->value(); const char* pstrPrivate = pPropertyNode->first_attribute("Private")->value(); const char* pstrSave = pPropertyNode->first_attribute("Save")->value(); const char* pstrCache = pPropertyNode->first_attribute("Cache")->value(); const char* pstrRef = pPropertyNode->first_attribute("Ref")->value(); const char* pstrUpload = pPropertyNode->first_attribute("Upload")->value(); bool bPublic = lexical_cast<bool>(pstrPublic); bool bPrivate = lexical_cast<bool>(pstrPrivate); bool bSave = lexical_cast<bool>(pstrSave); bool bCache = lexical_cast<bool>(pstrCache); bool bRef = lexical_cast<bool>(pstrRef); bool bUpload = lexical_cast<bool>(pstrUpload); NFData varProperty; if (TDATA_UNKNOWN == ComputerType(pstrType, varProperty)) { //std::cout << "error:" << pClass->GetTypeName() << " " << pClass->GetInstancePath() << ": " << strPropertyName << " type error!!!" << std::endl; NFASSERT(0, strPropertyName, __FILE__, __FUNCTION__); } //printf( " Property:%s[%s]\n", pstrPropertyName, pstrType ); NF_SHARE_PTR<NFIProperty> xProperty = pClass->GetPropertyManager()->AddProperty(NFGUID(), strPropertyName, varProperty.GetType()); xProperty->SetPublic(bPublic); xProperty->SetPrivate(bPrivate); xProperty->SetSave(bSave); xProperty->SetCache(bCache); xProperty->SetRef(bRef); xProperty->SetUpload(bUpload); } } return true; }
int NFCPropertyTrailModule::TrailObjectData(const NFGUID& self) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (nullptr == xObject) { return -1; } NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = xObject->GetPropertyManager(); if (nullptr != xPropertyManager) { NF_SHARE_PTR<NFIProperty> xProperty = xPropertyManager->First(); while (nullptr != xProperty) { m_pKernelModule->AddPropertyCallBack(self, xProperty->GetKey(), this, &NFCPropertyTrailModule::OnObjectPropertyEvent); xProperty = xPropertyManager->Next(); } } NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); if (nullptr != xRecordManager) { NF_SHARE_PTR<NFIRecord> xRecord = xRecordManager->First(); while (nullptr != xRecord) { m_pKernelModule->AddRecordCallBack(self, xRecord->GetName(), this, &NFCPropertyTrailModule::OnObjectRecordEvent); xRecord = xRecordManager->Next(); } } return 0; }
void NFCCreateRoleModule::SaveData(const NFGUID & self) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (xObject) { NF_SHARE_PTR<NFIPropertyManager> xPropManager = xObject->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); NFMsg::RoleDataPack xDataPack; *xDataPack.mutable_id() = NFINetModule::NFToPB(self); *(xDataPack.mutable_property()->mutable_player_id()) = NFINetModule::NFToPB(self); *(xDataPack.mutable_record()->mutable_player_id()) = NFINetModule::NFToPB(self); if (xPropManager) { ConvertPropertyManagerToPB(xPropManager, xDataPack.mutable_property()); } if (xRecordManager) { ConvertRecordManagerToPB(xRecordManager, xDataPack.mutable_record()); } m_pNetClientModule->SendSuitByPB(NF_SERVER_TYPES::NF_ST_DB, self.GetData(), NFMsg::EGMI_REQ_SAVE_ROLE_DATA, xDataPack); } }
void NFCCreateRoleModule::AttachData(const NFGUID & self) { auto it = mxObjectDataCache.find(self); if (it != mxObjectDataCache.end()) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (xObject) { NF_SHARE_PTR<NFIPropertyManager> xPropManager = xObject->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); if (xPropManager) { ConvertPBToPropertyManager(it->second.property(), xPropManager); } if (xRecordManager) { ConvertPBToRecordManager(it->second.record(), xRecordManager); } mxObjectDataCache.erase(it); } } }
NF_SHARE_PTR<NFIPropertyManager> NFCElementInfoModule::GetPropertyManager(const std::string& strConfigName) { NF_SHARE_PTR<ElementConfigInfo> pElementInfo = GetElement(strConfigName); if (pElementInfo.get()) { return pElementInfo->GetPropertyManager(); } return NULL; }
NF_SHARE_PTR<NFIPropertyManager> NFCClassModule::GetClassPropertyManager(const std::string& strClassName) { NF_SHARE_PTR<NFIClass> pClass = GetElement(strClassName); if (pClass) { return pClass->GetPropertyManager(); } return NULL; }
int NFCPropertyTrailModule::LogObjectData(const NFGUID& self) { NF_SHARE_PTR<NFIObject> xObject = m_pKernelModule->GetObject(self); if (nullptr == xObject) { return -1; } NF_SHARE_PTR<NFIPropertyManager> xPropertyManager = xObject->GetPropertyManager(); if (nullptr != xPropertyManager) { NF_SHARE_PTR<NFIProperty> xProperty = xPropertyManager->First(); while (nullptr != xProperty) { std::ostringstream stream; stream << " Start trail "; stream << xProperty->ToString(); m_pLogModule->LogProperty(NFILogModule::NF_LOG_LEVEL::NLL_INFO_NORMAL, self, xProperty->GetKey(), stream.str(), __FUNCTION__, __LINE__); xProperty = xPropertyManager->Next(); } } NF_SHARE_PTR<NFIRecordManager> xRecordManager = xObject->GetRecordManager(); if (nullptr != xRecordManager) { NF_SHARE_PTR<NFIRecord> xRecord = xRecordManager->First(); while (nullptr != xRecord) { for (int i = 0; i < xRecord->GetRows(); ++i) { NFCDataList xDataList; bool bRet = xRecord->QueryRow(i, xDataList); if (bRet) { std::ostringstream stream; stream << " Start trail Row[" << i << "]"; for (int j = 0; j < xDataList.GetCount(); ++j) { stream << " [" << j << "] " << xDataList.StringValEx(j); } m_pLogModule->LogRecord(NFILogModule::NF_LOG_LEVEL::NLL_INFO_NORMAL, self, xRecord->GetName(), stream.str(), __FUNCTION__, __LINE__); } } xRecord = xRecordManager->Next(); } } return 0; }
bool NFCElementModule::ExistElement(const std::string& strClassName, const std::string& strConfigName) { NF_SHARE_PTR<ElementConfigInfo> pElementInfo = GetElement(strConfigName); if (!pElementInfo) { return false; } const std::string& strClass = pElementInfo->GetPropertyManager()->GetPropertyString("ClassName"); if (strClass != strClassName) { return false; } return true; }
int NFCNPCRefreshModule::OnObjectClassEvent( const NFGUID& self, const std::string& strClassName, const CLASS_OBJECT_EVENT eClassEvent, const NFIDataList& var ) { NF_SHARE_PTR<NFIObject> pSelf = m_pKernelModule->GetObject(self); if (nullptr == pSelf) { return 1; } if (strClassName == NFrame::NPC::ThisName()) { if ( CLASS_OBJECT_EVENT::COE_CREATE_LOADDATA == eClassEvent ) { const std::string& strConfigIndex = m_pKernelModule->GetPropertyString(self, NFrame::NPC::ConfigID()); const std::string& strPropertyID = m_pElementInfoModule->GetPropertyString(strConfigIndex, NFrame::NPC::EffectData()); NF_SHARE_PTR<NFIPropertyManager> pConfigPropertyManager = m_pElementInfoModule->GetPropertyManager(strPropertyID); if (pConfigPropertyManager) { std::string strProperName; NF_SHARE_PTR<NFIPropertyManager> pSelfPropertyManager = pSelf->GetPropertyManager(); for (NFIProperty* pProperty = pConfigPropertyManager->FirstNude(strProperName); pProperty != NULL; pProperty = pConfigPropertyManager->NextNude(strProperName)) { if (pSelfPropertyManager && strProperName != NFrame::NPC::ID()) { pSelfPropertyManager->SetProperty(pProperty->GetKey(), pProperty->GetValue()); } } } } if ( CLASS_OBJECT_EVENT::COE_CREATE_HASDATA == eClassEvent ) { const std::string& strConfigID = m_pKernelModule->GetPropertyString(self, NFrame::NPC::ConfigID()); int nHPMax = m_pElementInfoModule->GetPropertyInt(strConfigID, NFrame::NPC::MAXHP()); m_pKernelModule->SetPropertyInt(self, NFrame::NPC::HP(), nHPMax); m_pKernelModule->AddPropertyCallBack( self, NFrame::NPC::HP(), this, &NFCNPCRefreshModule::OnObjectHPEvent ); } } return 0; }
bool NFCElementModule::CheckRef() { NF_SHARE_PTR<NFIClass> pLogicClass = m_pClassModule->First(); while (pLogicClass) { NF_SHARE_PTR<NFIPropertyManager> pClassPropertyManager = pLogicClass->GetPropertyManager(); if (pClassPropertyManager) { NF_SHARE_PTR<NFIProperty> pProperty = pClassPropertyManager->First(); while (pProperty) { //if one property is ref,check every config if (pProperty->GetRef()) { NFList<std::string>& strIdList = pLogicClass->GetIdList(); std::string strId; for (bool bRet = strIdList.First(strId); bRet; bRet = strIdList.Next(strId)) { const std::string& strRefValue= this->GetPropertyString(strId, pProperty->GetKey()); if (!this->GetElement(strRefValue)) { std::string msg; msg.append("check ref failed id: ").append(strRefValue).append(" in ").append(pLogicClass->GetClassName()); NFASSERT(nRet, msg.c_str(), __FILE__, __FUNCTION__); exit(0); } } } pProperty = pClassPropertyManager->Next(); } } ////////////////////////////////////////////////////////////////////////// pLogicClass = m_pClassModule->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; }
bool NFCElementInfoModule::Load(rapidxml::xml_node<>* attrNode, NF_SHARE_PTR<NFILogicClass> pLogicClass) { //attrNode is the node of a object std::string strConfigID = attrNode->first_attribute("ID")->value(); if (strConfigID.empty()) { NFASSERT(0, strConfigID, __FILE__, __FUNCTION__); return false; } if (ExistElement(strConfigID)) { NFASSERT(0, strConfigID, __FILE__, __FUNCTION__); return false; } NF_SHARE_PTR<ElementConfigInfo> pElementInfo(NF_NEW ElementConfigInfo()); AddElement(strConfigID, pElementInfo); //can find all configid by class name pLogicClass->AddConfigName(strConfigID); //ElementConfigInfo* pElementInfo = CreateElement( strConfigID, pElementInfo ); NF_SHARE_PTR<NFIPropertyManager> pElementPropertyManager = pElementInfo->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> pElementRecordManager = pElementInfo->GetRecordManager(); //1.add property //2.set the default value of them NF_SHARE_PTR<NFIPropertyManager> pClassPropertyManager = pLogicClass->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> pClassRecordManager = pLogicClass->GetRecordManager(); if (pClassPropertyManager.get() && pClassRecordManager.get()) { NF_SHARE_PTR<NFIProperty> pProperty = pClassPropertyManager->First(); while (pProperty.get()) { pElementPropertyManager->AddProperty(NFGUID(), pProperty); pProperty = pClassPropertyManager->Next(); } NF_SHARE_PTR<NFIRecord> pRecord = pClassRecordManager->First(); while (pRecord.get()) { pElementRecordManager->AddRecord(NFGUID(), pRecord->GetName(), pRecord->GetInitData(), pRecord->GetKeyState(), pRecord->GetInitDesc(), pRecord->GetTag(), pRecord->GetRelatedRecord(), pRecord->GetRows(), pRecord->GetPublic(), pRecord->GetPrivate(), pRecord->GetSave(), pRecord->GetView(), pRecord->GetIndex()); pRecord = pClassRecordManager->Next(); } } //3.set the config value to them //const char* pstrConfigID = attrNode->first_attribute( "ID" ); for (rapidxml::xml_attribute<>* pAttribute = attrNode->first_attribute(); pAttribute; pAttribute = pAttribute->next_attribute()) { const char* pstrConfigName = pAttribute->name(); const char* pstrConfigValue = pAttribute->value(); //printf( "%s : %s\n", pstrConfigName, pstrConfigValue ); NF_SHARE_PTR<NFIProperty> temProperty = pElementPropertyManager->GetElement(pstrConfigName); if (!temProperty) { continue; } NFIDataList::TData var; TDATA_TYPE eType = temProperty->GetType(); switch (eType) { case TDATA_INT: { if (!LegalNumber(pstrConfigValue)) { NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); } var.SetInt(lexical_cast<NFINT64>(pstrConfigValue)); } break; case TDATA_FLOAT: { if (strlen(pstrConfigValue) <= 0) { NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); } var.SetFloat((double)atof(pstrConfigValue)); } break; case TDATA_STRING: var.SetString(pstrConfigValue); break; case TDATA_OBJECT: { if (strlen(pstrConfigValue) <= 0) { NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); } var.SetObject(NFGUID()); } break; default: NFASSERT(0, temProperty->GetKey(), __FILE__, __FUNCTION__); break; } pElementPropertyManager->SetProperty(pstrConfigName, var); } NFIDataList::TData xData; xData.SetString(pLogicClass->GetClassName()); pElementPropertyManager->SetProperty("ClassName", xData); 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; }
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; }
int NFCBriefSkillConsumeProcessModule::ConsumeProcess( const NFGUID& self, const std::string& strSkillName, const NFIDataList& other, NFIDataList& damageListValue, NFIDataList& damageResultList ) { NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementModule->GetPropertyManager( strSkillName ); if ( pPropertyManager == NULL ) { return 1; } // NFIProperty* pSkillDamageProperty = pPropertyManager->GetElement( "DamageProperty" ); // NFIProperty* pSkillDamageValue = pPropertyManager->GetElement( "DamageValue" ); // NFIProperty* pSkillDamageType = pPropertyManager->GetElement( "DamageType" ); // NFIProperty* pSkillDamageSubType = pPropertyManager->GetElement( "DamageSubType" ); // if ( pSkillDamageProperty == NULL || pSkillDamageValue == NULL || pSkillDamageType == NULL || pSkillDamageSubType == NULL ) // { // return 1; // } // // int nDamageType = pSkillDamageType->QueryInt(); // int nDamageSubType = pSkillDamageSubType->QueryInt(); // NFCDataList valueEffectProperty( pSkillDamageProperty->QueryString().c_str(), "," ); // NFCDataList valueEffectValue( pSkillDamageValue->QueryString().c_str(), "," ); // // if ( valueEffectProperty.GetCount() != valueEffectValue.GetCount() ) // { // return 1; // } //for ( int i = 0; i < valueEffectProperty.GetCount(); i++ ) { //先测定目标是否有此属性(其实是担心配错了) for ( int j = 0; j < other.GetCount(); j++ ) { NFGUID identOther = other.Object( j ); if ( identOther.IsNull() ) { continue; } NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( identOther ); if ( pObject == NULL ) { continue; } //短刀伤害,只能是HP,MP之类的有最大上限值的属性 // std::string strCurProperty = valueEffectProperty.StringVal( i ); // std::string strMaxProperty = "MAX" + strCurProperty; // NFIProperty* pOtherCurProperty = pObject->GetPropertyManager()->GetElement( strCurProperty ); // NFIProperty* pOtherMaxProperty = pObject->GetPropertyManager()->GetElement( strMaxProperty ); // if ( pOtherCurProperty == NULL || pOtherMaxProperty == NULL ) // { // continue; // } NF_SHARE_PTR<NFIProperty> pLastProperty = pObject->GetPropertyManager()->GetElement( "LastAttacker" ); if ( pLastProperty ) { pLastProperty->SetObject( self ); } } } //m_pKernelModule->LogErrorItem(strSkillName.c_str(), ""); return 0; }
const bool NFCObjectSaveModule::AttachData( const NFIDENTID& self ) { NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self); if (!pObject) { return false; } NF_SHARE_PTR<NFMapEx<std::string, std::string> > pSelfData = mtObjectCache.GetElement(self); if (!pSelfData) { return false; } NF_SHARE_PTR<NFIPropertyManager> pProManager = pObject->GetPropertyManager(); NF_SHARE_PTR<NFIRecordManager> pRecordManager = pObject->GetRecordManager(); //assign property value NF_SHARE_PTR<NFIProperty> xProperty = pProManager->First(strName); while (xProperty) { if (xProperty->GetSave()) { NF_SHARE_PTR<std::string> pValue = pSelfData->GetElement(strName); if (pValue) { const std::string& strData = *pValue; if (!xProperty->FromString(strData)) { m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, self, "Load Property fail " + strName , ": " + strData, __FUNCTION__, __LINE__); } else { m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, self, "Load Property success " + strName, ": " + strData, __FUNCTION__, __LINE__); } } } strName.clear(); xProperty = pProManager->Next(strName); } //assign record value NF_SHARE_PTR<NFIRecord> xRecord = pRecordManager->First(strName); while (xRecord) { if (xRecord->GetSave()) { NF_SHARE_PTR<std::string> pValue = pSelfData->GetElement(strName); if (pValue) { const std::string& strData = *pValue; NFMsg::PlayerRecordBase xRecordData; if (xRecordData.ParseFromString(strData) && xRecordData.record_name() == strName) { ConvertPBToRecord(xRecordData, xRecord); } } } strName.clear(); xRecord = pRecordManager->Next(strName); } mtObjectCache.RemoveElement(self); return true; }