Пример #1
0
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);
}
Пример #2
0
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);
}