跳到正文

剪贴板

剪贴板 hp8tmu97

LJQ0808
原文
剪贴板信息

剪贴板信息

发布
收录
更新

duo compare(双人)(决斗类)

(多人版为 FFA)

C++
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
const int N=1e5+5;
int n;
struct Node{
	int k;
	int hp;
	string s;
	int shan;
};
Node a[N];
map<string,int> val;
signed main(){
	//HAPPY!
	srand(time(0));
	while(1){
		while(1){
			cout<<"开始 Y(yes)/N(no)/Q(query)\n";
			char c;
			cin>>c;
			if(c=='N'){
				cout<<"bye bye\n";
				return 0;
			}
			else if(c=='Q'){
				cout<<"谁??\n";
				string name;
				cin>>name;
				cout<<name<<" 比赛分为:"<<val[name]<<"\n";
				Sleep(1500);
				system("cls");
			}
			else{
				break;
			} 
		}
		cout<<"玩家2位\n";
		cin>>a[0].s>>a[1].s;
		while(a[0].s==a[1].s){
			cout<<"名字不能相同\n";
			cin>>a[0].s>>a[1].s;
		}
		a[0].hp=a[1].hp=150;
		a[0].k=a[1].k=0;
		a[0].shan=a[1].shan=0;
		int x=rand()%(2);
		cout<<a[x].s<<"先走\n";
		cout<<a[!x].s<<" 先选道具\n"; 
		cout<<"1(生命+20)/2(魔法阵+13)\n";
		while(1){
			char c;
			cin>>c;
			c-='0';
			if(c==1){
				cout<<a[!x].s<<" 生命+20\n";
				a[!x].hp+=20;
				cout<<a[x].s<<" 魔法阵+13\n";
				a[x].k+=13;
				break;
			}
			else if(c==2){
				cout<<a[!x].s<<" 魔法阵+13\n";
				a[!x].k+=13;
				cout<<a[x].s<<" 生命+20\n";
				a[x].hp+=20;
				break;
			}
			else{
				cout<<"错误\n";
				cout<<"1(生命+20)/2(魔法阵+13)\n";
			}
		} 
		Sleep(800);
		system("cls");
		while(1){
			cout<<a[0].s<<"\n魔法值为:"<<a[0].k<<"\n生命为:"<<a[0].hp<<"\n闪击牌为:"<<a[0].shan<<endl;
			cout<<a[1].s<<"\n魔法值为:"<<a[1].k<<"\n生命为:"<<a[1].hp<<"\n闪击牌为:"<<a[1].shan<<endl;
			cout<<a[x].s<<"走\n";
			cout<<"1(普攻)/2(魔法攻击)/3(抽卡)\n";
			char c;
			cin>>c;
			bool K=0;
			while(1){
				c-='0';
				if(c!=1 && c!=2 && c!=3){
					cout<<"错误\n";
					cout<<"1(普攻)/2(魔法攻击)/3(抽卡)\n";
					cin>>c;
					continue;
				}
				if(c==1){
					int ggg=rand()%(4);
					if(!ggg){
						cout<<a[!x].s<<" 闪!!!\n";
						break;
					}
					if(a[!x].shan>=1){
						cout<<a[!x].s<<" 闪!!!\n";
						a[!x].shan--;
						break;
					}
					a[!x].hp-=10;
					cout<<a[!x].s<<" hp-10\n";
					int up=rand()%(5)+1;
					cout<<a[x].s<<" 魔法值+"<<up<<endl;
					a[x].k+=up;
					break;
				} 
				else if(c==2){
					if(a[x].k<20){
						cout<<"魔法值不足20\n";
						cin>>c;
						continue;
					}
					if(a[!x].shan>=4){
						cout<<a[!x].s<<" 闪!!!\n";
						a[!x].shan-=4;
						break;
					}
					a[!x].hp-=30;
					a[x].k-=20;
					cout<<a[!x].s<<" hp-30\n";
					break;
				}
				else{
					int num=rand()%(9);
					if(num==0 || num==1){
						cout<<a[x].s<<" 使用(桃)\n";
						int xx=rand()%(5)+8;
						cout<<a[x].s<<" hp+"<<xx<<endl;
						a[x].hp+=xx;
					}
					else if(num==2 || num==3){
						cout<<a[x].s<<" 使用(杀)\n";
						int xx=rand()%(5)+10;
						a[!x].hp-=xx;
						cout<<a[!x].s<<" hp-"<<xx<<endl;
					}
					else if(num==4 || num==5){
						cout<<a[x].s<<" 使用(魔法阵)\n";
						int up=rand()%(5)+8;
						cout<<a[x].s<<" 魔法值+"<<up<<endl;
						a[x].k+=up;
					}
					else if(num==6){
						cout<<a[x].s<<" 使用(闪击)\n";
						int up=rand()%(1)+1;
						cout<<a[x].s<<" 闪击牌+"<<up<<endl;
						a[x].shan+=up;
					}
					else if(num==7){
						if(a[x].hp<50 && a[!x].hp<50){
							cout<<a[x].s<<" 你是否使用(决一死战)?(Y/N)\n";
							char yue;
							cin>>yue;
							if(yue=='N'){
								cout<<"ok\n";
							}
							else{
								cout<<a[x].s<<" 使用(决一死战)!!!\n";
								int yi=rand()%(5)+1;
								if(yi%2==0){
									cout<<a[x].s<<" wins\n";
									cout<<a[x].s<<" 比赛分+"<<a[x].hp<<"\n";
									val[a[x].s]+=a[x].hp;
									Sleep(3000);
									system("cls");
								}
								else{
									cout<<a[!x].s<<" wins\n";
									cout<<a[!x].s<<" 比赛分+"<<a[!x].hp<<"\n";
									val[a[!x].s]+=a[!x].hp;
									Sleep(3000);
									system("cls");
								}
								K=1;
							}
						}
						else{
							cout<<"无\n"; 
						}
					}
					else{
						cout<<"无\n";
					}
					break;
				} 
			}
			if(K){
				break;
			}
			Sleep(800);
			system("cls");
			if(a[!x].hp<=0){
				cout<<a[x].s<<" wins\n";
				cout<<a[x].s<<" 比赛分+"<<a[x].hp<<"\n";
				val[a[x].s]+=a[x].hp;
				Sleep(3000);
				system("cls");
				break;
			}
			cout<<a[0].s<<"\n魔法值为:"<<a[0].k<<"\n生命为:"<<a[0].hp<<"\n闪击牌为:"<<a[0].shan<<endl;
			cout<<a[1].s<<"\n魔法值为:"<<a[1].k<<"\n生命为:"<<a[1].hp<<"\n闪击牌为:"<<a[1].shan<<endl;
			cout<<a[!x].s<<"走\n";
			cout<<"1(普攻)/2(魔法攻击)/3(抽卡)\n";
			char cc;
			cin>>cc;
			while(1){
				cc-='0';
				if(cc!=1 && cc!=2 && cc!=3){
					cout<<"错误\n";
					cout<<"1(普攻)/2(魔法攻击)/3(抽卡)\n";
					cin>>cc;
					continue;
				}
				if(cc==1){
					int ggg=rand()%(4);
					if(!ggg){
						cout<<a[x].s<<" 闪!!!\n";
						break;
					}
					if(a[x].shan>=1){
						cout<<a[x].s<<" 闪!!!\n";
						a[x].shan--;
						break;
					}
					a[x].hp-=10;
					cout<<a[x].s<<" hp-10\n";
					int up=rand()%(5)+1;
					cout<<a[!x].s<<" 魔法值+"<<up<<endl;
					a[!x].k+=up;
					break;
				} 
				else if(cc==2){
					if(a[!x].k<20){
						cout<<"魔法值不足20\n";
						cin>>cc;
						continue;
					}
					if(a[x].shan>=4){
						cout<<a[x].s<<" 闪!!!\n";
						a[x].shan-=4;
						break;
					}
					a[x].hp-=30;
					a[!x].k-=20;
					cout<<a[x].s<<" hp-30\n";
					break;
				}
				else{
					int num=rand()%(9);
					if(num==0 || num==1){
						cout<<a[!x].s<<" 使用(桃)\n";
						int xx=rand()%(5)+8;
						cout<<a[!x].s<<" hp+"<<xx<<endl;
						a[!x].hp+=xx;
					}
					else if(num==2 || num==3){
						cout<<a[!x].s<<" 使用(杀)\n";
						int xx=rand()%(8)+10;
						a[x].hp-=xx;
						cout<<a[x].s<<" hp-"<<xx<<endl;
					}
					else if(num==4 || num==5){
						cout<<a[!x].s<<" 使用(魔法阵)\n";
						int up=rand()%(5)+8;
						cout<<a[!x].s<<" 魔法值+"<<up<<endl;
						a[!x].k+=up;
					}
					else if(num==6){
						cout<<a[!x].s<<" 使用(闪击)\n";
						int up=rand()%(1)+1;
						cout<<a[!x].s<<" 闪击牌+"<<up<<endl;
						a[!x].shan+=up;
					}
					else if(num==7){
						if(a[x].hp<60 && a[!x].hp<60){
							cout<<a[!x].s<<" 你是否使用(决一死战)?(Y/N)\n";
							char yue;
							cin>>yue;
							if(yue=='N'){
								cout<<"ok\n";
							}
							else{
								cout<<a[!x].s<<" 使用(决一死战)!!!\n";
								int yi=rand()%(5)+1;
								if(yi%2==0){
									cout<<a[!x].s<<" wins\n";
									cout<<a[!x].s<<" 比赛分+"<<a[!x].hp<<"\n";
									val[a[!x].s]+=a[!x].hp;
									Sleep(3000);
									system("cls");
								}
								else{
									cout<<a[x].s<<" wins\n";
									cout<<a[x].s<<" 比赛分+"<<a[x].hp<<"\n";
									val[a[x].s]+=a[x].hp;
									Sleep(3000);
									system("cls");
								}
								K=1;
								break;
							}
						}
						else{
							cout<<"无\n";
						}
						break;
					}
					else{
						cout<<"无\n";
					}
					break;
				} 
			}
			if(K){
				break;
			}
			Sleep(800);
			system("cls");
			if(a[x].hp<=0){
				cout<<a[!x].s<<" wins\n";
				cout<<a[!x].s<<" 比赛分+"<<a[!x].hp<<"\n";
				val[a[!x].s]+=a[!x].hp;
				Sleep(3000);
				system("cls");
				break;
			}
		}
	}
	return 0;
}