跳到正文

剪贴板

剪贴板 14qa5wuo

原文
剪贴板信息

剪贴板信息

收录
更新

秘境重生 v1.2.3版本

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
typedef map<string, int> mpsi;


mpsi things;
map<int, string> mp1{ {1, "木镐"}, {2, "铜镐"}, {3, "银镐"}, {4, "铁镐"}, {5, "金镐"} };
int jb = 0;
int mt = 0;

class Person{
public:
	Person(int mh1, int mt1, int d1, int a1, int x1) : maxHp(mh1), maxTl(mt1), dmg(d1), bj(a1), bjl(x1), hp(mh1), tl(mt1) {}

	~Person() {}

	int maxHp; //最大生命值
	int hp; //生命值
	int dmg; //伤害
	int maxTl; //最大体力值
	int tl; //体力值
	int bj; //暴击伤害
	int bjl; //暴击概率

	void checkInfo(void){
		cout << "生命值: " << hp << '/' << maxHp << endl;
		cout << "体力值: " << tl << '/' << maxTl << endl;
		cout << "伤害: " << dmg << endl;
		cout << "暴击: " << bj << ", " << bjl << '%' << endl;
	}

	void resetInfo(void){
        Person emptyPler(200, 1200, 18, 55, 20);
        *this = emptyPler;
	}
};

void duquPlayer(Person &p, string worldName){
	string road = "D:\\MJIU\\" + worldName + "\\player.save";
	ifstream file(road.c_str());
    if(!file)
    	return;
	file >> p.maxHp >> p.hp >> p.maxTl >> p.tl >> p.dmg >> p.bj >> p.bjl;
}

void xieruPlayer(const Person &p, string worldName){
	string road = "D:\\MJIU\\" + worldName + "\\player.save";
	ofstream file(road.c_str());
	file << p.maxHp << endl << p.hp << endl << p.maxTl << endl << p.tl << endl << p.dmg << endl << p.bj << endl << p.bjl ;
}

void duquThings(mpsi &m, string worldName){
	string road1 = "D:\\MJIU\\" + worldName + "\\things.save";
	string road2 = "D:\\MJIU\\" + worldName + "\\numOfThings.save";
	ifstream file1(road1.c_str());
	ifstream file2(road2.c_str());
	if(!file1 || !file2)
    	return;

	string s;
	int num;
	while(file1 >> s && file2 >> num)
		m[s] = num;
}
void xieruThings(mpsi m, string worldName){
	string road1 = "D:\\MJIU\\" + worldName + "\\things.save";
	string road2 = "D:\\MJIU\\" + worldName + "\\numOfThings.save";
	ofstream file1(road1.c_str());
	ofstream file2(road2.c_str());

	mpsi::iterator mit = m.begin();
	for(; mit != m.end(); ++mit){
		file1 << mit->first << ' ';
		file2 << mit->second << endl;
	}
}

void _srand_(void){
	srand((unsigned) time(NULL) + rand());
}

void duquJb(int &j, string worldName){
	string road = "D:\\MJIU\\" + worldName + "\\jb.save";
	ifstream file(road.c_str());
    if(!file)
    	return;
    file >> j;
}
void xieruJb(int j, string worldName){
    string road = "D:\\MJIU\\" + worldName + "\\jb.save";
	ofstream file(road.c_str());
    file << j;
}
void duquMt(int &m, string worldName){
	string road = "D:\\MJIU\\" + worldName + "\\mt.save";
	ifstream file(road.c_str());
    if(!file)
    	return;
    file >> m;
}
void xieruMt(int m, string worldName){
	string road = "D:\\MJIU\\" + worldName + "\\mt.save";
	ofstream file(road.c_str());
    file << m;
}
void duquName(vector<string> &name){
	ifstream file("D:\\MJIU\\worldnames.save");
	if(!file) return;

	string s;
	while(file >> s){
		name.push_back(s);
	}
}

void xieruName(vector<string> name) {
	ofstream file("D:\\MJIU\\worldnames.save");

	for(int i = 0; i < name.size(); ++i){
		file << name[i] << endl;
	}
}
int main(){
	cout << "欢迎来到游戏[秘境重生]!\n";
	Sleep(1000);

	int wd;
	vector<string> nm;
	duquName(nm);
	string worldName;
	Person player(200, 1200, 18, 55, 20);
	while(true){
		cout << "你现在想干什么?\n";
		cout << "1.打开以前的世界 \n";
		cout << "2.创建一个新的世界\n";

		char __c__ = _getch();
		if(__c__ == '1'){
			cout << "当前已存在的世界名:\n";
			for(int i = 0; i < nm.size(); ++i){
				cout << "第 " << i + 1 << " 个世界: " << nm[i] << endl;
			}
			cout << "请问你想要打开哪个世界(输入世界的序号) ?\n";

			cin >> wd;
			wd--;
			if(wd < 0 || wd >= nm.size()){
				cout << "不存在的世界!\n";
				continue;
			}

			worldName = nm[wd];
			cout << "打开[" << worldName << "]世界!\n" ;
			Sleep(1000);
			cout << "祝你游玩愉快!\n";
			system("pause");
			system("cls");

			duquPlayer(player, worldName);
			duquThings(things, worldName);
			duquJb(jb, worldName);
			duquMt(mt, worldName);
			break;
		}
		else if(__c__ == '2'){
			cout << "这是你创建的第" << nm.size() + 1 << "个世界!\n";
			Sleep(1000);
			cout << "输入世界名:";
			cin >> worldName;

			bool is_setupped = false;
			for(int i = 0; i < nm.size(); ++i){
				if(worldName == nm[i]){
					cout << "该世界已存在!\n";
					is_setupped = true;
					break;
				}
			}
			if(is_setupped) continue;

			cout << "新世界创建成功,自动进入该世界!\n";
			cout << "如果想进入其他世界,请退出游戏后重进!\n";


			nm.push_back(worldName);
			xieruName(nm);

			string filename = "D:\\MJIU\\" + worldName;
			string cmd = "mkdir " + filename;
			system(cmd.c_str());
			xieruPlayer(player, worldName);
			xieruThings(things, worldName);
			xieruJb(jb, worldName);
			xieruMt(mt, worldName);
			system("pause");
			system("cls");
			break;
		}
	}

	Sleep(1000);

	while(true){
		duquPlayer(player, worldName);
		duquThings(things, worldName);
		duquJb(jb, worldName);
		cout << "你现在想干什么?\n";
		cout << "1.查看属性\n";
		cout << "2.前往探险\n";
		cout << "3.回复状态\n";
		cout << "4.升级\n";
		cout << "5.存档清除\n";
		cout << "6.合成物品\n";
		cout << "7.关于我们\n";
		char cmd = _getch();
		system("cls");
		if(cmd == '1'){
			cout << "玩家属性:\n";
            player.checkInfo();
            cout << "\n工具与物品:\n";
            auto it = things.begin();
            for(; it != things.end(); ++it){
            	cout << it->first << " * " << it->second << endl;
			}
			cout << endl;
			cout << "金币:" << jb << endl << endl;
		}
		else if(cmd == '2'){
            int x = 0, y = 0;
            cout << "出发,一起去探险!\n";
            Sleep(1000);
            cout << "注意, 若你的所有指标中有任何一项归零,则你将面临死亡!(走1步耗费10点体力值)\n";
            system("pause");
            do{
            	cout << "你的位置是" << "(" << x << ", " << y << "), 营地的位置是(0, 0)\n";
            	cout << "当前状态值:\n";
            	player.checkInfo();
            	cout << "工具与物品:\n";
	            auto it = things.begin();
	            for(; it != things.end(); ++it){
	            	cout << it->first << " * " << it->second << endl;
				}
                bool b = true;
                int i = 3;
                while(b){
                	cout << "请选择你前进的方向 1.上 2.下 3.左 4.右 : \n";
                    char fang_xiang = _getch();

                    switch(fang_xiang){
                    	case '1':
                    		cout << "向上!\n";
                    		++x;
                    		b = false;
                    		break;
                        case '2':
                    		cout << "向下!\n";
                    		--x;
                    		b = false;
                    		break;
						case '3':
                    		cout << "向左!\n";
                    		--y;
                    		b = false;
                    		break;
						case '4':
                    		cout << "向右!\n";
                    		++y;
                    		b = false;
                    		break;
                        default:
                        	cout << "无效的命令,请重新输入!\n";
                        	break;
					}
                    Sleep(1000);
				}

				player.tl -= 10;
				if(x == 0 && y == 0){
					cout << "欢迎探险者凯旋归来!\n";
					Sleep(1000);
                    break;
				}
				if(abs(x) == 88 && abs(y) == 88){
					Person boss1( 900, 1000, 210, 280, 30); //攻击型
					Person boss2(1750, 1200, 90, 110, 15); //血量型
				}
				srand((unsigned) time(NULL) + rand() * i * -i * i * i * i * i);
				int randNum = rand() % 10000 + 1;
				if(randNum <= 1000){ //10%
					cout << "你拾到一些小木棍\n";
					Sleep(1000);
					srand((unsigned) time(NULL) + rand());
					int sticks = rand() % 4 + 1;
					cout << "恭喜获得:[木棍 * " << sticks << "]!\n";
					things["木棍"] += sticks;
					Sleep(1000);
				}
				else if(randNum <= 3000){ //20%
					cout << "这块地是空的\n";
					Sleep(1000);
					cout << "去别的地方探索吧!\n";
					Sleep(1000);
				}
				else if(randNum <= 4000){ //10%
					cout << "你发现了一片铜矿石(矿石数量:5~15块, 耗费体力值:3点/块)\n";
					srand((unsigned) time(NULL) + rand());
					int tong = rand() % 11 + 5;
					Sleep(1000);
					cout << "需要使用[木镐][铜镐][银镐][铁镐][金镐]进行挖掘!\n";
					Sleep(1000);
					cout << "是否挖掘? 1 = 是 其他数字 = 否\n";
					char qq = _getch();
					if(qq == '1'){
						Sleep(1000);
						int twtw;
						while(true){
							cout << "输入你想使用的采集工具:1.木镐 2.铜镐 3.银镐 4.铁镐 5.金镐";
							cin >> twtw;

							if(things.count(mp1[twtw + 0]) == 1){
								cout << "存在该工具,开始挖掘!\n";
								Sleep(1000);
								break;
							}
							else {
								cout << "不存在该工具,请重新输入!\n";
								Sleep(1000);
							}
						}
						for(int i = 1; i <= tong; ++i){
							cout << "挖掘进度: " << i << "/" << tong << endl;
							--things[mp1[twtw]];
							player.tl -= 3;
							things["铜矿石"]++;
							Sleep(1000);
						}
						cout << "挖掘完成!\n";
						Sleep(1000);
						cout << "祝你接下来的探索好运~\n";
						Sleep(1000);
					}
					else{
						cout << "跳过该矿脉!\n";
						Sleep(1000);
					}
				}
				else if(randNum <= 4500){ //5%
					cout << "你发现了一片银矿石(矿石数量:1~15块, 耗费体力值:5点/块)\n";
					srand((unsigned) time(NULL) + rand());
					int tong = rand() % 15 + 1;
					Sleep(1000);
					cout << "需要使用[铜镐][银镐][铁镐][金镐]进行挖掘!\n";
					Sleep(1000);
					cout << "是否挖掘? 1 = 是 其他数字 = 否\n";
					char qq = _getch();
					if(qq == '1'){
						Sleep(1000);
						int twtw;
						while(true){
							cout << "输入你想使用的采集工具: 1.铜镐 2.银镐 3.铁镐 4.金镐";
							cin >> twtw;

							if(things.count(mp1[twtw + 1]) == 1){
								cout << "存在该工具,开始挖掘!\n";
								Sleep(1000);
								break;
							}
							else {
								cout << "不存在该工具,请重新输入!\n";
								Sleep(1000);
							}
						}
						for(int i = 1; i <= tong; ++i){
							cout << "挖掘进度: " << i << "/" << tong << endl;
							--things[mp1[twtw + 1]];
							player.tl -= 5;
							things["银矿石"]++;
							Sleep(1500);
						}
						cout << "挖掘完成!\n";
						Sleep(1000);
						cout << "祝你接下来的探索好运~\n";
						Sleep(1000);
					}
					else{
						cout << "跳过该矿脉!\n";
						Sleep(1000);
					}
				}

				else if(randNum <= 4800){ //3%
					cout << "你发现了一片铁矿石(矿石数量:1~8块, 耗费体力值:8点/块)\n";
					srand((unsigned) time(NULL) + rand());
					int tong = rand() % 8 + 1;
					Sleep(1000);
					cout << "需要使用[银镐][铁镐][金镐]进行挖掘!\n";
					Sleep(1000);
					cout << "是否挖掘? 1 = 是 其他数字 = 否\n";
					char qq = _getch();
					if(qq == '1'){
						Sleep(1000);
						int twtw;
						while(true){
							cout << "输入你想使用的采集工具: 1.银镐 2.铁镐 3.金镐";
							cin >> twtw;

							if(things.count(mp1[twtw + 2]) == 1){
								cout << "存在该工具,开始挖掘!\n";
								Sleep(1000);
								break;
							}
							else {
								cout << "不存在该工具,请重新输入!\n";
								Sleep(1000);
							}
						}
						for(int i = 1; i <= tong; ++i){
							cout << "挖掘进度: " << i << "/" << tong << endl;
							--things[mp1[twtw + 2]];
							player.tl -= 8;
							things["铁矿石"]++;
							Sleep(2000);
						}
						cout << "挖掘完成!\n";
						Sleep(1000);
						cout << "祝你接下来的探索好运~\n";
						Sleep(1000);
					}
					else{
						cout << "跳过该矿脉!\n";
						Sleep(1000);
					}
				}

				else if(randNum <= 5000){ //2%
					cout << "你发现了一片金矿石(矿石数量:1~5块, 耗费体力值:12点/块)\n";
					srand((unsigned) time(NULL) + rand() * rand() );
					int tong = rand() % 5 + 1;
					Sleep(1000);
					cout << "需要使用[铁镐][金镐]进行挖掘!\n";
					Sleep(1000);
					cout << "是否挖掘? 1 = 是 其他数字 = 否\n";
					char qq = _getch();
					if(qq == '1'){
						Sleep(1000);
						int twtw;
						while(true){
							cout << "输入你想使用的采集工具: 1.铁镐 2.金镐";
							cin >> twtw;

							if(things.count(mp1[twtw + 3]) == 1){
								cout << "存在该工具,开始挖掘!\n";
								Sleep(1000);
								break;
							}
							else {
								cout << "不存在该工具,请重新输入!\n";
								Sleep(1000);
							}
						}
						for(int i = 1; i <= tong; ++i){
							cout << "挖掘进度: " << i << "/" << tong << endl;
							--things[mp1[twtw + 3]];
							player.tl -= 12;
							things["金矿石"]++;
							Sleep(4000);
						}
						cout << "挖掘完成!\n";
						Sleep(1000);
						cout << "祝你接下来的探索好运~\n";
						Sleep(1000);
					}
					else{
						cout << "跳过该矿脉!\n";
						Sleep(1000);
					}
				}
				else if(randNum <= 7000){ //20%
					cout << "你收集到了一些浆果\n";
					Sleep(1000);
					srand((unsigned) time(NULL) + rand());
					int sticks = rand() % 5 + 1;
					cout << "恭喜获得:[浆果 * " << sticks << "]!\n";
					things["浆果"] += sticks;
				}

				else if(randNum <= 7500){ //5%
					cout << "你遇到了一颗树\n";
					Sleep(1000);
					cout << "徒手:可以获得5~15根木棍,耗费体力5点/木棍\n";
					Sleep(1000);
					cout << "使用手斧:可以获得2~5块木片,耗费体力3点/木片,消耗手斧耐久1点/木片\n";
					Sleep(1000);
					cout << "请输入您想使用的采集方法 1.徒手 2.使用手斧 其他.跳过 :\n";
					char yyyt = _getch();
					if(yyyt == '1'){
						cout << "开始徒手采集!请耐心等待。。。\n";
						int num = rand() % 11 + 5;
						Sleep(num * 200);
						things["木棍"] += num;
						player.tl -= (num * 5);
						cout << "采集成功!\n";
						cout << "恭喜获得[木棍 * " << num << "]!\n";
						Sleep(1000);
					}
					else if(yyyt == '2'){
						if(things["手斧"] == 0){
							cout << "手斧的耐久不够了,请先去合成!\n";
						}
						else{
							cout << "开始使用手斧采集!请耐心等待。。。\n";
							int num = rand() % 4 + 2;
							Sleep(num * 200);
							things["木片"] += num;
							player.tl -= (num * 3);
							things["手斧"] -= num;
							cout << "采集成功!\n";
							cout << "恭喜获得[木片 * " << num << "]!\n";
							Sleep(1000);
						}
					}
					else{
						cout << "已跳过!\n";
						Sleep(1000);
					}
				}
				else if(randNum <= 9000){ //15%
					string name[20] = {"猪", "牛", "羊", "鸡", "野猪", "狼"};
					int dmg[20]  =    {5,    15,   7,    3,     20,     45}; //伤害
					int hp1[20]  =    {150,  450,  250,  80,    600,   210}; //血量上限
					int hp2[20]  =    {100,  350,  180,  60,    450,   150}; //下限
					int sb1[20]  =    {0,    2,    5,    3,     10,     30}; //闪避
					int bjj[20]  =    {15,   35,   15,   8,     35,     70}; //暴击
					int bjl[20]  =    {5,    10,   2,    10,    15,     25}; //暴击率
					int tll[20]  =    {666,  666,  666,  666,   666,   666}; //体力
					int jbb[20]  =    {20,   50,   35,   10,    120,   300};

					srand((unsigned) time(NULL) + rand());
					int rdn = rand() % 6;
					cout << "你遇到了一只动物: " << name[rdn] << endl;

					int dd = dmg[rdn];
					int hh = rand() % (hp1[rdn] - hp2[rdn] + 1) + hp2[rdn];
					int ss = sb1[rdn];
					int bj = bjj[rdn];
					int bj1 = bjl[rdn];
					int tt = tll[rdn];

					Person ds(hh, tt, dd, bj, bj1);
					ds.checkInfo();
					cout << "闪避率:" << ss << '%' << endl;
					cout << "是否开战?(确定请按y):";
					char ccc = _getch();

					if(ccc == 'y'){
						cout << "对战开始!\n";
						int now = 1;
						bool gd66 = false; //判断格挡
						bool sb66 = false; //判断闪避
						bool ft66 = false; //判断反弹
						while(ds.hp > 0 && player.hp > 0 && ds.tl > 0 && player.tl > 0){
							cout << "-----------------------------------\n";
							cout << "你:  体力:" << player.tl << "   血量:" << player.hp << endl;
							cout << "对手:体力:" << ds.tl     << "   血量:" << ds.hp << endl;
							cout << "-----------------------------------\n";

							cout << "第" << now++ << "回合:\n";
							Sleep(1000);
							if(now % 2 == 0){
								gd66 = false;
								sb66 = false;
								ft66 = false;
								cout << "你的攻击!\n";
								Sleep(1000);
								cout << "你可以执行的命令如下:\n";
								Sleep(1000);
								cout << "1.攻击对手(对手血量 -= 你的攻击力,你的体力 -= 你的攻击力)\n";
								cout << "2.格挡对手的下一次攻击 (你的体力 += 30%对手攻击力[向下取整],并且抵消对手下一次 10% 的伤害[向下取整])\n";
								cout << "3.尝试闪避 (你的体力 -= 40%对手攻击力[向下取整],并且 15% 的概率抵消下一次对手的所有伤害)\n";
								cout << "4.反弹 (你的体力 += 10%对手攻击力,抵消对手下一次 20% 的伤害[向下取整],并反弹给对手)\n";
								cout << "请输入你想执行的指令:";
								char zl = _getch();
								if(zl == '1'){
									cout << "发动攻击!\n";
									Sleep(1000);
									srand((unsigned) time(NULL) * time(NULL));
									int qpqp1 = rand() % 100 + 1; //判断闪避
									int qpqp2 = rand() % 100 + 1; //判断暴击
									if(qpqp1 <= ss){ //对方闪避
										cout << name[rdn] << "发动了闪避!\n";
										Sleep(1000);
										cout << "你扑了个空\n";
										cout << "你的体力 -" << player.dmg;
										player.tl -= player.dmg;
										Sleep(1000);
										continue;
									}
									if(qpqp2 <= player.bjl){ //自己暴击
										cout << "你发动了暴击!\n";
										Sleep(1000);
										cout << "对手血量 -" << player.bj << endl;
										Sleep(1000);
										cout << "你的体力 -" << player.bj << endl;

										player.tl -= player.bj;
										ds.hp -= player.bj;
									}
									else{
										cout << "你攻击了对手\n";
										Sleep(1000);
										cout << "对手血量 -" << player.dmg << endl;
										Sleep(1000);
										cout << "你的体力 -" << player.dmg << endl;

										player.tl -= player.dmg;
										ds.hp -= player.dmg;
									}
								} else if(zl == '2') {
									cout << "已开启下一轮的格挡\n";
									Sleep(1000);
									gd66 = true;
								} else if(zl == '3'){
									cout << "已开启下一轮的闪避\n";
									Sleep(1000);
									sb66 = true;
								} else if(zl == '4'){
									cout << "已开启下一轮的反弹\n";
									ft66 = true;
								} else {
									cout << "由于你输入错误,因此跳过你的攻击!\n";
									Sleep(1000);
								}
							}
							else{
								cout << "对手的攻击!\n";
								Sleep(1000);
								srand((unsigned) time(NULL) * time(NULL));
								int rdnum = rand() % 100 + 1;
								int zsdmg;
								if(rdnum < ds.bjl){
									cout << "对手发动了暴击!\n";
									zsdmg = ds.bj;
									Sleep(1000);
								} else zsdmg = ds.dmg;
								if(gd66){
									int zhenshi = zsdmg * 0.9; //对手的真实攻击力
									int jiacheng = zsdmg * 0.3; //我方体力加成
									cout << "由于你在上一轮开启了格挡,你抵消了对手10%的伤害\n";
									Sleep(1000);
									cout << "你的血量 -" << zhenshi << endl;
									cout << "你的体力 +" << jiacheng << endl;
									cout << "对手体力 -" << zhenshi << endl;
									Sleep(1000);
									player.hp -= zhenshi;
									player.tl += jiacheng;
									ds.tl -= zhenshi;
								} else if(sb66){
									srand((unsigned) time(NULL) * time(NULL));
									int pdsb = rand() % 100 + 1;
									int jianshao = zsdmg * 0.4;
									cout << "你开始尝试闪避!\n";
									Sleep(1000);
									if(pdsb <= 15){
										cout << "闪避成功!\n";
										Sleep(1000);
										cout << "你的体力 -" << jianshao << endl;
										cout << "对手体力 -" << zsdmg << endl;

										player.tl -= jianshao;
										ds.tl -= zsdmg;
									} else{
										cout << "闪避失败!\n";
										Sleep(1000);
										cout << "对手攻击了你\n";
										Sleep(1000);
										cout << "你的血量 -" << zsdmg << endl;
										cout << "你的体力 -" << jianshao << endl;
										cout << "对手体力 -" << zsdmg << endl;

										player.hp -= zsdmg;
										player.tl -= jianshao;
										ds.tl -= zsdmg;
									}
								} else if(ft66) {
									cout << "对手攻击了你\n";
									Sleep(1000);
									cout << "你吸收了对手20%的伤害,并返还给对手\n";
									Sleep(1000);
									cout << "你的血量 -" << int(zsdmg * 0.8) << endl;
									cout << "你的体力 +" << int(zsdmg * 0.1) << endl;
									cout << "对手血量 -" << int(zsdmg * 0.2) << endl;
									cout << "对手体力 -" << int(zsdmg) << endl;

									player.hp -= zsdmg * 0.8;
									player.tl += zsdmg * 0.1;
									ds.hp -= zsdmg * 0.2;
									ds.tl -= zsdmg;
								} else {
									cout << "对手攻击了你\n";
									Sleep(1000);
									cout << "你的血量 -" << zsdmg << endl;
									cout << "对手体力 -" << zsdmg << endl;

									player.hp -= zsdmg;
									ds.tl -= zsdmg;
								}
								system("pause");
								system("cls");
							}
							if(ds.hp <= 0 || ds.tl <= 0){
								cout << "对手死了!\n";
								Sleep(1000);
								cout << "你获得胜利!";
								Sleep(1000);
								if(name[rdn] == "猪" || name[rdn] == "牛" || name[rdn] == "羊" || name[rdn] == "鸡"){
									cout << "恭喜获得[生" << name[rdn] << "肉*5]!\n";
									string zlp = "生" + name[rdn] + "肉";
									things[zlp] += 5;
								}
								cout << "金币 +" << jbb[rdn];
								jb += jbb[rdn];
								break;
							}
							if(ds.hp <= 0 || ds.tl <= 0){
								break;
							}
						}
					} else {
						cout << "已跳过!\n";
					}
				}
				else{
					cout << "你发现了一片煤矿(矿石数量:5~15块, 耗费体力值:3点/块)\n";
					srand((unsigned) time(NULL) + rand());
					int tong = rand() % 11 + 5;
					Sleep(1000);
					cout << "需要使用[木镐][铜镐][银镐][铁镐][金镐]进行挖掘!\n";
					Sleep(1000);
					cout << "是否挖掘? 1 = 是 其他数字 = 否\n";
					char qq = _getch();
					if(qq == '1'){
						Sleep(1000);
						int twtw;
						while(true){
							cout << "输入你想使用的采集工具:1.木镐 2.铜镐 3.银镐 4.铁镐 5.金镐";
							cin >> twtw;

							if(things.count(mp1[twtw + 0]) == 1){
								cout << "存在该工具,开始挖掘!\n";
								Sleep(1000);
								break;
							}
							else {
								cout << "不存在该工具,请重新输入!\n";
								Sleep(1000);
							}
						}
						for(int i = 1; i <= tong; ++i){
							cout << "挖掘进度: " << i << "/" << tong << endl;
							--things[mp1[twtw]];
							player.tl -= 3;
							things["煤炭"]++;
							Sleep(1000);
						}
						cout << "挖掘完成!\n";
						Sleep(1000);
						cout << "祝你接下来的探索好运~\n";
						Sleep(1000);
					}
					else{
						cout << "跳过该矿脉!\n";
						Sleep(1000);
					}
				}
				auto it1 = things.begin();

				vector<string> can_erase;
				for(; it1 != things.end(); ++it1){
					if(it1->second <= 0){
						can_erase.push_back(it1->first);
					}
				}

				for(int i = 0; i < can_erase.size(); ++i){
		            things.erase(can_erase[i]);
				}
				if(player.tl <= 0 || player.hp <= 0){
					cout << "你在探险的途中死了!\n";
					Sleep(1000);
					cout << "已清除你的存档,祝你下次好运\n";
					Sleep(1000);
					player.resetInfo();
					things.clear();
					jb = 0;
					break;
				}
				system("pause");
				system("cls");
				xieruPlayer(player, worldName);
				xieruThings(things, worldName);
				xieruJb(jb, worldName);
				xieruMt(mt, worldName);
			}while(x != 0 || y != 0);
		}
		else if(cmd == '3'){
			cout << "回复状态需要吃一些食物!\n";
			Sleep(1000);
			cout << "\n工具与物品:\n";
            auto it = things.begin();
            for(; it != things.end(); ++it){
            	cout << it->first << " * " << it->second << endl;
			}
			cout << endl;

			cout << "请问你要吃什么食物来回复状态?(直接复制输入可食用的物品名称即可)";
            string food;
            cin >> food;
            cout << "请输入数量:";
            int num;
            cin >> num;


            if(food == "浆果"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 15 * num << endl;
	            	player.tl += (15 * num);
	            	things[food] -= num;
                }
			} else if(food == "生羊肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 40 * num << endl;
	            	player.tl += (40 * num);
	            	things[food] -= num;
	        	}
            }
            else if(food == "生猪肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 30 * num << endl;
	            	player.tl += (30 * num);
	            	things[food] -= num;
				}
            }
            else if(food == "生牛肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 55 * num << endl;
	            	player.tl += (55 * num);
	            	things[food] -= num;
	            }
            }
            else if(food == "生鸡肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 25 * num << endl;
	            	player.tl += (25 * num);
	            	things[food] -= num;
	            }
            }
            else if(food == "熟羊肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 70 * num << endl;
	            	cout << "血量+" << 10 * num << endl;
	            	player.tl += (70 * num);
	            	player.hp += (10 * num);
	            	things[food] -= num;
	            }
            }
            else if(food == "熟牛肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 110 * num << endl;
	            	cout << "血量+" << 15 * num << endl;
	            	player.tl += (70 * num);
	            	player.hp += (15 * num);
	            	things[food] -= num;
	            }
            }
            else if(food == "熟猪肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 65 * num << endl;
	            	cout << "血量+" << 10 * num << endl;
	            	player.tl += (70 * num);
	            	player.hp += (10 * num);
	            	things[food] -= num;
	            }
            }
            else if(food == "熟鸡肉"){
            	if(things[food] < num){
            		cout << "不是有效的命令!\n";
				}
				else{
					cout << "食用" << food << "!\n";
					Sleep(1000);
	            	cout << "体力值+" << 50 * num << endl;
	            	cout << "血量+" << 7 * num << endl;
	            	player.tl += (70 * num);
	            	player.hp += (10 * num);
	            	things[food] -= num;
	            }
            }

			if(player.tl > player.maxTl) player.tl = player.maxTl;
			if(player.hp > player.maxHp) player.hp = player.maxHp;
		}
		else if(cmd == '4'){
			player.checkInfo();
			cout << "请问你需要对哪种属性进行升级?\n";
			cout << "1. 血量——100金币获得15点加成\n";
			cout << "2. 攻击力——150金币获得3点加成\n";
			cout << "3. 体力值——60金币获得20点加成\n";
			cout << "4. 暴击伤害——150金币获得4点加成\n";
			cout << "5. 暴击概率——200金币获得1%加成\n";

			char kk = _getch();

			string nm[10] = {"血量", "攻击力", "体力值", "暴击伤害", "暴击概率"};
			int jc[10] = {15, 3, 20, 4, 1};
			int xy[10] = {100, 150, 60, 150, 200};

			if(kk < '1' || kk > '5'){
				cout << "不存在的命令!\n";
				continue;
			}
			int m = kk - '1';
			cout << "输入你想要升级的次数:";
			int cs;
			cin >> cs;
			cout << "需要让" << nm[m] << "属性增加" << jc[m] * cs << "点,需要" << xy[m] * cs << "金币。\n";
			Sleep(1000);
			cout << "请问是否升级?(确定请按y)\n";
			char sf = _getch();

			if(sf == 'y'){
				if(xy[m] * cs > jb){
					cout << "金币不足!\n";
					continue;
				}
				cout << "升级成功!\n";
				Sleep(1000);
				if(kk == '1'){
					player.maxHp += (jc[m] * cs);
					jb -= (xy[m] * cs);
				}
				if(kk == '2'){
					player.dmg += (jc[m] * cs);
					jb -= (xy[m] * cs);
				}
				if(kk == '3'){
					player.maxTl += (jc[m] * cs);
					jb -= (xy[m] * cs);
				}
				if(kk == '4'){
					player.bj += (jc[m] * cs);
					jb -= (xy[m] * cs);
				}
				if(kk == '5'){
					player.bjl += (jc[m] * cs);
					jb -= (xy[m] * cs);
				}
			}
			if(player.bjl > 100) player.bjl = 100;
		}
		else if(cmd == '5'){
			cout << "清除存档会清空自己的所有内容,确定要清空吗?";
			cout << "y = 确认,其他 = 取消\n";
			char c = _getch();
			if(c == 'y') {
				cout << "存档已清除!\n";
				player.resetInfo();
				things.clear();
				jb = 0;
			}
			else cout << "已取消!\n";
		}
		else if(cmd == '6'){
			cout << "请输入您的操作:1.合成物品 2.烧炼物品 3.添柴";
			int kkksc03;
			cin >> kkksc03;

			if(kkksc03 == 1){
				cout << "合成配方:\n";
				Sleep(1000);
				cout << "1.木片(1块):木棍*4\n";
				cout << "2.木板(1块):木片*4\n";
				cout << "3.木镐(100点耐久):木片*2,木板*3\n";
				cout << "4.铜镐(150点耐久):木片*2,铜锭*9\n";
				cout << "5.银镐(250点耐久):木片*2,银锭*9\n";
				cout << "6.铁镐(300点耐久):木片*2,铁锭*9\n";
				cout << "7.金镐(350点耐久):木片*2,金锭*9\n";
				cout << "8.手斧(用于伐树,150点耐久):木片*2,铜银合金*5\n";
				cout << "9.手斧(350点耐久):木片*3,铁银合金*5\n";
				cout << "10.铜银合金(2块):铜锭*2,银锭*1\n";
				cout << "11.铁银合金(2块):铁锭*2,银锭*2\n";
				cout << "请输入你想要合成的物品编号:";
				int id;
				cin >> id;

				cout << "输入你想要的数目:";
				int sum;
				cin >> sum;
				if(id == 1){
					int num1 = 4 * sum;
					cout << "需要木棍*" << num1 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木棍"] < num1){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木棍"] -= num1;
							things["木片"] += sum;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 2){
					int num1 = 4 * sum;
					cout << "需要木片*" << num1 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["木板"] += sum;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 3){
					int num1 = 2 * sum;
					int num2 = 3 * sum;
					cout << "需要木片*" << num1 << "木板*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1 || things["木板"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["木板"] -= num2;
							things["木镐"] += sum * 100;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 4){
					int num1 = 2 * sum;
					int num2 = 9 * sum;
					cout << "需要木片*" << num1 << "铜锭*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1 || things["铜锭"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["铜锭"] -= num2;
							things["铜镐"] += sum * 150;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 5){
					int num1 = 2 * sum;
					int num2 = 9 * sum;
					cout << "需要木片*" << num1 << "银锭*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1 || things["银锭"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["银锭"] -= num2;
							things["银镐"] += sum * 250;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 6){
					int num1 = 2 * sum;
					int num2 = 9 * sum;
					cout << "需要木片*" << num1 << "铁锭*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1 || things["铁锭"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["铁锭"] -= num2;
							things["铁镐"] += sum * 300;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 7){
					int num1 = 2 * sum;
					int num2 = 9 * sum;
					cout << "需要木片*" << num1 << "金锭*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1 || things["金锭"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["金锭"] -= num2;
							things["金镐"] += sum * 350;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 8){
					int num1 = 2 * sum;
					int num2 = 5 * sum;
					cout << "需要木片*" << num1 << "铜银合金*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1 || things["铜银合金"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["铜银合金"] -= num2;
							things["手斧"] += sum * 150;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 9){
					int num1 = 2 * sum;
					int num2 = 5 * sum;
					cout << "需要木片*" << num1 << "铁银合金*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["木片"] < num1 || things["铁银合金"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["木片"] -= num1;
							things["铁银合金"] -= num2;
							things["手斧"] += sum * 350;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 10){
					int num1 = 2 * sum;
					int num2 = 1 * sum;
					cout << "需要铜锭*" << num1 << "银锭*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["铜锭"] < num1 || things["银锭"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["铜锭"] -= num1;
							things["银锭"] -= num2;
							things["铜银合金"] += sum * 2;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
				if(id == 11){
					int num1 = 2 * sum;
					int num2 = 2 * sum;
					cout << "需要铁锭*" << num1 << "银锭*" << num2 << ", 是否合成?(合成请按y,否则按其他字母)" ;
					char c = _getch();
					if(c == 'y'){
						if(things["铁锭"] < num1 || things["银锭"] < num2){
							cout << "无法合成!请先去收集原材料!\n";
							Sleep(1000);
						}
						else{
							cout << "可以合成!\n";
							cout << "开始合成物品,请耐心等待。。。\n";
							Sleep(3000);
							cout << "合成成功!\n";
							things["铁锭"] -= num1;
							things["银锭"] -= num2;
							things["铁银合金"] += sum * 2;
						}
					}
					else{
						cout << "取消合成!\n";
						Sleep(1000);
					}
				}
			}

			else if(kkksc03 == 2){
				cout << "可烧炼的物品有:\n";
				cout << "1.生猪肉  烧炼时长:0.5秒/个 烧制成品:熟猪肉\n";
				cout << "2.生鸡肉  烧炼时长:0.6秒/个 烧制成品:熟鸡肉\n";
				cout << "3.生牛肉  烧炼时长:0.8秒/个 烧制成品:熟牛肉\n";
				cout << "4.生羊肉  烧炼时长:1.0秒/个 烧制成品:熟羊肉\n";
				cout << "5.铜矿石  烧炼时长:1.0秒/个 烧制成品:铜锭\n";
				cout << "6.银矿石  烧炼时长:1.2秒/个 烧制成品:银锭\n";
				cout << "7.铁矿石  烧炼时长:1.5秒/个 烧制成品:铁锭\n";
				cout << "8.金矿石  烧炼时长:1.8秒/个 烧制成品:金锭\n";
				cout << "烧制一个物品,需要1点燃烧值\n";
				cout << "当前剩余" << mt << "点燃烧值\n";

				cout << "输入你想烧炼物品的编号:";
				int id;
				cin >> id;
				int num;
				cout << "请输入你想烧炼的数量:";
				cin >> num;
				if(num > mt){
					cout << "没有足够的燃烧值,请先去添加柴火!\n";
					continue;
				}
				string ttt[10] = {"", "生猪肉", "生鸡肉", "生牛肉", "生羊肉", "铜矿石", "银矿石", "铁矿石", "金矿石"};
				string yyy[10] = {"", "熟猪肉", "熟鸡肉", "熟牛肉", "熟羊肉", "铜锭", "银锭", "铁锭", "金锭"};
				float wait_time[10] = {0, 0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 1.8};

				if(id > 8 || id < 1) cout << "不存在的命令,请重新输入!\n";
				else {
					if(num > things[ttt[id]]){
						cout << "数量超过限制,请重新输入!\n";
						continue;
					}
					system("cls");
					for(int i = 1; i <= num; ++i){
						cout << "开始烧制!\n";
						cout << "烧制物品:" << ttt[id] << " -> " << yyy[id] << endl;
						cout << "烧制进度:(" << i << '/' << num << ")\n";
						things[ttt[id]]--;
						mt--;
						things[yyy[id]]++;
						Sleep(wait_time[id] * 1000);
						system("cls");
					}
				}
			}
			else if(kkksc03 == 3){
				cout << "添加柴火的方法:\n";
				cout << "1. 木片*1 -> 燃烧值+1\n";
				cout << "2. 木板*1 -> 燃烧值+5\n";
				cout << "3. 煤炭*1 -> 燃烧值+2\n";
				cout << "请问你需要使用哪种方法?\n";
				int a;
				cin >> a;
				a--;
				string wp[3] = {"木片", "木板", "煤炭"};
				int num[3]   = {1,      5,      2};
				int k;
				cout << "请输入添加次数:";
				cin >> k;

				if(a < 0 || a > 2){
					cout << "不存在的方式!\n";
					continue;
				}
				cout << "需要" << k << "个" << wp[a] << "以添加" << num[a] * k << "点燃烧值,是否确定(y/n)\n";
				char c = _getch();
				if(c == 'y' || c == 'Y'){
					if(things[wp[a]] < k){
						cout << "原材料不够!\n";
						continue;
					}
					else{
						cout << "添加成功!\n";
						things[wp[a]] -= k;
						mt += (k * num[a]);
					}
				}
			}
		}
		else if(cmd == '7'){
			cout << "作者:逸晨\n";
			cout << "LuoguUID:Yi_chen123 <1528634>\n";
			cout << "版本号:v1.2.3\n";
		}
		else cout << "不存在的命令!\n";

		auto it = things.begin();

		vector<string> can_erase;
		for(; it != things.end(); ++it){
			if(it->second <= 0){
				can_erase.push_back(it->first);
			}
		}

		for(int i = 0; i < can_erase.size(); ++i){
            things.erase(can_erase[i]);
		}


		xieruPlayer(player, worldName);
		xieruThings(things, worldName);
		xieruJb(jb, worldName);
		xieruMt(mt, worldName);

		system("pause");
		system("cls");
	}


	return 0;
}

需要 .exe 后缀可执行文件请移步至这里