Ejemplo n.º 1
0
        /// <summary>
        /// This event is fired when Grid _ Cell Content Click
        /// </summary>
        private void Grid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // Get the columnIndex
            int columnIndex = e.ColumnIndex;

            // if this is the LinkButton
            if (e.ColumnIndex == 0)
            {
                // we must get the name of the selected System
                string systemName = FindSystemName(e.RowIndex);

                // If the systemName string exists
                if (TextHelper.Exists(systemName))
                {
                    // Find this system
                    ICardCountingSystem selectedSystem = CardCountingSystemFactory.FindCardCountingSystem(systemName);

                    // If the selectedSystem object exists
                    if (NullHelper.Exists(selectedSystem))
                    {
                        // get the helpLink
                        string helpLink = selectedSystem.HelpLink;

                        // if the helpLink exists
                        if (TextHelper.Exists(helpLink))
                        {
                            // Open a browser wined
                            System.Diagnostics.Process.Start(helpLink);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method performs initializations for this object.
        /// </summary>
        public void Init()
        {
            // Create each of the systems
            List <ICardCountingSystem> countingSystems = CardCountingSystemFactory.LoadCardCountingSystems();

            // load the combo box
            this.CountingSystemControl.LoadItems(countingSystems);

            // Select High Low
            this.CountingSystemControl.SelectedIndex = 0;

            // Wire up the Check Changed Listener
            this.SeatNumberCheckBox.CheckChangedListener = this;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method returns the Player
        /// </summary>
        internal Player CapturePlayer()
        {
            // initial value
            Player player = null;

            // If the Player object exists
            if (this.HasPlayer)
            {
                // use the existing player
                player = this.Player;
            }
            else
            {
                // Create a new instance of a 'Player' object.
                player = new Player();
            }

            // is this player seated
            player.SeatNumber = (SeatNumberEnum)this.SeatNumber;

            // if there is a selected card counting system
            if (this.CountingSystemControl.HasSelectedObject)
            {
                // Set the CardCountingSystem
                player.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(this.CountingSystemControl.SelectedObject.ToString());
            }

            // Set the players name
            player.Name = this.NameControl.Text;

            // Get the current chips
            player.Chips = NumericHelper.ParseDouble(this.ChipsControl.Text.Replace(",", "").Replace("$", ""), 0, -1);

            // Is this a computer player
            player.IsComputerPlayer = this.IsComputerPlayerCheckBox.Checked;

            // return value
            return(player);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This method performs initializations for this object.
        /// </summary>
        public void Init()
        {
            // Do not allow edits
            this.Grid.ReadOnly = true;

            // Create the HeaderImage
            this.HeaderImage = Properties.Resources.DeepGray;

            // Create the countingSystemsList
            List <ICardCountingSystem> countingSystemsList = CardCountingSystemFactory.LoadCardCountingSystems();

            // convert the list of countingSystems
            this.CountingSystems = CountingSystemViewFactory.Convert(countingSystemsList);

            // Set the Column Header Height
            Grid.ColumnHeadersDefaultCellStyle.SelectionBackColor = Color.LemonChiffon;

            // Size the Height of the Rows
            Grid.RowTemplate.Height = 30;
            Grid.AutoSizeRowsMode   = DataGridViewAutoSizeRowsMode.None;

            // Set the DataSource
            this.Grid.DataSource = countingSystems;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This method is used to load a GameManager object from the values from this object
        /// so that the controls be can be loaded when the program starts
        /// </summary>
        /// <returns></returns>
        public static GameManager Export(SecureUserData security, List <BlackJackPlayerControl> playerControls, MainForm table)
        {
            // initial value
            GameManager gameManager = null;

            // local
            BlackJackPlayerControl playerControl = null;

            // If the security object exists
            if (NullHelper.Exists(security, playerControls, table))
            {
                // Create a new instance of a 'GameManager' object.
                gameManager = new GameManager(NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1), table);

                // create a houseRules object
                Options houseRules = new Options();

                // set the properties from this form
                houseRules.AllowDoubleDown              = security.AllowDoubleDown;
                houseRules.AllowDoubleOnSplit           = security.AllowDoubleOnSplit;
                houseRules.AllowDoubleOnTenOrElevenOnly = security.AllowDoubleOnTenOrElevenOnly;
                houseRules.AllowInsurance   = security.AllowInsurance;
                houseRules.AllowResplitAces = security.AllowResplitAces;
                houseRules.AllowSplit       = security.AllowSplit;
                houseRules.AllowSplitAces   = security.AllowSplitAces;
                houseRules.AllowSurrender   = security.AllowSurrender;
                houseRules.ComputerPlayersUnlimitedRebuys = security.ComputerPlayersUnlimitedRebuys;
                houseRules.DealerMustHitSoft17            = security.DealerMustHitSoft17;
                houseRules.DefaultBankRoll         = security.DefaultBankRoll;
                houseRules.DefaultComputerBankRoll = security.DefaultComputerBankRoll;
                houseRules.GameSpeed = security.GameSpeed;
                houseRules.HumanPlayerUnlimitedRebuys = security.HumanPlayerUnlimitedRebuys;
                houseRules.NumberDecks = security.NumberDecks;
                houseRules.Penetration = security.Penetration;
                houseRules.SaveSettingsOnThisComputer = security.SaveSettingsOnThisComputer;
                houseRules.TableMaximum = security.TableMaximum;
                houseRules.TableMinimum = security.TableMinimum;

                // Create a list of players
                List <Player> players = new List <Player>();

                // if Player1's Name is set that is consider playing
                if (TextHelper.Exists(security.Player1Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat1);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 1
                        Player player1 = new Player(security.Player1Name, security.Player1Chips, security.Player1IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player1.SeatNumber = SeatNumberEnum.Seat1;

                        // Is Player1 Sitting Out
                        player1.SittingOut = security.Player1SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player1CountingSystem;
                        player1.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player1);
                    }
                }

                // if Player2's Name is set that is consider playing
                if (TextHelper.Exists(security.Player2Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat2);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 2
                        Player player2 = new Player(security.Player2Name, security.Player2Chips, security.Player2IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player2.SeatNumber = SeatNumberEnum.Seat2;

                        // Is Player2 Sitting Out
                        player2.SittingOut = security.Player2SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player2CountingSystem;
                        player2.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player2);
                    }
                }

                // if Player3's Name is set that is consider playing
                if (TextHelper.Exists(security.Player3Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat3);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 3
                        Player player3 = new Player(security.Player3Name, security.Player3Chips, security.Player3IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player3.SeatNumber = SeatNumberEnum.Seat3;

                        // Is Player3 Sitting Out
                        player3.SittingOut = security.Player3SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player3CountingSystem;
                        player3.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player3);
                    }
                }

                // if Player4's Name is set that is consider playing
                if (TextHelper.Exists(security.Player4Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat4);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 4
                        Player player4 = new Player(security.Player4Name, security.Player4Chips, security.Player4IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player4.SeatNumber = SeatNumberEnum.Seat4;

                        // Is Player4 Sitting Out
                        player4.SittingOut = security.Player4SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player4CountingSystem;
                        player4.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player4);
                    }
                }

                // if Player5's Name is set that is consider playing
                if (TextHelper.Exists(security.Player5Name))
                {
                    // Find the PlayerControl
                    playerControl = FindPlayerControl(playerControls, SeatNumberEnum.Seat5);

                    // if the control was found
                    if (NullHelper.Exists(playerControl))
                    {
                        // create player 5
                        Player player5 = new Player(security.Player5Name, security.Player5Chips, security.Player5IsComputerPlayer, playerControl);

                        // Setup the SeatNumber
                        player5.SeatNumber = SeatNumberEnum.Seat5;

                        // Is Player5 Sitting Out
                        player5.SittingOut = security.Player5SittingOut;

                        // Set the CountingSystem
                        string countingSystemName = security.Player5CountingSystem;
                        player5.CardCountingSystem = CardCountingSystemFactory.FindCardCountingSystem(countingSystemName);

                        // add this player
                        players.Add(player5);
                    }
                }

                // set the HouseRules & players
                gameManager.HouseRules = houseRules;
                gameManager.Players    = players;

                // if the HouseRules exist
                if (gameManager.HasHouseRules)
                {
                    // create
                    BlackJackCardValueBase blackJackCardValueBase = new BlackJackCardValueBase();

                    // Set the times to shuffle
                    int timesToShuffle = NumericHelper.ParseInteger(Properties.Resources.TimesToShuffle, 0, -1);

                    // Create the Shuffler
                    gameManager.Shuffler = new RandomShuffler(houseRules.NumberDecks, blackJackCardValueBase, 0);
                }
            }

            // return value
            return(gameManager);
        }