让我编译一个程序(cpp)

//必须叫征程,必须创建链接
#include<stdlib.h>
#include<stdio.h>
#include<time.h> //suiji
#include<string.h>
#include<windows.h> //SLEEP函数
#include <iostream>
#include <fstream>
using namespace std;
struct Player //玩家结构体,并初始化player
{
char name[21];
int attack;
int defense;
int health;
long int max_health;
int level;
int exp;
int range_exp;
long int max_exp;
}player={"勇者",100,40,100,100,1,0,0,100};
bool key=false,getmission=false,tee=false,baoshi=false,map=false;
int du;
int hold=0,wear=0;
struct Enemy //怪的结构体,并初始化各种怪
{
char name[20];
char wupin[12];
int attack;
int defense;
int health;
int money;
long int exp;
int wupin_sign;
int wupinpro;
int double_attack;
int miss;
}strongman={"污染的野狼","狼牙棒",80,100,700,400,200,13,20,1,0},
witch={"污染的象龟","龟甲",50,30,100,100,100,14,20,1,1},
xiyi={"污染的灰兔","\0",36,20,100,60,70,0,3,20,2},
big_strongman={"狼王","钢牙",80*5,100*5,700*5,400*5,200*5,16,40,2,0},
lion={"海底鲨鱼","\0",120,60,560,400,200,0,20,1,0},
horse={"海底食人鱼","\0",56,24,180,100,100,0,20,1,1},
bee={"海底水母","\0",34,22,120,60,70,0,30,2,2},
shitu={"水怪","宝石",120*8,60*8,560*8,400*8,200*8,17,10,1,0},
mouse={"魔王守卫","\0",200,60,500,400,300,0,20,1,0},
protecter={"魔王","陈旧的剑",1600,600,5600,4000,2200,18,10,1,0},
guai={"\0","\0",0,0,0,0,0,0,0,0,0};
struct Place
{
int bar,hotel,forest1,forest2,forest3,grass1,grass2,grass3,dilao1,dilao2,shop,tjp;
}place={1,2,3,4,5,6,7,8,9,10,11,12};


int max_exp=0;
int choose_number=0,s=0,strongman_arm=0,battle=0,money=500,place_sign=9;
int cao=3,jijiubao=2,baiyao=2,superbaiyao=1,boom=3,dubiao=2,atom_boom=1;
int fang=0,fang1=10,fang1n=0,fang2=20,fang2n=0,fang3=40,fang3n=0,fang4=100,fang4n=0,fang5=120,fang5n=0;
int gong=0,gong1=8,gong1n=0,gong2=15,gong2n=0,gong3=25,gong3n=0,gong4=60,gong4n=0,gong5=100,gong5n=0,gong6=120,gong6n=0;
char gongname[20]="无",fangname[20]="无";
char proof;


void AddWupin(int);
int AttackResult();
void BattleAct();
void ChooseWupin();
void DisplayState();
void OrdinaryAct();
int SuiJi();
int SuiJi100();
void WhetherLevelUp();
void SlowDisplay(char *);
ifstream fin;
ofstream fout;


int main()
{
fin.open("chapter2",ios::in); 
char canplay;
fin>>canplay;
if(canplay==0)
{
SlowDisplay("第一章未通关,无法解锁第二章");
getchar();
getchar();
exit(0); 
}
fin.close();
fin.open("battle.dat",ios::in);
fin>>player.attack>>player.defense>>player.exp>>player.health>>player.level>>player.max_exp>>player.max_health>>player.name>>player.range_exp;
fin>>fang>>gong>>hold>>wear>>gongname>>fangname;
fin>>fang1n;
fin>>fang1;
fin>>fang2n;
fin>>fang2;
fin>>fang3n;
fin>>fang3;
fin>>fang4n;
fin>>fang4;
fin>>gong1n;
fin>>gong1;
fin>>gong2n;
fin>>gong2;
fin>>gong3n;
fin>>gong3;
fin>>gong4n;
fin>>gong4;
fin>>gong5n;
fin>>gong5;
fin>>strongman_arm>>key;
fin>>atom_boom>>baiyao>>boom>>cao>>dubiao>>jijiubao>>superbaiyao;
fin>>money;
fin>>getmission>>tee>>baoshi>>map;
int i=0,j=0,k=0;
char player_name[21];
SlowDisplay("你带上了公主,开启了扫除邪气之旅。"); 
getchar();


OrdinaryAct();
return 0;
}


int SuiJi()
{
srand((unsigned)time(NULL));
return rand()%10;
}




int SuiJi100()
{
srand((unsigned)time(NULL));
return rand()%100;
}




void ChooseWupin() //选择物品 并使用
{
printf("物品: 1,止血草%d个 2,急救包%d个 3,云南白药%d个 4,超级云南白药%d个 5,手雷%d个 6,毒标%d个 7,手抛式原子弹%d个 0,返回\n\n\n",cao,jijiubao,baiyao,superbaiyao,boom,dubiao,atom_boom);
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
if(cao>0)
{
SlowDisplay("使用止血草,HP增加60\n\n\n");
if(player.health+60>player.max_health)player.health=player.max_health;
else player.health+=60;
cao--; 
}
else SlowDisplay("没有止血草了\n\n\n");
break;
case 2:
if(jijiubao>0)
{
SlowDisplay("使用急救包,HP增加80\n\n\n");
if(player.health+80>player.max_health)player.health=player.max_health;
else player.health+=80;
jijiubao--;
}
else SlowDisplay("没有急救包了\n\n\n");
break;
case 3:
if(baiyao>0)
{
SlowDisplay("使用云南白药,HP增加120\n\n\n");
if(player.health+120>player.max_health)player.health=player.max_health;
else player.health+=120;
baiyao--;
}
else SlowDisplay("没有云南白药了\n\n\n");
break;
case 4:
if(superbaiyao>0)
{
SlowDisplay("使用超级云南白药,HP增加200\n\n\n");
if(player.health+200>player.max_health)player.health=player.max_health;
else player.health+=200;
superbaiyao--;
}
else SlowDisplay("没有超级云南白药了\n\n\n");
break;
case 5:
if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
{
if(boom>0)
{
SlowDisplay("使用手雷,敌人HP减少100\n\n\n");
guai.health-=100;
boom--;
AttackResult();
}
}
else SlowDisplay("非战斗状态,不能使用手雷!\n\n\n");
break;
case 6:
if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
{
if(dubiao>0)
{
SlowDisplay("使用毒标,敌人HP减少200 敌人中毒! 每回合HP减少150\n\n\n");
guai.health-=200;
dubiao--;
du+=150; 
AttackResult();
}
}
else SlowDisplay("非战斗状态,不能使用毒标!\n\n\n");
break;
case 7:
if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
{
if(atom_boom>0)
{
SlowDisplay("使用手抛式原子弹,敌人HP减少500 放射性!敌人每回合HP减少200\n\n\n");
guai.health-=500;
atom_boom--;
du+=200;
AttackResult();
}
}
else SlowDisplay("非战斗状态,不能使用手抛式原子弹!\n\n\n");
break;
case 0:break;
default:printf("ChooseWupin error!\n\n\n");
}
}
int AttackResult() //攻击结果:判断是否获胜 是否获得物品 和 是否升级
{
if(guai.health<=0)
{
du=0;
battle=0;
printf("战斗胜利!获得金币%d,经验%d\n\n\n",guai.money,guai.exp);
player.exp+=guai.exp;
player.range_exp+=guai.exp;
money+=guai.money;
s=-10;
if(s<guai.wupinpro)
{
if(strcmp(guai.name,"魔王")==0) {SlowDisplay("缓缓地,魔王变为了人。\"这把金龙剑,只有在斩杀金龙之后才会生效,我为了寻找金龙,最终走火入魔…请你帮我斩杀金龙…\"");
SlowDisplay("第二章 《征程》结束 第三章《寻找金龙》解锁");
fout.open("chapter3",ios::out);
fout<<" "<<1; 
fout.close();
fout.open("battle.dat",ios::out);
fout<<" "<<player.attack<<" "<<player.defense<<" "<<player.exp<<" "<<player.health<<" "<<player.level<<" "<<player.max_exp<<" "<<player.max_health<<" "<<player.name<<" "<<player.range_exp;
fout<<" "<<fang<<" "<<gong<<" "<<hold<<" "<<wear<<" "<<gongname<<" "<<fangname;
fout<<" "<<fang1n;
fout<<" "<<fang1;
fout<<" "<<fang2n;
fout<<" "<<fang2;
fout<<" "<<fang3n;
fout<<" "<<fang3;
fout<<" "<<fang4n;
fout<<" "<<fang4;
fout<<" "<<gong1n;
fout<<" "<<gong1;
fout<<" "<<gong2n;
fout<<" "<<gong2;
fout<<" "<<gong3n;
fout<<" "<<gong3;
fout<<" "<<gong4n;
fout<<" "<<gong4;
fout<<" "<<gong5n;
fout<<" "<<gong5;
fout<<" "<<strongman_arm<<" "<<key;
fout<<" "<<atom_boom<<" "<<baiyao<<" "<<boom<<" "<<cao<<" "<<dubiao<<" "<<jijiubao<<" "<<superbaiyao;
fout<<" "<<money;
fout<<" "<<getmission<<" "<<tee<<" "<<baoshi<<" "<<map; 


getchar();
getchar();


exit(0);
} 
SlowDisplay("从敌人尸骸中发现");
printf("%s\n\n\n",guai.wupin);
AddWupin(guai.wupin_sign);
}
WhetherLevelUp();
if(strcmp(guai.name,"魔王")==0)
{
puts("战斗胜利!!!");
}
return 1; //攻击有结果了返回1,否则返回0,用于判断是否继续做战斗行为
}
else
{
int s=SuiJi();




if((guai.attack+s-(player.defense+fang)/3)<0)
{
player.health-=1;
printf("%s反击,你的HP减少了 1\n\n",guai.name);
}
else
{
player.health-=guai.attack+s-(player.defense+fang)/3;
printf("%s反击,你的HP减少了%d\n\n",guai.name,guai.attack+s-(player.defense+fang)/3);
}
if(player.health>=player.max_health/2) system("color 07");
if(player.health<player.max_health/2) system("color 0e");
if(player.health<player.max_health/3) system("color 06");
if(player.health<player.max_health/4) system("color 0c");
if(player.health<player.max_health/6) system("color 04");
if(player.health<0)
{
du=0;
battle=0;
printf("%s战死!",player.name);
if(money>=player.level*100) printf("使用%d金币贿赂裁判,复活!\n\n\n",player.level*100);
else 
{
printf("你穷到死都死不起了!裁判看你没钱,嫌你可怜,就把你的少的可怜的钱全收了");
money=0; 
} 
money-=player.level*500;
player.health=player.max_health/5;
OrdinaryAct();//
return 1;
}
}
return 0;
}
void AddWupin(int wupin_sign)
{


switch(wupin_sign)
{
case 13:gong6n++;break;
case 14:fang5n++;break;
case 16:tee++;break;
case 17:baoshi++;break;
default:printf("AddWupin error\n\n\n");
}


}
void WhetherLevelUp()
{
int i=0,j=0;
int l1=player.range_exp/100;
int l2=player.range_exp/300;
int l3=player.range_exp/600;
if(player.level<=15&&l1>0) //15级以下,经验足够 都满足则升级
{
if(l1==1)
{
printf("%s",player.name);
SlowDisplay(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3;
player.defense+=2;
player.max_health+=20;
player.health=player.max_health;
player.level++;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=100;
system("color 07");
}
else
{
printf("好厉害!连升%d级!",l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l1,2*l1,20*l1);
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3*l1;
player.defense+=2*l1;
player.max_health+=20*l1;
player.health=player.max_health;
player.level+=l1;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=100*l1;
system("color 07");
}
}
else if(player.level<=40&&l2>0)
{
if(l2==1)
{
printf("%s",player.name);
SlowDisplay(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3;
player.defense+=2;
player.max_health+=20;
player.health=player.max_health;
player.level++;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=300;
system("color 07");
}
else
{
printf("好厉害!连升%d级!",l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l2,2*l2,20*l2);
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3*l2;
player.defense+=2*l2;
player.max_health+=20*l2;
player.health=player.max_health;
player.level+=l2;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=300*l2;
system("color 07");
}
}
else if(l3>0)
{
if(l3==1)
{
printf("%s",player.name);
SlowDisplay(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3;
player.defense+=2;
player.max_health+=20;
player.health=player.max_health;
player.level++;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=600;
system("color 07");
}
else
{
printf("好厉害!连升%d级!",l1);
printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l3,2*l3,20*l3);
player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
player.attack+=3*l3;
player.defense+=2*l3;
player.max_health+=20*l3;
player.health=player.max_health;
player.level+=l3;
player.range_exp=0;
player.exp=player.max_exp;
player.max_exp+=600*l3;
system("color 07");
}
}
}
void OrdinaryAct() //正常行为菜单(移动,物品,对话,查看状态,装备,退出游戏)
{


while(1)
{
// \(1000);
// system("cls");


puts("=============================================================================");
printf("要做什么?\n\n\n 1,移动 2,道具 3,对话 4,查看状态 5,装备 0,退出游戏\n\n\n");
puts("=============================================================================");
switch(scanf("%d",&choose_number),choose_number)
{
case 1: //显示移动菜单
SlowDisplay("要去哪里?\n\n\n");
printf("1,酒吧 2,旅馆 3,森林一层 4,森林二层 5,森林三层 6,海底一层 7,海底二层 8,海底三层 9,迷宫一层 10,迷宫二层 11,商店 12,铁匠铺\n\n\n");
switch(scanf("%d",&choose_number),choose_number)
{
case 12:
SlowDisplay("1,锻造 2,售卖");
int choise;
scanf("%d",&choise);
switch(choise)
{
case 1:
SlowDisplay("选择锻造装备:");
printf("攻装: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个 5,大宝剑\n\n\n",gong1n,gong2n,gong3n,gong4n,gong5n);
printf("防装: 6,布衣:%d个 7,铁甲:%d个 8,银甲:%d个 9,黄金圣衣:%d个\t\t0,返回\n\n\n",fang1n,fang2n,fang3n,fang4n);
printf("选择要锻造的武器或防具以及锻造次数:(30个金币/次) 你有%d个\n\n\n",money);
int cishu;
scanf("%d%d",&choose_number,&cishu);
if(money<30*cishu) {printf("你没钱瞎嘚瑟啥!");break;}
money-=30*cishu;
switch(choose_number)
{
case 1:if(gong1n>=1)
{
SlowDisplay("锻造了匕首\n\n\n");
gong1+=1*cishu;
if(hold==1) gong+=1*cishu;
strcpy(gongname,"匕首");
}
else SlowDisplay("你没有匕首可以锻造\n\n\n");
break;
case 2:if(gong2n>=1)
{
SlowDisplay("锻造了长剑\n\n\n");
gong2+=3*cishu;
if(hold==2) gong+=3*cishu;
strcpy(gongname,"长剑");
}
else SlowDisplay("你没有长剑可以锻造\n\n\n");
break;
case 3:if(gong3n>=1)
{
SlowDisplay("锻造了碧血剑\n\n\n");
gong3+=5*cishu;
if(hold==3) gong+=5*cishu;
strcpy(gongname,"碧血剑");
}
else SlowDisplay("你没有碧血剑可以锻造\n\n\n");
break;
case 4:if(gong4n>=1)
{
SlowDisplay("锻造了绝世好剑\n\n\n");
gong4+=10*cishu;
if(hold==4) gong+=10*cishu;
strcpy(gongname,"绝世好剑");
}
else SlowDisplay("你没有绝世好剑可以锻造\n\n\n");
break;
case 6:if(fang1n>=1)
{
SlowDisplay("锻造了布衣\n\n\n");
fang1+=2*cishu;
if(wear==1) fang+=2*cishu;
strcpy(fangname,"布衣");
}
else SlowDisplay("你没有布衣可以锻造\n\n\n");
break;
case 7:if(fang2>=1)
{
SlowDisplay("锻造了铁甲\n\n\n");
fang2+=4*cishu;
if(wear==2) fang+=4*cishu;


strcpy(fangname,"铁甲");
}
else SlowDisplay("你没有铁甲可以锻造\n\n\n");
break;
case 8:if(fang3n>=1)
{
SlowDisplay("锻造了银甲\n\n\n");
fang3+=8*cishu;
if(wear==3) fang+=8*cishu;


strcpy(fangname,"银甲");
}
else SlowDisplay("你没有银甲可以锻造\n\n\n");
break;
case 9:if(fang4n>=1)
{
SlowDisplay("锻造了黄金圣衣\n\n\n");
fang4+=15*cishu;
if(wear==4) fang+=15*cishu;


strcpy(fangname,"黄金圣衣");
}
else SlowDisplay("你没有黄金圣衣可以锻造\n\n\n");
break;
case 0:{SlowDisplay("未锻造\n\n\n");money+=30*cishu;break;}
case 5:if(gong5n>=1)
{
SlowDisplay("锻造了大宝剑\n\n\n");
gong5+=15*cishu;
if(hold==5) gong+=15*cishu;
strcpy(gongname,"大宝剑");
}
default:{printf("change error!");money+=30;}
}
case 2:
SlowDisplay("1:匕首 10$ 2:长剑 30$ 3:碧血剑 50$ 4:绝世好剑 80$ 5:大宝剑 120$ 6:布衣 5$ 7:铁甲 15$ 8:银甲 35$ 9:黄金圣衣 60$");
scanf("%d",&choose_number);
switch(choose_number)
{
case 1:if(gong1n>=1)
{
SlowDisplay("出售了匕首\n\n\n");
gong1n--;
money+=10;
}
else SlowDisplay("你没有匕首可以出售\n\n\n");
break;
case 2:if(gong2n>=1)
{
SlowDisplay("出售了长剑\n\n\n");
gong2n--;
money+=30;


}
else SlowDisplay("你没有长剑可以出售\n\n\n");
break;
case 3:if(gong3n>=1)
{
SlowDisplay("出售了碧血剑\n\n\n");
gong3n--;
money+=50;


}
else SlowDisplay("你没有碧血剑可以出售\n\n\n");
break;
case 4:if(gong4n>=1)
{
SlowDisplay("出售了绝世好剑\n\n\n");
gong4n--;
money+=80;


}
else SlowDisplay("你没有绝世好剑可以出售\n\n\n");
break;
case 6:if(fang1n>=1)
{
SlowDisplay("出售了布衣\n\n\n");
fang1n--;
money+=5;


}
else SlowDisplay("你没有布衣可以出售\n\n\n");
break;
case 7:if(fang2>=1)
{
SlowDisplay("出售了铁甲\n\n\n");
fang2n--;
money+=15;


}
else SlowDisplay("你没有铁甲可以出售\n\n\n");
break;
case 8:if(fang3n>=1)
{
SlowDisplay("出售了银甲\n\n\n");
fang3n--;
money+=35;


}
else SlowDisplay("你没有银甲可以出售\n\n\n");
break;
case 9:if(fang4n>=1)
{
SlowDisplay("出售了黄金圣衣\n\n\n");
fang4n--;
money+=60;


}
else SlowDisplay("你没有黄金圣衣可以出售\n\n\n");
break;
case 0:{SlowDisplay("未出售\n\n\n");money+=30*cishu;break;}
case 5:if(gong5n>=1)
{
SlowDisplay("出售了大宝剑\n\n\n");
gong5n--;
money+=120;
}


}
} 
break;


case 11:
{
printf("1、止血草:80\n2、急救包:115\n3、云南白药:135\n4、超级云南白药:200\n5、手雷:100\n6、毒镖:190\n7、手抛式原子弹:450\n0、退出 你有%d$",money);
int buy;
scanf("%d",&buy);
switch(buy)
{
case 0:break;
case 1:
if(money>=80)
{
money-=80;
cao++;
SlowDisplay("交易成功!");
}
else {SlowDisplay("由于你买不起,你穷到肌肉萎缩!攻击力清零");
player.attack=0;}
break;
case 2:
if(money>=115)
{
money-=115;
jijiubao++;
SlowDisplay("交易成功!");
}
else {SlowDisplay("由于你买不起,你穷到肌肉萎缩!攻击力清零");
player.attack=0;}
break;
case 3:
if(money>=135)
{
money-=135;
baiyao++;
SlowDisplay("交易成功!");
}
else {SlowDisplay("由于你买不起,你穷到肌肉萎缩!攻击力清零");
player.attack=0;}
break;
case 4:
if(money>=200)
{
money-=200;
superbaiyao++;
SlowDisplay("交易成功!");
}
else {SlowDisplay("由于你买不起,你穷到肌肉萎缩!攻击力清零");
player.attack=0;}
break;
case 5:
if(money>=100)
{
money-=100;
boom++;
SlowDisplay("交易成功!");
}
else {SlowDisplay("由于你买不起,你穷到肌肉萎缩!攻击力清零");
player.attack=0;}
break;
case 6:
if(money>=190)
{
money-=190;
dubiao++;
SlowDisplay("交易成功!");
}
else {SlowDisplay("由于你买不起,你穷到肌肉萎缩!攻击力清零");
player.attack=0;}
break;
case 7:
if(money>=450)
{
money-=450;
atom_boom++;
SlowDisplay("交易成功!");
}
else {SlowDisplay("由于你买不起,你穷到肌肉萎缩!攻击力清零");
player.attack=0;}
break;
}
}
case 1:place_sign=place.bar; //记录目前位置-酒吧
// OrdinaryAct();
break;
case 2:place_sign=place.hotel; //进入旅店
SlowDisplay("要住店吗? 200个金币 1,是 0,否\n\n\n");
choose_number=1;
switch(scanf("%d",&choose_number),choose_number)
{
case 1:if(money-200<0) //判断钱是否够
{
SlowDisplay("Sorry,你的钱不够~\n\n\n");
}
else
{
SlowDisplay("好好休息\n\tHP满\n\t\t第二天了\n\n");
money-=200; //花费200住店费
player.health=player.max_health; //体力满
}
break;
case 0:SlowDisplay("下次再来!\n\n\n");break;
default:printf("hotel talk error!\n\n\n");
}
place_sign=0;
break;
case 3:
place_sign=place.forest1;
s=SuiJi();
if(s<7)
{
battle=1;
guai=xiyi;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=witch;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
SlowDisplay("这里安全\n\n\n");
//不用调用OAct函数,会自动执行OAct函数;
}
break;
case 4:
place_sign=place.forest2;
s=SuiJi();
if(s<7)
{
battle=1;
guai=witch;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=strongman;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
SlowDisplay("这里安全\n\n\n");
}
break;
case 5:
place_sign=place.forest3;
s=SuiJi();
if(s<7)
{
battle=1;
guai=strongman;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=big_strongman;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
SlowDisplay("这里安全\n\n\n");
}
break;
case 6:
place_sign=place.grass1;
s=SuiJi();
if(s<7)
{
battle=1;
guai=bee;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=horse;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
SlowDisplay("这里安全\n\n\n");
}
break;
case 7:
place_sign=place.grass2;
s=SuiJi();
if(s<7)
{
battle=1;
guai=horse;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
battle=1;
guai=lion;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else
{
SlowDisplay("这里安全\n\n\n");
}
break;
case 8:
place_sign=place.grass3;
s=SuiJi();
if(s<7)
{
battle=1;
guai=lion;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
}
else if(s<9)
{
guai=shitu;
printf("%s扑了过来!\n\n\n",guai.name);


battle=1;
BattleAct();
}
else
{
SlowDisplay("这里安全\n\n\n");
}
break;
case 9:
if(!map) {printf("你没有地图,贸然进入这里很危险");break;}
if(SuiJi()<9) {battle=1;
guai=mouse;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();}
else cout<<"这里安全";
break;


case 10:
if(!map) {printf("你没有地图,贸然进入这里很危险");break;}
battle=1;
SlowDisplay("魔王:啊啊啊啊啊!");
guai=protecter;
printf("%s扑了过来!\n\n\n",guai.name);
BattleAct();
break;


default:printf("choose map error!\n\n\n");
}
break;
case 2: ChooseWupin();break; //显示道具,并可以使用.
case 3: //对话选项
if(place_sign==place.bar)
{
SlowDisplay("要和谁说话?\n\n\n1,红发女郎 2,赏金猎人 3,酒吧老板 4,你自己\n\n\n"); //显示对话人物
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
if(!getmission)
{
SlowDisplay("红发女郎:\n\n\n 你说魔王啊,我知道他在哪,但是你要满足两个条件:\n");
SlowDisplay("首先,我要 狼王 的钢牙~ 赏金猎人最喜欢了~ 还有,上次水怪叼走了我的宝石,你也要帮我拿回来~ 都拿回来后我还会给你5000$酬谢~\n");
printf("%s:",player.name);
getmission=true;
SlowDisplay("事真多啊!"); 
}
else if(tee&&baoshi) {SlowDisplay("红发女郎:他在迷宫里,这是地图和你的5000$。\n");map=true;money+=5000;}
else if(tee||baoshi) {SlowDisplay("红发女郎:加油!");}; 
break;
case 2:
SlowDisplay("赏金猎人:\n\n\n 加油吧,年轻人!\n\n\n 不要被外面丛林和草原所吓倒!\n\n\n");
break;
case 3:
printf("要喝点什么?\n\n\n 1,二锅头25金币 HP+20 2,XO酒80金币 HP+50 3,人头马面150金币 HP+100 0,返回\n\n\n");
choose_number=1;
while(choose_number)
{
switch(scanf("%d",&choose_number),choose_number)
{
case 1:if(money<25)
{
SlowDisplay("钱不够!");
}
else
{
if(player.health+20<=player.max_health)
{
SlowDisplay("HP+20.");
money-=25;
player.health+=20;
}
else
{
SlowDisplay("HP满了");
player.health=player.max_health;
}
}
break;
case 2:if(money<80)
{
SlowDisplay("钱不够!");
}
else
{
if(player.health+50<=player.max_health)
{
SlowDisplay("HP+50.");
money-=80;
player.health+=50;
}
else
{
SlowDisplay("HP满了");
player.health=player.max_health;
}
}
break;
case 3:if(money<150)
{
SlowDisplay("钱不够!");
}
else
{
if(player.health+100<=player.max_health)
{
SlowDisplay("HP+100.");
money-=150;
player.health+=100;
}
else
{
SlowDisplay("HP满了");
player.health=player.max_health;
}
}
break;
case 0:SlowDisplay("下次在来!\n");break;
default:SlowDisplay("输入错误\n\n\n");
}
}
break; 
case 4:
char word[200];
cin>>word;
if(word[0]=='$'&&word[1]=='+') {int add;cin>>add;money+=add;}
}
}
else if(place_sign==place.hotel)
SlowDisplay("“老板娘!我...”\n\n\n“我忙着呢,没空理你~”\n\n\n");
else SlowDisplay("这里好像没人可以聊天\n\n\n");
break;
case 4: DisplayState(); break; //显示状态
case 5: //装备
printf("攻装: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个 5,大宝剑:%d个 \n\n\n",gong1n,gong2n,gong3n,gong4n,gong5n);
printf("防装: 6,布衣:%d个 7,铁甲:%d个 8,银甲:%d个 9,黄金圣衣:%d个\t\t0,返回\n\n\n",fang1n,fang2n,fang3n,fang4n);
SlowDisplay("选择要装备的武器或防具:\n\n\n");
switch(scanf("%d",&choose_number),choose_number)
{
case 1:if(gong1n>=1)
{
SlowDisplay("拿起了匕首\n\n\n");
gong=gong1;
hold=1;
strcpy(gongname,"匕首");
}
else SlowDisplay("你没有匕首可以装备\n\n\n");
break;
case 2:if(gong2n>=1)
{
SlowDisplay("拿起了长剑\n\n\n");
gong=gong2;
hold=2;
strcpy(gongname,"长剑");
}
else SlowDisplay("你没有长剑可以装备\n\n\n");
break;
case 3:if(gong3n>=1)
{
SlowDisplay("拿起了碧血剑\n\n\n");
gong=gong3;
hold=3;
strcpy(gongname,"碧血剑");
}
else SlowDisplay("你没有碧血剑可以装备\n\n\n");
break;
case 4:if(gong4n>=1)
{
SlowDisplay("拿起了绝世好剑\n\n\n");
gong=gong4;
hold=4;
strcpy(gongname,"绝世好剑");
}
else SlowDisplay("你没有绝世好剑可以装备\n\n\n");
break;
case 6:if(fang1n>=1)
{
SlowDisplay("穿上了布衣\n\n\n");
fang=fang1;
wear=1;
strcpy(fangname,"布衣");
}
else SlowDisplay("你没有布衣可以装备\n\n\n");
break;
case 7:if(fang2>=1)
{
SlowDisplay("穿上了铁甲\n\n\n");
fang=fang2;
wear=2;
strcpy(fangname,"铁甲");
}
else SlowDisplay("你没有铁甲可以装备\n\n\n");
break;
case 8:if(fang3n>=1)
{
SlowDisplay("穿上了银甲\n\n\n");
fang=fang3;
wear=3;
strcpy(fangname,"银甲");
}
else SlowDisplay("你没有银甲可以装备\n\n\n");
break;
case 9:if(fang4n>=1)
{
SlowDisplay("穿上了黄金圣衣\n\n\n");
fang=fang4;
wear=4;
strcpy(fangname,"黄金圣衣");
}
else SlowDisplay("你没有黄金圣衣可以装备\n\n\n");
break;
case 0:SlowDisplay("未更换装备\n\n\n");break;
case 5:if(gong5n>=1)
{
SlowDisplay("拿起了大宝剑\n\n\n");
gong=gong5;
hold=5;
strcpy(gongname,"大宝剑");
}
default:printf("change error!");
}
break;
case 0:
SlowDisplay("确定推出游戏?(Y/N)\n\n\n");
getchar();
proof=getchar();
if(proof=='y'||proof=='Y')
{
SlowDisplay("数据存储中...");
fout.open("battle.dat",ios::out);
fout<<" "<<player.attack<<" "<<player.defense<<" "<<player.exp<<" "<<player.health<<" "<<player.level<<" "<<player.max_exp<<" "<<player.max_health<<" "<<player.name<<" "<<player.range_exp;
fout<<" "<<fang<<" "<<gong<<" "<<hold<<" "<<wear<<" "<<gongname<<" "<<fangname;
fout<<" "<<fang1n;
fout<<" "<<fang1;
fout<<" "<<fang2n;
fout<<" "<<fang2;
fout<<" "<<fang3n;
fout<<" "<<fang3;
fout<<" "<<fang4n;
fout<<" "<<fang4;
fout<<" "<<gong1n;
fout<<" "<<gong1;
fout<<" "<<gong2n;
fout<<" "<<gong2;
fout<<" "<<gong3n;
fout<<" "<<gong3;
fout<<" "<<gong4n;
fout<<" "<<gong4;
fout<<" "<<gong5n;
fout<<" "<<gong5;
fout<<" "<<strongman_arm<<" "<<key;
fout<<" "<<atom_boom<<" "<<baiyao<<" "<<boom<<" "<<cao<<" "<<dubiao<<" "<<jijiubao<<" "<<superbaiyao;
fout<<" "<<money;
fout<<" "<<getmission<<" "<<tee<<" "<<baoshi<<" "<<map; 
//向文件中更新数据;
getchar();
SlowDisplay("按回车退出");
getchar();
return;
}
else if(proof=='n'||proof=='N')printf("继续游戏!\n\n\n");
else SlowDisplay("继续!\n\n\n");
break;
default:SlowDisplay("输入错误!\n\n\n");
}
}
}
void DisplayState()
{
printf("%s 攻击力:%d+%d=%d 防御力:%d+%d=%d HP:%d/%d \n\n\n",player.name,player.attack,gong,player.attack+gong,player.defense,fang,player.defense+fang,player.health,player.max_health);
printf("武器: %s 防具: %s \n\n\n",gongname,fangname);
printf("等级:%d 经验:%d/%d 还需要%d经验升级 金币:%d \n\n\n",player.level,player.exp,player.max_exp,player.max_exp-player.exp,money);
}
void BattleAct()
{
while(1)
{
puts("=============================================================================");
if(du>0) printf("敌人中毒!HP-%d 剩余%d",du,guai.health);
guai.health-=du;
printf("要怎么办?\n\n\n 1,攻击 2,物品 3,查看状态 4,逃跑\n\n\n");
switch(scanf("%d",&choose_number),choose_number)
{
case 1:
s=SuiJi();
printf("%s攻击! %sHP减少%d %s剩余血量:%d\n\n\n",player.name,guai.name,player.attack+s+gong-guai.defense/3,guai.name,guai.health-player.attack-s-gong+guai.defense/3);
guai.health-=player.attack+s+gong-guai.defense/3;
if(AttackResult())return; //如果攻击有结果(敌人或玩家战死)退出函数
else continue;
case 2: ChooseWupin();break; //选择物品,可以使用,战斗中允许使用攻击性物品
case 3:DisplayState();break; //显示状态
case 4:
s=SuiJi();
if(s<4) //40%的概率可以逃跑
{
printf("%s逃跑了~\n\n\n",player.name);
battle=0;
return;
}
else printf("%s逃跑失败!\n\n\n",player.name);
break;
default:SlowDisplay("输入错误,重新输入!\n\n\n");
}
}
}
void SlowDisplay(char *p)
{
while(1)
{
if(*p!=0)
printf("%c",*p++);
else
break;
Sleep(50);
}

}









NO.2

#include<iostream>  
#include<string>  
#include<ctime>   //用clock()%100 求余,做随机数种子  
using namespace std;  
  
struct shuxing  
{  
    string name;    //名字  
    double str; //力量  
    double dex;     //敏捷  
    double sudu;    //速度  
    double tizhi;   //体质  
};  
  
shuxing player; //声明全局变量角色,类型为结构  
shuxing enemy[10] = { "史莱姆",3,3,3,5 };//声明全局变量 怪物,类型为结构数组  
  
double hp[2];   //声明全局变量数组hp,hp[0]为玩家的,hp[1]为怪物的  
int ski;    //ski决定玩家有什么技能  
double def=1;   //def防御参数,和伤害数值相乘  
string laji;    //用于吃掉没意义的输入  
  
bool combat(int);   //guai为怪物编号  
void playershuxing();   //玩家属性  
void guaiwushuxing(int);    //怪物属性  
int minjie(int);    //敏捷带来的倍击函数  
int skill();    //技能函数,用于释放技能  
void combatend(int,bool);  
  
int main()  
{  
    int guai = 0;  
    bool zhandou;  
    cout << "欢迎来到游戏世界——《LOL世界冒险》" << endl;  
    cout << "请先输入你的名字:";  
    getline(cin, player.name);  
  
    player.str = 5;  
    player.dex = 5;  
    player.sudu = 5;  
    player.tizhi = 5;  
    hp[0] = int(player.tizhi * 5);  //初始化属性  
  
    playershuxing();    //调用函数,查看用户属性  
      
    cout << "糟糕,你遇见了第一只怪物!" << endl;  
    hp[1] = int(enemy[guai].tizhi * 4); //给怪物进行初始化血量  
    guaiwushuxing(guai);    //显示怪物属性  
    zhandou =combat(guai);  //战斗,并输出战斗结果  
    combatend(guai, zhandou);   //输出战斗结算  
  
  
  
    //system("pause");  
    return 0;  
}  
  
void playershuxing()    //查看 玩家的 属性调用本函数  
{  
    cout << "你好,---" << player.name << "---。你的属性为:" << endl;  
    cout << "力量(影响伤害):" << player.str << endl;  
    cout << "敏捷(触发倍击):" << player.dex << endl;  
    cout << "速度(影响攻速):" << player.sudu << endl;  
    cout << "体质(影响免伤):" << player.tizhi << endl;  
    cout << "最大生命值:" << player.tizhi * 5 << "(体质的5倍)" << endl;  
    if (hp[0] > player.tizhi * 5)hp[0] = player.tizhi * 5;  
    cout << "当前生命值:" << hp[0] << endl;  
    //system("pause");  
    cout << endl;  
}  
  
void guaiwushuxing(int guai)//查看 怪物 的属性调用本函数  
{  
    cout << "当前怪物***" << enemy[guai].name << "***的属性为:" << endl;  
    cout << "力量(影响伤害):" << enemy[guai].str << endl;  
    cout << "敏捷(触发倍击):" << enemy[guai].dex << endl;  
    cout << "速度(影响攻速):" << enemy[guai].sudu << endl;  
    cout << "体质(影响免伤):" << enemy[guai].tizhi << endl;  
    cout << "最大生命值:" << enemy[guai].tizhi * 4 << "(体质的4倍)" << endl;  
    if (hp[1] >enemy[guai].tizhi * 4)hp[1] = player.tizhi * 4;  
    cout << "当前生命值:" << hp[1] << endl;  
    //system("pause");  
    cout << endl;  
}  
  
bool combat(int guai)  
{  
    double lun = 1, V[2], v;    //lun回合数,V[2]数组(2成员,分别是玩家和怪物速度),v速度基数  
    char i,act; //i行动参数(1为怪物,0为玩家),act为行动参数  
    double minguai; //怪物攻击带来的参数  
    int dam;    //dam为伤害,每次实时计算  
  
    if (player.sudu < enemy[guai].sudu)   
    {   
        v = player.sudu;  
    }  
    else {  v = enemy[guai].sudu; } //双方速度低的,为速度基数  
    V[0] = V[1] = 0;  
    cout << "进入战斗。" << endl;  
      
  
    for (;hp[0] > 0 && hp[1] > 0;)    //血量都大于0,则执行战斗循环  
    {  
        cout << "*********** 这 *** 是 *** 新 *** 的 *** 回 *** 合 ***********" << endl;  
        cout << "现在是第--->>> " << lun << " <<<---回合。" << endl;  
        V[0] = V[0] + player.sudu;  
        V[1] = V[1] + enemy[guai].sudu; //回合开始,两人速度都增加  
        while (V[0] >= v || V[1] >= v)    //只要有一个人速度比速度基数高,就判断速度,速度高的出手  
        {  
            if (V[0] < V[1]) { i = 1; }  
            else { i = 0; } //根据行动快慢,决定谁先动  
            if (i == 0) //玩家行动轮  
            {  
                cout << "现在轮到你行动了!" << endl;  
                cout << "请决定你的动作:" << endl;  
                cout << "1.攻击\n2.防御\n3.使用技能\n你的动作是: ";  
                act = cin.get();  
                getline(cin,laji);  
                cout << endl;  
                if (act == '1') //攻击  
                {  
                    dam = int(player.str*minjie(guai)*(player.str / enemy[guai].tizhi));  
                    cout << "你对 " << enemy[guai].name << " 造成了 " << dam << " 点伤害。";  
                    hp[1] = hp[1] - dam;  
                    cout << "敌人还有 " << hp[1] << " 点生命值。" << endl << endl;  
                    V[0] = V[0] - v;  
                }  
                else if (act == '2')    //防御  
                {  
                    V[0] = 0;  
                    def = 0.25;  
                    cout << "你进行了防御,你的防御指数提高了!" << endl << endl;  
                }  
                else if (act == '3')    //使用技能  
                {  
                    act=skill();  
                }  
                else { cout << "输入错误,请重新输入动作代码:"; }  
            }  
            if (i == 1) //怪物行动轮  
            {  
                cout << enemy[guai].name << "  进行攻击!" << endl;  
                  
                minguai=minjie(guai);  
                if (0==minguai) { minguai = 3; }  
                else if (1 == minguai) { minguai = 1; }  
                else if (2 == minguai) { minguai = 1 / 2; }  
                else if (3 == minguai) { minguai = 1 / 3; }  
  
                dam = int(def*enemy[guai].str*minguai*(enemy[guai].str / player.tizhi));  
                hp[0] = hp[0] - dam;    //血量减少  
                cout << "你受到了 " << dam << " 点伤害。你当前血量为: " << hp[0] << endl << endl;  
                if(def<=1)def = def + 0.1;  
                V[1] = V[1] - v;  
            }  
            if (hp[0] <= 0 || hp[1] <= 0)break;  
        }  
        lun++;//当两人速度都小于速度基数时,回合数+1  
        def = 1;    //防御系数归1  
    }  
    if (hp[1] <= 0)  
    {  
        return 1;  
    }  
    else  
    {  
        return 0;  
    }  
}  
  
int skill()  
{  
    if (ski == 0) { cout << "你并未学会技能,行动失败。" << endl;    return 4;}  
  
}  
  
int minjie(int guai)    //敏捷参数,用于计算伤害倍数  
{  
    double a, b;  
    if (player.dex >= enemy[guai].dex * 2)return 3;  
    else if (player.dex >= enemy[guai].dex*1.5)return 2;  
    else if (player.dex >= enemy[guai].dex )  
    {  
        a = player.dex / enemy[guai].dex;   //取值范围1.5~1  
        b = clock() % 100 ; //在0~99之间随机一个数  
        a = (a * 100 - 100) * 2;  
        if (b <= a)return 2;  
        else return 1;  
    }  
    else  
    {  
        a= player.dex / enemy[guai].dex;    //取值范围1~0  
        a = a * 100;  
        b = clock() % 100;  //在1~100之间随机一个数  
        if (b <= a)return 1;  
        else return 0;  
    }  
}  
  
void combatend(int guai,bool a)  
{  
    double heal;  
    if (a == true)  
    {  
        cout << "战斗结束........." ;  
        //system("pause");  
        //system("cls");  
        cout << "***" << enemy[guai].name << "***死亡!你胜利啦!" << endl;  
        if (hp[0] <= 0)hp[0] = 1;  
        cout << "你当前生命值为:" << hp[0] << "点。" << endl;  
        heal = int(player.tizhi * 2 + enemy[guai].tizhi * 1);  
        hp[0] = hp[0] + heal;  
        if (hp[0] >= player.tizhi * 5)hp[0] = player.tizhi * 5;  
        cout << "由于战斗胜利,你获得了 " << heal << " 点治疗,你当前生命值为   " << hp[0] << " 点。" << endl;  
        player.str = player.str + 1;  
        player.dex = player.dex + 1;  
        player.sudu = player.sudu + 1;  
        player.tizhi = player.tizhi + 1;  
        playershuxing();  
    }  
    else if (a == false)  
    {  
        cout << "战斗结束.........";  
        //system("pause");  
        //system("cls");  
        cout << "---" << player.name << "---可耻的失败了!" << endl;  
        cout << "你被一个大汉爆了菊花!" << endl;  
        cout << "你被两个基佬爆了菊花!" << endl;  
        cout << "你被三个人妖爆了菊花!" << endl;  
        cout << "你被送到泰国,然后做了切除jj手术!" << endl;  
        cout << "你被送进外国某个地下红灯区!" << endl;  
        cout << "————十八禁内容————" << endl;  
        cout << "真是惨不忍睹啊!" << endl;  
        cout << "创世神看不下去了,将你复活了" << endl;  
        player.tizhi = player.tizhi + 4;  
        heal = int(player.tizhi * 2 + enemy[guai].tizhi * 1);  
        hp[0] = 1;  
        hp[0] = hp[0] + heal;  
        if (hp[0] >= player.tizhi * 5)hp[0] = player.tizhi * 5;  
        cout << "创世神对你进行了治疗,你回复了 " << heal << " 点血量。" << endl;  
        cout << "你的当前血量为 " << hp[0] << " 点。" << endl;  
        cout << "由于沐浴了创世神的光辉,你的体质提高了 4 点。这说明你更抗揍了。" << endl;  
        playershuxing();  
    }  
}  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值