足球赛(daoban)
yanziwei88 · · 休闲·娱乐
#include <iostream>
#include <random>
#include <ctime>
#include <windows.h>
using namespace std;
void Color(int a){
if(a==-2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);
if(a==-1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
if(a>=6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
}
struct team{
int qianglizhi;
string name;
}team[33];
bool survive[33];
int my_team;
void init(){
for(int i = 1;i<=32;i++){
team[i].qianglizhi = rand()%100;
if(i==1){
team[i].name="China";
}else if(i==2){
team[i].name="Brazil";
}else if(i==3){
team[i].name="Belguim";
}else if(i==4){
team[i].name="Argentina";
}else if(i==5){
team[i].name="France";
}else if(i==6){
team[i].name="Crotia";
}else if(i==7){
team[i].name="Japan";
}else if(i==8){
team[i].name="S.Korea";
}else if(i==9){
team[i].name="Morocco";
}else if(i==10){
team[i].name="Spain";
}else if(i==11){
team[i].name="Italy";
}else if(i==12){
team[i].name="England";
}else if(i==13){
team[i].name="Germany";
}else if(i==14){
team[i].name="Norway";
}else if(i==15){
team[i].name="Nigoria";
}else if(i==16){
team[i].name="USA";
}else if(i==17){
team[i].name="Mexico";
}else if(i==18){
team[i].name="Russia";
}else if(i==19){
team[i].name="Ukrain";
}else if(i==20){
team[i].name="Finland";
}else if(i==21){
team[i].name="Nethelands";
}else if(i==22){
team[i].name="Australia";
}else if(i==23){
team[i].name="India";
}else if(i==24){
team[i].name="Turkey";
}else if(i==25){
team[i].name="Philipin";
}else if(i==26){
team[i].name="Ireland";
}else if(i==27){
team[i].name="Iceland";
}else if(i==28){
team[i].name="Uragrey";
}else if(i==29){
team[i].name="Egypt";
}else if(i==30){
team[i].name="S.Africa";
}else if(i==31){
team[i].name="UEFA-A";
}else if(i==32){
team[i].name="FIFA2";
}
}
}
void clear_screen(){
system("cls");
}
int main()
{
srand(time(NULL));
init();
for(int i = 1;i<=32;i++) survive[i]=true;
cout<<"Please choose a team below:"<<endl;
for(int i = 1;i<=32;i++){
Sleep(200);
cout<<"("<<i<<"):"<<team[i].name<<' '<<team[i].qianglizhi<<endl;
}
cin>>my_team;
survive[my_team]=false;
system("cls");
cout<<"Good. Your team is"<<team[my_team].name<<endl;
Sleep(2000);
system("cls");
int rest = 32;
int rounds=0;
while(rest>1){
cout<<"Get 5 points!"<<endl;
Sleep(200);
rounds++;
cout<<"Round "<<rounds<<endl;
Sleep(2000);
clear_screen();
cout<<"Your oponment is ";
int opm=rand()%32;
opm++;
while(survive[opm]==false){
opm=rand()%32;
opm++;
}
cout<<team[opm].name<<endl;
int your_point=0,opm_point=0;
int ball=0;
while(your_point<5&&opm_point<5){
cout<<"Your possibility to win is "<<100-team[opm].qianglizhi<<endl;
cout<<endl;
Sleep(500);
cout<<"Now points: "<<team[my_team].name<<' '<<your_point<<"-"<<opm_point<<' '<<team[opm].name<<endl;
cout<<endl;
int op=0;
cout<<"(1) Pass"<<endl;
Sleep(250);
cout<<"(2) Shoot"<<endl;
Sleep(250);
cout<<"(3) TakeBall"<<endl;
Sleep(250);
cin>>op;
if(op>3){
system("cls");
continue;
}
if(op==1){
int possi=rand()%100;
if(possi<=team[opm].qianglizhi){
cout<<"Take by oponment"<<endl;
int pos=rand()%100;
if(pos<=team[opm].qianglizhi/2){
cout<<"They Goal!"<<endl;
opm_point++;
}
}else cout<<"It did!"<<endl;
}else if(op==2){
int possi=rand()%100;
if(possi<=64){
cout<<"GOALLLLLLLLL!"<<endl;
your_point++;
}else{
cout<<"No Goal"<<endl;
int pos=rand()%100;
if(pos<=team[opm].qianglizhi){
cout<<"Take by oponment"<<endl;
int po=rand()%100;
if(po<=team[opm].qianglizhi/2){
cout<<"They Goal!"<<endl;
opm_point++;
}
}
}
}
else{
int possi=rand()%100;
if(possi<=team[opm].qianglizhi){
cout<<"Take by oponment"<<endl;
int pos=rand()%100;
if(pos<=team[opm].qianglizhi/2){
cout<<"They Goal!"<<endl;
opm_point++;
}
}else cout<<"It did!"<<endl;
}
Sleep(1000);
clear_screen();
}
if(your_point==5){
cout<<"You win!"<<endl;
survive[opm]=false;
Sleep(500);
system("cls");
}else{
cout<<"You Lose!"<<endl;
return 0;
}
rest--;
}
system("cls");
cout<<"You are the Champion!";
return 0;
}