#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool die=1;
int health;
float je;
int nandu;
int allday,in1,shealth[5];
void printexit()
{
int j;
for(j=1;j<=2014748364;j++);
for(j=1;j<=2014748364;j++);
for(j=1;j<=2014748364;j++);
cout << "游戏运行结束,";
system("pause");
}
void gp(int dj,int fy,bool zb)
{
if(fy>dj*(2+zb)){
cout<<"你击败了一个生命值为"<< dj<<"的丧尸!\n";
return;
}
else{
if(health<=0){
cout<<"你倒在了丧尸的手中,游戏结束。";
die=0;
}
health += dj-fy*(2+zb);
cout<<"你被丧尸咬了一口,剩余血量"<<health<<"\n";
je -= 0.4;
return;
}
}
int loadin(){
system("color 03");
cout <<"---- 欢迎来到丧尸危机v0.7 ----"<<endl;
cout << "正在加载中";
for(int i=1;i<=10;i++){
cout <<".";
for(int j=1;j<=234748364;j++);
}
cout << " 请输入用户名";
char i94[50];
cin >> i94;
FILE *fout;
fout = fopen("shwj.txt","wb");
fprintf(fout,"%s\n",i94);
cout << "\n请选择模式:1.默认;2.自定义\n";
cin >> in1;
if(in1==1)
{allday=20;}
else{
cout << "请输入你要几天?";
cin >> allday;
}
cout<<"请选择难度:\n1.简单\n2.普通\n3.困难\n";
cin>>nandu;
switch(nandu){
case 1:
shealth[1]=3;
shealth[2]=6;
shealth[3]=10;
shealth[4]=14;
break;
case 2:
shealth[1]=6;
shealth[2]=10;
shealth[3]=14;
shealth[4]=20;
break;
case 3:
shealth[1]=8;
shealth[2]=13;
shealth[3]=19;
shealth[4]=27;
break;
default:
cout<<"输入错误,游戏结束。";
return 1;
}
return 0;
}
int main(int argc, char** argv) {
if(loadin()){
return 0;
}
cout<<"OK,设置成功\n";
system("pause");
system("cls");
int where,seed;
cout << "你要出生在哪?1.教室;2.食堂;3.警察局";
cin >> where;
cout << "正在加载\n";
int do1,money=50,sw=1,w1=1,gongJi=5,ys=0;
health=100;je=20;
cout << "正在加载地图与数据...";
for(int j=1;j<=2014748364;j++);
cout<<"加载成功\n";
system("pause");
seed = (rand()+where)%10;
cout << "你知道吗?饥饿值的上限为20 输入是请按1,否则按0\n";
for(int thisday=1;thisday<=allday;thisday++)
{
cout << "\n现在是第" << thisday << "天\n请问你要干什么,由于这是测试版本,所以只支持1:购物、2:吃东西、3:搜刮物资、4:睡觉、5:赚钱、6:刷怪\n当前你的饥饿值为"<<(int)je<< " 攻击力为"<<gongJi<<" 你有"<<money<< "元 ,你有" << sw<<"个苹果,生命值为"<< health << "\n";
cin >> do1;
if(je>=17){
health += 10;
}
if(ys!=0){
health += 20;
ys--;
}
if(do1==1)
{
cout << "欢迎来到超市,请选择你要去那个区域\n1:武器区\n2:食物区\n3:药水区\n";
int q1;
cin >> q1;
if(q1==1)
{
if(gongJi>=7){
cout << "你已经购买了枪,是否给枪升级?(升级一次可以增加2+20%攻击,需要10元)";
int q2;
cin >> q2;
if(money>=15)
{
if(q2==1)
{
gongJi+=(int)(2+(gongJi)/5.0);
money -= 10;
cout << "购买成功,剩余钱数为" <<money << "\n";
}
}
else cout << "你没有足够的钱";
}
else{
cout << "这里有一把枪,攻击力加成为8,价格为15,是否购买?";
int q2;
cin >> q2;
if(money>=15)
{
if(q2==1)
{
gongJi+=8;
money -= 15;
}
cout << "购买成功,剩余钱数为" << money << "\n";
}
else cout << "你没有足够的钱";
}
}
else if(q1==2)
{
cout <<"现在超市里有一些苹果,价格为5,预计以后会销售附魔金苹果、金苹果等商品,是否购买一个苹果?";
int q2;
cin >> q2;
if(money>=5)
{
if(q2==1)
{
sw++;
money -= 5;
}
cout << "购买成功,剩余钱数为" <<money << "\n";
}
else{
cout << "你没有足够的钱";
}
}
else if(q1==3){
cout <<"这里有一瓶生命恢复药水,购买后可以让生命增加20,可持续两天,价格为15,是否购买?";
int q2;
cin >> q2;
if(money>=15)
{
if(q2==1)
{
health += 20;
money -= 15;
ys+=2;
}
cout << "购买成功,剩余钱数为" <<money << "\n";
}
else{
cout << "你没有足够的钱";
}
}
else
{
cout <<"输入有误或该区未开发哦!";
}
}
else if(do1==2)
{
if(je>=17)
{
cout << "你的饥饿值现在是满的或较高\n";
}
else
{
if(sw>=1)
{
cout<< "你吃了一个苹果";
je+=6;
sw-=1;
}
else cout << "你目前还没有苹果,请去超市购买\n";
}
}
else if(do1==3)
{
if((((seed+thisday)%10)<=5)&&((rand()%10)<=5))
{
if(((rand()%10)<=4)&&(w1==1)){
cout << "恭喜你,有一把枪,是否拿起";
int css;
cin >> css;
if(css==1)
{
gongJi+=10;
w1=0;
}
}
else{
if(rand()%2==1){
cout << "恭喜你,找到一个苹果,是否拿起";
int css;
cin >> css;
if(css==1)
{
sw+=1;
}
}
else{
cout << "你找到了15元";
money+=15;
}
}
}
else{
cout << "没找到武器";
}
}
else if(do1==5){
if(rand()%3==2){
cout << "你赚了大钱:30元";
money+=30;
}
else{
cout << "你赚了小钱:15元";
money+=15;
}
}
else if(do1==6){
bool q2=0;
cout << "提示:刷怪可以提升攻击力,但是会消耗生命值,生命值低于20则无法刷怪\n";
while(q2==0&&health>20){
int rd=rand()%3+1;
gp(shealth[rd+1],gongJi,0);
for(int j=1;j<=214748364;j++);
gongJi+=1;
cout <<"你的生命值为"<<health<<",是否停止刷怪?";
cin >> q2;
}
}
if(thisday%5==0)
{
int rd=rand()%3+1;
if(thisday%20==0){
cout << "大批丧尸出没,你不得不攻击";
for(int p=1;p<=8;p++){
rd=rand()%3+1;
gp(shealth[rd+1],gongJi,0);
for(int j=1;j<=314748364;j++);
}
}
else{
cout << "少量丧尸出没,是否攻击?";
int xz;
cin >> xz;
if(xz==1){
for(int p=1;p<=3;p++){
rd=rand()%3+1;
gp(shealth[rd+1],gongJi,0);
for(int j=1;j<=314748364;j++);
}
if(rand()%2==1){
cout << "你从丧尸中找到了20元";
money+=20;
}
else{
cout << "你找到了5元";
money+=5;
}
}
}
}
je-=1;
if(je<0||health<=0||die==0)
{
cout <<"你死了!";
printexit();
return 0;
}
for(int j=1;j<=1014748364;j++);
}
system("cls");
cout << "恭喜你,获得了游戏的胜利\n" ;
cout<<"祝贺你,最终活下来了!\n";
printexit();
return 0;
}