public Game(Player player, Mastermind mastermind, IInput input, IOutput output, IRule rule) { Player = player; Mastermind = mastermind; Input = input; Output = output; Rule = rule; _inputValidator = new InputValidator(); }
public void Play() { var isWinning = false; while (!isWinning) { GuessCount += 1; _inputValidator.ThrowExceptionWhenTriedTooManyTimes(GuessCount); DisplayAllowedColours(); var selectedColours = UserSelectColours(); _currentSolution = Player.GenerateSolution(selectedColours); Output.Write(_currentSolution); var shuffledHint = Mastermind.CreateShuffledHintBasedOnPlayerSolution(_currentSolution); Output.Write(shuffledHint); isWinning = Rule.IsWinningCondition(shuffledHint); } Player.IsWinner = true; Output.Write(GameInstruction.YouWonMessage()); }
static void Main(string[] args) { var consoleInput = new ConsoleInput(); var consoleOutput = new ConsoleOutput(); var solutionGenerator = new NormalSolutionGenerator(); var player = new Player("Lan", solutionGenerator); var secretSolutionGenerator = new SecretSolutionGenerator(); var mastermind = new Mastermind(secretSolutionGenerator); var rule = new Rule(); var game = new Game(player, mastermind, consoleInput, consoleOutput, rule); try { game.Start(); game.Play(); } catch (Exception e) { Console.WriteLine(e); throw; } }
public void Start() { WelcomeUser(); DisplayInputRule(); Mastermind.SetSecretSolution(Colours); }