コード例 #1
0
ファイル: blue.c プロジェクト: Brainiarc7/ralink_sdk
int
main(int argc, char *argv[])
{
    CATCHALL(die);

    setlocale(LC_ALL, "");

    initscr();

    /*
     * We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing.
     */
    start_color();
    init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);
    init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE);
    init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);

#ifndef COLOR_PAIR
    letters[0] = OR_COLORS('h', RED_ON_WHITE);	/* hearts */
    letters[1] = OR_COLORS('s', BLACK_ON_WHITE);	/* spades */
    letters[2] = OR_COLORS('d', RED_ON_WHITE);	/* diamonds */
    letters[3] = OR_COLORS('c', BLACK_ON_WHITE);	/* clubs */
#if USE_CP437
    glyphs[0] = PC_COLORS('\003', RED_ON_WHITE);	/* hearts */
    glyphs[1] = PC_COLORS('\006', BLACK_ON_WHITE);	/* spades */
    glyphs[2] = PC_COLORS('\004', RED_ON_WHITE);	/* diamonds */
    glyphs[3] = PC_COLORS('\005', BLACK_ON_WHITE);	/* clubs */
#endif
#endif

#if USE_CP437
    if (tigetstr("smpch"))
	suits = glyphs;
#endif /* USE_CP437 */

    cbreak();

    if (argc == 2)
	srand((unsigned) atoi(argv[1]));
    else
	srand((unsigned) time((time_t *) 0));

    init_vars();

    do {
	deal_number++;
	shuffle(deck_size);
	deal_cards();
	display_cards(deal_number);
	play_game();
    }
    while
	((deck_size = collect_discards()) != 0);

    game_finished(deal_number);

    die(SIGINT);
    /*NOTREACHED */
}
コード例 #2
0
ファイル: blue.c プロジェクト: kal444/xiang-qi
int main(int argc, char *argv[])
{
    (void) signal(SIGINT, die);
    initscr();

    /*
     * We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing.
     */
    start_color();
    init_pair(RED_ON_WHITE,    COLOR_RED,   COLOR_WHITE);
    init_pair(BLUE_ON_WHITE,   COLOR_BLUE,  COLOR_WHITE);
    init_pair(BLACK_ON_WHITE,  COLOR_BLACK, COLOR_WHITE);

#ifndef COLOR_PAIR
    letters[0] = 'h' | COLOR_PAIR(RED_ON_WHITE);	/* hearts */
    letters[1] = 's' | COLOR_PAIR(BLACK_ON_WHITE);	/* spades */
    letters[2] = 'd' | COLOR_PAIR(RED_ON_WHITE);	/* diamonds */
    letters[3] = 'c' | COLOR_PAIR(BLACK_ON_WHITE);	/* clubs */
#if defined(__i386__) && defined(A_ALTCHARSET)
    glyphs[0]  = '\003' | A_ALTCHARSET | COLOR_PAIR(RED_ON_WHITE);	/* hearts */
    glyphs[1]  = '\006' | A_ALTCHARSET | COLOR_PAIR(BLACK_ON_WHITE);	/* spades */
    glyphs[2]  = '\004' | A_ALTCHARSET | COLOR_PAIR(RED_ON_WHITE);	/* diamonds */
    glyphs[3]  = '\005' | A_ALTCHARSET | COLOR_PAIR(BLACK_ON_WHITE);	/* clubs */
#endif
#endif

#if defined(__i386__) && defined(A_ALTCHARSET)
    if (tigetstr("smpch"))
	suits = glyphs;
#endif /* __i386__ && A_ALTCHARSET */

    cbreak();

    if (argc == 2)
	srand((unsigned)atoi(argv[1]));
    else
	srand((unsigned)time((time_t *)0));

    init_vars();

    do{
	deal_number++;
	shuffle(deck_size);
	deal_cards();
	display_cards(deal_number);
	play_game();
    }
    while
	((deck_size=collect_discards()) != 0);

    game_finished(deal_number);

    die(SIGINT);
    /*NOTREACHED*/
}
コード例 #3
0
ファイル: blue.c プロジェクト: Distrotech/slang
int main(int argc, char *argv[])
{
    (void) signal(SIGINT, die);
    initscr();

    /*
     * We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing.
     */
    start_color();
    init_pair(COLOR_RED,     COLOR_RED,   COLOR_WHITE);
    init_pair(COLOR_BLUE,    COLOR_BLUE,  COLOR_WHITE);
    init_pair(COLOR_GREEN,   COLOR_BLACK, COLOR_WHITE);

#if defined(__i386__) && defined(A_ALTCHARSET)
    if (tigetstr("smpch"))
	suits = glyphs;
#endif /* __i386__ && A_ALTCHARSET */

    cbreak();

    if (argc == 2)
	srand((unsigned)atoi(argv[1]));
    else
	srand((unsigned)time((time_t *)0));

    init_vars();

    do{
	deal_number++;
	shuffle(deck_size);
	deal_cards();
	display_cards(deal_number);
	play_game();
    }
    while
	((deck_size=collect_discards()) != 0);

    game_finished(deal_number);

    die(SIGINT);
    /*NOTREACHED*/
   return 1;
}
コード例 #4
0
ファイル: blue.c プロジェクト: akesandgren/ncurses
int
main(int argc, char *argv[])
{
    CATCHALL(die);

    setlocale(LC_ALL, "");

    use_pc_display();

    initscr();

    start_color();
    init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);
    init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE);
    init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);

    cbreak();

    if (argc == 2)
	srand((unsigned) atoi(argv[1]));
    else
	srand((unsigned) time((time_t *) 0));

    init_vars();

    do {
	deal_number++;
	shuffle(deck_size);
	deal_cards();
	display_cards(deal_number);
	play_game();
    }
    while
	((deck_size = collect_discards()) != 0);

    game_finished(deal_number);

    die(SIGINT);
    /*NOTREACHED */
}
コード例 #5
0
ファイル: blue.c プロジェクト: ThomasDickey/ncurses-snapshots
static void
play_game(void)
{
    int dead = 0, i, j;
    char c;
    int selection[4], card;

    while (dead < 4) {
	dead = 0;
	for (i = 0; i < 4; i++) {
	    card = grid[freeptr[i] - 1];

	    if (((card % SUIT_LENGTH) == KING)
		||
		(card == NOCARD))
		selection[i] = NOCARD;
	    else
		selection[i] = find(card + 1);

	    if (selection[i] == NOCARD)
		dead++;
	};

	if (dead < 4) {
	    char live[NSUITS + 1], *lp = live;

	    for (i = 0; i < 4; i++) {
		if (selection[i] != NOCARD) {
		    move(BASEROW + (selection[i] / GRID_WIDTH) * 2 + 3,
			 (selection[i] % GRID_WIDTH) * 5);
		    (void) printw("   %c ", (*lp++ = (char) ('a' + i)));
		}
	    };
	    *lp = '\0';

	    if (strlen(live) == 1) {
		move(PROMPTROW, 0);
		(void) printw(
				 "Making forced moves...                                 ");
		refresh();
		(void) sleep(1);
		c = live[0];
	    } else {
		char buf[BUFSIZ];

		_nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
			    "Type [%s] to move, r to redraw, q or INTR to quit: ",
			    live);

		do {
		    move(PROMPTROW, 0);
		    (void) addstr(buf);
		    move(PROMPTROW, (int) strlen(buf));
		    clrtoeol();
		    AddCh(' ');
		} while
		    (((c = (char) getch()) < 'a' || c > 'd')
		     && (c != 'r')
		     && (c != 'q'));
	    }

	    for (j = 0; j < 4; j++)
		if (selection[j] != NOCARD) {
		    move(BASEROW + (selection[j] / GRID_WIDTH) * 2 + 3,
			 (selection[j] % GRID_WIDTH) * 5);
		    (void) printw("     ");
		}

	    if (c == 'r')
		display_cards(deal_number);
	    else if (c == 'q')
		die(SIGINT);
	    else {
		i = c - 'a';
		if (selection[i] == NOCARD)
		    beep();
		else {
		    movecard(selection[i], freeptr[i]);
		    freeptr[i] = selection[i];
		}
	    }
	}
    }

    move(PROMPTROW, 0);
    (void) standout();
    (void) printw("Finished deal %d - type any character to continue...", deal_number);
    (void) standend();
    (void) getch();
}