コード例 #1
0
ファイル: OddsRunInfo.cs プロジェクト: d3x0r/xperdex
        //GameInfo prior_game = null;
        public state Step()
        {
            state result = new state();

            //Log.log( "Begin Step" );
            lock (this.step_lock)
            {
                // check to see if we're trying to end this.
                if (end)
                {
                    // valid will already be false.
                    return(result);
                }

                // check to see if the total duration is complete...
                if (_years == Years)
                {
                    return(result);
                }

                {
                    {
                        _total_games++;
                        _games++;

                        if (_games >= Games)
                        {
                            // need to do a step of session.
                            // setup some hotballs ....
                            _total_sessions++;
                            _sessions++;
                            if (_sessions >= Sessions)
                            {
                                _halls++;
                                if (_halls >= Halls)
                                {
                                    _days++;
                                    if (_days >= Days)
                                    {
                                        _years++;
                                        if (_years >= Years)
                                        {
                                            return(result);                                                         // here, result is not stepped.
                                        }
                                        _days = 0;
                                    }
                                    _halls = 0;
                                }
                                _sessions = 0;
                            }
                            _games = 0;

                            /// have counted the session, and now session is correct.
                            ///
                            // new session, create a new session event.
                            session_event = new BingoSessionEvent(bingo_session, false);
                            if (trigger_stats.enabled)
                            {
                                ball_data_interface.DropBalls();
                                session_event.trigger_balls = ball_data_interface.CallBalls(1);
                                ball_data_interface.DropBalls();
                                session_event.triggered_balls    = new int[trigger_stats.max_triggered];
                                session_event.triggered_ball_won = new bool[trigger_stats.max_triggered];
                            }
                            session_event.SaveToDatabase = flags.database_run;
                            session_event.Open(base_date.AddDays(_days), _sessions + 1);

                            // We need to add _days to the session_event.bingoday
                            // here so StateWriter (in BingoGameCore, which knows
                            // nothing about the OddsRunInfo.state) will assign
                            // the correct date to the records written to table
                            // called_game_player_rank2.

                            session_event.bingoday = session_event.bingoday.AddDays(_days);

                            {
                                BingoPlayers players = new BingoPlayers();                                 // create some players.
                                for (int p = 0; p < Players; p++)
                                {
                                    BingoPlayer player;
                                    players.Add(player = new BingoPlayer(Guid.NewGuid()));
                                    PlayerTransaction transaction;
                                    player.transactions.Add(transaction = new PlayerTransaction(player, p));
                                    foreach (BingoGameGroup bgg in session_event.session.GameGroups)
                                    {
                                        foreach (BingoPack pack in bgg.packs)
                                        {
                                            // something like this... so we can sell so many packs for players
                                            // but now players are not just sets of cards.
                                            for (int n = 0; n < Cards / PackSize; n++)
                                            {
                                                PlayerPack played;
                                                player.played_packs.Add(played = new PlayerPack());
                                                played.transaction             = transaction;
                                                played.pack_info           = pack;
                                                played.start_card          = pack.AutoDeal();
                                                played.pack_set            = 1;
                                                played.player              = player;
                                                played.pack_info.game_list = bingo_session.GameList;
                                                transaction.Add(played);
                                            }
                                        }
                                    }
                                }
                                session_event.PlayerList = players;
                            }
                        }

                        /// have counted the games and the game is correct.
                        session_event.StepToUsing(_games, (BingoGameState)result, ball_data_interface);                           // this is passed game index...

                        session_event.LoadPlayerCards(result);
                        result.Year = _years;
                        result.Day  = _days;

                        result.Hall = _halls;
                        result.Game = _games;

                        // here we can keep going, it's counting... maybe
                        // something like skipping a game for some reason causes invalidity...
                        // which is not terminal.
                        result.stepped = true;
                    }
                }
                //Log.log( "Created session evnet and players in session" );

                // return this state so we can unlock it.
                // with these balls and cards referenced
                // we should not have a problem with multi-threading this.
                return(result);
            }
        }