1. 程式人生 > >名字競技場 V3.0

名字競技場 V3.0

cls 3.0 難度 開始 知識 flag spa welcom 打開

更新內容

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

名字競技場 V3.0