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


C++ Money::Decrement方法代码示例

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


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

示例1: MethodPress

bool Wager::MethodPress(Money &cMoney, const Table &cTable, std::list<Bet> &lBets, const int nTimes)
{
    BetModificationSetup(cTable, lBets);
    if (m_bWon) ++m_nBetModCounter;

    // If a bet won and counter is less than or equal to nTimes, Press the bet.
    // 1) Loop through bets, find those that are modifiable and have won.
    // 2) Double their wager
    // 3) Set their state to Unresolved

    int nNewWager = 0;

    if (m_bWon)
    {
        if (m_nBetModCounter <= nTimes)
        {
            for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
            {
                if (it->Modifiable() && it->Won())
                {
                    nNewWager = it->Wager() * 2;
                    cMoney.Decrement(nNewWager);
                    it->SetWager(nNewWager);
                    it->SetUnresolved();
                }
            }
        }
        else
        {
            m_nBetModCounter = 0;
        }
    }

    return (false);
}
开发者ID:dmaddalone,项目名称:CrapSim,代码行数:35,代码来源:Wager.cpp

示例2: MethodTakeDownAfterHits

bool Wager::MethodTakeDownAfterHits(Money &cMoney, const Table &cTable, std::list<Bet> &lBets, const int nTimes)
{
    BetModificationSetup(cTable, lBets);
    if (m_bWon) ++m_nBetModCounter;

    // If a bet won and counter is less than or equal to nTimes, Press the bet.
    // 1) Loop through bets, find those that are modifiable and have won.
    // 2) Make a new bet at the same wager.
    // 3) Set their state to Unresolved

    if (m_bWon)
    {
        if (m_nBetModCounter <= nTimes)
        {
            for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
            {
                if (it->Modifiable() && it->Won())
                {
                    cMoney.Decrement(it->Wager());
                    it->SetUnresolved();
                }
            }
        }
        // Else remove all modifiable unresolved bets and reset thge counter
        else
        {
            for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
            {
                if (it->Modifiable() && !it->Resolved())
                {
                    cMoney.Increment(it->Wager());
                    it->SetReturned();
                }
            }
            m_nBetModCounter = 0;
        }
    }

    return (false);
}
开发者ID:dmaddalone,项目名称:CrapSim,代码行数:40,代码来源:Wager.cpp

示例3: MethodClassicRegression

bool Wager::MethodClassicRegression(Money &cMoney, const Table &cTable, std::list<Bet> &lBets)
{
    bool bStopMakingBets = false;

    BetModificationSetup(cTable, lBets);
    if (m_bWon) ++m_nBetModCounter;

    // If a bet won and counter is 1, a this is our first regression.
    // 1) Loop through bets, find those that can be taken down but are not
    // lost.
    // 2) Reduce their wager amount by half, if possible
    // 3) Set their state to Unresolved
    int nOldWager = 0;
    int nNewWager = 0;

    if (m_bWon && m_nBetModCounter == 1)
    {
        for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
        {
            // If bet is modifiable
            if (it->Modifiable())
            {
                // If bet won or is unresolved
                if (it->Won() || !it->Resolved())
                {
                    // Calculate new wager amount
                    nOldWager = it->Wager();
                    if (nOldWager >= m_nStandardWager * 2)
                    {
                        nNewWager = it->Wager() / 2;
                    }
                    else
                    {
                        nNewWager = m_nStandardWager;
                    }

                    // If won, make a new bet at half the original wager
                    if (it->Won())
                    {
                        it->SetWager(nNewWager);
                        cMoney.Decrement(nNewWager);
                        it->SetUnresolved();
                    }

                    // If not resolved, reduce current wager to half the
                    // original wager
                    else if (!it->Resolved())
                    {
                        it->SetWager(nNewWager);
                        cMoney.Increment(nOldWager - nNewWager);
                        it->SetUnresolved();
                    }
                }
            }
        }
    }

    // If a bet won and counter is 2, this is our second regression.
    // 1) Loop through bets, find those that can be taken down and are not
    // resolved.
    // 2) Reduce their wager to zero
    // 3) Set their state to Returned
    // 4) Return true to stop making further bets, until a new qualification is achieved

    if (m_bWon && m_nBetModCounter == 2)
    {
        for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
        {
            if (it->Modifiable())
            {
                if (!it->Resolved())
                {
                    cMoney.Increment(it->Wager());
                    it->SetReturned();
                }
            }
        }

        bStopMakingBets = true;
    }

    return (bStopMakingBets);
}
开发者ID:dmaddalone,项目名称:CrapSim,代码行数:83,代码来源:Wager.cpp

示例4: MethodCollectPressRegress

bool Wager::MethodCollectPressRegress(Money &cMoney, const Table &cTable, std::list<Bet> &lBets)
{
    BetModificationSetup(cTable, lBets);
    if (m_bWon) ++m_nBetModCounter;

    // If a bet won and counter is 1, a this is the Collect.
    // 1) Loop through bets, find those that are modifiable and have won.
    // 2) Set their state to Unresolved

    if (m_bWon && m_nBetModCounter == 1)
    {
        for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
        {
            if (it->Modifiable() && it->Won())
            {
                cMoney.Decrement(it->Wager());
                it->SetUnresolved();
            }
        }
    }

    // If a bet won and counter is 2, this is the Press.
    // 1) Loop through bets, find those that are modifiable and have won.
    // 2) Make a new bet at two times the original wager.
    // 3) Set their state to Unresolved.

    int nNewWager = 0;

    if (m_bWon && m_nBetModCounter == 2)
    {
        for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
        {
            if (it->Modifiable()  && it->Won())
            {
                nNewWager = it->Wager() * 2;
                cMoney.Decrement(nNewWager);
                it->SetWager(nNewWager);
                it->SetUnresolved();
            }
        }
    }

    // If a bet won and counter is 3, this is the Regress.
    // 1) Loop through bets, find those that are modifiable and have won.
    // 2) Make a new bet at half the original wager.
    // 3) Set their state to Unresolved.
    // 4) Reset the counter

    if (m_bWon && m_nBetModCounter == 3)
    {
        for (std::list<Bet>::iterator it = lBets.begin(); it != lBets.end(); ++it)
        {
            if (it->Modifiable()  && it->Won())
            {
                nNewWager = it->Wager() / 2;
                cMoney.Decrement(nNewWager);
                it->SetWager(nNewWager);
                it->SetUnresolved();

                m_nBetModCounter = 0;
            }
        }
    }

    return (false);
}
开发者ID:dmaddalone,项目名称:CrapSim,代码行数:66,代码来源:Wager.cpp


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