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 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 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 m_sob(void) { char genbuf[256], buf[256], userid[25], passbuf[24], msg[2048]=""; int count=0, i, isimported=0, corrected; FILE *fp; sobuserec man; time4_t d; clear(); move(1,0); outs( " 請注意 這是只給陽光沙灘使用者!\n" " 讓沙灘的使用者轉移個人資產以及重要信用資料, 享有平等安全的環境.\n" " 如果您不需要, 請直離開.\n" " -----------------------------------------------------------------\n" " 特別叮嚀:\n" " 為了帳號安全,您只有連續十次密碼錯誤的機會,請小心輸入.\n" " 連續次錯誤您的變身功\能就會被開罰單並直接通知站長.\n" " 請不要在變身過程中不正常斷線, 刻意斷線變半獸人站長不救唷.\n" ); if(getkey("是否要繼續?(y/N)")!='y') return 0; if(search_ulistn(usernum,2)) {vmsg("請登出其他視窗, 以免變身失敗"); return 0;} do { if(!getdata(10,0, " 沙灘的ID [大小寫要完全正確]:", userid, 20, DOECHO)) return 0; if(bad_user_id(userid)) continue; sprintf(genbuf, "sob/passwd/%c/%s.inf",userid[0], userid); if(!(fp=fopen(genbuf, "r"))) { isimported = 1; strcat(genbuf, ".done"); if(!(fp=fopen(genbuf, "r"))) { vmsg("查無此人或已經匯入過..請注意大小寫 "); isimported = 0; continue; } } count = fread(&man, sizeof(man), 1, fp); fclose(fp); }while(!count); count = 0; do{ if(!getdata(11,0, " 沙灘的密碼:", passbuf, sizeof(passbuf), NOECHO)) return 0; if(++count>=10) { cuser.userlevel |= PERM_VIOLATELAW; cuser.vl_count++; passwd_update(usernum, &cuser); post_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤十次", "違法觀察"); mail_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤十次", "違法觀察"); return 0; } if(!(corrected = checkpasswd(man.passwd, passbuf))) vmsg("密碼錯誤"); } while(!corrected); move(12,0); clrtobot(); if(!isimported) { if(!dashf(genbuf)) // avoid multi-login { vmsg("請不要嘗試多重id踹匯入"); return 0; } sprintf(buf,"%s.done",genbuf); rename(genbuf,buf); #ifdef MERGEMONEY reload_money(); sprintf(buf, "您的沙灘鸚鵡螺 %10d 換算成 " MONEYNAME " 幣為 %9d (匯率 22:1), \n" " 沙灘貝殼有 %10d 換算為 " MONEYNAME " 幣為 %9d (匯率 222105:1), \n" " 原有 %10d 匯入後共有 %d\n", (int)man.goldmoney, (int)man.goldmoney/22, (int)man.silvermoney, (int)man.silvermoney/222105, cuser.money, (int)(cuser.money + man.goldmoney/22 + man.silvermoney/222105)); demoney(man.goldmoney/22 + man.silvermoney/222105 ); strcat(msg, buf); #endif i = cuser.exmailbox + man.exmailbox + man.exmailboxk/2000; if (i > MAX_EXKEEPMAIL) i = MAX_EXKEEPMAIL; sprintf(buf, "您的沙灘信箱有 %d (%dk), 原有 %d 匯入後共有 %d\n", man.exmailbox, man.exmailboxk, cuser.exmailbox, i); strcat(msg, buf); cuser.exmailbox = i; if(man.userlevel & PERM_MAILLIMIT) { sprintf(buf, "開啟信箱無上限\n"); strcat(msg, buf); cuser.userlevel |= PERM_MAILLIMIT; } if (cuser.firstlogin > man.firstlogin) d = man.firstlogin; else d = cuser.firstlogin; cuser.firstlogin = d; if (cuser.numlogins < man.numlogins) i = man.numlogins; else i = cuser.numlogins; sprintf(buf, "沙灘進站次數 %d 此帳號 %d 將取 %d \n", man.numlogins, cuser.numlogins, i); strcat(msg,buf); cuser.numlogins = i; if (cuser.numposts < man.numposts ) i = man.numposts; else i = cuser.numposts; sprintf(buf, "沙灘文章次數 %d 此帳號 %d 將取 %d\n", man.numposts,cuser.numposts,i); strcat(msg,buf); cuser.numposts = i; outs(msg); while (search_ulistn(usernum,2)) {vmsg("請將重覆上站其他線關閉! 再繼續");} passwd_update(usernum, &cuser); } sethomeman(genbuf, cuser.userid); mkdir(genbuf, 0755); sprintf(buf, "tar zxvf %c/%s.tar.gz>/dev/null", userid[0], userid); chdir("sob/home"); system(buf); chdir(BBSHOME); if (getans("是否匯入個人信箱? (Y/n)")!='n') { sethomedir(buf, cuser.userid); sprintf(genbuf, "sob/home/%c/%s/.DIR", userid[0], userid); merge_dir(buf, genbuf, 1); strcat(msg, "匯入個人信箱\n"); } if(getans("是否匯入個人信箱精華區(個人作品集)? (會覆蓋\現有設定) (y/N)")=='y') { fileheader_t fh; sprintf(buf, "rm -rd home/%c/%s/man>/dev/null ; " "mv sob/home/%c/%s/man home/%c/%s>/dev/null;" "mv sob/home/%c/%s/gem home/%c/%s/man>/dev/null", cuser.userid[0], cuser.userid, userid[0], userid, cuser.userid[0], cuser.userid, userid[0], userid, cuser.userid[0], cuser.userid); system(buf); strcat(msg, "匯入個人信箱精華區(個人作品集)\n"); sprintf(buf,"home/%c/%s/man/gem", cuser.userid[0], cuser.userid); if(dashd(buf)) { strcat(fh.title, "◆ 個人作品集"); strcat(fh.filename, "gem"); sprintf(fh.owner, cuser.userid); sprintf(buf, "home/%c/%s/man/.DIR", cuser.userid[0], cuser.userid); append_record(buf, &fh, sizeof(fh)); } }