本文整理汇总了C++中PlayerPtr::GetCompNews方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerPtr::GetCompNews方法的具体用法?C++ PlayerPtr::GetCompNews怎么用?C++ PlayerPtr::GetCompNews使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerPtr
的用法示例。
在下文中一共展示了PlayerPtr::GetCompNews方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void ScheduleNewsCmd::Execute() const
{
if ( m_spContext == NULL )
{
return;
}
PlayerPtr spPlayer = m_spContext->GetPlayer();
if ( spPlayer == NULL )
{
return;
}
// Get news component
PlayerCompNewsPtr spCompNews = spPlayer->GetCompNews();
if ( m_spNews != NULL )
{
// Pay the news
Budget& budget = spPlayer->GetBudget();
budget.Book( CMadTV::ACCOUNT_CASH, CMadTV::ACCOUNT_NEWS_COSTS, m_spNews->GetCurrentPrice(), m_spContext->GetGame()->GetDateTime(), "Bought news" );
}
// Schedule
spCompNews->SetPlannedNews( m_u32Slot, m_spNews );
}
示例2: Execute
void ClearRecentlySubscribedChannelsCmd::Execute() const
{
if ( m_spContext == NULL )
{
return;
}
PlayerPtr spPlayer = m_spContext->GetPlayer();
if ( spPlayer == NULL )
{
return;
}
// Get news component
PlayerCompNewsPtr spCompNews = spPlayer->GetCompNews();
// Clear recently subscribed channels
spCompNews->RemoveRecentlySubscribedChannels();
}
示例3: Verify
Unsigned32 ScheduleNewsCmd::Verify() const
{
if ( m_spContext == NULL )
{
return ERROR_NONE;
}
PlayerPtr spPlayer = m_spContext->GetPlayer();
if ( spPlayer == NULL )
{
return ERROR_NONE;
}
// Get news component
PlayerCompNewsPtr spCompNews = spPlayer->GetCompNews();
// Check if slot is valid
if ( m_u32Slot >= PlayerCompNews::NUM_PLANNED_NEWS )
{
return ERROR_INVALID_SLOT;
}
// Check if player has news
if ( m_spNews != NULL &&
!spCompNews->HasNews( m_spNews ) )
{
return ERROR_NEWS_NOT_AVAILABLE;
}
// Check if enough money available
Budget& budget = spPlayer->GetBudget();
if ( m_spNews != NULL &&
budget.GetCash() < m_spNews->GetCurrentPrice() )
{
return ERROR_INSUFFICIENT_MONEY;
}
return ERROR_NONE;
}