Esempio n. 1
0
        /// <summary>
        /// Search for a pack already created by said name, if it doesn't exist, create a BingoPack as defined by PackTable Row.
        /// </summary>
        /// <param name="dataRow">a DataRow from PackTable</param>
        /// <returns></returns>
        public BingoPack MakePack(BingoGameGroup game_group, DataRow dataRow)
        {
            foreach (BingoPack pack in pack_skel)
            {
                if (String.Compare(pack.name, dataRow[PackTable.NameColumn].ToString(), true) == 0 &&
                    pack.game_groups.Contains(game_group))
                {
                    return(pack);
                }
            }

            foreach (BingoPack pack in pack_skel)
            {
                // found the pack, but it's not in this game group, so it's not really a pack.
                if (String.Compare(pack.name, dataRow[PackTable.NameColumn].ToString(), true) == 0)
                {
                    return(pack);
                }
            }

            BingoPack newpack = new BingoPack(game_group, dataRow);

            if (dataRow != null)
            {
                DataRow[] ranges = dataRow.GetChildRows("pack_has_cardset_range");
                if (ranges.Length == 0)
                {
                    MessageBox.Show("Pack " + dataRow[PackTable.NameColumn] + " does not have any cardset ranges...");
                    OpenSkieScheduler3.Controls.Forms.PackEditor pe = new OpenSkieScheduler3.Controls.Forms.PackEditor(dataRow);
                    pe.ShowDialog();
                    pe.Dispose();
                    ranges = dataRow.GetChildRows("pack_has_cardset_range");
                }
                if (ranges != null && ranges.Length > 0)
                {
                    foreach (DataRow cardset_range in ranges)
                    {
                        DataRow range = cardset_range.GetParentRow("cardset_range_in_pack");
                        newpack.dealers.Add(BingoDealers.GetDealer(range));
                    }
                }

                this.pack_skel.Add(newpack);
                newpack.pack_type = this.pack_skel.IndexOf(newpack);

                game_group.packs.Add(newpack);
            }
            return(newpack);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a fully populated session object
        /// </summary>
        /// <param name="bingoday"></param>
        /// <param name="session">DataRow from session_info table in OpenSkieScheduler</param>
        public BingoSession(DataRow session)
        {
            // this retains '75' as max_balls.
            DefaultCharacteristics();

            this.schedule = session.Table.DataSet as ScheduleDataSet;
            BingoDealers.LoadDealers(schedule.packs);

            this.dataRowSession = session;

            this.session_name = session[SessionTable.NameColumn].ToString();
            this.bingoday     = DateTime.Now;
            this.session      = 1;

            this.GameList = new BingoGameList(this);
        }
Esempio n. 3
0
 public BingoPack GetPackDelete(int start_card, int packtype)
 {
     foreach (BingoPack pack in pack_skel)
     {
         if (pack.pack_type == packtype)
         {
             //BingoData.pi.S
             BingoPack newpack = new BingoPack(pack);
             newpack.dealers.Add(BingoDealers.GetDealer(start_card, packtype));
             //newpack.start_card = start_card;
             this.Add(newpack);
             return(newpack);
         }
     }
     Log.log("Pack was not scheduled for today... could not find info to attach dealer.");
     //newpack.name =
     return(null);
 }
Esempio n. 4
0
        internal BingoPack GetRangePack(int start_card)
        {
            foreach (BingoPack pack in dealer_packs)
            {
                foreach (BingoDealer dealer in pack.dealers)
                {
                    if (dealer.real_min_range <= start_card &&
                        dealer.real_max_range >= start_card)
                    {
                        return(pack);
                    }
                }
            }
            BingoPack dealt = new BingoPack(this);

            dealt.dealers.Add(BingoDealers.GetDealer(start_card, this.pack_type));
            dealer_packs.Add(dealt);
            return(dealt);
        }
Esempio n. 5
0
        /// <summary>
        /// this specifically creates a BingoSession appropriate for RateRank application.
        /// </summary>
        /// <param name="schedule">OpenSkieSchedule.ScheduleDataset</param>
        /// <param name="bingoday">day to load</param>
        /// <param name="session_number">session number on that day to load</param>
        public BingoSession(ScheduleDataSet schedule, DateTime bingoday, int session_number)
        {
            // this retains '75' as max_balls.
            DefaultCharacteristics();

            BingoDealers.LoadDealers(schedule.packs);

            this.dataRowSession = schedule.GetSession(bingoday, session_number);
            if (this.dataRowSession == null)
            {
                MessageBox.Show("Could not find session " + session_number + " scheduled on " + bingoday.ToShortDateString());
                throw new Exception("Session Creation Failed");
            }
            else
            {
                this.schedule     = schedule;
                this.bingoday     = bingoday;
                this.session      = session_number;
                this.session_name = this.dataRowSession.ItemArray[7].ToString();

                this.GameList = new BingoGameList(this);
            }
        }
Esempio n. 6
0
        internal BingoPack GetRangePack(String range_name)
        {
            if (range_name == null)
            {
                return(null);
            }

            foreach (BingoPack pack in dealer_packs)
            {
                foreach (BingoDealer dealer in pack.dealers)
                {
                    if (dealer.RangeName == range_name)
                    {
                        return(pack);
                    }
                }
            }

            BingoPack dealt = new BingoPack(this);

            dealt.dealers.Add(BingoDealers.GetDealer(range_name));
            dealer_packs.Add(dealt);
            return(dealt);
        }
Esempio n. 7
0
        bool BuildRunInfo(bool one_session)
        {
            if (ori == null)
            {
                ori = new OddsRunInfo( );
            }

#if this_loaded_player_tracking_for_phsycial_players
            BingoPlayers players = new BingoPlayers();
            DbDataReader reader  = StaticDsnConnection.KindExecuteReader("select card,sum(value) from player_track where bingoday="
                                                                         + MySQLDataTable.MakeDateOnly(result.bingoday.AddYears(2006).AddDays(7).AddMonths(5))
                                                                         + " and session=" + (_sessions + 1)
                                                                         + " and card<>'000000000000000000'"
                                                                         + " group by card");
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    BingoPlayer player;
                    players.Add(player = new BingoPlayer(reader.GetString(0)));
                    int spend = reader.GetInt32(1);
                    for (int p = 0; p < (spend / 2000); p++)
                    {
                        BingoPack  pack = GameList.pack_list.GetPack(true, Cards, "Fictional Pack");
                        PlayerPack played;
                        pack.pack_set = p;
                        player.played_packs.Add(played = new PlayerPack());
                        played.pack_info = pack;
                        played.player    = player;
                        played.game_list = GameList;
                    }
                }
            }
#endif
            if (ori.trigger_stats.enabled = checkBoxTriggerBalls.Checked)
            {
                ori.trigger_stats.max_triggered = Convert.ToInt32(textBoxMaxTriggered.Text);
                ori.trigger_stats.triggered     = new int[ori.trigger_stats.max_triggered + 1];
                ori.trigger_stats.trigger_wins  = new int[ori.trigger_stats.max_triggered + 1];
            }
            if (one_session)
            {
                ori.Years    = 1;
                ori.Days     = 1;
                ori.Sessions = 1;
                ori.Halls    = 1;
                ori.Players  = Convert.ToInt32(textBoxPlayers.Text);
                ori.Cards    = Convert.ToInt32(textBoxCards.Text);
                // this will be overridden later, if external game grid is used.
                ori.Games = Convert.ToInt32(textBoxGames.Text);
            }
            else
            {
                ori.Years = Convert.ToInt32(textBoxYears.Text);
                ori.Days  = Convert.ToInt32(textBoxDays.Text);

                //move all days into the day counter
                // the DateTime thing will take just adding days.
                ori.Days  = ori.Years * ori.Days;
                ori.Years = 1;

                ori.Sessions = Convert.ToInt32(textBoxSessions.Text);
                ori.Halls    = Convert.ToInt32(textBoxHalls.Text);
                ori.Players  = Convert.ToInt32(textBoxPlayers.Text);
                ori.Cards    = Convert.ToInt32(textBoxCards.Text);
                // this will be overridden later, if external game grid is used.
                ori.Games = Convert.ToInt32(textBoxGames.Text);
            }

            ori.colored_balls = textBoxColorBallCount.Text.Length > 0 ? Convert.ToInt32(textBoxColorBallCount.Text) : 0;

            ori.flags.use_blower   = radioBallBlower.Checked;
            ori.flags.database_run = checkBoxDatabase.Checked;

            ori.flags.save_winning_cards = checkBoxSaveWinningCards.Checked;
            ori.flags.Count_BINGO_Calls  = checkBoxCountBINGOCalls.Checked;
            ori.flags.countColorBINGO    = checkBoxCountColorBINGO.Checked;
            ori.flags.quickshot          = checkBoxQuickshot.Checked;

            ori.flags.starburst     = checkBoxStarburst.Checked;
            ori.flags.simulate      = checkBoxSimulate.Checked;
            ori.flags.only_simulate = true;

            // this will be overridden later, if external game grid is used.
            ori.flags.hotball = checkBoxHotball.Checked;

            // this will be overridden later, if external game grid is used.
            ori.flags._5cashball = checkBox5Hotball.Checked;

            ori.PackSize = Convert.ToInt32(textBoxPackSize.Text);
            if ((ori.Cards / ori.PackSize) * ori.PackSize != ori.Cards)
            {
                ori = null;
                MessageBox.Show("Cards does not divide by Pack Size evenly...");
                return(false);
            }

            if (comboBox1.SelectedItem != null)
            {
                String name = (comboBox1.SelectedItem as DataRowView).Row["name"].ToString();
                if (name != null && name.Length > 0)
                {
                    try
                    {
                        DataRow row      = (comboBox1.SelectedItem as DataRowView).Row;
                        DataRow original = row["original_row"] as DataRow;
                        if (original != null)
                        {
                            ori.dealer = BingoDealers.GetDealer(original);
                        }
                        //ori.cardreader = new CardReader( row["original_row"] as DataRow );
                        //if( ori.cardreader.Length != 0 )
                        //	ori.flags.cardfile = true;
                    }
                    catch { }
                }
                else
                {
                    ori.dealer = BingoDealers.nodealer;
                }
            }
            else
            {
                ori.dealer = BingoDealers.nodealer;
            }

            if (!LoadGameInfoFromGrid())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 8
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);
        }