pip_store.c
来自「linux/unix环境下的建站系统」· C语言 代码 · 共 624 行 · 第 1/2 页
C
624 行
} 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;}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;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?