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


C++ PlayerPtr::GetBudget方法代码示例

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


在下文中一共展示了PlayerPtr::GetBudget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
开发者ID:coeing,项目名称:cframework,代码行数:26,代码来源:ScheduleNewsCmd.cpp

示例2: 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;
}
开发者ID:coeing,项目名称:cframework,代码行数:39,代码来源:ScheduleNewsCmd.cpp


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