Exemple #1
0
static void 
write_request()
{
	time_t		now;
	/* Half-hour remind  */
	if (*currmsg) {
		outmsg(currmsg);
		bell();
		*currmsg = 0;
		return;
	}
	time(&now);

#ifdef  LINUX
	signal(SIGUSR2, write_request);
#endif

	update_data();
	++cuser.receivemsg;
	substitute_record(fn_passwd, &cuser, sizeof(userec), usernum);
	bell();
	show_last_call_in();
	/* wildcat patch : 看不到水球??!! */
	currutmp->msgcount--;
	memcpy(&oldmsg[no_oldmsg], &currutmp->msgs[0], sizeof(msgque));
	no_oldmsg++;
	no_oldmsg %= MAX_REVIEW;
	if (oldmsg_count < MAX_REVIEW)
		oldmsg_count++;
	if (watermode) {
		if (watermode < oldmsg_count)
			watermode++;
		t_display_new(0);
	}
	refresh();
	currutmp->msgcount = 0;
}
Exemple #2
0
int
pip_basic_feed()
{				/* Òûʳ */
	time_t now;
	char buf[256];
	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
		    ("\033[1;44;37m  Òûʳѡµ¥  \033[46m[1]³Ô·¹ [2]Áãʳ [3]²¹Íè [4]ÁéÖ¥ [5]È˲Π[6]Ñ©Á« [Q]Ìø³ö£º         \033[m");
		pip_time_change(now);
		pipkey = igetkey();
		pip_time_change(now);

		switch (pipkey) {
		case '1':
			if (d.food <= 0) {
				move(b_lines, 0);
				temppress("ûÓÐʳÎïÂÞ..¿ìÈ¥Âò°É£¡");
				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;
			temppress("ÿ³ÔÒ»´ÎʳÎï»á»Ö¸´ÌåÁ¦50à¸!");
			break;

		case '2':
			if (d.cookie <= 0) {
				move(b_lines, 0);
				temppress("Áãʳ³Ô¹âÂÞ..¿ìÈ¥Âò°É£¡");
				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;
			temppress("³ÔÁãʳÈÝÒ×ÅÖà¸...");
			break;

		case '3':
			if (d.bighp <= 0) {
				move(b_lines, 0);
				temppress("ûÓдó²¹ÍèÁËÒ®! ¿ìÂò°É..");
				break;
			}
			d.bighp--;
			d.hp += 600;
			d.tired -= 20;
			d.weight += rand() % 2;
			move(4, 0);
			show_feed_pic(4);
			d.nodone = 0;
			temppress("²¹Íè..³¬¼«°ôµÄà¡...");
			break;

		case '4':
			if (d.medicine <= 0) {
				move(b_lines, 0);
				temppress("ûÓÐÁéÖ¥ÂÞ..¿ìÈ¥Âò°É£¡");
				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;
			temppress("ÿ³ÔÒ»´ÎÁéÖ¥»á»Ö¸´·¨Á¦50à¸!");
			break;

		case '5':
			if (d.ginseng <= 0) {
				move(b_lines, 0);
				temppress("ûÓÐǧÄêÈ˲ÎÒ®! ¿ìÂò°É..");
				break;
			}
			d.ginseng--;
			d.mp += 500;
			d.tired -= 20;
			move(4, 0);
			show_feed_pic(1);
			d.nodone = 0;
			temppress("ǧÄêÈ˲Î..³¬¼«°ôµÄà¡...");
			break;

		case '6':
			if (d.snowgrass <= 0) {
				move(b_lines, 0);
				temppress("ûÓÐÌìɽѩÁ«Ò®! ¿ìÂò°É..");
				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;
			temppress("ÌìɽѩÁ«..³¬¼«°ôµÄà¡...");
			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;
}
Exemple #3
0
int
pip_data_list()
{    /*看小鸡个人详细资料 */
    char buf[256];
    char inbuf1[20];
    char inbuf2[20];
    int tm;
    int pipkey;
    int page = 1;

    tm = (time(0) - start_time + d.bbtime) / 60 / 30;

    clear();
    move(1, 0);
    prints("       \033[1;33m┏━━━    ━━━  ┏━━━┓  ━━━  \033[m\n");
    prints("       \033[0;37m┃      ┃┃ ━   ┃┗┓┏━┛┃ ━   ┃\033[m\n");
    prints("       \033[1;37m┃      ┃┃┏┓  ┃  ┃┃    ┃┏┓  ┃\033[m\n");
    prints
    ("       \033[1;34m┗━━━  ┗┛┗━┛  ┗┛    ┗┛┗━┛\033[32m......................\033[m");
    do {
        clrchyiuan(5, 23);
        switch (page) {
            case 1:
                move(5, 0);
                sprintf(buf,
                        "\033[1;31m ┌┤\033[41;37m 基本资料 \033[0;1;31m├—————————————————————————————┐\033[m\n");
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#姓    名 :\033[37m %-10s \033[33m#生    日 :\033[37m %02d/%02d/%02d   \033[33m#年    纪 :\033[37m %-2d         \033[31m│\033[m\n",
                        d.name, d.year % 100, d.month, d.day, tm);
                prints(buf);

                sprintf(inbuf1, "%d/%d", d.hp, d.maxhp);
                sprintf(inbuf2, "%d/%d", d.mp, d.maxmp);
                sprintf(buf,
                        "\033[1;31m │\033[33m#体    重 :\033[37m %-5d(米克)\033[33m#体    力 :\033[37m %-11s\033[33m#法    力 :\033[37m %-11s\033[31m│\033[m\n",
                        d.weight, inbuf1, inbuf2);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#疲    劳 :\033[37m %-3d        \033[33m#病    气 :\033[37m %-3d        \033[33m#脏    脏 :\033[37m %-3d        \033[31m│\033[m\n",
                        d.tired, d.sick, d.shit);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#腕    力 :\033[37m %-7d    \033[33m#亲子关系 :\033[37m %-7d    \033[33m#金    钱 :\033[37m %-11d\033[31m│\033[m\n",
                        d.wrist, d.relation, d.money);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m ├┤\033[41;37m 能力资料 \033[0;1;31m├—————————————————————————————┤\033[m\n");
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#气    质 :\033[37m %-10d \033[33m#智    力 :\033[37m %-10d \033[33m#爱    心 :\033[37m %-10d \033[31m│\033[m\n",
                        d.character, d.wisdom, d.love);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#艺    术 :\033[37m %-10d \033[33m#道    德 :\033[37m %-10d \033[33m#家    事 :\033[37m %-10d \033[31m│\033[m\n",
                        d.art, d.etchics, d.homework);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#礼    仪 :\033[37m %-10d \033[33m#应    对 :\033[37m %-10d \033[33m#烹    饪 :\033[37m %-10d \033[31m│\033[m\n",
                        d.manners, d.speech, d.cookskill);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m ├┤\033[41;37m 状态资料 \033[0;1;31m├—————————————————————————————┤\033[m\n");
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#快    乐 :\033[37m %-10d \033[33m#满    意 :\033[37m %-10d \033[33m#人    际 :\033[37m %-10d \033[31m│\033[m\n",
                        d.happy, d.satisfy, d.toman);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#魅    力 :\033[37m %-10d \033[33m#勇    敢 :\033[37m %-10d \033[33m#信    仰 :\033[37m %-10d \033[31m│\033[m\n",
                        d.charm, d.brave, d.belief);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#罪    孽 :\033[37m %-10d \033[33m#感    受 :\033[37m %-10d \033[33m            \033[37m            \033[31m│\033[m\n",
                        d.offense, d.affect);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m ├┤\033[41;37m 评价资料 \033[0;1;31m├—————————————————————————————┤\033[m\n");
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#社交评价 :\033[37m %-10d \033[33m#战斗评价 :\033[37m %-10d \033[33m#魔法评价 :\033[37m %-10d \033[31m│\033[m\n",
                        d.social, d.hexp, d.mexp);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#家事评价 :\033[37m %-10d \033[33m            \033[37m            \033[33m            \033[37m            \033[31m│\033[m\n",
                        d.family);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m └————————————————————————————————————┘\033[m\n");
                prints(buf);

                move(b_lines - 1, 0);
                sprintf(buf,
                        "                                                              \033[1;36m第一页\033[37m/\033[36m共二页\033[m\n");
                prints(buf);
                break;

            case 2:
                move(5, 0);
                sprintf(buf,
                        "\033[1;31m ┌┤\033[41;37m 物品资料 \033[0;1;31m├—————————————————————————————┐\033[m\n");
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#食    物 :\033[37m %-10d \033[33m#零    食 :\033[37m %-10d \033[33m#大 补 丸 :\033[37m %-10d \033[31m│\033[m\n",
                        d.food, d.cookie, d.bighp);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#药    草 :\033[37m %-10d \033[33m#书    本 :\033[37m %-10d \033[33m#玩    具 :\033[37m %-10d \033[31m│\033[m\n",
                        d.medicine, d.book, d.playtool);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m ├┤\033[41;37m 游戏资料 \033[0;1;31m├—————————————————————————————┤\033[m\n");
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#猜 拳 赢 :\033[37m %-10d \033[33m#猜 拳 输 :\033[37m %-10d                         \033[31m│\033[m\n",
                        d.winn, d.losee);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m ├┤\033[41;37m 武力资料 \033[0;1;31m├—————————————————————————————┤\033[m\n");
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#攻 击 力 :\033[37m %-10d \033[33m#防 御 力 :\033[37m %-10d \033[33m#速 度 值 :\033[37m %-10d \033[31m│\033[m\n",
                        d.attack, d.resist, d.speed);
                prints(buf);
                sprintf(buf,
                        "\033[1;31m │\033[33m#抗魔能力 :\033[37m %-10d \033[33m#战斗技术 :\033[37m %-10d \033[33m#魔法技术 :\033[37m %-10d \033[31m│\033[m\n",
                        d.mresist, d.hskill, d.mskill);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#头部装备 :\033[37m %-10s \033[33m#右手装备 :\033[37m %-10s \033[33m#左手装备 :\033[37m %-10s \033[31m│\033[m\n",
                        weaponhead[d.weaponhead],
                        weaponrhand[d.weaponrhand],
                        weaponlhand[d.weaponlhand]);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m │\033[33m#身体装备 :\033[37m %-10s \033[33m#脚部装备 :\033[37m %-10s \033[33m            \033[37m            \033[31m│\033[m\n",
                        weaponbody[d.weaponbody],
                        weaponfoot[d.weaponfoot]);
                prints(buf);

                sprintf(buf,
                        "\033[1;31m └————————————————————————————————————┘\033[m\n");
                prints(buf);

                move(b_lines - 1, 0);
                sprintf(buf,
                        "                                                              \033[1;36m第二页\033[37m/\033[36m共二页\033[m\n");
                prints(buf);
                break;
        }
        move(b_lines, 0);
        sprintf(buf,
                "\033[1;44;37m  资料选单  \033[46m  [↑/PAGE UP]往上一页 [↓/PAGE DOWN]往下一页 [Q]离开:            \033[m");
        prints(buf);
        pipkey = igetkey();
        switch (pipkey) {
            case KEY_UP:
            case KEY_PGUP:
            case KEY_DOWN:
            case KEY_PGDN:
                if (page == 1)
                    page = 2;
                else if (page == 2)
                    page = 1;
                break;
#ifdef MAPLE
            case Ctrl('R'):
                if (currutmp->msgs[0].last_pid) {
                    show_last_call_in();
                    my_write(currutmp->msgs[0].last_pid,
                             "水球丢回去:");
                }
                break;
#endif    // END MAPLE
        }
    } while ((pipkey != 'Q') && (pipkey != 'q') && (pipkey != KEY_LEFT));
    return 0;
}
Exemple #4
0
static void write_request(int sig) {
    struct tm *ptime;
    time_t now;
    extern char watermode;
    
    time(&now);
    ptime = localtime(&now);
    
    if(currutmp->pager != 0 &&
       cuser.userlevel != 0 &&
       currutmp->msgcount != 0 &&
       currutmp->mode != TALK &&
       currutmp->mode != EDITING &&
       currutmp->mode != CHATING &&
       currutmp->mode != PAGE &&
       currutmp->mode != IDLE &&
       currutmp->mode != MAILALL &&
       currutmp->mode != MONITOR) {
	int i;
	char c0 = currutmp->chatid[0];
	int currstat0 = currstat;
	unsigned char mode0 = currutmp->mode;
	
	currutmp->mode = 0;
	currutmp->chatid[0] = 2;
	currstat = XMODE;
	
	do {
	    bell();
	    show_last_call_in(1);
	    igetch();
	    currutmp->msgcount--;
	    if(currutmp->msgcount>=MAX_MSGS)
	    {
		/* this causes chaos... jochang */
		raise(SIGFPE);
	    }
	    memcpy(&oldmsg[(int)no_oldmsg],
		   &currutmp->msgs[0], sizeof(msgque_t));
	    no_oldmsg++;
	    no_oldmsg %= MAX_REVIEW;
	    if(oldmsg_count < MAX_REVIEW)
		oldmsg_count++;
	    
	    for(i = 0; i < currutmp->msgcount; i++)
		currutmp->msgs[i] = currutmp->msgs[i + 1];
	} while(currutmp->msgcount);
	currutmp->chatid[0] = c0;
	currutmp->mode = mode0;
	currstat = currstat0;
    } else {
	bell();
	show_last_call_in(1);
	memcpy(&oldmsg[(int)no_oldmsg], &currutmp->msgs[0], sizeof(msgque_t));
	no_oldmsg++;
	no_oldmsg %= MAX_REVIEW;
	if(oldmsg_count < MAX_REVIEW)
	    oldmsg_count++;
	if(watermode > 0) {
	    if(watermode < oldmsg_count)
		watermode++;
	    t_display_new();
	}
	refresh();
	currutmp->msgcount = 0;
    }
}
Exemple #5
0
int
pip_play_guess()
{    /* 猜拳程式 */
    int com;
    int pipkey;
    struct tm *qtime;
    time_t now;

    time(&now);
    qtime = localtime(&now);
    d.satisfy += (rand() % 3 + 2);
    count_tired(2, 2, "Y", 100, 1);
    d.shit += rand() % 3 + 2;
    do {
        if (d.death == 1 || d.death == 2 || d.death == 3)
            return 0;
        if (pip_mainmenu(0))
            return 0;
        move(b_lines - 2, 0);
        clrtoeol();
        move(b_lines, 0);
        clrtoeol();
        move(b_lines, 0);
        prints
        ("\033[1;44;37m  猜拳选单  \033[46m[1]我出剪刀 [2]我出石头 [3]我出布啦 [4]猜拳记录 [Q]跳出:         \033[m");
        move(b_lines - 1, 0);
        clrtoeol();
        pipkey = igetkey();
        switch (pipkey) {
#ifdef MAPLE
            case Ctrl('R'):
                if (currutmp->msgs[0].last_pid) {
                    show_last_call_in();
                    my_write(currutmp->msgs[0].last_pid,
                             "水球丢回去:");
                }
                break;
#endif    // END MAPLE
            case '4':
                situ();
                break;
        }
    } while ((pipkey != '1') && (pipkey != '2') && (pipkey != '3')
             && (pipkey != 'q') && (pipkey != 'Q'));

    com = rand() % 3;
    move(18, 0);
    clrtobot();
    switch (com) {
        case 0:
            outs("小鸡:剪刀\n");
            break;
        case 1:
            outs("小鸡:石头\n");
            break;
        case 2:
            outs("小鸡:布\n");
            break;
    }

    move(17, 0);

    switch (pipkey) {
        case '1':
            outs("你  :剪刀\n");
            if (com == 0)
                tie();
            else if (com == 1)
                lose();
            else if (com == 2)
                win();
            break;
        case '2':
            outs("你 :石头\n");
            if (com == 0)
                win();
            else if (com == 1)
                tie();
            else if (com == 2)
                lose();
            break;
        case '3':
            outs("你 :布\n");
            if (com == 0)
                lose();
            else if (com == 1)
                win();
            else if (com == 2)
                tie();
            break;
        case 'q':
            break;
    }
    return 0;
}
Exemple #6
0
int pip_weapon_doing_menu(int variance,int type,const struct weapon *p)
{
    time_t now;
    register int n = 0;
    register char *s;
    char buf[256];
    char ans[5];
    char shortbuf[100];
    const static char menutitle[5][11] = { "头部装备区", "右手装备区", "左手装备区", "身体装备区",
                                           "足部装备区"
                                         };
    int pipkey;
    char choicekey[5];
    int choice;

    do {
        clear();
        showtitle(menutitle[type], BBS_FULL_NAME);
        show_weapon_pic(0);
        /*   move(10,2);
           sprintf(buf,"\033[1;37m现今能力:体力Max:\033[36m%-5d\033[37m  法力Max:\033[36m%-5d\033[37m  攻击:\033[36m%-5d\033[37m  防御:\033[36m%-5d\033[37m  速度:\033[36m%-5d \033[m",
                   d.maxhp,d.maxmp,d.attack,d.resist,d.speed);
           prints(buf);*/
        move(11, 2);
        sprintf(buf,
                "\033[1;37;41m [NO]  [器具名]  [体力]  [法力]  [速度]  [攻击]  [防御]  [速度]  [售  价] \033[m");
        prints(buf);
        move(12, 2);
        sprintf(buf,
                " \033[1;31m——\033[37m白色 可以购买\033[31m——\033[32m绿色 拥有装备\033[31m——\033[33m黄色 钱钱不够\033[31m——\033[35m紫色 能力不足\033[31m——\033[m");
        prints(buf);

        n = 0;
        while ((s = p[n].name)!=0) {
            move(13 + n, 2);
            if (variance != 0 && variance == (n)) { /*本身有的 */
                sprintf(buf,
                        "\033[1;32m (%2d)  %-10s %4d    %4d    %4d    %4d    %4d    %4d    %6d\033[m",
                        n, p[n].name, p[n].needmaxhp,
                        p[n].needmaxmp, p[n].needspeed,
                        p[n].attack, p[n].resist, p[n].speed,
                        p[n].cost);
            } else if (d.maxhp < p[n].needmaxhp || d.maxmp < p[n].needmaxmp || d.speed < p[n].needspeed) { /*能力不足 */
                sprintf(buf,
                        "\033[1;35m (%2d)  %-10s %4d    %4d    %4d    %4d    %4d    %4d    %6d\033[m",
                        n, p[n].name, p[n].needmaxhp,
                        p[n].needmaxmp, p[n].needspeed,
                        p[n].attack, p[n].resist, p[n].speed,
                        p[n].cost);
            }

            else if (d.money < p[n].cost) { /*钱不够的 */
                sprintf(buf,
                        "\033[1;33m (%2d)  %-10s %4d    %4d    %4d    %4d    %4d    %4d    %6d\033[m",
                        n, p[n].name, p[n].needmaxhp,
                        p[n].needmaxmp, p[n].needspeed,
                        p[n].attack, p[n].resist, p[n].speed,
                        p[n].cost);
            } else {
                sprintf(buf,
                        "\033[1;37m (%2d)  %-10s %4d    %4d    %4d    %4d    %4d    %4d    %6d\033[m",
                        n, p[n].name, p[n].needmaxhp,
                        p[n].needmaxmp, p[n].needspeed,
                        p[n].attack, p[n].resist, p[n].speed,
                        p[n].cost);
            }
            prints(buf);
            n++;
        }
        move(b_lines, 0);
        sprintf(buf,
                "\033[1;44;37m  武器购买选单  \033[46m  [B]购买武器  [S]卖掉装备  [W]个人资料  [Q]跳出:            \033[m");
        prints(buf);
        now = time(0);
        pip_time_change(now);
        pipkey = igetkey();
        pip_time_change(now);

        switch (pipkey) {
            case 'B':
            case 'b':
                move(b_lines - 1, 1);
                sprintf(shortbuf, "想要购买啥呢? 你的钱钱[%d]元:[数字]",
                        d.money);
                prints(shortbuf);
#ifdef MAPLE
                getdata(b_lines - 1, 1, shortbuf, choicekey, 4, LCECHO,
                        "0");
#else
                getdata(b_lines-1,1,shortbuf,choicekey,4,DOECHO,NULL,true);
                if ((choicekey[0] >= 'A') && (choicekey[0] <= 'Z'))
                    choicekey[0] = choicekey[0] | 32;
#endif    // END MAPLE
                choice = atoi(choicekey);
                if (choice >= 0 && choice <= n) {
                    move(b_lines - 1, 0);
                    clrtoeol();
                    move(b_lines - 1, 1);
                    if (choice == 0) { /*解除 */
                        sprintf(shortbuf, "放弃购买...");
                        temppress(shortbuf);
                    }

                    else if (variance == choice) { /*早已经有啦 */
                        sprintf(shortbuf, "你早已经有 %s 罗",
                                p[variance].name);
                        temppress(shortbuf);
                    }

                    else if (p[choice].cost >= (d.money + p[variance].sell)) { /*钱不够 */
                        sprintf(shortbuf,
                                "这个要 %d 元,你的钱不够啦!",
                                p[choice].cost);
                        temppress(shortbuf);
                    }

                    else if (d.maxhp < p[choice].needmaxhp || d.maxmp < p[choice].needmaxmp || d.speed < p[choice].needspeed) { /*能力不足 */
                        sprintf(shortbuf,
                                "需要HP %d MP %d SPEED %d 喔",
                                p[choice].needmaxhp,
                                p[choice].needmaxmp,
                                p[choice].needspeed);
                        temppress(shortbuf);
                    } else { /*顺利购买 */

                        sprintf(shortbuf,
                                "你确定要购买 %s 吗?($%d) [y/N]",
                                p[choice].name, p[choice].cost);
#ifdef MAPLE
                        getdata(b_lines - 1, 1, shortbuf, ans,
                                2, 1, 0);
#else
                        getdata(b_lines-1,1,shortbuf,ans,2,DOECHO,NULL,true);
#endif    // END MAPLE
                        if (ans[0] == 'y' || ans[0] == 'Y') {
                            sprintf(shortbuf,
                                    "小鸡已经装配上 %s 了",
                                    p[choice].name);
                            temppress(shortbuf);
                            d.attack +=
                                (p[choice].attack -
                                 p[variance].attack);
                            d.resist +=
                                (p[choice].resist -
                                 p[variance].resist);
                            d.speed +=
                                (p[choice].speed -
                                 p[variance].speed);
                            d.money -=
                                (p[choice].cost -
                                 p[variance].sell);
                            variance = choice;
                        } else {
                            sprintf(shortbuf,
                                    "放弃购买.....");
                            temppress(shortbuf);
                        }
                    }
                }
                break;

            case 'S':
            case 's':
                if (variance != 0) {
                    sprintf(shortbuf,
                            "你确定要卖掉%s吗? 卖价:%d [y/N]",
                            p[variance].name, p[variance].sell);
#ifdef MAPLE
                    getdata(b_lines - 1, 1, shortbuf, ans, 2, 1, 0);
#else
                    getdata(b_lines-1,1,shortbuf,ans,2,DOECHO,NULL,true);
#endif    // END MAPLE
                    if (ans[0] == 'y' || ans[0] == 'Y') {
                        sprintf(shortbuf, "装备 %s 卖了 %d",
                                p[variance].name,
                                p[variance].sell);
                        d.attack -= p[variance].attack;
                        d.resist -= p[variance].resist;
                        d.speed -= p[variance].speed;
                        d.money += p[variance].sell;
                        temppress(shortbuf);
                        variance = 0;
                    } else {
                        sprintf(shortbuf,
                                "ccc..我回心转意了...");
                        temppress(shortbuf);
                    }
                } else if (variance == 0) {
                    sprintf(shortbuf, "你本来就没有装备了...");
                    temppress(shortbuf);
                    variance = 0;
                }
                break;

            case 'W':
            case 'w':
                pip_data_list();
                break;

#ifdef MAPLE
            case Ctrl('R'):
                if (currutmp->msgs[0].last_pid) {
                    show_last_call_in();
                    my_write(currutmp->msgs[0].last_pid,
                             "水球丢回去:");
                }
                break;
#endif    // END MAPLE
        }
    } while ((pipkey != 'Q') && (pipkey != 'q') && (pipkey != KEY_LEFT));

    return variance;
}
Exemple #7
0
int pip_buy_goods_new(int mode,const struct goodsofpip *p,int *oldnum)
{
    const static char *shopname[4] = { "店名", "便利商店", "星空药铺", "夜里书局" };
    char inbuf[256];
    char genbuf[20];
    long smoney;
    int oldmoney;
    int i, pipkey, choice;

    oldmoney = d.money;
    do {
        clrchyiuan(6, 18);
        move(6, 0);
        sprintf(inbuf,
                "\033[1;31m  —\033[41;37m 编号 \033[0;1;31m—\033[41;37m 商      品 \033[0;1;31m——\033[41;37m 效            能 \033[0;1;31m——\033[41;37m 价     格 \033[0;1;31m—\033[37;41m 拥有数量 \033[0;1;31m—\033[0m  ");
        prints(inbuf);
        for (i = 1; i <= oldnum[0]; i++) {
            move(7 + i, 0);
            sprintf(inbuf,
                    "     \033[1;35m[\033[37m%2d\033[35m]     \033[36m%-10s      \033[37m%-14s        \033[1;33m%-10d   \033[1;32m%-9d    \033[0m",
                    p[i].num, p[i].name, p[i].msgbuy, p[i].money,
                    oldnum[i]);
            prints(inbuf);
        }
        clrchyiuan(19, 24);
        move(b_lines, 0);
        sprintf(inbuf,
                "\033[1;44;37m  %8s选单  \033[46m  [B]买入物品  [S]卖出物品  [Q]跳出:                         \033[m",
                shopname[mode]);
        prints(inbuf);
        pipkey = igetkey();
        switch (pipkey) {
            case 'B':
            case 'b':
                move(b_lines - 1, 1);
                sprintf(inbuf,
                        "想要买入啥呢? [0]放弃买入 [1~%d]物品商号",
                        oldnum[0]);
#ifdef MAPLE
                getdata(b_lines - 1, 1, inbuf, genbuf, 3, LCECHO, "0");
#else
                getdata(b_lines-1,1,inbuf,genbuf,3,DOECHO,NULL,true);
                if ((genbuf[0] >= 'A') && (genbuf[0] <= 'Z'))
                    genbuf[0] = genbuf[0] | 32;
#endif    // END MAPLE

                choice = atoi(genbuf);
                if (choice >= 1 && choice <= oldnum[0]) {
                    clrchyiuan(6, 18);
                    if (rand() % 2 > 0)
                        show_buy_pic(p[choice].pic1);
                    else
                        show_buy_pic(p[choice].pic2);
                    move(b_lines - 1, 0);
                    clrtoeol();
                    move(b_lines - 1, 1);
                    smoney = 0;
                    if (mode == 3)
                        smoney = 1;
                    else {
                        sprintf(inbuf,
                                "你要买入物品 [%s] 多少个呢?(上限 %d)",
                                p[choice].name,
                                d.money / p[choice].money);
#ifdef MAPLE
                        getdata(b_lines - 1, 1, inbuf, genbuf,
                                6, 1, 0);
#else
                        getdata(b_lines-1,1,inbuf,genbuf,6,DOECHO,NULL,true);
#endif    // END MAPLE
                        smoney = atoi(genbuf);
                    }
                    if (smoney < 0) {
                        temppress("放弃买入...");
                    } else if (d.money < smoney * p[choice].money) {
                        temppress("你的钱没有那麽多喔..");
                    } else {
                        sprintf(inbuf,"确定买入物品 [%s] 数量 %ld 个吗?(店家卖价 %ld) [y/N]:",p[choice].name,smoney,smoney*p[choice].money);
#ifdef MAPLE
                        getdata(b_lines - 1, 1, inbuf, genbuf,
                                2, 1, 0);
#else
                        getdata(b_lines-1,1,inbuf,genbuf,2,DOECHO,NULL,true);
#endif    // END MAPLE
                        if (genbuf[0] == 'y'
                                || genbuf[0] == 'Y') {
                            oldnum[choice] += smoney;
                            d.money -=
                                smoney * p[choice].money;
                            sprintf(inbuf,"老板给了你%ld个%s",smoney,p[choice].name);
                            temppress(inbuf);
                            temppress(p[choice].msguse);
                            if (mode == 3 && choice == 1) {
                                d.happy +=
                                    rand() % 10 +
                                    20 * smoney;
                                d.satisfy +=
                                    rand() % 10 +
                                    20 * smoney;
                            }
                            if (mode == 3 && choice == 2) {
                                d.happy +=
                                    (rand() % 2 +
                                     2) * smoney;
                                d.wisdom +=
                                    (2 +
                                     10 / (d.wisdom /
                                           100 +
                                           1)) * smoney;
                                d.character +=
                                    (rand() % 4 +
                                     2) * smoney;
                                d.art +=
                                    (rand() % 2 +
                                     1) * smoney;
                            }
                        } else {
                            temppress("放弃买入...");
                        }
                    }
                } else {
                    sprintf(inbuf, "放弃买入.....");
                    temppress(inbuf);
                }
                break;

            case 'S':
            case 's':
                if (mode == 3) {
                    temppress("这些东西不能卖喔....");
                    break;
                }
                move(b_lines - 1, 1);
                sprintf(inbuf,
                        "想要卖出啥呢? [0]放弃卖出 [1~%d]物品商号",
                        oldnum[0]);
#ifdef MAPLE
                getdata(b_lines - 1, 1, inbuf, genbuf, 3, LCECHO, "0");
#else
                getdata(b_lines-1,1,inbuf,genbuf,3,DOECHO,NULL,true);
                if ((genbuf[0] >= 'A') && (genbuf[0] <= 'Z'))
                    genbuf[0] = genbuf[0] | 32;
#endif    // END MAPLE
                choice = atoi(genbuf);
                if (choice >= 1 && choice <= oldnum[0]) {
                    clrchyiuan(6, 18);
                    if (rand() % 2 > 0)
                        show_buy_pic(p[choice].pic1);
                    else
                        show_buy_pic(p[choice].pic2);
                    move(b_lines - 1, 0);
                    clrtoeol();
                    move(b_lines - 1, 1);
                    smoney = 0;
                    sprintf(inbuf,
                            "你要卖出物品 [%s] 多少个呢?(上限 %d)",
                            p[choice].name, oldnum[choice]);
#ifdef MAPLE
                    getdata(b_lines - 1, 1, inbuf, genbuf, 6, 1, 0);
#else
                    getdata(b_lines-1,1,inbuf,genbuf,6,DOECHO,NULL,true);
#endif    // END MAPLE
                    smoney = atoi(genbuf);
                    if (smoney < 0) {
                        temppress("放弃卖出...");
                    } else if (smoney > oldnum[choice]) {
                        sprintf(inbuf,
                                "你的 [%s] 没有那麽多个喔",
                                p[choice].name);
                        temppress(inbuf);
                    } else {
                        sprintf(inbuf,"确定卖出物品 [%s] 数量 %ld 个吗?(店家买价 %ld) [y/N]:",
                                p[choice].name,smoney,smoney*p[choice].money*8/10);
#ifdef MAPLE
                        getdata(b_lines - 1, 1, inbuf, genbuf,
                                2, 1, 0);
#else
                        getdata(b_lines-1,1,inbuf,genbuf,2,DOECHO,NULL,true);
#endif    // END MAPLE
                        if (genbuf[0] == 'y'
                                || genbuf[0] == 'Y') {
                            oldnum[choice] -= smoney;
                            d.money +=
                                smoney * p[choice].money *
                                8 / 10;
                            sprintf(inbuf,"老板拿走了你的%ld个%s",smoney,p[choice].name);
                            temppress(inbuf);
                        } else {
                            temppress("放弃卖出...");
                        }
                    }
                } else {
                    sprintf(inbuf, "放弃卖出.....");
                    temppress(inbuf);
                }
                break;
            case 'Q':
            case 'q':
                sprintf(inbuf, "金钱交易共 %d 元,离开 %s ",
                        d.money - oldmoney, shopname[mode]);
                temppress(inbuf);
                break;
#ifdef MAPLE
            case Ctrl('R'):
                if (currutmp->msgs[0].last_pid) {
                    show_last_call_in();
                    my_write(currutmp->msgs[0].last_pid,
                             "水球丢回去:");
                }
                break;
#endif    // END MAPLE
        }
    } while ((pipkey != 'Q') && (pipkey != 'q') && (pipkey != KEY_LEFT));
    return 0;
}