| void playHangman (char playerName[]){
int aPuzzleNumber, wonGame;
puzzle secretPuzzle;
hangmanGameState gameState;
char playersGuess;
initGame(playerName, &gameState);
aPuzzleNumber = rand() % numberOfPuzzles();
secretPuzzle = getPuzzle(aPuzzleNumber);
while ((gameState.numberOfWrongGuesses < N) &&
(gameState.numberOfCorrectGuesses < secretPuzzle.numberOfCharsToGuess)){
gameStatistics(gameState, secretPuzzle);
presentPuzzleOutline(secretPuzzle,gameState); printf("\n");
presentRemainingAlphabet(gameState); printf("\n");
if (CHEATING) presentSecretPuzzle(secretPuzzle);
printf("\n");
playersGuess = getUsersGuess();
clrconsole();
updateGameState(&gameState, secretPuzzle, playersGuess);
}
gameStatistics(gameState, secretPuzzle);
wonGame = wonOrLost(gameState,secretPuzzle);
handleHighscore(gameState, secretPuzzle, wonGame);
} |