The Backrooms 后室·无限
你终于累垮了,在平地上摔了一跤,切出了地板。你回过神来,站起身,却发现脚下并不是潮湿的地毯,而是一片草地……“我真的逃出来了吗?”“我回家了吗?”
初次游玩请看菜单内<关于>了解游戏及操作 菜单内请用W/S选择
不知为何层级简介的文字介绍部分不能过QAQ
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
int level = 0, san = 120, food = 120, hp = 120, buff = 0, sbuff[5], tili = 120;
int wuping = 0, xrs = 0, jjyz = 0, hy = 0, hjkl = 0, gzlr = 0, zsq = 0, swfecj = 0;
int st = 0, sjcs, sxz, xd, yglgy = 0, man = 0, bbrl = 20, ynmht, rhmht, hf = 0, jj = 0;
int shiti[100], wuzi[101], sdt, dl, dc, sqdy, bsxh, kj = 0, duandao = 0, equip_duandao = 0;
int xrscj = 0, scj = 0, ts = 0, yqlyy = 0, sc = 0, llz = 0, ffht = 0, dz = 0, bd = 0, cjyscs = 0, xrssy = 0, LL, ttcg = 0, ha = 0;
map<int, int >L;
vector <int > swuping;
//新层级 物品发现地点 分界线 层级名称 实体多少
//新物品 物品简介 背包物品名称 使用 丢弃
int cjys = 0, xydn = 0, xsqqj = 0;
int xydn_buff = 0, mosun_budai;
void setsize(int col, int row) {
char cmd[64];
sprintf(cmd, "mode con cols=%d lines=%d", col, row);
system(cmd);
}
void anjian(){
while(5) for(int i=0;i<=200;i++)
if(GetAsyncKeyState(i)&0x8000) cout<<i<<' ';
}
void cls() {
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdOut == INVALID_HANDLE_VALUE) return;
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (!GetConsoleScreenBufferInfo(hStdOut, &csbi)) return;
DWORD cellCount = csbi.dwSize.X * csbi.dwSize.Y;
COORD homeCoords = {0, 0};
DWORD count;
FillConsoleOutputCharacter(hStdOut, ' ', cellCount, homeCoords, &count);
SetConsoleCursorPosition(hStdOut, homeCoords);
}
void Color(int a)
{
if(a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
if(a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
if(a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
if(a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
if(a == 6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
if(a == 7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
if(a == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
if(a == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE);
if(a == 10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);
if(a == 11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}void cj(int x){
cls();
Color(0);
cout << endl << endl << " 成就 ";
if (x == 1) cout << "流浪者" << endl;
if (x == 2) cout << "反复横跳" << endl;
if (x == 3) cout << "生存" << endl;
if (x == 4) cout << "杏仁水" << endl;
if (x == 5) cout << "收藏家" << endl;
if (x == 6) cout << "训蛾者" << endl;
else cout << "一千零一夜" << endl;
Sleep(1200);
cls();
}
// 0 1 2 3 4 5 6 7 8 9 10 11
// 白 较青蓝 绿 紫 大红 青 淡黄 深灰 较深红 较深蓝 较棕黄 浅灰
// 清除所有数据(精简版)
void saveGame() {
ofstream f("save.dat",ios::binary);
// 原有变量保存
f.write((char*)&level,sizeof(level)) .write((char*)&san,sizeof(san)) .write((char*)&food,sizeof(food));
f.write((char*)&hp,sizeof(hp)) .write((char*)&buff,sizeof(buff)) .write((char*)sbuff,sizeof(sbuff));
f.write((char*)&tili,sizeof(tili)) .write((char*)&wuping,sizeof(wuping)) .write((char*)&xrs,sizeof(xrs));
f.write((char*)&jjyz,sizeof(jjyz)) .write((char*)&hy,sizeof(hy)) .write((char*)&hjkl,sizeof(hjkl));
f.write((char*)&gzlr,sizeof(gzlr)) .write((char*)&zsq,sizeof(zsq)) .write((char*)&st,sizeof(st));
f.write((char*)&sjcs,sizeof(sjcs)) .write((char*)&sxz,sizeof(sxz)) .write((char*)&xd,sizeof(xd));
f.write((char*)&yglgy,sizeof(yglgy)) .write((char*)&man,sizeof(man)) .write((char*)&bbrl,sizeof(bbrl));
f.write((char*)&ynmht,sizeof(ynmht)) .write((char*)&rhmht,sizeof(rhmht)) .write((char*)&hf,sizeof(hf));
f.write((char*)&jj,sizeof(jj)) .write((char*)shiti,sizeof(shiti)) .write((char*)wuzi,sizeof(wuzi));
f.write((char*)&sdt,sizeof(sdt)) .write((char*)&dl,sizeof(dl)) .write((char*)&dc,sizeof(dc));
f.write((char*)&sqdy,sizeof(sqdy)) .write((char*)&bsxh,sizeof(bsxh)) .write((char*)&dz,sizeof(dz));
f.write((char*)&kj,sizeof(kj)) .write((char*)&duandao,sizeof(duandao)) .write((char*)&equip_duandao,sizeof(equip_duandao));
f.write((char*)&cjys,sizeof(cjys)) .write((char*)&xydn,sizeof(xydn)) .write((char*)&xsqqj,sizeof(xsqqj));
f.write((char*)&xydn_buff,sizeof(xydn_buff)) .write((char*)&mosun_budai,sizeof(mosun_budai));
f.write((char*)&xrscj, sizeof(xrscj))
.write((char*)&scj, sizeof(scj)) // 收藏家成就标记
.write((char*)&sc, sizeof(sc)) // 生存成就标记
.write((char*)&llz, sizeof(llz)) // 流浪者成就标记
.write((char*)&ffht, sizeof(ffht)) // 反复横跳成就标记
.write((char*)&bd, sizeof(bd)) // 布袋数量
.write((char*)&cjyscs, sizeof(cjyscs)) // 层级钥匙使用次数
.write((char*)&xrssy, sizeof(xrssy)) // 杏仁水使用次数
.write((char*)&LL, sizeof(LL)) // 探索层级数量
.write((char*)&ttcg, sizeof(ttcg)) // 逃离实体次数
.write((char*)&ha, sizeof(ha)); // 黑暗buff标记
f.close();
cout << endl << " 存档成功" << endl;
Sleep(1200);
cls();
}
void cenjijianjie(){
cls();
Color(0);
cout << endl;
if (level == 0){
cout << " Level 0 前厅 "<< endl;
cout << " 生存难度 class 1" << endl;
cout << " >> 安全" << endl;
cout << " >> 不稳定" << endl;
cout << " >> 无实体" << endl;
cout << " >> 物资正常" << endl;
}
else if (level == 1){
cout << " Level 1 宜居区 "<< endl;
cout << " 生存难度 class 1" << endl;
cout << " >> 安全" << endl;
cout << " >> 稳定" << endl;
cout << " >> 实体数量极少" << endl;
cout << " >> 物资较丰富" << endl;
}
else if (level == 2){
cout << " Level 2 管道噩梦 "<< endl;
cout << " 生存难度 class 2" << endl;
cout << " >> 不安全" << endl;
cout << " >> 稳定" << endl;
cout << " >> 实体相对较少" << endl;
cout << " >> 物资较匮乏" << endl;
}
else if (level == 3){
cout << " Level 3 电气室 "<< endl;
cout << " 生存难度 class 2" << endl;
cout << " >> 不安全" << endl;
cout << " >> 不稳定" << endl;
cout << " >> 少量实体" << endl;
cout << " >> 少量物资" << endl;
}
else if (level == 4){
cout << " Level 4 废弃办公室 "<< endl;
cout << " 生存难度 class 宜居" << endl;
cout << " >> 安全" << endl;
cout << " >> 稳定" << endl;
cout << " >> 无实体存在" << endl;
cout << " >> 物资较丰富" << endl;
}
else if (level == 5){
cout << " Level 5 恐怖旅馆 "<< endl;
cout << " 生存难度 class 5" << endl;
cout << " >> 不安全" << endl;
cout << " >> 未勘探完全" << endl;
cout << " >> 未经证实的实体目击" << endl;
cout << " >> 物资正常" << endl;
}
if (level == 6){
cout << " Level 6 熄灯 "<< endl;
cout << " 生存难度 待分" << endl;
cout << " >> 安全性未知" << endl;
cout << " >> 不稳定" << endl;
cout << " >> 未探明实体存在" << endl;
cout << " >> 物资极少" << endl;
}
else if (level == 7){
cout << " Level 7 深海恐惧症 "<< endl;
cout << " 生存难度 class 4" << endl;
cout << " >> 不安全" << endl;
cout << " >> 不稳定" << endl;
cout << " >> 中量实体" << endl;
cout << " >> 物资较稀缺" << endl;
}
else if (level == 8){
cout << " Level 8 岩洞系统 "<< endl;
cout << " 生存难度 class 4" << endl;
cout << " >> 不安全" << endl;
cout << " >> 极端环境风险" << endl;
cout << " >> 极多敌意存在" << endl;
cout << " >> 物资匮乏" << endl;
}
else if (level == 9){
cout << " Level 9 郊区 "<< endl;
cout << " 生存难度 class 5" << endl;
cout << " >> 不安全" << endl;
cout << " >> 不稳定" << endl;
cout << " >> 实体横行" << endl;
cout << " >> 少量物资" << endl;
}
else if (level == 10){
cout << " Level 10 丰裕 "<< endl;
cout << " 生存难度 class 宜居" << endl;
cout << " >> 安全" << endl;
cout << " >> 低环境风险" << endl;
cout << " >> 无敌对实体" << endl;
cout << " >> 物资极丰富" << endl;
}
else if (level == 11){
cout << " Level 11 不夜城 "<< endl;
cout << " 生存难度 class 2" << endl;
cout << " >> 安全" << endl;
cout << " >> 不稳定" << endl;
cout << " >> 少量实体" << endl;
cout << " >> 物资极丰富" << endl;
}
}
void loadGame() {
ifstream f("save.dat",ios::binary);
f.read((char*)&level,sizeof(level)) .read((char*)&san,sizeof(san)) .read((char*)&food,sizeof(food));
f.read((char*)&hp,sizeof(hp)) .read((char*)&buff,sizeof(buff)) .read((char*)sbuff,sizeof(sbuff));
f.read((char*)&tili,sizeof(tili)) .read((char*)&wuping,sizeof(wuping)) .read((char*)&xrs,sizeof(xrs));
f.read((char*)&jjyz,sizeof(jjyz)) .read((char*)&hy,sizeof(hy)) .read((char*)&hjkl,sizeof(hjkl));
f.read((char*)&gzlr,sizeof(gzlr)) .read((char*)&zsq,sizeof(zsq)) .read((char*)&st,sizeof(st));
f.read((char*)&sjcs,sizeof(sjcs)) .read((char*)&sxz,sizeof(sxz)) .read((char*)&xd,sizeof(xd));
f.read((char*)&yglgy,sizeof(yglgy)) .read((char*)&man,sizeof(man)) .read((char*)&bbrl,sizeof(bbrl));
f.read((char*)&ynmht,sizeof(ynmht)) .read((char*)&rhmht,sizeof(rhmht)) .read((char*)&hf,sizeof(hf));
f.read((char*)&jj,sizeof(jj)) .read((char*)shiti,sizeof(shiti)) .read((char*)wuzi,sizeof(wuzi));
f.read((char*)&sdt,sizeof(sdt)) .read((char*)&dl,sizeof(dl)) .read((char*)&dc,sizeof(dc));
f.read((char*)&sqdy,sizeof(sqdy)) .read((char*)&bsxh,sizeof(bsxh)) .read((char*)&dz,sizeof(dz));
f.read((char*)&kj,sizeof(kj)) .read((char*)&duandao,sizeof(duandao)) .read((char*)&equip_duandao,sizeof(equip_duandao));
f.read((char*)&cjys,sizeof(cjys)) .read((char*)&xydn,sizeof(xydn)) .read((char*)&xsqqj,sizeof(xsqqj));
f.read((char*)&xydn_buff,sizeof(xydn_buff)) .read((char*)&mosun_budai,sizeof(mosun_budai));
f.read((char*)&xrscj, sizeof(xrscj))
.read((char*)&scj, sizeof(scj))
.read((char*)&sc, sizeof(sc))
.read((char*)&llz, sizeof(llz))
.read((char*)&ffht, sizeof(ffht))
.read((char*)&bd, sizeof(bd))
.read((char*)&cjyscs, sizeof(cjyscs))
.read((char*)&xrssy, sizeof(xrssy))
.read((char*)&LL, sizeof(LL))
.read((char*)&ttcg, sizeof(ttcg))
.read((char*)&ha, sizeof(ha));
f.close();
cout << " 读档成功" << endl;
Sleep(1200);
cls();
}
void ksfm(){
Color(0);
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << " ■■■■■| ■| ■■■■■|" << endl;
cout << " ■| ̄ ■| ■ ̄ ̄" << endl;
cout << " ■| ■■■■■| ■■■■■|" << endl;
cout << " ■| ■| ̄■| ■| ̄ ̄" << endl;
cout << " ■| ■| ■| ■|" << endl;
cout << " ■| ■| ■| ■■■■■|" << endl;
cout << "  ̄  ̄  ̄  ̄ ̄ ̄" << endl;
Sleep(800);
system("cls");
int fma[6]={0, 10, 11, 7}, fmb[6]={0, 0, 0, 11, 7}, fmc[6]={0, 10, 11, 7};
for (int i = 1; i <= 4; i ++){
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
if (i < 3){
Color(fma[i]);
cout << " __ _ __, . _ _ _ _." << endl;
}
else cout << endl;
Color(fmb[i]);
cout << " |_)/_\\/ |_/ |_)| || |/\\/\\(_" << endl;
cout << " | )| |\\ | \\ | \\| || || | )" << endl;
if (i < 3){
Color(fmc[i]);
cout << "  ̄ ̄  ̄ ̄ ̄ ̄  ̄  ̄  ̄ ̄ ̄  ̄" << endl;
}
sjcs ++;
if (i == 1) Sleep(1000);
else Sleep(100);
system("cls");
}
Color(0);
system("cls");
Sleep(1500);
}
void guanyu(){
cls();
Color(11);
cout << endl;
cout << " The backrooms" << endl;
cout << " 如果你不小心,在错误的地方从现实中脱离,你就会来到后室,那里除了潮湿的旧地";
cout << " 毯的臭味,令人发疯的单调黄色,永不停歇的日光灯最大功率的嗡鸣噪音,以及被随";
cout << " 机分割成空房间的约六亿平方英里的区域以外什么都没有。如果你听到有东西在附近";
cout << " 徘徊,那你只能静待死亡了。" << endl << endl;
cout << " 什么是后室" << endl;
cout << " 欢迎来到后室,一个脱离于我们正常的现实世界的地方。你所目前所处的地方被称为Level 0。这是一般";
cout << " 情况下像你这样不小心脱离了现实,或者说,“卡出了现实世界”的人来到后室的第一站。后室就是一个";
cout << " 由不同空间,我们一般称之为“楼层”,所组成的迷宫,每个楼层都有它自己奇怪的特性,并以一种诡异";
cout << " 而复杂的方式连接在一起。有些楼层是相对安全的,比如你现在所在的Level 0,和接下来你会来到的";
cout << " Level 1,另一些楼层则是危险的,程度各不相同,但几乎每个楼层都会有威胁存在,这里可不如你以前";
cout << " 所在的现实世界安全,连物理定律都可能被篡改,还有各种奇形怪状的,我们称之为“实体”的后室生物";
cout << " 存在。在这里需要时时保持警惕,否则一不小心就会没命。" << endl;
cout << endl;
cout << " 我应该干什么" << endl;
cout << " 探索,求生,寻找,并时刻保持警惕?......" << endl;
cout << " 操作" << endl;
cout << " E打开背包 A/D选择物品 空格使用 P丢弃 Q退出" << endl;
cout << " M 查看层级信息 L 存档 O 读档 B 返回菜单 K 清除所有数据" << endl;
sjcs ++;
while (1){
if(kbhit()){
cls();
return;
}
}
}
void clearAllData() {
cls();
Color(4);
cout << "========== 确认清除所有数据?==========\n 按 Y 确认 | 按 N 取消\n=====================================" << endl;
while (kbhit() ? (_getch(), true) : true) { // 简化循环
char c = _getch();
if (c == 'Y' || c == 'y') {
// 1. 批量重置基础变量(合并赋值)
level = san = food = hp = buff = tili = wuping = xrs = jjyz = hy = hjkl = gzlr = zsq = st = sjcs = sxz = yglgy = man = 0;
san = food = hp = tili = 120; // 初始值单独赋值
xd = 1, bbrl = 20;
// 2. 重置状态/成就变量(添加 yqlyy 和 swfecj 的重置)
ynmht = rhmht = hf = jj = sdt = dl = dc = sqdy = bsxh = kj = duandao = equip_duandao =
xrscj = scj = sc = llz = ffht = dz = bd = cjyscs = xrssy = LL = ttcg = ha = cjys = xydn =
xsqqj = xydn_buff = mosun_budai = swfecj = yqlyy = 0; // 新增 swfecj(训蛾者)、yqlyy(一千零一夜)
// 3. 清空数组/容器(简化写法)
memset(sbuff, 0, sizeof(sbuff));
memset(shiti, 0, sizeof(shiti));
memset(wuzi, 0, sizeof(wuzi));
L.clear(), swuping.clear();
// 4. 删除存档文件(简化提示)
Color(2);
cout << "\n " << (remove("save.dat") == 0 ? "存档已删除!" : "无存档/删除失败!") << endl;
cout << " 所有数据已重置!" << endl;
Sleep(1500), cls(), ksfm(); // 链式调用减少行数
break;
} else if (c == 'N' || c == 'n') {
Color(7);
cout << "\n 已取消清除操作!" << endl;
Sleep(800), cls();
break;
}
}
}
void Say(char *p,int x)
{
while(1)
{
if(*p!=0) printf("%c",*p++);
else break;
Sleep(x);
}
}
void jiazai(){
cls();
cout << endl;cout << endl;cout << endl;
Color(11);
cout << " - The Backrooms -" << endl;
Color(7);
cout << " 你曾经来过这里";
Sleep(1500);
}
void my (int x){
cout << " ";
for (int i = 1; i <= x; i ++) cout << "? ";
cout << endl;
cout << " ? ? ? ? ?" << endl;
cout << " ? ? ? ? ?" << endl;
}
void cjxt (){
cls();
Color(0);
if (llz == 0) my(3);
else {
cout << " 流浪者" << endl;
cout << " 探索所有12个层级" << endl;
}
cout << endl;
if (ffht == 0) my(4);
else {
cout << " 反复横跳" << endl;
cout << " 使用层级钥匙4次" << endl;
}
cout << endl;
if (sc == 0) my(2);
else {
cout << " 生存" << endl;
cout << " 逃离实体15次" << endl;
}
cout << endl;
if (xrssy == 0) my(3);
else {
cout << " 杏仁水" << endl;
cout << " 使用杏仁水31次" << endl;
}
cout << endl;
if (scj == 0) my(3);
else {
cout << " 收藏家" << endl;
cout << " 获得5个磨损布袋" << endl;
}
cout << endl;
if (swfecj == 0) my(3);
else {
cout << " 训蛾者" << endl;
cout << " 驯服死亡飞蛾" << endl;
}
cout << endl;
if (yqlyy == 0) my(5);
else {
cout << " 一千零一夜" << endl;
cout << " 在一次游戏中存活101个轮回" << endl;
}
Color(7);
cout << endl << " 空格键退出" << endl;
while (1){
if(kbhit()){
char c=_getch();
if(c==' '){
cls();
return;
}
}
}
}
void kscd(){
int kk = 1, k = 1, xz = 1, stou[10]={0, 3, 2, 1, 0};
while (k){
if (GetAsyncKeyState(38)&0x8000) xz = 1;
if (GetAsyncKeyState(40)&0x8000) xz = 2;
if(kbhit()){
char c=_getch();
if(c==' ') {
if (xz == 1) guanyu();
else return ;
}
}
cout << endl;
cout << endl;
Color(11);
cout << "后室之中·无限" << endl;
cout << endl;
cout << " ";
Color(7);
cout << "■■";
Color(11);
cout << "■■";
Color(10);
cout << "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
Color(11);
cout << "■■";
Color(7);
cout << "■■" << endl;
int tou = stou[k], jiange = 0;
cout << " ";
Color(7);
cout << "==";
Color(11);
cout << "==";
for (int i = 1; i <= 30; i ++){
if (tou){
tou --;
Color(10);
cout << "=";
}
else if (jiange){
jiange --;
Color(10);
cout << "=";
}
else {
jiange = 3;
Color(0);
cout << "=";
}
}
Color(11);
cout << "==";
Color(7);
cout << "==";
int bian = rand() % 100;
if (bian % 24 == 0){
cout << endl;
Color(8);
cout << " @" << endl;
Color(7);
cout << " `■" << endl;
cout << " |#" << endl;
cout << " }" << endl;
cout << " [." << endl;
}
else {
cout << endl << endl << endl;
Color(0);
cout << " O" << endl;
Color(6);
cout << " ";
Color(6);
if (kk % 3 == 0) cout << "/";
else if (kk % 3 == 1)cout << "|";
else cout << "\\" ;
Color(6);
cout << " " << endl;
if (kk % 3 == 0){
Color(7);
cout << " / ";
Color(11);
cout << "\\" << endl;
}
else if (kk % 3 == 1){
Color(11);
cout << " / ";
Color(7);
cout << "\\" << endl;
}
else {
Color(11);
cout << " |" << endl;
}
}
cout << " ";
Color(7);
cout << "■■";
Color(11);
cout << "■■";
Color(10);
cout << "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
Color(11);
cout << "■■";
Color(7);
cout << "■■" << endl;
if (xz == 1) Color(11);
else Color(7);
cout << " 关于 " << endl;
if (xz == 2) Color(11);
else Color(7);
cout << " 开始游戏" << endl;
if (xz == 3) Color(11);
else Color(7);
cout << " 成就" << endl;
int u = 0;
while (++ u <= 7000){
if(kbhit()){
char c=_getch();
if(c=='w') {
xz = max(1, xz - 1);
break;
}
if(c=='s') {
xz = min(3, xz + 1);
break;
}
if(c==' ') {
if (xz == 1) guanyu();
else if (xz == 2){
jiazai();
return ;
}
else if (xz == 3){
cjxt();
break;
}
}
}
}
k ++;
kk ++;
if (k == 5) k = 1;
cls();
}
}
void cengji(){
Color(0);
if (level == 0) cout << "Level 0 -- 前厅";
else if (level == 1) cout << "Level 1 -- 宜居区";
else if (level == 2) cout << "Level 2 -- 管道噩梦";
else if (level == 3) cout << "Level 3 -- 电气室";
else if (level == 4) cout << "Level 4 -- 废弃办公室";
else if (level == 5) cout << "Level 5 -- 恐怖旅馆";
else if (level == 6) cout << "Level 6 -- 熄灯";
else if (level == 7) cout << "Level 7 -- 深海恐惧症";
else if (level == 8) cout << "Level 8 -- 岩洞系统";
else if (level == 9) cout << "Level 9 -- 郊区";
else if (level == 10) cout << "Level 10 -- 丰裕";
else if (level == 11) cout << "Level 11 -- 无垠城市";
}
void fenjie2(){
if (level == 0){
for (int i = 0; i < 30; i ++){
Color(10);
cout <<"▓";
}
}
else if (level == 1){
for (int i = 0; i < 30; i ++){
Color(7);
cout <<"■";
}
}
else if (level == 2){
for (int i = 0; i < 30; i ++){
if (i % 7 == 0 || i % 7 == 6){
Color(7);
cout << "▓";
}
else if (i % 7 == 3){
Color(8);
cout << "▌";
}
else if (i % 7 <= 2 || i % 7 <= 5){
Color(8);
cout <<"■";
}
}
}
else if (level == 3){
for (int i = 0; i < 30; i ++){
if(i % 7 <= 2){
Color(7);
cout <<"=";
}
else if (i % 7 <= 5){
Color(11);
cout << "#";
}
else {
Color(6);
cout << "*";
}
}
}
else if (level == 4){
for (int i = 0; i < 30; i ++){
Color(11);
cout <<"▓";
}
}
else if (level == 5){
for (int i = 0; i < 30; i ++){
Color(11);
cout <<"▓";
}
}
else if (level == 5 || level == 8){
for (int i = 0; i < 30; i ++){
Color(7);
cout <<"▓";
}
}
else if (level == 7){
for (int i = 0; i < 30; i ++){
if (i % 5 == 0) Color(1), cout << "■";
else Color(11), cout <<"▓";
}
}
else if (level == 9 || level == 11){
for (int i = 0; i < 30; i ++){
Color(7);
cout <<"■";
}
}
else if (level == 10){
for (int i = 0; i < 30; i ++){
Color(6);
if (i % 5 <= 2) cout <<"■";
else cout << "▓";
}
}
}
void fenjie1(){
if (level == 0){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 6 <= 2){
Color(10);
cout << "■";
}
else {
Color(0);
cout << "=";
}
}
}
else if (level == 1){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 8 <= 3){
Color(7);
cout << "▓";
}
else {
Color(0);
cout << "_";
}
}
}
else if (level == 2){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 8 <= 3){
Color(7);
cout << "■";
}
else {
Color(0);
cout << "■";
}
}
}
else if (level == 3){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 6 <= 3){
Color(7);
cout << "▓";
}
else {
Color(0);
cout << "=";
}
}
}
else if (level == 5){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 3 == 0){
Color(8);
cout << "▓";
}
else {
Color(6);
cout << "■";
}
}
}
else if (level == 4){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 8 <= 3){
Color(7);
cout << "▓";
}
else {
Color(0);
cout << "■";
}
}
}
else if (level == 6 || level == 8){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
Color(7);
if (i % 8 <= 3){
cout << "▓";
}
else if (i % 8 <= 5){
cout << "▼";
}
else {
Color(0);
cout << "■";
}
}
}
else if (level == 7){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
Color(7);
cout << "▓";
}
}
else if (level == 9){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 8 == 0){
Color(11);
cout << "▓";
}
else if (i % 8 <= 3 || i % 8 >= 5){
Color(7);
cout << "■";
}
else {
Color(11);
cout << "■";
}
}
}
else if (level == 10){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
if (i % 5 <= 1){
Color(6);
cout << "▓";
}
else {
Color(10);
cout << "■";
}
}
}
else if (level == 11){
fenjie2();
cout << endl;
for (int i = 0; i < 30; i ++){
Color(rand() % 12);
cout << "▓";
}
}
}
void zhuangtai(){
if (level == 0){
Color(10);
cout << "[] ";
}
else if (level == 1 || level == 2 || level == 3 || level == 6 || level == 7 || level == 9){
Color(7);
cout << "[] ";
}
else if (level == 5 || level == 10){
Color(6);
cout << "[] ";
}
else if (level == 4 || level == 11){
Color(11);
cout << "[] ";
}
}
void Buff(){
if (bsxh > 0) {
Color(7);
cout << "悲尸循环 " ;
}
if (hf > 0){
Color(2);
cout << "恢复 " ;
}
if (jj > 0){
Color(9);
cout << "安静 ";
}
}
void wpjj(int x){
Color(0);
if (x == 1){
cout << "杏仁水" << endl;
cout << "food+15 san+15 hp+5 体力+5";
}
else if (x == 2){
cout << "罐装龙肉" << endl;
cout << "food+40 hp+5 体力+5";
}
else if (x == 3){
cout << "皇家口粮" << endl;
cout << "珍贵的食物 food+60 san-5 hp+10";
}
else if (x == 4){
cout << "火盐" << endl;
cout << "投掷 击退!";
}
else if (x == 5){
cout << "寂静液汁" << endl;
cout << "使用后处于安静状态中,不易被发现";
}
else if (x == 6){
cout << "滋水枪" << endl;
cout << "加入杏仁水,发射!";
}
else if (x == 7){
cout << "亚格鲁格亚果实" << endl;
cout << "恢复效果 food+5 san+5 hp+5";
}
else if (x == 8){
cout << "油腻棉花糖" << endl;
cout << "难以下咽,加点杏仁水或许好些";
}
else if (x == 9){
cout << "融化棉花糖" << endl;
cout << "美味 food+30 san+5 体力+15";
}
else if (x == 10){
cout << "一节电池" << endl;
cout << "为手电筒提供电量";
}
else if (x == 11){
cout << "层级钥匙" << endl;
cout << "切换层级";
}
else if (x == 12){
cout << "幸运豆奶" << endl;
cout << "幸运效果 san+10 food+10";
}
else if (x == 13){
cout << "现实清新剂" << endl;
cout << "恢复san值,消除悲尸循环";
}
else if (x == 14){
cout << "磨损的布袋" << endl;
cout << "收纳";
}
// ===== 新增短刀描述 =====
else if (x == 15){
cout << "短刀" << endl;
cout << "攻击!";
}
}
void sywp(int x){
wuping --;
if (x == 1){
xrs --;
food += 15;
san += 15;
hp += 5;
tili += 5;
xrssy ++;
}
else if (x == 2){
gzlr --;
food += 40;
hp += 5;
tili += 5;
}
else if (x == 3){
hjkl --;
food += 60;
san -= 5;
hp += 10;
}
else if (x == 5){
jj += rand() % 6 + 8;
sbuff[++buff] = 3;
jjyz --;
}
else if (x == 6){
if (!xrs){
wuping ++;
cout << endl;
cout << " 你没有填装物!";
Sleep(500);
}
else if (sqdy > 0){
wuping ++;
cout << endl;
cout << " 有填装物了!";
Sleep(500);
}
else {
sqdy += 5;
xrs --;
}
}
else if (x == 7){
yglgy --;
food += 5;
sbuff[++buff] = 2;
hf += 6 + rand() % 6;
}
else if (x == 8) {
if ( !xrs){
wuping ++;
cout << endl;
cout << " 你没有东西融化它!";
Sleep(500);
}
else {
xrs --;
rhmht ++;
ynmht --;
}
}
else if (x == 9){
food += 30;
san += 5;
tili += 15;
rhmht --;
}
else if (x == 10){
if (dl == 0){
dl = 100;
dc --;
}
else {
wuping ++;
cout << endl;
cout << " 手电筒还有电!";
Sleep(500);
}
}
else if (x == 11){
cjys --;
cout << endl << " 请输入层级编号 " << endl;
cout << " 0 1 2 3 4 5 6 7 8 9 A B";
char ch = _getch();
int target_level = -1;
if (ch >= '0' && ch <= '9') {
target_level = ch - '0';
}
else if (ch == 'A' || ch == 'a') {
target_level = 10;
}
else if (ch == 'B' || ch == 'b') {
target_level = 11;
}
if (target_level >= 0 && target_level <= 11){
level = target_level;
cjyscs ++;
}
if (target_level >= 0 && target_level <= 11 ){
level = target_level;
cjyscs ++;
} else {
cjys ++;
cout << endl << " 无效层级";
wuping ++;
}
Sleep(1000);
}
else if (x == 12){ // 幸运豆奶
xydn --;
food += 10;
san += 10;
xydn_buff = 8 + rand() % 3;
sbuff[++buff] = 4;
}
else if (x == 13){ // 现实清新剂
xsqqj --;
san = 120;
if (bsxh > 0){
bsxh = 0;
buff --;
}
}
else if (x == 14){
mosun_budai --;
bbrl += 10;
}
// ===== 新增短刀使用逻辑(装备)=====
else if (x == 15){
duandao --;
equip_duandao = 1; // 装备短刀
}
}
void dqwp(int x){
man = 0;
Color(0);
cout << endl << "丢弃 ";
wuping --;
if (x == 1){
cout << "一瓶杏仁水" << endl;
xrs --;
}
else if (x == 2){
cout << "一罐罐装龙肉" << endl;
gzlr --;
}
else if (x == 3){
cout << "一盒皇家口粮" << endl;
hjkl --;
}
else if (x == 4){
cout << "一块火盐" << endl;
hy --;
}
else if (x == 5){
cout << "一瓶寂静液汁" << endl;
jjyz --;
}
else if (x == 6){
cout << "一把滋水枪" << endl;
zsq --;
}
else if (x == 7){
cout << "一颗亚格鲁格亚果实" << endl;
yglgy --;
}
else if (x == 8){
cout << "一包油腻棉花糖" << endl;
ynmht --;
}
else if (x == 9){
cout << "一包融化棉花糖" << endl;
rhmht --;
}
else if (x == 10){
cout << "电池" << endl;
dc --;
}
else if (x == 11){
cout << "一把层级钥匙" << endl;
cjys --;
}
else if (x == 12){
cout << "一盒幸运豆奶" << endl;
xydn --;
}
else if (x == 13){
cout << "一瓶现实清新剂" << endl;
xsqqj --;
}
else if (x == 14){
cout << "一个磨损的布袋" << endl;
mosun_budai --;
}
// ===== 新增短刀丢弃逻辑 =====
else if (x == 15){
cout << "一把短刀" << endl;
duandao --;
equip_duandao = 0;
}
}
void beibao(){
cls();
sjcs = rand() % sjcs;
int xz = 0, xzwp, tc = 0;
if (wuping > 0) xz = 1;
while (1){
if (wuping > bbrl) man = 1;
else man = 0;
int wp = 0, zs = 0, xzwp = 0;
cout << endl;
Color(0);
cout << "背包";
if (man) cout << "已满,请丢弃或使用物品";
cout << endl;
Color(11);
cout << "------------------------------" << endl;
if (xrs > 0){
for (int i = 1; i <= xrs; i ++){
wp ++;
if (wp == xz) xzwp = 1, Color(11);
else Color(7);
if (zs + 6 > 30){
zs = 8;
cout << endl;
}
else {
zs += 8;
}
cout << "杏仁水 ";
}
}
if (gzlr > 0){
for (int i = 1; i <= gzlr; i ++){
wp ++;
if (wp == xz) xzwp = 2, Color(11);
else Color(7);
if (zs + 8 > 30){
zs = 10;
cout << endl;
}
else {
zs += 10;
}
cout << "罐装龙肉 ";
}
}
if (hjkl > 0){
for (int i = 1; i <= hjkl; i ++){
wp ++;
if (wp == xz) xzwp = 3, Color(11);
else Color(7);
if (zs + 8 > 30){
zs = 10;
cout << endl;
}
else {
zs += 10;
}
cout << "皇家口粮 ";
}
}
if (hy > 0){
for (int i = 1; i <= hy; i ++){
wp ++;
if (wp == xz) xzwp = 4, Color(11);
else Color(7);
if (zs + 4 > 30){
zs = 6;
cout << endl;
}
else {
zs += 6;
}
cout << "火盐 ";
}
}
if (jjyz > 0)
for (int i = 1; i <= jjyz; i ++){
wp ++;
if (wp == xz) xzwp = 5, Color(11);
else Color(7);
if (zs + 8 > 30){
zs = 10;
cout << endl;
}
else {
zs += 10;
}
cout << "寂静液汁 ";
}
if (zsq > 0)
for (int i = 1; i <= zsq; i ++){
wp ++;
if (wp == xz) xzwp = 6, Color(11);
else Color(7);
if (zs + 6 > 30){
zs = 8;
cout << endl;
}
else {
zs += 8;
}
cout << "滋水枪 ";
}
if (yglgy > 0)
for (int i = 1; i <= yglgy; i ++){
wp ++;
if (wp == xz) xzwp = 7, Color(11);
else Color(7);
if (zs + 14 > 30){
zs = 16;
cout << endl;
}
else {
zs += 16;
}
cout << "亚格鲁格亚果实 ";
}
if (ynmht > 0)
for (int i = 1; i <= ynmht; i ++){
wp ++;
if (wp == xz) xzwp = 8, Color(11);
else Color(7);
if (zs + 10 > 30){
zs = 12;
cout << endl;
}
else {
zs += 12;
}
cout << "油腻棉花糖 ";
}
if (rhmht > 0)
for (int i = 1; i <= rhmht; i ++){
wp ++;
if (wp == xz) xzwp = 9, Color(11);
else Color(7);
if (zs + 10 > 30){
zs = 12;
cout << endl;
}
else {
zs += 12;
}
cout << "融化棉花糖 ";
}
if (dc > 0)
for (int i = 1; i <= dc; i ++){
wp ++;
if (wp == xz) xzwp = 10, Color(11);
else Color(7);
if (zs + 4 > 30){
zs = 6;
cout << endl;
}
else {
zs += 6;
}
cout << "电池 ";
}
if (cjys > 0)
for (int i = 1; i <= cjys; i ++){
wp ++;
if (wp == xz) xzwp = 11, Color(11);
else Color(7);
if (zs + 8 > 30){
zs = 10;
cout << endl;
}
else {
zs += 10;
}
cout << "层级钥匙 ";
}
if (xydn > 0)
for (int i = 1; i <= xydn; i ++){
wp ++;
if (wp == xz) xzwp = 12, Color(11);
else Color(7);
if (zs + 8 > 30){
zs = 10;
cout << endl;
}
else {
zs += 10;
}
cout << "幸运豆奶 ";
}
if (xsqqj > 0)
for (int i = 1; i <= xsqqj; i ++){
wp ++;
if (wp == xz) xzwp = 13, Color(11);
else Color(7);
if (zs + 10 > 30){
zs = 12;
cout << endl;
}
else {
zs += 12;
}
cout << "现实清新剂 ";
}
if (mosun_budai > 0)
for (int i = 1; i <= mosun_budai; i ++){
wp ++;
if (wp == xz) xzwp = 14, Color(11);
else Color(7);
if (zs + 10 > 30){
zs = 12;
cout << endl;
}
else {
zs += 12;
}
cout << "磨损的布袋 ";
}
// ===== 新增短刀显示 =====
if (duandao > 0)
for (int i = 1; i <= duandao; i ++){
wp ++;
if (wp == xz) xzwp = 15, Color(11);
else Color(7);
if (zs + 4 > 30){
zs = 6;
cout << endl;
}
else {
zs += 6;
}
cout << "短刀 ";
}
cout << endl;
Color(11), cout << "------------------------------" << endl;
wpjj(xzwp);
cout << endl;
Color(11), cout << "------------------------------" << endl;
Color(0), cout << "装备 " << endl;
if (sdt == 1){
cout << "手电筒 " ;
cout << "电量 ";
if (dl <= 20) Color(4);
cout << dl << "% " << endl;
}
// 显示已装备的短刀
if (equip_duandao == 1){
Color(0);
cout << "短刀 " << endl;
Color(0);
}
while (1){
if(kbhit()){
char c=_getch();
if (c == 'a'){
xz --;
if (xz < 1) xz = 1;
break;
}
if (c == 'd' && xz < wuping){
xz ++;
if (xz > wuping) xz = wuping;
break;
}
if (c == 'q' && !man){
tc = 1;
break;
}
if (c == ' '){
sywp(xzwp);
xz --;
if (xz < 1) xz = 1;
break;
}
if (c == 'p'){
dqwp(xzwp);
xz --;
if (xz < 1) xz = 1;
break;
}
}
}
cls();
if (tc == 1) break;
}
return ;
}
void qhcj(){
cls();
cout << endl << endl;
int yl = level;
while (yl == level) level = rand() % 12;
cout << endl;
Color(0);
cout << " 你切入了";
cengji();
Sleep(1500);
cls();
}
void tsyy(){
int sj;
sjcs ++;
int k = max((sjcs + 11) % 24, 1);
for (int i = 1; i <= k; i ++) sj = rand() % 78;
if (sj <= 14 || sj >= 72) cout << "继续探索这里" << endl;
else if (sj > 14 && sj <= 31) cout << "向四处走走" << endl;
else if (sj > 31 && sj <= 56) cout << "碰碰运气,搜寻一番" << endl;
else cout << "环顾四周,继续探索" << endl;
}
void xxyy(){
int sj;
sjcs ++;
int k = max((sjcs + 11) % 24, 1);
for (int i = 1; i <= k; i ++) sj = rand() % 78;
if (sj <= 14 || sj >= 63) cout << "探索很久了,歇歇吧" << endl;
else if (sj > 14 && sj <= 31) cout << "休息一会" << endl;
else cout << "找处安静地休息" << endl;
}
void xzyy(){
int sj;
sjcs ++;
int k = max((sjcs + 11) % 24, 1);
for (int i = 1; i <= k; i ++) sj = rand() % 78;
if (sj <= 14 || sj >= 63) cout << "想办法离开这儿" << endl;
else if (sj > 14 && sj <= 31) cout << "寻找层级出口" << endl;
else cout << "尝试离开这里" << endl;
}
void mysh(){
int sj;
sjcs ++;
int k = max((sjcs + 11) % 24, 1);
for (int i = 1; i <= k; i ++) sj = rand() % 78;
if (sj <= 14 || sj >= 63) cout << " 嗯..没有任何收获" << endl;
else if (sj > 14 && sj <= 31) cout << " 没有任何结果.." << endl;
else cout << " 空手而回.." << endl;
}
void ckdf(){
if (level == 0){
int sj = rand() % 3;
if (sj == 0) cout << "一个通风管道口";
else if (sj == 1) cout << "一面墙";
else cout << "一扇玻璃门";
}
else if (level == 1){
int sj = rand() % 3;
if (sj == 0) cout << "一扇门";
else if (sj == 1) cout << "一段阶梯";
else cout << "一面带有排水口的墙体";
}
else if (level == 2){
int sj = rand() % 3;
if (sj == 0) cout << "一条廊道";
else if (sj == 1) cout << "一扇金色大门";
else cout << "一个消防出口";
}
else if (level == 3){
int sj = rand() % 3;
if (sj == 0) cout << "一扇标有记号的门";
else if (sj == 1) cout << "一个破旧机器";
else cout << "一条走道";
}
else if (level == 4){
int sj = rand() % 3;
if (sj == 0) cout << "一扇活板门";
else if (sj == 1) cout << "一个天花板门";
else cout << "一个小房间";
}
else if (level == 5){
int sj = rand() % 3;
if (sj == 0) cout << "一扇黑暗的门";
else if (sj == 1) cout << "一条异常宽敞的走廊";
else cout << "一面中式风格的墙";
}
else if (level == 6){
int sj = rand() % 3;
if (sj == 0) cout << "一个楼梯井";
else if (sj == 1) cout << "一个门径";
else cout << "一扇巨大铁门";
}
else if (level == 7){
int sj = rand() % 2;
if (sj == 0) cout << "一个岩洞";
else if (sj == 1) cout << "一条笔直的路";
}
else if (level == 8){
int sj = rand() % 3;
if (sj == 0) cout << "一个通风管道";
else if (sj == 1) cout << "一个焦油坑";
else cout << "一个狭窄的隧道";
}
else if (level == 9){
int sj = rand() % 3;
if (sj == 0) cout << "一片田地";
else if (sj == 1) cout << "一片草地";
else cout << "一栋房子";
}
else if (level == 10){
int sj = rand() % 2;
if (sj == 0) cout << "一条小径";
else if (sj == 1) cout << "一片芥花籽";
}
else if (level == 11){
int sj = rand() % 3;
if (sj == 0) cout << "一片灌木丛";
else if (sj == 1) cout << "一个游戏厅";
else cout << "一所房子外表奇形怪的医院";
}
}
int xzcksh(){
cout << endl;
Color(0);
int sj = rand() % 100, zd = 0;
if (sj % 12 == 0 ) zd = 1;
if (zd == 1){
cout << "你发现了"; ckdf(); cout << endl;
return 1;
}
else {
int sj;
sjcs ++;
int k = max((sjcs + 11) % 24, 1);
for (int i = 1; i <= k; i ++) sj = rand() % 78;
if (sj <= 34 || sj >= 63) cout << " 好吧,这很难." << endl;
else cout << " 什么都没发现" << endl;
return 0;
}
}
void fxdf(){
if (level == 0){
int k = rand() % 2;
if (k == 0) cout << "地板上";
else cout << "墙角边";
}
else if (level == 1){
int k = rand() % 4;
if (k == 0) cout << "板条箱里";
else if (k == 1) cout << "地板上";
else if (k == 2) cout << "墙角";
else cout << "柱子边" ;
}
else if (level == 2){
int k = rand() % 4;
if (k == 0) cout << "电箱上";
else if (k == 1) cout << "地板上";
else if (k == 2) cout << "墙边";
else cout << "管道上" ;
}
else if (level == 3){
int k = rand() % 4;
if (k == 0) cout << "隧道里";
else if (k == 1) cout << "地板上";
else if (k == 2) cout << "墙边";
else cout << "机器上" ;
}
else if (level == 4){
int k = rand() % 4;
if (k == 0) cout << "办公桌上";
else if (k == 1) cout << "地板上";
else if (k == 2) cout << "墙边";
else cout << "椅子上" ;
}
else if (level == 5){
int k = rand() % 4;
if (k == 0) cout << "椅子上";
else if (k == 1) cout << "地毯上";
else if (k == 2) cout << "墙角";
else cout << "餐桌上" ;
}
else if (level == 6 || level == 8){
cout << "黑暗中";
}
else if (level == 7){
int k = rand() % 2;
if (k == 0) cout << "海面上";
else cout << "房间里";
}
else if (level == 9){
int k = rand() % 4;
if (k == 0) cout << "路灯下";
else if (k == 1) cout << "街道上";
else if (k == 2) cout << "房子内";
else cout << "田地边" ;
}
else if (level == 10){
int k = rand() % 4;
if (k == 0) cout << "田里";
else if (k == 1) cout << "仓库里";
else if (k == 2) cout << "湖边";
else cout << "门阶上" ;
}
else if (level == 11){
int k = rand() % 4;
if (k == 0) cout << "车上";
else if (k == 1) cout << "马路上";
else if (k == 2) cout << "草地上";
else cout << "房子边" ;
}
}
void ysh(){
int sj;
sjcs ++;
int k = max((sjcs + 11) % 24, 1);
Color(0);
wuping ++;
cout << "你在";
fxdf();
cout << "发现了 ";
for (int i = 1; i <= k; i ++) sj = rand() % 1200;
// ========== 概率等级1(3%):层级钥匙(分散为2个区间) ==========
if ((sj >= 0 && sj <= 14) || (sj >= 800 && sj <= 814)) {
cout << "一把层级钥匙" << endl;
cjys ++;
}
// ========== 概率等级2(5%):磨损的布袋(分散为2个区间) ==========
else if ((sj >= 15 && sj <= 40) || (sj >= 815 && sj <= 829)) {
cout << "一个磨损的布袋" << endl;
bd ++;
mosun_budai ++;
}
// ========== 概率等级2(5%):现实清新剂(分散为2个区间) ==========
else if ((sj >= 45 && sj <= 74) || (sj >= 830 && sj <= 844)) {
cout << "一瓶现实清新剂" << endl;
xsqqj ++;
}
// ========== 概率等级3(6%):滋水枪(分散为3个区间) ==========
else if ((sj >= 75 && sj <= 94) || (sj >= 845 && sj <= 864) || (sj >= 950 && sj <= 959)) {
cout << "一把滋水枪" << endl;
zsq ++;
}
// ========== 概率等级3(6%):皇家口粮(分散为3个区间) ==========
else if ((sj >= 95 && sj <= 118) || (sj >= 865 && sj <= 888) || (sj >= 960 && sj <= 969)) {
cout << "一盒皇家口粮" << endl;
hjkl ++;
}
// ========== 概率等级3(6%):电池/手电筒(分散为3个区间) ==========
else if ((sj >= 115 && sj <= 134) || (sj >= 885 && sj <= 904) || (sj >= 970 && sj <= 979)) {
if (sdt == 0) {
cout << "一个手电筒" << endl;
sdt = 1;
dl = max(rand() % 101, 20);
} else {
cout << "一节电池" << endl;
dc ++;
}
}
// ========== 概率等级4(8%):火盐(分散为4个区间) ==========
else if ((sj >= 135 && sj <= 154) || (sj >= 300 && sj <= 319) || (sj >= 450 && sj <= 469) || (sj >= 600 && sj <= 619)) {
cout << "一小块火盐" << endl;
hy ++;
}
// ========== 概率等级4(8%):寂静液汁(分散为4个区间) ==========
else if ((sj >= 155 && sj <= 174) || (sj >= 320 && sj <= 339) || (sj >= 470 && sj <= 489) || (sj >= 620 && sj <= 639)) {
cout << "一瓶寂静液汁" << endl;
jjyz ++;
}
// ========== 概率等级4(8%):幸运豆奶(分散为4个区间) ==========
else if ((sj >= 175 && sj <= 194) || (sj >= 340 && sj <= 359) || (sj >= 490 && sj <= 509) || (sj >= 640 && sj <= 659)) {
cout << "一盒幸运豆奶" << endl;
xydn ++;
}
// ========== 概率等级4(8%):油腻棉花糖(分散为4个区间) ==========
else if ((sj >= 195 && sj <= 214) || (sj >= 360 && sj <= 379) || (sj >= 510 && sj <= 529) || (sj >= 660 && sj <= 679)) {
cout << "一包油腻棉花糖" << endl;
ynmht ++;
}
// ========== 概率等级5(10%):亚格鲁格亚果实(分散为5个区间) ==========
else if ((sj >= 215 && sj <= 234) || (sj >= 380 && sj <= 399) || (sj >= 530 && sj <= 549) || (sj >= 680 && sj <= 699) || (sj >= 750 && sj <= 769)) {
cout << "一颗亚格鲁格亚果" << endl;
yglgy ++;
}
// ========== 概率等级5(8%):罐装龙肉(分散为4个区间) ==========
else if ((sj >= 230 && sj <= 259) || (sj >= 400 && sj <= 419) || (sj >= 550 && sj <= 569) || (sj >= 700 && sj <= 719)) {
cout << "一罐罐装龙肉" << endl;
gzlr ++;
}
// ========== 新增:短刀(4%概率,分散为2个区间) ==========
else if ((sj >= 260 && sj <= 299) || (sj >= 720 && sj <= 749) && (!duandao || !equip_duandao) ) {
cout << "一把短刀" << endl;
duandao ++;
}
// ========== 概率等级5(23%):杏仁水(大幅提升,分散补充所有剩余区间) ==========
else {
cout << "一瓶杏仁水" << endl;
xrs ++;
}
}
int tssh(){
int total_range = 1000;
int sj = rand() % total_range;
int has_item = 0;
if (sj == 234 || sj == 567 || sj == 345 || sj == 456 || sj == 678 && swfecj == 0){
cout << " 你遇到了一只死亡飞蛾" << endl;
cout << " e 洒杏仁水 p 离开" << endl;
while (1){
if (kbhit()){
char c=_getch();
if (c == 'e') {
int sj = rand() % 5;
if (sj >= 3) {
cout << " 你驯服了死亡飞蛾" << endl;
swfecj = 1;
cj(6);
}
else {
cout << " 死亡飞蛾离开了" << endl;
}
Sleep(1200);
return 0;
}
else return 0;
}
}
}
if (level == 0) {
// (22%概率):分散为3个区间
if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 729)) {
has_item = 1;
}
}
else if (level == 1) {
// (35%概率):分散为3个区间
if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799) || (sj >= 800 && sj <= 849)) {
has_item = 1;
}
}
else if (level == 2 || level == 6 || level == 8) {
// (18%概率):分散为2个区间
if ((sj >= 200 && sj <= 299) || (sj >= 500 && sj <= 579)) {
has_item = 1;
}
}
else if (level == 3 || level == 7 || level == 9) {
// (20%概率):分散为2个区间
if ((sj >= 200 && sj <= 299) || (sj >= 500 && sj <= 599)) {
has_item = 1;
}
}
else if (level == 4) {
// (30%概率):分散为3个区间
if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799)) {
has_item = 1;
}
}
else if (level == 5 ) {
// (37%概率):分散为3个区间
if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799) || (sj >= 800 && sj <= 869)) {
has_item = 1;
}
}
else if (level == 10 || level == 11) {
// (60%概率):分散为3个区间
if ((sj >= 200 && sj <= 239) || (sj >= 500 && sj <= 599) || (sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799) || (sj >= 800 && sj <= 869)) {
has_item = 1;
}
}
if (xydn_buff > 0 && sj >= 700) has_item = 1;
if (dl > 0 && sj >= 800) has_item = 1;
return has_item;
}
void sw(int x){
cls();
cout << endl << endl;
Color(4);
cout << " YOU DEAD" << endl;
cout << endl;
cout << " reason: ";
Color(7);
if (x == 1){
cout << "悲尸循环";
}
else if (x == 2){
cout << "饥饿";
}
else if (x == 3){
cout << "实体攻击";
}
else if (x == 4){
cout << "恐惧";
}
Sleep(1800);
exit(0);
}
int taotuo(int x){
int cg = 0, sj = rand() % 200;
if(x==1 && ((sj>=10&&sj<=29)||(sj>=80&&sj<=99))) cg=1; // 40/200=20%
if(x==2 && ((sj>=5&&sj<=24)||(sj>=50&&sj<=99))) cg=1; // 80/200=40%
if(x==3 && ((sj>=0&&sj<=39)||(sj>=60&&sj<=139))) cg=1; // 110/200=55%
if(x==4 && ((sj>=2&&sj<=71)||(sj>=90&&sj<=189))) cg=1; // 150/200=75%
if(x==5 && ((sj>=5&&sj<=24)||(sj>=50&&sj<=99))) cg=1; // 150/200=75%
return cg;
}
void guaiwu(){
st = 1;
int gw;
cls();
int sj = rand() % 200;
if ((sj >= 34 && sj <= 38 || sj >= 140 && sj <= 148 || sj >= 88 && sj <= 93)
|| (dl == 0 && sj >= 111 && sj <= 113)) gw = 1;//笑魇
else if(sj >= 41 && sj <= 49 || sj >= 21 && sj <= 28 ) gw = 2;//死亡飞蛾
else if(sj >= 160 && sj <= 167 || sj >= 189 && sj <= 194
|| sj >= 127 && sj <= 130) gw = 3;// 窃皮者
else if(sj >= 190 && sj <= 195 || sj >= 30 && sj <= 33
|| sj >= 100 && sj <= 108) gw = 4;// 钝人
else if(sj >= 63 && sj <= 68 || sj >= 151 && sj <= 158
|| sj >= 177 && sj <= 181) gw = 5;//肢团
else if(sj >= 69 && sj <= 73 || sj >= 168 && sj <= 170) gw = 6;//悲尸
if (level == 7 && sj >= 130) gw = 8;
else gw = 7;//猎犬
int xh = 0;
while (xh <= 460000){
cls();
san -= rand() % 9;
Color(8);
cout << "______________________________" << endl;
cout << "▉◢!◢◢◢!◢◢◢!◢◢◢!◢◢◢!◢◢◢!◢◢◢!◢◢▉" << endl;
cout << "正在遭遇 ";
Color(0);
if (gw == 1) cout << "笑魇", hp -= max(rand() % 18, 14);
else if (gw == 2) cout << "死亡飞蛾", hp -= max(rand() % 13, 10);
else if (gw == 3) cout << "窃皮者", hp -= max(rand() % 16, 12);
else if (gw == 4) cout << "钝人", hp -= max(rand() % 16, 10);
else if (gw == 5) cout << "肢团", hp -= max(rand() % 14, 12);
else if (gw == 6) cout << "悲尸", hp -= max(rand() % 15, 9);
else if (gw == 7) cout << "猎犬", hp -= max(rand() % 15, 9);
else if (gw == 8) cout << "小小", hp -= max(rand() % 16, 10);
cout << endl;
Color(8);
cout << "______________________________" << endl;
Color(0);
cout << "HP ";
if (hp > 20) Color(0);
else Color(4);
cout << hp << " ";
if (hp < 100) cout << " ";
if (hp < 10) cout << " ";
Color(0);
cout << "FOOD ";
if (food > 20) Color(0);
else Color(4);
cout << food << " ";
if (food < 100) cout << " ";
if (food < 10) cout << " ";
Color(0);
cout << "SAN ";
if (san > 20) Color(0);
else Color(4);
cout << san << " ";
if (san < 100) cout << " ";
if (san < 10) cout << " ";//基础数值
cout << endl;
Color(8);
cout << " ○ z 逃跑" << endl;
if (xrs > 0) cout << " ○ x 洒杏仁水" << endl;
if (hy > 0) cout << " ○ c 扔出火盐" << endl;
if (sqdy > 0) cout << " ○ v 滋水枪喷水" << endl;
if (equip_duandao > 0) cout << " ○ b 短刀攻击" << endl;
int u = 0, tt = 0;
while (1){
if (hp <= 0) {
sw(3);
}
if(kbhit()){
char c=_getch();
if (c == 'z') tt = 1;
else if (c == 'c' && hy > 0) tt = 2, hy --, hp += rand() % 3;
else if (c == 'x' && xrs > 0) tt = 3, xrs --, hp += 3 + rand() % 4;
else if (c == 'v' && sqdy > 0) tt = 4, sqdy --, hp += 6 + rand() % 5;
else if (c == 'b' && equip_duandao > 0) tt = 5, hp += 4 + rand() % 5;
if (tt > 0){
if (taotuo(tt)) {
ttcg ++;
return ;
}
else break;
}
}
}
}
}
void tradeSystem() {
cls();
srand((unsigned int)time(NULL)); // 初始化随机数
int trade_exit = 0;
int select_mode = 1; // 1=购买模式,2=出售模式
int select_item = 1;
// 物品核心信息(价值、背包指针、是否为装备、是否可作为奖励)
struct ItemInfo {
int id;
double value; // 单位价值(杏仁水=1)
string name;
int* count; // 指向背包物品数量的指针
bool is_equip; // 是否为装备
bool can_get; // 是否可作为售卖奖励
};
// 物品列表(严格按你指定的价值配置)
vector<ItemInfo> items = {
{1, 1.0, "杏仁水", &xrs, false, true},
{2, 4.0, "皇家口粮", &hjkl, false, true},
{3, 2.5, "寂静液汁", &jjyz, false, true},
{4, 8.0, "层级钥匙", &cjys, false, true},
{5, 3.0, "现实清新剂", &xsqqj, false, false},
{6, 4.0, "磨损布袋", &mosun_budai, false, false},
{7, 3.0, "罐装龙肉", &gzlr, false, true},
{8, 1.5, "幸运豆奶", &xydn, false, true},
{9, 1.5, "火盐", &hy, false, true},
{10, 2.0, "油腻棉花糖", &ynmht, false, true},
{12, 1.0, "电池", &dc, false, true},
{13, 8.0, "滋水枪", &zsq, false, true},
{14, 2.0, "亚格鲁格亚果实", &yglgy, false, true},
{15, 10.0, "短刀", &duandao, true, false} // 装备(无限制售卖)
};
// 购买物品配置
struct BuyItem { int id; string name; int cost; int num; };
vector<BuyItem> buy_list = {
{2,"皇家口粮",4,1}, {3,"寂静液汁",3,1}, {4,"层级钥匙",9,1},
{5,"现实清新剂",3,1}, {6,"磨损布袋",5,1}, {7,"罐装龙肉",5,2},
{8,"幸运豆奶",2,1}, {9,"火盐",1,1}, {12,"电池",2,3},
{10,"油腻棉花糖",3,2}, {14,"亚格鲁格亚果实",2,1}
};
while (!trade_exit) {
cls();
// 界面头部
Color(11); cout << "======= 交易市场 =======\n";
Color(7); cout << "杏仁水: " << xrs << "\n";
cout << "========================\n";
// 模式选择
Color(select_mode==1?2:7); cout << "[1] 购买\n";
Color(select_mode==2?2:7); cout << "[2] 出售\n";
Color(11); cout << "========================\n";
if (select_mode == 1) {
// 购买模式:显示可购买物品
Color(7); cout << "【可购买】\n";
for (int i=0; i<buy_list.size(); i++) {
if (i+1 == select_item) Color(2); else Color(7);
cout << "[" << i+1 << "]" << buy_list[i].name
<< " 价格:" << buy_list[i].cost << " 获得:" << buy_list[i].num << "\n";
}
} else {
// 出售模式:仅过滤 数量>0 + 不是杏仁水(装备无限制)
Color(7); cout << "【可出售】\n";
vector<ItemInfo> sellable;
for (auto& it : items) {
if (*it.count <= 0) continue; // 数量为0的物品不显示
if (it.id == 1) continue; // 杏仁水禁止售卖
sellable.push_back(it); // 所有装备都加入可售卖列表
}
if (sellable.empty()) {
Color(4); cout << " 没有可出售物品\n"; Color(7);
} else {
// 遍历可售卖物品,选中时显示预计获得的物品
for (int i=0; i<sellable.size(); i++) {
ItemInfo& item = sellable[i];
if (i+1 == select_item) {
Color(2);
cout << "[" << i+1 << "]" << item.name << " ×" << *item.count << "\n";
Color(10); // 浅绿色显示预计奖励
// 提前计算选中物品卖出后会获得的物品(仅显示,不执行)
vector<ItemInfo> rewards;
for (auto& it : items) if (it.can_get) rewards.push_back(it);
int r = rand()%rewards.size();
ItemInfo& get_item = rewards[r];
// 计算价值(控制差值≤1.5)
double base_value = item.value;
// 波动范围:base_value-1.5 ~ base_value+1.5,且不低于0.1
double min_total = max(base_value - 1.5, 0.1);
double max_total = base_value + 1.5;
double total = min_total + (rand() % (int)((max_total - min_total)*100))/100.0;
int cnt = max((int)(total / get_item.value), 1); // 至少1个
cout << " → 卖出可获得:" << cnt << "个" << get_item.name << "\n";
Color(7);
} else {
Color(7);
cout << "[" << i+1 << "]" << item.name << " ×" << *item.count << "\n";
}
}
}
}
// 操作提示
Color(7);
cout << "========================\n";
cout << "W上 S下|A买 D卖|空格确认|Q退出\n";
// 处理用户输入
while (true) {
if (!_kbhit()) continue;
char op = _getch();
// 预筛选可售卖物品(用于上下选择逻辑)
vector<ItemInfo> sellable;
for (auto& it : items) {
if (*it.count <=0 || it.id ==1) continue;
sellable.push_back(it);
}
// 上下选择物品
if (op == 'w' || op == 'W') {
select_item = max(1, select_item-1); break;
}
if (op == 's' || op == 'S') {
if (select_mode ==1) select_item = min((int)buy_list.size(), select_item+1);
else select_item = min((int)sellable.size(), select_item+1);
break;
}
// 切换模式
if (op == 'a' || op == 'A') { select_mode=1; select_item=1; break; }
if (op == 'd' || op == 'D') { select_mode=2; select_item=1; break; }
// 空格确认(购买/出售)
if (op == ' ') {
if (select_mode ==1) {
// 购买逻辑(保持不变)
if (select_item <1 || select_item > buy_list.size()) break;
auto& b = buy_list[select_item-1];
if (xrs >= b.cost) {
xrs -= b.cost;
for (auto& it : items) if (it.id == b.id) *it.count += b.num;
wuping += b.num;
Color(2); cout << "\n购买成功!\n"; Sleep(1200);
} else { Color(4); cout << "\n杏仁水不足\n"; Sleep(800); }
} else {
// 出售逻辑(控制价值差值≤1.5)
if (sellable.empty()) { Color(4); cout << "\n无可出售\n"; Sleep(800); break; }
if (select_item <1 || select_item > sellable.size()) break;
auto& sold = sellable[select_item-1];
*sold.count -=1; // 直接减少物品数量
wuping -=1;
// 筛选可作为奖励的物品
vector<ItemInfo> rewards;
for (auto& it : items) if (it.can_get) rewards.push_back(it);
int r = rand()%rewards.size();
auto& get = rewards[r];
// 核心:控制价值差值≤1.5
double base_value = sold.value;
double min_total = max(base_value - 1.5, 0.1); // 最低价值0.1,避免负数
double max_total = base_value + 1.5;
double total = min_total + (rand() % (int)((max_total - min_total)*100))/100.0;
int cnt = max((int)(total / get.value), 1); // 至少获得1个
// 确保最终差值不超过1.5(兜底校验)
double actual_diff = abs(total - base_value);
if (actual_diff > 1.5) {
total = base_value + (rand()%2==0 ? 1.5 : -1.5);
cnt = max((int)(total / get.value), 1);
}
*get.count += cnt;
wuping += cnt;
// 提示售卖结果(不显示价值)
Color(2);
cout << "\n出售成功!\n";
Color(7);
cout << "卖出:" << sold.name << "\n";
cout << "获得:" << cnt << "个" << get.name << "\n";
Sleep(1800);
}
break;
}
// Q退出交易
if (op == 'q' || op == 'Q') { trade_exit=1; break; }
}
}
cls();
}
bool check_entity_spawn() {
int total_range = 1000;
int sj = rand() % total_range;
int spawn = 0;
int entity_level = 0;
if (level == 0 || level == 5 || level == 4) entity_level = 0; // 0级 - 0%
else if (level == 1 || level == 11) entity_level = 1; // 1级 - 3%
else if (level == 2) entity_level = 2; // 2级 - 6%
else if (level == 3 || level == 7) entity_level = 3;
else if (level == 8) entity_level = 4;
else if (level == 9) entity_level = 5;
switch(entity_level) {
case 0:
spawn = 0;
break;
case 1:
if ((sj >= 10 && sj <= 19) ||
(sj >= 210 && sj <= 219) ||
(sj >= 410 && sj <= 419)) {
spawn = 1;
}
break;
case 2: // 2级 - 6% 概率(4个分散区间,总计60个值)
if ((sj >= 20 && sj <= 34) ||
(sj >= 220 && sj <= 234) ||
(sj >= 420 && sj <= 434) ||
(sj >= 620 && sj <= 634)) {
spawn = 1;
}
break;
case 3: // 3级 - 9% 概率(5个分散区间,总计90个值)
if ((sj >= 35 && sj <= 52) ||
(sj >= 235 && sj <= 252) ||
(sj >= 435 && sj <= 452) ||
(sj >= 635 && sj <= 652) ||
(sj >= 835 && sj <= 852)) {
spawn = 1;
}
break;
case 4: // 4级 - 12% 概率(6个分散区间,总计120个值)
// 区间1: 53-72 (20个) + 区间2: 253-272 (20个) + 区间3: 453-472 (20个) + 区间4: 653-672 (20个) + 区间5: 853-872 (20个) + 区间6: 953-972 (20个)
if ((sj >= 53 && sj <= 72) ||
(sj >= 253 && sj <= 272) ||
(sj >= 453 && sj <= 472) ||
(sj >= 653 && sj <= 672) ||
(sj >= 853 && sj <= 872) ||
(sj >= 953 && sj <= 972)) {
spawn = 1;
}
break;
case 5: // 5级 - 15% 概率(7个分散区间,总计147个值)
if ((sj >= 73 && sj <= 93) ||
(sj >= 173 && sj <= 193) ||
(sj >= 273 && sj <= 293) ||
(sj >= 473 && sj <= 493) ||
(sj >= 673 && sj <= 693) ||
(sj >= 873 && sj <= 893) ||
(sj >= 973 && sj <= 993)) {
spawn = 1;
}
break;
}
return spawn == 1;
}
int main(){
srand((unsigned)time(NULL));
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
// ============== 修复:安全读档(先判断文件是否存在)==============
ifstream f("save.dat", ios::binary);
if (f.is_open()) {
f.read((char*)&xrscj, sizeof(xrscj))
.read((char*)&scj, sizeof(scj))
.read((char*)&sc, sizeof(sc))
.read((char*)&llz, sizeof(llz))
.read((char*)&ffht, sizeof(ffht))
.read((char*)&bd, sizeof(bd))
.read((char*)&cjyscs, sizeof(cjyscs))
.read((char*)&xrssy, sizeof(xrssy))
.read((char*)&LL, sizeof(LL))
.read((char*)&ttcg, sizeof(ttcg))
.read((char*)&swfecj, sizeof(swfecj))
.read((char*)&yqlyy, sizeof(yqlyy));
f.close();
} else {
// 文件不存在,初始化所有成就/计数变量
xrscj = 0;
scj = 0;
sc = 0;
llz = 0;
ffht = 0;
bd = 0;
cjyscs = 0;
xrssy = 0;
LL = 0;
ttcg = 0;
}
ksfm();
cls();
xd = 1;
wuzi[0] = 1;
shiti[1] = 1;
wuzi[1] = 2;
shiti[2] = 2;
wuzi[2] = -1;
shiti[3] = 3;
shiti[7] = shiti[8] = shiti[9] = shiti[11] = 3;
while (1){
kscd();
while (1){
int tc = 0, ymy = 0;
cls();
L[level] ++;
LL += (L[level] == 1);
if (LL == 12 && llz == 0) LL ++, llz = 1, cj(1), ymy = 1;
if (cjyscs == 4 && ffht == 0) ffht = 1, cj(2), ymy = 1;
if (ttcg == 15 && sc == 0) sc = 1, cj(3), ymy = 1;
if (xrssy == 31 && xrscj == 0) xrscj = 1, cj(4), ymy = 1;
if (bd == 5 && scj == 0) scj = 1, cj(5), ymy = 1;
if (swfecj == 1) swfecj = 2, ymy = 1;
if (ts = 101 && yqlyy == 0)yqlyy = 1, ymy = 1;
if (ymy){
ifstream f("save.dat",ios::binary);
if (f.is_open()) { // 新增:检查文件是否打开
f.read((char*)&xrscj, sizeof(xrscj))
.read((char*)&scj, sizeof(scj))
.read((char*)&sc, sizeof(sc))
.read((char*)&llz, sizeof(llz))
.read((char*)&ffht, sizeof(ffht))
.read((char*)&bd, sizeof(bd))
.read((char*)&cjyscs, sizeof(cjyscs))
.read((char*)&xrssy, sizeof(xrssy))
.read((char*)&LL, sizeof(LL))
.read((char*)&ttcg, sizeof(ttcg))
.read((char*)&swfecj, sizeof(swfecj))
.read((char*)&yqlyy, sizeof(yqlyy));
f.close(); // 新增:关闭文件
} else {
// 初始化成就相关变量为默认值
xrscj = 0, scj = 0, sc = 0, llz = 0, ffht = 0;
bd = 0, cjyscs = 0, xrssy = 0, LL = 0, ttcg = 0, yqlyy = 0;
}
}
if (level != 2) dz = 0;
int ssj = rand() % 200;
if (ssj >= 30 && ssj <= 32 || ssj >= 150 && ssj <= 153 || ((level == 8 || level == 9 || level == 3 || level == 10 || level == 11)&& (ssj >= 60 && ssj <= 63 || ssj >= 160 && ssj <= 161))) qhcj();
if (level == 2){
int sj = rand() % 200;
if (sj >= 12 && sj <= 15 || sj >= 120 && sj <= 122){
cls();
dz = 7;
}
}
int nd = shiti[level];
if (shiti[level] != 0) {
int my = 0;
int ssj = rand() % 90;
if (jj > 0 && ssj >= 68) {
my = 1;
}
if (!my && check_entity_spawn()) {
guaiwu();
cls();
st = 0;
}
else if (!my && dz > 0 && check_entity_spawn()) {
guaiwu();
cls();
st = 0;
}
}
if (sdt) dl = max(0, dl - 1);
sjcs ++;
// 幸运豆奶buff
if (xydn_buff > 0) {
xydn_buff --;
if (xydn_buff == 0) buff --;
}
//恐惧buff
if (kj > 0){
buff ++;
kj --;
san -= rand() % 4;
if (kj == 0) buff --;
}
if (level == 6 || level == 8){
buff ++;
ha = 1;
san -= rand() % 2;
}
else if (ha == 1)buff --, ha = 0;
if (food == 0) hp -= rand() % 3;
if (!xd) food -= rand() % 2, san -= rand() % 3, san += rand() % 2, tili -= rand() % 2, tili += rand() % 2;
if (hf){
hf --;
hp += rand() % 6;
if (hf == 0) buff --;
}
if (jj){
jj --;
if (jj == 0) buff --;
}
if (bsxh) san -= rand() % 2, bsxh --;
if (1000 - bsxh >= 16 && bsxh > 0){
sw(1);
}
if ((san <= 30 ) || (san <= 40 && level == 4)&& !bsxh){
int sj = rand() % 100;
if(sj % 12 == 0 || (san <= 20 && sj % 9 == 0)){
bsxh = 1000;
buff ++;
}
}
if (san >= 30 && bsxh > 0){
int sj = rand() % 100;
if(sj % 12 == 0 || (san <= 20 && sj % 19 == 0)){
buff --;
bsxh = 0;
}
else if (san >= 45 && sj >= 56 && sj <= 59 || sj == 82){
buff --;
bsxh = 0;
}
else if (san >= 60 &&( sj >= 130 && sj <= 141 || sj >= 33 && sj <= 37)){
buff --;
bsxh = 0;
}
else if (san >= 80){
buff --;
bsxh = 0;
}
}
if((level == 5 || level == 7 )&& dl == 0 && tili < 40){
int sj = rand() % 200;
if (sj >= 130 && sj <= 140 || sj >= 170 && sj <= 180 || sj >= 50 && sj <= 55){
if (kj == 0) kj += 4;
if (kj > 0) kj += rand() % 2 + 1;
}
}
tili = min(tili, 120);
tili = max(tili, 0);
hp = min(hp, 120);
hp = max(hp, 0);
food = min(food, 120);
food = max(food, 0);
san = min(san, 120);
san = max(san, 0);
if (food == 0) hp -= rand() % 3;
xd = 0;
if (food == 0 && hp == 0) sw(2);
cout << endl;
cout << " ";
cengji();
cout << endl;
if (dz > 0){
dz --;
Color(6);
cout << "地震 -实体频出" << endl;
}
fenjie1();
cout << endl;//层级及分界
if (food == 0) hp -= rand() % 3;
if (hp <= 0 && food == 0) {
sw(2);
}
zhuangtai();
Color(0);
cout << "HP ";
if (hp > 20) Color(0);
else Color(4);
cout << hp << " ";
if (hp < 100) cout << " ";
if (hp < 10) cout << " ";
Color(0);
cout << "FOOD ";
if (food > 20) Color(0);
else Color(4);
cout << food << " ";
if (food < 100) cout << " ";
if (food < 10) cout << " ";
Color(0);
cout << "SAN ";
if (san > 20) Color(0);
else Color(4);
cout << san << " ";
if (san < 100) cout << " ";
if (san < 10) cout << " ";//基础数值
cout << endl;
fenjie2();
cout << endl;//分界
Color(0);
cout << "BUFF ";
if (buff == 0) cout << "--";
else {
Buff();
// 显示幸运豆奶buff
if (xydn_buff > 0) {
Color(6);
cout << " 幸运 ";
}
if (kj > 0){
Color(8);
cout << "恐惧 ";
}
if (ha > 0){
Color(7);
cout << "黑暗 ";
}
if (level == 8){
Color(11);
cout << "流逝 ";
hp -= rand() % 2;
san -= rand() % 2;
tili -= rand() % 2;
}
}//BUFF
cout << endl;
Color(0), cout << "体力 " << tili;
cout << endl;
fenjie2();
cout << endl;//分界
if (!st){
Color(0);
cout << "我可以.." << endl;
cout << " ○ 1 ";
tsyy();
cout << " ○ 2 ";
xxyy();
cout << " ○ 3 ";
xzyy();
if (level == 11){
cout << " ○ 4 交易 ";
cout << endl;
}
}
long long xhcs = 0;
while(++ xhcs < 50000){
if(kbhit()){
char c=_getch();
if(c=='e'){
beibao();
break;
}
if(c=='1' && tili) {
cout << endl;
Color(11);
cout << " 搜寻中";
Say("...", rand() % 600 + 400);
cout << endl;
tili -= rand() % 6;
food -= rand() % 7;
san -= rand() % 6;
hp -= rand() % 2;
xd = 1;
int sh = tssh();
if (sh == 0){
mysh();
Sleep(500);
}
else{
ysh();
Sleep(600);
if (wuping > bbrl) {
man = 1;
beibao();
}
}
break;
}
if(c=='2') {
hp += rand() % 2;
san += rand() % 10;
tili += rand() % 17;
food -= rand() % 5;
xd = 1;
Color(11);
cout << " 休息中";
Say("...", rand() % 600 + 500);
break;
}
if(c=='3' && tili){
tili -= rand() % 6;
food -= rand() % 6;
san -= rand() % 6;
hp -= rand() % 2;
xd = 1;
Color(11);
cout << " 寻找中";
Say("...", rand() % 600 + 400);
cout << endl;
if (xzcksh()){
cout << " 是否切换层级." << endl;
Color(0);
cout << " 1 是 ";
Color(0);
cout << "2 否";
while (1){
if(kbhit()){
char c=_getch();
if (c == '2') break;
if (c == '1'){
qhcj();
break;
}
}
}
}
else {
Sleep(800);
}
break;
}
if(c=='4' && level == 11){
tradeSystem(); // 调用交易系统
break;
}
if(c=='m'){
cenjijianjie();
cout << endl;
Color(7);
cout << " 空格以退出";
while (1){
if (kbhit()){
char c=_getch();
if (c == ' ') break;
}
}
cls();
break;
}
if(c=='l'){
saveGame();
break;
}
if(c=='o'){
loadGame();
break;
}
if(c=='k' || c=='K'){
clearAllData();
break;
}
if (c == 'b'){
tc = 1;
break;
}
}
}//操作
if (tc == 1) {
cls();
cout << " 1 仅退出 2 退出(重新开始)";
while (1){
if(kbhit()){
char c=_getch();
if (c == '2') {
level = san = food = hp = buff = tili = wuping = xrs = jjyz = hy = hjkl = gzlr = zsq = st = sjcs = sxz = yglgy = man = 0;
san = food = hp = tili = 120; // 初始值单独赋值
xd = 1, bbrl = 20;
ynmht = rhmht = hf = jj = sdt = dl = dc = sqdy = bsxh = kj = duandao = equip_duandao = xrscj = scj = sc = llz = ffht = dz = bd = cjyscs = xrssy = LL = ttcg = ha = cjys = xydn = xsqqj = xydn_buff = mosun_budai = 0;
memset(sbuff, 0, sizeof(sbuff));
break;
}
else break;
}
}
cls();
break;
}
ts ++;
}
cls();
}
return 0;
}