예제 #1
0
파일: fish.c 프로젝트: jyin0813/OpenBSD-src
int
main(int argc, char *argv[])
{
	int ch, move;

	while ((ch = getopt(argc, argv, "ph")) != -1)
		switch(ch) {
		case 'p':
			promode = 1;
			break;
		case '?':
		case 'h':
		default:
			usage();
		}

	srandomdev();
	instructions();
	init();

	if (nrandom(2) == 1) {
		printplayer(COMPUTER);
		(void)printf("get to start.\n");
		goto istart;
	}
	printplayer(USER);
	(void)printf("get to start.\n");
	
	for (;;) {
		move = usermove();
		if (!comphand[move]) {
			if (gofish(move, USER, userhand))
				continue;
		} else {
			goodmove(USER, move, userhand, comphand);
			continue;
		}

istart:		for (;;) {
			move = compmove();
			if (!userhand[move]) {
				if (!gofish(move, COMPUTER, comphand))
					break;
			} else
				goodmove(COMPUTER, move, comphand, userhand);
		}
	}
	/* NOTREACHED */
}
예제 #2
0
파일: fish.c 프로젝트: msharov/bsd-games
int main (void)
{
    initialize_curses();
    initialize_windows();
    shuffle_deck_and_deal();
    instructions();

    enum EPlayer player = nrand(NPLAYERS);
    printplayer (player);
    waddstr (_wmsg, "get to start.\n");
    for (;;) {
	unsigned m = makemove (player);
	if (_hand[OTHER(player)][m])
	    goodmove (player, m);
	else if (!gofish (player, m))
	    player = OTHER(player);
    }
    return EXIT_SUCCESS;
}