public void displayResults(GuessResult res) { int i = 0; for (; i < Math.Floor((double)res.getRightColours() / 4); i++) { resultDisplays[i].displayResults(4, keepAboveZero(res.getRightPlaces() - i * 4)); } if (res.getRightColours() % 4 != 0) { resultDisplays[i].displayResults(res.getRightColours() % 4, keepAboveZero(res.getRightPlaces() - i * 4)); } }
protected override bool doTurn() //run through one turn { hostForm.nextTurn(); //prepare the GUI Code inputCode = hostForm.getCodeFromPlayer(); //get a new guess from the player if (inputCode == null) //this occurs if the form wants to close { return(false); //just stop the loop } hostForm.endPlayerInput(); //tell the form to stop recieving player input guessCodes.Add(inputCode); //add the guess to the list of guesses GuessResult result = inputCode.checkGuess(target); //generate the results if (result.getRightPlaces() == inputCode.getCodeLength()) //if the code is corrent { hostForm.endGame(true); //end the game with a win return(false); //stop the game loop } hostForm.displayResults(result); //display the results of the game on the form return(true); //the player has not guessed the code yet; more turns need to be done }