Пример #1
0
int
m_sysop()
{
  setutmpmode(MSYSOP);
  mail_sysop();
  return 0;
}
Пример #2
0
static void chc_init(int s, board_t board) {
    userinfo_t *my = currutmp;

    setutmpmode(CHC);
    clear();
    chc_warnmsg[0] = 0;
    chc_my = my->turn;
    chc_mateid = my->mateid;
    chc_firststep = 1;
    chc_init_board(board);
    chc_redraw(board);
    chc_cursor.r = 9, chc_cursor.c = 0;
    add_io(s, 0);
    
    if(my->turn) chc_recvmove(s);
    passwd_query(usernum, &xuser);
    cuser.chc_win = xuser.chc_win;
    cuser.chc_lose = xuser.chc_lose + 1;
    cuser.chc_tie = xuser.chc_tie;
    cuser.money   = xuser.money;
    passwd_update(usernum, &cuser);
    
    getuser(chc_mateid);
    chc_hiswin = xuser.chc_win;
    chc_hislose = xuser.chc_lose;
    chc_histie = xuser.chc_tie;
    
    if(!my->turn) {
	chc_sendmove(s);
	chc_hislose++;
    }
    
    chc_redraw(board);
}
Пример #3
0
static void chc_init(int s, board_t board) {

    user_info *my = uin;
    setutmpmode(CHESS);
    clear();
    chc_warnmsg[0] = 0;
    chc_my = currutmp->turn;

    chc_firststep = 1;
    chc_init_board(board);
    chc_redraw(board);
    chc_cursor.r = 9, chc_cursor.c = 0;
    add_io(s, 0);
    chc_load(cuser.userid,1);

    if(my->turn) chc_recvmove(s);
    chc_load(uin->userid,2);

//    if(!currutmp->turn) {
        chc_sendmove(s);
//        chc_hislose++;
//    }

    chc_redraw(board);
}
Пример #4
0
int
lockutmpmode(int unmode, int state)
{
    int             errorno = 0;

    if (currutmp->lockmode)
	errorno = LOCK_THIS;
    else if (state == LOCK_MULTI && is_playing(unmode))
	errorno = LOCK_MULTI;

    if (errorno) {
	clear();
	move(10, 20);
	if (errorno == LOCK_THIS)
	    prints("請先離開 %s 才能再 %s ",
		   ModeTypeTable[currutmp->lockmode],
		   ModeTypeTable[unmode]);
	else
	    prints("抱歉! 因為您目前多重登入所以無法使用 %s",
                   ModeTypeTable[unmode]);
	pressanykey();
	return errorno;
    }
    setutmpmode(unmode);
    currutmp->lockmode = unmode;
    return 0;
}
Пример #5
0
static void do_talk(int fd)
{
   struct talk_win mywin, itswin;
   time_t talkstart;
   usint myword = 0,itword = 0;
   char mid_line[128], data[200];
   int i, ch, datac;
   int im_leaving = 0;
   struct tm *ptime;
   time_t now;
   char genbuf[200], fpath[100];

   time(&now);
   ptime = localtime(&now);

   sethomepath(fpath, cuser.userid);
   strcpy(fpath, tempnam(fpath, "talk_"));
   flog = fopen(fpath, "w");

   setutmpmode(TALK);

   ch = 58 - strlen(save_page_requestor);
   sprintf(genbuf, "%s【%s", cuser.userid, cuser.username);
   i = ch - strlen(genbuf);
   if (i >= 0)
      i = (i >> 1) + 1;
   else
   {
Пример #6
0
int
Announce(void)
{
    setutmpmode(ANNOUNCE);
    a_menu(BBSNAME "佈告欄", "man",
	   ((HasUserPerm(PERM_SYSOP) ) ? SYSOP : NOBODY),
	   0,
	   NULL, NULL);
    return 0;
}
Пример #7
0
int p_five()
{
   int i=0;
   srandom(time(0));

restart:
  setutmpmode(FIVE);
  showtitle("天地五子棋", BOARDNAME);

  outs("┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐\n");
for(sum=0;sum<20;sum++)
  outs("├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤\n");
  outs("└┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┘\n");


   gotoxy(48,1); outs("=-=-=-=-=-=-=-=-=-=");
   gotoxy(48,2); outs("|   天地五子棋    |");
   gotoxy(48,3); outs("=-=-=-=-=-=-=-=-=-=");
   who(0); who(1);

   gotoxy(45,17); outs(" ↓↑→← >> 控制方向");
   gotoxy(45,18); outs("  空白鍵  >> 確定");
   gotoxy(45,19); outs("     2    >> 二號玩家換人");
   gotoxy(45,20); outs("     b    >> 悔棋");
   gotoxy(45,21); outs("     r    >> 重新開始");
   gotoxy(45,22); outs("     q    >> 離開");

   for(m=1;m<22;m++)
    for(n=1;n<22;n++)
      chess[m][n]=0;

   sum=fturn=0;
   m=n=mm=nn=11;
   for(;;)
   {
     if(role[fturn]==1)
     {
       int tmp=fplayer(fturn+1);
       if(tmp==1) goto restart;
       if(tmp==2) return;
     }
     else
     {
       int hk=think(fturn+1);
       if(hk)
       {
         i=show_win(hk);
         if(i=='q'||i=='n') return;
         goto restart;
       }
     }
     fturn=abs(fturn-1);
   }
}
Пример #8
0
start(user_info *uin)
{
 char x,y,xx,yy,tmp,genbuf[255],n[8][4]=
       {{3,5,5,7},{7,9,9,11},{11,13,13,15},{15,15,15,15},
        {67,69,69,71},{71,73,73,75},{75,77,77,79},{79,79,79,79}};
 int i,j,k;
 FILE *fs;

 clear();
 setutmpmode(DARK);
 showtitle("天地暗棋", BOARDNAME);

 move(1,0);
 fs=fopen("game/dark.i","r"); //* 改成自己的路徑
 while (fgets(genbuf, 254, fs)) prints(genbuf);
 fclose(fs);

 sprintf(genbuf, BBSHOME "/home/%s/.dark", currutmp->userid);
  if(fs=fopen(genbuf, "r")) {
   fscanf(fs, "%d %d %d", &i, &j, &k);
   fclose(fs); 
 } else i=j=k=0;
 printtt(19, 26, "%-13s", currutmp->userid);
 sprintf(genbuf,"%d-%d-%d",i,j,k);
 strncat(genbuf,"        ",13-strlen(genbuf));
 printtt(20, 26, "%s", genbuf);

 sprintf(genbuf, BBSHOME "/home/%s/.dark", uin->userid);
 if(fs=fopen(genbuf, "r")) {
   fscanf(fs, "%d %d %d", &i, &j, &k);
   fclose(fs);
 } else i=j=k=0;
 printtt(19, 87, "%-13s", uin->userid);
 sprintf(genbuf,"%d-%d-%d",i,j,k);
 strncat(genbuf,"        ",13-strlen(genbuf));
 printtt(20, 87, "%s", genbuf);
 refresh();

 memcpy(chess,n,strlen((char *)n));
 for(i=0;i<30000;i++) {
  x=random()%4; xx=random()%4;
  y=random()%8; yy=random()%8;
  tmp=chess[yy][xx];
  chess[yy][xx]=chess[y][x];
  chess[y][x]=tmp;
 }
}
Пример #9
0
int x_love() {
    char buf1[200], save_title[TTLEN + 1];
    char receiver[61], path[STRLEN] = "home/";
    int x, y = 0, tline = 0, poem = 0;
    FILE *fp, *fpo;
    time_t timenow;
    struct tm *gtime;
    fileheader_t mhdr;
    
    setutmpmode(LOVE);
    time(&timenow);
    gtime = localtime(&timenow);
    sprintf(buf1,"%c/%s/love%d%d",
	    cuser.userid[0], cuser.userid,gtime->tm_sec,gtime->tm_min);
    strcat(path,buf1);
    move(1,0);
    clrtobot();
    
    outs("\n歡迎使用情書產生器 v0.00 版 \n");
    outs("有何難以啟齒的話,交由系統幫你說吧.\n爸爸說 : 濫情不犯法.\n");
    
    if(!getdata(7, 0, "收信人:", receiver, 60, DOECHO)) return 0;
    if(receiver[0] && !(searchuser(receiver) &&
			getdata(8, 0, "主  題:", save_title,
				TTLEN, DOECHO))) {
	move(10, 0);
	outs("收信人或主題不正確, 情書無法傳遞. ");
	pressanykey();
	return 0;
    }
    
    fpo = fopen(path, "w");
    fprintf(fpo, "\n");
    if((fp = fopen(DATA, "r"))) {
	while(fgets(buf1,100, fp)) {
	    switch(buf1[0]) {
	    case '#':
		break;
	    case '@':
		if(!strncmp(buf1, "@begin", 6) || !strncmp(buf1, "@end", 4))
		    tline=3;
		else if(!strncmp(buf1,"@poem",5)) {
		    poem = 1;
		    tline = 1;
		    fprintf(fpo, "\n\n");
		} else
		    tline=2;
		break;
	    case '1':
	    case '2':
	    case '3':
	    case '4':
	    case '5':
	    case '6':
	    case '7':
	    case '8':
	    case '9':
		sscanf(buf1,"%d",&x);
		y = (rand() % (x - 1)) * tline; 
		break;
	    default:
		if(!poem) {
		    if(y > 0)
			y = y - 1;
		    else {
			if(tline > 0) {
			    fprintf(fpo, "%s", buf1);
			    tline--;
			}
		    }
		} else {
		    if(buf1[0] == '$')
			y--;
		    else if(y == 0)
			fprintf(fpo,"%s",buf1);
		}
	    } 

	}
	
	fclose(fp);
	fclose(fpo);
	if(vedit(path, YEA, NULL) == -1) {
	    unlink(path);
	    clear();
	    outs("\n\n 放棄寄情書\n");
	    pressanykey();
	    return -2;
	}
	sethomepath(buf1, receiver);
	stampfile(buf1, &mhdr);
	Rename(path, buf1);
	strncpy(mhdr.title, save_title, TTLEN);
	strcpy(mhdr.owner, cuser.userid);
	mhdr.savemode = '\0';
	sethomedir(path, receiver );
	if(append_record(path, &mhdr, sizeof(mhdr)) == -1)
	    return -1;
	hold_mail(buf1, receiver);
	return 1;
    }
    return 0;
}
Пример #10
0
int five_pk(int fd,int first)
{
    int cx, ch, cy,datac,fdone,x /* ,y */;
    char genbuf[100],data[90],xy_po[5],genbuf1[20] /* ,x1[1],y1[1],done[1] */;
    /*    struct user_info *opponent; */
    /*     char fname[50]; */
    int i,j /* ,k */,fway,banf,idone;


    /*
     *      Ôö¼ÓÁÄÌ칦ÄÜ. Added by satan. 99.04.02
     */

#define START    17
#define END      21
#define PROMPT   23
#undef MAX
#define MAX      (END - START)
#define BSIZE    60


    char chatbuf[80], *cbuf;
    int ptr = 0, chating = 0 /*, over = 0 */;

    setutmpmode(FIVE);       /*Óû§×´Ì¬ÉèÖÃ*/
    clear ();
    InitScreen();
    five_chat (NULL, 1);

    cbuf = chatbuf + 19;
    chatbuf[0] = '\0';
    chatbuf[79] = '\0';
    cbuf[0] = '\0';
    sprintf (chatbuf + 1, "%-16s: ", cuser.username);

    add_io(fd, 0);

begin:
    for(i=0; i<=14; i++)
        for(j=0; j<=14; j++)
            playboard[i][j]=0;


    hand=1;
    winner=0;
    quitf=0;
    px=14;
    py=7;
    fway = 1;
    banf = 1;
    idone = 0;


    sprintf(genbuf, "%s (%s)", cuser.userid, cuser.username);

    if(first)
    {
        move(1,33);
        prints("ºÚ¡ñÏÈÊÖ %s  ",genbuf);
        move(2,33);
        prints("°×¡ðºóÊÖ %s  ",save_page_requestor);
    }
    else
    {
        move(1,33);
        prints("°×¡ðºóÊÖ %s  ",genbuf);
        move(2,33);
        prints("ºÚ¡ñÏÈÊÖ %s  ",save_page_requestor);
    }


    move(15,35);
    if(first)
        outs("¡ïµÈ´ý¶Ô·½ÏÂ×Ó¡ï");
    else
        outs("¡ôÏÖÔÚ¸Ã×Ô¼ºÏ¡ô");
    move(7,14);
    outs("¡ñ");
    player=white;
    playboard[7][7]=black;
    chess[1][0]=14; /*¼Í¼ËùÏÂλַ*/
    chess[1][1]=7;
    move(4,35);
    outs("µÚ 1ÊÖ ¡ñH 8");

    if(!first)
    {   /*³¬¹Ö!*/
        move (7, 14);
        fdone=1;
    }
    else
        fdone=0;    /*¶ÔÊÖÍê³É*/

    while (1)
    {
        ch=igetkey();

        if (ch == I_OTHERDATA)
        {
            datac = recv(fd, data, sizeof(data), 0);
            if (datac <= 0)
            {
                move(17,30);
                outs(" ¶Ô·½Í¶½µÁË...@_@ ");
                break;
            }
            if (data[0] == '\0')
            {
                five_chat (data + 1, 0);
                if (chating)
                    move (PROMPT, ptr + 6);
                else
                    move (py, px);
                continue;
            }
            else if (data[0] == '\1')
            {
                bell ();
                RMSG = YEA;
                saveline (PROMPT, 0);
                sprintf (genbuf, "%s ˵: ÖØÀ´Ò»Å̺ÃÂð? (Y/N)[Y]:", save_page_requestor);
                getdata (PROMPT, 0, genbuf, genbuf1, 2, LCECHO, YEA);
                RMSG = NA;
                if (genbuf1[0] == 'n' || genbuf1[0] == 'N')
                {
                    saveline (PROMPT, 1);
                    send (fd, "\3", 1, 0);
                    continue;
                }
                else
                {
                    saveline (PROMPT, 1);
                    InitScreen ();
                    first = 0;
                    send (fd, "\2", 1, 0);
                    goto begin;
                }
            }
            else if (data[0] == '\2')
            {
                bell ();
                saveline (PROMPT, 0);
                move (PROMPT, 0);
                clrtoeol ();
                prints ("%s ½ÓÊÜÁËÄãµÄÇëÇó :-)", save_page_requestor);
                refresh ();
                sleep (1);
                saveline (PROMPT, 1);
                InitScreen ();
                first = 1;
                goto begin;
            }
            else if (data[0] == '\3')
            {
                bell ();
                saveline (PROMPT, 0);
                move (PROMPT, 0);
                clrtoeol ();
                prints ("%s ¾Ü¾øÁËÄãµÄÇëÇó :-(", save_page_requestor);
                refresh ();
                sleep (1);
                saveline (PROMPT, 1);
                if (chating)
                    move (PROMPT, ptr + 6);
                else
                    move (py, px);
                continue;
            }
            else if (data[0] == '\xff')
            {
                move (PROMPT, 0);
                quit ();
                break;
            }
            i=atoi(data);
            cx=i/1000;   /*½âÒëdata³ÉÆåÅÌ×ÊÁÏ*/
            cy=(i%1000)/10;
            fdone=i%10;
            hand+=1;

            if(hand%2==0)
                move(((hand-1)%20)/2+4,48);
            else
                move(((hand-1)%19)/2+4,35);

            prints("µÚ%2dÊÖ %s%c%2d",hand,
                   (player==black)?"¡ñ":"¡ð",abcd[cx/2],15-cy);


            move(cy,cx);
            x=cx/2;
            playboard[x][cy]=player;
            if(player==black)
            {
                outs("¡ñ");
                player=white;
            }
            else
            {
                outs("¡ð");
                player=black;
            }
            move (cy, cx);
            refresh ();
            bell ();
            move(15,35);
            outs("¡ôÏÖÔÚ¸Ã×Ô¼ºÏ¡ô");
            haha (5);

            tdeadf=tlivef=livethree=threefour=0;
            for(j=0; j<=10; j++)
                calvalue(cx/2,j,cx/2,j+1,cx/2,j+2,cx/2,j+3,cx/2,j+4);
            for(i=0; i<=10; i++) /*ºáÏò*/
                calvalue(i,cy,i+1,cy,i+2,cy,i+3,cy,i+4,cy);
            for(i=-4; i<=0; i++) /*бÓÒÏÂ*/
                calvalue(cx/2+i,cy+i,cx/2+i+1,cy+i+1,cx/2+i+2,cy+i+2,
                         cx/2+i+3,cy+i+3,cx/2+i+4,cy+i+4);
            for(i=-4; i<=0; i++) /*б×óÏÂ*/
                calvalue(cx/2-i,cy+i,cx/2-i-1,cy+i+1,cx/2-i-2,cy+i+2,cx/2-i-3,
                         cy+i+3,cx/2-i-4,cy+i+4);

            for(j=0; j<=9; j++)
                callfour(cx/2,j,cx/2,j+1,cx/2,j+2,cx/2,j+3,cx/2,j+4,cx/2,j+5);
            for(i=0; i<=9; i++) /*ËĺáÏò*/
                callfour(i,cy,i+1,cy,i+2,cy,i+3,cy,i+4,cy,i+5,cy);
            for(i=-5; i<=0; i++)
            {   /*ËÄбÓÒÏÂ*/
                callfour(cx/2+i,cy+i,cx/2+i+1,cy+i+1,cx/2+i+2,cy+i+2,
                         cx/2+i+3,cy+i+3,cx/2+i+4,cy+i+4,cx/2+i+5,cy+i+5);
                /*ËÄб×óÏÂ*/
                callfour(cx/2-i,cy+i,cx/2-i-1,cy+i+1,cx/2-i-2,cy+i+2,cx/2-i-3,
                         cy+i+3,cx/2-i-4,cy+i+4,cx/2-i-5,cy+i+5);
            }

            py = cy;
            px = cx;
            if(tlivef>=2 && winner==0)
                bandhand(4);
            if(livethree>=2 && tlivef ==0)
                bandhand(3);
            if(threefour==black)
                haha(1);
            else if(threefour==white)
                haha(1);
            if (chating)
            {
                sleep (1);
                move (PROMPT, ptr + 6);
            }
            else
                move (py, px);
            if (winner)
            {
                InitScreen ();
                goto begin;
            }
        }
        else
        {
            if (ch == Ctrl('X'))
            {
                quitf = 1;
            }
            else if (ch==Ctrl('C') || ((ch=='Q' || ch=='q') && !chating))
            {
                RMSG = YEA;
                saveline (PROMPT, 0);
                getdata(PROMPT, 0, "ÄúÈ·¶¨ÒªÀ뿪Âð? (Y/N)?[N] ", genbuf1, 2, LCECHO, YEA);
                if (genbuf1[0] == 'Y' || genbuf1[0] == 'y')
                    quitf = 1;
                else
                    quitf = 0;
                saveline (PROMPT, 1);
                RMSG = NA;
            }
            else if (ch==Ctrl('N') || ((ch=='N' || ch=='n') && !chating))
            {
                saveline (PROMPT, 0);
                RMSG = YEA;
                getdata(PROMPT,0,"ÄúÈ·¶¨ÒªÖØпªÊ¼Âð? (Y/N)?[N] ",genbuf1,2,LCECHO, YEA);
                if (genbuf1[0] == 'Y' || genbuf1[0] == 'y')
                {
                    send (fd, "\1", 1, 0);
                    move (PROMPT, 0);
                    bell ();
                    clrtoeol ();
                    move (PROMPT, 0);
                    outs ("ÒѾ­ÒѾ­ÌæÄú·¢³öÇëÇóÁË");
                    refresh ();
                    sleep (1);
                }
                RMSG = NA;
                saveline (PROMPT, 1);
                if (chating)
                    move (PROMPT, ptr + 6);
                else
                    move (py, px);
                continue;
            }
            else if (ch == '\t')
            {
                if (chating)
                {
                    chating = 0;
                    move (py, px);
                }
                else
                {
                    chating = 1;
                    move (PROMPT, 6 + ptr);
                }
                continue;
            }
            else if (ch == '\0')
                continue;
            else if (chating)
            {
                if (ch == '\n' || ch == '\r')
                {
                    if (!cbuf[0])
                        continue;
                    ptr = 0;
                    five_chat (chatbuf + 1, 0);
                    send (fd, chatbuf, strlen (chatbuf + 1) + 2, 0);
                    cbuf[0] = '\0';
                    move (PROMPT, 6);
                    clrtoeol ();
                }
                else if (ch == KEY_LEFT)
                {
                    if (ptr)
                        ptr --;
                }
                else if (ch == KEY_RIGHT)
                {
                    if (cbuf[ptr])
                        ptr ++;
                }
                else if (ch == Ctrl ('H') || ch == '\177')
                {
                    if (ptr)
                    {
                        ptr --;
                        memcpy (&cbuf[ptr], &cbuf[ptr+1], BSIZE-ptr);
                        move (PROMPT, ptr+6);
                        clrtoeol ();
                        prints ("%s",&cbuf[ptr]);
                    }
                }
                else if (ch == KEY_DEL)
                {
                    if (cbuf[ptr])
                    {
                        memcpy (&cbuf[ptr], &cbuf[ptr+1], BSIZE-ptr);
                        clrtoeol ();
                        prints ("%s",&cbuf[ptr]);
                    }
                }
                else if (ch == Ctrl ('A'))
                {
                    ptr = 0;
                }
                else if (ch == Ctrl ('E'))
                {
                    while (cbuf[++ptr])
                        ;
                }
                else if (ch == Ctrl ('K'))
                {
                    ptr = 0;
                    cbuf[ptr] = '\0';
                    move (PROMPT, ptr+6);
                    clrtoeol ();
                }
                else if (ch == Ctrl ('U'))
                {
                    memmove (cbuf, &cbuf[ptr], BSIZE - ptr + 1);
                    ptr = 0;
                    move (PROMPT, ptr+6);
                    clrtoeol ();
                    prints ("%s",cbuf);
                }
                else if (ch == Ctrl ('W'))
                {
                    if (ptr)
                    {
                        int optr;

                        optr = ptr;
                        ptr --;
                        do
                        {
                            if (cbuf[ptr] != ' ')
                                break;
                        }
                        while (-- ptr);
                        do
                        {
                            if (cbuf[ptr] == ' ')
                            {
                                if (cbuf[ptr+1] != ' ')
                                    ptr ++;
                                break;
                            }
                        }
                        while (-- ptr);
                        memcpy (&cbuf[ptr], &cbuf[optr], BSIZE-optr+1);
                        move (PROMPT, ptr+6);
                        clrtoeol ();
                        prints ("%s",&cbuf[ptr]);
                    }
                }
                else if (isprint2 (ch))
                {
                    if (ptr == BSIZE)
                        continue;
                    if (!cbuf[ptr])
                    {
                        cbuf[ptr] = ch;
                        move (PROMPT, 6 + ptr);
                        outc (ch);
                        cbuf[++ptr] = 0;
                    }
                    else
                    {
                        memmove (&cbuf[ptr+1], &cbuf[ptr], BSIZE-ptr+1);
                        cbuf[ptr] = ch;
                        move (PROMPT, 6 + ptr);
                        prints ("%s",&cbuf[ptr]);
                        ptr ++;
                    }
                }
                move (PROMPT, 6 + ptr);
                continue;
            }
        }

        if(fdone==1 && !chating && ch != I_OTHERDATA)/*»»ÎÒ*/
        {

            move(py,px);
            switch (ch)
            {

            case KEY_DOWN:
            case 'j':
            case 'J':
                py=py+1;
                if(py>14)
                    py=0;
                break;

            case KEY_UP:
            case 'k':
            case 'K':
                py=py-1;
                if(py<0)
                    py=14;
                break;

            case KEY_LEFT:
            case 'h':
            case 'H':
                px=px-1;
                if(px<0)
                    px=28;
                break;

            case KEY_RIGHT:
            case 'l':
            case 'L':
                px=px+1;
                if(px>28)
                {
                    px=0;
                    px=px-1;
                }                      /*»áÌø¸ñßÖ*/
                break;
            case ' ':
                if(banf==1)
                    break;

                if((px%2)==1)
                    px=px-1; /*½â¾önetterm²»ºÏÎÊÌâ*/
                move(py,px);
                hand+=1;
                playboard[x][py]=player;
                if(player==black)
                {
                    outs("¡ñ");
                    player=white;
                }
                else
                {
                    outs("¡ð");
                    player=black;
                }
                chess[hand][0]=px;
                chess[hand][1]=py;
                if(hand%2==0)
                    move(((hand-1)%20)/2+4,48);
                else
                    move(((hand-1)%19)/2+4,35);

                prints("µÚ%2dÊÖ %s%c%2d",hand,
                       (hand%2==1)?"¡ñ":"¡ð",abcd[px/2],15-py);
                idone=1;
                move (py, px);
                refresh ();
                break;
            default:
                break;
            }
            move(py,px);
            x=px/2;
            if(playboard[x][py]!=0)
                banf=1;
            else
                banf=0;

            if(idone==1)
            {
                xy_po[0] = px/10 + '0';
                xy_po[1] = px%10 + '0';
                xy_po[2] = py/10 + '0';
                xy_po[3] = py%10 + '0';
                fdone=0;
                xy_po[4]='1';
                if(send(fd,xy_po,sizeof(xy_po),0)==-1)
                    break;

                move(15,35);
                outs("¡ïµÈ´ý¶Ô·½ÏÂ×Ó¡ï");
                haha (5);

                tdeadf=tlivef=livethree=threefour=0;
                for(j=0; j<=10; j++)
                    calvalue(px/2,j,px/2,j+1,px/2,j+2,px/2,j+3,px/2,j+4);
                for(i=0; i<=10; i++) /*ºáÏò*/
                    calvalue(i,py,i+1,py,i+2,py,i+3,py,i+4,py);
                for(i=-4; i<=0; i++) /*бÓÒÏÂ*/
                    calvalue(px/2+i,py+i,px/2+i+1,py+i+1,px/2+i+2,py+i+2,
                             px/2+i+3,py+i+3,px/2+i+4,py+i+4);
                for(i=-4; i<=0; i++) /*б×óÏÂ*/
                    calvalue(px/2-i,py+i,px/2-i-1,py+i+1,px/2-i-2,py+i+2,px/2-i-3,
                             py+i+3,px/2-i-4,py+i+4);

                for(j=0; j<=9; j++)
                    callfour(px/2,j,px/2,j+1,px/2,j+2,px/2,j+3,px/2,j+4,px/2,j+5);
                for(i=0; i<=9; i++) /*ËĺáÏò*/
                    callfour(i,py,i+1,py,i+2,py,i+3,py,i+4,py,i+5,py);
                for(i=-5; i<=0; i++)
                {   /*ËÄбÓÒÏÂ*/
                    callfour(px/2+i,py+i,px/2+i+1,py+i+1,px/2+i+2,py+i+2,
                             px/2+i+3,py+i+3,px/2+i+4,py+i+4,px/2+i+5,py+i+5);
                    /*ËÄб×óÏÂ*/
                    callfour(px/2-i,py+i,px/2-i-1,py+i+1,px/2-i-2,py+i+2,px/2-i-3,
                             py+i+3,px/2-i-4,py+i+4,px/2-i-5,py+i+5);
                }

                if(tlivef>=2 && winner==0)
                    bandhand(4);
                if(livethree>=2 && tlivef ==0)
                    bandhand(3);
                if(threefour==black)
                    haha(1);
                else if(threefour==white)
                    haha(1);

            }
            idone=0;
        }
        if (quitf)
        {
            genbuf1[0] = '\xff';
            send (fd, genbuf1, 1, 0);
            press ();
            break;
        }
        if (winner)
        {
            InitScreen ();
            goto begin;
        }
    }

    add_io(0, 0);
    close(fd);
    return;
}
Пример #11
0
Файл: bj.c Проект: yrchen/Athena
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ÁÙ¦³ %d ¤¸",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ÁÙ¦³ %d »È¨â",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("     ¢¶¢¶¢¶     ");
      move(3,0);prints("¢¶¢¶¢¶ !!! ±o¼úª÷ %d »È¨â",money*seven);
      inmoney(money*seven);
      game_log("BLACKJACK","¤¤¤F %7d ¤¸ªº "COLOR1"  ¢¶¢¶¢¶   "
        ,money*seven);
      pressanykey("±zÁÙ¦³ %d »È¨â",cuser.silvermoney);
      return;
    }

    if((guest_card[0]==40&&guest_card[1]==0)||(guest_card[0]==0&&guest_card[1]==40)){
      move(18,3);prints(" ¶W¯Å¥¿²Î BLACK JACK  ");
      move(3,0);prints("¶W¯Å¥¿²Î BLACK JACK !!! ±o¼úª÷ %d »È¨â",money*super_jack);
      inmoney(money*super_jack);
      game_log("BLACKJACK","¤¤¤F %7d ¤¸ªº  ¥¿²Î ¢Ï¢Ø "
        ,money*super_jack);
      pressanykey("±zÁÙ¦³ %d »È¨â",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(" SUPER BLACK JACK  ");
      move(3,0);prints("SUPER BLACK JACK !!! ±o¼úª÷ %d »È¨â",money*aj);
      inmoney(money*aj);
      game_log("BLACKJACK","¤¤¤F %7d ¤¸ªº  Super¢Ï¢Ø ",money*aj);
      pressanykey("±zÁÙ¦³ %d »È¨â",cuser.silvermoney);
      return;
    }

    if(guest_point==21&&guest_count==1){
      move(18,3);prints("  BLACK JACK  ");
      move(3,0);prints("BLACK JACK !!! ±o¼úª÷ %d »È¨â",money*win_jack);
      inmoney(money*win_jack);
      move(0,0);clrtoeol();prints("±zÁÙ¦³ %d »È¨â",cuser.silvermoney);
    if(money*win_jack>=500000){
      game_log("BLACKJACK","¤¤¤F %7d ¤¸ªº  BlackJack  %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("ÂI¼Æ: %d",host_point);
    move(14,0); clrtoeol();prints("ÂI¼Æ: %d",guest_point);
    if(guest_point>21){
      pressanykey("  Ãz±¼°Õ~~~  ");
      return;
    }

    if(guest_count==5){
      move(18,3);prints("            ¹L¤»Ãö            ");
      move(3,0);prints("¹L¤»Ãö !!! ±o¼úª÷ %d »È¨â",money*six);
      inmoney(money*six);
      game_log("BLACKJACK","¤¤¤F %7d ¤¸ªº   ¹L¤»Ãö   ",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ÁÙ¦³ %d »È¨â",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("ÂI¼Æ: %d",host_point);
    move(14,0); clrtoeol();prints("ÂI¼Æ: %d",guest_point);
    if(host_point>21){
      move(14,0); clrtoeol(); prints("ÂI¼Æ: %d  WINNER ",guest_point);

      move(3,0);prints("§AŤF~~~~ ±o¼úª÷ %d »È¨â",money*win);
      inmoney(money*win);
      move(0,0);clrtoeol();prints("±zÁÙ¦³ %d »È¨â",cuser.silvermoney);
      pressanykey(NULL);
      return;
    }
    host_count++;
    card_count++;
    mov_y+=4;
  }while(host_point<guest_point);

  pressanykey("§A¿é¤F~~~~ »È¨â¨S¦¬!");
  return;
}
Пример #12
0
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(¤W­­250000)? «ö 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("¥»¹CÀ¸¥Ñ¯îÂÕ¤Û¹Ò(weird.twbbs.org)¯¸ªø weiren ³]­p´£¨Ñ! ¯S¦¹·PÁÂ!!\n");
        prints("e-mail: [email protected]");

        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%s%s%s..¹q¸£%s..%s..%d",poker[guest_card[mark[0]]],
                 x==1?"­F":poker[guest_card[mark[1]]],kind[find_all(set)],log,
                 win?(win==1?"¥­¤â":"ŤF"):"¿é¤F",bet);
        move(15,4);
        prints("[1;%d;%dm   %s%s     ¢x  ¢x  [1;%d;%dm         %s         "
               ,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("§AŤF %d !!.. :D",i-bet);
            inmoney(i);
            break;
        case 1:
            pressanykey("¥­¤â!!..");
            inmoney(bet);
            break;
        case 0:
            pressanykey("§A¿é¤F³á.. :))" );
            break;
        }
    }
}
Пример #13
0
int fightNum()
{
  setutmpmode(NumFight);
  mainNum(1);
}
Пример #14
0
int use_dict() {
    FILE *fp;
    char lang[150], word[80] = "";
    char j, f, buf[120], sys[] = "|\033[31me\033[m:編籍字典";
    int i = 0;
    
    setutmpmode(DICT);
    if(!HAS_PERM(PERM_SYSOP))
	sys[0]=0;
    
    clear();
    
    sprintf(buf,"\033[45m                           ●\033[1;44;33m"
	    "  %-14s\033[3;45m ●                              ", dict);
    strcpy(&buf[100],"\033[m\n");
    for(;;) {
	move(0, 0);
	sprintf(lang, "  請輸入關鍵字串(%s) 或指令(h,t,a)\n", dict);
	outs(lang);
	sprintf(lang, "[\033[32m<關鍵字>\033[m|\033[32mh\033[m:help|\033[32m"
		"t\033[m:所有資料|\033[32ma\033[m:新增資料%s]\n:", sys);
	outs(lang);
	getdata(2, 0, ":", word, 18, DOECHO);
	outs("資料搜尋中請稍候....");
	strcpy(word,lower(word));
	if(word[0] == 0)
	    return 0;
	clear();
	move(4, 0);
	outs(buf);
	if(strlen(word) == 1) {
	    if(word[0] == 'a') {
		clear();
		move(4,0);
		outs(buf);
		addword(word);
		continue;
	    } else if(word[0] == 't')
		word[0] = 0;
	    else if(word[0] == 'h') {
		more("etc/dict.hlp",YEA);
		clear();
		continue;
	    } else if(word[0]=='e') {
		vedit(database,NA, NULL);
		clear();
		continue;
	    } else {
		outs("字串太短,請輸入多一點關鍵字");
		continue;
	    }
	}

	if((fp = fopen(database,"r"))) {
	    i = 0;
	    while(fgets(lang,150,fp) != NULL) {
		if(lang[65] == '[') {
		    lang[65] = 0;
		    f = 1;
		} else
		    f = 0;
		if(strstr(lower(lang),word)) {
		    if(f == 1)
			lang[65] = '[';
		    outs(lang);
		    i++;
		    if(!((i+1)%17)) {
			move(23, 0);
			outs("\033[45m                               "
			     "任意鍵繼續  Q:離開                             "
			     "\033[m ");
			j = igetch();
                        if(j == 'q')
			    break;
                        else {
			    clear();
			    move(4,0);
			    outs(buf);
                        }
		    }
		}
	    }
	}
	fclose(fp);
	if(i == 0) {
	    getdata(5, 0, "沒這個資料耶,新增嗎?(y/N)", lang, 3, LCECHO);
	    if(lang[0] == 'y') {
		clear();
		move(4,0);
		outs(buf);
		addword(word);
	    }
	}
    }
}