int NFCGamePVPModule::OnDeadSwapHeroHeart(const NFGUID & self, const std::string & strHeartBeat, const float fTime, const int nCount)
{
	NFGUID xFightingHero = m_pKernelModule->GetPropertyObject(self, NFrame::Player::FightHeroID());
	NFGUID xHero1 = m_pKernelModule->GetPropertyObject(self, NFrame::Player::HeroID1());
	NFGUID xHero2 = m_pKernelModule->GetPropertyObject(self, NFrame::Player::HeroID2());
	NFGUID xHero3 = m_pKernelModule->GetPropertyObject(self, NFrame::Player::HeroID3());

	int nHeroHP1 = m_pKernelModule->GetPropertyInt(self, NFrame::Player::FightHeroHP1());
	int nHeroHP2 = m_pKernelModule->GetPropertyInt(self, NFrame::Player::FightHeroHP2());
	int nHeroHP3 = m_pKernelModule->GetPropertyInt(self, NFrame::Player::FightHeroHP3());

	if (nHeroHP1 <= 0 && nHeroHP2 <= 0 && nHeroHP3 <= 0)
	{
		//all dead, end the battle
		EndTheBattle(self);

		return 0;
	}

	if (nHeroHP1 > 0)
	{
		m_pHeroModule->SwitchFightHero(self, xHero1);
	}
	else if (nHeroHP2 > 0)
	{
		m_pHeroModule->SwitchFightHero(self, xHero2);
	}
	else if (nHeroHP3 > 0)
	{
		m_pHeroModule->SwitchFightHero(self, xHero3);
	}
	//swap hero

	return 0;
}
void NFCGamePVPModule::OnReqEndPVPOpponentProcess(const NFSOCK nSockIndex, const int nMsgID, const char *msg,
											  const uint32_t nLen)
{
	CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqEndBattle);

	//get oppnent
	//calculate how many monster has been killed
	//calculate how many building has been destroyed
	//calculate how much experice and how many money

	//tell client the end information
	//set oppnent 0
	int pvpType = m_pKernelModule->GetPropertyInt(nPlayerID, NFrame::Player::PVPType());
	if (pvpType == NFMsg::EPVPType::PVP_INDIVIDUAL)
	{
		EndTheBattle(nPlayerID);
	}

}
Example #3
0
void NFGamePVPModule::OnReqEndPVPOpponentProcess(const NFSOCK nSockIndex, const int nMsgID, const char *msg,
											  const uint32_t nLen)
{
	CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqEndBattle);

	//get oppnent
	//calculate how many monster has been killed
	//calculate how many building has been destroyed
	//calculate how much experice and how many money

	//tell client the end information
	//set oppnent 0
	const int nSceneID = m_pKernelModule->GetPropertyInt(nPlayerID, NFrame::Player::SceneID());
	E_SCENE_TYPE eSceneType = (E_SCENE_TYPE)m_pElementModule->GetPropertyInt32(std::to_string(nSceneID), NFrame::Scene::Type());
	if (eSceneType == E_SCENE_TYPE::SCENE_TYPE_SINGLE_CLONE_SCENE
		|| eSceneType == E_SCENE_TYPE::SCENE_TYPE_MULTI_CLONE_SCENE)
	{
		EndTheBattle(nPlayerID);
	}
}