跳到正文

剪贴板

剪贴板 0l9iv4ee

原文
剪贴板信息

剪贴板信息

收录
更新

Alpha 1.2

C++
#include<bits/stdc++.h>
#include<windows.h>
#define clr system("cls")
#define int long long
using namespace std;
string dj[]={"放大镜","华子","小刀","饮料","手铐"},zd[]={"空弹","实弹"};
string pl1,pl2;
bool is1=1,sk,zs;//sk:手铐 zs:打自己
int yu,kb,sd,b1=2,b2=2,ls=1,hit=1,mxb=2,jl;//jl:记录被挂手铐后局数
vector<int>dj1,dj2;
queue<int>g;//枪械装弹
signed main(){
    cout<<"玩家1的名字:";
    cin>>pl1;
    cout<<"玩家2的名字:";
    cin>>pl2;
    clr;
    cout<<"现在讲解规则:\n小刀:可以让下一发子弹伤害变成两倍\n华子:可以回一滴血\n放大镜:你可以查看当前子弹\n饮料:可以退一发子弹\n手铐:可以限制对方一回合动不了\n一共有3轮。\n";
    Sleep(1200);
    system("pause");
    clr;
    start:;
    if(ls==4){
        exit(0);
    }
    //初始化
    b1=2*ls;
    b2=2*ls;
    hit=1;
    zs=0;
    sk=0;
    yu=0;
    kb=0;
    sd=0;
    jl=0;
    mxb=b1;
    dj1.clear();
    dj2.clear();
    while(g.size())g.pop();
    cout<<"第"<<ls<<"局\n";
    Sleep(1200);
//    for(int i=1;i<=12;i++){
//      dj1.push_back(4);
//  }
    clr;
    while(1){
        clr;
        srand(time(0));
        if(!yu){
            sc:;
            cout<<"现在开始上道具!\n"<<pl1<<"(p1)获得了:";
            for(int i=1;i<=4;i++){
                int t=rand()%5;
                dj1.push_back(t);
                cout<<dj[t]<<' ';
                Sleep(500);
            }
            cout<<"\n现在"<<pl1<<"(p1)拥有道具:\n";
            for(auto v:dj1){
                cout<<dj[v]<<' ';
            }
            cout<<'\n';
            Sleep(1200);
            system("pause");
            clr;
            cout<<pl2<<"(p2)获得了:";
            for(int i=1;i<=4;i++){
                int t=rand()%5;
                dj2.push_back(t);
                cout<<dj[t]<<' ';
                Sleep(500);
            }
            cout<<"\n现在"<<pl2<<"(p2)拥有道具:\n";
            for(auto v:dj2){
                cout<<dj[v]<<' ';
            }
            cout<<'\n';
            Sleep(1200);
            system("pause");
            clr;
            kb=rand()%6+1;
            sd=rand()%6+1;
            yu=(kb+sd);
            int tk=kb,ts=sd;
            cout<<"空包弹有:"<<kb<<" 实弹有:"<<sd<<'\n';
            cout<<"装填子弹中......\n";
            srand(time(0));
            for(int i=1;i<=yu;i++){
                bool k=rand()%2;
                if(k){
                    if(tk){
                        g.push(0);
                        --tk;
                    }
                    else{
                        g.push(1);
                        --ts;
                    }
                }
                else{
                    if(ts){
                        g.push(1);
                        --ts;
                    }
                    else{
                        g.push(0);
                        --tk;
                    }
                }
            }
            Sleep(1200);
        }
        cout<<"\n现在"<<pl1<<"(p1)拥有道具:\n";
        for(auto v:dj1){
            cout<<dj[v]<<' ';
        }
        cout<<"\n现在"<<pl2<<"(p2)拥有道具:\n";
        for(auto v:dj2){
            cout<<dj[v]<<' ';
        }
        cout<<"\n生命值(p1,p2):"<<b1<<","<<b2<<"\n";
        cout<<"空包弹有:"<<kb<<"发,实弹有:"<<sd<<"发\n";
        if(is1){
            cout<<"现在是"<<pl1<<"(p1)的回合\n";
            use1:;
            if(dj1.size()){
                cout<<"\n现在"<<pl1<<"(p1)拥有道具:\n";
                int total=0;
                for(auto v:dj1){
                  cout<<(++total)<<"号:"<<dj[v]<<' ';
                }
                cout<<"你要使用道具吗?(Y/N)\n";
                string t;
                ques:;
                cin>>t;
                if(t.size() > 1){
                    cout<<"请重新输入:";
                    goto ques;
                }
                char q=t[0];
                q=toupper(q);
                if(q=='Y'){
                    cout<<"\n请告诉我要使用道具在你拥有的的编号(从1开始;输入0代表不小心输错不使用道具):";
                    int bh;
                    string inp;
                    quesd1:;
                    cin>>inp;
                    if(inp.size()>1){
                        cout<<"不合法!\n请重新输入!";
                        goto quesd1;
                    }
                    if(!isdigit(inp[0])){
                        cout<<"不合法!\n请重新输入!";
                        goto quesd1;
                    }
                    bh=inp[0]-49;
                    if(bh==-1)goto hit1;
                    if(bh>dj1.size()-1 || bh<0){
                        cout<<"不合法!\n请重新输入!";
                        goto quesd1;
                    }
                    else{
                        int tmp=dj1[bh];
                        dj1.erase(dj1.begin()+bh);
                        switch (tmp) {
                            case 0:{
                                cout<<"当前子弹:";
                                cout<<zd[g.front()]<<'\n';
                                Sleep(1500);
                                break;
                            }
                            case 1:{
                                if(b1==mxb){
                                    cout<<"达到上限值,无法回复。";
                                }
                                else{
                                    ++b1;
                                    cout<<"你选择了华子!\n"<<pl1<<"回复1点血量,现在他有"<<b1<<"条生命值!";
                                }
                                Sleep(1500);
                                break;
                            }
                            case 2:{
                                if(hit==2){
                                    cout<<"你在本回合已经使用了小刀,不能再使用了!将会新加小刀至末尾。\n";
                                    dj1.push_back(2);
                                }else{
                                    hit=2;
                                    cout<<"你选择了小刀!这一回合将造成双倍伤害!\n";
                                }
                                Sleep(1500);
                                break;
                            }
                            case 3:{
                                int tmpo=g.front();
                                g.pop();
                                cout<<"你选择了饮料!退出的这发子弹是:"<<zd[tmpo]<<"!\n";
                                if(tmpo)--sd;
                                else --kb;
                                --yu;
                                Sleep(1500);
                                break;
                            }
                            case 4:{
                                if(sk){
                                    cout<<"别人已经被铐起来了.....将把手铐移至末尾!\n";
                                    dj1.push_back(4);
                                }else{
                                    sk=1;
                                    jl=0;
                                    cout<<"你选择了手铐!下一回合敌人将无法移动!\n";
                                }
                                Sleep(1500);
                                break;
                            }
                        }
                        if(!yu){
                            goto sc;
                        }
                        goto use1;
                    }
                }
                else if(q=='N'){
                    cout<<"好的。";
                }
                else{
                    cout<<"请重新输入:";
                    goto ques;
                }
            }
            hit1:;
            cout<<"你要打谁?(0:自己 1:另一名玩家):";
            bool ht;
            cin>>ht;
            int k=g.front();
            if(ht){
                if(k){
                    cout<<"当前是实弹!"<<pl2<<"受到了"<<hit<<"点伤害!\n";
                    jl=0;
                    sk=0;
                    b2-=hit;
                    --sd;
                }
                else{
                    cout<<"很遗憾,当前是空包弹。\n";
                    --kb;
                }
            }
            else{
                zs=1;
                if(k){
                    cout<<"哦豁,当前是实弹!"<<pl1<<"受到了"<<hit<<"点伤害!\n";
                    b1-=hit;
                    --sd;
                }
                else{
                    cout<<"恭喜你,当前是空包弹!\n";
                    --kb;
                }
            }
            g.pop();
            Sleep(1000);
            --yu;
            hit=1;
        }
        else{
            cout<<"现在是"<<pl2<<"(p2)的回合\n";
            use2:;
            if(dj2.size()){
                char q;
                int total=0;
                cout<<"\n现在"<<pl2<<"(p2)拥有道具:\n";
                for(auto v:dj2){
                    cout<<(++total)<<"号:"<<dj[v]<<' ';
                }
                ques2:;
                cout<<"\n你要使用道具吗?(Y/N)\n";
                string t;
                cin>>t;
                if(t.size() > 1){
                    cout<<"请重新输入:";
                    goto ques2;
                }
                q=t[0];
                if(q=='Y'){
                    cout<<"\n请告诉我要使用道具在你拥有的的编号(从1开始;输入0代表不小心输错不使用道具):";
                    string inp;
                    quesd2:;
                    cin>>inp;
                    if(inp.size()>1){
                        cout<<"不合法!\n请重新输入!";
                        goto quesd2;
                    }
                    if(!isdigit(inp[0])){
                        cout<<"不合法!\n请重新输入!";
                        goto quesd2;
                    }
                    int bh=inp[0]-49;
                    if(bh==-1){
                        goto hit2;
                    }
                    if(bh>dj2.size()-1 || bh<0){
                        cout<<"不合法!\n请重新输入!";
                        goto quesd2;
                    }
                    else{
                        int tmp=dj2[bh];
                        dj2.erase(dj2.begin()+bh);
                        switch (tmp) {
                            case 0:{
                                cout<<"当前子弹:";
                                cout<<zd[g.front()]<<'\n';
                                Sleep(1500);
                                break;
                            }
                            case 1:{
                                if(b2==mxb){
                                    cout<<"达到上限值,无法回复。";
                                }else{
                                    ++b2;
                                    cout<<"你选择了华子!\n"<<pl2<<"回复1点血量,现在他有"<<b2<<"条生命值!";
                                }
                                Sleep(1500);
                                break;
                            }
                            case 2:{
                                if(hit==2){
                                    cout<<"你在本回合已经使用了小刀,不能再使用了!将会新加小刀至末尾。\n";
                                    dj2.push_back(2);
                                }
                               else{
                                    hit=2;
                                    cout<<"你选择了小刀!这一回合将造成双倍伤害!\n";
                               }
                                Sleep(1500);
                                break;
                            }
                            case 3:{
                                int tmpo=g.front();
                                g.pop();
                                cout<<"你选择了饮料!退出的这发子弹是:"<<zd[tmpo]<<"!\n";
                                --yu;
                                if(tmpo){
                                    --sd;
                                }
                                else --kb;
                                Sleep(1500);
                                break;
                            }
                            case 4:{
                                if(sk){
                                    cout<<"别人已经被铐起来了......将把手铐移至末尾!\n";
                                    dj2.push_back(4);
                                }
                                else{
                                    sk=1;
                                    jl=0;
                                    cout<<"你选择了手铐!下一回合敌人将无法移动!\n";
                                }

                                Sleep(1500);
                                break;
                            }
                        }
                        if(!yu){
                            goto sc;
                        }
                        goto use2;
                    }
                }
                else if(q=='N'){
                    cout<<"好的。";
                }
                else{
                    cout<<"请重新输入:";
                    goto ques2;
                }
            }
            hit2:;
            cout<<"你要打谁?(0:自己 1:另一名玩家):";
            bool ht;
            cin>>ht;
            int k=g.front();
            if(ht){
                if(k){
                    cout<<"当前是实弹!"<<pl1<<"受到了"<<hit<<"点伤害!\n";
                    jl=0;
                    sk=0;
                    b1-=hit;
                    --sd;
                }
                else{
                    cout<<"很遗憾,当前是空包弹。\n";
                    --kb;
                }
            }
            else{
                zs=1;
                if(k){
                    cout<<"哦豁,当前是实弹!"<<pl2<<"受到了"<<hit<<"点伤害!\n";
                    b2-=hit;
                    --sd;
                }
                else{
                    cout<<"恭喜你,当前是空包弹!\n";
                    --kb;
                }
            }
            g.pop();
            Sleep(1000);
            --yu;
            hit=1;
        }
        if(b1<=0){
            cout<<pl2<<"赢了";
            Sleep(500);
            clr;
            ++ls;
            goto start;
        }
        if(b2<=0){
            cout<<pl1<<"赢了";
            Sleep(500);
            clr;
            ++ls;
            goto start;
        }
        if(sk){
            ++jl;
            if(jl==2)sk=0;
        }
        if(!sk&&!zs){
            is1=1-is1;
        }
        zs=0;
    }
    return 0;
}