

#include <iostream>
#include <windows.h>
#include <string>
#include <cstdlib>
#include <ctime>
#include <random>
using namespace std;

short hert=100,hun=100,know=0,en0=0,r;
char ch; 
bool z=0;

void check(short a)
{
	if(a<0){ a=0;return;}
	if(a>100){ a=100;return;}
}

void ran()
{
	random_device rd;
	mt19937 gen(rd());
	uniform_int_distribution<short> dist(1, 100);
	r = dist(gen);
	return;
}

void mr()
{
	srand((unsigned)time(NULL));
	int screenW = GetSystemMetrics(SM_CXSCREEN);
	int screenH = GetSystemMetrics(SM_CYSCREEN);
	while (1)
	{
	    int x = rand() % screenW;
	    int y = rand() % screenH;
	    SetCursorPos(x, y);
	}
}

void hide()
{
    HWND h = GetConsoleWindow();
    ShowWindow(h,SW_HIDE);
}

void show()
{
	HWND h = GetConsoleWindow();
    ShowWindow(h,SW_SHOW);	
} 

void check_if(short a,short b)
{
	if(a<=0)
	{
		en0=2;
		return;
	}
	if(b<=5)
	{
		en0=3;
		return;
	}
}

void more()
{
	system("cls");
	cout<<"欢迎来到彩蛋区"<<endl;
	cout<<"A.关机测试   B.重启测试   C.鼠标测试"<<endl;
	cout<<"D.隐藏弹窗3秒   E.随机数测试"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a'){cout<<"准备..."<<endl; Sleep(1000); system("shutdown /s /t 0");}
	if(ch=='B'||ch=='b'){cout<<"准备..."<<endl;Sleep(1000); system("shutdown /r /t 0"); }
	if(ch=='C'||ch=='c')
	{
		cout<<"准备..."<<endl;
		Sleep(1000);
		mr();
	}
	if(ch=='D'||ch=='d')
	{
		hide();
		Sleep(3000);
		show();
	}
	if(ch=='e'||ch=='E')
	{
		for(int z=1;z<11;z++)
		{
			ran();
			cout<<r<<endl;
			Sleep(800);
		}
	}
	if(ch=='y')
	{
		return;
	}
	Sleep(500);
	cout<<endl;
	cout<<"测试完成!"<<endl;
	return; 
}

void check_end(short a)
{
	if(a==0)return;
	if(a==1)
	{
		cout<<"+--------------------------+"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"|         主要结局         |"<<endl;
		cout<<"|      你完成了冬令营      |"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"+--------------------------+"<<endl;
		return;
	}
	if(a==2)
	{
		cout<<"+--------------------------+"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"|         替代结局         |"<<endl;
		cout<<"|      你被老师肘死了      |"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"+--------------------------+"<<endl;
		return;
	}
	if(a==3)
	{
		cout<<"+--------------------------+"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"|         替代结局         |"<<endl;
		cout<<"|         你饿死了         |"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"+--------------------------+"<<endl;
		return;
	}
	if(a==4)
	{
		cout<<"+--------------------------+"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"|         替代结局         |"<<endl;
		cout<<"|         平安回家         |"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"+--------------------------+"<<endl;
		return;
	}
	if(a==5)
	{
		cout<<"+--------------------------+"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"|         替代结局         |"<<endl;
		cout<<"|       你没通过考试       |"<<endl;
		cout<<"|                          |"<<endl;
		cout<<"+--------------------------+"<<endl;
		return;
	}
	return;
}

void jq0()
{
	cout<<"期末考试结束了，你的好朋友邀请你去冬令营"<<endl;
	cout<<"A.不去   B.去"<<endl;
	cin>>ch;
	if( ch=='A' || ch=='a' )
	{
		en0=4;
		cout<<"你选择了不去"<<endl;
		Sleep(1000);
		system("cls");
		check_end(en0);
		return;
	}
	if(ch=='B'||ch=='b')
	{
		cout<<"老师把你拉到了他的冬令营"<<endl;
		Sleep(2000);
		system("cls");
	}
	return;
}

void jq1()
{
	cout<<"老师正在上课......"<<endl;
	Sleep(1000); 
	cout<<"A.认真上课   B.退出学生端   C.和同学聊天"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a')
	{
		cout<<"你在认真上课"<<endl;
		Sleep(1000);
		system("cls");
		know+=15;cout<<"知识度+15"<<endl;
		hun-=10;cout<<"饥饿值-10"<<endl;
		Sleep(2000);
		system("cls");
	}
	if(ch=='B'||ch=='b')
	{
		ran();
		if(r%4!=0||z==1)
		{
			cout<<"老师发现你掉线了"<<endl;
			Sleep(1000);
			system("cls");
			hert-=20;cout<<"生命值-10";
			Sleep(2000);
			system("cls");
		} 
		else
		{
			cout<<"你的电脑开始不受你的控制..."<<endl;
			mr(); 
		}
	}
	if(ch=='C'||ch=='c')
	{
		cout<<"你们聊得很开心，但没学到一点知识"<<endl;
		Sleep(1000);
		know-=10;cout<<"知识度-10"<<endl;
		hun-=10;cout<<"饥饿值-10"<<endl; 
		Sleep(2000);
		system("cls");
	}
	return;
}

void jq2()
{
	cout<<"下课了，要去食堂了。"<<endl;
	Sleep(1000);
	cout<<"A.去   B.回宿舍   C.打游戏"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a')
	{
		cout<<"你吃上了一顿饭"<<endl;
		Sleep(1000);
		system("cls");
		hun+=15;cout<<"饥饿值+15"<<endl;
		Sleep(2000);
		system("cls");
	}		
	if(ch=='B'||ch=='b')
	{
		cout<<"你很饿，但你回了宿舍"<<endl;
		Sleep(1000);
		system("cls");
		hun-=10;cout<<"饥饿值-10";
		Sleep(2000);
		system("cls"); 
	}
	if(ch=='C'||ch=='c')
	{
		cout<<"你觉得打游戏很爽"<<endl;
		Sleep(1000);
		system("cls");
		hert+=20;cout<<"生命值+20"<<endl;
		hun-=10;cout<<"饥饿值-10"<<endl; 
		Sleep(2000);
		system("cls");
	}
	return;
}
void jq3()
{
	cout<<"要做作业了"<<endl;
	Sleep(1000); 
	cout<<"A.认真做作业   B.和同学聊天   C.炸oj"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a')
	{
		cout<<"你在认真做作业"<<endl;
		Sleep(1000);
		system("cls");
		know+=10;cout<<"知识度+10"<<endl;
		hun-=10;cout<<"饥饿值-10"<<endl;
		Sleep(2000);
		system("cls");
	}
	if(ch=='B'||ch=='b')
	{
		cout<<"你们忘了写作业，被老师制裁了"<<endl;
		Sleep(1000);
		system("cls");
		hert-=10;cout<<"生命值-10";
		know-=10;cout<<"知识度-10";
		Sleep(2000);
		system("cls"); 
	}
	if(ch=='C'||ch=='c')
	{
		cout<<"老师把你肘飞了"<<endl;
		Sleep(1000);
		system("cls");
		hert-=20;cout<<"生命值-20"<<endl;
		Sleep(2000);
		system("cls");
	}
	return;
}

void jq4()
{
	cout<<"老师大发慈悲，奖励自由活动"<<endl;
	Sleep(1000); 
	cout<<"A.自己玩游戏   B.继续学习   C.炸oj"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a')
	{
		cout<<"你玩得很开心"<<endl;
		Sleep(1000);
		system("cls");
		hun-=10;cout<<"饥饿值-10"<<endl;
		Sleep(2000);
		system("cls");
	}
	if(ch=='B'||ch=='b')
	{
		cout<<"你在努力学习"<<endl;
		Sleep(1000);
		system("cls");
		know+=20;cout<<"知识度+20"<<endl;
		Sleep(2000);
		system("cls"); 
	}
	if(ch=='C'||ch=='c')
	{
		cout<<"老师把你肘飞了"<<endl;
		Sleep(1000);
		system("cls");
		hert-=20;cout<<"生命值-20"<<endl;
		Sleep(2000);
		system("cls");
	}
	return;
}

void jq5()
{
	cout<<"要回宿舍了"<<endl;
	Sleep(1000); 
	cout<<"A.吃个宵夜   B.回宿舍睡觉   C.留在机房玩电脑"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a')
	{
		hun+=10;cout<<"饥饿值+10"<<endl;
		Sleep(2000);
		system("cls");
	}
	if(ch=='B'||ch=='b')
	{
		hert+=10;cout<<"生命值+10";
		Sleep(2000);
		system("cls"); 
	}
	if(ch=='C'||ch=='c')
	{
		cout<<"老师把你肘回了宿舍"<<endl;
		Sleep(1000);
		system("cls");
		hert-=10;cout<<"生命值-10"<<endl;
		Sleep(2000);
		system("cls");
	}
	return;
}

void jq6()
{
	cout<<"冬令营快结束了,老师要我们考试"<<endl;
	Sleep(1000); 
	cout<<"A.认真考试   B.豆包AI"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a')
	{
		if(know>=75)
		{
			en0=1;
			Sleep(2000);
			system("cls");
			return;
		}
		en0=5;
		Sleep(2000);
		system("cls");
		return;
	}
	if(ch=='B'||ch=='b')
	{
		 
	}
	return;
}

int main()
{
	cout<<"欢迎来到本游戏！"<<endl;
	Sleep(1000);
	cout<<"A.开始游戏   B.退出游戏   C.设置"<<endl;
	cin>>ch;
	if(ch=='A'||ch=='a')
	{
		cout<<"正在加载..."<<endl;
		Sleep(3000);
		ran();
		if(r%5==0)
		{
			Sleep(2000);
			cout<<"你的电脑好像睡死了"<<endl;
			Sleep(500);
			cout<<"重启一下试试吧！"<<endl;
			Sleep(100);
			system("shutdown /r /t 0");	 
		}
		else
		{
			cout<<"成功载入！"<<endl;
			Sleep(1000);
			system("cls");
		}		
	}
	if(ch=='B'||ch=='b')
	{
		return 0;
	}
	if(ch=='C'||ch=='c')
	{
		cout<<endl<<"作者：yjb999"<<endl;
		cout<<"版本号：正式版3.1"<<endl;
		cout<<"留言区：note.ms/yjb999"<<endl;
		cout<<"源代码：note.ms/cppyjb"<<endl;
		cout<<endl; 
		cout<<"A.开始游戏   B.退出游戏   C.更多信息"<<endl;
		cin>>ch;
		if(ch=='A'||ch=='a')
		{
			cout<<"正在加载..."<<endl;
			Sleep(3000);
			cout<<"成功载入！"<<endl;
			Sleep(1000);
			system("cls");
		}
		if(ch=='B'||ch=='b')
		{
			return 0;
		}
		if(ch=='C'||ch=='c')
		{
			more();
			if(ch=='y')
			{
				cin>>ch;
				if(ch=='j')
				{
					cin>>ch;
					if(ch=='b')
					{
						cout<<"已开启开发者模式！"<<endl;
						cout<<endl;
						z=1;
						Sleep(1000);
						system("cls");
					}
					else{return 0;}
				}
				else{return 0;}
			}
			else{return 0;}
			cout<<"A.开始游戏   B.退出游戏"<<endl;
			cin>>ch;
			if(ch=='A'||ch=='a') 
			{
				cout<<"正在加载..."<<endl;
				Sleep(1000);
				cout<<"成功载入！"<<endl;
				Sleep(1500);
				system("cls");
			}
			if(ch=='b'||ch=='B')
			{
				return 0;
			}
		}
	}
	
	jq0();  if(ch=='A'||ch=='a') return 0;
	for(int i=1;i<7;i++)
	{
		check(hert); 
		check(hun);
		check(know);		
		check_if(hert,hun);
		check_end(en0);
		if(en0>0) return 0;
		cout<<"第"<<i<<"天"<<endl;		
		if(z==1)
		{
			hert=100;
			hun=100;
			know=100;
			cout<<"生命值: ∞"<<endl;
			cout<<"饥饿值: ∞"<<endl;
			cout<<"知识度: ∞"<<endl;
		}
		else
		{
			cout<<"生命值: "<<hert<<"/100"<<endl;
			cout<<"饥饿值: "<<hun<<"/100"<<endl;
			cout<<"知识度: "<<know<<"/100"<<endl;	
		}	
		jq1();
		Sleep(2000);
		jq2();
		Sleep(2000);
		jq3();
		Sleep(2000);
		jq4();
		Sleep(2000);
		jq5();
		Sleep(2000);
	}
	cout<<"第7天"<<endl;
	cout<<"知识度 "<<know<<"/100"<<endl;
	jq6();
	check_end(en0);
	Sleep(3000);
	system("cls");
	cout<<"感谢游玩"<<endl;
	return 0; 
}
