Exemplo n.º 1
0
		public void btnGuess_Click(object sender, EventArgs e) {
			if (!Mastermind.gameIsOver()) {
				try {
					ColorSequence guess = new ColorSequence();
					for (int i = 0; i < Mastermind.GameState.NrOfPins; i++)
						guess.addLast(
							ClrPicker.parseEnum <Colors>(
								CtrlController.LblArrayPlayer[Mastermind.GameState.TurnNumber - 1, i].BackColor.ToKnownColor().ToString()));
					passGuessAndGetFeedback(guess);
				} catch (ArgumentException) {
					MessageBox.Show(
						string.Format("Every pin must have a color and a color can't be used twice..."), string.Format("Error"));
				}
			}
		} /*btnGuess_Click*/
Exemplo n.º 2
0
		} /*updateTurn*/

		private ColorSequence createRandomSequence(byte length) {
			ColorSequence randomCombo = new ColorSequence();
			bool[] used = new bool[NrOfAvailableColors];

			for (byte i = 0; i < length; i++) {
				int tmp;
				do {
					tmp = Randomizer.Next(NrOfAvailableColors);
				} while (used[tmp]);
				randomCombo.addLast((Colors)tmp);
				used[tmp] = true;
			}

			return randomCombo;
		} /*createRandomSequence*/