蒟蒻自制 《战斗迷宫》

#include <iostream>
#include <bits/stdc++.h>
#ifdef _WIN32
#define WINDOWS
#include <windows.h>
#include <conio.h>
#define in(c) c = getch()
#endif
#ifdef __linux__
#define LINUX
#include <unistd.h>
#include <signal.h>
#endif
using namespace std;
bool HackerMode = 0;//黑客模式
bool Exit;
int logD(int n) {
	if (!n) {
		return 0;
	}
	return logD(n / 10) + 1;
}

const int MAX_DRUG_NUM = 3;
void PAUSE(int s) {
	Sleep(s * 1000);
}
struct WEAPON {		//武器
	string name;	//名字
	int atk;		//攻击
	int more_atk;
	int more_atk_rand;
};
struct ARMOR {		//盔甲
	string name;	//名字
	int dr;			//
	int defense;
	double percent_dr;
	int sb_rand;
};
struct DRUG {		//药物
	string name;
	int hp_add;
};
struct PLAYER {
	string name;
	WEAPON wea;
	ARMOR arm;

	DRUG bag[10];
	int drug_num;

	int exp;		//经验
	int lv;			//等级

	int max_hp;		//血量上限
	int real_hp;	//真正血量

	int base_atk;	//基础攻击力

	int max_es;		//自身防御力上限
	int real_es;	//剩余防御力
};

PLAYER _P_, Summ;

WEAPON mood_sword, stone_sword, gold_sword, iron_sword, diamond_sword, end_sword, strange_sword;

ARMOR leather_armor, chain_armor, iron_armor, gold_armor, diamond_armor, happy_armor;

DRUG little_heart, broken_heart;

PLAYER SummonAIBOSS() {
	int ai_lv = rand() % 3 + 10;	//boss 等级
	PLAYER ret_ai;
	ret_ai.name = "美国总统";
	ret_ai.lv = ai_lv;
	ret_ai.exp = 0;
	ret_ai.max_hp = int((rand() % 3 + 10) * pow(1.25, ai_lv));
	ret_ai.max_es = ret_ai.max_hp / (rand() % 2 + 2);
	ret_ai.base_atk = int(pow((rand() % 5 + 115.0) / 100.0, ai_lv));
	ret_ai.real_hp = ret_ai.max_hp;

	ret_ai.wea = end_sword;

	ret_ai.arm = gold_armor;

	ret_ai.drug_num = 3;
	for (int i = 1; i <= ret_ai.drug_num; i++)ret_ai.bag[i] = little_heart;

	return ret_ai;
}
PLAYER SummonAI(int ai_lv) {
	PLAYER ret_ai;

	if (rand() % 5 == 0)ret_ai.name = "美国大兵";
	else if (rand() % 5 <= 1)ret_ai.name = "美国恶霸";
	else if (rand() % 5 <= 2)ret_ai.name = "美国主任";
	else if (rand() % 5 <= 3)ret_ai.name = "美国牢大";
	else if (rand() % 5 <= 4)ret_ai.name = "美国炮灰";

	ret_ai.lv = ai_lv;
	ret_ai.exp = 0;
	ret_ai.max_hp = int((rand() % 3 + 10) * pow(1.25, ai_lv));
	ret_ai.max_es = ret_ai.max_hp / (rand() % 2 + 2);
	ret_ai.base_atk = int(pow((rand() % 5 + 115.0) / 100.0, ai_lv));
	ret_ai.real_hp = ret_ai.max_hp;

	if (rand() % 10 == 0)ret_ai.wea = mood_sword;
	else if (rand() % 10 <= 2)ret_ai.wea = stone_sword;
	else if (rand() % 10 <= 5)ret_ai.wea = iron_sword;
	else if (rand() % 10 <= 7)ret_ai.wea = gold_sword;
	else if (rand() % 10 <= 9)ret_ai.wea = diamond_sword;


	if (rand() % 10 == 0)ret_ai.arm = leather_armor;
	else if (rand() % 10 <= 2)ret_ai.arm = chain_armor;
	else if (rand() % 10 <= 5)ret_ai.arm = iron_armor;
	else if (rand() % 10 <= 7)ret_ai.arm = gold_armor;
	else if (rand() % 10 <= 9)ret_ai.arm = diamond_armor;


	ret_ai.drug_num = rand() % 3;
	for (int i = 1; i <= ret_ai.drug_num; i++) {
		if (rand() % 2 == 0)
			ret_ai.bag[i] = little_heart;
		else
			ret_ai.bag[i] = broken_heart;
	}

	return ret_ai;
}
void PrintInfo() {//初始画面
	printf("#############################\n");
	printf("#       迷宫探险 v1.1       #\n");
	printf("# 开发者:jinyanshao(洛谷名) #\n");
	printf("#  特别鸣谢:MWL_wma(洛谷名) #\n");
	printf("#############################\n");
	printf("#     使用 wasd 进行控制    #\n");
	printf("#       画有\"&\"的地点       #\n");
	printf("#        代表一个man        #\n");
	printf("#       画有\"#\"的地点       #\n");
	printf("#         你无法进入        #\n");
	printf("#       画有\"*\"的地点       #\n");
	printf("#        代表一个惊喜       #\n");
	printf("#       画有\"!\"的地点       #\n");
	printf("#      代表最终的 Boss      #\n");
	printf("#  你的目标是达到右下角的点 #\n");
	printf("#      并且击败 Boss!      #\n");
	printf("#       起航吧探险者!      #\n");
	printf("#############################\n");
	system("pause");
}
void FightItemINIT() {
	mood_sword.name = "木剑 -|-- ", mood_sword.atk = 1, mood_sword.more_atk = 3, mood_sword.more_atk_rand = 2;
	stone_sword.name = "石剑 -|--> ", stone_sword.atk = 2, stone_sword.more_atk = 5, stone_sword.more_atk_rand = 3;
	iron_sword.name = "铁剑 =|==> ", iron_sword.atk = 3, iron_sword.more_atk = 7, iron_sword.more_atk_rand = 4;
	gold_sword.name = "金剑 =|===> ", gold_sword.atk = 4, gold_sword.more_atk = 9, gold_sword.more_atk_rand = 3;
	diamond_sword.name = "钻石剑 ==|====> ", diamond_sword.atk = 5, diamond_sword.more_atk = 10, diamond_sword.more_atk_rand = 3;
	end_sword.name = "下界合金剑 -+====> ", end_sword.atk = 7, end_sword.more_atk = 18, end_sword.more_atk_rand = 3;
	strange_sword.name = "阳寿剑  =:)==>", strange_sword.atk = 1, strange_sword.more_atk = 114514, strange_sword.more_atk_rand = 8;

	leather_armor.name = "皮革甲 (_)", leather_armor.dr = 3, leather_armor.percent_dr = 2.0, leather_armor.sb_rand = 1000, leather_armor.defense = 0;
	chain_armor.name = "锁链甲 (_)", chain_armor.dr = 3, chain_armor.percent_dr = 1.5, chain_armor.sb_rand = 1000, chain_armor.defense = 0;
	iron_armor.name = "铁甲 (_)", iron_armor.dr = 2.5, iron_armor.percent_dr = 1.0, iron_armor.sb_rand = 1000, iron_armor.defense = 0;
	gold_armor.name = "金甲 |_|", gold_armor.dr = 2, gold_armor.percent_dr = 0.9, gold_armor.sb_rand = 1000, gold_armor.defense = 10;
	diamond_armor.name = "钻石甲 |_|", diamond_armor.dr = 1.5, diamond_armor.percent_dr = 0.85, diamond_armor.sb_rand = 1000, diamond_armor.defense = 15;
	happy_armor.name = "下界合金甲 (::)", happy_armor.dr = 1.0, happy_armor.percent_dr = 0.75, happy_armor.sb_rand = 2, happy_armor.defense = 8;
	little_heart.name = "小血瓶 (o)", little_heart.hp_add = 10;
	broken_heart.name = "大血瓶 (0)", broken_heart.hp_add = 20;

	Summ.name = "Summ";
	Summ.drug_num = 0;
	Summ.base_atk = 10000;
	Summ.max_hp = 20;
	Summ.real_hp = 20;
	Summ.max_es = 100000;
	Summ.real_es = 100000;
	Summ.exp = 2;
	Summ.lv = 30;
	Summ.arm = diamond_armor;
	Summ.wea = end_sword;
}
void FightUI(PLAYER plr, PLAYER ai) {
	system("cls");
	// 等级(经验 / 多少经验升级)名字
	cout << "等级:" << plr.lv << "(" << plr.exp << "/" << int(pow(1.5, plr.lv + 1)) << ")   " << plr.name << endl;
	//武器名
	cout << "武器 : " << plr.wea.name << endl;
	//盔甲名
	cout << "盔甲 : " << plr.arm.name << endl;
	//真实血量/最大血量
	cout << "血量 : " << plr.real_hp << "/" << plr.max_hp << endl;
	//剩余防御/ 自身最大防御 + 盔甲防御值
	cout << "防御 : " << plr.real_es << "/" << plr.max_es + plr.arm.defense << endl;

	cout << endl << endl;

	cout << "等级:" << ai.lv << "(" << ai.exp << "/" << int(pow(1.5, ai.lv + 1)) << ")   " << ai.name << endl;
	cout << "武器 : " << ai.wea.name << endl;
	cout << "盔甲 : " << ai.arm.name << endl;
	cout << "血量 : " << ai.real_hp << "/" << ai.max_hp << endl;
	cout << "盔甲血量 : " << ai.real_es << "/" << ai.max_es + ai.arm.defense << endl;

	cout << endl << endl;

	cout << "按 k/K 键攻击,输入 1/2/3 来使用血瓶." << endl;
	cout << "背包" << endl;
	for (int i = 1; i <= plr.drug_num; i++)
		cout << i << "." << plr.bag[i].name << endl;

	cout << endl << endl;
}
void LevelUP(PLAYER &plr) {	//升级
	if (plr.exp < int(pow(1.5, plr.lv + 1)))
		return;
	else {
		system("cls");
		cout << "你升到了 " << plr.lv + 1 << " 级!" << endl;
		plr.exp -= int(pow(1.5, plr.lv + 1));
		plr.lv++;
		plr.max_hp = int((rand() % 3 + 10) * pow(1.25, plr.lv));
		plr.max_es = plr.max_hp / (rand() % 2 + 2);
		plr.base_atk = int(pow((rand() % 5 + 115.0) / 100.0, plr.lv));
		plr.real_hp = plr.max_hp;
	}
	if (HackerMode) {
		plr.base_atk = 10000;
		plr.max_hp = 1919810;
		plr.real_hp = 114514;
	}
}
void FightINIT(PLAYER &plr) {	//战斗前的初始化
	plr.real_es = plr.max_es;	//防御力初始化
}
void Attack(PLAYER &plr, PLAYER &ai) {
	int real_atk = plr.base_atk;
	if (plr.wea.more_atk_rand != 0 && rand() % plr.wea.more_atk_rand == 0) {
		cout << "暴击了!!!" << endl;
		real_atk += plr.wea.more_atk;
	} else
		real_atk += plr.wea.atk;
	if (ai.arm.percent_dr != 0)
		real_atk = real_atk * ai.arm.percent_dr;
#ifdef DEBUG
	cout << "DEBUG : now " << ai.name << " arm's precent_dr is " << ai.arm.percent_dr << endl;
	cout << "DEBUG : now " << plr.name << " real_atk is " << real_atk << endl;
#endif
	real_atk -= ai.arm.dr;
	real_atk = max(real_atk, 1);
	if (ai.arm.sb_rand != 0  &&  rand() % ai.arm.sb_rand == 0)
		cout << "闪避!" << endl;
	else {
		if (ai.arm.defense >= real_atk)
			ai.arm.defense -= real_atk;
		else if (ai.arm.defense + ai.real_es >= real_atk) {
			ai.arm.defense = 0;
			ai.real_es -= real_atk;
		} else {
			ai.arm.defense = 0;
			ai.real_es = 0;
			ai.real_hp = ai.real_hp - (real_atk - (ai.arm.defense + ai.real_es));
		}
	}
	cout << "铛! " << plr.name << " 造成了 " << real_atk << " 滴血 的伤害!" << endl;
}
bool Fight(PLAYER &plr, PLAYER ai) {
	FightINIT(plr);
	FightINIT(ai);
	while (1) {
		FightUI(plr, ai);
		if (plr.real_hp <= 0 && ai.real_hp <= 0) {
			cout << "你和敌人同归于尽了!\n";
			cout << "你将额外获得 1 滴血!\n";
			PAUSE(1.5);
			plr.real_hp = 1;
			return true;
		}
		if (plr.real_hp <= 0) {
			cout << "你输了!" << endl;
			Sleep(1000);
			cout << "你的荣耀将由下一个人传承" << endl;
			Sleep(1000);
			PAUSE(1.5);
			return false;
		}
		if (ai.real_hp <= 0) {
			cout << "恭喜你,在怪物的攻击下活下来了!" << endl;
			plr.exp += max(1, (rand() % 3 + 10) * ai.lv / 10);
			LevelUP(plr);
			PAUSE(1.5);
			return true;
		}

		cout << plr.name << " , 轮到你了!" << endl;
atk_again:
		char op;
#ifdef WINDOWS
		in(op);
#endif
		if ('0' <= op && op <= '9') {
			int arr = op - '0';
			if (arr > plr.drug_num)
				cout << "你没有足够的药物了 :(" << endl;
			else {
				cout << plr.bag[arr].name << endl;
				for (int i = 1; i <= 4; i++) {
					cout << "gulu ";
					Sleep(300);
				}
				cout << endl;
				cout << "哎嘛,香!" << endl;
				Sleep(500);
				cout << "哎嘛,真香!" << endl;
				Sleep(500);
				cout << "哎嘛,太香了!" << endl;
				Sleep(500);
				for (int i = arr; i <= plr.drug_num - 1; i++)plr.bag[i] = plr.bag[i + 1];
				plr.drug_num--;
				plr.real_hp = min(plr.max_hp, plr.real_hp + plr.bag[arr].hp_add);
				cout << "铛! 你还有 " << plr.real_hp << "滴血 !" << endl;
			}
		} else if (op == 'K' || op == 'k')Attack(plr, ai);
		else {
			cout << "请按 k/K/1~9 操作" << endl;
			Sleep(500);

			goto atk_again;
		}
		PAUSE(2);
		FightUI(ai, plr);


		cout << ai.name << " , 轮到你了!" << endl;
		if (ai.real_hp * 2 < ai.max_hp && ai.drug_num != 0) {
			for (int i = 1; i <= 4; i++) {
				cout << "gulu ";
				Sleep(300);
			}
			int drug_maxx = -1, maxi;
			for (int i = 1; i <= ai.drug_num; i++) {
				if (ai.bag[i].hp_add > drug_maxx) {
					drug_maxx = ai.bag[i].hp_add;
					maxi = i;
				}
			}
			for (int i = maxi; i <= ai.drug_num - 1; i++)
				ai.bag[i] = ai.bag[i + 1];
			ai.drug_num--;
			ai.real_hp = min(ai.max_hp, ai.real_hp + drug_maxx);
			cout << ai.name << "现在血量有 " << ai.real_hp << "了!" << endl;
		} else {
			cout << ai.name << " 攻击了你 !" << endl;
			Attack(ai, plr);
		}
		PAUSE(2);
	}
}
void Pick() {
	int t = rand() % 3;
#ifdef DEBUG
	cout << "DEBUG:t is " << t << endl;
#endif
	if (t == 0) {
		WEAPON pick_it;
		int tt = rand() % 17;
		if (tt <= 3)pick_it = mood_sword;
		else if (tt <= 7)pick_it = stone_sword;
		else if (tt <= 10)pick_it = iron_sword;
		else if (tt <= 12)pick_it = gold_sword;
		else if (tt <= 14)pick_it = diamond_sword;
		else if (tt <= 15)pick_it = end_sword;
		else if (tt <= 16)pick_it = strange_sword;

		if (_P_.wea.atk) {
			cout << "换不换 ?" << endl;
			cout << _P_.wea.name << endl << pick_it.name << endl;
			cout << "(h / bh)" << endl;
			string ins;
			cin >> ins;
			if (ins == "h") {
				_P_.wea = pick_it;
				cout << "你得到了 " << pick_it.name << " !" << endl;
			}
		} else {
			_P_.wea = pick_it;
			cout << "你得到了 " << pick_it.name << " !" << endl;
		}
	} else if (t == 1) {
		ARMOR pick_it_2;
		int tt2 = rand() % 16;
		if (tt2 <= 3)pick_it_2 = leather_armor;
		else if (tt2 <= 7)pick_it_2 = chain_armor;
		else if (tt2 <= 10)pick_it_2 = iron_armor;
		else if (tt2 <= 12)pick_it_2 = gold_armor;
		else if (tt2 <= 14)pick_it_2 = diamond_armor;
		else if (tt2 <= 15)pick_it_2 = happy_armor;

		if (_P_.arm.dr ) {
			cout << "换不换 ?" << endl;
			cout << _P_.arm.name << endl << pick_it_2.name << endl;
			cout << "(h / bh)" << endl;
			string ins_2;
			cin >> ins_2;
			if (ins_2 == "h") {
				_P_.arm = pick_it_2;
				cout << "你得到了 " << pick_it_2.name << " !" << endl;
			}
		} else {
			_P_.arm = pick_it_2;
			cout << "你得到了 " << pick_it_2.name << " !" << endl;
		}
	} else {
		if (_P_.drug_num > MAX_DRUG_NUM) {
			cout << "你没有足够的空间了 :(" << endl;
			PAUSE(1);
			return;
		}
		int tt3 = rand() % 3;
#ifdef DEBUG
		cout << "DEBUG : _P_.drug_num is " << _P_.drug_num << endl;
#endif
		if (tt3 <= 1) {
			_P_.bag[++_P_.drug_num] = little_heart;
			cout << "你得到了 " << little_heart.name << " !" << endl;
		} else {
			_P_.bag[++_P_.drug_num] = broken_heart;
			cout << "你得到了 " << broken_heart.name << " !" << endl;
		}
	}
	PAUSE(1);
}
//begin makemap
int Sx = 2, Sy = 2;
struct side {
	int from, to;
} edges[14405];
const int I = 17, J = 31;
int indplan = 0, p[125];
char maze[20][40];
vector<int> g[125];
long long seed = time(0);
void print(int x, int y);

int find(int x) {
	if (p[x] != x) {
		p[x] = find(p[x]);
	}
	return p[x];
}
void init() {
	memset(&edges, 0, sizeof(struct side));
	for (int i = 1; i <= 120; i++) {
		g[i].clear();
	}
	for (int i = 1; i <= 120; i++) {
		if (i + 15 >= 1 && i + 15 <= 120) {
			edges[++indplan].from = i;
			edges[indplan].to = i + 15;
		}
		if (i + 1 >= 1 && i + 1 <= 120 && i % 15 != 0) {
			edges[++indplan].from = i;
			edges[indplan].to = i + 1;
		}
	}
}

void kruskal() {
	memset(maze, '#', sizeof(maze));
	init();
	for (int i = 1; i <= 120; i++) {
		p[i] = i;
	}
	for (int j = 1; j <= indplan; j++) {
		int beyond = rand() % indplan + 1;
		swap(edges[j], edges[beyond]);
	}
	int endcnt = 0;
	for (int i = 1; i <= indplan; i++) {
		if (endcnt == 119) {
			break;
		}
		if (i + 1 == indplan && endcnt < 119) {
			i = 1;
		}
		if (rand() % 2) {
			if (find(edges[i].from) != find(edges[i].to)) {
				endcnt++;
				// cout << edges[i].from << ' ' << edges[i].to << endl;
				p[find(p[edges[i].from])] = find(edges[i].to);
				g[edges[i].from].push_back(edges[i].to - edges[i].from);
			}
		}
	}
	int id = 1;
	for (int i = 2; i <= I; i += 2) {
		for (int j = 2; j <= J; j += 2) {
			maze[i][j] = ' ';
			for (int k = 0; k < g[id].size(); k++) {
				if (g[id][k] == 1) {
					//->
					maze[i][j + 1] = ' ';
				}
				if (g[id][k] == 15) {
					//down
					maze[i + 1][j] = ' ';
				}
			}
#ifdef dev
			print(seed);
			clear();
#endif
			id++;
		}
	}
	for (int i = 1; i <= I; i++) {
		for (int j = 1; j <= J; j++) {
			if (maze[i][j] != '#') {
				int x = rand();
				maze[i][j] = (x % 8 == 0 ? '*' : (x % 8 == 1 ? '&' : ' '));
			}
		}
	}
	maze[I - 1][J - 1] = '!';
}

void print(int x, int y) {
	for (int i = 1; i <= I; i++) {
		for (int j = 1; j <= J; j++) {
			if (i == x && j == y) cout << "@";
			else cout << maze[i][j];
		}
		cout << endl;
	}
	cout << "# 等级:" << _P_.lv << "(" << _P_.exp << "/" << int(pow(1.5, _P_.lv + 1)) << ")   " << _P_.name;
	for (int i = 1; i <= 16 - logD(_P_.lv) - logD(_P_.exp) - logD(int(pow(1.5, _P_.lv + 1))) - _P_.name.length(); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 武器 : " << _P_.wea.name;
	for (int i = 1; i <= 21 - _P_.wea.name.length(); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 盔甲 : " << _P_.arm.name;
	for (int i = 1; i <= 21 - _P_.arm.name.length(); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 血量 : " << _P_.real_hp << "/" << _P_.max_hp;
	for (int i = 1; i <= 20 - logD(_P_.real_hp) - logD(_P_.max_hp); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 盔甲血量 : " << _P_.real_es << "/" << _P_.max_es + _P_.arm.defense;
	for (int i = 1; i <= 15 - logD(_P_.real_es) - logD(_P_.max_es + _P_.arm.defense); i++) {
		printf(" ");
	}
	printf("#\n");

	cout << "###############################\n";

	cout << "输入 1/2/3 来使用血瓶." << endl;
	cout << "背包" << endl;
	for (int i = 1; i <= _P_.drug_num; i++)
		cout << i << "." << _P_.bag[i].name << endl;

	cout << endl << endl;
}
//end makemap
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
void Operation(char ch, int &x, int &y, bool &dead) {
	if (!dead)return;
	int op;
	if (ch == 'w')op = 3;
	else if (ch == 'a')op = 1;
	else if (ch == 's')op = 2;
	else op = 0;
	if (ch >= '1' && ch <= '9') {
		int arr = ch - '0';
		if (arr > _P_.drug_num)
			cout << "你没有足够的药物了 :(" << endl;
		else {
			cout << _P_.bag[arr].name << endl;
			for (int i = 1; i <= 4; i++) {
				cout << "gulu ";
				Sleep(300);
			}
			cout << endl;
			cout << "哎嘛,香!" << endl;
			Sleep(500);
			cout << "哎嘛,真香!" << endl;
			Sleep(500);
			cout << "哎嘛,太香了!" << endl;
			Sleep(500);
			for (int i = arr; i <= _P_.drug_num - 1; i++)_P_.bag[i] = _P_.bag[i + 1];
			_P_.drug_num--;
			_P_.real_hp = min(_P_.max_hp, _P_.real_hp + _P_.bag[arr].hp_add);
		}
	}
	int nx = x + dx[op], ny = y + dy[op];
	if (nx < 1 || nx > I || ny < 1 || ny > J)return;
	if (maze[nx][ny] == '#')return;
	if (maze[nx][ny] == '*') {
		Pick();
		maze[nx][ny] = ' ';
	}
	if (maze[nx][ny] == '&') {
		dead = Fight(_P_, SummonAI(max(1, min(9, _P_.lv + rand() % 4 - 2))));
		if (dead)
			maze[nx][ny] = ' ';
	}
	if (maze[nx][ny] == '!') {
		if (!HackerMode)
			dead = Fight(_P_, SummonAIBOSS());
		else {
			cout << endl << "不 " << _P_.name << "!!! 这是BOSS !!!" << endl;
			PAUSE(1);
			dead = Fight(_P_, Summ);
		}
		if (dead) {
			maze[nx][ny] = ' ';
			cout << " 你通关了!!! 你可以 退出 或者 继续探索 !!!\n";
			PAUSE(2);
			system("cls");
			printf("#############################\n");
			printf("#       迷宫探险 v1.1       #\n");
			printf("# 开发者:jinyanshao(洛谷名) #\n");
			printf("#  特别鸣谢:MWL_wma(洛谷名) #\n");
			printf("#############################\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#     You win the game!     #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#      按 y 以继续探索      #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#        按 n 以退出        #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#############################\n");
			char ch;
			ch = getch();
			if (ch == 'n') {
				Exit = 1;
			}
		}
	}
	x = nx, y = ny;
}
void Game(int x, int y) {
back_and_agian:
	kruskal();
	cout << "注意看!@是你" << endl;
	print(x, y);
	cout << endl << "请使用 wasd 控制 @ 行走" << endl << endl;
	cout << "如果这个地图错误了,你可以按下 Esc 重开.";
	cout << endl;
	char ch;
	ch = getch();
	if (ch == 27) {
		system("cls");
		goto back_and_agian;
	}
	while (1) {
		ch = getch();
		bool dead = true;
		Operation(ch, x, y, dead);
		if (!dead || Exit)return;
		system("cls");
		print(x, y);
	}
}
int main() {
	PrintInfo();
	system("cls");
	_P_ = SummonAI(1);
	cout << "请输入名字:";
	cin >> _P_.name;
	if (_P_.name == "经验")
		_P_.exp += 10000;
	if (_P_.name == "创造") {
		_P_.base_atk = 10000;
		_P_.max_hp = 1919810;
		_P_.real_hp = 114514;
		HackerMode = true;
	}
	seed = time(NULL);
	srand(seed);
	FightItemINIT();
	Game(Sx, Sy);
	return 0;
}
13 个赞

P.max_hp = 19198180
P.real_hp = 114514;
你这代码有点臭

3 个赞

那个黑客模式有什么用

1 个赞

改成1了没效果

1 个赞

我的世界好评

2 个赞

将名称改成创造

即开创造

谢谢

:+1::+1::+1::blush::blush::blush:

我天 这么长

在此处键入或粘贴代码
````#include <iostream>
#include <bits/stdc++.h>
#ifdef _WIN32
#define WINDOWS
#include <windows.h>
#include <conio.h>
#define in(c) c = getch()
#endif
#ifdef __linux__
#define LINUX
#include <unistd.h>
#include <signal.h>
#endif
using namespace std;
bool HackerMode = 0;
bool Exit;
int logD(int n) {
	if (!n) {
		return 0;
	}
	return logD(n / 10) + 1;
}

const int MAX_DRUG_NUM = 3;
void PAUSE(int s) {
	Sleep(s * 1000);
}
struct WEAPON {	
	string name;
	int atk;
	int more_atk;
	int more_atk_rand;
};
struct ARMOR {	
	string name;
	int dr;	
	int defense;
	double percent_dr;
	int sb_rand;
};
struct DRUG {
	string name;
	int hp_add;
};
struct PLAYER {
	string name;
	WEAPON wea;
	ARMOR arm;

	DRUG bag[10];
	int drug_num;

	int exp;		
	int lv;
	int max_hp;	
	int real_hp;
	int base_atk;

	int max_es;	
	int real_es;
};

PLAYER _P_, Summ;

WEAPON mood_sword, stone_sword, gold_sword, iron_sword, diamond_sword, end_sword, strange_sword;

ARMOR leather_armor, chain_armor, iron_armor, gold_armor, diamond_armor, happy_armor;

DRUG little_heart, broken_heart;

PLAYER SummonAIBOSS() {
	int ai_lv = rand() % 3 + 10;
	PLAYER ret_ai;
	ret_ai.name = "日本总统";
	ret_ai.lv = ai_lv;
	ret_ai.exp = 0;
	ret_ai.max_hp = int((rand() % 3 + 10) * pow(1.25, ai_lv));
	ret_ai.max_es = ret_ai.max_hp / (rand() % 2 + 2);
	ret_ai.base_atk = int(pow((rand() % 5 + 115.0) / 100.0, ai_lv));
	ret_ai.real_hp = ret_ai.max_hp;

	ret_ai.wea = end_sword;

	ret_ai.arm = gold_armor;

	ret_ai.drug_num = 3;
	for (int i = 1; i <= ret_ai.drug_num; i++)ret_ai.bag[i] = little_heart;

	return ret_ai;
}
PLAYER SummonAI(int ai_lv) {
	PLAYER ret_ai;

	if (rand() % 5 == 0)ret_ai.name = "小日本鬼子";
	else if (rand() % 5 <= 1)ret_ai.name = "日本恶霸";
	else if (rand() % 5 <= 2)ret_ai.name = "日本主任";
	else if (rand() % 5 <= 3)ret_ai.name = "科比牛逼";
	else if (rand() % 5 <= 4)ret_ai.name = "日本炮灰";

	ret_ai.lv = ai_lv;
	ret_ai.exp = 0;
	ret_ai.max_hp = int((rand() % 3 + 10) * pow(1.25, ai_lv));
	ret_ai.max_es = ret_ai.max_hp / (rand() % 2 + 2);
	ret_ai.base_atk = int(pow((rand() % 5 + 115.0) / 100.0, ai_lv));
	ret_ai.real_hp = ret_ai.max_hp;

	if (rand() % 10 == 0)ret_ai.wea = mood_sword;
	else if (rand() % 10 <= 2)ret_ai.wea = stone_sword;
	else if (rand() % 10 <= 5)ret_ai.wea = iron_sword;
	else if (rand() % 10 <= 7)ret_ai.wea = gold_sword;
	else if (rand() % 10 <= 9)ret_ai.wea = diamond_sword;


	if (rand() % 10 == 0)ret_ai.arm = leather_armor;
	else if (rand() % 10 <= 2)ret_ai.arm = chain_armor;
	else if (rand() % 10 <= 5)ret_ai.arm = iron_armor;
	else if (rand() % 10 <= 7)ret_ai.arm = gold_armor;
	else if (rand() % 10 <= 9)ret_ai.arm = diamond_armor;


	ret_ai.drug_num = rand() % 3;
	for (int i = 1; i <= ret_ai.drug_num; i++) {
		if (rand() % 2 == 0)
			ret_ai.bag[i] = little_heart;
		else
			ret_ai.bag[i] = broken_heart;
	}

	return ret_ai;
}
void PrintInfo() {
	printf("#############################\n");
	printf("#       迷宫探险 v1.1       #\n");
	printf("# 开发者:jinyanshao(洛谷名) #\n");
	printf("#  特别鸣谢:MWL_wma(洛谷名) #\n");
	printf("#############################\n");
	printf("#     使用 wasd 进行控制    #\n");
	printf("#       画有\"&\"的地点       #\n");
	printf("#        代表一个man        #\n");
	printf("#       画有\"#\"的地点       #\n");
	printf("#         你无法进入        #\n");
	printf("#       画有\"*\"的地点       #\n");
	printf("#        代表一个惊喜       #\n");
	printf("#       画有\"!\"的地点       #\n");
	printf("#      代表最终的 Boss      #\n");
	printf("#  你的目标是达到右下角的点 #\n");
	printf("#      并且击败 Boss!      #\n");
	printf("#       起航吧探险者!      #\n");
	printf("#############################\n");
	system("pause");
}
void FightItemINIT() {
	mood_sword.name = "木剑 -|-- ", mood_sword.atk = 1, mood_sword.more_atk = 3, mood_sword.more_atk_rand = 2;
	stone_sword.name = "石剑 -|--> ", stone_sword.atk = 2, stone_sword.more_atk = 5, stone_sword.more_atk_rand = 3;
	iron_sword.name = "铁剑 =|==> ", iron_sword.atk = 3, iron_sword.more_atk = 7, iron_sword.more_atk_rand = 4;
	gold_sword.name = "金剑 =|===> ", gold_sword.atk = 4, gold_sword.more_atk = 9, gold_sword.more_atk_rand = 3;
	diamond_sword.name = "钻石剑 ==|====> ", diamond_sword.atk = 5, diamond_sword.more_atk = 10, diamond_sword.more_atk_rand = 3;
	end_sword.name = "下界合金剑 -+====> ", end_sword.atk = 7, end_sword.more_atk = 18, end_sword.more_atk_rand = 3;
	strange_sword.name = "阳寿剑  =:)==>", strange_sword.atk = 1, strange_sword.more_atk = 114514, strange_sword.more_atk_rand = 8;

	leather_armor.name = "皮革甲 (_)", leather_armor.dr = 3, leather_armor.percent_dr = 2.0, leather_armor.sb_rand = 1000, leather_armor.defense = 0;
	chain_armor.name = "锁链甲 (_)", chain_armor.dr = 3, chain_armor.percent_dr = 1.5, chain_armor.sb_rand = 1000, chain_armor.defense = 0;
	iron_armor.name = "铁甲 (_)", iron_armor.dr = 2.5, iron_armor.percent_dr = 1.0, iron_armor.sb_rand = 1000, iron_armor.defense = 0;
	gold_armor.name = "金甲 |_|", gold_armor.dr = 2, gold_armor.percent_dr = 0.9, gold_armor.sb_rand = 1000, gold_armor.defense = 10;
	diamond_armor.name = "钻石甲 |_|", diamond_armor.dr = 1.5, diamond_armor.percent_dr = 0.85, diamond_armor.sb_rand = 1000, diamond_armor.defense = 15;
	happy_armor.name = "下界合金甲 (::)", happy_armor.dr = 1.0, happy_armor.percent_dr = 0.75, happy_armor.sb_rand = 2, happy_armor.defense = 8;
	little_heart.name = "小血瓶 (o)", little_heart.hp_add = 10;
	broken_heart.name = "大血瓶 (0)", broken_heart.hp_add = 20;

	Summ.name = "Summ";
	Summ.drug_num = 0;
	Summ.base_atk = 10000;
	Summ.max_hp = 20;
	Summ.real_hp = 20;
	Summ.max_es = 100000;
	Summ.real_es = 100000;
	Summ.exp = 2;
	Summ.lv = 30;
	Summ.arm = diamond_armor;
	Summ.wea = end_sword;
}
void FightUI(PLAYER plr, PLAYER ai) {
	system("cls");
	cout << "等级:" << plr.lv << "(" << plr.exp << "/" << int(pow(1.5, plr.lv + 1)) << ")   " << plr.name << endl;
	cout << "武器 : " << plr.wea.name << endl;
	cout << "盔甲 : " << plr.arm.name << endl;
	cout << "血量 : " << plr.real_hp << "/" << plr.max_hp << endl;
	cout << "防御 : " << plr.real_es << "/" << plr.max_es + plr.arm.defense << endl;

	cout << endl << endl;

	cout << "等级:" << ai.lv << "(" << ai.exp << "/" << int(pow(1.5, ai.lv + 1)) << ")   " << ai.name << endl;
	cout << "武器 : " << ai.wea.name << endl;
	cout << "盔甲 : " << ai.arm.name << endl;
	cout << "血量 : " << ai.real_hp << "/" << ai.max_hp << endl;
	cout << "盔甲血量 : " << ai.real_es << "/" << ai.max_es + ai.arm.defense << endl;

	cout << endl << endl;

	cout << "按 k/K 键攻击,输入 1/2/3 来使用血瓶." << endl;
	cout << "背包" << endl;
	for (int i = 1; i <= plr.drug_num; i++)
		cout << i << "." << plr.bag[i].name << endl;

	cout << endl << endl;
}
void LevelUP(PLAYER &plr) {
	if (plr.exp < int(pow(1.5, plr.lv + 1)))
		return;
	else {
		system("cls");
		cout << "你升到了 " << plr.lv + 1 << " 级!" << endl;
		plr.exp -= int(pow(1.5, plr.lv + 1));
		plr.lv++;
		plr.max_hp = int((rand() % 3 + 10) * pow(1.25, plr.lv));
		plr.max_es = plr.max_hp / (rand() % 2 + 2);
		plr.base_atk = int(pow((rand() % 5 + 115.0) / 100.0, plr.lv));
		plr.real_hp = plr.max_hp;
	}
	if (HackerMode) {
		plr.base_atk = 10000;
		plr.max_hp = 1919810;
		plr.real_hp = 114514;
	}
}
void FightINIT(PLAYER &plr) {
	plr.real_es = plr.max_es;
}
void Attack(PLAYER &plr, PLAYER &ai) {
	int real_atk = plr.base_atk;
	if (plr.wea.more_atk_rand != 0 && rand() % plr.wea.more_atk_rand == 0) {
		cout << "暴击了!!!" << endl;
		real_atk += plr.wea.more_atk;
	} else
		real_atk += plr.wea.atk;
	if (ai.arm.percent_dr != 0)
		real_atk = real_atk * ai.arm.percent_dr;
#ifdef DEBUG
	cout << "DEBUG : now " << ai.name << " arm's precent_dr is " << ai.arm.percent_dr << endl;
	cout << "DEBUG : now " << plr.name << " real_atk is " << real_atk << endl;
#endif
	real_atk -= ai.arm.dr;
	real_atk = max(real_atk, 1);
	if (ai.arm.sb_rand != 0  &&  rand() % ai.arm.sb_rand == 0)
		cout << "闪避!" << endl;
	else {
		if (ai.arm.defense >= real_atk)
			ai.arm.defense -= real_atk;
		else if (ai.arm.defense + ai.real_es >= real_atk) {
			ai.arm.defense = 0;
			ai.real_es -= real_atk;
		} else {
			ai.arm.defense = 0;
			ai.real_es = 0;
			ai.real_hp = ai.real_hp - (real_atk - (ai.arm.defense + ai.real_es));
		}
	}
	cout << "铛! " << plr.name << " 造成了 " << real_atk << " 滴血 的伤害!" << endl;
}
bool Fight(PLAYER &plr, PLAYER ai) {
	FightINIT(plr);
	FightINIT(ai);
	while (1) {
		FightUI(plr, ai);
		if (plr.real_hp <= 0 && ai.real_hp <= 0) {
			cout << "你和敌人同归于尽了!\n";
			cout << "你将额外获得 1 滴血!\n";
			PAUSE(1.5);
			plr.real_hp = 1;
			return true;
		}
		if (plr.real_hp <= 0) {
			cout << "你输了!" << endl;
			Sleep(1000);
			cout << "你的荣耀将由下一个人传承" << endl;
			Sleep(1000);
			PAUSE(1.5);
			return false;
		}
		if (ai.real_hp <= 0) {
			cout << "恭喜你,在垃圾的攻击下活下来了!" << endl;
			plr.exp += max(1, (rand() % 3 + 10) * ai.lv / 10);
			LevelUP(plr);
			PAUSE(1.5);
			return true;
		}

		cout << plr.name << " , 轮到你了!" << endl;
atk_again:
		char op;
#ifdef WINDOWS
		in(op);
#endif
		if ('0' <= op && op <= '9') {
			int arr = op - '0';
			if (arr > plr.drug_num)
				cout << "你没有足够的药物了 :(" << endl;
			else {
				cout << plr.bag[arr].name << endl;
				for (int i = 1; i <= 4; i++) {
					cout << "gulu ";
					Sleep(300);
				}
				cout << endl;
				cout << "哎嘛,香!" << endl;
				Sleep(500);
				cout << "哎嘛,真香!" << endl;
				Sleep(500);
				cout << "哎嘛,太香了!" << endl;
				Sleep(500);
				for (int i = arr; i <= plr.drug_num - 1; i++)plr.bag[i] = plr.bag[i + 1];
				plr.drug_num--;
				plr.real_hp = min(plr.max_hp, plr.real_hp + plr.bag[arr].hp_add);
				cout << "铛! 你还有 " << plr.real_hp << "滴血 !" << endl;
			}
		} else if (op == 'K' || op == 'k')Attack(plr, ai);
		else {
			cout << "请按 k/K/1~9 操作" << endl;
			Sleep(500);

			goto atk_again;
		}
		PAUSE(2);
		FightUI(ai, plr);


		cout << ai.name << " , 轮到你了!" << endl;
		if (ai.real_hp * 2 < ai.max_hp && ai.drug_num != 0) {
			for (int i = 1; i <= 4; i++) {
				cout << "gulu ";
				Sleep(300);
			}
			int drug_maxx = -1, maxi;
			for (int i = 1; i <= ai.drug_num; i++) {
				if (ai.bag[i].hp_add > drug_maxx) {
					drug_maxx = ai.bag[i].hp_add;
					maxi = i;
				}
			}
			for (int i = maxi; i <= ai.drug_num - 1; i++)
				ai.bag[i] = ai.bag[i + 1];
			ai.drug_num--;
			ai.real_hp = min(ai.max_hp, ai.real_hp + drug_maxx);
			cout << ai.name << "现在血量有 " << ai.real_hp << "了!" << endl;
		} else {
			cout << ai.name << " 攻击了你 !" << endl;
			Attack(ai, plr);
		}
		PAUSE(2);
	}
}
void Pick() {
	int t = rand() % 3;
#ifdef DEBUG
	cout << "DEBUG:t is " << t << endl;
#endif
	if (t == 0) {
		WEAPON pick_it;
		int tt = rand() % 17;
		if (tt <= 3)pick_it = mood_sword;
		else if (tt <= 7)pick_it = stone_sword;
		else if (tt <= 10)pick_it = iron_sword;
		else if (tt <= 12)pick_it = gold_sword;
		else if (tt <= 14)pick_it = diamond_sword;
		else if (tt <= 15)pick_it = end_sword;
		else if (tt <= 16)pick_it = strange_sword;

		if (_P_.wea.atk) {
			cout << "换不换 ?" << endl;
			cout << _P_.wea.name << endl << pick_it.name << endl;
			cout << "(h / bh)" << endl;
			string ins;
			cin >> ins;
			if (ins == "h") {
				_P_.wea = pick_it;
				cout << "你得到了 " << pick_it.name << " !" << endl;
			}
		} else {
			_P_.wea = pick_it;
			cout << "你得到了 " << pick_it.name << " !" << endl;
		}
	} else if (t == 1) {
		ARMOR pick_it_2;
		int tt2 = rand() % 16;
		if (tt2 <= 3)pick_it_2 = leather_armor;
		else if (tt2 <= 7)pick_it_2 = chain_armor;
		else if (tt2 <= 10)pick_it_2 = iron_armor;
		else if (tt2 <= 12)pick_it_2 = gold_armor;
		else if (tt2 <= 14)pick_it_2 = diamond_armor;
		else if (tt2 <= 15)pick_it_2 = happy_armor;

		if (_P_.arm.dr ) {
			cout << "换不换 ?" << endl;
			cout << _P_.arm.name << endl << pick_it_2.name << endl;
			cout << "(h / bh)" << endl;
			string ins_2;
			cin >> ins_2;
			if (ins_2 == "h") {
				_P_.arm = pick_it_2;
				cout << "你得到了 " << pick_it_2.name << " !" << endl;
			}
		} else {
			_P_.arm = pick_it_2;
			cout << "你得到了 " << pick_it_2.name << " !" << endl;
		}
	} else {
		if (_P_.drug_num > MAX_DRUG_NUM) {
			cout << "你没有足够的空间了 :(" << endl;
			PAUSE(1);
			return;
		}
		int tt3 = rand() % 3;
#ifdef DEBUG
		cout << "DEBUG : _P_.drug_num is " << _P_.drug_num << endl;
#endif
		if (tt3 <= 1) {
			_P_.bag[++_P_.drug_num] = little_heart;
			cout << "你得到了 " << little_heart.name << " !" << endl;
		} else {
			_P_.bag[++_P_.drug_num] = broken_heart;
			cout << "你得到了 " << broken_heart.name << " !" << endl;
		}
	}
	PAUSE(1);
}
int Sx = 2, Sy = 2;
struct side {
	int from, to;
} edges[14405];
const int I = 17, J = 31;
int indplan = 0, p[125];
char maze[20][40];
vector<int> g[125];
long long seed = time(0);
void print(int x, int y);

int find(int x) {
	if (p[x] != x) {
		p[x] = find(p[x]);
	}
	return p[x];
}
void init() {
	memset(&edges, 0, sizeof(struct side));
	for (int i = 1; i <= 120; i++) {
		g[i].clear();
	}
	for (int i = 1; i <= 120; i++) {
		if (i + 15 >= 1 && i + 15 <= 120) {
			edges[++indplan].from = i;
			edges[indplan].to = i + 15;
		}
		if (i + 1 >= 1 && i + 1 <= 120 && i % 15 != 0) {
			edges[++indplan].from = i;
			edges[indplan].to = i + 1;
		}
	}
}

void kruskal() {
	memset(maze, '#', sizeof(maze));
	init();
	for (int i = 1; i <= 120; i++) {
		p[i] = i;
	}
	for (int j = 1; j <= indplan; j++) {
		int beyond = rand() % indplan + 1;
		swap(edges[j], edges[beyond]);
	}
	int endcnt = 0;
	for (int i = 1; i <= indplan; i++) {
		if (endcnt == 119) {
			break;
		}
		if (i + 1 == indplan && endcnt < 119) {
			i = 1;
		}
		if (rand() % 2) {
			if (find(edges[i].from) != find(edges[i].to)) {
				endcnt++;
				// cout << edges[i].from << ' ' << edges[i].to << endl;
				p[find(p[edges[i].from])] = find(edges[i].to);
				g[edges[i].from].push_back(edges[i].to - edges[i].from);
			}
		}
	}
	int id = 1;
	for (int i = 2; i <= I; i += 2) {
		for (int j = 2; j <= J; j += 2) {
			maze[i][j] = ' ';
			for (int k = 0; k < g[id].size(); k++) {
				if (g[id][k] == 1) {
					//->
					maze[i][j + 1] = ' ';
				}
				if (g[id][k] == 15) {
					//down
					maze[i + 1][j] = ' ';
				}
			}
#ifdef dev
			print(seed);
			clear();
#endif
			id++;
		}
	}
	for (int i = 1; i <= I; i++) {
		for (int j = 1; j <= J; j++) {
			if (maze[i][j] != '#') {
				int x = rand();
				maze[i][j] = (x % 8 == 0 ? '*' : (x % 8 == 1 ? '&' : ' '));
			}
		}
	}
	maze[I - 1][J - 1] = '!';
}

void print(int x, int y) {
	for (int i = 1; i <= I; i++) {
		for (int j = 1; j <= J; j++) {
			if (i == x && j == y) cout << "@";
			else cout << maze[i][j];
		}
		cout << endl;
	}
	cout << "# 等级:" << _P_.lv << "(" << _P_.exp << "/" << int(pow(1.5, _P_.lv + 1)) << ")   " << _P_.name;
	for (int i = 1; i <= 16 - logD(_P_.lv) - logD(_P_.exp) - logD(int(pow(1.5, _P_.lv + 1))) - _P_.name.length(); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 武器 : " << _P_.wea.name;
	for (int i = 1; i <= 21 - _P_.wea.name.length(); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 盔甲 : " << _P_.arm.name;
	for (int i = 1; i <= 21 - _P_.arm.name.length(); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 血量 : " << _P_.real_hp << "/" << _P_.max_hp;
	for (int i = 1; i <= 20 - logD(_P_.real_hp) - logD(_P_.max_hp); i++) {
		printf(" ");
	}
	printf("#\n");
	cout << "# 盔甲血量 : " << _P_.real_es << "/" << _P_.max_es + _P_.arm.defense;
	for (int i = 1; i <= 15 - logD(_P_.real_es) - logD(_P_.max_es + _P_.arm.defense); i++) {
		printf(" ");
	}
	printf("#\n");

	cout << "###############################\n";

	cout << "输入 1/2/3 来使用血瓶." << endl;
	cout << "背包" << endl;
	for (int i = 1; i <= _P_.drug_num; i++)
		cout << i << "." << _P_.bag[i].name << endl;

	cout << endl << endl;
}
//end makemap
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
void Operation(char ch, int &x, int &y, bool &dead) {
	if (!dead)return;
	int op;
	if (ch == 'w')op = 3;
	else if (ch == 'a')op = 1;
	else if (ch == 's')op = 2;
	else op = 0;
	if (ch >= '1' && ch <= '9') {
		int arr = ch - '0';
		if (arr > _P_.drug_num)
			cout << "你没有足够的药物了 :(" << endl;
		else {
			cout << _P_.bag[arr].name << endl;
			for (int i = 1; i <= 4; i++) {
				cout << "gulu ";
				Sleep(300);
			}
			cout << endl;
			cout << "哎嘛,香!" << endl;
			Sleep(500);
			cout << "哎嘛,真香!" << endl;
			Sleep(500);
			cout << "哎嘛,太香了!" << endl;
			Sleep(500);
			for (int i = arr; i <= _P_.drug_num - 1; i++)_P_.bag[i] = _P_.bag[i + 1];
			_P_.drug_num--;
			_P_.real_hp = min(_P_.max_hp, _P_.real_hp + _P_.bag[arr].hp_add);
		}
	}
	int nx = x + dx[op], ny = y + dy[op];
	if (nx < 1 || nx > I || ny < 1 || ny > J)return;
	if (maze[nx][ny] == '#')return;
	if (maze[nx][ny] == '*') {
		Pick();
		maze[nx][ny] = ' ';
	}
	if (maze[nx][ny] == '&') {
		dead = Fight(_P_, SummonAI(max(1, min(9, _P_.lv + rand() % 4 - 2))));
		if (dead)
			maze[nx][ny] = ' ';
	}
	if (maze[nx][ny] == '!') {
		if (!HackerMode)
			dead = Fight(_P_, SummonAIBOSS());
		else {
			cout << endl << "不 " << _P_.name << "!!! 这是BOSS !!!" << endl;
			PAUSE(1);
			dead = Fight(_P_, Summ);
		}
		if (dead) {
			maze[nx][ny] = ' ';
			cout << " 你通关了!!! 你可以 退出 或者 继续探索 !!!\n";
			PAUSE(2);
			system("cls");
			printf("#############################\n");
			printf("#       迷宫探险 v1.1       #\n");
			printf("# 开发者:jinyanshao(洛谷名) #\n");
			printf("#  特别鸣谢:MWL_wma(洛谷名) #\n");
			printf("#############################\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#     You win the game!     #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#      按 y 以继续探索      #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#        按 n 以退出        #\n");
			printf("#                           #\n");
			printf("#                           #\n");
			printf("#############################\n");
			char ch;
			ch = getch();
			if (ch == 'n') {
				Exit = 1;
			}
		}
	}
	x = nx, y = ny;
}
void Game(int x, int y) {
back_and_agian:
	kruskal();
	cout << "注意看!@是你" << endl;
	print(x, y);
	cout << endl << "请使用 wasd 控制 @ 行走" << endl << endl;
	cout << "如果这个地图错误了,你可以按下 Esc 重开.";
	cout << endl;
	char ch;
	ch = getch();
	if (ch == 27) {
		system("cls");
		goto back_and_agian;
	}
	while (1) {
		ch = getch();
		bool dead = true;
		Operation(ch, x, y, dead);
		if (!dead || Exit)return;
		system("cls");
		print(x, y);
	}
}
int main() {
	PrintInfo();
	system("cls");
	_P_ = SummonAI(1);
	cout << "请输入名字:";
	cin >> _P_.name;
	if (_P_.name == "经验")
		_P_.exp += 10000;
	if (_P_.name == "创造") {
		_P_.base_atk = 10000;
		_P_.max_hp = 1919810; 
		_P_.real_hp = 114514;
		HackerMode = true;
	}
	seed = time(NULL);
	srand(seed);
	FightItemINIT();
	Game(Sx, Sy);
	return 0;
}`