#include<assert.h>
#include<ctype.h>
#include<errno.h>
#include<float.h>
#include<fstream>
#include<iomanip>
#include<limits.h>
#include<locale.h>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<wchar.h>
#include<wctype.h>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<map>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
#include<complex.h>
#include<fenv.h>
#include<inttypes.h>
#include<stdbool.h>
#include<conio.h>
#include<stdint.h>
#include<tgmath.h>
#include<windows.h>
#include<list>
#include<iterator>
#include<stack>
#include<commdlg.h>
#include<ole2.h>
#include<winerror.h>
#include<objbase.h>
#include<oleauto.h>
#include<pshpack8.h>
#include<oleidl.h>
#include<rpc.h>
#include<rpcndr.h>
#include<stralign.h>
#include<winsvc.h>
#include<mcx.h>
#include<imm.h>
#include<stddef.h>
#include<_mingw_unicode.h>
#include<_mingw.h>
#include<basetsd.h>
#include<pshpack1.h>
#include<poppack.h>
#include<crtdefs.h>
#include<sec_api/conio_s.h>
#include"_mingw_mac.h"
#include"_mingw_secapi.h"
#include<apisetcconv.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
	char f;
	system("title 逃出地牢");
	string s="|                  逃出地牢                  | ";
	string s1="|                  准备好了(k)               |";
	string s2="|                  玩法说明(a)开发ing        |";
	long long x=1,y=1,q=0,cx=1,cy=1,dy=1,kk=0,z=1;
	cout<<"------------------------------------------";
	cout<<endl;
	long long ss=0;
	char dt[124][32]={"###############################",
					 "#n *   #*   #           #  *# #",
					 "#  #####  ##*## # #### ##  ## #",
					 "#   #      # #* #  ###    ### #",
					 "### #### # #### ## ###### ### #",
					 "#                         * # #", 
					 "#     #########################",
					 "#d    #*         *          ###",
					 "#    ##   ############# * #####",
					 "#         #  **################",
					 "###############################"
	};
	for(int i=0;i<=40;i++){
		cout<<s[i];
		Sleep(20);
	}
	cout<<"|"<<endl;
	for(int i=0;i<=40;i++){
		cout<<s1[i];
		Sleep(20);
	}
	cout<<"|"<<endl; 
	for(int i=0;i<=40;i++){
		cout<<s2[i];
		Sleep(20);
	}
	cout<<"|"<<endl;
	cout<<"------------------------------------------";
	cout<<endl;
	cout<<"注:wsad上下左右,c设置传送点,v前往传送点,h回家,0是终点,共有12把钥匙,n是你,d是敌人(只会观察左右)"<<endl; 
	char c;
	cin>>c;
	if(c=='k'){
		system("cls");
		for(int i=1;i<=3;i++){
			cout<<"                  加载中";
			for(int j=0;j<=2;j++){
				cout<<".";
				Sleep(500);
			}
			system("cls");
		}
		while(1){
			system("color 0D");
			cout<<"已拿到"<<ss<<"把钥匙"<<endl;
			for(int i=0;i<=11;i++){
				puts(dt[i]);
			}
			f=getch();
			if(f=='a' and dt[x][y-1]!='#'){
				if(dt[x][y-1]=='*'){
					ss++;
					dt[x][y-1]=' ';
				}
				dt[x][y]=' ';
				y--;
				dt[x][y]='n';
				if(dt[x][y-1]=='0'){
					cout<<"胜利!!!";
					break;
				}
			}
			if(f=='d' and dt[x][y+1]!='#'){
				if(dt[x][y+1]=='*'){
					ss++;
					dt[x][y+1]=' ';
				}
				dt[x][y]=' ';
				y++;
				dt[x][y]='n';
				if(dt[x][y+1]=='0'){
					cout<<"胜利!!!";
					break;
				}
			}
			if(f=='w' and dt[x-1][y]!='#'){
				if(dt[x-1][y]=='*'){
					ss++;
					dt[x-1][y]=' ';
				}
				dt[x][y]=' ';
				x--;
				dt[x][y]='n';
				if(dt[x-1][y]=='0'){
					cout<<"胜利!!!";
					break;
				}
			}
			if(f=='c'){
				cx=x;
				cy=y;
			}
			if(f=='v'){
				dt[x][y]=' ';
				x=cx;
				y=cy;
				dt[x][y]='n';
			}
			if(f=='s' and dt[x+1][y]!='#'){
				if(dt[x+1][y]=='*'){
					ss++;
					dt[x+1][y]=' ';
				}
				if(dt[x+1][y]=='0'){
					cout<<"胜利!!!";
					break;
				}
				dt[x][y]=' ';
				x++;
				dt[x][y]='n';
			}
			if(ss==8 and q==0){
				dt[9][10]=' ';
				q++;
				
			}
			if(ss==10 and q==1){
				dt[3][5]='*';
				q++;
			}
			if(ss==11 and q==2){
				dt[3][13]='n';
				dt[x][y]=' ';
				x=3;y=13;
				q++;
			}
			if(x==9 and y==10){
				dt[9][12]='#';
				dt[8][13]=' ';
				
			}
			system("cls");
			if(ss==12){
				dt[2][1]='0';
			}
			if(f=='h'){
				dt[x][y]=' ';
				x=1;
				y=1;
				dt[x][y]='n';
			}
			if(kk==0){
				z++;
				dt[7][z]='d';
				dt[7][z-1]=' ';
				dy++;
				if(z==5){
					kk=1;
				}
			}
			if(kk==1){
				z--;
				dt[7][z]='d';
				dt[7][z+1]=' ';
				dy--;
				if(z==1){
					kk=0;
				}
			}
			if(f=='z'){
				string w;
				cin>>w;
				if(w=="zb"){
					dt[3][5]='*';
					while(1){
						cout<<"已拿到"<<ss<<"把钥匙"<<endl;
						for(int i=0;i<=11;i++){
							puts(dt[i]);
						}
						f=getch();
						if(f=='w'){
							dt[x][y]=' ';
							x--;
							if(dt[x][y]=='*'){
								ss++;
							}
							dt[x][y]='n';
						}
						if(f=='s'){
							dt[x][y]=' ';
							x++;
							if(dt[x][y]=='*'){
								ss++;
							}
							dt[x][y]='n';
						}
						if(f=='a'){
							dt[x][y]=' ';
							y--;
							if(dt[x][y]=='*'){
								ss++;
							}
							dt[x][y]='n';
						}
						if(f=='d'){
							dt[x][y]=' ';
							y++;
							if(dt[x][y]=='*'){
								ss++;
							}
							dt[x][y]='n';
						}
						if(f=='b'){
							cout<<"关闭"<<endl;
							Sleep(100);
							system("cls");
							break;
						}
						system("cls");
					}
				}
			}
			if(dy==y-1 and x==7 or dy==y+1 and x==7 or y==dy and x==7){
				cout<<"你被敌人抓住了!";
				break;
			}
		}
	}
}