コード例 #1
0
ファイル: pip_basic.c プロジェクト: marvelliu/lilacsrc
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;
}
コード例 #2
0
ファイル: pip_store.c プロジェクト: loverabbit/kbs-redis
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;
}