Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Random            r = new Random();
            int               n;
            BallDataInterface bdi;

            //for( n = 0; n < 5550; n++ )
            for (n = 0; n < 5325; n++)
            {
                players.Add(new Player(r.Next(1000000000)));
            }

            bdi = shuffler = new BallData_Random75(players.Count);
            for (n = 0; n < num_to_draw; n++)
            {
                int[] order;
                lists[n] = new List <Player>();
                order    = bdi.CallBalls(players.Count);
                for (int p = 0; p < players.Count; p++)
                {
                    lists[n].Add(players[order[p] - 1]);
                }
            }
            label3.Text = players.Count.ToString();
        }
Exemple #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            players.Clear();
            PlayerLoader pl = new PlayerLoader(players);

            pl.ShowDialog();
            pl.Dispose();


            int n;
            BallDataInterface bdi;

            bdi = shuffler = new BallData_Random75(players.Count);
            for (n = 0; n < num_to_draw; n++)
            {
                int[] order;
                lists[n] = new List <Player>();
                order    = bdi.CallBalls(players.Count);
                for (int p = 0; p < players.Count; p++)
                {
                    lists[n].Add(players[order[p] - 1]);
                }
            }
            label3.Text = players.Count.ToString();
        }
Exemple #3
0
 public UPickFactory(int upick_size)
 {
     this.upickem_size = upick_size;
     random_source     = new BallData_Random75();
     random_source.DropBalls();
     random_offset = 75;
 }
Exemple #4
0
 /// <summary>
 /// Result game event is sourced by external or existing number generator...
 /// </summary>
 public BingoGameEvent(BingoGame game, BallDataInterface bdi = null)
 {
     this.games.Add(game);
     if (bdi != null)
     {
         this.ball_interface = bdi;
     }
     //game.
 }
Exemple #5
0
        public BingoSessionEvent(BingoSession base_session, BallDataInterface bdi)
        {
            session   = base_session;
            ball_data = bdi;

            //game_group_list = game_groups;

            session_number = base_session.session;

            bingoday = base_session.bingoday;

            _PlayerList = new BingoPlayers(this);
        }
Exemple #6
0
        private void button7_Click(object sender, EventArgs e)
        {
            DataTable tmp        = new DataTable();
            String    sql_script = INI.Default["Player Select"]["SQL Statement"].Value;

            String[] sql_commands = sql_script.Split(new char[] { ';' });
            int      n_command    = 0;
            string   card_column  = INI.Default["Player Select"]["Card column name"].Value;
            string   name_column  = INI.Default["Player Select"]["Name column name"].Value;

            players.Clear();

            for (n_command = 0; n_command < (sql_commands.Length - 1); n_command++)
            {
                StaticDsnConnection.dsn.ExecuteNonQuery(sql_commands[n_command]);
            }
            if (DsnSQLUtil.FillDataTable(StaticDsnConnection.dsn, tmp, sql_commands[n_command], true) != null)
            {
                // uhmm...
            }
            else
            {
                tmp = null;
            }
            if (tmp == null)
            {
                MessageBox.Show(StaticDsnConnection.dsn.Error, "SQL Error or No Data");
                return;
            }

            foreach (DataRow row in tmp.Rows)
            {
                players.Add(new Player(0, row[card_column].ToString(), row[name_column].ToString()));
            }
            int n;

            player_shuffler = shuffler = new BallData_Random75(players.Count);
            for (n = 0; n < num_to_draw; n++)
            {
                int[] order;
                lists[n] = new List <Player>();

                order = player_shuffler.CallBalls(players.Count);
                for (int p = 0; p < players.Count; p++)
                {
                    lists[n].Add(players[order[p] - 1]);
                }
            }
            label3.Text = players.Count.ToString();
        }
Exemple #7
0
        public Form1(string[] args)
        {
            InitializeComponent();
            num_to_draw = INI.Default["Player Select"]["player draw count"].Integer;
            sets        = new pick_set[num_to_draw];
            for (int p = 0; p < num_to_draw; p++)
            {
                sets[p] = new pick_set();
            }
            lists   = new List <Player> [num_to_draw];
            players = new List <Player>();

            player_shuffler = new BallData_Random75();

            File_output = INI.Default["Output"]["File Path", "c:/players/winners.txt"];

            if (INI.Default["Ball Select"]["Use prize validation database"].Bool)
            {
                bdi = null;
            }
            else if (INI.Default["Ball interface"]["Use random Ball generator", "1"].Bool)
            {
                bdi = new BallData_Random75();
            }

            if (args.Length > 1)
            {
                if (args[1] == "go")
                {
                    button7_Click(button7, new EventArgs());
                    if (players.Count > 5)
                    {
                        button2_Click(button2, new EventArgs());
                    }
                    else
                    {
                        AbortStatus();
                    }
                    this.Close();
                }
            }
        }
Exemple #8
0
 public CardFactory(int balls)
 {
     bdi     = new BallData_Random75(balls);
     entropy = new Random();
     nums    = bdi.CallBalls();
 }
Exemple #9
0
        void UpdateStatus()
        {
            StreamWriter sw      = null;
            int          written = 0;

            try
            {
                sw = new StreamWriter(File_output, false);
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("Path does not exist for file [" + File_output + "]" + "\n Will not write file output, sorry.");
                return;
            }

            catch (FileNotFoundException)
            {
                MessageBox.Show("Path does not exist for file [" + File_output + "]");
                return;
            }
            listBox1.Items.Clear();
restart:
            for (int p = 0; p < num_to_draw; p++)
            {
                if (sets[p].picked != null)
                {
                    for (int p2 = p + 1; p2 < num_to_draw; p2++)
                    {
                        if (sets[p].picked.card == sets[p2].picked.card)
                        {
                            List <Player> shuffled = new List <Player>();
                            {
                                BallDataInterface bdi   = shuffler;
                                int[]             order = player_shuffler.CallBalls(players.Count);
                                for (int p3 = 0; p3 < players.Count; p3++)
                                {
                                    shuffled.Add(players[order[p3] - 1]);
                                }
                            }
                            sets[p2].BucketPlayers(shuffled);
                            for (int n = 0; n < this.balls.Count; n++)
                            {
                                sets[p2].ReBucketPlayers(balls[n]);
                                if (sets[p2].finished)
                                {
                                    break;
                                }
                            }
                            goto restart;
                        }
                    }
                }
            }
            for (int p = 0; p < num_to_draw; p++)
            {
                if (sets[p].finished)
                {
                    sw.WriteLine(sets[p].picked.name + "," + sets[p].picked.card + '@' + players.Count);
                    written++;
                    listBox1.Items.Add(sets[p].picked.name);
                }
            }
            if (written == 0)
            {
                sw.WriteLine("No Player,000000000000000000,0");
            }
            sw.Close();
        }
Exemple #10
0
 public UPickFactory()
 {
     random_source = new BallData_Random75();
     random_source.DropBalls();
     random_offset = 75;
 }
Exemple #11
0
        // all cards in the session? the game lists should maintain this good enough?
        //public card_list playing_cards;



        /// <summary>
        /// This completes final initialization fo a bingo game state, including loading the cards for each player
        /// </summary>
        /// <param name="game_index">if game== null, index will be used to get the GameList entry at the index.</param>
        /// <param name="result">this is the partial state we're going to use...</param>
        /// <returns>result or NULL if fails</returns>
        public BingoGameState StepToUsing(int game_index, BingoGameState result, BallDataInterface bdi = null)
        {
            // setup a play state for an absolute game number...
            // get one game of all the ones defined in the bingo core state...

            lock (this.step_lock)
            {
                BingoGame game = null;
                result.game_needs_balls = false;

                // no games in state.
                if (session.GameList == null || session.GameList.Count == 0)
                {
                    // return an early result (no process)
                    return(result);
                }

                result.session_event = this;
                {
                    {
                        // if game is already set, no reason to use game_index
                        if (result.game == null)
                        {
                            if (game_index >= session.GameList.Count)
                            {
                                Log.log("StepTo passed a game number beyond the current list.");
                                return(result);
                                // need to do a step of session.
                                // setup some hotballs ....
                            }

                            // new session, played all players and all their cards
                            game = session.GameList[game_index];
                        }
                        else
                        {
                            game = result.game;
                        }
                        // should wait before running the NEXT game...
                        // for that game to finish...
                        while (game.playing)
                        {
                            Thread.SpinWait(1);
                        }

                        if (result.game == null)
                        {
                            // though at this point I should have result.session_event... and we should have
                            // been progressing through that...


                            // with events, I need to know the prior event ....
                            // but the threaded nature of this makes this impossible... since we are
                            // not really within a session container... it's really an observation of
                            // game by game...

                            if (prior_game_event != null && game.prior_game != null && game.into)
                            {
                                result.game_event       = BingoGameEvent.Continue(prior_game_event, game);
                                result.game_event_index = result.game_event.games.Count - 1;
                            }
                            else
                            {
                                result.game_event = new BingoGameEvent(game, bdi);
                                prior_game_event  = result.game_event;
                            }

                            string[] str = game.Name.Split('\t');
                            if (my_store_to_database)
                            {
                                game.ID = Local.bingo_tracking.OpenGame(game_index + 1, game.ballset_number, str[1]);                                   //game.Name );
                            }
                            if (game.number_colored > 0)
                            {
                                int[] newballs = new int[game.number_colored];
                                int   n;
                                for (n = 0; n < game.number_colored; n++)
                                {
                                    newballs[n] = -1 - n;
                                }
                                result.game_event.balls.AddExtraBalls(newballs);
                            }
                            if (game.cashballs == 5)
                            {
                                byte[] card = result.game_event.card_factory.Create5Card();
                                result.game_event.playing_hotballs = new int[card.Length];
                                for (int n = 0; n < card.Length; n++)
                                {
                                    result.game_event.playing_hotballs[n] = card[n];
                                }
                            }
                            else
                            {
                                result.game_event.playing_hotballs = result.game_event.balls.CallBalls(game.cashballs);
                            }
                        }
                    }
                }

                result.bestwin = session.max_balls;                // game.bestwin; // start at more than any level...

                // this is indexed with -1... soo [card, ball-1] == count away.
                result.winning_cards = new List <wininfo>();
                // this resultset is the whole sess's cards?
                result.playing_cards = new List <BingoCardState>();                 // playing_cards;
                result.playing_packs = new List <PlayerPack>();

                result.valid = true;

                result.session_event = this;

                List <object> game_pack_set_ids = new List <object>();
                if (opened)
                {
                    if (my_store_to_database)
                    //foreach( BingoGameGroup group in result.game.game_groups )
                    {
                        game_pack_set_ids.Add(result.game.game_group.group_pack_set_id = Local.bingo_tracking.AddPackSetToGame(result.game.game_group.pack_set_id));
                    }
                }
                else
                {
                    game_pack_set_ids.Add(Guid.Empty);
                }

                /*
                 * if( _PlayerList != null )
                 * {
                 *      foreach( BingoPlayer player in _PlayerList )
                 *      {
                 *              LoadPlayerCards( player, game_pack_set_ids, result );
                 *      }
                 * }
                 */
                // 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);
            }
        }