模拟帝国类游戏(c++语言)(保证能运行)

直接上代码(游戏有的功能没做,还不能用):

作者卑微申请:给个赞,再观看:

# include 
# include 
# include 
using namespace std;
void player_one(int end)
{
int year,level,people,soldiers,money,food,point,a1,a2,a3,a4,mind,rate,people_money,assemble,ready=0,ready1=0;
year=0; level=1; people=100; soldiers=0; money=100000; food=200; mind=100; rate=5; assemble=0; 
cout<<"Note: The initial grain is only enough for the people to survive for 2 years"
	<<"";
cin>>a1;
while (end==0)
{
	if (level==1)	point=5;
	if (level==2)   point=10;
	if (level==3)   point=15;
	if (level==4)   point=20;
	year+=1;
	system("cls");
	cout<<"                                                                "
		< 100)"<>a3;
		a3=(a3%100*2/4%20+27)%10%2;
		if (a3==0)
		{
			cout<<"you win the war,lose soldiers:"<0)
	{
		cout<<"result:                                                 <1>make soldiers:                      2points "<make money:                         2points"<make food:                          1point "<assemble soldiers:                  3points "<fight a war:                        3points"<change tax:                         no point"<Diplomacy:                          2points "<random event:                       3points "<investigate the enemy's situation:  2points"<next year"<end"<>a1;
		//招募士兵 
		if (a1==1)
		{
			if (point>=2)
			{
				point-=2;
				srand(time(0));
	    		cout<<"write the random number(the number must >2000)"<>a2;
	    		if (level==1)a2=(a2%100/7*3/2*5)%90;
	    		if (level==2)a2=((a2%500/3*2+a2%100/2)/2+a1%200/3)%480;
	   			if (level==3)a2=(a2%1000+a2%1000/3)%800;
	    		if (level==4)a2=(a2%2000/2+a2%2000/3*2-a2%800)%2000;
				while (a2+soldiers>people)
				{
					if (level==1)a2=(a2%100/7*3/2*5)%90;
	    			if (level==2)a2=((a2%500/3*2+a2%100/2)/2+a1%200/3)%480;
	   				if (level==3)a2=(a2%1000+a2%1000/3)%800;
	    			if (level==4)a2=(a2%2000/2+a2%2000/3*2-a2%800)%2000;
			} 
			soldiers+=a2;
    		cout<<"make soldiers:"<people/2) cout<<"You seem to have too many soldiers,this will lead to a gradual shortage of food for you."
									   <=2)
			{
			point-=2;
			srand(time(0));
			int b=rand()%money/5;
			money+=b;
			cout<<"make money:"<=1)
			{
				point-=1;
				srand(time(0));
				int c=rand()%(people-soldiers)/5*80;
				food+=c;
				cout<<"make food:"<=3)
			{
			
			cout<<"write your assemble soldiers's number."<>a3;
			if (a3>soldiers||a3==0)
				cout<<"the number must < your all soldiers and the number must > 0."<=3)
			{
			if (a3==0)
				cout<<"you must assemble soldiers before you fight a war."<=1)
			{
				cout<<"+ or -(1 or 2)"<>a3;
				cout<<"write the number (after - must >= 0,after + must <=100)"<>a4;
				if (a3==2)
				{
					while (a4>=rate)
					{
						cout<<"the number is wrong.please write again."<= 0,after + must <=100)"<>a4;
					}
					rate-=a4;
				}
				else
				{
					while (a4+rate>100)
					{
						cout<<"the number is wrong.please write again."<= 0,after + must <=100)"<>a4;
					}
					rate+=a4;
				}
				
			}
			else	cout<<"you have no points to do that."<=2)
			{
				cout<<"write your use money."<>a3;
				if (a3>money)	cout<<"please write again."<=90) mind+=3;
					if (mind<90&&mind>=80) mind+=7;
					if (mind<80) mind+=10;
				}
			}
			else	cout<<"you have no points to do that."<=3)
			{
				cout<<"write the random number.(the number must >100)"<>a3;
				a3=(a3%10*2%7*3%9+1)%3;
				if (a3==1)
				{
					cout<<"a major earthquake has struck your country,causing half of the money to be lost."<10&&rate<25)
				{
					cout<<"the rate is too big!!!"<=25&&rate<50)
				{
					cout<<"the rate is too big!!!"<=50)
				{
					cout<<"the rate is too big!!!"<food)
	{
		cout<<"this year,"<=10&&mind<20)
	{
		cout<<"\033[31mcaution!!!:your country's people mind is too low\033[0m"
			<<"your country has suffered an uprising,which has failed.the number of soldiers and people has been halved."
			<";
	cin>>a1;
 }
}


int main()
{
int end,result,x1;
end=0;
cout<<"                                                              "
	  "         Empire          " 
	<  two player<2>"
	  "                       "
	<>x1;
if (x1==1)
{
	player_one(end);
}
else
{
	cout<<"sorry,the part is not open now."<

你可能感兴趣的:(c++,游戏,算法)