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 p_seven() { char buf1[8],log[80]; char *kind[9]= {"¯QÀs","³æF","¨ßF","¤T±ø","¶¶¤l","¦Pªá","¸¬Äª", "ÅK¤ä","¬h¤B" }; char *poker[52]= {"¢±","¢±","¢±","¢±","¢²","¢²","¢²","¢²", "¢³","¢³","¢³","¢³","¢´","¢´","¢´","¢´","¢µ","¢µ","¢µ","¢µ", "¢¶","¢¶","¢¶","¢¶","¢·","¢·","¢·","¢·","¢¸","¢¸","¢¸","¢¸", "10","10","10","10","¢Ø","¢Ø","¢Ø","¢Ø","¢ß","¢ß","¢ß","¢ß", "¢Ù","¢Ù","¢Ù","¢Ù","¢Ï","¢Ï","¢Ï","¢Ï" }; int cardlist[52]= {0}; int mark[2]= {7,7}, set[6],key,tax=0; /* tax ¬°ª±®aĹ®É©âªºµ| */ int i,j,k,x,m,ch,z=1; int win,color,color2,bet; int host_card[7]= {0}, guest_card[7]= {0}; time_t now = time(0); time(&now); while(-1) { clear(); setutmpmode(SEVENCARD); showtitle("½ä«°¤C±i", BoardName); show_money(bet=0); do { getdata(21, 0,"n¤Uª`¦h¤Ö©O(¤W250000)? «ö Enter Â÷¶}>", buf1, 7, 1, 0); bet=atoi(buf1); if(bet<0) bet=0; } while(bet>250000); if(!bet) return 0; if(bet>cuser.silvermoney) { pressanykey("§Aªº²{ª÷¤£°÷³á.. :)"); return 0; } demoney(bet); show_money(bet); move(21,0); prints("(«ö ¡ô¡õ¡ö¡÷ ©Î ijkl ¿ïµP, ¿ï¦n«ö enter ÅuµP)"); for(i=0; i<52; i++) cardlist[i]=0; mark[0]=mark[1]=7; z=1; for(i=1; i<=52; i++) { m=0; do { j=(time(0)+cuser.silvermoney+random())%52; if (cardlist[j]==0) { cardlist[j]=i; m=1; } } while(m==0); }; for(i=0; i<52; i++)cardlist[i]--; /* ¬~µP */ j=0; for(i=0; i<7; i++) { host_card[i]=cardlist[j]; j++; guest_card[i]=cardlist[j]; j++; } /* µo«e¤Q¥|±iµP */ for(i=0; i<7; i++) { for(j=0; j<(6-i); j++) { if(guest_card[j]>guest_card[j+1]) { x=guest_card[j]; guest_card[j]=guest_card[j+1]; guest_card[j+1]=x; } if(host_card[j]>host_card[j+1]) { x=host_card[j]; host_card[j]=host_card[j+1]; host_card[j+1]=x; } } } /* ±Æ§Ç */ move(1,0); prints("[33;1m¥»¹CÀ¸¥Ñ¯îÂÕ¤Û¹Ò(weird.twbbs.org)¯¸ªø weiren ³]p´£¨Ñ! ¯S¦¹·PÁÂ!!\n"); prints("e-mail: [email protected][m"); move(3,0); prints("¢~¢w¢~¢w¢~¢w¢~¢w¢~¢w¢~¢w¢~¢w¢w¢w¢¡"); move(4,0); prints("¢x ¢x ¢x ¢x ¢x ¢x ¢x ¢x"); move(5,0); prints("¢x ¢x ¢x ¢x ¢x ¢x ¢x ¢x"); move(6,0); prints("¢x ¢x ¢x ¢x ¢x ¢x ¢x ¢x"); move(7,0); prints("¢x ¢x ¢x ¢x ¢x ¢x ¢x ¢x"); move(8,0); prints("¢x ¢x ¢x ¢x ¢x ¢x ¢x ¢x"); move(9,0); prints("¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢w¢w¢£"); for(i=0; i<7; i++) { print_Scard(guest_card[i],11,0+4*i); /* ¦L¥X«e¤C±iµP */ } j=2; k=0; x=0; move(15,2); do { ch=igetkey(); switch (ch) { case KEY_RIGHT: case 'l': j+=4; if(j>26)j=26; break; case KEY_LEFT: case 'j': j-=4; if(j<2)j=2; break; case KEY_UP: case 'i': k=(j-2)/4; if(x<2&&mark[0]!=k&&mark[1]!=k) { if(mark[0]==7)mark[0]=k; else mark[1]=k; x++; cursor_show(15,j); } break; case KEY_DOWN: case 'k': k=(j-2)/4; if(mark[0]==k) { mark[0]=7; x--; } if(mark[1]==k) { mark[1]=7; x--; } cursor_clear(15,j); break; case 13: /* ¿ï¥X¨â±i«á«ö enter */ if(x==2)z=0; break; prints("¥»¹CÀ¸¥Ñ¯îÂÕ¤Û¹Ò(weird.twbbs.org)¯¸ªø weiren ³]p\n"); prints("e-mail: [email protected]"); } move(15,j); } while(z==1); if(mark[0]>mark[1]) { i=mark[0]; mark[0]=mark[1]; mark[1]=i; } for(i=1; i<18; i++) { move(i,0); clrtoeol(); } print_Scard(guest_card[mark[0]],11,0); print_Scard(guest_card[mark[1]],11,4); j=0; for(i=0; i<7; i++) { if(i!=mark[0]&&i!=mark[1]) { print_Scard(guest_card[i],11,16+j*4); set[j]=guest_card[i]; j++; } } /* ¦L¥Xª±®a¤À¦n¨â°ô«áªºµP */ set[5]=5; if(diedragon(set,guest_card[mark[0]],guest_card[mark[1]])==1) { ; pressanykey("ËÀs!"); continue; } if(guest_card[mark[0]]/4==guest_card[mark[1]]/4)x=1; key=find_host(host_card); print_hostcard(host_card,key,log); i=bigsmall(host_card,guest_card,key,mark); switch(i) { case 0: win=2; color=41; color2=41; break; /* ª±®a duA duB ¬ÒĹ */ case 1: win=1; color=41; color2=47; break; /* duA Ĺ duB ¿é */ case 2: win=1; color=47; color2=41; break; /* duA ¿é duB Ĺ */ case 3: win=0; color=47; color2=47; break; /* ¨â½ä¬Ò¿é */ } game_log(SEVENCARD,"§ÚªºµP[46;1m%s%s%s[m..¹q¸£[45;1m%s[m..%s..%d[m",poker[guest_card[mark[0]]], x==1?"F":poker[guest_card[mark[1]]],kind[find_all(set)],log, win?(win==1?"[33;1m¥¤â":"[32;1mŤF"):"[31;1m¿é¤F",bet); move(15,4); prints("[1;%d;%dm %s%s [m ¢x ¢x [1;%d;%dm %s [m" ,color, color==41?33:30 ,poker[guest_card[mark[0]]],x==1?"F":poker[guest_card[mark[1]]] ,color2, color2==41?33:30 ,kind[find_all(set)]); i=bet*2-bet/100*tax; switch(win) { case 2: pressanykey("[1;33m§AŤF %d !!.. :D[44m",i-bet); inmoney(i); break; case 1: pressanykey("[1;36m¥¤â!!..[44m"); inmoney(bet); break; case 0: pressanykey("[1;31m§A¿é¤F³á.. :))[44m" ); break; } } }
int mainNum(int fighting /* Thor.990317: 對戰模式 */) { Num myNumber; char buf[80]; int money; /* 倍率 0 1 2 3 4 5 6 7 8 9 10 */ float bet[11]={0,100, 50, 10, 3 ,1.5,1.2,0.9, 0.8 ,0.5,0.1}; /* initialize variables */ #if 1 if(!hisList) hisList = (His *)malloc(sizeof(His)); /* pseudo */ if(!numSet) numSet = (char *)malloc(10*9*8*7*sizeof(char)); #endif hisNum = 0; numNum = 10*9*8*7; memset(numSet, 0, numNum*sizeof(char)); srand(time(NULL)); /* Thor.990317:對戰模式 */ stand_title(fighting ? "猜數字大戰" :"傻瓜猜數字"); /* clear(); */ do{ move(0,0); prints("您身上還有 [1;44;33m%d[m 元",cuser.silvermoney); getdata(1, 0, "要押注多少錢(1 - 250000)? ", buf, 7, DOECHO,0); money=atoi(buf); if(!buf[0])return; if(check_money(money,SILVER)) return; }while((money<1)||(money>250000)); /* Thor.990221: 有人反應離不開 */ if(answer("想好您的數字了嗎?[y/N]")!='y') { pressanykey("不玩了啊? 下次再來哦! ^_^"); return 0; } if(fighting) ord2Num(rand() % numNum, myNumber); /* Thor.990317:對戰模式 */ demoney(money); /* while there is possibility */ for(;;) { Num myGuess, yourGuess; int youA,youB, myA, myB; if(fighting) /* Thor.990317:對戰模式 */ { int i , a , b; char tmp[50]; do{ getdata(b_lines-3, 0, "您猜我的數字是[????]:", tmp, 5, DOECHO,0); /* Thor.990317: 為簡化, 不作checking */ if(!tmp[0]) goto abort_game; if(tmp[0] == '!' && HAS_PERM(PERM_SYSOP)) pressanykey("%d%d%d%d",myNumber[0],myNumber[1],myNumber[2],myNumber[3]); for (a=0;a<3;a++) for (b=a+1;b<4;b++) if(tmp[a]==tmp[b]) tmp[0]=0; if(!tmp[0]) { pressanykey("輸入數字有問題!!"); } }while (!tmp[0]); for(i=0;i<4;i++) yourGuess[i] = tmp[i] - '0'; AB(myNumber,yourGuess, &myA, &myB); move(b_lines-2,0); clrtoeol(); move(b_lines-2,0); prints("我說 \033[1m%dA%dB \033[m", myA, myB); if(myA==4) { int m = money ,e = ba ; /* you win */ #if 1 game_log(NumFight,"猜了%d次,贏了%d元,EXP %d 點" , hisNum,(int)bet[hisNum]*money,(int)bet[hisNum]*ba); #endif if(hisNum > 10) hisNum = 10; m *= bet[hisNum]; e *= bet[hisNum]; inmoney(m); // inexp(e); // pressanykey("您贏了! 好崇拜 ^O^,獎金 %d 元,經驗值 %d 點!",m,e); pressanykey("您贏了! 好崇拜 ^O^,獎金 %d 元!",m); return 0; } } /* pickup a candidate number */ for(;;) { int i; /* pickup by random */ if(numNum<=0) goto foolme; i = rand() % numNum; i = getth(i, numSet); /* i-th ordering num */ numSet[i] = 1; numNum--; /* filtered out */ ord2Num(i, myGuess); /* convert ordering num to Num */ /* check history */ if(matchHis(myGuess)) break; } /* show the picked number */ move(b_lines - 1, 0); clrtoeol(); move(b_lines - 1, 0); prints("我猜您的數字是 \033[1;37m%d%d%d%d\033[m",myGuess[0], myGuess[1], myGuess[2], myGuess[3]); /* get ?A?B */ for(;;) { char buf[5]; /* get response */ getdata(b_lines, 0, "您的回答[?A?B]:", buf, 5, DOECHO,0); if(!buf[0]) { abort_game: /* abort */ pressanykey("不玩了啊? 下次再來哦! ^_^"); #if 1 game_log(NumFight,"猜了%d次,不想玩了!", hisNum); #endif return 0; } if(isdigit(buf[0]) && (buf[1]|0x20) == 'a' &&isdigit(buf[2]) && (buf[3]|0x20) == 'b' ) { youA = buf[0] - '0'; youB = buf[2] - '0'; /* check legimate */ if(youA >= 0 && youA <=4 && youB >=0 && youB <= 4 && youA + youB <= 4) { /* if 4A, end the game */ if(youA == 4) { int m=money,e=ba; #if 1 game_log(NumFight,"猜了%d次,輸給電腦!", hisNum); #endif /* I win */ if(hisNum > 10) hisNum = 10; m *= bet[10 - hisNum]*0.1; e *= bet[10 - hisNum]; // pressanykey("我贏了! 厲害吧 ^O^,賠你 %d 元,得到 %d 點經驗值",m,e); pressanykey("我贏了! 厲息a ^O^,賠你 %d 元!",m); inmoney(m); // inexp(e); return 0; } else break; } } /* err A B */ outmsg("輸入格式有誤"); } /* put in history */ hisNum ++; hisList = (His *) realloc(hisList, hisNum * sizeof(His)); /* assume must succeeded */ memcpy(hisList[hisNum - 1].n, myGuess, sizeof(Num)); hisList[hisNum - 1].A=youA; hisList[hisNum - 1].B=youB; move(2+hisNum,0); if(fighting) /* Thor.990317: 對戰模式 */ prints("第 \033[1;37m%d\033[m 次, 你猜 \033[1;36m%d%d%d%d\033[m, 我說 \033[1;33m%dA%dB\033[m; 我猜 \033[1;33m%d%d%d%d\033[m, 你說 \033[1;36m%dA%dB\033[m", hisNum, yourGuess[0], yourGuess[1], yourGuess[2], yourGuess[3], myA, myB, myGuess[0], myGuess[1], myGuess[2], myGuess[3], youA, youB); else prints("第 \033[1;37m%d\033[m 次, 我猜 \033[1;33m%d%d%d%d\033[m, 你說 \033[1;36m%dA%dB\033[m", hisNum, myGuess[0], myGuess[1], myGuess[2], myGuess[3], youA, youB); } foolme: /* there is no posibility, show "you fool me" */ pressanykey("你騙我! 不跟你玩了 ~~~>_<~~~"); #if 1 game_log(NumFight,"猜了%d次,耍電腦,被趕出去!", hisNum); #endif return 0; }
/* ºÚ½Ü¿ËÓÎÏ· */ 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; }
int gagb() { int money; char genbuf[200], buf[80]; char ans[5] = ""; /* ±¶ÂÊ 0 1 2 3 4 5 6 7 8 9 10 */ float bet[11] = {0, 100, 50, 10, 3, 1.5, 1.2, 0.9, 0.8, 0.5, 0.1}; int a, b, c, count; modify_user_mode(M_XAXB); srandom(time(0)); money = get_money(0,"game/gagb.welcome"); if(!money) return 0; move(6, 0); prints("[36m%s[m", MSG_SEPERATOR); move(17, 0); prints("[36m%s[m", MSG_SEPERATOR); do { itoa(random() % 10000, ans); for (a = 0; a < 3; a++) for (b = a + 1; b < 4; b++) if (ans[a] == ans[b]) ans[0] = 0; } while (!ans[0]); for (count = 1; count < 11; count++) { do { getdata(5, 0, "Çë²Â[q - Í˳ö] ¡ú ", genbuf, 5, DOECHO, YEA); if (!strcmp(genbuf, "Good")) { prints("[%s]", ans); sprintf(genbuf,"²ÂÊý×Ö×÷±×, ÏÂ×¢ %d Ôª", money); gamelog(genbuf); igetch(); } if ( genbuf[0] == 'q' || genbuf[0] == 'Q' ) { sprintf(buf,"·ÅÆú²Â²â, ¿Û³ýѹע½ð¶î %d Ôª.", money); gamelog(buf); return; } c = atoi(genbuf); itoa(c, genbuf); for (a = 0; a < 3; a++) for (b = a + 1; b < 4; b++) if (genbuf[a] == genbuf[b]) genbuf[0] = 0; if (!genbuf[0]) { move ( 18,3 ); prints("ÊäÈëÊý×ÖÓÐÎÊÌâ!!"); pressanykey(); move ( 18,3 ); prints(" "); } } while (!genbuf[0]); move(count + 6, 0); prints(" [1;31mµÚ [37m%2d [31m´Î£º [37m%s -> [33m%dA [36m%dB [m", count, genbuf, an(genbuf, ans), bn(genbuf, ans)); if (an(genbuf, ans) == 4) break; } if (count > 10) { sprintf(buf, "ÄãÊäÁËßÏ£¡ÕýÈ·´ð°¸ÊÇ %s£¬Ï´ÎÔÙ¼ÓÓÍ°É!!", ans); sprintf(genbuf,"[1;31m¿ÉÁ¯Ã»²Âµ½£¬ÊäÁË %d Ôª£¡[m", money); gamelog(genbuf); } else { int oldmoney = money; money *= bet[count]; inmoney(money); if (money - oldmoney > 0) sprintf(buf, "¹§Ï²£¡×ܹ²²ÂÁË %d ´Î£¬¾»×¬½±½ð %d Ôª", count, money - oldmoney); else if (money - oldmoney == 0) sprintf(buf, "°¦¡«¡«×ܹ²²ÂÁË %d ´Î£¬Ã»ÊäûӮ£¡", count); else sprintf(buf, "°¡¡«¡«×ܹ²²ÂÁË %d ´Î£¬ÅâÇ® %d Ôª£¡", count, oldmoney - money); } gamelog(buf); move(22, 0); clrtobot(); prints(buf); pressanykey(); return 0; }
int vice_main() { FILE *fb = fopen(VICE_BINGO, "r"), *fd, *fj; char buf_data[256] , serial[16], ch[2], *ptr; int TABLE[] = {0,10,200,1000,4000,10000,40000,100000,200000}; int total = 0, money, i = 4, j = 0; sprintf(buf_data, BBSHOME "/home/%c/%s/%s", cuser.userid[0], cuser.userid, VICE_DATA); fd = fopen(buf_data, "r"); if(!fd) { ran_showmfile(VICE_NO, MAX_NO_PICTURE); return 0; } clear(); ran_showfile(0, 0, VICE_PLAY, 1); ran_showfile(10, 0, VICE_SHOW, 1); getdata(8, 0, "任一鍵:對獎 s:查票 q:離開): ", ch, 2, LCECHO); if(ch[0] == 'q' || ch[0] == 'Q'){ if(fd) fclose(fd); return 0; } if(ch[0] == 's' || ch[0]=='S') { j = 0; i = 0; move(10,22); clrtoeol(); prints("這一期的發票號碼"); while(fgets(serial, 15, fd)) { if((ptr = strchr(serial,'\r'))) *ptr = 0; if(j == 0) i++; move(10 + i, 20 + j); prints("%s", serial); j += 9; j %= 45; } getdata(8, 0, "妳要開始對獎了嗎?(或是按q離開)): ", ch, 2, LCECHO); if(ch[0] == 'q'){ if(fd) fclose(fd); return 0; } } lockreturn0(VICE, LOCK_MULTI); if(!fd) { ran_showmfile(VICE_END, MAX_END_PICTURE); unlockutmpmode(); return 0; } showtitle("發票對獎", BBSName); rewind(fd); vice_load(fb); while(fgets(serial, 15, fd)) { if((ptr = strchr(serial,'\n'))) *ptr = 0; money = TABLE[check(serial)]; total += money; prints("%s 中了 %d\n", serial, money); } pressanykey(); if(total > 0) { if(!(fj = fopen(VICE_JAKPOT, "a"))) perror("can't open jakpot file"); ran_showmfile(VICE_WIN, MAX_WIN_PICTURE); move(22,0); clrtoeol(); prints("全部的發票中了 %d 塊錢\n", total); inmoney(total); fprintf(fj, "%-15s 中了$%d\n", cuser.userid, total); fclose(fj); } else ran_showmfile(VICE_LOST, MAX_LOST_PICTURE); fclose(fd); unlink(buf_data); pressanykey(); unlockutmpmode(); return 0; }