自己做的c++小游戏

        大家好,是我syex_luoyukai,这次完结了传奇打怪,从别人那学来了存档功能(此篇为LYK游戏机的完结,后续会出新的游戏,最近一段时间由于学业压迫,可能会减少发的次数)

#include<bits/stdc++.h>
using namespace std;
long long i,k,t,dgbb[1000],dgq,j,gx,dgx,sh;
long long dgjg[1000]={0,10,30,1,45,100,2,5,60,4},dgxl[1000]={0,10,25,0,30,0,0,0,50,0};
string s[1000]={"","匕首","长弓","弓箭","大刀","战甲","木头","铁","手枪","子弹"}; 
bool zd;
void knss()
{
	system("cls");
	int a,b,c;
	srand(time(0));
	a=rand()%100+0;
	b=rand()%100+0;
	cout<<a<<"*"<<b<<"=";
	cin>>c;
	if(t==10)
	{
		return;
	}
	if(a*b==c)
	{
		system("cls");
		cout<<"你对了"<<endl;
		system("pause");
	}
	else
	{
		system("cls");
		cout<<"答错了,在来一遍吧!"<<endl;
		system("pause");
		knss(); 
		t++;
	}
	return;
}
void jdss()
{
	system("cls");
	int n,m,j;
	srand(time(0));
	n=rand()%10000+0;
	m=rand()%10000+0;
	cout<<n<<"+"<<m<<"=";
	cin>>j;
	if(t==10)
	{
		return;
	}
	if(n+m==j)
	{
		system("cls");
		cout<<"你对了,难度升级"<<endl;
		t=0;
		system("pause");
		knss(); 
	}
	else
	{
		system("cls");
		cout<<"答错了,在来一遍吧!"<<endl;
		system("pause");
		jdss(); 
		t++;
	}
	return;
}
void ss()
{
	int n;
	system("cls");
	cout<<"请选择模式"<<endl;
	cout<<"简单按1"<<endl;
	cout<<"困难按2"<<endl; 
	cin>>n;
	system("cls");
	if(n==1)
	{
		jdss();
	}
	if(n==2)
	{
		knss();
	}
 
}
void cs()
{
	system("cls");
	cout<<"在0到10000间选一个数"<<endl; 
	int n,m;
	srand(time(0));
	n=rand()%10000+0;
	while(1)
	{
		cin>>m;
		if(m>n)
		{
			cout<<"大了"<<endl; 
		}
		if(m<n)
		{
			cout<<"小了"<<endl; 
		}
		if(m==n)
		{
			cout<<"对了"<<endl;
			system("pause");
			return; 
		}
	}
}
void xsl()
{
	dgx=100;
	int t,n,j,i;
	srand(time(0));
	t=rand()%10+0;
	if(t>=0&&t<=8)
	{
		gx=50;
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了麻雀"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			else if(n==-1)
			{
				return;
			 } 
			else
			{
				srand(time(0));
				j=rand()%10+0;
				if(j<=9&&j>=0)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"麻雀受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"麻雀躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了麻雀"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				system("pause");
				dgq+=j;
				gx=50;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(10-dgbb[5]*5<0)
						sh=0;
					else
						sh=10-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
					dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了10点伤害"<<endl; 
					dgx-=10;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}
	}
	
	
	
	else
	{
		gx=100;	
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了老虎"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			else
			{
				srand(time(0));
				j=rand()%10+0;
				if(j<=9&&j>=0)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"老虎受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"老虎躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了老虎"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				dgq+=j;
				system("pause");
				gx=100;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(15-dgbb[5]*5<0)
						sh=0;
					else
						sh=15-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
					dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了15点伤害"<<endl; 
					dgx-=15;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}	
	}
}
void sgsl()
{
	dgx=100;
	int t,n,j,i;
	srand(time(0));
	t=rand()%10+0;
	if(t>=0&&t<=3)
	{
		gx=500;
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了狮子"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(n==-1)
			{
				return;
			} 
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			
			else
			{
				srand(time(0));
				j=rand()%30+0;
				if(j<=27&&j>=3)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"狮子受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"狮子躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了狮子"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				system("pause");
				dgq+=j;
				gx=50;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(20-dgbb[5]*5<0)
						sh=0;
					else
						sh=20-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
					dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了20点伤害"<<endl; 
					dgx-=20;
					if(dgx<0)
					dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}
	}
	
	
	
	else
	{
		gx=200;	
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了毒蛇"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			else
			{
				srand(time(0));
				j=rand()%20+0;
				if(j<=18&&j>=9)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"毒蛇受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"毒蛇躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了毒蛇"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				dgq+=j;
				system("pause");
				gx=100;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(15-dgbb[5]*5<0)
						sh=0;
					else
						sh=15-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
					dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了10点伤害"<<endl; 
					dgx-=10;
					if(zd==1)
					{
						dgx-=5;
					}
					if(dgx<0)
						dgx=0;
					cout<<"你中毒了(每回合多扣5滴血)\n"<<"你还有"<<dgx<<"点血"<<endl;
					zd=1;
				}
				
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}	
	}
}
void sbdk()
{
		dgx=100;
	int t,n,j,i;
	srand(time(0));
	t=rand()%10+0;
	if(t>=0&&t<=3)
	{
		gx=100;
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了强盗首领,他有两把手枪"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(n==-1)
			{
				return;
			} 
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			
			else
			{
				srand(time(0));
				j=rand()%100+0;
				if(j<=90&&j>=10)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"强盗首领受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"强盗首领躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了强盗首领"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				system("pause");
				dgq+=j;
				gx=50;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(100-dgbb[5]*5<0)
						sh=0;
					else
						sh=100-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了100点伤害"<<endl; 
					dgx-=100;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}
	}
	
	
	
	else
	{
		gx=100;	
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了强盗小兵,他有一把带毒的小刀"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			else
			{
				srand(time(0));
				j=rand()%50+0;
				if(j<=45&&j>=5)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"强盗小兵受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"强盗小兵躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了强盗小兵"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				dgq+=j;
				system("pause");
				gx=100;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(30-dgbb[5]*5<0)
						sh=0;
					else
						sh=30-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了20点伤害"<<endl; 
					dgx-=20;
					if(zd==1)
					{
						dgx-=10;
					}
					if(dgx<0)
						dgx=0;
					cout<<"你中毒了(每回合多扣10滴血)\n"<<"你还有"<<dgx<<"点血"<<endl;
					zd=1;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}	
	}
}
 
void sg()
{
	long long n;
	system("cls");
	cout<<"请选择你要去山谷的哪处"<<endl;
	cout<<"1:山中树林(简单)"<<endl;
	cout<<"2:山壁(困难)"<<endl;
	cin>>n;
	if(n==-1)
	{
		return;
	} 
	if(n==1)
	{
		sgsl();
	} 
	if(n==2)
	{
		sbdk();
	}
}
void xxmx()
{
	dgx=100;
	int t,n,j,i;
	srand(time(0));
	t=rand()%10+0;
	if(t>=0&&t<=3)
	{
		gx=300;
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了骷髅怪"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(n==-1)
			{
				return;
			} 
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			
			else
			{
				srand(time(0));
				j=rand()%100+0;
				if(j<=90&&j>=10)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"骷髅怪受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"骷髅怪躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了骷髅怪"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				system("pause");
				dgq+=j;
				gx=50;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(100-dgbb[5]*5<0)
						sh=0;
					else
						sh=100-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了100点伤害"<<endl; 
					dgx-=100;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}
	}
	
	
	
	else
	{
		gx=200;	
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了墓穴守卫者,他有一把带毒的小刀"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			else
			{
				srand(time(0));
				j=rand()%100+0;
				if(j<=90&&j>=10)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"墓穴守卫者受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"墓穴守卫者躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了墓穴守卫者"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				dgq+=j;
				system("pause");
				gx=100;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(40-dgbb[5]*5<0)
						sh=0;
					else
						sh=40-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了40点伤害"<<endl; 
					dgx-=40;
					if(zd==1)
					{
						dgx-=10;
					}
					if(dgx<0)
						dgx=0;
					cout<<"你中毒了(每回合多扣10滴血)\n"<<"你还有"<<dgx<<"点血"<<endl;
					zd=1;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}	
	}
}
void dxmx()
{
	dgx=100;
	int t,n,j,i;
	srand(time(0));
	t=rand()%10+0;
	if(t>=0&&t<=3)
	{
		gx=300;
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了兵马俑"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(n==-1)
			{
				return;
			} 
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			
			else
			{
				srand(time(0));
				j=rand()%100+0;
				if(j<=90&&j>=10)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"兵马俑受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"兵马俑躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了兵马俑"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				system("pause");
				dgq+=j;
				gx=50;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(200-dgbb[5]*5<0)
						sh=0;
					else
						sh=200-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了200点伤害"<<endl; 
					dgx-=200;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}
	}
	
	
	
	else
	{
		gx=200;	
		while(1)
		{
			
			system("cls");
			cout<<"你遇到了亡灵"<<endl;
			cout<<"输入你要用的武器"<<endl;
			cin>>n;
			if(dgbb[n]==0||n==2&&dgbb[3]==0||n==8&&dgbb[9]==0)
			{
				cout<<"对不起,你没有该物品"<<endl;
				system("pause");
			}
			else
			{
				srand(time(0));
				j=rand()%100+0;
				if(j<=90&&j>=10)
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"亡灵者受到了"<<dgxl[n]<<"点伤害"<<endl;
					gx-=dgxl[n]; 
					if(gx<0)
						gx=0;
					cout<<"它还有"<<gx<<"点血"<<endl;
				}
				else
				{
					if(n==2)
					{
						dgbb[3]--;
					} 
					if(n==8)
					{
						dgbb[9]--;
					}
					cout<<"亡灵躲过了攻击"<<endl;
				}
				system("pause");
			}
			if(gx<=0)
			{
				cout<<"恭喜你,打败了亡灵"<<endl;
				cout<<"你获得了"<<j<<"个金币"<<endl;
				dgq+=j;
				system("pause");
				gx=100;
				return;
			}
			srand(time(0));
			t=rand()%10+0;
			if(t<=9)
			{
				if(dgbb[5]!=0)
				{
					if(50-dgbb[5]*5<0)
						sh=0;
					else
						sh=50-dgbb[5]*5;
					cout<<"你受到了"<<sh<<"点伤害"<<endl;
					dgx-=sh;
					if(dgx<0)
						dgx=0;
					cout<<"你还有"<<dgx<<"点血"<<endl; 
				}
				else
				{
					cout<<"你受到了50点伤害"<<endl; 
					dgx-=50;
					cout<<"你还有"<<dgx<<"点血"<<endl;
				}
				system("pause");
			}
			else
			{
				cout<<"你躲过了攻击"<<endl;
				system("pause");
			}
			
			if(dgx<=0)
			{
				cout<<"你死了"<<endl;
				system("pause");
				return;
			}
		}	
	}	
} 
void md()
{
	int n;
	system("cls");
	cout<<"你想去墓地的哪处"<<endl;
	cout<<"1.小型墓穴"<<endl;
	cout<<"2.大型墓穴"<<endl;
	cin>>n;
	if(n==1)
	{
		xxmx();
	}
	if(n==2)
	{
		dxmx();
	}
}
void dg()
{
	dgx=100;
	zd=0; 
	int n;
	while(1)
	{
		system("cls");
		cout<<"请选择打怪地点(退出按-1,死亡退出)"<<endl;
		cout<<"1:小树林(简单)"<<endl;
		cout<<"2:山谷(普通)"<<endl;
		cout<<"3:墓地(困难)"<<endl;
		cin>>n;
		if(n==-1||dgx<=0)
		{
			return;
		}
		if(n==1)
		{
			xsl();
		}
		if(n==2)
		{
			sg();
		}
		if(n==3)
		{
			md();
		}
	}
} 
 
void sd()
{
	system("cls");
	int n,m;
	for(i=1;i<=9;i++)
	{
		cout<<i<<":购买"<<s[i]<<"要用"<<dgjg[i]<<"个金币"<<endl; 
	}
	cout<<"你有"<<dgq<<"个金币"<<endl;
	cout<<"请输入你要买的物品"<<endl;
	cin>>n;
	cout<<"请输入你要买物品的数量"<<endl;
	cin>>m;
	if(dgjg[n]*m>dgq)
	{
		cout<<"对不起,你没有足够的金币"<<endl;
		system("pause");
	}
	else
	{
		cout<<"购买成功"<<endl;
		dgq-=dgjg[n]*m; 
		dgbb[n]+=m;
		system("pause");
	}
}
void zzt()
{
	int n,t;
	system("cls");
	cout<<"可制作的物品有"<<endl;
	cout<<"-1: 退出"<<endl;
	cout<<"1: 1块铁+1块木头=8只弓箭"<<endl;
	cout<<"2: 4快铁=6枚子弹"<<endl;
	cout<<"3: 10块木头=1把长弓"<<endl;
	cin>>n;
	srand(time(0));
	t=rand()%10+0;
	if(n==-1)
	{
		return;
	}
	if(n==1)
	{
		if(dgbb[6]>=1&&dgbb[7]>=1)
		{
			dgbb[6]--;
			dgbb[7]--;
			if(t<=2)
			{
				cout<<"对不起,由于你的手抖了一下,弓箭制造失败(任会扣除材料)"<<endl;
				system("pause");
			}
			else
			{
				cout<<"恭喜你制造弓箭成功"<<endl;
				system("pause");
				dgbb[3]+=8; 
			} 
		}
		else
		{
			cout<<"对不起,你没有该物品"<<endl;
			system("pause");
		}
	}
	if(n==2)
	{
		if(dgbb[7]>=4)
		{
			dgbb[7]-=4;
			if(t<=3)
			{
				cout<<"对不起,由于你的手抖了一下,子弹制造失败(任会扣除材料)"<<endl;
				system("pause");
			}
			else
			{
				cout<<"恭喜你制造子弹成功"<<endl;
				system("pause");
				dgbb[9]+=6; 
			} 
		}
		else
		{
			cout<<"对不起,你没有该物品"<<endl;
			system("pause");
		}
		
	}
	if(n==3)
	{
		if(dgbb[6]>=10)
		{
			dgbb[6]-=10;
			if(t<=3)
			{
				cout<<"对不起,由于你的手抖了一下,长弓制造失败(任会扣除材料)"<<endl;
				system("pause");
			}
			else
			{
				cout<<"恭喜你制造长弓成功"<<endl;
				system("pause");
				dgbb[2]++; 
			} 
		}
		else
		{
			cout<<"对不起,你没有该物品"<<endl;
			system("pause");
		}
		
	}
}
void bb()
{
	system("cls");
	for(i=1;i<=9;i++)
	{
		cout<<s[i]<<" "<<dgbb[i]<<endl; 
	}
	cout<<"金币:"<<dgq<<endl;
	system("pause");
}
void cq()
{
	int n,m,i,j,k;
	system("cls");
	cout<<"欢迎来到传奇打怪"<<endl;
	system("pause");
	while(1){
		system("cls");
		cout<<"退出按-1"<<endl; 
		cout<<"查看背包按1"<<endl;
		cout<<"去商店按2"<<endl;
		cout<<"去打怪按3"<<endl;
		cout<<"去制作台按4"<<endl; 
		cout<<"读取存档按5"<<endl;
		cout<<"保存按6"<<endl;
		cin>>n;
		if(n==-1)
		{
			return;
		}
		if(n==1)
		{
			bb(); 
		}
		if(n==2)
		{
			sd();		
		}
		if(n==3)
		{
			dg(); 
		}
		if(n==4)
		{
			zzt();
		}
		if(n==5)
		{
			ifstream ifile;
			ifile.open("dg.txt");
			for(i=1;i<=9;i++)
			{
				ifile>>dgbb[i];
			}
			ifile>>dgq;
			cout<<"读取成功"<<endl;
			system("pause");
		}
		if(n==6)
		{
			ofstream file;
			file.open("dg.txt", ios::out);
			for(i=1;i<=9;i++)
			{
				file<<dgbb[i]<<endl;
			}
			file<<dgq;
			file.close();
			cout<<"保存成功"<<endl;
			system("pause");
		}
	}	
}
int main(){
	dgbb[1]=1;
	dgq=100;
	while(1)
	{
		system("cls");
		cout<<"欢迎进入LYK游戏机";
		cout<<endl;
		cout<<"算数游戏按1"<<endl;
		cout<<"猜数游戏按2"<<endl;
		cout<<"传奇打怪按3"<<endl; 
		cin>>k;
		if(k==1)
		{
			ss();
		} 	
		if(k==2)
		{
			cs();
		}
		if(k==3)
		{
			cq();
		}
	}
    return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值