问题标题: 酷町堂:好玩的代码

1
1
已解决
郑泓毅
郑泓毅
资深守护
资深守护
#include<iostream>
#include<windows.h>
#include<cstring>
using namespace std;
bool sm[1005]; 
string name[1005];
int rw[1005][105],n,k;
string x[10005][105];
bool jn[1005][5];
//1.铁壁 2.聚气
int jntime[1005][5];
int jnt[5]={0,15,10};

bool tsjn[1005][105];
//1.魅惑
int tsjnt[1005][105];
int tsjntime[105]={0,2};
void dyx(){
	x[1][1]="发起攻击,";
	x[1][2]="回避了攻击.";
	x[1][3]="受到";
	x[1][4]="点伤害";
	x[1][5]="使用伤害反弹,";
	x[1][6]="连击,";
	x[2][1]="被击倒了.";
	x[3][1]="发动铁壁,";
	x[3][2]="防御力大幅上升.";
	x[3][3]="开始聚气,";
	x[3][4]="攻击力大幅上升.";
	x[4][1]="从铁壁中解除.";
	x[4][2]="聚气消失了.";
	x[5][1]="使用魅惑,";
	x[5][2]="被魅惑了.";
	x[6][1]="从魅惑中解除.";
	return ;
}
int main(){
	cin>>n;
	k=n;
	for(int i=1;i<=n;i++)
		cin>>name[i]>>rw[i][1]>>rw[i][2]>>rw[i][3]>>rw[i][4]>>rw[i][5]>>rw[i][6];
	dyx();
	memset(sm,true,sizeof(sm));
	system("cls");
	for(int i=1;i<=k;i++)
		cout<<name[i]<<" "<<rw[i][1]<<" "<<rw[i][2]<<" "<<rw[i][3]<<" "<<rw[i][4]<<" "<<rw[i][5]<<" "<<rw[i][6]<<endl;
	while(n!=1){
		for(int i=1;i<=k;i++){//查看技能 
			if(!sm[i]) continue;
			for(int j=1;j<=2;j++){
				if(jn[i][j]) jntime[i][j]++;
				if(jntime[i][j]>=jnt[j]){
					jn[i][j]=false;
					jntime[i][j]=0;
					cout<<name[i]<<x[4][j]<<endl;
					Sleep(800);
				}
			}
		}
		int l=rand()%10+1;
		if(l<=7){
			//-------------选人-----------------// 
			int k1,kkk3=rand()%100;
			if(kkk3<=50){
				k1=rand()%k+1;
			}else{
				int kkk5=0;
				int kkk4=rand()%100;
				if(kkk4<=40){
					for(int i=1;i<=k;i++){
						if(kkk5<rw[i][6]){
							kkk5=rw[i][6];
							k1=i;
						}
					}
				}else if(kkk4<=60){
					kkk5=50;
					for(int i=1;i<=k;i++){
						if(kkk5<rw[i][6]){
							kkk5=rw[i][6];
							k1=i;
							break;
						}
					}
				}else if(kkk4<=80){
					k1=rand()%k+1;
				}else{
					k1=rand()%k;
					while(k1==0){
						k1=rand()%k;
					} 
				}
			}
			int k2=rand()%k+1;
			if(n==2){
				int k10=rand()%100;
				int q13=0;
				if(k10>=50){
					for(int i=1;i<=k;i++)
						if(sm[i]){
							if(q13==0){
								k1=i;
								q13++;
							}else{
								k2=i;
								break;
							}
						}
				}else{
					for(int i=1;i<=k;i++)
						if(sm[i]){
							if(q13==0){
								k2=i;
								q13++;
							}else{
								k1=i;
								break;
							}
						}
				}
			}else{
				if(sm[k1]==false) continue;
				if(sm[k2]==false) continue;
				if(k1==k2) continue;
			}
			int sos1=k2;
			if(tsjn[k2][1]) tsjnt[k2][1]++;
			if(tsjn[k1][1]) k2=k1;
			if(tsjn[k1][1]) tsjnt[k1][1]++;
			//-------------开打-----------------// 
			cout<<name[k1]<<x[1][1];
			int zsd=rand()%99+1;
			Sleep(800);
			if(rw[k2][6]>90){//反弹 
				int k22=rand()%100;
				if(k22<=20){
					cout<<name[k2]<<x[1][5];
					Sleep(800);
					int k33=rand()%100;
					if(k33+50<rw[k1][6]){
						cout<<name[k1]<<x[1][2]<<endl;
						Sleep(800);
						continue;
					}else{
						int k44=rand()%99+rw[k1][2];
						if(jn[k1][1]) k44=1;
						cout<<name[k1]<<x[1][3]<<k44<<x[1][4]<<endl;
						if(k44==1) rw[k1][1]-=1;
						else{
							rw[k1][1]-=k44;
							rw[k1][1]+=rw[k2][3]*0.1;
						}
						if(rw[k2][1]<=0){
							Sleep(800);
							cout<<"  "<<name[k2]<<x[2][1]<<endl;
							sm[k1]=false;
							n--;
						}
						Sleep(800);
						continue;
					}
				}
			}
			if(rw[k2][6]>=zsd){//普通 
				int k3=rand()%100;
				if(jn[k1][2]) k3+=100;
				if(k3+50<rw[k2][6]){//回避 
					cout<<name[k2]<<x[1][2]<<endl;
					Sleep(800);
					continue;
				}
				if(jn[k2][1]) k3=1;
				cout<<name[k2]<<x[1][3]<<k3<<x[1][4]<<endl;
				if(k3==1) rw[k2][1]-=1;
				else{
					rw[k2][1]-=k3;
					rw[k2][1]+=rw[k2][3]*0.2;
				}
				if(rw[k2][1]<=0){
					Sleep(800);
					cout<<"  "<<name[k2]<<x[2][1]<<endl;
					sm[k2]=false;
					n--;
				}
			}else{
				int k4=rand()%99+rw[k1][2];
				if(jn[k1][2]) k4+=100;
				if(jn[k2][1]) k4=1;
				cout<<name[k2]<<x[1][3]<<k4<<x[1][4]<<endl;
				if(k4==1) rw[k2][1]-=1;
				else{
					rw[k2][1]-=k4;
					rw[k2][1]+=rw[k2][3]*0.2;
				}
				if(rw[k2][1]<=0){
					Sleep(800);
					cout<<"  "<<name[k2]<<x[2][1]<<endl;
					sm[k2]=false;
					n--;
				}
			}
			int kk9=rand()%300;
			if(kk9<80&&rw[k1][6]>70){//连击 
				int k39=rw[k1][6]/30-1;
				Sleep(800);
				for(int i=1;i<=k39; ){
					int k12=rand()%rw[k1][2]+20;
					if(jn[k1][2]) k12+=100;
					int k22=rand()%k+1;
					if(sm[k1]==false) continue;
					if(sm[k22]==false) continue;
					if(k1==k22) continue;
					if(tsjn[k1][1]) k22=k1;
					cout<<"  "<<name[k1]<<x[1][6];
					Sleep(300);
					if(jn[k22][1]) k12=1;
					cout<<name[k22]<<x[1][3]<<k12<<x[1][4]<<endl;
					rw[k22][1]-=k12;
					if(rw[k22][1]<=0){
						Sleep(300);
						cout<<"  "<<name[k22]<<x[2][1]<<endl;
						sm[k22]=false;
						n--;
					}
					i++;
					Sleep(300);
					for(int i=1;i<=k;i++){//查看技能 
						if(!sm[i]) continue;
						for(int j=1;j<=2;j++){
							if(jn[i][j]) jntime[i][j]++;
							if(jntime[i][j]>=jnt[j]){
								jn[i][j]=false;
								jntime[i][j]=0;
								cout<<"  "<<name[i]<<x[4][j]<<endl;
								Sleep(300);
							}
						}
					}
				}
				Sleep(800);
			}
			if(tsjnt[k1][1]>=tsjntime[1]){
				cout<<"  "<<name[k1]<<x[6][1]<<endl;
				Sleep(800);
				tsjnt[k1][1]=0;
				tsjn[k1][1]=false;
			}
			if(tsjnt[sos1][1]>=tsjntime[1]){
				cout<<"  "<<name[sos1]<<x[6][1]<<endl;
				Sleep(800);
				tsjnt[sos1][1]=0;
				tsjn[sos1][1]=false;
			}
		}else if(l<=9){
			int kkk0=rand()%k+1;
			int kkk9=rand()%k+1;
			if(sm[kkk0]==false) continue;
			if(sm[kkk9]==false) continue;
			int kk22=rand()%100;
			if((max(kkk0,kkk9)-min(kkk0,kkk9)<=k/3||k<=2)&&kk22<=40){
				int kkk8=rand()%2+1;
				if(jn[(kkk0+kkk9+1)/2][kkk8]==true) jntime[(kkk0+kkk9+1)/2][kkk8]=0;
				jn[(kkk0+kkk9+1)/2][kkk8]=true;
				cout<<name[(kkk0+kkk9+1)/2]<<x[3][kkk8*2-1];
				Sleep(800); 
				cout<<name[(kkk0+kkk9+1)/2]<<x[3][kkk8*2]<<endl;
			}else{
				continue;
			}
		}else if(l<=10){//特技 5.6. 
			int kk55=rand()%1+1;
			int kk66=rand()%k+1;//->
			int kk77=rand()%k+1;//  |  |  fang
			if(kk66==kk77) continue;
			if(sm[kk66]==false) continue;
			if(sm[kk77]==false) continue;
			if(kk55==1){
				int kk88=rand()%100;
				if(rw[kk77][6]>kk88){
					cout<<name[kk77]<<x[1][2]<<endl;
					Sleep(800);
				}else{
					cout<<name[kk66]<<x[5][kk55*2-1];
					Sleep(800);
					cout<<name[kk77]<<x[5][kk55*2]<<endl;
					tsjn[kk77][1]=true;
				}
			}
		}
		Sleep(800);
	}
	int k55;
	for(int i=1;i<=100;i++){
		if(sm[i]){
			k55=i;
			break;
		}
	}
	cout<<endl<<"胜者为:";
	Sleep(800);
	cout<<name[k55];
	return 0;
} 

输入形式:总数n

人物名字   血量  攻击力   防御力   魔   幻   智(n个人)

郑泓毅在2021-01-31 09:43:46追加了内容

@张恩泽

快来!!!!!! 


0
0
张恩泽
张恩泽
高级天翼
高级天翼

额,你是在1月31好@我的,为什么我现在才看到

0
汪恺恒
汪恺恒
中级启示者
中级启示者

很好,提个建议,输出的时候快一点,不然如果角色多,好长时间都运行不完

我要回答