void main(void) { char *fname = "NAMECARD.DAT"; char name[NAME_SIZE]; int i; card *t; init_card(); while ((i = select_menu()) != 8) { switch (i) { case 1 : input_card(); break; case 2 : printf("\n Input name to delete -> "); gets(name); if (!delete_card(name)) printf("\n Can't find that name."); break; case 3 : printf("\n Input name to search -> "); gets(name); t = search_card(name); if (t == NULL) { printf("\n Can't find that name."); break; } print_header(stdout); print_card(t, stdout); break; case 4 : load_cards(fname); break; case 5 : save_cards(fname); break; case 6 : t = head->next; print_header(stdout); while (t != tail) { print_card(t, stdout); t = t->next; } break; case 7 : t = head->next; print_header(stdprn); while (t != tail) { print_card(t, stdprn); t = t->next; } break; } } printf("\n\nProgram ends..."); }
static void print_pile(struct pile *pile,bool bRankOnly,bool bInteger) { int n; for (n = 0; n < pile->pile_depth; n++) print_card(pile->pile[n],0x0a,bRankOnly,bInteger); }
int Euler54::compute_best_hand(Euler54::Hand _hand){ if(royal_flush(_hand)){ std::cout << "Royal Flush" << std::endl; return 10; }else if(straight_flush(_hand)){ std::cout << "Straight Flush" << std::endl; return 9; }else if(quads(_hand)){ std::cout << "Quads" << std::endl; return 8; }else if(full_house(_hand)){ std::cout << "Full House" << std::endl; return 7; }else if(flush(_hand)){ std::cout << "Flush" << std::endl; return 6; }else if(straight(_hand)){ std::cout << "Straight" << std::endl; return 5; }else if(trips(_hand)){ std::cout << "Trips" << std::endl; return 4; }else if(two_pair(_hand)){ std::cout << "Two Pair" << std::endl; return 3; }else if(pair(_hand, 0)){ std::cout << "Pair" << std::endl; return 2; }else{ set_highest_card(highest_card(_hand)); std::cout << "you have the high card " << print_card(current_highest_card) << std::endl; return 1; std::cout << " you got squat " << std::endl; } }
int main( int argc, char ** argv ) { for( int i = 0; i < 52 ; i++ ) { print_card(&deck[i]); } return 0; }
void print_hand(struct player p) { int i; for(i = 0; i < NUM_OF_CARDS_IN_HAND; ++i) { if(!is_card_empty(p.hand[i])) { print_card(p.hand[i]); } } }
int main(int argc, char *argv[]) { card **hand; deck *fulldeck; int i, j, k; /* create an array of card pointers */ hand = (card **)malloc(sizeof(card *)*5); /* make a card for each one */ for(i=0;i<5;i++) hand[i] = make_card(i%4, (i*17)%14); /* print out the cards in the hand */ printf("Hand: "); for(i=0;i<5;i++) print_card(hand[i]); printf("\n"); /* make a standard deck of cards */ fulldeck = make_standard_deck(); if (fulldeck == NULL) { printf("make_standard_deck not yet implemented ... exiting\n"); exit(0); } /* print out all of the cards */ for(i=0;i<fulldeck->num_cards;) for(j=0;j<13 && i<fulldeck->num_cards;j++,i++) print_card(&(fulldeck->cards[i])); /* compare some cards */ printf("Compare: "); print_card(&(fulldeck->cards[5])); print_card(&(fulldeck->cards[17])); printf(": %d\n",compare(&(fulldeck->cards[5]),&(fulldeck->cards[17]))); printf("find index: C 5: %d", find_index(fulldeck,0,5)); }
int main(void) { t_deck *d; t_burned *b; b = malloc(sizeof(t_burned)); b->nb_card = 0; if (!(d = create_deck())) return (1); g_randfd = open("/dev/random", O_RDONLY); print_deck(d); get_random_card(d, b); get_random_card(d, b); get_random_card(d, b); print_deck(d); print_card(b->card[0]); print_card(b->card[1]); print_card(b->card[2]); recover_cards(d, b, NULL); print_deck(d); return (0); }
int main() { struct board_t board; int winner = 0; int pTurn = 0; int pCard = 0; int mLane = 0; struct card_t generatedCard; struct deck_t generatedDeck = GenerateMultipleCards(30); WriteGeneratedDeckToFile(&generatedDeck,"idiocracy.csv"); generatedCard = GenerateCard(); print_card(generatedCard,1); // INIT STUFF HERE ! if (!init_board(&board)) { printf("Error.File Not Found! WTF, DO NOT TOUCH THE DATA !\n"); return -1; } // ================= winner = 0; while(winner == 0) { pCard = 0; turn_begin(&board.Player[pTurn]); //Print Board Here ! PrintBoard(board); //================== if (pTurn == 0) while (pCard != 6) { printf("Choose card:"); scanf("%d",&pCard); if (pCard !=6 && board.Player[pTurn].Open_Spots_Hand[pCard-1] != 1) { printf("\nChoose lane:"); scanf("%d",&mLane); int result = play_card(&board,pTurn,pCard-1,mLane-1); PrintBoard(board); } } else RunSimpleAI(&board,pTurn); turn_end(&board,pTurn); if (board.Player[pTurn].health <= 0) { winner = 1-pTurn; break; } pTurn = 1-pTurn; } printf("\n\nWinner is Player: %d\n\n",winner+1); return 0; }
static void print_piles(struct pile *piles,bool bOnlyFaceUp,bool bRankOnly,bool bInteger) { int m; int n; for (m = 0; m < NUM_PILES; m++) { if (bOnlyFaceUp) { for (n = 0; n < piles[m].face_up_depth; n++) { if (n < piles[m].face_up_depth - 1) print_card(piles[m].pile[n],' ',bRankOnly,bInteger); else print_card(piles[m].pile[n],0x0a,bRankOnly,bInteger); } } else { for (n = 0; n < piles[m].pile_depth; n++) { if (n < piles[m].pile_depth - 1) print_card(piles[m].pile[n],' ',bRankOnly,bInteger); else print_card(piles[m].pile[n],0x0a,bRankOnly,bInteger); } } } }
int can_play_card(board_t *board, int turn, card_t card_to_put, int num_lane){ switch(can_put_card(card_to_put, board->p[turn].manapool)){ case 0: printf("You don't have enough mana to put this card.\n"); return 0; case 1: if(is_card_empty(board->lanes[turn][num_lane])){ return 1; }else { print_card(board->lanes[turn][num_lane]); printf("This line is taken.\n"); return 0; } } }
int main(int argc, const char *argv[]) { nfc_device *pnd; nfc_target nt; nfc_context *context; nfc_init(&context); if(context == NULL) { printf("unable to init (malloc)\n"); exit(EXIT_FAILURE); } pnd = nfc_open(context, NULL); if (pnd == NULL) { printf("ERROR: %s\n", "Unable to open NFC Device."); exit(EXIT_FAILURE); } if (nfc_initiator_init(pnd) < 0) { nfc_perror(pnd, "nfc_initiator_init"); exit(EXIT_FAILURE); } printf("NFC reader: %s opened\n", nfc_device_get_name(pnd)); const nfc_modulation nmMifare = { .nmt = NMT_ISO14443A, .nbr = NBR_106, }; for(int i = 0; i < 24; i++) { if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) > 0) { printf("The following (NFC) card was found:\n"); print_card(nt.nti.nai.abtUid, nt.nti.nai.szUidLen); } while (0 == nfc_initiator_target_is_present(pnd, NULL)){} } nfc_close(pnd); nfc_exit(context); exit(EXIT_SUCCESS); }
int main(void) { int i,pos,s,nums; if (scanf("%d", &T) != 1) { exit(0); } for (t=0; t < T; t++) { scanf("%d", &N); for (n=0; n < N; n++) { for (i=0; i < 52; i++) { scanf("%d", &pos); shuffles[n][pos - 1] = i; } } gets(line); for(i=0; i < 52; i++) { cards_odd[i] = i; } nums = 0; while (1) { if (gets(line) == NULL) break; if (blank_line()) break; if (sscanf(line, "%d", &s) != 1) break; nums++; if (nums % 2 == 1) { src = cards_odd; dst = cards_even; } else { src = cards_even; dst = cards_odd; } for (i=0; i < 52; i++) { dst[shuffles[s - 1][i]] = src[i]; } } if (t) printf("\n"); for(i=0; i < 52; i++) { print_card(dst[i]); } } }
int main() { pcd pointer, *dp, fanswm; pcd dipai[3]; pointer = card; dp = dipai; set_card(pointer, 14, 4); set_card_ddz_ji(pointer, 14, 4); print_card(pointer, 14, 4); print_card2(pointer, 14, 4); print_card_ji(pointer); fapai(player, 3, 17, pointer, dp); print_player(player,3,17); print_dipai(dp); all_player_sort(player, 3, 17); print_player_no_hua(player,3,17); }
int main(int argc, char *argv[]) { char numbers[90]; int card; int i; long seed = 1; int blnk; int oblnk; int rowtot, coltot; int num, row, col; int trow, tcol; int cnd; int broken = 0; int blnktot; while (seed++) { srand48(seed); if (seed % 5000 == 0) fprintf(stderr, "Seed: %ld\n", seed); /* Clear the card */ memset(cards, 0, sizeof(cards)); /* Add blanks */ broken = 0; blnk = 0; while (blnk < 72) { oblnk = blnk; for (col = 0; col < 9; col++) { blnktot = 8; if (col == 0) blnktot = 9; if (col == 8) blnktot = 7; memset(blanks, 0, sizeof(blanks)); cnd = 0; coltot = 0; for (row = 0; row < 18; row++) { /* Keep a count of blanks encountered */ if (cards[row][col]) coltot = coltot + 1; else { /* This is a potential candidate row */ /* Check this rows population */ rowtot = 0; for (i = 0; i < 9; i++) if (cards[row][i]) rowtot++; if (rowtot < 4) { /* Candidate row found */ blanks[cnd++] = row; } } } if (coltot < blnktot && cnd > 0) { /* We found candiates for this column */ /* Take a random one */ row = blanks[get_rnd(0, cnd - 1)]; if (cards[row][col] == 100) { sprintf(stderr, "Yikes.Seed %ld, Candidate already taken!\n", seed); broken = 1; break; } cards[row][col] = 100; blnk++; } } if (oblnk == blnk) { printf("Help! Spinning on seed %ld\n", seed); print_card(); broken = 1; break; } } if (broken == 0) { for(i=0;i<90;i++) numbers[i]=i+1; shuffle(numbers, 89); /* Add numbers */ for (num = 1; num < 91; num++) { if (add_to_card(numbers[num]) == 0) { printf("Ouch! Could not add %d to card!\n", numbers[num]); break; } } print_card(); } } return (0); }
void Euler54::print_hand(Hand _hand){ for(int i = 0; i < _hand.cards.size(); i++){ std::cout << print_card(_hand.cards[i]); } std::cout << std::endl; }
int main(int argc, char const *argv[]) { setvbuf(stdout, (char *)NULL, _IONBF, 0); while(1) { char command; printf("=============================\n"); printf(" [SERVER CREATER] \n"); printf(" Blackjack (b) \n"); printf(" Gusee Number (g) \n"); printf(" Quit (q) \n"); printf("=============================\n"); printf("Enter your choice: "); scanf(" %c", &command); printf("=============================\n"); printf("Loading...\n"); if(command != 'b' && command != 'g') break; else { int player_num; while(1){ printf("=============================\n"); printf("Enter the capacity: "); scanf(" %d", &player_num); printf("=============================\n"); if (player_num > MAX_PLAYER || player_num < MIN_PLAYER) printf("Enter 1 to 10.\n"); else break; } int sock_fd; int conn_fd[player_num]; char game_type_uppercase, game_type_lowercase; char not_fit = 'D'; //don't fit the game type char msg[100], msg0[100] ,msg1[100], msg2[100], msg3[100], msg4[100], msg5[100], msg6[300]; struct sockaddr_in ser_addr, cli_addr; socklen_t cli_len = sizeof(cli_addr); if((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) fprintf(stderr, "socket error\n"); int timeout = 1; setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&timeout, sizeof(int)); bzero(&ser_addr , sizeof(ser_addr)); ser_addr.sin_family = AF_INET; ser_addr.sin_addr.s_addr = INADDR_ANY; if(command == 'G' || command == 'g') ser_addr.sin_port = htons(PORT_FOR_GM); else ser_addr.sin_port = htons(PORT_FOR_BJ); bind(sock_fd, (struct sockaddr *)&ser_addr, sizeof(ser_addr)); listen(sock_fd, 1); if (command == 'G' || command =='B'){ game_type_uppercase = command; game_type_lowercase = command + 32; //transfrom ascii to lowercase if(command == 'G') printf("Server is going to hold Guess Number.\n"); else printf("Server is going to hold Blackjack.\n"); } else if (command == 'g' || command == 'b') { game_type_lowercase = command; game_type_uppercase = command - 32; //transfrom ascii to uppercase if(command == 'g') printf("Server is going to hold Guess Number.\n"); else printf("Server is going to hold Blackjack.\n"); } else printf("Game type error, please try again.\n"); int i; int player_state[player_num]; for (i = 0; i < player_num; ++i) { char tmp_type; conn_fd[i] = accept(sock_fd , (struct sockaddr *)&cli_addr, &cli_len); read(conn_fd[i], &tmp_type, sizeof(char)); if (tmp_type == game_type_uppercase || tmp_type == game_type_lowercase){ write(conn_fd[i], &game_type_uppercase, sizeof(char)); sprintf(msg, "You are the %d player.\nWait for other %d player(s) join.\n" , i+1, player_num - (i+1)); write(conn_fd[i], &msg, sizeof(msg)); read(conn_fd[i], &player_state[i], sizeof(int)); } else{ write(conn_fd[i], ¬_fit, sizeof(char)); i--; } } int bet[10]; for (i = 0; i < player_num; ++i) //ask every player to enter bet. { sprintf(msg0, "Enter your bet: "); write(conn_fd[i], msg0, sizeof(msg0)); read(conn_fd[i], &bet[i], sizeof(int)); player_state[i] -= bet[i]; } if (game_type_uppercase == 'G') { int ans[4]; int is_Over[player_num]; int end = 0; gen_num(ans); Overset_init(is_Over, player_num); printf("=============================\n"); printf(" GAME START \n"); printf("=============================\n"); printf("The answer is : %d %d %d %d\n", ans[0], ans[1], ans[2], ans[3]); sprintf(msg1, " GAME START \n"); for(i = 0; i < 10; ++i){ if (end == 1) break; int j, k, l; for(j = 0; j < player_num; j++){ int A = 0, B = 0; int tmp_num[4]; if (i == 0) write(conn_fd[j], msg1, sizeof(msg)); sprintf(msg2, "Round %d.\n", i + 1); write(conn_fd[j], msg2, sizeof(msg)); for(k = 0; k < 4; k++ ) read(conn_fd[j], &tmp_num[k], sizeof(int)); printf("=============================\n"); printf("Round %d.\nThe %d player entered %d %d %d %d.\n", i + 1, j + 1, tmp_num[0], tmp_num[1], tmp_num[2], tmp_num[3]); calculate(&A, &B, tmp_num, ans); if (A == 4){ is_Over[j] = 1; end = 1; } write(conn_fd[j], &A, sizeof(int)); write(conn_fd[j], &B, sizeof(int)); } if (end == 1){ for(l = 0; l < player_num; l++) if(is_Over[l] == 1){ int money = Stake_count(l , bet, i + 1); sprintf(msg3, "Correct answer!\nYou get $%d.\n", money); write(conn_fd[l], &msg3, sizeof(msg)); player_state[l] += money; //fprintf(stderr, "player_state = %d\n", player_state[l]); } else{ sprintf(msg4, "Game Over.\nThe correct answer is %d%d%d%d.\nOthers wins, you lose %d dollars.\n", ans[0], ans[1], ans[2], ans[3], bet[l]); write(conn_fd[l], &msg4, sizeof(msg)); //fprintf(stderr, "player_state = %d\n", player_state[l]); } } else for(l = 0; l < player_num; l++) if(i != 9){ sprintf(msg5, "No one is correct. Continue...\n"); write(conn_fd[l], &msg5, sizeof(msg)); } else{ sprintf(msg6, "=============================\n GAME OVER \n=============================\nCorrect answer is %d%d%d%d.\nNo one wins, you lose %d dollars.\n", ans[0], ans[1], ans[2], ans[3], bet[l]); write(conn_fd[l], &msg6, sizeof(msg)); //fprintf(stderr, "player_state = %d\n", player_state[l]); } } int m; for (m = 0; m < player_num; ++m) write(conn_fd[m], &player_state[m], sizeof(int)); printf("=============================\n"); printf(" GAME OVER \n"); printf("=============================\n"); for (m = 0; m < player_num; ++m) close(conn_fd[m]); close(sock_fd); } else if(game_type_uppercase == 'B'){ int i, j, k; int card[52]; int deal_card_num = 0; int current = 0, visible_cur = 0; int visible_card[52] = {0};//visible card int deal_card[10] = {0}; int player_card_num = 0; char option = 'I'; // init shuffle_card(card); printf(" GAME START \n"); sprintf(msg1, " GAME START \n"); printf("Card order: \n"); print_card(card); printf("\n"); printf("=============================\n"); deal_card[deal_card_num++] = card[current++]; visible_card[visible_cur++] = card[current]; deal_card[deal_card_num++] = card[current++]; for (i = 0; i < player_num; ++i) { visible_card[visible_cur] = card[2 * visible_cur + 1]; visible_cur++; } for (i = 0; i < player_num; ++i) { write(conn_fd[i], &msg1, sizeof(msg));//1 write(conn_fd[i], &deal_card[1], sizeof(int)); //2 //send deal_card to player write(conn_fd[i], &card[current++], sizeof(int));//3 //send player card to player //visible_card[visible_cur++] = card[current]; write(conn_fd[i], &card[current++], sizeof(int));//4 //write(conn_fd[i], &visible_cur, sizeof(int));//5 //for (j = 0; j < visible_cur; ++j) //write(conn_fd[i], &visible_card[j], sizeof(int ));//6 7 } printf("You get: "); print_card(deal_card); printf("=============================\n"); int test[2] = {0}; for(i = 0; i < player_num; ++i) { write(conn_fd[i], &visible_cur, sizeof(int)); for (j = 0; j < visible_cur; ++j) write(conn_fd[i], &visible_card[j], sizeof(int)); while(option != 'S'){ read(conn_fd[i], &option, sizeof(char)); if(option == 'H'){//hit visible_card[visible_cur++] = card[current]; test[0] = card[current]; printf("send to client: "); print_card(test); printf("=============================\n"); write(conn_fd[i], & card[current++], sizeof(int)); } else if(option == 'S')//stand break; else if(option == 'P'){//split visible_card[visible_cur++] = card[current]; write(conn_fd[i], & card[current++], sizeof(int)); visible_card[visible_cur++] = card[current]; write(conn_fd[i], & card[current++], sizeof(int)); } else{ perror("Error input.\n"); } } option = 'I'; } char buffer; int Dealer; while (1) { Dealer = (count_for_BJ(deal_card, deal_card_num)); if (Dealer == -1) { printf(" You BUST!!!\n"); break; } printf("Now %d points\n", Dealer); printf("You have: "); print_card(deal_card); printf("\n"); printf(" HIT (h) \n"); printf(" STAND (s) \n"); printf("=============================\n"); printf("Enter your choice: "); scanf(" %c", &buffer); printf("=============================\n"); if (buffer == 's') if ( Dealer < 17) printf("Need to get over 17.\n"); else break; else if (buffer == 'h') { test[0] = card[current]; printf("=============================\n"); printf("Send card to server: "); print_card(test); printf("=============================\n"); deal_card[deal_card_num++] = card[current++]; } } printf("=============================\n"); printf(" GAME OVER \n"); printf("=============================\n"); for(i = 0; i < player_num; i++){ write(conn_fd[i], &Dealer, sizeof(int)); close(conn_fd[i]); } close(sock_fd); } } } return 0; }
void BlackJack() { char buf[256]; int num[52]={11,11,11,11,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6, 7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10,10}; int cardlist[52]={0}; int i,j,m,tmp=0,tmp2,ch; int win=2,win_jack=5; /* win ¬°Ä¹®Éªº¿²v, win_jack ¬°«e¨â±i´N 21 ÂI¿²v */ int six=10, seven=20, aj=10, super_jack=20; /* 777, A+J, spade A+J ªº¿²v */ int host_count=2, guest_count=1, card_count=3, A_count=0, AA_count=0; int host_point=0, guest_point=0, mov_y=4; int host_card[12]={0}, guest_card[12]={0}; long int money; int CHEAT=0; /* °µ¹ú°Ñ¼Æ, 1 ´N§@¹ú, 0 ´N¤£§@ */ time_t now = time(0); time(&now); clear(); setutmpmode(BLACKJACK); do{ move(0,0);prints("±z¨¤WÁÙ¦³ [1;44;33m%d[m ¤¸",cuser.silvermoney); getdata(1, 0, "n©ãª`¦h¤Ö¿ú(1 - 250000)? ", buf, 7, DOECHO,0); money=atoi(buf); if(!buf[0])return; if(check_money(money,SILVER)) return; }while((money<1)||(money>250000)); demoney(money); move(2,0);prints("(«ö y ÄòµP, n ¤£ÄòµP, d double)"); move(0,0);clrtoeol();prints("±zÁÙ¦³ [1;44;33m%d[m »È¨â",cuser.silvermoney); for(i=1;i<=52;i++){ m=0; do{ j=(time(0)+cuser.silvermoney+rand())%52; if (cardlist[j]==0){cardlist[j]=i;m=1;} }while(m==0); }; for(i=0;i<52;i++)cardlist[i]--; /* ¬~µP */ if(money>=20000)CHEAT=1; if(CHEAT==1){ if(cardlist[1]<=3){ tmp2=cardlist[50]; cardlist[50]=cardlist[1]; cardlist[1]=tmp2; } } /* §@¹ú½X */ host_card[0]=cardlist[0]; if(host_card[0]<4)AA_count++; guest_card[0]=cardlist[1]; if(guest_card[0]<4)A_count++; host_card[1]=cardlist[2]; if(host_card[1]<4)AA_count++; /* µo«e¤T±iµP */ move(5,0); prints("¢~¢w¢w¢w¢¡"); move(6,0); prints("¢x ¢x"); move(7,0); prints("¢x ¢x"); move(8,0); prints("¢x ¢x"); move(9,0); prints("¢x ¢x"); move(10,0); prints("¢x ¢x"); move(11,0); prints("¢¢¢w¢w¢w¢£"); print_card(host_card[1],5,4); print_card(guest_card[0],15,0); /* ¦L¥X«e¤T±iµP */ host_point=num[host_card[1]]; guest_point=num[guest_card[0]]; do{ m=1; guest_card[guest_count]=cardlist[card_count]; if(guest_card[guest_count]<4)A_count++; print_card(guest_card[guest_count],15,mov_y); guest_point+=num[guest_card[guest_count]]; if((guest_card[0]>=24&&guest_card[0]<=27)&&(guest_card[1]>=24&&guest_card[1]<=27)&&(guest_card[2]>=24&&guest_card[2]<=27)){ move(18,3);prints("[1;41;33m ¢¶¢¶¢¶ [m"); move(3,0);prints("[1;41;33m¢¶¢¶¢¶ !!! ±o¼úª÷ %d »È¨â[m",money*seven); inmoney(money*seven); game_log("BLACKJACK","¤¤¤F [1;33m%7d[m ¤¸ªº "COLOR1"[1m ¢¶¢¶¢¶ [m" ,money*seven); pressanykey("±zÁÙ¦³ [1;44;33m%d[m »È¨â",cuser.silvermoney); return; } if((guest_card[0]==40&&guest_card[1]==0)||(guest_card[0]==0&&guest_card[1]==40)){ move(18,3);prints("[1;41;33m ¶W¯Å¥¿²Î BLACK JACK [m"); move(3,0);prints("[1;41;33m¶W¯Å¥¿²Î BLACK JACK !!! ±o¼úª÷ %d »È¨â[m",money*super_jack); inmoney(money*super_jack); game_log("BLACKJACK","¤¤¤F [1;33m%7d[m ¤¸ªº [1;41;33m ¥¿²Î ¢Ï¢Ø [m" ,money*super_jack); pressanykey("±zÁÙ¦³ [1;44;33m%d[m »È¨â",cuser.silvermoney); return; } if((guest_card[0]<=3&&guest_card[0]>=0)&&(guest_card[1]<=43&&guest_card[1]>=40))tmp=1; if((tmp==1)||((guest_card[1]<=3&&guest_card[1]>=0)&&(guest_card[0]<=43&&guest_card[0]>=40))){ move(18,3);prints("[1;41;33m SUPER BLACK JACK [m"); move(3,0);prints("[1;41;33mSUPER BLACK JACK !!! ±o¼úª÷ %d »È¨â[m",money*aj); inmoney(money*aj); game_log("BLACKJACK","¤¤¤F [1;33m%7d[m ¤¸ªº [1;44;33m Super¢Ï¢Ø [m",money*aj); pressanykey("±zÁÙ¦³ [1;44;33m%d[m »È¨â",cuser.silvermoney); return; } if(guest_point==21&&guest_count==1){ move(18,3);prints("[1;41;33m BLACK JACK [m"); move(3,0);prints("[1;41;33mBLACK JACK !!![44m ±o¼úª÷ %d »È¨â[m",money*win_jack); inmoney(money*win_jack); move(0,0);clrtoeol();prints("±zÁÙ¦³ [1;44;33m%d[m »È¨â",cuser.silvermoney); if(money*win_jack>=500000){ game_log("BLACKJACK","¤¤¤F [1;33m%7d[m ¤¸ªº [1;47;30m BlackJack [m %s ",money*win_jack); } pressanykey(NULL); return; } /* «e¨â±i´N 21 ÂI */ if(guest_point>21){ if(A_count>0){guest_point-=10;A_count--;}; } move(12,0); clrtoeol();prints("[1;32mÂI¼Æ: [33m%d[m",host_point); move(14,0); clrtoeol();prints("[1;32mÂI¼Æ: [33m%d[m",guest_point); if(guest_point>21){ pressanykey(" Ãz±¼°Õ~~~ "); return; } if(guest_count==5){ move(18,3);prints("[1;41;33m ¹L¤»Ãö [m"); move(3,0);prints("[1;41;33m¹L¤»Ãö !!! ±o¼úª÷ %d »È¨â[m",money*six); inmoney(money*six); game_log("BLACKJACK","¤¤¤F [1;33m%7d[m ¤¸ªº [1;44;33m ¹L¤»Ãö [m",money*six); pressanykey("±zÁÙ¦³ %d »È¹ô",cuser.silvermoney); return; } guest_count++; card_count++; mov_y+=4; do{ if(ch=='d')m=0; if(m!=0)ch=igetkey(); }while(ch!='y'&&ch!='n'&&ch!='d'&&m!=0); /* §ì key */ if(ch=='d'&&m!=0&&guest_count==2){ if(cuser.silvermoney>=money){ demoney(money); money*=2; } else ch='n'; move(0,0);clrtoeol();prints("±zÁÙ¦³ [1;44;33m%d[m »È¨â",cuser.silvermoney); } /* double */ if(ch=='d'&&guest_count>2)ch='n'; if(guest_point==21)ch='n'; }while(ch!='n'&&m!=0); mov_y=8; print_card(host_card[0],5,0); print_card(host_card[1],5,4); host_point+=num[host_card[0]]; do{ if(host_point<guest_point){ host_card[host_count]=cardlist[card_count]; print_card(host_card[host_count],5,mov_y); if(host_card[host_count]<4)AA_count++; host_point+=num[host_card[host_count]]; } if(host_point>21){ if(AA_count>0){host_point-=10;AA_count--;}; } move(12,0); clrtoeol();prints("[1;32mÂI¼Æ: [33m%d[m",host_point); move(14,0); clrtoeol();prints("[1;32mÂI¼Æ: [33m%d[m",guest_point); if(host_point>21){ move(14,0); clrtoeol(); prints("[1;32mÂI¼Æ: [33m%d [1;41;33m WINNER [m",guest_point); move(3,0);prints("[1;44;33m§AŤF~~~~ ±o¼úª÷ %d »È¨â[m",money*win); inmoney(money*win); move(0,0);clrtoeol();prints("±zÁÙ¦³ [1;44;33m%d[m »È¨â",cuser.silvermoney); pressanykey(NULL); return; } host_count++; card_count++; mov_y+=4; }while(host_point<guest_point); pressanykey("§A¿é¤F~~~~ »È¨â¨S¦¬!"); return; }
/* ºÚ½Ü¿ËÓÎÏ· */ int BlackJack() { int num[52] = {11, 11, 11, 11, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}; int cardlist[52] = {0}; int i, j, m, tmp = 0, tmp2, ch; int win = 2, win_jack = 5; /* win ΪӮʱµÄ±¶ÂÊ, win_jack * 1 µã±¶ÂÊ */ int six = 10, seven = 20, aj = 10, super_jack = 20; /* 777, A+J, spade A+J µÄ±¶ÂÊ */ int host_count = 2, guest_count = 1, card_count = 3, A_count = 0, AA_count = 0; int host_point = 0, guest_point = 0, mov_y = 4; int host_card[12] = {0}, guest_card[12] = {0}; long int money; int CHEAT = 0; /* ×ö±×²ÎÊý, 1 ¾Í×÷±×, 0 ¾Í²»×÷ */ modify_user_mode(M_BLACKJACK); money = get_money(0,"game/blackjack.welcome"); if(!money) return 0; move(1, 0); prints("¡¾ºÚ½Ü¿Ë¡¿ÓÎÏ· [°´ y ÐøÅÆ, n ²»ÐøÅÆ, d double, q ÈÏÊäÍ˳ö]"); move(0, 0); clrtoeol(); srandom(time(0)); for (i = 1; i <= 52; i++) { m = 0; do { j = random() % 52; if (cardlist[j] == 0) { cardlist[j] = i; m = 1; } } while (m == 0); }; for (i = 0; i < 52; i++) cardlist[i]--; /* Ï´ÅÆ */ if (money >= 20000) CHEAT = 1; if (CHEAT == 1) { if (cardlist[1] <= 3) { tmp2 = cardlist[50]; cardlist[50] = cardlist[1]; cardlist[1] = tmp2; } } /* ×÷±×Âë */ host_card[0] = cardlist[0]; if (host_card[0] < 4) AA_count++; guest_card[0] = cardlist[1]; if (guest_card[0] < 4) A_count++; host_card[1] = cardlist[2]; if (host_card[1] < 4) AA_count++; /* ·¢Ç°ÈýÕÅÅÆ */ move(5, 0); prints("¨q©¤©¤©¤¨r"); move(6, 0); prints("©¦ ©¦"); move(7, 0); prints("©¦ ©¦"); move(8, 0); prints("©¦ ©¦"); move(9, 0); prints("©¦ ©¦"); move(10, 0); prints("©¦ ©¦"); move(11, 0); prints("¨t©¤©¤©¤¨s"); print_card(host_card[1], 5, 4); print_card(guest_card[0], 15, 0); /* Ó¡³öÇ°ÈýÕÅÅÆ */ host_point = num[host_card[1]]; guest_point = num[guest_card[0]]; do { m = 1; guest_card[guest_count] = cardlist[card_count]; if (guest_card[guest_count] < 4) A_count++; print_card(guest_card[guest_count], 15, mov_y); guest_point += num[guest_card[guest_count]]; if ((guest_card[0] >= 24 && guest_card[0] <= 27) && (guest_card[1] >= 24 && guest_card[1] <= 27) && (guest_card[2] >= 24 && guest_card[2] <= 27)) { move(18, 3); prints("[1;41;33m £·£·£· [m"); move(3, 0); sprintf(genbuf,"[1;41;33m£·£·£· !!! µÃ½±½ð %d ÒøÁ½[m", money * seven); prints(genbuf); inmoney(money * seven); gamelog(genbuf); pressanykey(); return 0; } if ((guest_card[0] == 40 && guest_card[1] == 0) || (guest_card[0] == 0 && guest_card[1] == 40)) { move(18, 3); prints("[1;41;33m ³¬¼¶Õýͳ BLACK JACK [m"); move(3, 0); sprintf(genbuf,"[1;41;33m³¬¼¶Õýͳ BLACK JACK !!! µÃ½±½ð %d ÒøÁ½[m", money * super_jack); prints(genbuf); inmoney(money * super_jack); gamelog(genbuf); pressanykey(); return 0; } if ((guest_card[0] <= 3 && guest_card[0] >= 0) && (guest_card[1] <= 43 && guest_card[1] >= 40)) tmp = 1; if ((tmp == 1) || ((guest_card[1] <= 3 && guest_card[1] >= 0) && (guest_card[0] <= 43 && guest_card[0] >= 40))) { move(18, 3); prints("[1;41;33m SUPER BLACK JACK [m"); move(3, 0); sprintf(genbuf,"[1;41;33mSUPER BLACK JACK !!! µÃ½±½ð %d ÒøÁ½[m", money * aj); prints(genbuf); inmoney(money * aj); gamelog(genbuf); pressanykey(); return 0; } if (guest_point == 21 && guest_count == 1) { move(18, 3); prints("[1;41;33m BLACK JACK [m"); move(3, 0); sprintf(genbuf,"[1;41;33mBLACK JACK !!![44m µÃ½±½ð %d ÒøÁ½[m", money * win_jack); prints(genbuf); inmoney(money * win_jack); gamelog(genbuf); pressanykey(); return 0; } /* Ç°Á½ÕÅ¾Í 21 µã */ if (guest_point > 21) { if (A_count > 0) { guest_point -= 10; A_count--; }; } move(19, 0); //clrtoeol(); prints("[1;32mµãÊý: [33m%d[m", host_point); move(20, 0); //clrtoeol(); prints("[1;32mµãÊý: [33m%d[m", guest_point); if (guest_point > 21) { move(20, 0); //clrtoeol(); prints(" ±¬µôÀ²~~~ "); pressanykey(); return 0; } if (guest_count == 5) { move(18, 3); prints("[1;41;33m ¹ýÁù¹Ø [m"); move(3, 0); sprintf(genbuf,"[1;41;33m¹ýÁù¹Ø !!! µÃ½±½ð %d ÒøÁ½[m", money * six); prints(genbuf); inmoney(money * six); gamelog(genbuf); pressanykey(); return 0; } guest_count++; card_count++; mov_y += 4; do { if (ch == 'd') m = 0; if (m != 0) ch = egetch(); } while (ch != 'y' && ch != 'Y' && ch != 'n' && ch != 'N' && ch != 'd' && ch != 'D' && ch != 'q' && ch != 'Q' && m != 0 ); /* ×¥ key */ if (ch == 'd' && m != 0 && guest_count == 2) { if (currentuser.money >= money) { demoney(money); money *= 2; } else ch = 'n'; } /* double */ if (ch == 'd' && guest_count > 2) ch = 'n'; if (ch == 'q' || ch == 'Q') return ; if (guest_point == 21) ch = 'n'; } while (ch != 'n' && m != 0); mov_y = 8; print_card(host_card[0], 5, 0); print_card(host_card[1], 5, 4); host_point += num[host_card[0]]; do { if (host_point < guest_point) { host_card[host_count] = cardlist[card_count]; print_card(host_card[host_count], 5, mov_y); if (host_card[host_count] < 4) AA_count++; host_point += num[host_card[host_count]]; } if (host_point > 21) { if (AA_count > 0) { host_point -= 10; AA_count--; }; } move(19, 0); //clrtoeol(); prints("[1;32mµãÊý: [33m%d[m", host_point); move(20, 0); //clrtoeol(); prints("[1;32mµãÊý: [33m%d[m", guest_point); if (host_point > 21) { move(20, 0); //clrtoeol(); prints("[1;32mµãÊý: [33m%d [1;41;33m WINNER [m", guest_point); move(3, 0); sprintf(genbuf,"Ó®ÁË~~~~ µÃ½±½ð %d ÒøÁ½", money * win); prints(genbuf); gamelog(genbuf); inmoney(money * win); pressanykey(); return 0; } host_count++; card_count++; mov_y += 4; } while (host_point < guest_point); sprintf(genbuf,"ÊäÁË~~~~ ûÊÕ %d ÒøÁ½!", money); prints(genbuf); gamelog(genbuf); pressanykey(); return 0; }