Esempio n. 1
0
			internal PlayerBestCard( int pack, int card, BingoPlayer player, int away )
			{
				card_number = card;
				pack_number = pack;
				this.player = player;
				away_count = away;
			}
Esempio n. 2
0
        public wininfo(int card, int mask, Guid player)
        {
//			this.playing_card = playing_card;
            this.card_number = card;
            this.mask        = mask;
            this.player      = new BingoPlayer(player);
        }
Esempio n. 3
0
 public PlayerTransaction(BingoPlayer player, int transnum)
 {
     this.player   = player;
     this.transnum = transnum;
     this.ID       = Guid.NewGuid();
     loaded        = new List <bool>();
 }
Esempio n. 4
0
 public BingoCardState(byte[, ,] CardData, BingoPlayer _Player, PlayerPack pack, int unit_card, int real_card, BingoGameEvent game)
 {
     this.card                = CardData;
     this.player              = _Player;
     this.pack                = pack;
     this.unit_card_number    = unit_card;
     this.cardset_card_number = real_card;
     this.game                = game;
 }
Esempio n. 5
0
 public wininfo(int card_id, BingoCardState card)
 {
     this.ball_win_count = card.BallCount;
     this.playing_card   = card;
     this.card_number    = card.unit_card_number;
     this.card_index     = card_id;
     this.mask           = card.BestMask();
     this.player         = card.player;
     this.pack           = card.pack;
 }
Esempio n. 6
0
 public wininfo(int card_id, int card_number, int mask, BingoPlayer player, PlayerPack pack, byte[, ,] playing_card, int ball_count)
 {
     this.ball_win_count = ball_count;
     //this.playing_card = playing_card;
     this.card_number = card_number;
     this.card_index  = card_id;
     this.mask        = mask;
     this.player      = player;
     this.pack        = pack;
 }
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
		public static bool Calculate( BingoGameState s )
		{
			//return false;
			if( !s.game.rate )
				return false;
			//if( !GameCounts( s ) )
			//   return false;
            int electronic_one_away;
            int paper_one_away;
            if( s.session_event.session.schedule != null )
            {
                {
                    //DataRow[] e = game_points.Select( "type=1 and " + OpenSkieScheduler.Relations.SessionGameGroupGameOrder.PrimaryKey + "=" + s.game.session_game_group_game_id );
                    //electronic_one_away = e.Length > 0 ? Convert.ToInt32( e[0]["points"] ) : 0;
                    //DataRow[] p = game_points.Select( "type=2 and " + OpenSkieScheduler.Relations.SessionGameGroupGameOrder.PrimaryKey + "=" + s.game.session_game_group_game_id );
                    //paper_one_away = p.Length > 0 ? Convert.ToInt32( p[0]["points"] ) : 0;
                }
            }
			//if( s.bestwin < max_balls )
			{
				int[] totals = new int[26];
				//int[, ,] player_totals = new int[s.Players, s.Packs, 26];
				//int[] limited_totals = new int[26];
				//int[, ,] limited_player_totals = new int[s.Players, s.Packs, 26];
				List<PlayerBestCard>[] all_bests = new List<PlayerBestCard>[s.Players];
				//List<PlayerBestPackSet>[] all_pack_bests = new List<PlayerBestPackSet>[s.Packs];
				if( s.session_event._PlayerList != null )
				{
					int count = 0;

					int game_index = s.game.game_ID;

					//Log.log( "calculating for game " + game_index );

					foreach( PlayerPack pack in s.playing_packs )
//					foreach( BingoCardState card in s.playing_cards )
					//foreach( BingoPlayer player in s.session_event._PlayerList )
					{
						BingoPlayer player = pack.player;
						//PlayerPack pack = card.pack;
						int max_set = 0;
						int min_set = s.Packs;

						while( pack.card_away_count.Count <= game_index )
						{
							pack.card_away_count.Add( new List<CardPoints>() );
							//player.card_away_count.
						}

						{
							int set = pack.pack_set;
							if( set > 0 )
							{
								//while( set > best_packs.Count )
								//	best_packs.Add( new PlayerBestPackSet() );
								//best_packs[set - 1].member_packs.Add( pack.pack_info );
								//best_packs[set - 1].points = 0;
								if( set > max_set )
									max_set = set;
								if( set < min_set )
									min_set = set;
							}
							int this_count = s.game.GetCardCount( pack.pack_info );

							//Log.log( "Processing pack " + pack );

							foreach( BingoCardState card in pack.Cards[s.game.game_group.game_group_ID] )
							//lock( pack.card_away_count )
							{
								while( pack.card_away_count[game_index].Count <= card.pack_card_index )
								{
									// expand for number of cards in this game that this pack is...
									pack.card_away_count[game_index].Add( new CardPoints() );
								}

								int pack_points = 0;
								//for( int card = 0; card < count; card++ )

								{
									int away_count = card.BestAway();
									//Log.log( "Card away is " + away_count );
									pack.card_away_count[game_index][card.pack_card_index].away = away_count;
									if( away_count == 1 )
									{
										//if( pack.paper )
										//	pack.card_away_count[game_index][card.pack_card_index].points = paper_one_away;
										//else
										//	pack.card_away_count[game_index][card.pack_card_index].points = electronic_one_away;
									}
									else
										pack.card_away_count[game_index][card.pack_card_index].points = 0;

#if old_scoring_system
									DataRow[] value = points.Select( "away_count=" + away_count );
									if( value.Length > 0 )
										//best_packs[set - 1].points += Convert.ToInt32( value[0]["points"] );
										pack.card_away_count[game_index][card.pack_card_index].points = Convert.ToInt32( value[0]["points"] );

									pack.card_away_count[game_index][card.pack_card_index].away = away_count;
									//if( away_count > 0 )
									//player_totals[player.ID, pack_number, away_count]++;
									totals[away_count]++;
									//player_totals[player.ID, set, away_count]++;
#endif
#if using_absolute_best_cards
									if( max_rated_cards == 0 ||
											bests.Count < max_rated_cards )
									{
										//Log.log( "less than 84... adding " + away_count );
										bests.Add( new PlayerBestCard( pack_number, card_id, player, away_count ) );
									}
									else
									{
										int worst_away = 0;
										foreach( PlayerBestCard a in bests )
										{
											if( a.away_count > worst_away )
												worst_away = a.away_count;
										}
										//Log.log( "worst is " + worst_away + " this is " + away_count );
										if( worst_away > away_count )
										{
											// okay there is a card worse than this somewhere... get it and replace it.
											int swapout = bests.FindIndex( delegate( PlayerBestCard a ) { return ( a.away_count == worst_away ); } );
											if( swapout >= 0 )
											{
												//Log.log( "swapping " + swapout );
												bests[swapout] = new PlayerBestCard( pack_number, card_id, player, away_count );
											}
										}
									}
#endif
								}
							}
							count += s.game.GetCardCount( pack.pack_info );
						}

					}
				}
				else
				{
#if asdfasdf
					for( int player = 0; player < ( s.Players ); player++ )
					{
						for( int _card = 0; _card < ( s.Cards ); _card++ )
						{
							int card = player * s.Cards + _card;
							//Console.WriteLine( card+"=="+ s.playing_card_away[card, s.bestwin] );
							totals[s.playing_card_away[card, s.bestwin - 1]]++;
							player_totals[player, _card / s.PackSize, s.playing_card_away[card, s.bestwin - 1]]++;
						}
					}
#endif
				}
				//s.playing_card_away_totals = totals;
				//s.playing_card_away_pack_player_totals = player_totals;
				//s.playing_card_away_totals_limited = limited_totals;
				//s.playing_card_away_pack_player_totals_limited = limited_player_totals;
			}
			return true;
		}
Esempio n. 9
0
        /// <summary>
        /// This literally loads the packs each player is playing into the bingo game state
        /// </summary>
        /// <param name="_Player"></param>
        /// <param name="s"></param>
        void LoadPlayerCards(BingoPlayer _Player, List <object> game_pack_set_ids, BingoGameState s)
        {
            int            pack_number = 0;
            BingoGameGroup game_group  = s.game.game_group;

            while (_Player._played_cards.Count <= game_group.game_group_ID)
            {
                _Player._played_cards.Add(new List <BingoCardState>());
            }

            List <BingoCardState> player_card_list = _Player._played_cards[game_group.game_group_ID];

            // already loaded these cards?
            if (player_card_list.Count > 0)
            {
                return;
            }
            //player_card_list.Clear();

            //foreach( PlayerTransaction trans in _Player.transactions )
            {
                foreach (PlayerPack _pack in _Player.played_packs)
                {
                    bool skip_pack = true;
                    if (_pack.pack_info.game_groups.Count > 0)
                    {
                        foreach (BingoGameGroup group in _pack.pack_info.game_groups)
                        {
                            if (group.Contains(s.game))
                            {
                                // this pack is in this game, load cards for it.
                                game_group = group;
                                skip_pack  = false;
                                break;
                            }
                        }
                        if (skip_pack)
                        {
                            continue;
                        }
                    }
                    while (_pack.Cards.Count <= s.game.game_ID)
                    {
                        _pack.Cards.Add(new List <BingoCardState>());
                    }

                    pack_number++;

                    _pack.played = true;

                    int card_count = _pack.pack_info.count;                    // s.game.GetCardCount( _pack.pack_info );
                    if (_pack.pack_info.count == 0)
                    {
                        // pack does not play this game, skip it.
                        continue;
                    }

                    s.playing_packs.Add(_pack);

                    List <BingoCardState> game_cards = _pack.Cards[s.game.game_ID];

                    if (game_cards.Count < card_count)
                    {
                        if (_pack.dealer == null)
                        {
                            Log.log("Fatality, dealer not assigned on pack.");
                            continue;
                        }

                        int base_real_card = _pack.dealer.Add((_pack.start_card),
                                                              !_pack.paper
                                                                ? s.game.ballset_number
                                                                : s.game.page_skip);

                        //if( base_real_card > 320000 )
                        {
                            //	MessageBox.Show( "Card is out of range!" );
                        }


                        int col = 0;
                        int row = 0;
                        for (int card = 0; card < card_count; card++)
                        {
                            byte[, ,] card_faces;
                            row++;
                            if (row >= _pack.pack_info.rows)
                            {
                                col++;
                                row = 0;
                            }
                            //if( col == _pack.pack_info.
                            // dealer does a subtract 1, this is a 0 based physical card index.
                            if (base_real_card == 512301)
                            {
                                int a = 3;
                            }
                            int unit_card = _pack.dealer.GetNext(base_real_card, row, col, card);
                            int real_card = _pack.dealer.GetPhysicalNext(base_real_card, row, col, card);

                            if (_pack.dealer.card_data == null)
                            {
                                card_faces = new byte[1, 5, 5] {
                                    { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }
                                };
                            }
                            else
                            {
                                if (_pack.pack_info.name == "Double Double" || _pack.pack_info.name == "Dual Daub")
                                {
                                    int a = 3;
                                }
                                card_faces = _pack.dealer.card_data.Create(
                                    real_card
                                    , _pack.pack_info.flags.double_action ? 2 : 1
                                    , _pack.pack_info.flags.starburst
                                    );
                            }

                            BingoCardState cs = new BingoCardState(card_faces);
                            cs.player = _Player;
                            cs.pack   = _pack;
                            //cs.prize_level_id = _pack.pack_info._dealer.prize_level_id;
                            cs.unit_card_number    = unit_card;
                            cs.cardset_card_number = real_card;
                            cs.game = s.game_event;
                            game_cards.Add(cs);
                            cs.pack_card_index = game_cards.IndexOf(cs);

                            player_card_list.Add(cs);
                            s.playing_cards.Add(cs);

                            if (s.session_event.opened)
                            {
                                cs.ID = Local.bingo_tracking.AddCard(game_group.group_pack_set_id, _pack.ID, s.game.ballset_number, cs.unit_card_number, cs.CardData);
                            }
                        }
                    }
                    else
                    {
                        for (int card = 0; card < card_count; card++)
                        {
                            BingoCardState cs = _pack.Cards[s.game.game_ID][card];
                            s.playing_cards.Add(cs);
                            player_card_list.Add(cs);
                            if (s.session_event.opened)
                            {
                                cs.ID = Local.bingo_tracking.AddCard(null, _pack.ID, s.game.ballset_number, cs.unit_card_number, cs.CardData);
                            }
                        }
                    }
                }
            }
        }