Пример #1
0
        private void ButtonEndTurn_Click(object sender, RoutedEventArgs e)
        {
            /*
             * Ends the turn for the current player
             * Should reset the dice roll
             */

            btnDice.Content = "Dice Roll";

            Chatlog.Content = Chatlog.Content + "\n> " + player.getName() + "'s turn has ended. Player 2's turn begins.";
            Chatlog.ScrollToEnd();
        }
Пример #2
0
        private void ButtonDiceRoll_Click(object sender, RoutedEventArgs e)
        {
            /*
             * Generates a random value (1-n)
             * where n is the maximum value of the selected die
             * The value then changes the button text and sends
             * a message to the chat log
             */

            int diceMax = 20;       //Max value set to 20 as default, will change in the future

            Random rngDice = new Random();

            diceRollVal = (int)(rngDice.NextDouble() * diceMax) + 1;

            btnDice.Content = diceRollVal;

            Chatlog.Content = Chatlog.Content + "\n> " + player.getName() + " has rolled a " + diceRollVal;
            Chatlog.ScrollToEnd();
        }
Пример #3
0
        /// <summary>
        /// Detects when user hits enter key to signal inpout of a command or text to the chat. Can be expanded on in the future.
        /// </summary>
        /// <param name="sender">Eventually will contain info about who the request is from for username information</param>
        /// <param name="e">The key that is pressed. We are looking for the enter key, others can be used here</param>
        private void Chatbox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key.Equals(Key.Enter) && Chatbox.Text != "")    //User submitted request

            {
                if (Chatbox.Text.StartsWith("/"))       //Request is a command
                {
                    Chatlog.Content += ProcessCommand(Chatbox.Text.ToLower().Split());
                }
                else                                                         //Request is a chat message
                {
                    Chatlog.Content = Chatlog.Content + "\n" + Chatbox.Text; //TODO: @Ruiming this is where I moved your chat events to.
                    Chatbox.Text    = "";
                }

                //TODO: @Noah - I want to allow users to hit up and be able to reselect old requests they entered during this session. This will require storing this info before clearning.
                Chatbox.Text = ""; //Clear chatbox after input is dealt with

                Chatlog.ScrollToEnd();
            }
        }