名字大作战V2.0!

致歉:因为各种原因自测的时候没有找到bug,现在已修改,致歉

版本更新:

1.加入多人对战,形式:个人竞技。

2.采取了函数式技能

3.我是蒟蒻!

//by floatiy

#include
#include
#include
#include
using namespace std;
string name[2000];
int n;
struct I {
    int heal;
    int att;
    int stand;
    int buff;
    int baoji;
    int lengdong;
    int xuean;
    string s;
}id[2000];
//显示部分
void welcome(){
    printf("                             SDFZ版名字竞技场\n");
    printf("几人对战?\n");cin>>n;
    printf("输入名字:\n");
    for(int i = 1;i <= n;i++){
        cin>>name[i];
    }
    printf("请稍后");
}
void print() {
    printf("                             SDFZ版名字竞技场\n");
//          --------------------------------------------------------------------------------
    printf("                                          by floatiy\n");
    for(int i = 1; i <= n; i++) {
        cout <<"    "<"    HP:"<"    攻击:"<"    防御:"<cout<<"    暴击:"<"    冷冻:"<for(int i = 1; i <= n; i++) {
        cout<<"   "<" HP ";
        int tmp=id[i].heal;
        while(tmp > 0) {
            tmp-=30;
            cout<<"-";
        }
        cout<printf("\n\n");
}

//初始化
void init_MP5(string x,int num) {
    if(x== "MP5娘") {
        id[num].baoji += 100;
        id[num].heal += 100;
        id[num].lengdong = 0;
        id[num].att += 50;
        id[num].stand = 10;
    }
}
void init_WWQ(string x,int num) {
    if(x== "王文强") {
        id[num].baoji = 0;
        id[num].heal += 200;
        id[num].lengdong = 30;
        id[num].att += 50;
    }
}
void BOSS() {
    for(int i = 1; i <= n; i++) {
        init_MP5(name[i],i);
        init_WWQ(name[i],i);
    }
}
void join(I &x,string neko) {
    x.s = neko;
    x.att = x.s[1] + (rand() % 20);
    if(x.att < 0) x.att *= -1;
    x.heal = x.s[0] - x.s[2] + rand() % 211;
    x.heal *= 7;
    x.stand = rand() % x.s[1];
    x.att += 70;
    Sleep(200);
    x.baoji = rand() + x.s[2];
    x.baoji %= 10;
    Sleep(500);
    x.lengdong = rand()-x.s[1];
    x.lengdong %= 10;
    x.lengdong += 10;
    x.baoji += 20;
    if(x.heal < 0) x.heal *= -1;
    Sleep(1000);
}
void init() {
    for(int i = 1;i <= n;i++){
        join(id[i],name[i]);
    }
    BOSS();
    system("cls");
}

//技能
void hit(I &x,I &y);
bool tongji_BOSS(I &x,I &y,int opt) {
    if(x.s == "王文强" && opt % 4 == 0) {
        x.baoji += 10;
        x.heal += 50;
        x.lengdong += 5;
        print();
        cout<<"--------------------------------------------------------------------------------"<cout<<"王文强开始了通技课,各项能力提高了!"<500);
        cout<<"然而大家都睡着了。。。对方跳过一回合"<1500);
        system("cls");
        hit(x,y);
        return 1;
    }
    return 0;
}
bool MP5_BOSS(I &x,I &y,int opt) {
    if(x.s == "MP5娘" && opt % 3 == 0) {
        int ham = x.att;
        if(ham <= 5) ham = 5;
        x.stand += 10;
        y.heal -= ham*7;
        print();
        cout<<"--------------------------------------------------------------------------------"<cout<"启动了核心"<cout<"造成了"<7<<"点伤害!"<500);
        cout<"还有"<"点生命!"<500);
        cout<<"MP5娘开启了力场,防御++"<if(y.heal < 0){
            Sleep(300);
            y.buff = 1;
            cout<"被击倒了"<1500);
        system("cls");
        return 1;
    }
    return 0;
}
bool BAOJI(I &x,I &y,int opt) {
    if(0int ham = x.att - rand() % 20;
        if(ham <= 5) ham = 5;
        ham *= 3;
        y.heal -= ham;
        print();
        cout<<"--------------------------------------------------------------------------------"<cout<"打出了致命一击!"<cout<"造成了"<"点伤害!"<500);
        cout<"还有"<"点生命!"<if(y.heal < 0){
            Sleep(300);
            y.buff = 1;
            cout<"被击倒了"<1500);
        system("cls");
        return 1;
    }
    return 0;
}
bool FREEZE(I &x,I &y,int opt) {
    if(50 <= opt && opt <= 50 + x.lengdong) {
        int ham = y.heal * 0.4;
        y.heal -= ham;
        print();
        cout<<"--------------------------------------------------------------------------------"<cout<"打开了对方的月考卷子!敌人凉凉了"<cout<"造成了"<"点伤害!(剩余生命的40%)"<500);
        cout<"还有"<"点生命!暂停一回合"<if(y.heal < 0){
            Sleep(300);
            y.buff = 1;
            cout<"被击倒了"<1500);
        system("cls");
        hit(x,y);
        return 1;
    }
    return 0;
}
bool AOYE(I &x,I &y,int opt) {
    if(opt%7 ==0) {
        int ham = y.att * 0.4;
        y.att -= ham;
        y.heal += 50;
        print();
        cout<<"--------------------------------------------------------------------------------"<cout<"留了大量的作业!"<cout<"熬夜爆肝,攻击力下降了"<"!"<cout<"学到了知识,体力恢复了50点!"<1500);
        system("cls");
        return 1;
    }
    return 0;
}
bool GEDANG(I &x,I &y,int opt) {
    if(y.stand > opt) {
        y.heal += 50;
        print();
        cout<<"--------------------------------------------------------------------------------"<cout<"的攻击被格挡了!"<cout<"去校园服务部吃东西"<cout<"体力恢复了50点!"<1500);
        system("cls");
        return 1;
    }
    return 0;
}

//主体
bool judge() {
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(id[i].heal <= 0) cnt++;
    }
    if(cnt >= n - 1) return 0;
    else return 1;
}
void hit(I &x,I &y) {
    if(x.heal<0 || y.heal<0) return;
    int opt = rand() % 100 + 1;
    if(tongji_BOSS(x,y,opt)) return;
    else if(MP5_BOSS(x,y,opt)) return;
    else if(BAOJI(x,y,opt)) return;
    else if(GEDANG(x,y,opt)) return;
    else if(AOYE(x,y,opt)) return;
    else if(FREEZE(x,y,opt)) return;

    int ham = x.att - rand() % 20;
    if(ham <= 5) ham = 5;
    y.heal -= ham;
    print();
    cout<<"--------------------------------------------------------------------------------"<cout<"造成了"<"点伤害!"<500);
    cout<"还有"<"点生命!"<if(y.heal < 0){
            Sleep(300);
            y.buff = 1;
            cout<"被击倒了"<1500);
    system("cls");
}
void begin() {
    while(1) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if(i == j) continue;
                if(id[j].buff != 1 && id[i].buff != 1) hit(id[i],id[j]);
                if(!judge()) {
                    cout<"胜利了!"<return;
                }
            }
        }
    }
}
//id[2].heal
//主函数
int main() {
    srand(time(NULL));
    welcome();
    init();
    begin();
    return 0;
}

//by SDFZ-Floatiy

你可能感兴趣的:(————杂————,小游戏)