/// <summary>
        /// This method returns the Card
        /// </summary>
        private static string ConvertCard(CardEnum card, ICardCountingSystem countingSystem)
        {
            // initial value
            string cardValue = "";

            // locals
            Card   redCard        = null;
            Card   blackCard      = null;
            string redCardValue   = "";
            string blackCardValue = "";

            // create a red and black card
            redCard        = new Card(SuitEnum.Hearts, card, countingSystem);
            blackCard      = new Card(SuitEnum.Spades, card, countingSystem);
            redCardValue   = GetCardValue(redCard, countingSystem);
            blackCardValue = GetCardValue(blackCard, countingSystem);

            // if the values are the same
            if (redCardValue == blackCardValue)
            {
                // Set the value
                cardValue = redCardValue.ToString();
            }
            else
            {
                // Set both values
                cardValue = redCardValue.ToString() + @"/" + blackCardValue.ToString();
            }

            // return value
            return(cardValue);
        }
        /// <summary>
        /// This method converts an ICardCountingSystem to a CardCoutnignView object.
        /// </summary>
        /// <param name="countingSystem"></param>
        /// <returns></returns>
        public static CountingSystemView Convert(ICardCountingSystem countingSystem)
        {
            // initial value
            CountingSystemView countingSystemView = null;

            // If the countingSystem object exists
            if (NullHelper.Exists(countingSystem))
            {
                // Create a new instance of a 'CountingSystemView' object.
                countingSystemView = new CountingSystemView();

                // Set the value for each property
                countingSystemView.Balanced = countingSystem.BalancedSystem;
                countingSystemView.Name     = countingSystem.Name;
                countingSystemView.Level    = ConvertLevel(countingSystem.Level);
                countingSystemView.Notes    = countingSystem.Notes;

                // Now set the Card Values; we have to set each value with a red and black card in case this
                // counting system returns different values.
                countingSystemView.Ace   = ConvertCard(CardEnum.Ace, countingSystem);
                countingSystemView.Two   = ConvertCard(CardEnum.Two, countingSystem);
                countingSystemView.Three = ConvertCard(CardEnum.Three, countingSystem);
                countingSystemView.Four  = ConvertCard(CardEnum.Four, countingSystem);
                countingSystemView.Five  = ConvertCard(CardEnum.Five, countingSystem);
                countingSystemView.Six   = ConvertCard(CardEnum.Six, countingSystem);
                countingSystemView.Seven = ConvertCard(CardEnum.Seven, countingSystem);
                countingSystemView.Eight = ConvertCard(CardEnum.Eight, countingSystem);
                countingSystemView.Nine  = ConvertCard(CardEnum.Nine, countingSystem);
                countingSystemView.Ten   = ConvertCard(CardEnum.Ten, countingSystem);
            }

            // return value
            return(countingSystemView);
        }
Esempio n. 3
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);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// This method returns the Card Value
        /// </summary>
        private static string GetCardValue(Card card, ICardCountingSystem countingSystem)
        {
            // initial value
            string cardValueAsString = "";

            // If the countingSystem object exists
            if (NullHelper.Exists(countingSystem, card))
            {
                // Call the counting system to get the CardValue
                double cardValue = countingSystem.GetCardCountValue(card);

                // now convert the value to a string
                cardValueAsString = cardValue.ToString();
            }

            // return value
            return(cardValueAsString);
        }
Esempio n. 5
0
        /// <summary>
        /// This method Display Player
        /// </summary>
        private void DisplayPlayer()
        {
            // locals
            bool   isSeated         = false;
            bool   isComputerPlayer = false;
            int    countSystemIndex = -1;
            string name             = "";
            string chips            = "$.0.00";

            // If the Player object exists
            if (this.HasPlayer)
            {
                // set the values
                isSeated = this.Player.Seated;
                ICardCountingSystem countingSystem = this.Player.CardCountingSystem;
                name             = this.Player.Name;
                chips            = "$" + String.Format("{0:n0}", this.Player.Chips);
                isComputerPlayer = this.Player.IsComputerPlayer;

                // if the countingSystem exists
                if (NullHelper.Exists(countingSystem))
                {
                    // Find the countSystemIndex
                    countSystemIndex = FindCountSystemIndex(countingSystem);
                }
                else
                {
                    // Find the countSystemIndex
                    HighLowSystem highLow = new HighLowSystem();
                    countSystemIndex = FindCountSystemIndex(highLow);
                }
            }

            // Check the box if seated
            this.IsComputerPlayerCheckBox.Checked    = isComputerPlayer;
            this.SeatNumberCheckBox.Checked          = isSeated;
            this.CountingSystemControl.SelectedIndex = countSystemIndex;
            this.NameControl.Text  = name;
            this.ChipsControl.Text = chips;
        }
Esempio n. 6
0
        /// <summary>
        /// This method returns the Count System Index
        /// </summary>
        private int FindCountSystemIndex(ICardCountingSystem countingSystem)
        {
            // initial value
            int countSystemIndex = -1;

            // locals
            int index = -1;

            // If the countingSystem object exists
            if (NullHelper.Exists(countingSystem))
            {
                // iterate the items in this controls
                foreach (object item in this.CountingSystemControl.Items)
                {
                    // Increment the value for index
                    index++;

                    // cast the item as an ICardCountingSystem object
                    string name = item.ToString();

                    // If the tempCountingSystem object exists
                    if (TextHelper.Exists(name))
                    {
                        // if this is the item being sought
                        if (TextHelper.IsEqual(name, countingSystem.Name))
                        {
                            // set the return value
                            countSystemIndex = index;

                            // break out of the loop
                            break;
                        }
                    }
                }
            }

            // return value
            return(countSystemIndex);
        }
        /// <summary>
        /// This method returns the Card Counting System
        /// </summary>
        internal static ICardCountingSystem FindCardCountingSystem(string countingSystemName)
        {
            // initial value
            ICardCountingSystem countingSystem = null;

            // If the countingSystemName string exists
            if (TextHelper.Exists(countingSystemName))
            {
                // determine the CountingSystem to return based upon the CountingSystemName
                switch (countingSystemName)
                {
                case "Basic Strategy (No Count)":

                    // Create this countingSystem
                    countingSystem = new BasicStrategySystem();

                    // required
                    break;


                case "High - Low":

                    // Create this countingSystem
                    countingSystem = new HighLowSystem();

                    // required
                    break;

                case "High Opt I":

                    // Create this countingSystem
                    countingSystem = new HighOptISystem();

                    // required
                    break;

                case "High Opt II":

                    // Create this countingSystem
                    countingSystem = new HighOptIISystem();

                    // required
                    break;

                case "KISS II":

                    // Create this countingSystem
                    countingSystem = new KISSIISystem();

                    // required
                    break;

                case "KISS III":

                    // Create this countingSystem
                    countingSystem = new KISSIIISystem();

                    // required
                    break;

                case "Wong Halves":

                    // Create this countingSystem
                    countingSystem = new WongHalvesSystem();

                    // required
                    break;

                case "Knock Out":

                    // Create this countingSystem
                    countingSystem = new KnockOutSystem();

                    // required
                    break;
                }
            }

            // return value
            return(countingSystem);
        }