神奇又简单的抽卡游戏c++

Posted 道标 · 落彡

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了神奇又简单的抽卡游戏c++相关的知识,希望对你有一定的参考价值。

不想写注释

#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <bits/stdc++.h>
using namespace std;
void cc(const string a)
{
	size_t len = a.size();
	for(int i = 0; i < a.size(); i++)
	{
		cout << a[i];
		usleep(32000);

	}
	cout<<"\\n";
}

//抄袭可耻,创意最珍!
const int chao_xi_zhe = 250;
const int AAA = 37,BBB = 29;
int ja = 15,jb=2,jc=27;
int lck[99] = {-1,2,4,-1,5,-2,6,2,8,-3,6,2,7,-3,8,2,4,5,7,9,3,5,-2};
int main()
{
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	cc("抄袭可耻,创意最珍!");
	system("cls");
	usleep(10000);
	int z;
	cout<<"是否查看规则&剧情?"<<endl;
	cout<<"是选1,不是选2"<<endl;
	cin >>z;
	if(z == 1)
	{
		system("cls");
		cout<<"欢迎来到 抽卡人生"<<endl;
		sleep(1);
		cout<<"2109年,迷##执掌大权"<<endl;
		sleep(1);
		cout<<"同时制定了一系列不公的政策"<<endl;
		sleep(1);
		cout<<"你干什么都要抽卡,吃饭,喝水。。。"<<endl;
		sleep(1);
		cout<<"你是一位打击迷##的正(造)义(反)人(分)士(子)"<<endl;
		sleep(1);
		cout<<"被抓进了监狱"<<endl;
		sleep(1);
		cout<<"必须逃出去!"<<endl;
		sleep(1);
		cout<<"下面为规则"<<endl;
		sleep(1);
		cout<<"你一天能干五件事"<<endl;
		sleep(1);
		cout<<"吃饭和喝水都需要卡"<<endl;
		sleep(1);
		cout<<"卡包里装你拥有的卡"<<endl;
		sleep(1);
		cout<<"在商店里,你可以买卖卡片(除了RRPG卡)"<<endl;
		sleep(1);
		cout<<"你每抽一次卡都要花金币"<<endl;
		sleep(1);
		cout<<"睡觉可以让你更快乐,同时进入下一天"<<endl;
		sleep(1);
		cout<<"当你的饥饿(干渴值)为零时"<<endl;
		sleep(1);
		cout<<"或是快乐值小于30时"<<endl;
		sleep(1);
		cout<<"你的生命值就会下降"<<endl;
		sleep(1);
		cout<<"降到0就死了"<<endl;
		sleep(1);
		cout<<"哦对了,你需要抽到10张RPG卡才能出狱"<<endl;
		sleep(1);
		cout<<"生存下去吧!"<<endl;
		sleep(1);
		system("cls");
	}
	system("cls");
	cout<<"是否有存档?"<<endl<<"1、有    2、没有";
	int table;
	cin >> table;
	int tme = 1;
	srand(time(0));
	int life,gold,hungry,sirsty,happy,time;
	int cardA,cardB,cardC,cardRPG,cardfood,cardwater;
	int A,B,C,food,water,RPG;
	int a,b,c,d,e,f;
	if(z != 3)
	{
		life = 100;
		gold = 100;
		hungry = 100;
		sirsty = 100;
		happy = 100;
		cardA = 0;
		cardB = 0;
		cardC = 0;
		cardfood = 0;
		cardwater = 0;
		cardRPG = 0;
	}
	else
	{
		cout<<"你好,帅气的作者"<<endl;
		cout<<"欢迎测试游戏"<<endl;
		life = 100;
		gold = 999999999;
		hungry = 100;
		sirsty = 100;
		happy = 100;
		cardA = 99999;
		cardB = 99999;
		cardC = 99999;
		cardfood = 99999;
		cardwater = 99999;
		cardRPG = 0;
	}
	if(table == 1)
	{
		cout<<"请输入存档号(不要瞎输哦,后果很严重):";
		int jym,myj;
		cin>>jym>>life>>gold>>hungry>>sirsty>>happy>>tme>>cardA>>cardB>>cardC>>cardRPG>>cardfood>>cardwater>>myj;
		life/= lck[2];
		gold/= lck[3];
		hungry/= lck[4];
		sirsty/= lck[5];
		happy/= lck[6];
		tme/= lck[7];
		cardA/= lck[8];
		cardB/= lck[9];
		cardC/= lck[10];
		cardRPG/= lck[11];
		cardfood/= lck[12];
		cardwater/= lck[13];

		if(! ( (jym * AAA + BBB == myj) && (jym - (tme - ja) - (jb*gold) == jc)))
		{
			cout<<"你输错了,拜拜";
			return 0;
		}
		cout<<"正";
		usleep(40000);
		cout<<"在";
		usleep(40000);
		cout<<"打";
		usleep(40000);
		cout<<"开";
		usleep(40000);
		cout<<"存";
		usleep(40000);
		cout<<"档";
		usleep(40000);
		cout<<"。";
		usleep(40000);
		cout<<"。";
		usleep(40000);
		cout<<"。";
		usleep(40000);
		cout<<endl;
		sleep(2);
	}
	while(1)
	{
		//
		A = (rand()%11)+10;
		B = (rand()%6)+5;
		C = (rand()%9)+2;
		food = (rand()%16)+15;
		water = (rand()%16)+15;
		cout<<"第"<<tme<<"天"<<endl;
		sleep(3);
		for(int i=1; i<= 5; i++)
		{
			if(gold < 10&&cardA == 0&&cardB == 0&&cardC == 0&&cardfood == 0&&cardwater == 0)
			{
				cout<<"你现在陷入了困境"<<endl;
				cout<<"你既没有钱,有没有卡"<<endl;
				cout<<"于是仁慈的作者决定帮你一把"<<endl;
				gold+=100;
			}
			if(cardRPG == 10)
			{
				cout<<"你集齐了10张RPG卡!"<<endl;
				cout<<"你赢了!"<<endl;
				return 0;
			}
			if(hungry < 10)
			{
				life-=5;
			}
			if(sirsty < 10)
			{
				life-=5;
			}
			if(sirsty < 30)
			{
				life-=10;
			}
			if(life <= 0)
			{
				cout<<"你死了。。。。。。。。。"<<endl;
				return 0;
			}

			if(happy > 100)
			{
				happy = 100;
			}
			if(hungry > 100)
			{
				hungry = 100;
			}
			if(hungry < 0)
			{
				hungry = 0;
			}
			if(sirsty > 100)
			{
				sirsty = 100;
			}
			if(sirsty < 0)
			{
				sirsty = 0;
			}
			system("cls");
			cout<<"生命:"<<life<<endl;
			cout<<"金钱:"<<gold<<endl;
			cout<<"饥饿:"<<hungry<<endl;
			cout<<"干渴:"<<sirsty<<endl;
			cout<<"快乐:"<<happy<<endl;
			cout<<"1、吃饭 2、喝水 3、抽卡(10金币) 4、卡包 5、商店 6、睡觉 7、存档"<<endl;
			if(z != 3)
			{
				cin>>a;
			}
			if(z == 3)
			{
				life = 100;
				gold = 999999999;
				cardA = 99999;
				cardB = 99999;
				cardC = 99999;
				cardfood = 99999;
				cardwater = 99999;
				cardRPG = 0;
				a = 3;
			}
			if(a == 1)
			{
				if(cardfood > 0&&hungry < 100)
				{
					cardfood -= 1;
					hungry += 10;
					cout<<"嗝。。。"<<endl;
					sleep(1);
				}
				else if(hungry == 100||hungry > 90)
				{
					cout<<"你都饱了还吃个啥?"<<endl;
					sleep(1);
				}
				else
				{
					cout<<"你没有食物卡"<<endl;
					sleep(1);
				}
			}
			if(a == 2)
			{
				if(cardwater > 0&&sirsty <= 100)
				{
					cardwater -= 1;
					sirsty += 10;
					cout<<"咕咚,咕咚。。。"<<endl;
					sleep(1);
				}
				else if(sirsty == 100)
				{
					cout<<"你都不渴还喝个啥?"<<endl;
					sleep(1);
				}
				else
				{
					cout<<"你没有水卡"<<endl;
					sleep(1);
				}
			}
			if(a == 3)
			{
				if(gold >= 10)
				{
					gold -= 10;
					b = rand()%100;
					if(b <= 30)
					{
						cout<<"你获得一张A卡"<<endl;
						cardA++;
					}
					if(b <= 55&&b > 30)
					{
						cout<<"你获得一张B卡"<<endl;
						cardB++;
						happy -= 2;
					}
					if(b <= 70&&b > 55)
					{
						cout<<"你获得一张C卡"<<endl;
						cardC++;
						happy -= 5;
					}
					if(b <= 71&&b > 70)
					{
						cout<<"你获得一张RPG卡!!!!!"<<endl;
						cardRPG++;
						happy += 5;
					}
					if(b <= 76&&b > 71)
					{
						cout<<"你啥都没获得"<<endl;
						happy -= 10;
					}
					if(b <= 88&&b > 76)
					{
						cout<<"你获得一张!食物!卡"<<endl;
						cardfood++;
						happy += 2;
					}
					if(b <= 99&&b > 88)
					{
						cout<<"你获得一张!水!卡"<<endl;
						cardwater++;
						happy += 2;
					}
					sleep(2);
				}
				else
				{
					cout<<"你没钱了。。。"<<endl;
					sleep(1);
				}
			}
			if(a == 4)
			{
				cout<<"A卡"<<cardA<<endl;
				cout<<"B卡"<<cardB<<endl;
				cout<<"C卡"<<cardC<<endl;
				cout<<"水卡"<<cardwater<<endl;
				cout<<"食物卡"<<cardfood<<endl;
				cout<<"RPG卡"<<cardRPG<<endl;
				sleep(3);
			}
			if(a == 5)
			{
				system("cls");
				while(1)
				{
					system("cls");
					cout<<"1、买卡 2、卖卡 3、退出"<<endl;
					cin>> c;
					if(c == 3)
					{
						break;
					}
					if(c == 1)
					{
						system("cls");
						cout<<"你有"<<gold<<"金币"<<endl;
						cout<<"1、A卡:"<<A<<"金币"<<endl;
						cout<<"2、B卡:"<<B<<"金币"<<endl;
						cout<<"3、C卡:"<<C<<"金币"<<endl;
						cout<<"4、食物卡:"<<food<<"金币"<<endl;
						cout<<"5、水卡:"<<water<<"金币"<<endl;
						cin >> d;
						cout<<"数量:";
						int many;
						cin >> many;
						switch(d)
						{
							case 1:
								if(gold >= A*many)
								{
									cout<<"购买成功!"<<endl;
									cardA += many;
									gold -= A*many;
								}
								else
								{
									cout<<"你钱不够"<<endl;
								}
								break;
							case 2:
								if(gold >= B*many)
								{
									cout<<"购买成功!"<<endl;
									cardB += many;
									gold -= B*many;
								}
								else
								{
									cout<<"你钱不够"<<endl;
								}
								break;
							case 3:
								if(gold >= C*many)
								{
									cout<<"购买成功!"<<endl;
									cardC += many;
									gold -= C*many;
								}
								else
								{
									cout<<"你钱不够"<<endl;
								}
								break;
							case 4:
								if(gold >= food*many)
								{
									cout<<"购买成功!"<<endl;
									cardfood += many;
									gold -= food*many;
								}
								else
								{
									cout<<"你钱不够"<<endl;
								}
								break;
							case 5:
								if(gold >= water*many)
								{
									cout<<"购买成功!"<<endl;
									cardwater += many;
									gold -= water*many;
								}
								else
								{
									cout<<"你钱不够"<<endl;
								}
								break;
						}
					}
					if(c == 2)
					{
						cout<<"你有:"<<endl;
						cout<<"A卡*"<<cardA<<endl;
						cout<<"B卡*"<<cardB<<endl;
						cout<<"C卡*"<<cardC<<endl;
						cout<<"水卡*"<<cardwater<<endl;
						cout<<"食物卡*"<<cardfood<<endl;
						cout<<endl<<endl<<endl;
						cout<<"1、A卡:"<<A<<"金币"<<endl;
						cout<<"2、B卡:"<<B<<"金币"<<endl;
						cout<<"3、C卡:"<<C<<"金币"<<endl;
						cout<<"4、食物卡:"<<food<<"金币"<<endl;
						cout<<"5、水卡:"<<water<<"金币"<<endl;
						cin>> d;
						int much;
						cout<<"出售数量:";
						cin >> much;
						switch(d)
						{
							case 1:
								if(cardA*much >= 1)
								{
									cout<<"出售成功!"<<endl;
									sleep(1);
									cardA-=much;
									gold+=A*much;
								}
								else
								{
									cout<<"你没那个卡"<<endl;
									sleep(1);
								}
								break;
							case 2:
								if(cardB*much >= 1)
								{
									cout<<"出售成功!"<<endl;
									sleep(1);
									cardB-=much;
									gold+=B*much;
								}
								else
								{
									cout<<"你没那个卡"<<endl;
									sleep(1);
								}
								break;
							case 3:
								if(cardC*much >= 1)
								{
									cout<<"出售成功!"<<endl;
									sleep(1);
									cardC-=much;
									gold+=C*much;
								}
								else
								{
									cout<<"你没那个卡"<<endl;
									sleep(1);
								}
								break;
							case 4:
								if(cardfood*much >= 1)
								{
									cout<<"出售成功!"<<endl;
									sleep(1);
									cardfood-=much;
									gold+=food*much;
								}
								else
								{
									cout<<"你没那个卡"<<endl;
									sleep(1);
								}
								break;
							case 5:
								if(cardwater*much >= 1)
								{
									cout<<"出售成功!"<<endl;
									sleep(1);
									cardwater-=much;
									gold+=water*much;
								}
								else
								{
									cout<<"你没那个卡"<<endl;
									sleep(1);
								}
								break;
						}
					}
				}
			}
			if(a == 6)
			{
				cout<<"呼噜,呼噜......"<<endl;
				sleep(1);
				happy += 5;
				if(happy > 100)
				{
					happy = 100;
				}
				hungry-=10;
				sirsty-= 10;
				system("cls");
				break;
			}
			if(a == 7)
			{
				int yuo = 27;
				yuo += 2*gold;
				yuo += tme - 15;
				int ouy = yuo * AAA + BBB;
				cout<<"友情提示,请将终端拉至最大,否则会出BUG"<<endl;
				sleep(3);
				cout<<"存档号:"
				    <<yuo<<" "
				    <<lck[2] * life<<" "
				    <<lck[3] * gold<<" "
				    <<lck[4] * hungry<<" "
				    <<lck[5] * sirsty<<" "
				    <<lck[6] * happy<<" "
				    <<lck[7] * tme<<" "
				    <<lck[8] * cardA<<" "
				    <<lck[9] * cardB<<" "
				    <<lck[10] * cardC<<" "
				    <<lck[11] * cardRPG<<" "
				    <<lck[12] * cardfood<<" "
				    <<lck[13] * cardwater<<" "
				    <<ouy;
				return 0;
			}
			if(i == 3)
			{
				hungry-=10;
			}
			if(i % 2==0)
			{
				sirsty-=10;
			}
		}
		tme++;


	}
}

以上是关于神奇又简单的抽卡游戏c++的主要内容,如果未能解决你的问题,请参考以下文章

码蹄集 - MT2165 - 小码哥的抽卡之旅1

用C语言做一个简单的原神抽卡小游戏

费马小定理

公主连结网页抽卡

简单又神奇的container_of

简单又神奇的container_of