更新内容
1.加入新boss,更高的难度。
2.支持组队模式勒!
3.针对大家反应的人物属性算法进行了修改,现在人物属性更多的取决于名字而不是随机数
4.用户界面优化
INF.代码拿走赞留下,不然你赢不了的
//by floatiy #include<iostream> #include<cstdio> #include<cstdlib> #include<ctime> #include<windows.h> using namespace std; string name[2000]; int n; struct I { int heal; int att; int stand; int buff; int baoji; int lengdong; int flag; 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("按顺序输入战队(数字):"); for(int i = 1;i <= n;i++){ cin>>id[i].flag; } printf("请稍后"); } void print() { printf(" SDFZ版名字竞技场\n"); // -------------------------------------------------------------------------------- printf(" by floatiy\n"); for(int i = 1; i <= n; i++) { cout <<" "<<id[i].s<<" HP:"<<id[i].heal<<" 攻击:"<<id[i].att<<" 防御:"<<id[i].stand; cout<<" 暴击:"<<id[i].baoji<<" 冷冻:"<<id[i].lengdong<<endl; } for(int i = 1; i <= n; i++) { cout<<id[i].flag<<"队 "<<id[i].s<<" HP "; int tmp=id[i].heal; while(tmp > 0) { tmp-=30; cout<<"-"; } cout<<endl; } printf("\n\n"); } //初始化 void init_Teacher(string x,int num) { if(x== "静静") { id[num].baoji = 0; id[num].heal += 400; id[num].lengdong = 0; id[num].att += 50; id[num].stand = 30; } } void init_MP5(string x,int num) { if(x== "MP5娘") { id[num].baoji += 100; id[num].heal += 150; id[num].lengdong = 0; id[num].stand = 10; } } void init_WWQ(string x,int num) { if(x== "王文强") { id[num].baoji = 0; id[num].heal += 250; id[num].lengdong = 0; id[num].att = 50; } } void BOSS() { for(int i = 1; i <= n; i++) { init_MP5(name[i],i); init_WWQ(name[i],i); init_Teacher(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 teacher_BOSS(I &x,I &y,int opt){ if(x.s == "静静" && opt % 2 == 0) { y.heal = -100; print(); cout<<"--------------------------------------------------------------------------------"<<endl; cout<<"静静发现"<<y.s<<"在玩游戏,来查房了!"<<endl; Sleep(500); cout<<y.s<<"出局了!"<<endl; Sleep(1500); system("cls"); return 1; } return 0; } bool tongji_BOSS(I &x,I &y,int opt) { if(x.s == "王文强" && opt % 3 == 0) { x.baoji += 10; x.heal += 300; x.lengdong += 5; print(); cout<<" 当前回合:"<<x.s<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; cout<<"王文强开始了通技课,各项能力提高了!"<<endl; Sleep(500); cout<<"然而大家都睡着了。。。对方跳过一回合"<<endl; Sleep(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<<" 当前回合:"<<x.s<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; cout<<x.s<<"启动了核心"<<endl; cout<<x.s<<"造成了"<<ham*7<<"点伤害!"<<endl; Sleep(500); cout<<y.s<<"还有"<<y.heal<<"点生命!"<<endl; Sleep(500); cout<<"MP5娘开启了力场,防御++"<<endl; if(y.heal < 0){ Sleep(300); y.buff = 1; cout<<y.s<<"被击倒了"<<endl; } Sleep(1500); system("cls"); return 1; } return 0; } bool BAOJI(I &x,I &y,int opt) { if(0<opt && opt < x.baoji) { int ham = x.att - rand() % 20; if(ham <= 5) ham = 5; ham *= 3; y.heal -= ham; print(); cout<<" 当前回合:"<<x.s<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; cout<<x.s<<"打出了致命一击!"<<endl; cout<<x.s<<"造成了"<<ham<<"点伤害!"<<endl; Sleep(500); cout<<y.s<<"还有"<<y.heal<<"点生命!"<<endl; if(y.heal < 0){ Sleep(300); y.buff = 1; cout<<y.s<<"被击倒了"<<endl; } Sleep(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<<" 当前回合:"<<x.s<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; cout<<x.s<<"打开了对方的月考卷子!敌人凉凉了"<<endl; cout<<x.s<<"造成了"<<ham<<"点伤害!(剩余生命的40%)"<<endl; Sleep(500); cout<<y.s<<"还有"<<y.heal<<"点生命!暂停一回合"<<endl; if(y.heal < 0){ Sleep(300); y.buff = 1; cout<<y.s<<"被击倒了"<<endl; } Sleep(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<<" 当前回合:"<<x.s<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; cout<<x.s<<"留了大量的作业!"<<endl; cout<<y.s<<"熬夜爆肝,攻击力下降了"<<ham<<"!"<<endl; cout<<y.s<<"学到了知识,体力恢复了50点!"<<endl; Sleep(1500); system("cls"); return 1; } return 0; } bool GEDANG(I &x,I &y,int opt) { if(y.stand > opt) { y.heal += 50; print(); cout<<" 当前回合:"<<x.s<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; cout<<x.s<<"的攻击被格挡了!"<<endl; cout<<y.s<<"去校园服务部吃东西"<<endl; cout<<y.s<<"体力恢复了50点!"<<endl; Sleep(1500); system("cls"); return 1; } return 0; } //主体 void judge() { int cnt = 0; int col = 0; for(int i = 1; i <= n; i++) { if(id[i].heal > 0 && col == 0) col = id[i].flag; if(id[i].heal > 0 && col != id[i].flag) return; } cout<<col<<"队胜利了!"<<endl; cout<<"幸存:"; for(int i = 1;i <= n;i++){ if(id[i].heal > 0) cout<<id[i].s<<" "; } exit(0); } 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(teacher_BOSS(x,y,opt)) return; else if(BAOJI(x,y,opt)) return; else if(FREEZE(x,y,opt)) return; else if(GEDANG(x,y,opt)) return; else if(AOYE(x,y,opt)) return; int ham = x.att - rand() % 20; if(ham <= 5) ham = 5; y.heal -= ham; print(); cout<<" 当前回合:"<<x.s<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; cout<<x.s<<"造成了"<<ham<<"点伤害!"<<endl; Sleep(500); cout<<y.s<<"还有"<<y.heal<<"点生命!"<<endl; if(y.heal < 0){ Sleep(300); y.buff = 1; cout<<y.s<<"被击倒了"<<endl; } Sleep(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[i].flag && id[j].flag && id[i].flag == id[j].flag) continue; if(id[j].buff != 1 && id[i].buff != 1) hit(id[i],id[j]); judge(); } } } } //id[2].heal //主函数 int main() { srand(time(NULL)); welcome(); init(); begin(); return 0; } //by SDFZ-Floatiy