Example #1
0
int main(void)
{
	//init all
	CARD t_poker_card[CARDNUM];
	CARD hand_cards1[HANDCARDMAX], hand_cards2[HANDCARDMAX], hand_cards3[HANDCARDMAX], hand_cards4[HANDCARDMAX];

	PLAYER t_card_player[HANDCARDMAX] = {
		{{"Alice"}, 0, {hand_cards1[HANDCARDMAX]}}, 
		{{"Ben"}, 1, {hand_cards2[HANDCARDMAX]}}, 
		{{"Clark"}, 2, {hand_cards3[HANDCARDMAX]}}, 
		{{"Durant"}, 3, {hand_cards4[HANDCARDMAX]}}};

	SCOREIND t_indicator = {2, 2, 1};
	int game_level = 2;

	while(t_indicator.partnerA < 14|| t_indicator.partnerB < 14){
			//start one game
		init_cards(t_poker_card);
		shuffle_cards(t_poker_card);

		if(t_indicator.round != 1){
			//

		}
		else{
			//first game
			deal_cards(t_poker_card, &t_card_player[0], &t_card_player[1], &t_card_player[2], &t_card_player[3]);

		}
	}



	return 0;
}
Example #2
0
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 */
}
Example #3
0
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*/
}
Example #4
0
/** Handle a button press event */
void button_click(uint8_t n)
{
	switch (n) {
		case D_UP:
			dec_wrap(pos_y, 0, HEIGHT);
			break;

		case D_DOWN:
			inc_wrap(pos_y, 0, HEIGHT);
			break;

		case D_LEFT:
			if (pos_x == 0) dec_wrap(pos_y, 0, HEIGHT);  // go to previous row
			dec_wrap(pos_x, 0, WIDTH);
			break;

		case D_RIGHT:
			if (pos_x == WIDTH - 1) inc_wrap(pos_y, 0, HEIGHT);  // go to next row
			inc_wrap(pos_x, 0, WIDTH);
			break;

		case D_SELECT:
			if (tiles_revealed == 2) break;  // two already shown
			if (board[Cursor].state != SECRET) break;  // selected tile not secret

			// reveal a tile
			if (tiles_revealed < 2) {
				board[Cursor].state = REVEALED;
				tiles_revealed++;

				if(tiles_revealed == 1) {
					tile1 = Cursor;
				} else {
					tile2 = Cursor;
				}
			}

			// Check equality if it's the second
			if (tiles_revealed == 2) {
				hide_timeout_match = (board[tile1].color == board[tile2].color);
				hide_timeout = HIDE_TIME;
			}

			break;

		case D_RESTART:
			deal_cards();
			if (board[Cursor].state == GONE)
				safe_press_arrow_key(D_RIGHT);

			break;
	}
}
Example #5
0
int main()
{
    double start_time[10];
    int i, j;
    int sorted_players[10];
    
    testgame = new_game(10);
    for (i = 0; i < 10; i++) {
        testgame->players[i].active = 1;
    }
    print_deck();
    puts("*** AFTER SHUFFLING ***");
    shuffle_deck(testgame);
    print_deck();
    puts("*** COMMUNITY CARDS ***");
    deal_community(testgame);
    print_community();
    puts("*** DEALING CARDS ***");
    deal_cards();
    print_hands();

    puts("*** SORTING PLAYERS ***");
    get_player_ranks(testgame, sorted_players);
    puts("In order of card ranking (low to high):");
    for (i = 0; i < 10; i++)
        printf("Player %d\n", sorted_players[i]);

    /*
    puts("*** BENCHMARKING ***");
    start_time[0] = get_time();
    for (i = 0; i < 5000; i++)
        shuffle_deck();
    printf("Shuffled deck 5,000 times in %f\n", get_time() - start_time[0]);

    for (i = 0; i < 10; i++) {
        start_time[i] = get_time();
        for (j = 0; j < 100000; j++)
            get_best_player_hand(i);
        printf("Calculated best hand for Player %d 100,000 times in %f\n", i, get_time() - start_time[i]);
    }
    */

    return 0;
}
Example #6
0
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;
}
Example #7
0
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 */
}
Example #8
0
/** Program initialization */
void SECTION(".init8") init()
{
	// Randomize RNG
	adc_init();
	srand(adc_read_word(0));

	// led strip data
	as_output(WS1);

	// gamepad buttons
	as_input_pu(BTN_LEFT);
	as_input_pu(BTN_RIGHT);
	as_input_pu(BTN_UP);
	as_input_pu(BTN_DOWN);
	as_input_pu(BTN_SELECT);
	as_input_pu(BTN_RESTART);

	as_input_pu(FLAG_SMALL); // when LOW, use smaller board.

	// add buttons to debouncer
	debo_add_rev(BTN_LEFT);
	debo_add_rev(BTN_RIGHT);
	debo_add_rev(BTN_UP);
	debo_add_rev(BTN_DOWN);
	debo_add_rev(BTN_SELECT);
	debo_add_rev(BTN_RESTART);

	// setup timer
	TCCR0A = _BV(WGM01); // CTC
	TCCR0B = _BV(CS02) | _BV(CS00);  // prescaler 1024
	OCR0A = 156;  // interrupt every 10 ms
	sbi(TIMSK0, OCIE0A);

	// prepare game board
	deal_cards();

	// enable timer interrupts (update & render)
	sei();
}
Example #9
0
void play_poker ()
{
    initialize_cards (deck_of_cards);
    deal_cards (current_hand.begin (), deck_of_cards.begin ()); 
}