当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerCreature::decreaseGoldEx方法代码示例

本文整理汇总了C++中PlayerCreature::decreaseGoldEx方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerCreature::decreaseGoldEx方法的具体用法?C++ PlayerCreature::decreaseGoldEx怎么用?C++ PlayerCreature::decreaseGoldEx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerCreature的用法示例。


在下文中一共展示了PlayerCreature::decreaseGoldEx方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: execute

void CGStashRequestBuyHandler::execute (CGStashRequestBuy* pPacket , Player* pPlayer)
	 throw(ProtocolException , Error)
{
	__BEGIN_TRY __BEGIN_DEBUG_EX
	__BEGIN_DEBUG

#ifdef __GAME_SERVER__

	Assert(pPacket != NULL);
	Assert(pPlayer != NULL);

	GamePlayer*     pGamePlayer     = dynamic_cast<GamePlayer*>(pPlayer);
	Creature*       pPC             = pGamePlayer->getCreature();
	PlayerCreature* pPlayerCreature = dynamic_cast<PlayerCreature*>(pPC);

	BYTE curStashNum = pPlayerCreature->getStashNum();

	// 가지고 있는 보관함이 맥스라면 리턴
	if (curStashNum >= STASH_RACK_MAX)
	{
		GCNPCResponse failpkt;
		failpkt.setCode(NPC_RESPONSE_STASH_SELL_FAIL_MAX);
		pPlayer->sendPacket(&failpkt);
		return;
	}

	Price_t price = g_pPriceManager->getStashPrice(curStashNum+1);

	// 돈이 모자라도 실패쥐.
	if (pPlayerCreature->getGold() < price)
	{
		GCNPCResponse failpkt;
		failpkt.setCode(NPC_RESPONSE_STASH_SELL_FAIL_MONEY);
		pPlayer->sendPacket(&failpkt);
		return;
	}

	// 보관함 갯수를 한 칸 늘려주고...
	pPlayerCreature->setStashNumEx(curStashNum+1);

	// 돈을 줄인다.
	//pPlayerCreature->setGoldEx(pPlayerCreature->getGold() - price);

	// by sigi. 2002.9.4
	pPlayerCreature->decreaseGoldEx(price);

	// 마지막으로 OK 패킷을 날려준다.
	GCNPCResponse okpkt;
	okpkt.setCode(NPC_RESPONSE_STASH_SELL_OK);
	pPlayer->sendPacket(&okpkt);

#endif

	__END_DEBUG
	__END_DEBUG_EX __END_CATCH
}
开发者ID:jun199004,项目名称:server,代码行数:56,代码来源:CGStashRequestBuyHandler.cpp

示例2: execute


//.........这里部分代码省略.........

//	ServerID_t serverID;
//	ZoneID_t zoneID;
//	bool bHasCastle = g_pGuildManager->hasCastle(guildID , serverID , zoneID);

//	if (bHasCastle && serverID == g_pConfig->getPropertyInt("ServerID" ) && zoneID == m_ZoneID )

	CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo(m_ZoneID);
	GuildID_t ownerGuildID = pCastleInfo->getGuildID();

	if (guildID == ownerGuildID )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_ALREADY_HAS_CASTLE);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	// 이미 전쟁 신청을 했는가?
	if (g_pGuildManager->hasWarSchedule(guildID ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_ALREADY_REGISTERED);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	// 전쟁 스케쥴이 다 찼는가?
/*	if (!pWarScheduler->canAddWar(WAR_GUILD ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	GuildWar* pWar = new GuildWar(m_ZoneID, guildID, War::WAR_STATE_WAIT);

	pWar->setRegistrationFee(warRegistrationFee);

	if (!pWarScheduler->addWar(pWar ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);

		SAFE_DELETE(pWar);
		return;
	}*/

	Schedule* pNextSchedule = pWarScheduler->getRecentSchedule();

	Work* pNextWork = NULL;
	if (pNextSchedule != NULL ) pNextWork = pNextSchedule->getWork();

	SiegeWar* pNextWar = dynamic_cast<SiegeWar*>(pNextWork);

	if (pNextWar == NULL )
	{
		pNextWar = new SiegeWar(m_ZoneID, War::WAR_STATE_WAIT);
		pNextWar->addRegistrationFee(warRegistrationFee);
		pNextWar->addChallengerGuild(guildID);

		if (!pWarScheduler->addWar(pNextWar ) )
		{
			gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
			pPC->getPlayer()->sendPacket(&gcNPCResponse);

			SAFE_DELETE(pNextWar);
			return;
		}
	}
	else if (pNextWar->getChallengerGuildCount() < 5 )
	{
		WarSchedule* pNextWarSchedule = dynamic_cast<WarSchedule*>(pNextSchedule);
		Assert(pNextWarSchedule != NULL);

		pNextWar->addRegistrationFee(warRegistrationFee);
		pNextWar->addChallengerGuild(guildID);
		pNextWarSchedule->save();
	}
	else
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);

//		SAFE_DELETE(pNextWar);
		return;
	}

	pPC->decreaseGoldEx(warRegistrationFee);

	GCModifyInformation gcMI;
	gcMI.addLongData(MODIFY_GOLD, pPC->getGold());
	pPC->getPlayer()->sendPacket(&gcMI);

	gcNPCResponse.setCode(NPC_RESPONSE_WAR_REGISTRATION_OK);
	pPC->getPlayer()->sendPacket(&gcNPCResponse);
	return;

#endif

	__END_CATCH
}
开发者ID:hillwah,项目名称:darkeden,代码行数:101,代码来源:ActionRegisterSiege.cpp


注:本文中的PlayerCreature::decreaseGoldEx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。