c++哈利·波特

//转自https://www.luogu.com.cn/discuss/387551
#include<bits/stdc++.h>
#include <windows.h>
using namespace std;
bool shootin(){
	srand(time(0));
	int bol=rand()%99;
	bol++;
	if(85>=bol)return 1;
	return 0;
}
void NAME()
{
	srand(time(0));
	char* NA1[444] = { "赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许", "何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章", "云", "苏", "潘", "葛", "奚", "范", "彭", "郎", "鲁", "韦", "昌", "马", "苗", "凤", "花", "方", "俞", "任", "袁", "柳", "酆", "鲍", "史", "唐", "费", "廉", "岑", "薛", "雷", "贺", "倪", "汤", "滕", "殷", "罗", "毕", "郝", "邬", "安", "常", "乐", "于", "时", "傅", "皮", "卞", "齐", "康", "伍", "余", "元", "卜", "顾", "孟", "平", "黄", "和", "穆", "萧", "尹", "姚", "邵", "湛", "汪", "祁", "毛", "禹", "狄", "米", "贝", "明", "臧", "计", "伏", "成", "戴", "谈", "宋", "茅", "庞", "熊", "纪", "舒", "屈", "项", "祝", "董", "梁", "杜", "阮", "蓝", "闵", "席", "季", "麻", "强", "贾", "路", "娄", "危", "江", "童", "颜", "郭", "梅", "盛", "林", "刁", "钟", "徐", "邱", "骆", "高", "夏", "蔡", "田", "樊", "胡", "凌", "霍", "虞", "万", "支", "柯", "昝", "管", "卢", "莫", "经", "房", "裘", "缪", "干", "解", "应", "宗", "丁", "宣", "贲", "邓", "郁", "单", "杭", "洪", "包", "诸", "左", "石", "崔", "吉", "钮", "龚", "程", "嵇", "邢", "滑", "裴", "陆", "荣", "翁", "荀", "羊", "於", "惠", "甄", "麴", "家", "封", "芮", "羿", "储", "靳", "汲", "邴", "糜", "松", "井", "段", "富", "巫", "乌", "焦", "巴", "弓", "牧", "隗", "山", "谷", "车", "侯", "宓", "蓬", "全", "郗", "班", "仰", "秋", "仲", "伊", "宫", "宁", "仇", "栾", "暴", "甘", "钭", "厉", "戎", "祖", "武", "符", "刘", "景", "詹", "束", "龙", "叶", "幸", "司", "韶", "郜", "黎", "蓟", "薄", "印", "宿", "白", "怀", "蒲", "邰", "从", "鄂", "索", "咸", "籍", "赖", "卓", "蔺", "屠", "蒙", "池", "乔", "阴", "郁", "胥", "能", "苍", "双", "闻", "莘", "党", "翟", "谭", "贡", "劳", "逄", "姬", "申", "扶", "堵", "冉", "宰", "郦", "雍", "舄", "璩", "桑", "桂", "濮", "牛", "寿", "通", "边", "扈", "燕", "冀", "郏", "浦", "尚", "农", "温", "别", "庄", "晏", "柴", "瞿", "阎", "充", "慕", "连", "茹", "习", "宦", "艾", "鱼", "容", "向", "古", "易", "慎", "戈", "廖", "庾", "终", "暨", "居", "衡", "步", "都", "耿", "满", "弘", "匡", "国", "文", "寇", "广", "禄", "阙", "东", "殴", "殳", "沃", "利", "蔚", "越", "夔", "隆", "师", "巩", "厍", "聂", "晁", "勾", "敖", "融", "冷", "訾", "辛", "阚", "那", "简", "饶", "空", "曾", "毋", "沙", "乜", "养", "鞠", "须", "丰", "巢", "关", "蒯", "相", "查", "後", "荆", "红", "游", "竺", "权", "逯", "盖", "益", "桓", "公", "仉", "督", "晋", "楚", "闫", "法", "汝", "鄢", "涂", "钦", "归", "海", "岳", "帅", "缑", "亢", "况", "后", "有", "琴", "商", "牟", "佘", "佴", "伯", "赏", "墨", "哈", "谯", "笪", "年", "爱", "阳", "佟", "言", "福" };
	char* NA2[59] = { "万俟", "司马", "上官", "欧阳", "夏侯", "诸葛", "闻人", "东方", "赫连", "皇甫", "尉迟", "公羊", "澹台", "公冶", "宗政", "濮阳", "淳于", "单于", "太叔", "申屠", "公孙", "仲孙", "轩辕", "令狐", "钟离", "宇文", "长孙", "慕容", "鲜于", "闾丘", "司徒", "司空", "亓官", "司寇", "子车", "颛孙", "端木", "巫马", "公西", "漆雕", "乐正", "壤驷", "公良", "拓跋", "夹谷", "宰父", "谷梁", "百里", "东郭", "南门", "呼延", "羊舌", "微生", "梁丘", "左丘", "东门", "西门", "南宫", "第五" };
	char* ME1m[140] = { "伟", "刚", "勇", "毅", "俊", "峰", "强", "军", "平", "保", "东", "文", "辉", "力", "明", "永", "健", "世", "广", "志", "义", "兴", "良", "海", "山", "仁", "波", "宁", "贵", "福", "生", "龙", "元", "全", "国", "胜", "学", "祥", "才", "发", "武", "新", "利", "清", "飞", "彬", "富", "顺", "信", "子", "杰", "涛", "昌", "成", "康", "星", "光", "天", "达", "安", "岩", "中", "茂", "进", "林", "有", "坚", "和", "彪", "博", "诚", "先", "敬", "震", "振", "壮", "会", "思", "群", "豪", "心", "邦", "承", "乐", "绍", "功", "松", "善", "厚", "庆", "磊", "民", "友", "裕", "河", "哲", "江", "超", "浩", "亮", "政", "谦", "亨", "奇", "固", "之", "轮", "翰", "朗", "伯", "宏", "言", "若", "鸣", "朋", "斌", "梁", "栋", "维", "启", "克", "伦", "翔", "旭", "鹏", "泽", "晨", "辰", "士", "以", "建", "家", "致", "树", "炎", "德", "行", "时", "泰", "盛" };
	char* ME2m[140] = { "伟", "刚", "勇", "毅", "俊", "峰", "强", "军", "平", "保", "东", "文", "辉", "力", "明", "永", "健", "世", "广", "志", "义", "兴", "良", "海", "山", "仁", "波", "宁", "贵", "福", "生", "龙", "元", "全", "国", "胜", "学", "祥", "才", "发", "武", "新", "利", "清", "飞", "彬", "富", "顺", "信", "子", "杰", "涛", "昌", "成", "康", "星", "光", "天", "达", "安", "岩", "中", "茂", "进", "林", "有", "坚", "和", "彪", "博", "诚", "先", "敬", "震", "振", "壮", "会", "思", "群", "豪", "心", "邦", "承", "乐", "绍", "功", "松", "善", "厚", "庆", "磊", "民", "友", "裕", "河", "哲", "江", "超", "浩", "亮", "政", "谦", "亨", "奇", "固", "之", "轮", "翰", "朗", "伯", "宏", "言", "若", "鸣", "朋", "斌", "梁", "栋", "维", "启", "克", "伦", "翔", "旭", "鹏", "泽", "晨", "辰", "士", "以", "建", "家", "致", "树", "炎", "德", "行", "时", "泰", "盛" };
	char* ME1f[165] = { "秀", "娟", "英", "华", "慧", "巧", "美", "娜", "静", "淑", "惠", "珠", "翠", "雅", "芝", "玉", "萍", "红", "娥", "玲", "芬", "芳", "燕", "彩", "春", "菊", "兰", "凤", "洁", "梅", "琳", "素", "云", "莲", "真", "环", "雪", "荣", "爱", "妹", "霞", "香", "月", "莺", "媛", "艳", "瑞", "凡", "佳", "嘉", "琼", "勤", "珍", "贞", "莉", "桂", "娣", "叶", "璧", "璐", "娅", "琦", "晶", "妍", "茜", "秋", "珊", "莎", "锦", "黛", "青", "倩", "婷", "姣", "婉", "娴", "瑾", "颖", "露", "瑶", "怡", "婵", "雁", "蓓", "纨", "仪", "荷", "丹", "蓉", "眉", "君", "琴", "蕊", "薇", "菁", "梦", "岚", "苑", "筠", "柔", "竹", "霭", "凝", "晓", "欢", "霄", "枫", "芸", "菲", "寒", "欣", "滢", "伊", "亚", "宜", "可", "姬", "舒", "影", "荔", "枝", "思", "丽", "秀", "飘", "育", "馥", "琦", "晶", "妍", "茜", "秋", "珊", "莎", "锦", "黛", "青", "倩", "婷", "宁", "蓓", "纨", "苑", "婕", "馨", "瑗", "琰", "韵", "融", "园", "艺", "咏", "卿", "聪", "澜", "纯", "毓", "悦", "昭", "冰", "爽", "琬", "茗", "羽", "希" };
	char* ME2f[165] = { "秀", "娟", "英", "华", "慧", "巧", "美", "娜", "静", "淑", "惠", "珠", "翠", "雅", "芝", "玉", "萍", "红", "娥", "玲", "芬", "芳", "燕", "彩", "春", "菊", "兰", "凤", "洁", "梅", "琳", "素", "云", "莲", "真", "环", "雪", "荣", "爱", "妹", "霞", "香", "月", "莺", "媛", "艳", "瑞", "凡", "佳", "嘉", "琼", "勤", "珍", "贞", "莉", "桂", "娣", "叶", "璧", "璐", "娅", "琦", "晶", "妍", "茜", "秋", "珊", "莎", "锦", "黛", "青", "倩", "婷", "姣", "婉", "娴", "瑾", "颖", "露", "瑶", "怡", "婵", "雁", "蓓", "纨", "仪", "荷", "丹", "蓉", "眉", "君", "琴", "蕊", "薇", "菁", "梦", "岚", "苑", "筠", "柔", "竹", "霭", "凝", "晓", "欢", "霄", "枫", "芸", "菲", "寒", "欣", "滢", "伊", "亚", "宜", "可", "姬", "舒", "影", "荔", "枝", "思", "丽", "秀", "飘", "育", "馥", "琦", "晶", "妍", "茜", "秋", "珊", "莎", "锦", "黛", "青", "倩", "婷", "宁", "蓓", "纨", "苑", "婕", "馨", "瑗", "琰", "韵", "融", "园", "艺", "咏", "卿", "聪", "澜", "纯", "毓", "悦", "昭", "冰", "爽", "琬", "茗", "羽", "希" };
	int NA1Roll = rand() % 444;
	int NA2Roll = rand() % 59;
	int ME1mRoll = rand() % 140;
	int ME2mRoll = rand() % 140;
	int ME1fRoll = rand() % 165;
	int ME2fRoll = rand() % 165;
	int a=rand()%7;
	a++;
	if(a==1){
	printf("%s%s\n", NA1[NA1Roll], ME1m[ME1mRoll]);
	NA1Roll = rand() % 444;
	ME1mRoll = rand() % 140;
	}
	if(a==2){
		printf("%s%s\n", NA1[NA1Roll], ME1f[ME1fRoll]);
	NA1Roll=rand() % 444;
	ME1mRoll=rand() % 140;
	ME2mRoll=rand() % 140;
	}
	if(a==3){
		printf("%s%s%s\n", NA1[NA1Roll], ME1m[ME1mRoll], ME1m[ME2mRoll]);
	NA1Roll = rand() % 444;
	ME1fRoll = rand() % 165;
	ME2fRoll = rand() % 165;
	}
	if(a==4){
		printf("%s%s%s\n", NA1[NA1Roll], ME1f[ME1fRoll], ME1f[ME2fRoll]);
	NA2Roll = rand() % 59;
	ME1mRoll = rand() % 140;
	}
	if(a==5){
		printf("%s%s\n", NA2[NA2Roll], ME1m[ME1mRoll]);
	NA2Roll = rand() % 59;
	ME1fRoll = rand() % 165;
	}
	if(a==6){
		printf("%s%s\n", NA2[NA2Roll], ME1f[ME1fRoll]);
	NA2Roll = rand() % 59;
	ME1mRoll = rand() % 140;
	ME2mRoll = rand() % 140;
	}
	if(a==7){
		printf("%s%s%s\n", NA2[NA2Roll], ME1m[ME1mRoll], ME2m[ME2mRoll]);
	NA2Roll = rand() % 59;
	ME1fRoll = rand() % 165;
	ME2fRoll = rand() % 165;
	}
	if(a==8)printf("%s%s%s\n", NA2[NA2Roll], ME1f[ME1fRoll], ME2f[ME2fRoll]);
}
bool use(int x){
	if(x>=100)return 1;
	srand(time(0));
	int bol=rand()%99;
	bol++;
	if(x>=bol)return 1;
	return 0;
}
struct mozhou{
	string name;
	int damage;
	int protect;
	int freeze;
	int fire;
	int shock;
}s[1001];
void pre(){
	s[1].name="lighting";
	s[1].damage=25;
	s[1].protect=0;
	s[1].freeze=0;
	s[1].fire=5;
	s[1].shock=25;
	s[2].name="Protego";
	s[2].damage=5;
	s[2].protect=10;
	s[2].freeze=0;
	s[2].fire=0;
	s[2].shock=100;
	s[3].name="Finite Incantatem";
	s[3].damage=15;//falldamage
	s[3].protect=10;
	s[3].freeze=20;
	s[3].fire=0;
	s[3].shock=40;
	s[4].name="Tergeo";
	s[4].damage=10;
	s[4].protect=10;
	s[4].freeze=0;
	s[4].fire=0;
	s[4].shock=30;
	s[5].name="Oppugno";
	s[5].damage=40;
	s[5].protect=-20;
	s[5].freeze=0;
	s[5].fire=50;
	s[5].shock=0;
}
int choose_f(int score){
	if(score<=100)return 1;//very easy
	if(score<=300)return 2;//easy
	if(score<=500)return 3;//medium
	if(score<=1000)return 4;//a bit hard
	if(score<=10000)return 5;//hard
	if(score<=20000)return 6;//very hard;
	return 7;//fudimo
}
int own[10001]={0};
int score=0,gold=100,coin=100,HP=100,k,hp;
void shop(){
	cout<<"##############################"<<endl;
	cout<<"#     Welcome to the shop    #"<<endl;
	cout<<"#                            #"<<endl;
	cout<<"# add HP  &&buy magic skills #"<<endl;
	cout<<"##############################"<<endl; 
	cout<<"是否需要回血(1/0)"<<endl;
	int x;
	cin>>x;
	if(x==1){
		if(HP<100)coin-=100;
		coin+=HP;
		HP=100;
		if(coin<0){
			HP-=abs(coin);
			coin=0;
		}
		cout<<"YOU have added HP";
		Sleep(1000);
		system("cls");
	}
//	cout<<"是否需要购买魔咒?(1/0)"<<endl;
//	cin>>x;
//	if(x==1){
//		
//	}
	cout<<"欢迎再来!";
	Sleep(1000);
	system("cls"); 
}
int theychoose(){
	srand(time(0));
//	if(choose_f(score)==1){
		int y=rand()%5;
		return y+1;
//	}
	/*if(choose(score)==2){
		
	}if(choose(score)==3){
		
	}if(choose(score)==4){
		
	}if(choose(score)==5){
		
	}if(choose(score)==6){
		
	}if(choose(score)==7){
		
	}*/
	//while(fine=0){
	//	used=rand()%choose_f(score)*choose_f(score);
	//	used++;
	//	if(s[used].damage>=20&&hp>HP)fine=1;
	//	if(s[used].protect>=10&&hp<HP)fine=1;
	//	if(s[used].stop>=1)fine=1;
	//}
}
void fight(){
	cout<<"你的对手是";
	NAME();
	int used;
	string stu="normal";
	hp=100*choose_f(score);
	while(hp>=0&&HP>=0){
		if(stu=="normal"){
			bool fine=0;
			used=theychoose();
			int x;
			for(int i=1;i<=k;i++)cout<<i<<"st name:"<<s[own[i]].name<<"   damage:"<<s[own[i]].damage<<"   protection:"<<s[own[i]].protect<<endl;
			cout<<"请选择魔咒";
			cin>>x;
			while(x>k){
				system("cls");
				cout<<"不合法\n";
				for(int i=1;i<=k;i++)cout<<i<<"st name:"<<s[own[i]].name<<"   damage:"<<s[own[i]].damage<<"   protection:"<<s[own[i]].protect<<endl;
				cin>>x;
				
			}
			system("cls");
			cout<<"对方使用魔咒"<<s[used].name<<endl;
			int damagea,damageb;
			bool youin=0,hein=0;
			if(shootin()==1){
				youin=1;
				if(shootin()==1){
					hein=1;
					damagea=s[x].damage-s[used].protect;
					damagea=max(damagea,0);
					damageb=s[used].damage-s[x].protect;
					damageb=max(damageb,0);
				}
				else {
					damageb=0;
					cout<<"They missed"<<endl;
				}
			}
			else{
				cout<<"You missed"<<endl;
				damagea=0;
				if(shootin()==0){
					damageb=0;
					cout<<"They missed"<<endl;
				}
				else{
					hein=1;
					damageb=s[used].damage;
				}
			}
			if(damagea==damageb)cout<<"魔咒抵消了"<<endl;
			else if(damagea>damageb){
				cout<<"they lose "<<damagea-damageb <<"HP!Well done!"<<endl;
				hp-=damagea-damageb;
			}
			else{
				cout<<"you lose "<<damageb-damagea <<"HP!Cheer UP!"<<endl;
				hp-=damagea-damageb;
			}
			if(youin==1){
				if(use(s[x].fire)==1){
					stu="fire1";
				}
				if(use(s[x].shock)==1){
					stu="shock1";
				}
				if(use(s[x].freeze)==1){
					stu="freeze1";
				}
			}
			Sleep(3000);
			system("cls");
			}
		
		if(stu=="freeze1"){
			stu="normal";
			bool fine=0;
			//used=theychoose();
			int x;
			for(int i=1;i<=k;i++)cout<<i<<"st name:"<<s[own[i]].name<<"   damage:"<<s[own[i]].damage<<"   protection:"<<s[own[i]].protect<<endl;
			cout<<"请选择魔咒";
			cin>>x;
			while(x>k){
				system("cls");
				cout<<"不合法\n";
				for(int i=1;i<=k;i++)cout<<i<<"st name:"<<s[own[i]].name<<"   damage:"<<s[own[i]].damage<<"   protection:"<<s[own[i]].protect<<endl;
				cin>>x;
				
			}
			system("cls");
		//	cout<<"对方使用魔咒"<<s[used].name<<endl;
			int damagea,damageb;
			bool youin=0,hein=0;
			damageb=0;
			if(shootin()==1){
				youin=1;
					damagea=s[x].damage-20;
					damagea=max(damagea,0);
				
				
			}
			else{
				cout<<"You missed"<<endl;
				damagea=0;
				damageb=0;
			}
			if(damagea==damageb)cout<<"魔咒抵消了"<<endl;
			else if(damagea>damageb){
				cout<<"they lose "<<damagea-damageb <<"HP!Well done!"<<endl;
				hp-=damagea-damageb;
			}
			else{
				cout<<"you lose "<<damageb-damagea <<"HP!Cheer UP!"<<endl;
				hp-=damagea-damageb;
			}
			if(youin==1){
				if(use(s[x].fire)==1){
					stu="fire1";
				}
				if(use(s[x].shock)==1){
					stu="shock1";
				}
				if(use(s[x].freeze)==1){
					stu="freeze1";
				}
			}
			Sleep(3000);
			system("cls");
			
		}
		if(stu=="fire1"){
			stu="normal";
			bool fine=0;
			used=theychoose();
			int x;
			for(int i=1;i<=k;i++)cout<<i<<"st name:"<<s[own[i]].name<<"   damage:"<<s[own[i]].damage<<"   protection:"<<s[own[i]].protect<<endl;
			cout<<"请选择魔咒";
			cin>>x;
			while(x>k){
				system("cls");
				cout<<"不合法\n";
				for(int i=1;i<=k;i++)cout<<i<<"st name:"<<s[own[i]].name<<"   damage:"<<s[own[i]].damage<<"   protection:"<<s[own[i]].protect<<endl;
				cin>>x;
				
			}
			system("cls");
			cout<<"对方使用魔咒"<<s[used].name<<endl;
			int damagea,damageb;
			bool youin=0,hein=0;
			if(shootin()==1){
				youin=1;
				if(shootin()==1){
					hein=1;
					damagea=s[x].damage-s[used].protect+5;
					damagea=max(damagea,5);
					damageb=s[used].damage-s[x].protect;
					damageb=max(damageb,0);
				}
				else {
					damageb=0;
					cout<<"They missed"<<endl;
				}
			}
			else{
				cout<<"You missed"<<endl;
				damagea=5;
				if(shootin()==0){
					damageb=0;
					cout<<"They missed"<<endl;
				}
				else{
					hein=1;
					damageb=s[used].damage;
				}
			}
			if(damagea==damageb)cout<<"魔咒抵消了"<<endl;
			else if(damagea>damageb){
				cout<<"they lose "<<damagea-damageb <<"HP!Well done!"<<endl;
				hp-=damagea-damageb;
			}
			else{
				cout<<"you lose "<<damageb-damagea <<"HP!Cheer UP!"<<endl;
				hp-=damagea-damageb;
			}
			if(youin==1){
				if(use(s[x].fire)==1){
					stu="fire1";
				}
				if(use(s[x].shock)==1){
					stu="shock1";
				}
				if(use(s[x].freeze)==1){
					stu="freeze1";
				}
			}
			Sleep(3000);
			system("cls");
			
		}
	}	
}
int main(){
	srand(time(0));
	pre();
	score=0,gold=100,coin=100,HP=100;
	k=5;
	cout<<"welcome to c++的奇怪1的哈利波特 v1.1\n";
	cout<<"made by awadiamond";
	/*
	cout<<"读档中"<<endl;
	freopen("in.txt", "r", stdin);
	int a;
	cin>>a;
	if(a==0){
		cout<<"无存档"<<endl;
		freopen("CON","r",stdin);
	}
	else{
		cout<<"读档成功"<<endl;
	}
	freopen("CON","r",stdin);
	*/
	//while(1)cin>>score;
	Sleep(1000);
	system("cls");
	own[1]=1;
	own[2]=2;
	own[3]=3;
	own[4]=4;
	own[5]=5;
	while(true){
		shop();
		cout<<"coin: "<<coin<<" gold: "<<gold<<endl;
		fight();	
	}
	return 0;
}
C Builder是一个集成开发环境(IDE),用于创建和开发窗体应用程序、控制台应用程序和动态链接库等,它使用Delphi的Object Pascal语言作为其主要开发语言。 高波特率设置是指在C Builder中设置串行通信端口(COM端口)的传输速率。串行通信是一种在计算机系统之间传输数据的方式,其中数据按照比特(bit)的顺序连续传输。波特率(baud rate)是衡量每秒传输比特数量的度量单位。较高的波特率意味着数据传输速度更快。 在C Builder中进行高波特率设置的过程通常涉及以下步骤: 1. 打开C Builder,并创建相应的窗体应用程序项目。 2. 在窗体上添加串行通信组件。在C Builder中,可以使用TComPort组件来实现串行通信。 3. 通过设置TComPort组件的属性,指定要连接的串行通信端口的名称和波特率设置。通常,可以通过设置BaudRate属性来指定波特率。 4. 在代码中编写逻辑,以处理串行通信的数据传输。可以使用TComPort组件提供的事件和方法来实现相关功能,例如OnRxChar事件用于处理接收到的字符数据。 5. 编译和运行应用程序,使用高波特率设置与已连接的串行设备进行数据通信。 总结起来,C Builder提供了方便的工具和组件,可以帮助开发人员轻松地进行串行通信相关的编程工作。通过设置合适的波特率,可以实现高速的数据传输,从而满足特定应用程序的需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值