private void CheckCommand(object sender, EventArgs e) { MyMasterMindCodeColors[] code = new MyMasterMindCodeColors[MyMasterMindConstants.Columns]; int currentGuessRow = Game.GetCurrentGuessRow() + 1; for (int i = 0; i < MyMasterMindConstants.Columns; i++) { code[i] = MasterMindBoard.GetGuessColor(currentGuessRow, i); } IMasterMindGuessModel guess = Game.SetGuess(currentGuessRow, code); MasterMindBoard.SetGuessEvaluation(currentGuessRow, guess.GetEvaluation().Black, guess.GetEvaluation().White); MasterMindBoard.MarkGuessCell(currentGuessRow, CellMark.None); currentGuessRow++; if ((currentGuessRow >= MyMasterMindConstants.Rows) || Game.Finished()) { ShowCode(); DisableCommands(new List <MyMasterMindCommands>() { MyMasterMindCommands.Check, MyMasterMindCommands.Cancel }); EnableCommands(new List <MyMasterMindCommands>() { MyMasterMindCommands.ComputerSlow, MyMasterMindCommands.ComputerFast, MyMasterMindCommands.User, MyMasterMindCommands.Clear }); return; } MasterMindBoard.MarkGuessCell(currentGuessRow, CellMark.ForInput); MasterMindCommands.SetButtonState(MyMasterMindCommands.Check, false); }
private void BackgroundWorkerComputerProgressChanged(object sender, ProgressChangedEventArgs e) { IMasterMindGuessModel guess = Game.GetCurrentGuess(); if (guess != null) { int currentGuessRow = Game.GetCurrentGuessRow(); for (int j = 0; j < MyMasterMindConstants.Columns; j++) { MasterMindBoard.SetGuessColor(currentGuessRow, j, guess.GetCode().Colors[j]); } if (guess.GetEvaluation() != null) { MasterMindBoard.SetGuessEvaluation(currentGuessRow, guess.GetEvaluation().Black, guess.GetEvaluation().White); } } if (e.UserState != null) { ComputerPlayInformation computerPlayInformation = (ComputerPlayInformation)e.UserState; MasterMindBoard.MarkGuessCell(computerPlayInformation.Item1, computerPlayInformation.Item2); } }