战斗系统完善

修改了一些代码,改掉了透支体力的BUG,同时因系统问题导致的复制代码时连带行号,我已经把行号取消了,点击复制按钮,往下翻,就可以复制代码了,如果想要exe文件,请e-mail我,<[email protected]>,谢谢.

 

2020-05-21 12:19:51

#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int main() {
    int fangyu=0,shengmin=20,gongji=10,tili=15,sudu=10;
    int choose,user_input,qiangzhigongji;
    int rjfangyu,rjshengmin,rjgongji,rjtili,rjsudu,rjshangxian;
    srand(time(NULL));
    cout<<"你发现了";
    rjfangyu=rand()%(9-7+1)+7;
    rjshengmin=rand()%(50-35+1)+35;
    rjgongji=rand()%(7-5+1)+5;
    rjshangxian=rand()%(13-10+1)+10;
    rjsudu=rand()%(9-5+1)+5;
    rjtili=rjshangxian;
    user_input=getchar();
start:
    cout<<"怪物"<<endl;
    cout<<"1.查看其属性"<<endl;
    cout<<"2.查看自身属性"<<endl;
    cout<<"3.防御"<<endl;
    cout<<"4.攻击"<<endl;
    cout<<"5.技能"<<endl;
    cout<<"6.逃跑"<<endl;
    if(tili>0) {
        cin>>choose;
        system("cls");
        switch(choose) {
            case 1:
                goto a1;
                break;
            case 2:
                goto a2;
                break;
            case 3:
                goto a3;
                break;
            case 4:
                goto a4;
                break;
            case 5:
                goto a5;
                break;
            case 6:
                goto a6;
                break;
            default:
                goto start;

        }

    } else {
        cout<<"你的体力已耗尽,轮到怪物了"<<endl;
        Sleep(1500);
        choose=rand()%(4-1+1)+1;
        switch(choose) {
            case 1:
                cout<<"怪物:哈哈,天道好轮回,苍天饶过谁!" <<endl;
                break;
            case 2:
                cout<<"怪物:哈哈,待我长发及腰,你已成夜宵!" <<endl;
                break;
            case 3:
                cout<<"怪物:哈哈,今朝有酒今朝醉,大铁锅里两行泪!" <<endl;
                break;
            case 4:
                cout<<"怪物:哈哈,有缘千里来相会,我要你的心肝肺!" <<endl;
                break;
            default:
                goto start;

        }
        rjtili=rjshangxian;
        Sleep(1500);
        system("cls");
        goto rjhuihe;

    }
a1:
    cout<<"皮糙肉厚,却略微笨拙的怪物"<<endl;
    cout<<"防御:"<<rjfangyu<<endl;
    cout<<"生命:"<<rjshengmin<<endl;
    cout<<"攻击:"<<rjgongji<<endl;
    cout<<"体力:"<<rjtili<<endl;
    cout<<"速度:"<<rjsudu<<endl;
    Sleep(2000);
    system("cls");
    goto start;

a2:
    cout<<"防御:"<<fangyu<<endl;
    cout<<"生命:"<<shengmin<<endl;
    cout<<"攻击:"<<gongji<<endl;
    cout<<"体力:"<<tili<<endl;
    cout<<"速度:"<<sudu<<endl;
    Sleep(2000);
    system("cls");
    goto start;

a3:
    if(tili>=3) {
        cout<<"你强化了防御"<<endl;
        tili=tili-3;
        fangyu++;
        user_input=getchar();
        Sleep(1500);
        system("cls");
        goto start;
    } else {
        cout<<"体力不支了"<<endl;
        Sleep(1500);
        system("cls");
        goto start;
    }

a4:
    qiangzhigongji=rand()%(2-1+1)+1;
    if(gongji-rjfangyu>0) {
        cout<<"你打出一击"<<endl;
        cout<<"造成了"<<gongji-rjfangyu<<"点伤害"<<endl;
        rjshengmin=rjshengmin+rjfangyu-gongji;

    } else {
        cout<<"你打出一击,却连怪物的鳞片都打不烂,只能踹出一脚,造成" <<qiangzhigongji<<"点伤害" <<endl;
        rjshengmin=rjshengmin-qiangzhigongji;

    }
    tili--;
    Sleep(1500);
    system("cls");
    if(rjshengmin>0) {
        goto start;

    } else goto rjdie;
a5:
    cout<<"技能列表" <<endl;
    cout<<"1.诅咒之术"<<endl;
    cout<<"2.祝福之术"<<endl;
    cout<<"3.返回"<<endl;
    cin>>choose;
    switch(choose) {
        case 1:
            goto jineng1;
            break;
        case 2:
            goto jineng2;
            break;
        case 3:
            system("cls");
            goto start;
            break;
        default:
            goto a5;

    }

a6:
    srand(time(NULL));
    choose=rand()%(10-1+1)+1;
    if(choose!=1) {
        cout<<"逃跑失败,怪物乘机给了你一下,造成2点伤害,又浪费了2点体力"<<endl;
        tili=tili-2;
        shengmin=shengmin-2;

    } else {
        cout<<"你成功逃出了怪物的魔爪"<<endl;
        Sleep(1500);
        return 0;

    }
    Sleep(1500);
    system("cls");
    goto start;

rjhuihe:
    choose=rand()%(2-1+1)+1;
    if(rjtili>0) {
        switch(choose) {
            case 1:
                goto rj1;
                break;
            case 2:
                goto rj2;
                break;
            default:
                goto rjhuihe;

        }

    } else
        cout<<"怪物的体力已耗尽,轮到你了"<<endl;
    tili=15;
    Sleep(1500);
    system("cls");
    goto start;

rj1:
    if(rjtili>=3) {
        cout<<"怪物的鳞片更坚硬了"<<endl;
        rjfangyu++;
        rjtili=rjtili-3;
        Sleep(1500);
        system("cls");
        goto rjhuihe;

    } else goto rjhuihe;

rj2:
    qiangzhigongji=rand()%(2-1+1)+1;
    if(rjgongji-fangyu>0) {
        cout<<"怪物朝你扑来,造成了" <<rjgongji-fangyu<<"点伤害" <<endl;
        shengmin=shengmin+fangyu-rjgongji;

    } else {
        cout<<"怪物朝你扑来,却连你的盔甲都抓不烂,只能一巴掌拍飞你,造成" <<rand()%(2-1+1)+1<<"点伤害" <<endl;
        shengmin=shengmin-qiangzhigongji;

    }
    rjtili--;
    Sleep(1500);
    system("cls");
    if(shengmin>0) {
        goto rjhuihe;

    } else goto die;
rjdie:
    cout<<"怪物倒飞了出去,再也没有站起来......"<<endl;
    Sleep(1500);
    cout<<"你,赢了";
    user_input=getchar();
    return 0;

die:
    cout<<"怪物的爪子扎进了你的心脏,你缓缓倒在了血泊中......"<<endl;
    Sleep(1500);
    cout<<"你,输了";
    user_input=getchar();
    return 0;

jineng1:
    if(tili>=4) {
        if(rjshangxian>2) {
            cout<<"怪物变得虚弱"<<endl;
            rjshangxian--;
            tili=tili-4;
            Sleep(1500);
            system("cls");
            goto start;

        } else {
            cout<<"怪物已经虚弱得不能再虚弱了"<<endl;
            Sleep(1500);
            system("cls");
            goto start;

        }
    } else {
        cout<<"体力不支了"<<endl;
        Sleep(1500);
        system("cls");
        goto start;
    }

jineng2:
    if(tili>=5) {
        cout<<"你感觉一道圣光照在你身上,你的伤口有所愈合,肌肉也更坚韧了"<<endl;
        shengmin=shengmin+3;
        gongji=gongji+2;
        fangyu++;
        tili=tili-5;
        Sleep(1500);
        system("cls");
        goto start;
    } else {
        cout<<"体力不支了"<<endl;
        Sleep(1500);
        system("cls");
        goto start;
    }
    return 0;
}
战斗系统代码

猜你喜欢

转载自www.cnblogs.com/Tianyu1105/p/12929917.html
今日推荐