Ejemplo 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();
}
Ejemplo 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(); 
}
Ejemplo n.º 3
0
void
main(int argc, char **argv)
{
	struct utsname u;

	uname(&u);
	if(argc == 1){
		printf("%s\n", u.sysname);
		exit(0);
	}
	ARGBEGIN {
	case 'a':
		prword(u.sysname);
		prword(u.nodename);
		prword(u.release);
		prword(u.version);
		prword(u.machine);
		break;
	case 'm':
		prword(u.machine);
		break;
	case 'n':
		prword(u.nodename);
		break;
	case 'r':
		prword(u.release);
		break;
	case 's':
		prword(u.sysname);
		break;
	case 'v':
		prword(u.version);
		break;
	} ARGEND
	printf("\n");
	exit(0);
}
Ejemplo n.º 4
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();
}
Ejemplo n.º 5
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();
}