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; }
NFGUID NFCHeroModule::AddHero(const NFGUID& self, const std::string& strID) { NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName()); if (nullptr == pHeroRecord) { return NFGUID(); } int nRow = pHeroRecord->FindString(NFrame::Player::PlayerHero::ConfigID, strID); if (nRow >= 0) { return NFGUID(); } NF_SHARE_PTR<NFDataList> xRowData = pHeroRecord->GetInitData(); NFGUID xHeroID = m_pKernelModule->CreateGUID(); xRowData->SetObject(NFrame::Player::PlayerHero::GUID, xHeroID); xRowData->SetString(NFrame::Player::PlayerHero::ConfigID, strID); xRowData->SetInt(NFrame::Player::PlayerHero::Activated, 0); if (pHeroRecord->AddRow(-1, *xRowData) < 0) { return NFGUID(); } AddToFightList(self, xHeroID); return xHeroID; }
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; }
int NFCSkillModule::ExistSkill( const NFGUID& self, const std::string& strSkillName ) { NF_SHARE_PTR<NFIRecord> pRecord = m_pKernelModule->FindRecord( self, mstrSkillTableName ); if ( pRecord ) { NFCDataList varResult; pRecord->FindString( EGameSkillStoreType::EGSST_TYPE_SKILL_CONFIGID, strSkillName.c_str(), varResult ); if ( varResult.GetCount() == 1 ) { return varResult.Int( 0 ); } } return -1; }
NFGUID NFCHeroModule::GetHeroGUID(const NFGUID& self, const std::string& strID) { NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::PlayerHero::ThisName()); if (nullptr == pHeroRecord) { return NFGUID(); } int nRow = pHeroRecord->FindString(NFrame::Player::PlayerHero::ConfigID, strID); if (nRow < 0) { return NFGUID(); } return pHeroRecord->GetObject(nRow, NFrame::Player::PlayerHero::GUID); }
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; }
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; }