废话不多说上游戏
不知道叫什么你们自己取名字吧!
不喜误喷!!!
#include<bits/stdc++.h>
using namespace std;
int main(){
string zhuangbei2;
float num;
double a,b;
int i;
float random[1];
srand(time(NULL));
int jingyan=49;//经验
int jinbi=750;//金币的数量
int shuru;//移动 背包 关于游戏的输入
int shuru2;//旅店 商城 冒险的输入
char shuru2_5;//是否开房的输入
int shuru3;//买什么东西的输入
int shuru4;//冒险去哪里的输入
int shuru5;//攻击 逃跑 的输入
int shuru6;
char shuru7;
int shuru8;
int yuanshiren=100;//原始人的血量
int shuiguai=150;//水怪的血量
int youling=200;//幽灵的血量
int niaoren=350;//鸟人血量
int elong=500;//恶龙的血量
int zhandoul=50;//战斗力
int fangyul=10;//防御力
int xueliang=100;//主角的血量
int taopao=0;//逃跑的次数
int jingyian=0;//经验
int tuichu=0;
int mujian=0;//木剑的数量
int tiejian=0;//铁剑的数量
int shengjian=0;//圣剑的数量
int jingshi=0;//晶石的数量
int shengjia=0;//圣甲的数量
int dunpai=0;//盾牌的数量
int shoulei=0;//手雷的数量
int feibiao=0;//飞镖的数量
int huixuecao=3;//回血草的数量
string mingzi;//主角的名字
int zhandoul2=100;
int fangyul2=10;
int shengji=50;
int dengji=0;
cout<<"========================================================================================================"<<endl;
cout<<" 欢迎来到(想填什么填什么)世界1.0测试版"<<endl;
cout<<"========================================================================================================"<<endl;
cout<<"你叫什名字?"<<endl;
cin>>mingzi;
if(mingzi=="圣战斗士"){
cout<<"伟大的圣战血统啊!你终于觉醒了!请你救出公主吧!"<<endl;
zhandoul+=150;
}else{
cout<<"伟大的"<<mingzi<<"勇士请你救出公主吧!"<<endl;
}
system("pause");
while(true){
if(shengjian>=1){
zhandoul=zhandoul2+50;
}else if(tiejian>=1){
zhandoul=zhandoul2+30;
}else if(mujian>=1){
zhandoul=zhandoul2+10;
}
if(shengjia>=1){
fangyul=fangyul2+40;
}else if(dunpai>=1){
fangyul=fangyul2+20;
}
cout<<"========================================================================================================"<<endl;
cout<<" 你想去干什么? "<<endl;
cout<<"1移动 2背包 3查看状态 4提示 5关于本游戏 6使用道具 7退出"<<endl;
cin>>shuru;
if(shuru==1){
cout<<"========================================================================================================"<<endl;
cout<<"1旅店 2商城 3冒险 4出售"<<endl;
cin>>shuru2;
if(shuru2==1){
cout<<"是否开房y/n(150元)"<<endl;
cin>>shuru2_5;
if(shuru2_5=='y'){
if(jinbi>=50){
cout<<"血量恢复满了"<<endl;
xueliang=100;
}else{
cout<<"金币不足"<<endl;
}
}else{
cout<<"好的"<<endl;
}
}else if(shuru2==2){
cout<<"1木剑150"<<endl;
cout<<"2铁剑500"<<endl;
cout<<"3圣剑1200"<<endl;
cout<<"4盾牌1500"<<endl;
cout<<"5圣甲2000"<<endl;
cin>>shuru3;
if(shuru3==1){
if(jinbi>=150){
cout<<"购买成功"<<endl;
jinbi-=150;
mujian++;
}else{
cout<<"金币不足"<<endl;
}
}else if(shuru3==2){
if(jinbi>=500){
cout<<"购买成功"<<endl;
jinbi-=500;
tiejian++;
}else{
cout<<"金币不足"<<endl;
}
}else if(shuru3==3){
if(jinbi>=1200){
cout<<"购买成功"<<endl;
jinbi-=1200;
shengjian++;
}else{
cout<<"金币不足"<<endl;
}
}else if(shuru3==4){
if(jinbi>=1500){
cout<<"购买成功"<<endl;
jinbi-=1500;
dunpai++;
}else{
cout<<"金币不足"<<endl;
}
}else if(shuru3==5){
if(jinbi>=2000){
cout<<"购买成功"<<endl;
jinbi-=2000;
}else{
cout<<"金币不足"<<endl;
}
}
}else if(shuru2==3){
cout<<"==============================================================================================================="<<endl;
cout<<" 去哪里冒险?"<<endl;
cout<<" 1原始森林 难度:1"<<endl;
cout<<" 2致命湖泊 难度:2"<<endl;
cout<<" 3恐怖鬼屋 难度:3"<<endl;
cout<<" 4天空之城 难度:4"<<endl;
cout<<" 5恶龙巢穴 难度:5"<<endl;
cin>>shuru4;
if(shuru4==1){
cout<<"你遇到了原始人"<<endl;
while(true){
if(taopao==3){
cout<<"逃跑成功"<<endl;
yuanshiren=100;
taopao=0;
break;
}else if(yuanshiren<=0){
cout<<"战斗胜利!!!"<<endl;
cout<<"金币+50!"<<endl;
jinbi+=50;
yuanshiren=100;
jingyan+=10;
taopao=0;
if(jingyan>=shengji){
zhandoul+=3;
zhandoul2+=3;
fangyul+=1;
fangyul2+=1;
shengji+=20;
cout<<mingzi<<"升级!攻击力+3!防御力+1"<<endl;
dengji++;
jingyan=0;
}
break;
}else if(xueliang<=0){
cout<<mingzi<<"勇士,你死了你的财产归我了!!!。(金币归零)"<<endl;
jinbi=0;
yuanshiren=100;
xueliang=100;
taopao=0;
break;
}
cout<<"原始人反击!你扣了"<<20-fangyul<<"滴血!"<<endl;
xueliang-=20-fangyul;
cout<<"1攻击 2逃跑"<<endl;
cin>>shuru5;
if(shuru5==1){
cout<<mingzi<<"攻击!原始人扣了"<<zhandoul<<"滴血"<<endl;
yuanshiren-=zhandoul;
}else if(shuru5==2){
taopao++;
}
}
}else if(shuru4==3){
cout<<"你遇到了幽灵!";
while(true){
if(taopao==3){
cout<<"逃跑成功";
youling=150;
taopao=0;
break;
}else if(youling<=0){
cout<<"战斗胜利!!!"<<endl;
cout<<"金币+75!"<<endl;
jinbi+=75;
youling=150;
jingyan+=20;
if(jingyan>=shengji){
zhandoul+=3;
zhandoul2+=3;
fangyul+=1;
fangyul2+=1;
shengji+=20;
cout<<mingzi<<"升级!攻击力+3!防御力+1"<<endl;
dengji++;
jingyan=0;
}
taopao=0;
break;
}else if(xueliang<=0){
cout<<mingzi<<"勇士,你死了你的财产归我了!!!。(金币归零)"<<endl;
jinbi=0;
youling=150;
xueliang=100;
taopao=0;
break;
}
cout<<"幽灵反击!你扣了"<<50-fangyul<<"滴血!"<<endl;
xueliang-=50-fangyul;
cout<<"1攻击 2逃跑"<<endl;
cin>>shuru5;
if(shuru5==1){
cout<<mingzi<<"攻击!幽灵扣了"<<zhandoul<<"滴血"<<endl;
youling-=zhandoul;
}else if(shuru5==2){
taopao++;
}
}
}else if(shuru4==2){
cout<<"你遇到了水怪"<<endl;
while(true){
if(taopao==3){
cout<<"逃跑成功"<<endl;
shuiguai=150;
taopao=0;
break;
}else if(shuiguai<=0){
cout<<"战斗胜利!!!"<<endl;
cout<<"金币+70!"<<endl;
jinbi+=70;
shuiguai=150;
taopao=0;
for (int i = 0; i < 10; i++)
{
random[i] = rand() % (N + 1) / (float)(N + 1);
}
for (int i = 0; i < 1; i++)
{
b=random[i]; //输出产生的10个随机数
}
if(b==0.1){
cout<<"你从水怪的身上找到了回血草!"<<endl;
huixuecao++;
}
jingyan+=10;
if(jingyan>=shengji){
zhandoul+=3;
zhandoul2+=3;
fangyul+=1;
fangyul2+=1;
shengji+=20;
cout<<mingzi<<"升级!攻击力+3!防御力+1"<<endl;
dengji++;
jingyan=0;
}
break;
}else if(xueliang<=0){
cout<<mingzi<<"勇士,你死了你的财产归我了!!!。(金币归零)"<<endl;
jinbi=0;
shuiguai=150;
xueliang=100;
taopao=0;
break;
}
cout<<"水怪反击!你扣了"<<30-fangyul<<"滴血!"<<endl;
xueliang-=30-fangyul;
cout<<"1攻击 2逃跑"<<endl;
cin>>shuru5;
if(shuru5==1){
cout<<mingzi<<"攻击!水怪扣了"<<zhandoul<<"滴血"<<endl;
shuiguai-=zhandoul;
}else if(shuru5==2){
taopao++;
}
}
}else if(shuru4==4){
cout<<"你遇到了鸟人!";
while(true){
if(taopao==3){
cout<<"逃跑成功";
niaoren=350;
taopao=0;
break;
}else if(niaoren<=0){
cout<<"战斗胜利!!!"<<endl;
cout<<"金币+100!"<<endl;
jinbi+=100;
niaoren=350;
taopao=0;
for (int i = 0; i < 10; i++)
{
random[i] = rand() % (N + 1) / (float)(N + 1);
}
for (int i = 0; i < 1; i++)
{
a=random[i]; //输出产生的10个随机数
}
jingyan+=30;
if(jingyan>=shengji){
zhandoul+=3;
zhandoul2+=3;
fangyul+=1;
fangyul2+=1;
shengji+=20;
cout<<mingzi<<"升级!攻击力+3!防御力+1"<<endl;
dengji++;
jingyan=0;
}
break;
if(a>0.5){
cout<<"你遇到了一个老人他给了你一个飞镖!"<<endl;
feibiao++;
break;
}
else if(a<=0.5&&a>0.3){
cout<<"你遇到了一个老人他给了你一个手雷!"<<endl;
shoulei++;
break;
}
}else if(xueliang<=0){
cout<<mingzi<<"勇士,你死了你的财产归我了!!!(金币归零)"<<endl;
jinbi=0;
niaoren=150;
xueliang=100;
taopao=0;
break;
}
cout<<"鸟人反击!你扣了"<<70-fangyul<<"滴血!";
xueliang-=70-fangyul;
cout<<"1攻击 2逃跑"<<endl;
cin>>shuru5;
if(shuru5==1){
cout<<mingzi<<"攻击!鸟人扣了"<<zhandoul<<"滴血"<<endl;
niaoren-=zhandoul;
}else if(shuru5==2){
taopao++;
}
}
}else if(shuru4==5){
cout<<"你终于来了!哈哈哈!只不过你可能要死了,公主我是不会交给你的!(此关卡不可以逃跑)"<<endl;
system("pause");
while(true){
if(elong<=0){
cout<<"恭喜你救出了公主游戏胜利!"<<endl;
system("pause");
return 0;
}else if(xueliang<=0){
cout<<"你死了,我们会纪念你的勇士!"<<endl;
system("pause");
return 0;
}
cout<<"恶龙攻击!你扣了"<<120-fangyul<<endl;
xueliang-=120-fangyul;
cout<<"1攻击 2道具"<<endl;
cin>>shuru5;
if(shuru5==1){
cout<<"勇者攻击!恶龙扣了"<<zhandoul<<"滴血!";
elong-=zhandoul;
}else if(shuru5==2){
cout<<"1手雷"<<shoulei<<"个"<<endl;
cout<<"2飞镖"<<feibiao<<"个"<<endl;
cin>>shuru6;
if(shuru6==1){
if(shoulei>=1){
shoulei--;
cout<<mingzi<<"丢出了手雷!恶龙扣了100滴血!"<<endl;
elong-=100;
}else{
cout<<"数量不足"<<endl;
}
}else if(shuru6==2){
if(feibiao>=1){
feibiao--;
cout<<mingzi<<"甩出了飞镖!恶龙扣了70滴血"<<endl;
elong-=70;
}else{
cout<<"数量不足"<<endl;
}
}
}
}
}
}else if(shuru2==4){
cout<<"1木剑"<<mujian<<"把"<<endl;
cout<<"2铁剑"<<tiejian<<"把"<<endl;
cout<<"3圣剑"<<shengjian<<"把"<<endl;
cout<<"4圣甲"<<shengjia<<"套"<<endl;
cout<<"5盾牌"<<dunpai<<"个"<<endl;
cout<<"你要卖什么?"<<endl;
cin>>shuru5;
if(shuru5==1){//购买木剑
if(mujian>=1){//购买木剑成功
jinbi+=150;
mujian-=1;
cout<<"购买成功"<<endl;
}else{//购买木剑失败
cout<<"金币不足!"<<endl;
}
}else if(tiejian==2){//购买铁剑
if(jinbi>=1){//购买铁剑成功
jinbi+=300;
tiejian-=1;
cout<<"购买成功";
}else{//购买铁剑 失败
cout<<"金币不足";
}
}else if(shuru5==2){//购买圣剑
if(shengjian>=1){//购买圣剑成功
jinbi+=2000;
shengjian-=1;
cout<<"购买成功";
}else{//购买圣剑失败
cout<<"金币不足";
}
}else if(shuru5==2){//购买圣甲
if(shengjia>=1){//购买圣甲成功
jinbi+=2500;
shengjia-=1;
cout<<"购买成功";
}else{//购买圣甲失败
cout<<"金币不足";
}
}else if(shuru5==2){//购买盾牌
if(dunpai>=1){//购买盾牌成功
jinbi+=1500;
dunpai-=1;
cout<<"购买成功";
}else{//购买盾牌失败
cout<<"金币不足";
}
}
}
}else if(shuru==2){
cout<<"金币"<<jinbi<<"个"<<endl;
cout<<"木剑"<<mujian<<"个"<<endl;
cout<<"铁剑"<<tiejian<<"个"<<endl;
cout<<"圣剑"<<shengjian<<"个"<<endl;
cout<<"盾牌"<<dunpai<<"个"<<endl;
cout<<"圣甲"<<shengjia<<"个"<<endl;
cout<<"回血草"<<huixuecao<<"个"<<endl;
cout<<"手雷"<<shoulei<<"个"<<endl;
cout<<"飞镖"<<feibiao<<"个"<<endl;
system("pause");
}else if(shuru==4){
cout<<"=============================================================================================="<<endl;
cout<<"装备默认装备最强的"<<endl;
system("pause");
}else if(shuru==5){
cout<<"================================================================================================="<<endl;
cout<<"名字输入“圣战斗士”即可开挂!"<<endl;
cout<<"此游戏为作者原创不得抄袭!"<<endl;
system("pause");
}else if(shuru==7){
cout<<"==========================================================================================================="<<endl;
cout<<"真的要退出吗?y/n"<<endl;
cin>>shuru7;
system("pause");
if(shuru7=='y'){
system("pause");
return 0;
}else{
cout<<"好的!"<<endl;
}
return 0;
}else if(shuru==3){
cout<<"攻击力:"<<zhandoul<<endl;
cout<<"防御力:"<<fangyul<<endl;
cout<<"血量:"<<xueliang<<endl;
cout<<"等级:"<<dengji<<"级"<<endl;
system("pause");
}else if(shuru==6){
cout<<"1回血草"<<endl;
cin>>shuru8;
if(shuru8==1){
if(huixuecao>=1){
xueliang+=20;
cout<<"使用成功,血量+20!"<<endl;
huixuecao--;
}else{
cout<<"数量不足"<<endl;
}
}
}
}
return 0;
}