bool NFCPVPMatchRedisModule::GetStatusRoomID(const int nPVPMode, const int nGrade, const int nStatus, std::vector<NFGUID>& xRoomIDList)
{
	NF_SHARE_PTR<NFINoSqlDriver> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
    if (pNoSqlDriver)
    {
        std::string strKey = MakeStatusRoomIDRedisKey(nPVPMode, nGrade, nStatus);
        std::string strData;

        std::vector<std::string> valueVec;
        if (pNoSqlDriver->HValues(strKey, valueVec))
        {
            for (int i = 0; i < valueVec.size(); i++)
            {
                NFGUID xIdent;
                xIdent.FromString(valueVec[i]);
                if (!xIdent.IsNull())
                {
                    xRoomIDList.push_back(xIdent);
                }
            }

            return true;
        }
    }

    return false;
}
예제 #2
0
int NFCEquipModule::GetEquipHoleCount(const NFGUID & self, const NFGUID & id)
{
	if (id.IsNull() || self.IsNull())
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return false;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return false;
	}

	const int nRow = xDataList.Int(0);
	return pRecord->GetInt(nRow, NFrame::Player::BagEquipList_SlotCount);
}
예제 #3
0
NFGUID NFCPVPMatchModule::CreateRoom(const NFGUID& self, const int nPVPMode, const int nGrade)
{
    NFGUID xRoomID = m_pKernelModule->CreateGUID();
    if (xRoomID.IsNull())
    {
        return NFGUID();
    }

    NFMsg::PVPRoomInfo xRoomInfo;

    xRoomInfo.set_ncellstatus(0);
    *xRoomInfo.mutable_roomid() = NFINetModule::NFToPB(xRoomID);
    xRoomInfo.set_npvpmode(nPVPMode);
    xRoomInfo.set_npvpgrade(nGrade);

    int nPVPModeMaxMember = GetMemberCount(nPVPMode);
    if (nPVPModeMaxMember < 0)
    {
        return NFGUID();
    }

    xRoomInfo.set_maxpalyer(nPVPModeMaxMember);
    if (!m_pPVPMatchRedisModule->SetRoomInfo(xRoomID, xRoomInfo))
    {
        return NFGUID();
    }

    return xRoomID;
}
bool NFCLoginNet_HttpServerModule::OnLogin(const NFHttpRequest& req)
{
	std::string strResponse;
	NFResponseLogin xResponsetLogin;

	NFRequestLogin xRequestLogin;
	ajson::load_from_buff(xRequestLogin, req.body.c_str());
	if (xRequestLogin.user.empty()
		|| xRequestLogin.password.empty())
	{
		xResponsetLogin.code = NFIResponse::ResponseType::RES_TYPE_FAILED;
		xResponsetLogin.jwt = "";

		ajson::string_stream ss;
		ajson::save_to(ss, xResponsetLogin);
		strResponse = ss.str();
	}
	else
	{
		NFGUID xGUIDKey = m_pKernelModule->CreateGUID();

		xResponsetLogin.code = NFIResponse::ResponseType::RES_TYPE_SUCCESS;
		xResponsetLogin.jwt = xGUIDKey.ToString();

		mToken[xRequestLogin.user] = xGUIDKey.ToString();

		ajson::string_stream ss;
		ajson::save_to(ss, xResponsetLogin);
		strResponse = ss.str();
	}

	return m_pHttpNetModule->ResponseMsg(req, strResponse, NFWebStatus::WEB_OK);
}
예제 #5
0
bool NFCEquipModule::DressEquipForHero(const NFGUID& self, const NFGUID& hero, const NFGUID& id)
{
	if (id.IsNull() || self.IsNull() || hero.IsNull())
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pBagRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pBagRecord)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pHeroRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_PlayerHero());
	if (!pHeroRecord)
	{
		return false;
	}

	NFCDataList xEquipDataList;
	pBagRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xEquipDataList);
	if (xEquipDataList.GetCount() != 1)
	{
		return false;
	}

	NFCDataList xHeroDataList;
	pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, hero, xHeroDataList);
	if (xHeroDataList.GetCount() != 1)
	{
		return false;
	}

	const int nEquipRow = xEquipDataList.Int(0);
	const int nHeroRow = xHeroDataList.Int(0);
	const std::string& strEquipID = pBagRecord->GetString(nEquipRow, NFrame::Player::BagEquipList_ConfigID);
	const int nEquipPos = m_pElementModule->GetPropertyInt(strEquipID, NFrame::Equip::ItemSubType());

    if (nEquipRow < 0
		|| nHeroRow < 0
		|| strEquipID.empty()
		|| nEquipPos < 0
		|| nEquipPos > (NFrame::Player::PlayerHero_Equip6 - NFrame::Player::PlayerHero_Equip1))
    {
		return false;
    }

	//so there have any bind?
	//hero, position
	pHeroRecord->SetObject(nHeroRow, nEquipPos + NFrame::Player::PlayerHero_Equip1, id);
	pBagRecord->SetObject(nEquipRow, NFrame::Player::BagEquipList_WearGUID, hero);

    return false;
}
예제 #6
0
void NFCTeamModule::OnCreateTeamProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
	CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqAckCreateTeam);

	std::string strRoleName ;
	int nLevel = 0;
	int nJob = 0;
	int nDonation= 0;
	int nVIP= 0;

	NFGUID xTeam = CreateTeam(nPlayerID, NFINetModule::PBToNF(xMsg.team_id()), strRoleName, strRoleName, nLevel, nJob, nDonation, nVIP);

	if (!xTeam.IsNull())
	{
		NFMsg::ReqAckCreateTeam xAck;
		*xAck.mutable_team_id() = NFINetModule::NFToPB(xTeam);

        NFMsg::TeamInfo xTeamInfo;
        if (!GetTeamInfo(nPlayerID, xTeam, xTeamInfo))
        {
            xAck.mutable_xteaminfo()->CopyFrom(xTeamInfo);
            m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_TEAM, xAck, nSockIndex, nPlayerID);
            return;
        }
    }

    NFMsg::ReqAckCreateTeam xAck;
    *xAck.mutable_team_id() = NFINetModule::NFToPB(xTeam);

    m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_TEAM, xAck, nSockIndex, nPlayerID);
}
예제 #7
0
bool NFCTeamModule::BroadcastMsgToTeam(const NFGUID& self, const NFGUID& xTeam, const uint16_t nMsgID, google::protobuf::Message& xData)
{
    std::vector<std::string> xPlayerList;
    std::vector<int> xGameIDList;

    std::vector<NFGUID> xPlayerIDList;
    if (!GetMemberList(self, xTeam, xPlayerIDList))
    {
        return false;
    }

    for (int i = 0; i < xPlayerIDList.size(); i++)
    {
        xPlayerList.push_back(xPlayerIDList[i].ToString());
    }

    for (int i = 0; i < xGameIDList.size() && i < xPlayerList.size(); i++)
    {
        int nGameID = xGameIDList[i];
        NFGUID xPlayer;
        xPlayer.FromString(xPlayerList[i]);
        m_pWorldNet_ServerModule->SendMsgToGame(nGameID, (NFMsg::EGameMsgID)nMsgID, xData, xPlayer);
    }

    return true;
}
bool NFCPVPMatchRedisModule::GetPlayerRoomIDList(const std::vector<NFGUID>& xPlayerList, std::vector<NFGUID>& vecRoomIDList)
{
	NF_SHARE_PTR<NFINoSqlDriver> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
    if (pNoSqlDriver)
    {
        std::vector<std::string> vFields;
        std::vector<std::string> vValues;
        std::string strKey = MakePlayerRoomKey();
        std::string strData;

        for (int i = 0; i < xPlayerList.size(); ++i)
        {
            vFields.push_back(xPlayerList[i].ToString());
        }

        if (pNoSqlDriver->HMGet(strKey, vFields, vValues))
        {
            for (int i = 0; i < vValues.size(); ++i)
            {
                NFGUID xIdent;
                xIdent.FromString(vValues[i]);
                vecRoomIDList.push_back(xIdent);
            }

            return true;
        }
    }

    return false;
}
bool NFCAccountRedisModule::CreateRole(const std::string & strAccount, const std::string & strRoleName, const NFGUID & id)
{
	std::string strAccountKey = m_pCommonRedisModule->GetAccountCacheKey(strAccount);
	NF_SHARE_PTR<NFINoSqlDriver> xNoSqlDriver = m_pNoSqlModule->GetDriverBySuit(strAccount);
	if (xNoSqlDriver)
	{
		if (xNoSqlDriver->Exists(strAccountKey) && !xNoSqlDriver->Exists(strRoleName))
		{
			xNoSqlDriver->HSet(strAccountKey, NFrame::Player::Name(), strRoleName);
			xNoSqlDriver->HSet(strAccountKey, NFrame::Player::ID(), id.ToString());

            NF_SHARE_PTR<NFINoSqlDriver> xRoleNameNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
            if (xRoleNameNoSqlDriver)
            {
                xRoleNameNoSqlDriver->HSet(strRoleName, NFrame::Player::ID(), id.ToString());
            }
			/*
			std::vector<std::string> vKey;
			std::vector<std::string> vValue;
			xNoSqlDriver->HMSet(m_pCommonRedisModule->GetPropertyCacheKey(id), vKey, vValue);
			xNoSqlDriver->HMSet(m_pCommonRedisModule->GetRecordCacheKey(id), vKey, vValue);
			xNoSqlDriver->HMSet(m_pCommonRedisModule->GetPropertyStorageKey(id), vKey, vValue);
			xNoSqlDriver->HMSet(m_pCommonRedisModule->GetRecordStorageKey(id), vKey, vValue);
			*/
			return true;
		}
	}

	return false;
}
예제 #10
0
void NFCGuildModule::OnCreateGuildProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
	CLIENT_MSG_PROCESS_NO_OBJECT(nSockIndex, nMsgID, msg, nLen, NFMsg::ReqAckCreateGuild);

	std::string strRoleName ;
	int nLevel = 0;
	int nJob = 0;
	int nDonation= 0;
	int nVIP= 0;

	m_pGuildDataModule->GetPlayerInfo(nPlayerID, strRoleName, nLevel, nJob, nDonation, nVIP);
	NFGUID xGuild = CreateGuild(nPlayerID, xMsg.guild_name(), strRoleName, nLevel, nJob, nDonation, nVIP);

	if (!xGuild.IsNull())
	{
		NFMsg::ReqAckCreateGuild xAck;
		*xAck.mutable_guild_id() = NFINetModule::NFToPB(xGuild);
		xAck.set_guild_name(xMsg.guild_name());

		m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_GUILD, xAck, nSockIndex, nPlayerID);
	}
	else
	{
		NFMsg::ReqAckCreateGuild xAck;
		*xAck.mutable_guild_id() = NFINetModule::NFToPB(xGuild);
		xAck.set_guild_name("");

		m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_GUILD, xAck, nSockIndex, nPlayerID);
	}
}
예제 #11
0
int NFCEquipModule::GetEquipElementLevel(const NFGUID & self, const NFGUID & id, NFrame::Player::BagEquipList eIndex)
{
	if (id.IsNull() || self.IsNull())
	{
		return -1;
	}

	if (eIndex > NFrame::Player::BagEquipList_ElementLevel5_POISON
		|| eIndex < NFrame::Player::BagEquipList_ElementLevel1_FIRE)
	{
		return -1;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return -1;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return -1;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return -1;
	}

	const int nRow = xDataList.Int(0);
	return pRecord->GetInt(nRow, eIndex);
}
예제 #12
0
bool NFCEquipModule::AddEquipIntensifyLevel(const NFGUID& self, const NFGUID& id)
{
	if (id.IsNull() || self.IsNull())
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return false;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return false;
	}

	const int nRow = xDataList.Int(0);
	const int nLevel = pRecord->GetInt(nRow, NFrame::Player::BagEquipList_IntensifyLevel);
	pRecord->SetInt(nRow, NFrame::Player::BagEquipList_IntensifyLevel, nLevel + 1);

	return true;
}
예제 #13
0
NFGUID NFCHeroModule::ActiviteHero(const NFGUID & self, const string & strID)
{
	NFGUID id = AddHero(self, strID);
	if (!id.IsNull())
	{
		ActiviteHero(self, id);
	}

	return id;
}
예제 #14
0
bool NFCPVPMatchRedisModule::SetPlayerRoomID(const NFGUID& self, const NFGUID& xRoomID)
{
	NF_SHARE_PTR<NFINoSqlDriver> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
    if (pNoSqlDriver)
    {
        std::string strKey = MakePlayerRoomKey();
        return pNoSqlDriver->HSet(strKey, self.ToString(), xRoomID.ToString());
    }

    return false;
}
예제 #15
0
bool NFCPatrolState::Execute(const NFGUID& self)
{
    if (!NFIState::Execute(self))
    {
        NFIStateMachine* pStateMachine = m_pAIModule->GetStateMachine(self);
        if (pStateMachine)
        {
			NFGUID ident = m_pHateModule->QueryMaxHateObject(self);
			NFAI_MOVE_TYPE eMoveType = (NFAI_MOVE_TYPE)(m_pKernelModule->GetPropertyInt(self, "MoveType"));

			//如果是定点的,则不走,继续idle
			switch (eMoveType)
			{
			case NFAI_MOVE_TYPE::MOVE_BY_POINT_LIST:
				{
					//查找是否有可以攻击的对象
					if (!ident.IsNull())
					{
						pStateMachine->ChangeState(FightState);
					}
					else
					{
						//下一个节点
                        //object记录当前的路径ID和index,以记录寻路的位置
					}
				}
				break;

			case NFAI_MOVE_TYPE::MOVE_BY_RANDOM:
				{
					//查找是否有可以攻击的对象
					if (!ident.IsNull())
					{
						pStateMachine->ChangeState(FightState);
					}
					else
					{
						RandomPatrol(self);
					}
				}
				break;
			default:
				break;
			}
        }
    }

    return true;
}
예제 #16
0
bool NFCHeroPropertyModule::CalHeroEquipProperty(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;
	}

	////////////////////Equip//////////////////////////////////////////////////////
	xDataList.Clear();

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

	for (int i = NFrame::Player::PlayerHero_Equip1; i <= NFrame::Player::PlayerHero_Equip6; ++i)
	{
		NFCDataList EquipDataList;
		const NFGUID xEquipID = pHeroRecord->GetObject(nRow, i);
		if (!xEquipID.IsNull() && m_pEquipPropertyModule->CalEquipProperty(self, xEquipID, EquipDataList))
		{
			//one equip
			for (int j = 0; j < pHeroPropertyRecord->GetCols(); ++j)
			{
				int nOldValue = xDataList.Int(j);
				int nEquipValue = EquipDataList.Int(j);

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

	return true;
}
예제 #17
0
bool NFCCommonRedisModule::SaveRecordInfo(const NFGUID & self, const NFMsg::ObjectRecordList& xRecordData, const int nExpireSecond)
{
	if (self.IsNull())
	{
		return false;
	}

	NF_SHARE_PTR<NFIRedisClient> pDriver = m_pNoSqlModule->GetDriverBySuit(self.ToString());
	if (!pDriver)
	{
		return false;
	}

	std::vector<std::string> vKeyList;
	std::vector<std::string> vValueList;
	
	for (int i = 0; i < xRecordData.record_list_size(); ++i)
	{
		const NFMsg::ObjectRecordBase& xRecord = xRecordData.record_list(i);

		std::string strValue;
		if (!xRecord.SerializeToString(&strValue))
		{
			continue;
		}

		vKeyList.push_back(xRecord.record_name());
		vValueList.push_back(strValue);
	}


	if (vKeyList.size() != vValueList.size())
	{
		return false;
	}

	std::string strKey = GetRecordCacheKey(self);
	if (!pDriver->HMSET(strKey, vKeyList, vValueList))
	{
		return false;
	}

	if (nExpireSecond > 0)
	{
		pDriver->EXPIRE(strKey, nExpireSecond);
	}

	return true;
}
int NFCNPCRefreshModule::OnObjectHPEvent( const NFGUID& self, const std::string& strPropertyName, const NFIDataList::TData& oldVar, const NFIDataList::TData& newVar)
{
    if ( newVar.GetInt() <= 0 )
    {
        NFGUID identAttacker = m_pKernelModule->GetPropertyObject( self, NFrame::NPC::LastAttacker());
        if (!identAttacker.IsNull())
        {
            m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_BE_KILLED, NFCDataList() << identAttacker );

            m_pKernelModule->AddHeartBeat( self, "OnDeadDestroyHeart", this, &NFCNPCRefreshModule::OnDeadDestroyHeart, 5.0f, 1 );
        }
    }

    return 0;
}
예제 #19
0
bool NFCEquipModule::SetEquipInlayStoneID(const NFGUID& self, const NFGUID& id, NFrame::Player::BagEquipList eIndex, const std::string& strStoneID)
{
	if (id.IsNull() || self.IsNull() || strStoneID.empty())
	{
		return false;
	}

	if (eIndex > NFrame::Player::BagEquipList_InlayStone10
		|| eIndex < NFrame::Player::BagEquipList_InlayStone1)
	{
		return false;
	}

	if (!m_pElementModule->ExistElement(strStoneID))
	{
		return false;
	}

	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(self);
	if (NULL == pObject)
	{
		return false;
	}

	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement(NFrame::Player::R_BagEquipList());
	if (!pRecord)
	{
		return false;
	}

	NFCDataList xDataList;
	pRecord->FindObject(NFrame::Player::BagEquipList_GUID, id, xDataList);
	if (xDataList.GetCount() != 1)
	{
		return false;
	}

	const int nRow = xDataList.Int(0);
	const int nSoltCount = pRecord->GetInt(nRow, NFrame::Player::BagEquipList_SlotCount);
	if ((eIndex - NFrame::Player::BagEquipList_InlayStone1) <= nSoltCount)
	{
		return false;
	}

	pRecord->SetString(nRow, eIndex, strStoneID);

	return true;
}
예제 #20
0
bool NFCPackModule::DeleteEquip( const NFGUID& self, const NFGUID& id )
{
	if (id.IsNull())
	{
		return false;
	}

	//删除3个地方,背包,英雄穿戴,玩家穿戴
	NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( self );
	if (nullptr == pObject)
	{
		return false;
	}


	NF_SHARE_PTR<NFIRecord> pRecord = pObject->GetRecordManager()->GetElement( NFrame::Player::R_BagEquipList() );
	if (nullptr == pRecord)
	{
		return false;
	}

	NFCDataList varFindResult;
	int nFindRowCount = pRecord->FindObject(NFrame::Player::BagItemList_ConfigID, id, varFindResult);
	if (nFindRowCount > 0)
	{
		int nTotalCount = 0;
		for (int i = 0; i < varFindResult.GetCount(); ++i)
		{
			int nFindRow = varFindResult.Int(i);
			pRecord->Remove(nFindRow);
		}
	}

	return true;
}
예제 #21
0
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;
}
예제 #22
0
bool NFCHeroModule::HeroSkillUp(const NFGUID& self, const NFGUID& xHeroID, const int nIndex)
{
	if (xHeroID.IsNull())
	{
		return false;
	}

	if (nIndex > NFrame::Player::PlayerHero::Skill5 && nIndex < NFrame::Player::PlayerHero::Skill1)
	{
		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& strSkillID = pHeroRecord->GetString(nRow, nIndex);
	const std::string& strNextSkillID = m_pElementModule->GetPropertyString(strSkillID, NFrame::Skill::NextID());
	if (strNextSkillID.empty())
	{
		//no next talent id, this skill is the best talent
		return false;
	}

	pHeroRecord->SetString(nRow, nIndex, strNextSkillID);
	return true;
}
예제 #23
0
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;
}
예제 #24
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);
	}
}
bool NFCGSSwichServerModule::ChangeServer(const NFGUID& self, const int nServer, const int nSceneID, const int nGroup)
{
	NFMsg::ReqSwitchServer xMsg;

	xMsg.set_sceneid(nSceneID);
	*xMsg.mutable_selfid() = NFINetModule::NFToPB(self);
	xMsg.set_self_serverid(pPluginManager->GetAppID());
	xMsg.set_target_serverid(nServer);
    xMsg.set_groupid(nGroup);

	int nGate = 0;
	NFGUID xClient;

    NF_SHARE_PTR<NFIGameServerNet_ServerModule::GateBaseInfo> pGateInfo = m_pGameServerNet_ServerModule->GetPlayerGateInfo(self);
	if (!pGateInfo)
	{
		return false;
	}

    nGate = pGateInfo->nGateID;
    xClient = pGateInfo->xClientID;
	*xMsg.mutable_client_id() = NFINetModule::NFToPB(xClient);
	xMsg.set_gate_serverid(nGate);

	m_pNetClientModule->SendSuitByPB(NF_SERVER_TYPES::NF_ST_WORLD, self.ToString(), NFMsg::EGMI_REQSWICHSERVER, xMsg);

	return true;
}
예제 #26
0
bool NFCProperty::SetObject(const NFGUID& value)
{
	if (eType != TDATA_OBJECT)
	{
		return false;
	}

	if (!mxData.get())
	{
		//本身是空就是因为没数据,还来个没数据的就不存了
		if (value.IsNull())
		{
			return false;
		}

		mxData = NF_SHARE_PTR<NFIDataList::TData>(NF_NEW NFIDataList::TData(TDATA_OBJECT));
		mxData->SetObject(NFGUID());

	}

	if (value == mxData->GetObject())
	{
		return false;
	}

	NFCDataList::TData oldValue;
	oldValue = *mxData;

	mxData->SetObject(value);

	OnEventHandler(oldValue, *mxData);

	return true;
}
예제 #27
0
void NFCPVPMatchModule::OnAckCreatePVPEctypeProcess(const int nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS_NO_OBJECT(nSockIndex, nMsgID, msg, nLen, NFMsg::AckCreatePVPEctype);

    NFGUID xRoomID = NFINetModule::PBToNF(xMsg.xroominfo().roomid());
    if (!xRoomID.IsNull())
    {
        int nServerID = 0;
        int nSceneID = 0;
        int nGroup = 0;
        if (!xMsg.xroominfo().has_serverid())
        {
            return;
        }

        if (!xMsg.xroominfo().has_sceneid())
        {
            return;
        }
        if (!xMsg.xroominfo().has_groupid())
        {
            return;
        }

        nServerID = xMsg.xroominfo().serverid();
        nSceneID = xMsg.xroominfo().sceneid();
        nGroup = xMsg.xroominfo().groupid();

        NFMsg::PVPRoomInfo xRoomInfo;
        if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo))
        {
            UpdateRoomStatus(xRoomInfo, EPVPROOMSTATUS_FIGHT);

            if (xRoomInfo.ncellstatus() == EPVPROOMSTATUS_FIGHT)
            {
                xRoomInfo.set_serverid(nServerID);
                xRoomInfo.set_sceneid(nSceneID);
                xRoomInfo.set_groupid(nGroup);

                if (m_pPVPMatchRedisModule->SetRoomInfo(xRoomID, xRoomInfo))
                {
                    BroadcastMsgToRoom(nPlayerID, xRoomID, NFMsg::EGMI_ACK_CREATEPVPECTYPE, xMsg);
                }
            }
        }
    }
}
예제 #28
0
bool NFCPVPMatchRedisModule::SetStatusRoomID(const int nPVPMode, const int nGrade, const int nStatus, const NFGUID& xRoomID)
{
	NF_SHARE_PTR<NFINoSqlDriver> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
    if (pNoSqlDriver)
    {
        std::string strKey = MakeStatusRoomIDRedisKey(nPVPMode, nGrade, nStatus);
        std::string strData;

        std::vector<std::string> valueVec;
        if (pNoSqlDriver->HSet(strKey, xRoomID.ToString(), xRoomID.ToString()))
        {
            return true;
        }
    }

    return false;
}
예제 #29
0
bool NFPatrolState::Execute(const NFGUID& self, NFIStateMachine* pStateMachine)
{
    if (!NFIState::Execute(self, pStateMachine))
    {
			NFGUID ident = m_pHateModule->QueryMaxHateObject(self);
			NFAI_NPC_TYPE eMoveType = (NFAI_NPC_TYPE)(m_pKernelModule->GetPropertyInt(self, NFrame::NPC::NPCType()));

			//如果是定点的,则不走,继续idle
			switch (eMoveType)
			{
			case NFAI_NPC_TYPE::MASTER_TYPE:
				{
					//查找是否有可以攻击的对象
					if (!ident.IsNull())
					{
						pStateMachine->ChangeState(FightState);
					}
					else
					{
						//下一个节点
                        //object记录当前的路径ID和index,以记录寻路的位置
					}
				}
				break;

			case NFAI_NPC_TYPE::HERO_TYPE:
				{
					//查找是否有可以攻击的对象
					if (!ident.IsNull())
					{
						pStateMachine->ChangeState(FightState);
					}
					else
					{
						RandomPatrol(self, pStateMachine);
					}
				}
				break;
			default:
				break;
			}
    }

    return true;
}
예제 #30
0
bool NFCPVPMatchRedisModule::GetPlayerRoomID(const NFGUID& self, NFGUID& xRoomID)
{
	NF_SHARE_PTR<NFINoSqlDriver> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent();
    if (pNoSqlDriver)
    {
        std::string strKey = MakePlayerRoomKey();
        std::string strData;
        if (pNoSqlDriver->HGet(strKey, self.ToString(), strData))
        {
            if (xRoomID.FromString(strData))
            {
                return true;
            }
        }
    }

    return false;
}