?

Log in

 
 
20 July 2006 @ 06:12 pm
Вот эта хрень заведует раздачей деньгами. Пиздец, ага?  


bool ReelController::NextRound( int bet, int lines, LayoutData &out, WinInfo animate[LinesCount] )
{
    int rand_val = 0;
    int zone_num = 0;

    int_vector game_result;
    long game_win = 0;

    FundData *pFund = &funds[bet];
    StatData *pStat = &stats[bet];

    float t_fund = pFund->fund_state;

    t_fund += (bet+1)*(lines)*win_percentage;
    money_in += (bet+1)*(lines);
    
    for ( zone_num = 0; zone_num < ZoneNum; zone_num++ ){
        if ( (pFund->zone_ranges[zone_num].first <= floorf( t_fund )) &&
            (pFund->zone_ranges[zone_num].second >= floorf( t_fund ) ))
            break;
    }
        
    games_count++;
    pStat->games_count++;
    pStat->zone_games_count[bet]++;

    for ( int lineIdx = 0; lineIdx < lines; lineIdx++ ) {


        last_zone_played = zone_num;

        int range_num = WinCodeCount;
        int *pProb = pFund->zones[zone_num].probability;

        bool force_global = false;
        bool force = false;

        int comboIdx = 0;

        rand_val = rand_gen.get_one()*100;
        if ( rand_val > pFund->zone_probability[zone_num] ){

            if ( pStat->no_win_counter < pFund->current_nowin &&  global_forced_wins_counter!= 0 ) {
                pStat->no_win_counter++;
                global_forced_wins_counter--;
                continue;
            } else {
                force_global = (global_forced_wins_counter == 0);
                force = true;
                pStat->no_win_counter = pFund->nowin_ranges.first + rand_gen()%(pFund->nowin_ranges.second-pFund->nowin_ranges.first);
                range_num = ForceNum;
                pProb = pFund->force_wins;
            }

        }


        if ( !force_global ) {
            rand_val = rand_gen.get_one()*1000;

            for ( comboIdx = 0; comboIdx < range_num; comboIdx++ ) {
                if ( rand_val < pProb[comboIdx] ) {
                    break;
                }
            }
        } else {
            comboIdx = 0;
        }


/*      if ( force ) {
            if ( force_global )
                pStat->forced_game_stat++; //g_GlobalForcedStatistic[bet]++;
            else
                //g_LocalForcedStatistic[bet][comboIdx]++;
                pStat->local_foced_stat[comboIdx]++;
        }
*/
        game_win += g_WinTable[comboIdx];
    
        pStat->no_win_counter = 0;
        global_forced_wins_counter = no_win_range.first + rand_gen.get_one()*(no_win_range.second-no_win_range.first);
    }


    bool win = false;
    if ( game_win != 0 ){

        layout_set &current_set = layout_table[lines-1];
        layout_set_iterator pFound = find( current_set.begin(), current_set.end(), game_win );
    
        if ( pFound != current_set.end() ) {
//          cout << "Found combo costed " << pFound->total_cost*(bet+1) << endl;
            out = SelectRandomCombo( pFound->total_cost, current_set );
            win = true;
//          out = *pFound;
            
        } else {
            hold_fund += game_win;

            pFound = FindClosestCombo( hold_fund, current_set );
            if ( pFound != current_set.end() ) {
                out = SelectRandomCombo( pFound->total_cost, current_set );
                
                win = true;
                //out = *pFound;

                hold_fund -= out.total_cost*(bet+1);
            } 
        } 

    }

    if ( win ) {
        FillField( out );
        GetMetadata( out, lines, animate );
        game_win = out.total_cost*(bet+1);
        pFund->fund_state = t_fund - game_win;
        
        // Commit statistic values
        total_money_win += game_win;
        total_win_count++;
        pStat->bet_games_wins++;
        pStat->betfund_hits[zone_num]++;
//      pStat->win_code_games[comboIdx]++;
    } else {
        pFund->fund_state = t_fund;
        FillEmptyField( out );
        GetMetadata( out, lines, animate );
    }

//  CommitLog( bet, lines, out, animate );

    return win;
    
}
_Winnie C++ Colorizer
 
 
Current Mood: крик души
 
 
 
(Deleted comment)
Festerfester_ua on July 24th, 2006 03:21 pm (UTC)
Папандоса нет, это я просто матерюсь на ужасный код.
wind666wind666 on October 26th, 2006 02:23 pm (UTC)
Сблевала после ссылок на глобальные переменные, префиксов и K&R....
постфиксная инкремента, ве
возвращение значения по ссылке
nikokoshev on February 19th, 2007 11:48 am (UTC)
Такая красивая девушка (сверху :) и рассуждает о каких-то потс.. сфкс.. ..ных инкрементах...

kaine_tregard on September 16th, 2010 02:15 pm (UTC)
:-) ; fester_ua