Exemplo n.º 1
0
        /// <summary>
        /// This method performs initializations for this object.
        /// </summary>
        public void Init()
        {
            // Create a shuffler
            Shuffler = new RandomShuffler(1, 60, 10);

            // Shuffle ten times
            Shuffler.Shuffle(10);

            // Start with a random banner
            this.CurrentBanner = GetRandomBanner();
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method performs initializations for this object.
        /// </summary>
        public void Init()
        {
            // Create a Guid
            this.Id = Guid.Empty;

            // Changing the count to get the last 20 messages.
            this.DisplayMessagesCount = 20;

            // Create a Shuffler
            Shuffler = new RandomShuffler(1, 6, 1, 10);
        }
        /// <summary>
        /// This method returns the Random Location
        /// </summary>
        private Point GetRandomLocation(RandomShuffler shuffler)
        {
            // initial value (off screen)
            Point location = new Point(-1000, -1000);

            // locals
            int left = -1000;
            int top  = -1000;

            // if the shuffler has been shuffled
            if (shuffler.Shuffled)
            {
                // get the left
                left = shuffler.PullNextItem(false);

                // get the top
                top = shuffler.PullNextItem(false);
            }

            // if the value is set
            if ((left > 0) && (top > 0))
            {
                // the left can go wider, this spreads the chips out a little
                left = left * 2;

                // move items towards the center
                left -= 20;

                // move items up for the size of the chip and add a little padding
                top -= 20;

                // if top is less than padding
                if (top < 4)
                {
                    // reset
                    top = 4;
                }

                // if less than the padding value
                if (left < 4)
                {
                    // reset to padding
                    left = 4;
                }

                // create the location
                location = new Point(left, top);
            }

            // return value
            return(location);
        }
        private void GenerateTable(byte[] encryptionKey)
        {
            List <int> viableStates = new List <int>();
            int        maxState     = (Denominator << 1);

            for (int i = Denominator; i < maxState; i++)
            {
                viableStates.Add(i);
            }
            if (encryptionKey != null)
            {
                SeededRng rng = new SeededRng(encryptionKey);
                RandomShuffler <int> .ShuffleList(viableStates, rng);
            }
            else
            {
                RandomShuffler <int> .ShuffleList(viableStates);
            }
            Table = new Dictionary <int, Dictionary <int, int> >();
            GenerateStateRanges(out var stateRanges);
            FillTable(stateRanges, viableStates);
        }
Exemplo n.º 5
0
        /// <summary>
        /// This method returns the For Insurance
        /// </summary>
        internal void PromptForInsurance(IPlayerResponseRequest takeInsuranceRequest)
        {
            // verify this player is in this hand (has a hand and the GameMagager.Shuffler exists)
            bool isInHand = IsInHand();

            // If this player is dealt in
            if ((isInHand) && (this.HasPlayerControl) && (this.PlayerControl.HasTable))
            {
                // if this is a computer player
                if (this.IsComputerPlayer)
                {
                    // Find the Shuffler to use
                    RandomShuffler chipShuffler = this.PlayerControl.Table.ChipShuffler;

                    // if the Shuffler exists
                    if ((chipShuffler.HasRandomIntStorage) && (chipShuffler.CanPullNextItem()))
                    {
                        // get a randomIntValue
                        int randomIntValue = chipShuffler.PullNextItem(false);

                        // Take Insurance if the random value is an even number
                        bool takeInsurance = ((randomIntValue % 2) == 0);

                        // Send the response
                        PlayerResponse response = null;

                        // if this player choose to takeInsurance
                        if (takeInsurance)
                        {
                            // the player choose to take insurance

                            // Create a response this player took insurance
                            response = new PlayerResponse(ResponseTypeEnum.Insurance, this.CurrentHand.AmountWagered / 2);

                            // This was an insurance request
                            response.ResponseRequestType = ResponseRequestTypeEnum.Insurance;

                            // Get a reference to the PlayerResponseControl
                            PlayerResponseControl playerResponseControl = this.PlayerControl.Table.GetPlayerResponseControl();

                            // If the playerResponseControl object exists
                            if (NullHelper.Exists(playerResponseControl))
                            {
                                // If the value for the property playerResponseControl.HasSendResponseCallBack is true
                                if (playerResponseControl.HasSendResponseCallBack)
                                {
                                    // Send the response back
                                    playerResponseControl.SendResponseCallBack(response);
                                }
                            }
                        }
                        else
                        {
                            // the player declined taking insurance

                            // Create a response this player took insurance
                            response = new PlayerResponse(ResponseTypeEnum.No);

                            // This was an insurance request
                            response.ResponseRequestType = ResponseRequestTypeEnum.Insurance;

                            // Get a reference to the PlayerResponseControl
                            PlayerResponseControl playerResponseControl = this.PlayerControl.Table.GetPlayerResponseControl();

                            // If the playerResponseControl object exists
                            if (NullHelper.Exists(playerResponseControl))
                            {
                                // If the value for the property playerResponseControl.HasSendResponseCallBack is true
                                if (playerResponseControl.HasSendResponseCallBack)
                                {
                                    // Send the response back
                                    playerResponseControl.SendResponseCallBack(response);
                                }
                            }
                        }
                    }
                }
                else
                {
                    // This is a human so start the ResponseRequest
                    takeInsuranceRequest.Start(this.PlayerControl.Table.GameManager.ResponseControl, this.PlayerControl);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// event is fired when the 'GetDataButton' is clicked.
        /// </summary>
        private void GetDataButton_Click(object sender, EventArgs e)
        {
            // Erase
            this.ResultsTextBox.Text = "Generating random data, please wait...";

            // Refresh everything
            this.Refresh();
            Application.DoEvents();

            // Create a new Gateway instance
            Gateway gateway = new Gateway(MainForm.ConnectionName);

            // if the FirstNames do not exist
            if (!this.HasFirstNames)
            {
                // Load the FirstNames
                this.FirstNames = gateway.LoadFirstNames();
            }

            // if the LastNames do not exist
            if (!this.HasLastNames)
            {
                // Load the LastNames
                this.LastNames = gateway.LoadLastNames();
            }

            // if the Verbs do not exist
            if (!this.HasVerbs)
            {
                // Load the Verbs
                this.Verbs = gateway.LoadVerbs();
            }

            // if the Adjectives do not exist
            if (!this.HasAdjectives)
            {
                // Load the Adjectives
                this.Adjectives = gateway.LoadAdjectives();
            }

            // if the Nouns do not exist
            if (!this.HasNouns)
            {
                // Load the Nouns
                this.Nouns = gateway.LoadNouns();
            }

            // if all the lists exist
            if ((ListHelper.HasOneOrMoreItems(FirstNames, LastNames, Adjectives)) && (ListHelper.HasOneOrMoreItems(Verbs, Nouns)))
            {
                // Create the shufflers if they don't exist
                if (!HasShuffler)
                {
                    // Create a new instance of a 'RandomShuffler' object.
                    Shuffler = new RandomShuffler(0, firstNames.Count, 5);
                }

                // if the Shffler2 doesn't exist
                if (!HasShuffler2)
                {
                    // Create a new instance of a 'RandomShuffler' object.
                    Shuffler2 = new RandomShuffler(0, lastNames.Count, 5);
                }

                // if the Shffler3 doesn't exist
                if (!HasShuffler3)
                {
                    // Create a new instance of a 'RandomShuffler' object.
                    Shuffler3 = new RandomShuffler(0, Verbs.Count, 5);
                }

                // if the Shffler4 doesn't exist
                if (!HasShuffler4)
                {
                    // Create a new instance of a 'RandomShuffler' object.
                    Shuffler4 = new RandomShuffler(0, Adjectives.Count, 5);
                }

                // if the Shffler5 doesn't exist
                if (!HasShuffler5)
                {
                    // Create a new instance of a 'RandomShuffler' object.
                    Shuffler5 = new RandomShuffler(0, Nouns.Count, 5);
                }

                // Display the character name
                this.ResultsTextBox.Text = "Random Characters/Plot: " + Environment.NewLine;

                // iterate up to 10 names
                for (int x = 0; x < 10; x++)
                {
                    // Pull the next items
                    int firstNameIndex = shuffler.PullNextItem();
                    int lastNameIndex  = shuffler2.PullNextItem();
                    int verbIndex      = shuffler3.PullNextItem();
                    int adjectiveIndex = shuffler4.PullNextItem();
                    int nounIndex      = shuffler5.PullNextItem();

                    // Set the first and last name
                    string firstName = firstNames[firstNameIndex].Name;
                    string lastName  = lastNames[lastNameIndex].Name;
                    string verb      = Verbs[verbIndex].WordText;
                    string adjective = Adjectives[adjectiveIndex].WordText;
                    string noun      = Nouns[nounIndex].WordText;

                    // Add to the text
                    this.ResultsTextBox.Text += firstName + " " + lastName + " " + verb + " " + adjective + " " + noun;

                    // if not the last item
                    if (x < 9)
                    {
                        // Display the character name
                        this.ResultsTextBox.Text += Environment.NewLine;
                    }
                }
            }
        }