pip_menu.c
来自「linux/unix环境下的建站系统」· C语言 代码 · 共 933 行 · 第 1/2 页
C
933 行
/* * 武官 */ if ((time(0) - start_time) >= 900) { d.seeroyalJ = 0; } if (m == 0) /*诞生 */ age = 0; else if (m == 1) /*婴儿 */ age = 1; else if (m >= 2 && m <= 5) /*幼儿 */ age = 2; else if (m >= 6 && m <= 12) /*儿童 */ age = 3; else if (m >= 13 && m <= 15) /*少年 */ age = 4; else if (m >= 16 && m <= 18) /*青年 */ age = 5; else if (m >= 19 && m <= 35) /*成年 */ age = 6; else if (m >= 36 && m <= 45) /*壮年 */ age = 7; else if (m >= 45 && m <= 60) /*更年 */ age = 8; else if (m >= 60 && m <= 70) /*老年 */ age = 9; else if (m >= 70 && m <= 100) /*古稀 */ age = 10; else if (m > 100) /*神仙 */ age = 11; else age=0; clear(); /* * showtitle("电子养小鸡", BBS_FULL_NAME); */ move(0, 0); if (d.sex == 1) sprintf(buf, "\033[1;41m 星空战斗鸡 ~ \033[32m♂ \033[37m%-15s \033[0m", d.name); else if (d.sex == 2) sprintf(buf, "\033[1;41m 星空战斗鸡 ~ \033[33m♀ \033[37m%-15s \033[0m", d.name); else sprintf(buf, "\033[1;41m 星空战斗鸡 ~ \033[34m? \033[37m%-15s \033[0m", d.name); prints(buf); move(1, 0); if (d.money <= 100) color1 = 31; else if (d.money > 100 && d.money <= 500) color1 = 33; else color1 = 37; sprintf(inbuf1, "%02d/%02d/%02d", d.year, d.month, d.day); sprintf(buf, " \033[1;32m[状 态]\033[37m %-5s \033[32m[生 日]\033[37m %-9s \033[32m[年 龄]\033[37m %-5d \033[32m[金 钱]\033[%dm %-8d \033[m", yo[age], inbuf1, tm, color1, d.money); prints(buf); move(2, 0); if ((d.hp * 100 / d.maxhp) <= 20) color1 = 31; else if ((d.hp * 100 / d.maxhp) <= 40 && (d.hp * 100 / d.maxhp) > 20) color1 = 33; else color1 = 37; if (d.maxmp == 0) color2 = 37; else if ((d.mp * 100 / d.maxmp) <= 20) color2 = 31; else if ((d.mp * 100 / d.maxmp) <= 40 && (d.mp * 100 / d.maxmp) > 20) color2 = 33; else color2 = 37; if (d.tired >= 80) color3 = 31; else if (d.tired < 80 && d.tired >= 60) color3 = 33; else color3 = 37; sprintf(inbuf1, "%d/%d", d.hp, d.maxhp); sprintf(inbuf2, "%d/%d", d.mp, d.maxmp); sprintf(buf, " \033[1;32m[生 命]\033[%dm %-10s\033[32m[法 力]\033[%dm %-10s\033[32m[体 重]\033[37m %-5d \033[32m[疲 劳]\033[%dm %-4d\033[0m ", color1, inbuf1, color2, inbuf2, d.weight, color3, d.tired); prints(buf); move(3, 0); if (d.shit >= 80) color1 = 31; else if (d.shit < 80 && d.shit >= 60) color1 = 33; else color1 = 37; if (d.sick >= 75) color2 = 31; else if (d.sick < 75 && d.sick >= 50) color2 = 33; else color2 = 37; if (d.happy <= 20) color3 = 31; else if (d.happy > 20 && d.happy <= 40) color3 = 33; else color3 = 37; if (d.satisfy <= 20) color4 = 31; else if (d.satisfy > 20 && d.satisfy <= 40) color4 = 33; else color4 = 37; sprintf(buf, " \033[1;32m[脏 脏]\033[%dm %-4d \033[32m[病 气]\033[%dm %-4d \033[32m[快乐度]\033[%dm %-4d \033[32m[满意度]\033[%dm %-4d\033[0m", color1, d.shit, color2, d.sick, color3, d.happy, color4, d.satisfy); prints(buf); if (mode == 0) { /*主要画面 */ anynum = 0; anynum = rand() % 4; move(4, 0); if (anynum == 0) sprintf(buf, " \033[1;35m[站长曰]:\033[31m红色\033[36m表示危险 \033[33m黄色\033[36m表示警告 \033[37m白色\033[36m表示安全\033[0m"); else if (anynum == 1) sprintf(buf, " \033[1;35m[站长曰]:\033[37m要多多注意小鸡的疲劳度和病气 以免累死病死\033[0m"); else if (anynum == 2) sprintf(buf, " \033[1;35m[站长曰]:\033[37m随时注意小鸡的生命数值唷!\033[0m"); else if (anynum == 3) sprintf(buf, " \033[1;35m[站长曰]:\033[37m快快乐乐的小鸡才是幸福的小鸡.....\033[0m"); prints(buf); } else if (mode == 1) { /*饮食 */ move(4, 0); if (d.food == 0) color1 = 31; else if (d.food <= 5 && d.food > 0) color1 = 33; else color1 = 37; if (d.cookie == 0) color2 = 31; else if (d.cookie <= 5 && d.cookie > 0) color2 = 33; else color2 = 37; if (d.bighp == 0) color3 = 31; else if (d.bighp <= 2 && d.bighp > 0) color3 = 33; else color3 = 37; if (d.medicine == 0) color4 = 31; else if (d.medicine <= 5 && d.medicine > 0) color4 = 33; else color4 = 37; sprintf(buf, " \033[1;36m[食物]\033[%dm%-7d\033[36m[零食]\033[%dm%-7d\033[36m[补丸]\033[%dm%-7d\033[36m[灵芝]\033[%dm%-7d\033[36m[人参]\033[37m%-7d\033[36m[雪莲]\033[37m%-7d\033[0m", color1, d.food, color2, d.cookie, color3, d.bighp, color4, d.medicine, d.ginseng, d.snowgrass); prints(buf); } else if (mode == 2) { /*打工 */ move(4, 0); sprintf(buf, " \033[1;36m[爱心]\033[37m%-5d\033[36m[智慧]\033[37m%-5d\033[36m[气质]\033[37m%-5d\033[36m[艺术]\033[37m%-5d\033[36m[道德]\033[37m%-5d\033[36m[勇敢]\033[37m%-5d\033[36m[家事]\033[37m%-5d\033[0m", d.love, d.wisdom, d.character, d.art, d.etchics, d.brave, d.homework); prints(buf); } else if (mode == 3) { /*修行 */ move(4, 0); sprintf(buf, " \033[1;36m[智慧]\033[37m%-5d\033[36m[气质]\033[37m%-5d\033[36m[艺术]\033[37m%-5d\033[36m[勇敢]\033[37m%-5d\033[36m[攻击]\033[37m%-5d\033[36m[防御]\033[37m%-5d\033[36m[速度]\033[37m%-5d\033[0m", d.wisdom, d.character, d.art, d.brave, d.attack, d.resist, d.speed); prints(buf); } move(5, 0); sprintf (linebuf, "\033[1;%dm┌—————————————————————————————————————┐\033[m", color); prints(linebuf); move(6, 0); switch (age) { case 0: case 1: case 2: if (d.weight <= (60 + 10 * tm - 30)) show_basic_pic(1); else if (d.weight > (60 + 10 * tm - 30) && d.weight < (60 + 10 * tm + 30)) show_basic_pic(2); else if (d.weight >= (60 + 10 * tm + 30)) show_basic_pic(3); break; case 3: case 4: if (d.weight <= (60 + 10 * tm - 30)) show_basic_pic(4); else if (d.weight > (60 + 10 * tm - 30) && d.weight < (60 + 10 * tm + 30)) show_basic_pic(5); else if (d.weight >= (60 + 10 * tm + 30)) show_basic_pic(6); break; case 5: case 6: if (d.weight <= (60 + 10 * tm - 30)) show_basic_pic(7); else if (d.weight > (60 + 10 * tm - 30) && d.weight < (60 + 10 * tm + 30)) show_basic_pic(8); else if (d.weight >= (60 + 10 * tm + 30)) show_basic_pic(9); break; case 7: case 8: if (d.weight <= (60 + 10 * tm - 30)) show_basic_pic(10); else if (d.weight > (60 + 10 * tm - 30) && d.weight < (60 + 10 * tm + 30)) show_basic_pic(11); else if (d.weight >= (60 + 10 * tm + 30)) show_basic_pic(12); break; case 9: show_basic_pic(13); break; case 10: case 11: show_basic_pic(16); break; } move(18, 0); sprintf (linebuf, "\033[1;%dm└—————————————————————————————————————┘\033[m", color); prints(linebuf); move(19, 0); prints(" \033[1;34m—\033[37;44m 状 态 \033[0;1;34m—\033[0m"); move(20, 0); prints(" "); if (d.shit == 0) prints("干净小鸡 "); if (d.shit > 40 && d.shit < 60) prints("有点臭臭 "); if (d.shit >= 60 && d.shit < 80) prints("\033[1;33m很臭了说\033[m "); if (d.shit >= 80 && d.shit < 100) { prints("\033[1;35m快臭死了\033[m "); d.sick += 4; d.character -= (rand() % 3 + 3); } if (d.shit >= 100) { d.death = 1; pipdie("\033[1;31m哇~臭死了\033[m ", 1); return -1; } if (d.hp <= 0) pc = 0; else pc = d.hp * 100 / d.maxhp; if (pc == 0) { d.death = 1; pipdie("\033[1;31m呜~饿死了\033[m ", 1); return -1; } if (pc < 20) { prints("\033[1;35m快饿昏了\033[m "); d.sick += 3; d.happy -= 5; d.satisfy -= 3; } if (pc < 40 && pc >= 20) prints("\033[1;33m想吃东西\033[m "); if (pc <= 100 && pc >= 90) prints("肚子饱饱 "); if (pc < 110 && pc > 100) prints("\033[1;33m撑撑的说\033[m "); pc = d.tired; if (pc < 20) prints("精神很好 "); if (pc < 80 && pc >= 60) prints("\033[1;33m有点小累\033[m "); if (pc < 100 && pc >= 80) { prints("\033[1;35m真的很累\033[m "); d.sick += 5; } if (pc >= 100) { d.death = 1; pipdie("\033[1;31mㄚ~累死了\033[m ", 1); return -1; } pc = 60 + 10 * tm; if (d.weight < (pc + 30) && d.weight >= (pc + 10)) prints("\033[1;33m有点小胖\033[m "); if (d.weight < (pc + 50) && d.weight >= (pc + 30)) { prints("\033[1;35m太胖了啦\033[m "); d.sick += 3; if (d.speed >= 2) d.speed -= 2; else d.speed = 0; } if (d.weight > (pc + 50)) { d.death = 1; pipdie("\033[1;31m呜~肥死了\033[m ", 1); return -1; } if (d.weight < (pc - 50)) { d.death = 1; pipdie("\033[1;31m:~~ 瘦死了\033[m ", 1); return -1; } if (d.weight > (pc - 30) && d.weight <= (pc - 10)) prints("\033[1;33m有点小瘦\033[m "); if (d.weight > (pc - 50) && d.weight <= (pc - 30)) prints("\033[1;35m太瘦了喔\033[m "); if (d.sick < 75 && d.sick >= 50) { prints("\033[1;33m生病了啦\033[m "); count_tired(1, 8, "Y", 100, 1); } if (d.sick < 100 && d.sick >= 75) { prints("\033[1;35m正病重中\033[m "); d.sick += 5; count_tired(1, 15, "Y", 100, 1); } if (d.sick >= 100) { d.death = 1; pipdie("\033[1;31m病死了啦 :~~\033[m ", 1); return -1; } pc = d.happy; if (pc < 20) prints("\033[1;35m很不快乐\033[m "); if (pc < 40 && pc >= 20) prints("\033[1;33m不太快乐\033[m "); if (pc < 95 && pc >= 80) prints("快乐啦.. "); if (pc <= 100 && pc >= 95) prints("很快乐.. "); pc = d.satisfy; if (pc < 20) prints("\033[1;35m很不满足..\033[m "); if (pc < 40 && pc >= 20) prints("\033[1;33m不太满足\033[m "); if (pc < 95 && pc >= 80) prints("满足啦.. "); if (pc <= 100 && pc >= 95) prints("很满足.. "); prints("\n"); pip_write_file(); return 0;}/*固定时间作的事 */intpip_time_change(cnow)time_t cnow;{ int stime = 60; int stired = 2; while ((time(0) - lasttime) >= stime) { /* 固定时间做的事 */ /* * 不做事 还是会变脏的 */ if ((time(0) - cnow) >= stime) d.shit += (rand() % 3 + 3); /* * 不做事 疲劳当然减低啦 */ if (d.tired >= stired) d.tired -= stired; else d.tired = 0; /* * 不做事 肚子也会饿咩 */ d.hp -= rand() % 2 + 2; if (d.mexp < 0) d.mexp = 0; if (d.hexp < 0) d.hexp = 0; /* * 体力会因生病降低一点 */ d.hp -= d.sick / 10; /* * 病气会随机率增加减少少许 */ if (rand() % 3 > 0) { d.sick -= rand() % 2; if (d.sick < 0) d.sick = 0; } else d.sick += rand() % 2; /* * 随机减快乐度 */ if (rand() % 4 > 0) { d.happy -= rand() % 2 + 2; } else d.happy += 2; if (rand() % 4 > 0) { d.satisfy -= (rand() % 4 + 5); } else d.satisfy += 2; lasttime += stime; }; /* * 快乐度满意度最大值设定 */ if (d.happy > 100) d.happy = 100; else if (d.happy < 0) d.happy = 0; if (d.satisfy > 100) d.satisfy = 100; else if (d.satisfy < 0) d.satisfy = 0; /* * 评价 */ if (d.social < 0) d.social = 0; if (d.tired < 0) d.tired = 0; if (d.hp > d.maxhp) d.hp = d.maxhp; if (d.mp > d.maxmp) d.mp = d.maxmp; if (d.money < 0) d.money = 0; if (d.charm < 0) d.charm = 0; return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?