Exemplo n.º 1
0
/*
 * endgame:
 *	Do what's necessary at the end of the game
 */
void
endgame()
{
	char ch;

	prman();
	if (Errors >= MAXERRS)
		Errors = MAXERRS + 2;
	prword();
	prdata();
	move(MESGY, MESGX);
	if (Errors > MAXERRS)
		printw("Sorry, the word was \"%s\"\n", Word);
	else
		printw("You got it!\n");

	for (;;) {
		mvaddstr(MESGY + 1, MESGX, "Another word? ");
		leaveok(stdscr, FALSE);
		refresh();
		if ((ch = readch()) == 'n')
			die(0);
		else
			if (ch == 'y')
				break;
		mvaddstr(MESGY + 2, MESGX, "Please type 'y' or 'n'");
	}

	leaveok(stdscr, TRUE);
	move(MESGY, MESGX);
	deleteln();
	deleteln();
	deleteln();
}
Exemplo n.º 2
0
/*
 * endgame:
 *      Do what is necessary at the end of the game
 */
void endgame()
{
    char ch;
    
    /* Print out the hangman */
    prman();
    
    /* Print out the current word */
    prword();
    /* Print out the current guesses */
    prdata();
    
    /* Move curses window cursor */
    move(MESGY, MESGX);
    
    /* Tell the user how they did by printing 
       formatted output in the curses window */
    if (Errors >= MAXERRS)
    {
        printw("Sorry, the word was \"%s\"\n", Word);
    }
    else
    {
        printw("You got it!\n");
    }
    
    for (;;) 
    {
        /* Prompt for another word */
        mvaddstr(MESGY + 1, MESGX, "Another word? ");
        leaveok(stdscr, FALSE);
        refresh();
        
        if ((ch = readch()) == 'n')
        {
	    /* If user says no, exit */
            exit(0);
        }
        else
        {
            if (ch == 'y')
            {
	        /* If user says yes, keep going */ 
                break;			// fixes bug 6
            }
	    /* If user says neither y or n, prompt user */
            mvaddstr(MESGY + 2, MESGX, "Please type 'y' or 'n'");
        }
    }
    
    /* Clean up the window */
    leaveok(stdscr, TRUE);
    move(MESGY, MESGX);
    
    deleteln();
    deleteln();
    deleteln(); 
}
Exemplo n.º 3
0
/*
 * playgame:
 *	play a game
 */
void
playgame(void)
{
	bool *bp;

	getword();
	Errors = 0;
	bp = Guessed;
	while (bp < &Guessed[26])
		*bp++ = FALSE;
	while (Errors < MAXERRS && index(Known, '-') != NULL) {
		prword();
		prdata();
		prman();
		getguess();
	}
	endgame();
}
Exemplo n.º 4
0
/*
 * playgame:
 *	play a game
 */
void
playgame(void)
{
	int i;

	if (syms)
		sym_getword();
	else
		getword();
	Errors = 0;
	for (i = 0; i < 26 + 10; i++)
		Guessed[i] = FALSE;
	while (Errors < MAXERRS && strchr(Known, '-') != NULL) {
		prword();
		prdata();
		prman();
		getguess();
	}
	endgame();
}