问题标题: 名字竞技场 <- 不是那一个

0
1
已解决
张帆
张帆
中级天翼
中级天翼

Name-computation1.0:

实现名字竞技场基本功能,

但是鬼魅和感染没有效用,这将会在2.0中改善,

2.0正在造,

想要提前得到或者加入开发的加入洛谷team

不说了直接上代码:

#include<iostream>
#include<windows.h>
#include<bits/stdc++.h>

using namespace std;

struct j{
	string fire;//技能名字
	string fine;//对敌人造成的伤害 
}; 

struct chacracter{
	string name;
	int HP,G,Z;
	j ay;
	int idx,num;
	string turn_num="";
	string wy_num="";
	int go_upper=0;
}; /*
	HP:血量
	G:攻击力
	Z:智力 
	ay:特技 
	idx:所在队伍 
	num:人物编号 
	*/

int n=1;

chacracter c[110]; 
j how[20];//技能 

void give_num_to_how_a_fine_work(){
	how[1].fire="火球术",how[1].fine="100";
	how[2].fire="心灵控制",how[2].fine="10+turn";
	how[3].fire="地裂术",how[3].fine="25+every";
	//how[4].fire="铁壁",how[4].fine="0+fend";//fend防守
	how[4].fire="瘟疫",how[4].fine="10+wy";//wy感染
	how[5].fire="懒癌",how[5].fine="20+wy";//wy感染 
	//how[7].fire="回避攻击",how[8].fine="0+fend"; 
	how[6].fire="终极一击",how[6].fine="200+every+wy+turn";
	return ; 
}

void out(string said){
	for(int i=0;i<said.length();i++){
		cout<<said[i];
		Sleep(5);
	}
	return ;
}//输入一个字符串,每5毫秒输出一个字符 

void ano(){
	cout<<"\n";
	return ;
}//换行简写 

void begin(){
	out("欢迎来到NC 1.0");
	//ano();
	//ano();
	Sleep(1000);
	system("cls");
	out("下面请输入名字,按enter+enter分队,禁止外挂,若系统发现外挂,自动退游,最多支持100个名字对战,超出可能会报错。");
	ano();
	out("按enter+(ctrl+z)+enter(注:分开按)结束输入,开始对战");
	Sleep(2000);
	//cout<"\n";
	system("cls");
	return ; 
}//开始对白

void give_num_to_people(int id){
	int x=rand()%5+1;
	c[id].ay.fire=how[x].fire;
	c[id].ay.fine=how[x].fine;
	if(c[id].name.find("dragon",0)!=-1){
		c[id].ay.fire=how[6].fire;
		c[id].ay.fine=how[6].fine;
	} 
	c[id].HP=rand()%201+200;
	c[id].G=rand()%41+10;
	c[id].Z=rand()%100+1; 
	return ;
}//对于每一个人物,生成属性。 

void in(){
	int ans=1;
	while(getline(cin,c[n].name)){
		if(c[n].name.empty()){
			ans++;
		} else {
			c[n].idx=ans;
			c[n].num=n; 
			give_num_to_people(n); 
			n++;
		}
		//give_num_to_people(n); 
		//cout<<n<<" "<<c[n].HP<<" "<<c[n].G<<" "<<c[n].Z<<" "<<c[n].idx<<"\n";
	}
	n--;
	if(n<2){
		out("wrong");
		exit(0);
	} 
	if(ans==1){//单斗模式 
		//int poster=1;
		for(int i=1;i<=n;i++){
			c[i].idx=i;
		} 
	}
	return ;
}//输入 

void fight_begin_out(){
	system("cls");
	for(int i=1;i<=n;i++){
		cout<<(char)(c[i].idx+'A'-1)<<":";
		cout<<c[i].name<<"  ";
		cout<<"HP:"<<c[i].HP<<" ";
		cout<<"攻:"<<c[i].G<<" ";
		cout<<"智:"<<c[i].Z<<" ";
		//cout<<"队伍:"<<c[i].idx<<" "; 
		ano();
		//if(c[i].idx!=c[i-1].idx) ano(); 
	}
	cout<<"_____________________________________________________\n";
	return ;
}//开始输出属性 

bool check(){
	int pos=0,cnt=0;
	for(int i=1;i<=n;i++){
		if(c[i].HP>0){
			if(c[i].idx!=pos){
				pos=c[i].idx;
				cnt++;
			}
		}
	}
	return cnt>1;
}

int turn(string s){
	int sum=0;
	for(int i=0;i<s.length();i++){
		if(!(s[i]>='0'&&s[i]<='9')) break;
		sum=sum*10+(int)(s[i]-'0');
	}
	return sum;
}

void fight(){
	int now_turn=0;
	while(check()){
		//cout<<"yes\n";
		now_turn=now_turn%n+1;
		if(c[now_turn].HP==0) continue;
		int pos=rand()%3+1;//出招与否
		//if(c[now_turn].ay.fire=="铁壁"||c[now_turn].ay.fire=="回避攻击"){
		//	pos=2;
		//} 
		int names_you_go=rand()%n+1;
		while(c[names_you_go].idx==c[now_turn].idx||c[names_you_go].HP<=0) names_you_go=rand()%n+1;
		int yes=rand()%10+1; 
		switch(pos){
			case 3:{//出技能 
				cout<<c[now_turn].name<<" 使用了 "<<c[now_turn].ay.fire<<",\n";
				int flag=c[now_turn].ay.fine.find("every",0);
				if(flag==-1){
					if(yes==1){
						cout<<c[names_you_go].name<<" 回避了攻击 。\n"; 
					} else {
						int fight_num=turn(c[now_turn].ay.fine);
						//if(!c[now_turn].ay.fire) 
						cout<<c[names_you_go].name<<" 受到了 "<<fight_num<<"点伤害";
						c[names_you_go].HP-=fight_num;
						if(c[names_you_go].HP<0) c[names_you_go].HP=0;
						if(c[names_you_go].HP==0){
							cout<<"	  "<<c[names_you_go].name<<"被击倒了"; 
							c[now_turn].go_upper++;
						}
						if(c[now_turn].ay.fine.find("turn",0)!=-1){
							cout<<","<<c[names_you_go].name<<" 被鬼魅了 ";
							c[names_you_go].turn_num="yes";
						}
						if(c[now_turn].ay.fine.find("wy",0)!=-1){
							cout<<","<<c[names_you_go].name<<" 被感染了 ";
							c[names_you_go].wy_num="yes";
						}
					}
					ano();
				} else {
					int fight_num=turn(c[now_turn].ay.fine);
					for(int i=1;i<=n;i++){
						if(c[i].HP<=0) continue;
						if(c[i].idx==c[names_you_go].idx){
							cout<<"   "<<c[i].name<<" 受到了 "<<fight_num<<"点伤害";
							c[i].HP-=fight_num;
							if(c[i].HP<=0){
								c[i].HP=0;
								cout<<","<<c[i].name<<"被击倒了;\n";
								c[now_turn].go_upper++;
								continue; 
							} 
							if(c[now_turn].ay.fine.find("turn",0)!=-1){
								cout<<","<<c[i].name<<" 被鬼魅了 ";
								c[i].turn_num="yes";
							}
							if(c[now_turn].ay.fine.find("wy",0)!=-1){
								cout<<","<<c[i].name<<" 被感染了 ";
								c[i].wy_num="yes";
							}
							cout<<"\n";
						}
					}
				}
				break;
			}
			default:{//出普通攻击 
				cout<<c[now_turn].name<<"发起攻击,"; 
				if(yes==1){
					cout<<c[names_you_go].name<<" 回避了攻击 。"; 
				} else {
					int fight_num=c[now_turn].G;
					//if(!c[now_turn].ay.fire) 
					cout<<c[names_you_go].name<<" 受到了 "<<fight_num<<"点伤害";
					c[names_you_go].HP-=fight_num;
					if(c[names_you_go].HP<0) c[names_you_go].HP=0;
					if(c[names_you_go].HP==0){
						cout<<"	  "<<c[names_you_go].name<<"被击倒了";
						c[now_turn].go_upper++; 
					}
					//if(c[now_turn].ay.fine.find("turn",0)!=-1){
					//	cout<<","<<c[names_you_go].name<<" 被鬼魅了 ";
					//	c[names_you_go].turn_num="yes";
					//}
					//if(c[now_turn].ay.fine.find("wy",0)!=-1){
					//	cout<<","<<c[names_you_go].name<<" 被感染了 ";
					//	c[names_you_go].wy_num="yes";
					//}
					ano();
				}
				break;
			} 
		} 
		Sleep(500);
		cout<<endl;
	}
	return ;
}

void last_out(){
	//cout<<turn("100");
	ano();
	ano();
	cout<<"胜者:";
	int pos=-1;
	ano();
	for(int i=1;i<=n;i++){
		if(c[i].HP>0){
			pos=c[i].idx;
			break;
		}	
	} 
	for(int i=1;i<=n;i++){
		if(c[i].idx==pos){
			cout<<(char)(c[i].idx+'A'-1)<<":";
			cout<<c[i].name<<" "<<c[i].go_upper<<"\n";
		}
	}
	ano();
	ano();
	cout<<"败者:";
	ano();
	 for(int i=1;i<=n;i++){
		if(c[i].idx!=pos){
			cout<<(char)(c[i].idx+'A'-1)<<":";
			cout<<c[i].name<<" "<<c[i].go_upper<<"\n";
		}
	}
	return ;
}

int main(){
	give_num_to_how_a_fine_work(); 
	begin();
	in();
	fight_begin_out();
	fight();
	last_out();
	return 0;
}

征求意见,这是本人第一次写游戏,大佬们不要见怪。

张帆在2021-02-09 09:30:09追加了内容

依据 @汪恺恒 我改了一下代码:

#include<iostream>
#include<windows.h>
#include<bits/stdc++.h>

using namespace std;

struct j{
	string fire;//技能名字
	string fine;//对敌人造成的伤害 
}; 

struct chacracter{
	string name;
	int HP,G,Z;
	j ay;
	int idx,num;
	string turn_num="";
	string wy_num="";
	int go_upper=0;
}; /*
	HP:血量
	G:攻击力
	Z:智力 
	ay:特技 
	idx:所在队伍 
	num:人物编号 
	*/

int n=1;

chacracter c[110]; 
j how[20];//技能 

void give_num_to_how_a_fine_work(){
	how[1].fire="火球术",how[1].fine="100";
	how[2].fire="心灵控制",how[2].fine="10+turn";
	how[3].fire="地裂术",how[3].fine="25+every";
	//how[4].fire="铁壁",how[4].fine="0+fend";//fend防守
	how[4].fire="瘟疫",how[4].fine="10+wy";//wy感染
	how[5].fire="懒癌",how[5].fine="20+wy";//wy感染 
	//how[7].fire="回避攻击",how[8].fine="0+fend"; 
	how[6].fire="终极一击",how[6].fine="200+every+wy+turn";
	return ; 
}

void out(string said){
	for(int i=0;i<said.length();i++){
		cout<<said[i];
		Sleep(5);
	}
	return ;
}//输入一个字符串,每5毫秒输出一个字符 

void ano(){
	cout<<"\n";
	return ;
}//换行简写 

void begin(){
	out("欢迎来到NC 1.1");
	//ano();
	//ano();
	Sleep(1000);
	system("cls");
	out("下面请输入名字,按enter+enter分队,禁止外挂,若系统发现外挂,自动退游,最多支持100个名字对战,超出可能会报错。");
	ano();
	out("按enter+(ctrl+z)+enter(注:分开按)结束输入,开始对战");
	Sleep(5000);
	//cout<"\n";
	system("cls");
	return ; 
}//开始对白

void give_num_to_people(int id){
	int x=rand()%5+1;
	c[id].ay.fire=how[x].fire;
	c[id].ay.fine=how[x].fine;
	if(c[id].name.find("dragon",0)!=-1){
		c[id].ay.fire=how[6].fire;
		c[id].ay.fine=how[6].fine;
	} 
	c[id].HP=rand()%201+200;
	c[id].G=rand()%41+10;
	c[id].Z=rand()%100+1; 
	return ;
}//对于每一个人物,生成属性。 

void in(){
	int ans=1;
	while(getline(cin,c[n].name)){
		if(c[n].name.empty()){
			ans++;
		} else {
			c[n].idx=ans;
			c[n].num=n; 
			give_num_to_people(n); 
			n++;
		}
		//give_num_to_people(n); 
		//cout<<n<<" "<<c[n].HP<<" "<<c[n].G<<" "<<c[n].Z<<" "<<c[n].idx<<"\n";
	}
	n--;
	if(n<2){
		out("wrong");
		exit(0);
	} 
	if(ans==1){//单斗模式 
		//int poster=1;
		for(int i=1;i<=n;i++){
			c[i].idx=i;
		} 
	}
	return ;
}//输入 

void fight_begin_out(){
	system("cls");
	for(int i=1;i<=n;i++){
		cout<<(char)(c[i].idx+'A'-1)<<":";
		cout<<c[i].name<<"  ";
		cout<<"HP:"<<c[i].HP<<" ";
		cout<<"攻:"<<c[i].G<<" ";
		cout<<"智:"<<c[i].Z<<" ";
		//cout<<"队伍:"<<c[i].idx<<" "; 
		ano();
		//if(c[i].idx!=c[i-1].idx) ano(); 
	}
	cout<<"_____________________________________________________\n";
	return ;
}//开始输出属性 

bool check(){
	int pos=0,cnt=0;
	for(int i=1;i<=n;i++){
		if(c[i].HP>0){
			if(c[i].idx!=pos){
				pos=c[i].idx;
				cnt++;
			}
		}
	}
	return cnt>1;
}

int turn(string s){
	int sum=0;
	for(int i=0;i<s.length();i++){
		if(!(s[i]>='0'&&s[i]<='9')) break;
		sum=sum*10+(int)(s[i]-'0');
	}
	return sum;
}

void fight(){
	int now_turn=0;
	while(check()){
		//cout<<"yes\n";
		now_turn=now_turn%n+1;
		if(c[now_turn].HP==0) continue;
		int pos=rand()%3+1;//出招与否
		//if(c[now_turn].ay.fire=="铁壁"||c[now_turn].ay.fire=="回避攻击"){
		//	pos=2;
		//} 
		int names_you_go=rand()%n+1;
		while(c[names_you_go].idx==c[now_turn].idx||c[names_you_go].HP<=0) names_you_go=rand()%n+1;
		int yes=rand()%10+1; 
		switch(pos){
			case 3:{//出技能 
				cout<<c[now_turn].name<<" 使用了 "<<c[now_turn].ay.fire<<",\n";
				int flag=c[now_turn].ay.fine.find("every",0);
				if(flag==-1){
					if(yes==1){
						cout<<c[names_you_go].name<<" 回避了攻击 。\n"; 
					} else {
						int fight_num=turn(c[now_turn].ay.fine);
						//if(!c[now_turn].ay.fire) 
						cout<<c[names_you_go].name<<" 受到了 "<<fight_num<<"点伤害";
						c[names_you_go].HP-=fight_num;
						if(c[names_you_go].HP<0) c[names_you_go].HP=0;
						if(c[names_you_go].HP==0){
							cout<<"	  "<<c[names_you_go].name<<"被击倒了"; 
							c[now_turn].go_upper++;
						}
						if(c[now_turn].ay.fine.find("turn",0)!=-1){
							cout<<","<<c[names_you_go].name<<" 被鬼魅了 ";
							c[names_you_go].turn_num="yes";
						}
						if(c[now_turn].ay.fine.find("wy",0)!=-1){
							cout<<","<<c[names_you_go].name<<" 被感染了 ";
							c[names_you_go].wy_num="yes";
						}
					}
					ano();
				} else {
					int fight_num=turn(c[now_turn].ay.fine);
					for(int i=1;i<=n;i++){
						if(c[i].HP<=0) continue;
						if(c[i].idx==c[names_you_go].idx){
							cout<<"   "<<c[i].name<<" 受到了 "<<fight_num<<"点伤害";
							c[i].HP-=fight_num;
							if(c[i].HP<=0){
								c[i].HP=0;
								cout<<","<<c[i].name<<"被击倒了;\n";
								c[now_turn].go_upper++;
								continue; 
							} 
							if(c[now_turn].ay.fine.find("turn",0)!=-1){
								cout<<","<<c[i].name<<" 被鬼魅了 ";
								c[i].turn_num="yes";
							}
							if(c[now_turn].ay.fine.find("wy",0)!=-1){
								cout<<","<<c[i].name<<" 被感染了 ";
								c[i].wy_num="yes";
							}
							cout<<"\n";
						}
					}
				}
				break;
			}
			default:{//出普通攻击 
				cout<<c[now_turn].name<<"发起攻击,"; 
				if(yes==1){
					cout<<c[names_you_go].name<<" 回避了攻击 。"; 
				} else {
					int fight_num=c[now_turn].G;
					//if(!c[now_turn].ay.fire) 
					cout<<c[names_you_go].name<<" 受到了 "<<fight_num<<"点伤害";
					c[names_you_go].HP-=fight_num;
					if(c[names_you_go].HP<0) c[names_you_go].HP=0;
					if(c[names_you_go].HP==0){
						cout<<"	  "<<c[names_you_go].name<<"被击倒了";
						c[now_turn].go_upper++; 
					}
					//if(c[now_turn].ay.fine.find("turn",0)!=-1){
					//	cout<<","<<c[names_you_go].name<<" 被鬼魅了 ";
					//	c[names_you_go].turn_num="yes";
					//}
					//if(c[now_turn].ay.fine.find("wy",0)!=-1){
					//	cout<<","<<c[names_you_go].name<<" 被感染了 ";
					//	c[names_you_go].wy_num="yes";
					//}
					ano();
				}
				break;
			} 
		} 
		Sleep(500);
		cout<<endl;
	}
	return ;
}

void last_out(){
	//cout<<turn("100");
	ano();
	ano();
	cout<<"胜者:";
	int pos=-1;
	ano();
	for(int i=1;i<=n;i++){
		if(c[i].HP>0){
			pos=c[i].idx;
			break;
		}	
	} 
	for(int i=1;i<=n;i++){
		if(c[i].idx==pos){
			cout<<(char)(c[i].idx+'A'-1)<<":";
			cout<<c[i].name<<" "<<c[i].go_upper<<"\n";
		}
	}
	ano();
	ano();
	cout<<"败者:";
	ano();
	 for(int i=1;i<=n;i++){
		if(c[i].idx!=pos){
			cout<<(char)(c[i].idx+'A'-1)<<":";
			cout<<c[i].name<<" "<<c[i].go_upper<<"\n";
		}
	}
	return ;
}

int main(){
	give_num_to_how_a_fine_work(); 
	begin();
	in();
	fight_begin_out();
	fight();
	last_out();
	return 0;
}

 

张帆在2021-02-09 10:35:18追加了内容

ding

张帆在2021-02-09 18:27:03追加了内容
#include<iostream>
#include<windows.h>
#include<bits/stdc++.h>

using namespace std;

struct j{
	string fire;//技能名字
	string fine;//对敌人造成的伤害 
}; 

struct chacracter{
	string name;
	int HP,G,Z;
	j ay;
	int idx,num;
	string turn_num="";
	string wy_num="";
	int go_upper=0;
}; /*
	HP:血量
	G:攻击力
	Z:智力 
	ay:特技 
	idx:所在队伍 
	num:人物编号 
	*/

int n=1;

chacracter c[110]; 
j how[20];//技能 

void give_num_to_how_a_fine_work(){
	how[1].fire="火球术",how[1].fine="100";
	how[2].fire="心灵控制",how[2].fine="10+turn";
	how[3].fire="地裂术",how[3].fine="25+every";
	//how[4].fire="铁壁",how[4].fine="0+fend";//fend防守
	how[4].fire="瘟疫",how[4].fine="10+wy";//wy感染
	how[5].fire="懒癌",how[5].fine="20+wy";//wy感染 
	//how[7].fire="回避攻击",how[8].fine="0+fend"; 
	how[6].fire="终极一击",how[6].fine="200+every+wy+turn";
	return ; 
}

void out(string said){
	for(int i=0;i<said.length();i++){
		cout<<said[i];
		Sleep(50);
	}
	return ;
}//输入一个字符串,每5毫秒输出一个字符 

void ano(){
	cout<<"\n";
	return ;
}//换行简写 

void begin(){
	out("欢迎来到NC 1.2");
	//ano();
	//ano();
	Sleep(1000);
	system("cls");
	out("下面请输入名字,按enter+enter分队,禁止外挂,若系统发现外挂,自动退游,最多支持100个名字对战,超出可能会报错。");
	ano();
	out("按enter+(ctrl+z)+enter(注:分开按)结束输入,开始对战");
	Sleep(5000);
	//cout<"\n";
	system("cls");
	return ; 
}//开始对白

void give_num_to_people(int id){
	int x=rand()%5+1;
	c[id].ay.fire=how[x].fire;
	c[id].ay.fine=how[x].fine;
	if(c[id].name.find("dragon",0)!=-1){
		c[id].ay.fire=how[6].fire;
		c[id].ay.fine=how[6].fine;
	} 
	c[id].HP=rand()%201+200;
	c[id].G=rand()%41+10;
	c[id].Z=rand()%100+1; 
	return ;
}//对于每一个人物,生成属性。 

void in(){
	int ans=1;
	while(getline(cin,c[n].name)){
		if(c[n].name.empty()){
			ans++;
		} else {
			c[n].idx=ans;
			c[n].num=n; 
			give_num_to_people(n); 
			n++;
		}
		//give_num_to_people(n); 
		//cout<<n<<" "<<c[n].HP<<" "<<c[n].G<<" "<<c[n].Z<<" "<<c[n].idx<<"\n";
	}
	n--;
	if(n<2){
		out("wrong");
		exit(0);
	} 
	if(ans==1){//单斗模式 
		//int poster=1;
		for(int i=1;i<=n;i++){
			c[i].idx=i;
		} 
	}
	return ;
}//输入 

void fight_begin_out(){
	system("cls");
	for(int i=1;i<=n;i++){
		cout<<(char)(c[i].idx+'A'-1)<<":";
		cout<<c[i].name<<"  ";
		cout<<"HP:"<<c[i].HP<<" ";
		cout<<"攻:"<<c[i].G<<" ";
		cout<<"智:"<<c[i].Z<<" ";
		//cout<<"队伍:"<<c[i].idx<<" "; 
		ano();
		//if(c[i].idx!=c[i-1].idx) ano(); 
	}
	cout<<"_____________________________________________________\n";
	return ;
}//开始输出属性 

bool check(){
	int pos=0,cnt=0;
	for(int i=1;i<=n;i++){
		if(c[i].HP>0){
			if(c[i].idx!=pos){
				pos=c[i].idx;
				cnt++;
			}
		}
	}
	return cnt>1;
}

int turn(string s){
	int sum=0;
	for(int i=0;i<s.length();i++){
		if(!(s[i]>='0'&&s[i]<='9')) break;
		sum=sum*10+(int)(s[i]-'0');
	}
	return sum;
}

void fight(){
	int now_turn=0;
	while(check()){
		//cout<<"yes\n";
		now_turn=now_turn%n+1;
		if(c[now_turn].HP==0) continue;
		int pos=rand()%3+1;//出招与否
		//if(c[now_turn].ay.fire=="铁壁"||c[now_turn].ay.fire=="回避攻击"){
		//	pos=2;
		//} 
		int names_you_go=rand()%n+1;
		while(c[names_you_go].idx==c[now_turn].idx||c[names_you_go].HP<=0) names_you_go=rand()%n+1;
		int yes=rand()%10+1; 
		switch(pos){
			case 3:{//出技能 
				cout<<c[now_turn].name<<" 使用了 "<<c[now_turn].ay.fire<<",\n";
				int flag=c[now_turn].ay.fine.find("every",0);
				if(flag==-1){
					if(yes==1){
						cout<<c[names_you_go].name<<" 回避了攻击 。\n"; 
					} else {
						int fight_num=turn(c[now_turn].ay.fine);
						//if(!c[now_turn].ay.fire) 
						cout<<c[names_you_go].name<<" 受到了 "<<fight_num<<"点伤害";
						c[names_you_go].HP-=fight_num;
						if(c[names_you_go].HP<0) c[names_you_go].HP=0;
						if(c[names_you_go].HP==0){
							cout<<"	  "<<c[names_you_go].name<<"被击倒了"; 
							c[now_turn].go_upper++;
						}
						if(c[now_turn].ay.fine.find("turn",0)!=-1){
							cout<<","<<c[names_you_go].name<<" 被鬼魅了 ";
							c[names_you_go].turn_num="yes";
						}
						if(c[now_turn].ay.fine.find("wy",0)!=-1){
							cout<<","<<c[names_you_go].name<<" 被感染了 ";
							c[names_you_go].wy_num="yes";
						}
					}
					ano();
				} else {
					int fight_num=turn(c[now_turn].ay.fine);
					for(int i=1;i<=n;i++){
						if(c[i].HP<=0) continue;
						if(c[i].idx==c[names_you_go].idx){
							cout<<"   "<<c[i].name<<" 受到了 "<<fight_num<<"点伤害";
							c[i].HP-=fight_num;
							if(c[i].HP<=0){
								c[i].HP=0;
								cout<<","<<c[i].name<<"被击倒了;\n";
								c[now_turn].go_upper++;
								continue; 
							} 
							if(c[now_turn].ay.fine.find("turn",0)!=-1){
								cout<<","<<c[i].name<<" 被鬼魅了 ";
								c[i].turn_num="yes";
							}
							if(c[now_turn].ay.fine.find("wy",0)!=-1){
								cout<<","<<c[i].name<<" 被感染了 ";
								c[i].wy_num="yes";
							}
							cout<<"\n";
						}
					}
				}
				break;
			}
			default:{//出普通攻击 
				cout<<c[now_turn].name<<"发起攻击,"; 
				if(yes==1){
					cout<<c[names_you_go].name<<" 回避了攻击 。"; 
				} else {
					int fight_num=c[now_turn].G;
					//if(!c[now_turn].ay.fire) 
					cout<<c[names_you_go].name<<" 受到了 "<<fight_num<<"点伤害";
					c[names_you_go].HP-=fight_num;
					if(c[names_you_go].HP<0) c[names_you_go].HP=0;
					if(c[names_you_go].HP==0){
						cout<<"	  "<<c[names_you_go].name<<"被击倒了";
						c[now_turn].go_upper++; 
					}
					//if(c[now_turn].ay.fine.find("turn",0)!=-1){
					//	cout<<","<<c[names_you_go].name<<" 被鬼魅了 ";
					//	c[names_you_go].turn_num="yes";
					//}
					//if(c[now_turn].ay.fine.find("wy",0)!=-1){
					//	cout<<","<<c[names_you_go].name<<" 被感染了 ";
					//	c[names_you_go].wy_num="yes";
					//}
					ano();
				}
				break;
			} 
		} 
		Sleep(500);
		cout<<endl;
	}
	return ;
}

void last_out(){
	//cout<<turn("100");
	ano();
	ano();
	cout<<"胜者:";
	int pos=-1;
	ano();
	for(int i=1;i<=n;i++){
		if(c[i].HP>0){
			pos=c[i].idx;
			break;
		}	
	} 
	for(int i=1;i<=n;i++){
		if(c[i].idx==pos){
			cout<<(char)(c[i].idx+'A'-1)<<":";
			cout<<c[i].name<<" "<<c[i].go_upper<<"\n";
		}
	}
	ano();
	ano();
	cout<<"败者:";
	ano();
	 for(int i=1;i<=n;i++){
		if(c[i].idx!=pos){
			cout<<(char)(c[i].idx+'A'-1)<<":";
			cout<<c[i].name<<" "<<c[i].go_upper<<"\n";
		}
	} 
	return ;
}

int main(){
	give_num_to_how_a_fine_work(); 
	begin();
	in();
	fight_begin_out();
	fight();
	last_out();
	return 0;
}

 

张帆在2021-02-09 18:42:11追加了内容

@黄子澄 

@包涵宇 

@汪恺恒 

1.2版本,改好了。

 

 

 

张帆在2021-02-10 11:23:33追加了内容

迁贴


0
已采纳
汪恺恒
汪恺恒
中级启示者
中级启示者

输出是不是有些太快了,还没看清就结束了

0
沙宸安
沙宸安
高级启示者
高级启示者

不得不说,这次,你用心了。

[鼓掌]

0
0
0
0
0
赵朗
赵朗
高级光能
高级光能

小心点·-·

官方无能,挂逼纵横

我要回答