Ejemplo n.º 1
0
        bool LoadGameInfoFromGrid()
        {
            if (!Loaded)
            {
                int game_number = 1;
                //int maxid = 0;
                OddsRunInfo.GameInfo prior_game = null;
                GameList = new BingoGameList();

                foreach (DataRow row in GamePatternTable.Rows)
                {
                    bool rate;
                    if (!(rate = row["Rate Game"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Rate Game"])))
                    {
                        continue;
                    }

                    OddsRunInfo.GameInfo game = new OddsRunInfo.GameInfo();

                    game.patterns = new List <Pattern>();
                    int pattern_col = GamePatternTable.Columns.IndexOf("Pattern 1");
                    ori.flags.lastBall = row["Last Ball"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Last Ball"]);
                    game.starburst     = row["Starburst"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Starburst"]);
                    if (game.starburst)
                    {
                        ori.flags.starburst = true;
                    }
                    game.rate = rate;
                    //game.rate = row["Rate Game"].Equals( DBNull.Value ) ? false : Convert.ToBoolean( row["Rate Game"] );
                    game.ignore_b_balls = row["Ignore Bs"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Bs"]);
                    game.ignore_i_balls = row["Ignore Is"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Is"]);
                    game.ignore_n_balls = row["Ignore Ns"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Ns"]);
                    game.ignore_g_balls = row["Ignore Gs"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Gs"]);
                    game.ignore_o_balls = row["Ignore Os"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Os"]);
                    //if( !game.rate )
                    //	continue;
                    //game.hotball = row["Hotball"].Equals( DBNull.Value ) ? false : Convert.ToBoolean( row["Hotball"] );
                    game.cashballs   = row["# Cash Ball"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(row["# Cash Ball"]);
                    game.progressive = row["Progressive"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Progressive"]);
                    //game.double_action = row["Double Action"].Equals( DBNull.Value ) ? false : Convert.ToBoolean( row["Double Action"] );
                    game.overlapped = row["Overlapped"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Overlapped"]);
                    game.extension  = row["Extension"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Extension"]);

                    game.upick_size     = row["Upick Count"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(row["Upick Count"]);
                    game.number_colored = row["Colored Ball Count"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(row["Colored Ball Count"]);
                    // extended games have a prior_game.

                    if (game.extension)
                    {
                        if (prior_game == null)
                        {
                            game.extension = false;
                        }
                        game.prior_game = prior_game;
                    }

                    // if there is a prior game, then check that game to see if it was progressive or overlapped... if it is, then this has a prior.

                    else if (prior_game != null && (prior_game.progressive || prior_game.overlapped))
                    {
                        game.prior_game = prior_game;
                        game.into       = true;                   // set that we are the inot part of a progressive...
                    }
                    else
                    {
                        game.prior_game = null;
                    }

                    prior_game = game;

                    // game group is 5...

                    // okay pattern is found by name and added offset... good.

                    if (game.cashballs == 1)
                    {
                        ori.flags.hotball = true;
                    }

                    if (game.cashballs == 5)
                    {
                        ori.flags._5cashball = true;
                    }

                    Patterns tmp = new Patterns(schedule);
                    for (int i = 0; i < 1; i++)
                    {
                        object pattern_id = row[pattern_col + i];

                        if (pattern_id != DBNull.Value)
                        {
                            DataRow[] rows = schedule.patterns.Select("pattern_id='" + pattern_id + "'");
                            if (rows.Length > 0)
                            {
                                tmp.Add(new Pattern(rows[0], patterns));
                            }
                        }
                    }
                    if (tmp.Count == 0)
                    {
                        // otherwise we don't need (or want) patterns
                        if (game.upick_size == 0)
                        {
                            // no pattern, and not upick, drop the issue
                            continue;                             // next game.
                        }
                        game.Name = "Upickem " + game.upick_size;
                    }
                    else
                    {
                        game.Name = tmp[0].Name;
                        if (game.upick_size > 0)
                        {
                            // this is a conflict.
                        }
                        game.SetPatterns(tmp.ToArray());
                    }

                    game.game_number = game_number;

                    bool found_match = false;

                    // this shouldn't have to be initialized to zero here.

                    // there won't be any in the list

                    // so it will end up being assigned before the

                    // location that the compiler throws a stupid warning

                    game.game_ID = 0;
                    int game_pattern_count = game.patterns.Count;

                    // gamelist as null is okay, and just bails the loop.
                    foreach (OddsRunInfo.GameInfo checkgame in GameList)
                    {
                        int i = 0;
                        if (checkgame.patterns.Count == game_pattern_count)
                        {
                            for ( ; i < game_pattern_count; i++)
                            {
                                if (!checkgame.patterns[i].ID.Equals(game.patterns[i].ID))
                                {
                                    break;
                                }
                            }
                        }

                        if (i == game_pattern_count)
                        {
                            found_match       = true;
                            game.game_ID      = checkgame.game_ID;
                            game.pattern_list = checkgame.pattern_list;
                            game.stats        = checkgame.stats;
                            lock (game.stats)
                            {
                                game.stats.games++;
                            }
                            break;
                        }
                    }

                    if (!found_match)
                    // if it's still zero, didn't find one, so set one.
                    {
                        OddsRunInfo.GameTypeInfo stats = new OddsRunInfo.GameTypeInfo();
                        ///if( !ori.GameTypeList )
                        if (ori.GameTypeList == null)
                        {
                            ori.GameTypeList = new List <OddsRunInfo.GameTypeInfo>();
                        }
                        stats.best_wins = new int[ori.bestwins.Length];
                        stats.aways     = new int[5];
                        stats.games     = 1;                     // one same game.
                        stats.name      = game.Name;
                        stats.lastBalls = new int[90];
                        if (ori.colored_balls > 0)
                        {
                            stats.colored_ball_hit = new int[ori.colored_balls];
                        }
                        ori.GameTypeList.Add(stats);
                        game.stats   = stats;
                        game.game_ID = ori.GameTypeList.IndexOf(stats);
                    }

                    game.quickshot = ori.flags.quickshot;

                    if ((game.patterns.Count > 0) || (game.upick_size > 0))
                    {
                        GameList.Add(game);
                    }
                    else
                    {
                        game = null;                         // just make sure we auto destruct this...
                    }
                    game_number++;
                }

                //-------------------------------------------------------------
                // Check if user has selected a game/pattern
                //-------------------------------------------------------------
                if (GameList.Count <= 0)
                {
                    MessageBox.Show("Please select a Pattern and Game to Rate from the Game Grid before pressing 'Go'", "Missing Pattern");
                    return(false);
                }

                ori.Games = GameList.Count;

                BingoGameGroup bgg = null;                // new BingoGameGroup( Guid.NewGuid() );
                BingoDealer    dealer;
                if (ori.dealer != null)
                {
                    dealer = ori.dealer;
                }
                else
                {
                    dealer = BingoDealers.CreateSimpleDealer();
                }
                foreach (BingoGame game in GameList)
                {
                    if (bgg == null || !game.into)
                    {
                        bgg = new BingoGameGroup(Guid.NewGuid());
                        GameList.game_group_list.AddGameGroup(bgg);
                        // add some packs to the game_group
                        if (game.upick_size > 0)
                        {
                            BingoDealer upick_dealer = BingoDealers.CreateUpickDealer(game.upick_size);
                            BingoPack   upick_pack   = GameList.CreatePack(upick_dealer, "Fictional UPick " + game.upick_size, ori.Cards);
                            upick_pack.face_size     = game.upick_size;
                            upick_pack.flags.upickem = true;
                            if (!upick_pack.game_groups.Contains(bgg))
                            {
                                upick_pack.game_groups.Add(bgg);
                            }
                            bgg.packs.Add(upick_pack);
                        }
                        else
                        {
                            BingoPack pack = GameList.CreatePack(dealer, "Fictional Pack", ori.PackSize);
                            pack.game_groups.Add(bgg);
                            bgg.packs.Add(pack);
                        }
                    }
                    bgg.Add(game);
                    game.game_group = bgg;
                    if (game.pack_card_counts.Count < 1)
                    {
                        game.pack_card_counts.Add(ori.Cards);
                    }
                }
                ori.bingo_session = new BingoSession(GameList);
                ori.bingo_session.session_name = "Odds Run Info";
            }
            return(true);
        }
Ejemplo n.º 2
0
        public BingoGame(BingoGameList game_list, DataRow group_game)
        {
            BingoGame       _game    = ((game_list.Count > 0) ? game_list[game_list.Count - 1] : null);
            ScheduleDataSet schedule = game_list.schedule;

            Init();

            Name        = group_game.ToString();
            game_number = Convert.ToInt32(group_game[SessionGame.NumberColumn]);

            //game_list.
            //dataRow_game_group_game = group_game;
            {
                DataRow[] tmp = group_game.GetChildRows("session_game_has_session_game_group");
                int       n   = 0;
                foreach (DataRow row in tmp)
                {
                    BingoGameGroup bgg;
                    this.game_group = bgg = game_list.game_group_list.GetGameGroup(row.GetParentRow("session_game_group_in_session_game"));
                    bgg.Add(this);
                    {
                        DataRow   session_game_group = row.GetParentRow("session_game_group_in_session_game");
                        DataRow[] game_prizes        = session_game_group.GetChildRows("game_group_has_pack");
                        //DataRow[] game_prizes = group_packs.
                        //DataRow[] game_group_prizes = game_group_row.GetChildRows( "game_group_has_prize_level" );
                        foreach (DataRow game_prize in game_prizes)
                        {
                            DataRow _prize = game_prize.GetParentRow("prize_level_in_game_group");
                            if (_prize[PrizeLevelNames.PrimaryKey] == null)
                            {
                                int a = 3;
                            }
                            prizes.Add(new BingoPrize(_prize[PrizeLevelNames.PrimaryKey], 50));
                        }
                        // should further check against overrides to get corrected prizes.
                    }
                }
            }

            {
                Patterns new_patterns = new Patterns(schedule);

                DataRow[] GamePatterns = schedule.game_patterns.GetPatterns(group_game);
                //Log.log( "Selected " + GamePatterns.Length + " game pattes for " + group["game_info_id"] );
                foreach (DataRow pattern in GamePatterns)
                {
                    object pattern_id = pattern[schedule.patterns.PrimaryKeyName];
                    Log.log("Looking up pattern " + pattern_id);

                    Pattern GamePattern = new Pattern(pattern, new_patterns);
                    new_patterns.Add(GamePattern);
                }
                SetPatterns(new_patterns.ToArray());
            }

            if (Convert.ToBoolean(group_game["single_hotball"]))
            {
                cashballs = 1;
            }

            //double_action = Convert.ToBoolean( group_game["double_action"] );

            // Load all of the packs defined in this session.
            // these are used to validate sales loaded into players....
            // they are also used to collect raw informatino to match by name
            // the pack sales to pack definitions such ad dealer parameters.
            DataRow[] game_group_packs;

            {
                game_group_packs = schedule.session_games.GetGameGroupPacks(group_game);
                BingoPack pack = null;
                if (game_group_packs != null)
                {
                    foreach (DataRow info in game_group_packs)
                    {
                        BingoGameGroup use_group = null;
                        bool           found     = false;
                        //foreach( BingoGameGroup game_group in game_groups )
                        {
                            DataRow real_game_group = info.GetParentRow("game_group_prize_level_has_pack");
                            if (game_group.ID.Equals(real_game_group[PackGroupTable.PrimaryKey]))
                            {
                                use_group = game_group;
                                found     = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            game_group = use_group = new BingoGameGroup(info[PackGroupTable.PrimaryKey]);
                        }

                        game_group_packs = schedule.session_games.GetPacks(group_game);
                        foreach (DataRow ggp in game_group_packs)
                        {
                            pack = game_list.pack_list.MakePack(use_group, ggp);
                            while (pack_card_counts.Count <= pack.pack_type)
                            {
                                pack_card_counts.Add(0);
                            }
                        }

                        if (pack == null)
                        {
                        }
                        if (pack != null)
                        {
                            pack_card_counts[pack.pack_type] = pack.count;
                        }
                    }
                }

                prior_group_game = null;
                foreach (BingoGame g in game_list)
                {
                    if (g == this)
                    {
                        continue;
                    }
                    //foreach( BingoGameGroup gamegroup in g.game_groups )
                    {
                        //foreach( BingoGameGroup this_group in this.game_groups )
                        if (g.game_group != null && this.game_group != null)                          // this isn't set during loading...
                        {
                            if (g.game_group.ID.Equals(this.game_group.ID))
                            {
                                prior_group_game = g;
                                break;
                            }
                        }
                    }
                }
                if (prior_group_game == null)
                {
                    page_skip = 0;
                    // this isn't really an into, prior game might be 'normal' progressive, but
                    // that's really into the next part, not this one.
                    into = false;
                }
                else
                if (into)
                {
                    page_skip = prior_group_game.page_skip;
                }
                else
                {
                    page_skip = prior_group_game.page_skip + 1;
                }

                //game_group_id = group_id;
            }
            // setup progressive game, and game skips (by page, and by absolute ball-set)
            {
                progressive = (Convert.ToInt32(group_game["progressive"]) != 0);
                if (_game != null)
                {
                    if (_game.progressive)
                    {
                        ballset_number = _game.ballset_number;
                        into           = true;
                    }
                    else
                    {
                        ballset_number = _game.ballset_number + 1;
                    }
                }
                else
                {
                    ballset_number = 0;
                }
            }

            // setup page_skip.
            {
                if (prior_group_game == null)
                {
                    page_skip = 0;
                    // this isn't really an into, prior game might be 'normal' progressive, but
                    // that's really into the next part, not this one.
                    into = false;
                }
                else
                if (into)
                {
                    page_skip = prior_group_game.page_skip;
                }
                else
                {
                    page_skip = prior_group_game.page_skip + 1;
                }
            }
            //game_number = game_number;
            prior_game = _game;

            //_game = game;
        }