Esempio n. 1
0
 //Default constructor
 public SelectedNumbersListType()
 {
     ///Initializes tracked numbers obj
     numbersTracked = new TrackUsedNumbers();
 }
Esempio n. 2
0
 //Resets tracked numbers
 public void reset()
 {
     TrackUsedNumbers numbersTracked = new TrackUsedNumbers();
     //numbersTracked.initilizeTrackedNumbersArray();
 }
Esempio n. 3
0
        //This is the code that will copy the player guesses and store them into a guess
        //area. It will also display the hints to the player as well.
        private void btnChoiceConfirm_Click(object sender, EventArgs e)
        {
            bool         winner          = false;
            string       loseMessage     = "Congrats! You managed to lose the game! Better luck next time!";
            string       continueMessage = "Do you want to play again?";
            string       winMessage      = "Congrats! You win!";
            DialogResult button;

            // Gets a number from the colors that are picked and places them into an array
            for (int i = 0; i < 4; i++)
            {
                guessArray[i] = myColor.getCode(newPlayerGuessButton[0, i]);
            }

            //Copies array into Guess Area Class array
            myGuess.GuessArray = guessArray;


            //Shows players guess in message box
            MessageBox.Show("Guess is: " + myGuess.getArraytoDisplay());

            //Fills in buttons from player guess area to guess board
            for (int i = 0; i < 4; i++)
            {
                newGuessButton[i, guessCount].BackColor = newPlayerGuessButton[0, i].BackColor;
            }

            //Gets true or false for win condition
            winner = mySolution.isWinner(myGuess, myReport);

            //Sets up pegs to transfer colors
            int[]    pegNumber  = new int[4];
            Button[] pegButtons = new Button[4];

            for (int i = 0; i < 4; i++)
            {
                pegNumber[i]  = 0;
                pegButtons[i] = new Button();
            }

            //Paints pegs on guess board
            setPegOnBoard(pegNumber);

            //Calls color palette and matches the peg number to peg button
            for (int i = 0; i < 4; i++)
            {
                myColor.setPegColor(pegNumber[i], pegButtons[i]);
            }

            //Paints the back color of peg buttons to the gameboard pegs
            for (int i = 0; i < 4; i++)
            {
                newHintButton[i, guessCount].BackColor = pegButtons[i].BackColor;
            }

            //Increments count
            guessCount++;

            //Tests to see if there is a winner
            if (winner == true)
            {
                setPlayerWinConditions();

                button = MessageBox.Show(winMessage + "\r\n" + continueMessage, "Game Over!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                //This gives the player the choice to play a new game or quit
                if (button == DialogResult.Yes)
                {
                    TrackUsedNumbers.initilizeTrackedNumbersArray();
                    newGamePlus();
                }

                else
                {
                    this.Close();
                }
            }

            //This compares the number of guess given from the difficulty to the number of guesses taken. If no winning matches
            //this loser message displays.
            if (guessCount == numberOfGuessDueToDifficulty && winner == false)
            {
                pnlSolutionBoard.Visible = true;

                button = MessageBox.Show(loseMessage + "\r\n" + continueMessage, "Game Over!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (button == DialogResult.Yes)
                {
                    newGamePlus();
                }

                else
                {
                    this.Close();
                }
            }
        }