/** * Prompt and wait user to press any key. * @param[in] msg The prompt message. * @param[in] x Line number. */ void presskeyfor(const char *msg, int x) { extern int showansi; showansi = 1; screen_move_clear(x); outs(msg); egetch(); screen_move_clear(x); }
/** * Prompt and wait user to press any key. * @param[in] msg The prompt message. * @param[in] x Line number. */ void presskeyfor(const char *msg, int x) { extern int showansi; showansi = 1; move(x, 0); clrtoeol(); outs(msg); egetch(); move(x, 0); clrtoeol(); }
int presskeyfor(char *msg,int x) { extern int showansi; showansi = 1; //saveline(x,0); move(x, 0); clrtoeol(); prints(msg); egetch(); move(x, 0); clrtoeol(); //saveline(x,1); return 0; }
int interrupt_chk() { int key; while (1) { key = egetch(); if (!inrp_by_user) { return; } if (key == Ctrl('C')) { kill(uinfo.pid, SIGINT); return; } } }
void winmine() { int x, y; win_showrec(); clear(); prints("Enable ANSI color?[Y/N]"); refresh(); if (strchr("Nn", egetch())) colorful = 0; while (1) { clear(); for (x = 0; x <= 31; x++) for (y = 0; y <= 17; y++) { a[x][y] = 0; m[x][y] = 0; o[x][y] = 0; } winrefresh(); winloop(); pressanykey(); } }
static int morekey(void) { int ch; while (1) { switch (ch = egetch()) { case 'q': case KEY_LEFT: case EOF: return KEY_LEFT; case ' ': case KEY_RIGHT: case KEY_PGDN: case Ctrl('F'): return KEY_RIGHT; case KEY_PGUP: case Ctrl('B'): return KEY_PGUP; case '\r': case '\n': case KEY_DOWN: case 'j': return KEY_DOWN; case 'k': case KEY_UP: return KEY_UP; case 'h': case 'H': case '?': return 'H'; case 'b': case 'B': case KEY_HOME: return KEY_HOME; case 'e': case 'E': case KEY_END: return KEY_END; case 'l': case 'L': return 'L'; case 'g': case 'G': return 'G'; case 'y': case 'Y': case 'n': case 'N': case 'r': case 'R': case 'c': case 'C': case 'm': case 'M': return toupper(ch); case '*': return ch; default: ; } } }
void winloop() { int x, y, c, marked, t0, inited; char buf[100]; x = 10; y = 8; inited = 0; marked = 0; clearbuf(); t0 = time(0); while (1) { c = egetch(); if (c == 257 && y > 1) y--; if (c == 258 && y < 16) y++; if (c == 260 && x > 1) x--; if (c == 259 && x < 30) x++; move(0, 20); sprintf(buf, "ʱ¼ä: %d ", (int) (time(0) - t0)); prints(buf); move(40, 20); sprintf(buf, "±ê¼Ç: %d ", marked); prints(buf); move(0, 22); sprintf(buf, "×ø±ê: %3d, %3d", x, y); prints(buf); move(x * 2 - 2, y - 1); if (c == 'h' || c == 'H') winhelp(); if (c == 'd' || c == 'D') winrefresh(); if (c == 'a' || c == 'A') { if (!inited) { wininit(x, y); inited = 1; } dig(x, y); } if ((c == 83 || c == 115) && !o[x][y]) { if (m[x][y]) { m[x][y] = 0; marked--; } else { m[x][y] = 1; marked++; } winsh(x, y); } if (checkwin() == 1) { move(0, 22); prints("×£ºØÄ㣡Äã³É¹¦ÁË£¡ "); { char buf[100]; sprintf(buf, "finished in %d s.", (int) (time(0) - t0)); win_checkrec(time(0) - t0); winminelog(buf); } gameover = 0; return; } if (gameover) { move(0, 22); prints("ºÜÒź¶£¬Äãʧ°ÜÁË... ÔÙÀ´Ò»´Î°É£¡ "); { char buf[100]; sprintf(buf, "failed in %d s.", (int) (time(0) - t0)); winminelog(buf); } gameover = 0; return; } move(x * 2 - 2, y - 1); refresh(); } }
int winloop() { int x, y, c, marked, t0, inited; char buf[100]; x= 10; y= 8; inited= 0; marked= 0; clearbuf(); t0= time(0); while(1) { c= egetch(); if((c==257||c=='k')&&y>1) y--; if((c==258||c=='j')&&y<16) y++; if((c==260||c=='h')&&x>1) x--; if((c==259||c=='l')&&x<30) x++; move(0, 20); //% sprintf(buf, "时间: %ld ", time(0)-t0); sprintf(buf, "\xca\xb1\xbc\xe4: %ld ", time(0)-t0); prints(buf); move(40, 20); //% sprintf(buf, "标记: %d ", marked); sprintf(buf, "\xb1\xea\xbc\xc7: %d ", marked); prints(buf); move(0, 21); //% sprintf(buf, "坐标: %3d, %3d", x, y); sprintf(buf, "\xd7\xf8\xb1\xea: %3d, %3d", x, y); prints(buf); move(x*2-2, y-1); if(c=='H') winhelp(); if(c=='d'|| c=='D') winrefresh(); if(c=='f'|| c=='F'){ if(!inited) { wininit(x, y); inited= 1; } dig(x, y); } if((c==83|| c==115)&&!o[x][y]) { if(m[x][y]){ m[x][y]=0; marked--; } else { m[x][y]=1; marked++; } winsh(x, y); } if(checkwin()==1) { move(0, 22); //% prints("祝贺你!你成功了! "); prints("\xd7\xa3\xba\xd8\xc4\xe3\xa3\xa1\xc4\xe3\xb3\xc9\xb9\xa6\xc1\xcb\xa3\xa1 "); { char buf[100]; sprintf(buf, "finished in %ld s.", time(0)-t0); syslog(buf); } gameover= 0; win_checkrec(time(0)-t0);/* added by soff 进行排行检查 */ return; } if(gameover) { move(0, 22); //% prints("很遗憾,你失败了... 再来一次吧! "); prints("\xba\xdc\xd2\xc5\xba\xb6\xa3\xac\xc4\xe3\xca\xa7\xb0\xdc\xc1\xcb... \xd4\xd9\xc0\xb4\xd2\xbb\xb4\xce\xb0\xc9\xa3\xa1 "); { char buf[100]; sprintf(buf, "failed in %ld s.", time(0)-t0); syslog(buf); } gameover= 0; return; } move(x*2-2, y-1); refresh(); } }
static FILE *alsaSelectPcmOut(struct modlistentry *entry) { char *t; int card, device; if (!strcmp(entry->name, "default.dev")) { strcpy(alsaCardName, "default"); } else if (!strcmp(entry->name, "custom.dev")) { int mlTop=mlDrawBox(); char str[DEVICE_NAME_MAX+1]; unsigned int curpos; unsigned int cmdlen; int insmode=1; unsigned int scrolled=0; strcpy(str, alsaCardName); displaystr(mlTop+1, 5, 0x0b, "Give me something to crunch!!", 29); displaystr(mlTop+3, 5, 0x0b, "-- Finish with enter, abort with escape --", 32); curpos=strlen(str); cmdlen=strlen(str); setcurshape(1); while (1) { uint16_t key; displaystr(mlTop+2, 5, 0x8f, str+scrolled, plScrWidth-10); setcur(mlTop+2, 5+curpos-scrolled); while (!ekbhit()) framelock(); key=egetch(); if ((key>=0x20)&&(key<=0x7f)) { if (insmode) { if ((cmdlen+1)<sizeof(str)) { memmove(str+curpos+1, str+curpos, cmdlen-curpos+1); str[curpos++]=key; cmdlen++; } } else if (curpos==cmdlen) { if ((cmdlen+1)<(sizeof(str))) { str[curpos++]=key; str[curpos]=0; cmdlen++; } } else str[curpos++]=key; } else switch (key) { case KEY_ESC: setcurshape(0); return NULL; case KEY_LEFT: if (curpos) curpos--; break; case KEY_RIGHT: if (curpos<cmdlen) curpos++; break; case KEY_HOME: curpos=0; break; case KEY_END: curpos=cmdlen; break; case KEY_INSERT: { insmode=!insmode; setcurshape(insmode?1:2); } break; case KEY_DELETE: if (curpos!=cmdlen) { memmove(str+curpos, str+curpos+1, cmdlen-curpos); cmdlen--; } break; case KEY_BACKSPACE: if (curpos) { memmove(str+curpos-1, str+curpos, cmdlen-curpos+1); curpos--; cmdlen--; } break; case _KEY_ENTER: strcpy(alsaCardName, str); setcurshape(0); goto out; } while ((curpos-scrolled)>=(plScrWidth-10)) scrolled+=8; while (((signed)curpos-(signed)scrolled)<0) scrolled-=8; } } else { if (!(t=strchr(entry->name, ':'))) return NULL; card=atoi(t+1); if (!(t=strchr(entry->name, ','))) return NULL; device=atoi(t+1); snprintf(alsaCardName, sizeof(alsaCardName), "plughw:%d,%d", card, device); snprintf(alsaMixerName, sizeof(alsaMixerName), "hw:%d", card); } out: /* #ifdef ALSA_DEBUG */ fprintf(stderr, "ALSA: Selected card %s\n", alsaCardName); /* #endif */ { if (customfileref!=0xffffffff) { struct moduleinfostruct mi; mdbGetModuleInfo(&mi, customfileref); snprintf(mi.modname, sizeof(mi.modname), "%s", alsaCardName); mdbWriteModuleInfo(customfileref, &mi); } } return NULL; }
void cpiKeyHelpDisplay(void) { unsigned int i, j, offset=0; unsigned char cola, colb; if (!keymapping_n) return; while (1) { if ((plScrMode==100)||(plScrMode==101)||(plScrMode==13)) gDrawBox(); else DrawBox(); for (j=0; j<(keymapping_n-offset); j++) { const char *s="unknown key"; if (j>=height) break; for (i=0; i<(sizeof(KeyNames)/sizeof(struct cpiKeyHelpKeyName)); i++) { if (KeyNames[i].key==keymapping[j+offset].key) { s=KeyNames[i].name; break; } } if (validkey(KeyNames[i].key)) { cola=0x0f; colb=0x0a; } else { cola=0x01; colb=0x01; } if ((plScrMode==100)||(plScrMode==101)||(plScrMode==13)) { gdrawstr(j+top, left, s, 16, colb, 0x00); gdrawstr(j+top, left+16, keymapping[j+offset].name, width-16, cola, 0x00); } else { displaystr(j+top, left, colb, s, 16); displaystr(j+top, left+16, cola, keymapping[j+offset].name, width-16); } } if ((plScrMode==100)||(plScrMode==101)||(plScrMode==13)) for (; j<height; j++) gdrawstr(j+top, left, "", width, 0x00, 0x00); while (!ekbhit()) framelock(); switch (egetch()) { case KEY_PPAGE: case KEY_UP: if (offset) offset--; break; case ' ': case KEY_NPAGE: case KEY_DOWN: if ((keymapping_n-offset)>height) offset++; break; case KEY_ESC: case KEY_ALT_K: keymapping_n=0; cpiKeyHelpReset(); return; } } }
int pip_results_show() /*收获季*/ { //% char *showname[5]={" ","武斗大会","艺术大展","皇家舞会","烹饪大赛"}; char *showname[5]={" ","\xce\xe4\xb6\xb7\xb4\xf3\xbb\xe1","\xd2\xd5\xca\xf5\xb4\xf3\xd5\xb9","\xbb\xca\xbc\xd2\xce\xe8\xbb\xe1","\xc5\xeb\xe2\xbf\xb4\xf3\xc8\xfc"}; char buf[256]; int pipkey,i=0; int winorlost=0; int a,b[3][2],c[3]; screen_clear(); move(10,14); //% prints("[1;33m叮咚叮咚~ 辛苦的邮差帮我们送信来了喔...[0m"); prints("[1;33m\xb6\xa3\xdf\xcb\xb6\xa3\xdf\xcb\xa1\xab \xd0\xc1\xbf\xe0\xb5\xc4\xd3\xca\xb2\xee\xb0\xef\xce\xd2\xc3\xc7\xcb\xcd\xd0\xc5\xc0\xb4\xc1\xcb\xe0\xb8...[0m"); //% pressanykey("嗯 把信打开看看吧..."); pressanykey("\xe0\xc5 \xb0\xd1\xd0\xc5\xb4\xf2\xbf\xaa\xbf\xb4\xbf\xb4\xb0\xc9..."); screen_clear(); show_resultshow_pic(0); //% sprintf(buf,"[A]%s [B]%s [C]%s [D]%s [Q]放弃:",showname[1],showname[2],showname[3],showname[4]); sprintf(buf,"[A]%s [B]%s [C]%s [D]%s [Q]\xb7\xc5\xc6\xfa:",showname[1],showname[2],showname[3],showname[4]); move(b_lines,0); prints(buf); do { pipkey=egetch(); } while(pipkey!='q' && pipkey!='Q' && pipkey!='A' && pipkey!='a' && pipkey!='B' && pipkey!='b' && pipkey!='C' && pipkey!='c'&& pipkey!='D' && pipkey!='d'); a=rand()%4+1; b[0][0]=a-1; b[1][0]=a+1; b[2][0]=a; switch(pipkey) { case 'A': case 'a': //% pressanykey("今年共有四人参赛~现在比赛开始"); pressanykey("\xbd\xf1\xc4\xea\xb9\xb2\xd3\xd0\xcb\xc4\xc8\xcb\xb2\xce\xc8\xfc\xa1\xab\xcf\xd6\xd4\xda\xb1\xc8\xc8\xfc\xbf\xaa\xca\xbc"); for(i=0;i<3;i++) { a=0; b[i][1]=0; //% sprintf(buf,"你的第%d个对手是%s",i+1,resultmanlist[b[i][0]].name); sprintf(buf,"\xc4\xe3\xb5\xc4\xb5\xda%d\xb8\xf6\xb6\xd4\xca\xd6\xca\xc7%s",i+1,resultmanlist[b[i][0]].name); pressanykey(buf); a=pip_vs_man(b[i][0],resultmanlist,2); if(a==1) b[i][1]=1;/*对方输了*/ winorlost+=a; d.death=0; } switch(winorlost) { case 3: pip_results_show_ending(3,1,b[1][0],b[0][0],b[2][0]); d.hexp+=rand()%10+50; break; case 2: if(b[0][1]!=1) { c[0]=b[0][0]; c[1]=b[1][0]; c[2]=b[2][0]; } else if(b[1][1]!=1) { c[0]=b[1][0]; c[1]=b[2][0]; c[2]=b[0][0]; } else if(b[2][1]!=1) { c[0]=b[2][0]; c[1]=b[0][0]; c[2]=b[1][0]; } pip_results_show_ending(2,1,c[0],c[1],c[2]); d.hexp+=rand()%10+30; break; case 1: if(b[0][1]==1) { c[0]=b[2][0]; c[1]=b[1][0]; c[2]=b[0][0]; } else if(b[1][1]==1) { c[0]=b[0][0]; c[1]=b[2][0]; c[2]=b[1][0]; } else if(b[2][1]==1) { c[0]=b[1][0]; c[1]=b[0][0]; c[2]=b[2][0]; } pip_results_show_ending(1,1,c[0],c[1],c[2]); d.hexp+=rand()%10+10; break; case 0: pip_results_show_ending(0,1,b[0][0],b[1][0],b[2][0]); d.hexp-=rand()%10+10; break; } break; case 'B': case 'b': //% pressanykey("今年共有四人参赛~现在比赛开始"); pressanykey("\xbd\xf1\xc4\xea\xb9\xb2\xd3\xd0\xcb\xc4\xc8\xcb\xb2\xce\xc8\xfc\xa1\xab\xcf\xd6\xd4\xda\xb1\xc8\xc8\xfc\xbf\xaa\xca\xbc"); show_resultshow_pic(21); //% pressanykey("比赛情形"); pressanykey("\xb1\xc8\xc8\xfc\xc7\xe9\xd0\xce"); if((d.art*2+d.character)/400>=5) { winorlost=3; } else if((d.art*2+d.character)/400>=4) { winorlost=2; } else if((d.art*2+d.character)/400>=3) { winorlost=1; } else { winorlost=0; } pip_results_show_ending(winorlost,2,rand()%2,rand()%2+2,rand()%2+4); d.art+=rand()%10+20*winorlost; d.character+=rand()%10+20*winorlost; break; case 'C': case 'c': //% pressanykey("今年共有四人参赛~现在比赛开始"); pressanykey("\xbd\xf1\xc4\xea\xb9\xb2\xd3\xd0\xcb\xc4\xc8\xcb\xb2\xce\xc8\xfc\xa1\xab\xcf\xd6\xd4\xda\xb1\xc8\xc8\xfc\xbf\xaa\xca\xbc"); if((d.art*2+d.charm)/400>=5) { winorlost=3; } else if((d.art*2+d.charm)/400>=4) { winorlost=2; } else if((d.art*2+d.charm)/400>=3) { winorlost=1; } else { winorlost=0; } d.art+=rand()%10+20*winorlost; d.charm+=rand()%10+20*winorlost; pip_results_show_ending(winorlost,3,rand()%2,rand()%2+4,rand()%2+2); break; case 'D': case 'd': //% pressanykey("今年共有四人参赛~现在比赛开始"); pressanykey("\xbd\xf1\xc4\xea\xb9\xb2\xd3\xd0\xcb\xc4\xc8\xcb\xb2\xce\xc8\xfc\xa1\xab\xcf\xd6\xd4\xda\xb1\xc8\xc8\xfc\xbf\xaa\xca\xbc"); if((d.affect+d.cookskill*2)/200>=4) { winorlost=3; } else if((d.affect+d.cookskill*2)/200>=3) { winorlost=2; } else if((d.affect+d.cookskill*2)/200>=2) { winorlost=1; } else { winorlost=0; } d.cookskill+=rand()%10+20*winorlost; d.family+=rand()%10+20*winorlost; pip_results_show_ending(winorlost,4,rand()%2+2,rand()%2,rand()%2+4); break; case 'Q': case 'q': //% pressanykey("今年不参加啦.....:("); pressanykey("\xbd\xf1\xc4\xea\xb2\xbb\xb2\xce\xbc\xd3\xc0\xb2.....:("); d.happy-=rand()%10+10; d.satisfy-=rand()%10+10; d.relation-=rand()%10; break; } if(pipkey!='Q' && pipkey!='q') { d.tired=0; d.hp=d.maxhp; d.happy+=rand()%20; d.satisfy+=rand()%20; d.relation+=rand()%10; } 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; }
static int search_board(const choose_board_t *cbrd, int *num) { static int i = 0, find = YEA; static char bname[STRLEN]; int n, ch, tmpn = NA; if (find == YEA) { bzero(bname, sizeof (bname)); find = NA; i = 0; } while (1) { move(t_lines - 1, 0); clrtoeol(); prints("请输入要查找的版面名称:%s", bname); ch = egetch(); if (isprint2(ch)) { bname[i++] = ch; for (n = 0; n < cbrd->num; n++) { if (!strncasecmp(cbrd->brds[n].name, bname, i)) { tmpn = YEA; *num = n; if (!strcmp(cbrd->brds[n].name, bname)) return 1 /* 找到类似的版,画面重画 */; } } if (tmpn) return 1; if (find == NA) { bname[--i] = '\0'; } continue; } else if (ch == Ctrl('H') || ch == KEY_LEFT || ch == KEY_DEL || ch == '\177') { i--; if (i < 0) { find = YEA; break; } else { bname[i] = '\0'; continue; } } else if (ch == '\t') { find = YEA; break; } else if (ch == '\n' || ch == '\r' || ch == KEY_RIGHT) { find = YEA; break; } bell(1); } if (find) { move(t_lines - 1, 0); clrtoeol(); return 2 /* 结束了 */; } return 1; }
int pip_basic_feed() /* Òûʳ*/ { time_t now; char inbuf[80]; char genbuf[200]; char buf[256]; long smoney; int pipkey; d.nodone=1; do { if(d.death==1 || d.death==2 || d.death==3) return 0; if(pip_mainmenu(1)) return 0; move(b_lines-2, 0); clrtoeol(); move(b_lines-2, 1); sprintf(buf,"%s¸Ã×öʲ÷áÊÂÄØ?",d.name); prints(buf); now=time(0); move(b_lines, 0); clrtoeol(); move(b_lines, 0); prints("[1;44;37m Òûʳѡµ¥ [46m[1]³Ô·¹ [2]Áãʳ [3]²¹Íè [4]ÁéÖ¥ [5]È˲Π[6]Ñ©Á« [Q]Ìø³ö£º [m"); pip_time_change(now); pipkey=egetch(); pip_time_change(now); switch(pipkey) { case '1': if(d.food<=0) { move(b_lines,0); pressanykey("ûÓÐʳÎïÂÞ..¿ìÈ¥Âò°É£¡"); break; } move(4,0); if((d.bbtime/60/30)<3) show_feed_pic(0); else show_feed_pic(1); d.food--; d.hp+=50; if(d.hp >=d.maxhp) { d.hp=d.maxhp; d.weight+=rand()%2; } d.nodone=0; pressanykey("ÿ³ÔÒ»´ÎʳÎï»á»Ö¸´ÌåÁ¦50à¸!"); break; case '2': if(d.cookie<=0) { move(b_lines,0); pressanykey("Áãʳ³Ô¹âÂÞ..¿ìÈ¥Âò°É£¡"); break; } move(4,0); d.cookie--; d.hp+=100; if(d.hp >=d.maxhp) { d.hp=d.maxhp; d.weight+=(rand()%2+2); } else { d.weight+=(rand()%2+1); } if(rand()%2>0) show_feed_pic(2); else show_feed_pic(3); d.happy+=(rand()%3+4); d.satisfy+=rand()%3+2; d.nodone=0; pressanykey("³ÔÁãʳÈÝÒ×ÅÖà¸..."); break; case '3': if(d.bighp<=0) { move(b_lines,0); pressanykey("ûÓдó²¹ÍèÁËÒ®! ¿ìÂò°É.."); break; } d.bighp--; d.hp+=600; d.tired-=20; d.weight+=rand()%2; move(4,0); show_feed_pic(4); d.nodone=0; pressanykey("²¹Íè..³¬¼«°ôµÄà¡..."); break; case '4': if(d.medicine<=0) { move(b_lines,0); pressanykey("ûÓÐÁéÖ¥ÂÞ..¿ìÈ¥Âò°É£¡"); break; } move(4,0); show_feed_pic(1); d.medicine--; d.mp+=50; if(d.mp >=d.maxmp) { d.mp=d.maxmp; } d.nodone=0; pressanykey("ÿ³ÔÒ»´ÎÁéÖ¥»á»Ö¸´·¨Á¦50à¸!"); break; case '5': if(d.ginseng<=0) { move(b_lines,0); pressanykey("ûÓÐǧÄêÈ˲ÎÒ®! ¿ìÂò°É.."); break; } d.ginseng--; d.mp+=500; d.tired-=20; move(4,0); show_feed_pic(1); d.nodone=0; pressanykey("ǧÄêÈË ..³¬¼«°ôµÄà¡..."); break; case '6': if(d.snowgrass<=0) { move(b_lines,0); pressanykey("ûÓÐÌìɽѩÁ«Ò®! ¿ìÂò°É.."); break; } d.snowgrass--; d.mp=d.maxmp; d.hp=d.maxhp; d.tired-=0; d.sick=0; move(4,0); show_feed_pic(1); d.nodone=0; pressanykey("ÌìɽѩÁ«..³¬¼«°ôµÄà¡..."); break; #ifdef MAPLE case Ctrl('R'): if (currutmp->msgs[0].last_pid) { show_last_call_in(); my_write(currutmp->msgs[0].last_pid, "Ë®Çò¶ª»ØÈ¥£º"); } d.nodone=0; break; #endif // END MAPLE } }while((pipkey!='Q')&&(pipkey!='q')&&(pipkey!=KEY_LEFT)); return 0; }