哈利波特C++游戏

#include <iostream>
#include <string>
#include <windows.h>
#include <conio.h>
#include <fstream>
#include <ctime>
#include <time.h>
#include <stdio.h>
using namespace std;
 
int D_Of_C, OK, ane, xy, D_Of_C1, OK1, ane1, xy1, nowM, MoralValue;
int ict = 0, nowlevel = 0;
int bag[44] = { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0};
//0抽奖券 1经验石R 2经验石SR 3经验石SSR 4经验石SSS 5经验石X
//6技能书快快复苏 7技能书铁甲咒 8技能书昏昏倒地 9技能书神锋无影 10技能书咒立停 11技能书石化咒 12技能书恢复咒 13技能书召唤咒 14技能书遗忘咒 15技能书万弹齐发 16技能书钻心咒 17技能书夺魂咒 18技能书死亡咒
//19生命药水 20防御药水 21攻击药水 22经验药水 23全幅药水 
//24猫狸子胡须 25媚娃头发 26马形水怪的鬃毛 27龙心腱 28雷鸟尾羽 29凤凰羽毛 30独角兽尾毛 31龙神经 32夜骐的尾羽
//33桦木 34紫衫木 35冬青木 36山楂木柳条 37橡木 38械木 39山毛榉木 40栗木 41樱桃木 42桃花心木
//43速度药水
string Material1name[9] = { "猫狸子胡须","媚娃头发","马形水怪的鬃毛","龙心腱","雷鸟尾羽","凤凰羽毛","独角兽尾毛","龙神经","夜骐的尾羽" };
string Material2name[10] = { "桦木","紫衫木","冬青木","山楂木柳条","橡木","械木","山毛榉木","栗木","樱桃木","桃花心木" };
int health = 1000, maxhealth = 1000, money=0, attack = 250, defense = 10, experience = 0, camp, level = 1, amm = 0, f = 0, speed = 0;
string Nwand = "空手";
int LE1 = 1, LE2 = 1, Sl[13];
bool dead = false;
string wandname[100] = { "柳条魔杖","胡桃魔杖","鹅耳枥木魔杖","柳条魔杖","花心木魔杖","冬青木魔杖","紫杉木魔杖","老魔杖" };
int wandpower[100] = { 200,500,1100,1300,2400,5000,9000,20000 }, wand[100], wandi = 8, wandnamei = 8, wandpoweri = 8;
string name, password;
int choose()
{
	system("cls");
	cout << "请选择您的阵营。" << endl;
	cout << "0, 哈利.HarryPotter" << endl;
	cout << "1, 伏地魔 LordVoldemort" << endl;
	cin >> camp;
	if (camp != 0 && camp != 1) {
		cout << "输入错误。";
		Sleep(250);
		choose();
	}
	else {
		if (MessageBox(0, TEXT("你确定?"), TEXT("请选择"), MB_OKCANCEL | MB_ICONINFORMATION) == IDOK) return 0; 
		choose();
	}
	return 0;
}
int login()
{
	string DN, DPW;
	bool isn = false;
	cout << "请输入账号和密码" << endl;
	cout << "账号:";
	cin >> name;
	cout << "密码:";
	cin >> password;
	ifstream fin("data2.txt");
	while(fin >> DN) {
		if (DN == name) {
			fin >> DPW;
			if (DPW != password) {
				cout << "密码错误!" << endl; isn = true;
				system("cls"); login();
			}
			else {
				fin >> money >> attack >> defense >> health >> level >> experience >> LE1 >> LE2  >> camp >> maxhealth;
				fin >> D_Of_C >> OK >> ane >> xy >> D_Of_C1 >> OK1 >> ane1 >> xy1 >> nowM;
				fin >> bag[0] >> bag[1] >> bag[2] >> bag[3] >> bag[4] >> bag[5] >> bag[6] >> bag[7];
				fin >> bag[8] >> bag[9] >> bag[10] >> bag[11] >> bag[12] >> bag[13] >> bag[14] >> bag[15];
				fin >> bag[16] >> bag[17] >> bag[18] >> bag[19] >> bag[20] >> bag[21] >> bag[22] >> bag[23];
				fin >> bag[24] >> bag[25] >> bag[26] >> bag[27] >> bag[28] >> bag[29] >> bag[30] >> bag[31];
				fin >> bag[32] >> bag[33] >> bag[34] >> bag[35] >> bag[36] >> bag[37] >> bag[38] >> bag[39];
				fin >> bag[40] >> bag[41] >> bag[42] >> bag[43];
				fin >> Sl[0] >> Sl[1] >> Sl[2] >> Sl[3] >> Sl[4] >> Sl[5] >> Sl[6] >> Sl[7] >> Sl[8] >> Sl[9] >> Sl[10] >> Sl[11] >> Sl[12];
				for (int i = 0; i < 100; i++) {
					fin >> wandname[i];
					fin >> wandpower[i];
					fin >> wand[i];
				}			
				fin >> Nwand >> amm >> f >> wandi >> wandnamei >> wandpoweri >> ict >> speed >> nowlevel;
				isn = true;
			}
		}
	}
	if (!isn) {
		cout << "无此用户!" << endl;
		login();
	}
	cout << "登入成功!" << endl;
	Sleep(1000);
	return 0;
}
int save()
{
	ofstream outfile("data2.txt", ios::binary | ios::app | ios::in | ios::out);
	outfile << name << " " << password << " " << money << " " << attack << " " << defense << " " << health << " " << level << " " << experience << " " << LE1 << " " << LE2 << " " << camp << " " << maxhealth << " ";
	outfile << D_Of_C << " " << OK << " " << ane << " " << xy << " " << D_Of_C1 << " " << OK1 << " " << ane1 << " " << xy1 << " " << nowM << " ";
	outfile << bag[0] << " " << bag[1] << " " << bag[2] << " " << bag[3] << " " << bag[4] << " " << bag[5] << " " << bag[6] << " " << bag[7] << " ";
	outfile << bag[8] << " " << bag[9] << " " << bag[10] << " " << bag[11] << " " << bag[12] << " " << bag[13] << " " << bag[14] << " " << bag[15] << " ";
	outfile << bag[16] << " " << bag[17] << " " << bag[18] << " " << bag[19] << " " << bag[20] << " " << bag[21] << " " << bag[22] << " " << bag[23] << " ";
	outfile << bag[24] << " " << bag[25] << " " << bag[26] << " " << bag[27] << " " << bag[28] << " " << bag[29] << " " << bag[30] << " " << bag[31] << " ";
	outfile << bag[32] << " " << bag[33] << " " << bag[34] << " " << bag[35] << " " << bag[36] << " " << bag[37] << " " << bag[38] << " " << bag[39] << " ";
	outfile << bag[40] << " " << bag[41] << " " << bag[42] << " " << bag[43] << " ";
	outfile << Sl[0] << " " << Sl[1] << " " << Sl[2] << " " << Sl[3] << " " << Sl[4] << " " << Sl[5] << " " << Sl[6] << " " << Sl[7] << " " << Sl[8] << " " << Sl[9] << " " << Sl[10] << " " << Sl[11] << " " << Sl[12] << " ";
	for (int i = 0; i < 100; i++) {
		outfile << wandname[i] << " ";
		outfile << wandpower[i] << " ";
		outfile << wand[i] << " ";
	}
	outfile << Nwand << " " << amm << " " << f << " " << wandi << " " << wandnamei << " " << wandpoweri << " " << ict << " " << speed << " " << nowlevel << endl;
	outfile.close();
	return 0;
}
int Reg()
{
	string DN, DPW;
	cout << "请输入账号和密码  " << endl;
	cout << "账号:";
	cin >> name;
	cout << endl << "密码:";
	cin >> password;
	ifstream fin("data2.txt");
	while(fin >> DN) {
		if (DN == name) {
			cout << "用户名已被使用=====请重新起名";
			Reg();
		}
	}
	choose();
	return 0;
}
int monsterfight(string Hname, int hisH, int hisA, int hisD, int hisS, int hisSP)
{
	int mhealth = 10000, mdefense = 1000, mattack = 10000, mspeed = 500;
	int hfaint = 0;
	int mfaint = 0;
	dead = false;
	int ha = hisA;
	while (1) {
		if (hfaint > 0) hfaint -= 1; 
		if (mfaint > 0) {
			if (rand() % 3 == 0)
			{
				mfaint = 0;
				cout << "石怪使用技能咒立停,停止了魔咒!" << endl;
			}
			else mfaint -= 1;
		}
		if (mfaint <= 0) {
			if (rand() % 3) {
				cout << "石怪使用技能快快复苏 生命增加200" << endl;
				mhealth += 200;
			}
			if (rand() % 3) {
				cout << "石怪使用技能铁甲护身 生命增加100 防御增加50" << endl;
				mhealth += 100;
				mdefense += 50;
			}
			if (rand() % 3) {
				cout << "石怪使用技能神锋无影 攻击增加200 对方扣血200滴" << endl;
				hisH -= 200;
				mattack += 200;
			}
			Sleep(1000);
			int ran = rand() % 40 - 20;
			if (rand() % 10000 > hisSP) {
				if (attack + ran > hisD) {
					cout << "石怪发起进攻 " << Hname << "扣血" << mattack - hisD + ran << "滴 剩余" << hisH - (mattack - hisD + ran) << "滴" << endl;
					hisH -= mattack - hisD + ran;
				}
				else cout << "石怪发起进攻 " << Hname << "扣血0滴 剩余" << hisH << "滴" << endl; 
			}
			else {
				if (rand() % 2) cout << "石怪一脚踹了过去,但没有踢中" << endl; 
				else {
					cout << "石怪一脚踹了过去,但只擦着了腰" << endl;
					if ((mattack / 3) + ran > hisD) {
						cout << Hname << "扣血" << (mattack / 3) + ran - hisD << "滴 剩余" << hisH - ((mattack / 3) + ran - hisD) << "滴" << endl;
						hisH -= (mattack / 3) + ran - hisD;
					}
					else cout << Hname << "扣血0滴 剩余" << hisH << "滴" << endl; 
				}
			}
		}
		Sleep(1000);
		if (hisH <= 0) {
			if (hisS == 20 && rand() % 3 == 0) {
				cout << "对方发动技能:恢复如初 满血复活" << endl;
				hisH = ha; Sleep(1000);
			}
			else {
				cout << "对方死亡" << endl;
				return 0;
			}
		}
		if (hfaint <= 0) {
			if (hisS != 0) {
				if (rand() % 3 == 0) {
					if (hisS == 14) {
						cout << "对方发动技能:快快复苏  生命加200" << endl;
						hisH += 200;
					}
					if (hisS == 15) {
						cout << "对方发动技能:盔甲护身  生命加50 防御增加50" << endl;
						hisH += 50;
						hisD += 50;
					}
					if (hisS == 17) {
						cout << "对方发动技能神锋无影 攻击增加200 扣血200滴" << endl;
						health -= 200;
						hisA += 200;
					}
				}
				Sleep(1000);
			}
			int ran = rand() % 40 - 20;
			if (rand() % 10000 > mspeed) {
				if (hisA + ran > defense) {
					cout << Hname << "发起进攻 " << "石怪扣血" << hisA - defense + ran << "滴 剩余" << mhealth - (hisA - defense + ran) << "滴" << endl;
					mhealth -= hisA - defense + ran;
				}
				else cout << Hname << "发起进攻 " << "石怪扣血0滴 剩余" << mhealth << "滴" << endl; 
			}
			else {
				if (rand() % 2) cout << Hname << "一脚踹了过来,但没有踢中" << endl; 
				else {
					cout << "对方一脚踹了过来,但只擦着了石怪的腰" << endl;
					if ((hisA / 3) + ran > hisD) {
						cout << "石怪扣血" << (hisA / 3) + ran - defense << "滴 剩余" << mhealth - ((hisA / 3) + ran - defense) << "滴" << endl;
						mhealth -= ((hisA / 3) + ran - defense);
					}
					else cout << "石怪扣血0滴 剩余" << mhealth << "滴" << endl;
				}
			}
			Sleep(1000);
			if (mhealth <= 0) {
				cout << "石怪死亡" << endl;
				return hisH;
			}
		}
	}
	return 0;
}
int fight1(string Hname, int hisH, int hisA, int hisD, int hisS, int hisSP)
{
	int hfaint = 0, hhurt = 0, hbeat = 0;
	int mfaint = 0, mhurt = 0;
	dead = false;
	int ha = hisA;
	int his = hisA + hisD + hisH;
	while (1) {
		if (hfaint > 0) {
			if (rand() % 3 == 0) {
				cout << "对方使用技能:咒立停!停止了魔咒" << endl;
				hfaint = 1;
			}
			hfaint -= 1;
		}
		if (hbeat == 1) {
			if (rand() % 10 == 0) {
				cout << "对方一躲,躲过了你的石头" << endl;
				hbeat = 0;
			}
			else {
				cout << "对方躲闪不急,石头正好撞在他的鼻子上 扣血50滴" << endl;
				hisH -= 50;
			}
		}
		if (mfaint > 0) {
			if (Sl[6]) mfaint = 0; 
			else mfaint -= 1;
		}
		if (mhurt > 0) {
			if (Sl[6]) mhurt = 0; 
			else mhurt -= 1; 
			cout << "你的心像被一把刀刺穿了一样 扣血200滴" << endl;
			health -= 200;
		}
		if (mfaint <= 0) {
			if (rand() % 3 && Sl[0]) {
				cout << "你使用技能快快复苏 生命增加200" << endl;
				health += 200;
			}
			if (rand() % 3 && Sl[1]) {
				cout << "你使用技能铁甲护身 生命增加100 防御增加50" << endl;
				health += 100; defense += 50;
			}
			if (rand() % 3 && Sl[2]) {
				cout << "你使用技能昏昏倒地 " << Hname << "一回合之内不能攻击" << endl;
				hfaint += 1;
			}
			if (rand() % 3 && Sl[3]) {
				cout << "你使用技能神锋无影 攻击增加200 扣血200滴" << endl;
				hisH -= 200; attack += 200;
			}
			if (rand() % 3 && Sl[5]) {
				if (rand() % 10) {
					cout << "你使用技能统统石化 " << Hname << "二回合之内不能攻击" << endl;
					hfaint += 2;
				}
				else {
					cout << "你使用技能统统石化 " << Hname << "十回合之内不能攻击" << endl;
					hfaint += 10;
				}
			}
			if (rand() % 4 == 0 && Sl[7])
			{
				cout << "你使用技能召唤咒!召唤出石怪跟" << Hname << "战斗" << endl;
				hisH = monsterfight(Hname, hisH, hisA, hisD, hisS, hisSP);
				if (hisH < 1) return 0;
				if (Sl[0]) {
					cout << "在对方和石怪的战斗中,你已经恢复了2000生命" << endl;
					if (maxhealth < health + 2000) health = maxhealth; 
					else health += 2000; 
				}
			}
			if (rand() % 4 == 0 && Sl[8]) {
				cout << "你使用技能召唤咒!召唤出石怪跟" << Hname << "战斗" << endl;
			}
			if (rand() % 3 && Sl[9]) {
				cout << "你使用技能万弹齐发!变出几十块石头" << endl;
				hbeat = 1;
			}
			if (rand() % 3 && Sl[10]) {
				cout << "你使用技能钻心咒!对方将疼痛5回合" << endl;
				hhurt += 5;
			}
			if (rand() % 3 && Sl[11]) {
				cout << "魂魄出窍!你使用夺魂咒,企图让" << Hname << "自己攻击自己!" << endl;
				Sleep((rand() % 1000) + 1000);
				cout << Hname << "被你控制了,开始攻击自己" << endl;
				Sleep(700);
				int ran = rand() % 40 - 20;
				if (hisA + ran > hisD) {
					cout << "对方发起进攻 自己扣血" << hisH - hisD + ran << "滴 剩余" << hisH - (hisA - hisD + ran) << "滴" << endl;
					hisH -= hisA - hisD + ran;
				}
				else cout << "对方发起进攻 自己扣血0滴 剩余" << hisH << "滴" << endl; 
			}
			if (rand() % 2 && Sl[12]) {
				cout << "你使用技能阿瓦达索命 " << Hname << "扣血" << hisH - hisH / 4 << "滴" << endl;
				hisH /= 4;
			}
			Sleep(1000);
			int ran = rand() % 40 - 20;
			if (rand() % 10000 > hisSP) {
				if (attack + ran > hisD) {
					cout << "你发起进攻 " << Hname << "扣血" << attack - hisD + ran << "滴 剩余" << hisH - (attack - hisD + ran) << "滴" << endl;
					hisH -= attack - hisD + ran;
				}
				else cout << "你发起进攻 " << Hname << "扣血0滴 剩余" << hisH << "滴" << endl; 
			}
			else {
				if (rand() % 2) cout << "你一脚踹了过去,但没有踢中" << endl; 
				else {
					cout << "你一脚踹了过去,但只擦着了腰" << endl;
					if ((attack / 3) + ran > hisD) {
						cout << Hname << "扣血" << (attack / 3) + ran - hisD << "滴 剩余" << hisH - ((attack / 3) + ran - hisD) << "滴" << endl;
						hisH -= (attack / 3) + ran - hisD;
					}
					else cout << Hname << "扣血0滴 剩余" << hisH << "滴" << endl; 
				}
			}
		}
		Sleep(700);
		if (hhurt > 0) {
			hhurt -= 1;
			cout << "对方因中了你的钻心咒,正捂着心大叫呢 扣血200滴" << endl;
			hisH -= 200;
		}
		if (hisH <= 0) {
			if (hisS == 20 && rand() % 3 == 0) {
				cout << "对方发动技能:恢复如初 满血复活" << endl;
				hisH = ha;
				Sleep(1000);
			}
			else {
				cout << "对方死亡\n获得" << (his / 30) << "经验" << endl;
				experience += (his / 30);
				if (ane == 3) D_Of_C++;
				if (ane1 == 3) D_Of_C1++;
				return 0;
			}
		}
		if (hfaint <= 0) {
			if (rand() % 3 == 0) {
				if (hisS == 14) {
					cout << "对方发动技能:快快复苏  生命加200" << endl;
					hisH += 200;
				}
				if (hisS == 15) {
					cout << "对方发动技能:盔甲护身  生命加50 防御增加50" << endl;
					hisH += 50; hisD += 50;
				}
				if (hisS == 17) {
					cout << "对方发动技能神锋无影 攻击增加200 扣血200滴" << endl;
					health -= 200; hisA += 200;
				}
				Sleep(1000);
			}
			int ran = rand() % 40 - 20;
			if (rand() % 10000 > speed) {
				if (hisA + ran > defense) {
					cout << Hname << "发起进攻 " << "你扣血" << hisA - defense + ran << "滴 剩余" << health - (hisA - defense + ran) << "滴" << endl;
					health -= hisA - defense + ran;
				}
				else cout << Hname << "发起进攻 " << "你扣血0滴 剩余" << health << "滴" << endl; 
			}
			else {
				if (rand() % 2) cout << Hname << "一脚踹了过来,但没有踢中" << endl; 
				else {
					cout << "对方一脚踹了过来,但只擦着了你的腰" << endl;
					if ((hisA / 3) + ran > hisD) {
						cout << "你扣血" << (hisA / 3) + ran - defense << "滴 剩余" << health - ((hisA / 3) + ran - defense) << "滴" << endl;
						health -= ((hisA / 3) + ran - defense);
					}
					else cout << "你扣血0滴 剩余" << health << "滴" << endl; 
				}
			}
			Sleep(700);
			if (health <= 0) {
				if (Sl[6] && rand() % 2) {
					cout << "你发动技能:恢复如初 满血复活" << endl;
					health = maxhealth;
					Sleep(1000);
				}
				else {
					cout << "你死亡";
					health = 20;
					dead = true;
					return 0;
				}
			}
		}
	}
	return 0;
}
int fight2(string Hname, int hisH, int hisA, int hisD, int hisS, int hisSP)
{
	int hfaint = 0, hhurt = 0, hbeat = 0;
	int mfaint = 0, mhurt = 0;
	dead = false;
	int ha = hisA;
	int his = hisA + hisD + hisH;
	while (1) {
		if (hfaint > 0) {
			if (rand() % 3 == 0) {
				cout << "对方使用技能:咒立停!停止了魔咒";
				hfaint = 1;
			}
			hfaint -= 1;
		}
		if (hbeat == 1) {
			if (rand() % 10 == 0) {
				cout << "对方一躲,躲过了你的石头" << endl;
				hbeat = 0;
			}
			else {
				cout << "对方躲闪不急,石头正好撞在他的鼻子上 扣血50滴" << endl;
				hisH -= 50;
			}
		}
		if (mfaint > 0) {
			if (Sl[6]) mfaint = 0; 
			else mfaint -= 1; 
		}
		if (mhurt > 0) {
			if (Sl[6]) mhurt = 0;
			else mhurt -= 1;
			cout << "你的心像被一把刀刺穿了一样 扣血200滴" << endl;
			health -= 200;
		}
		if (mfaint <= 0) {
			if (rand() % 3 && Sl[0]) {
				cout << "你使用技能快快复苏 生命增加200" << endl;
				health += 200;
			}
			if (rand() % 3 && Sl[1]) {
				cout << "你使用技能铁甲护身 生命增加100 防御增加50" << endl;
				health += 100;
				defense += 50;
			}
			if (rand() % 3 && Sl[2]) {
				cout << "你使用技能昏昏倒地 " << Hname << "一回合之内不能攻击" << endl;
				hfaint += 1;
			}
			if (rand() % 3 && Sl[3]) {
				cout << "你使用技能神锋无影 攻击增加200 扣血200滴" << endl;
				hisH -= 200;
				attack += 200;
			}
			if (rand() % 3 && Sl[5]) {
				if (rand() % 10) {
					cout << "你使用技能统统石化 " << Hname << "二回合之内不能攻击" << endl;
					hfaint += 2;
				}
				else {
					cout << "你使用技能统统石化 " << Hname << "十回合之内不能攻击" << endl;
					hfaint += 10;
				}
			}
			if (rand() % 4 == 0 && Sl[7]) {
				cout << "你使用技能召唤咒!召唤出石怪跟" << Hname << "战斗" << endl;
				hisH = monsterfight(Hname, hisH, hisA, hisD, hisS, hisSP);
				if (hisH < 1) return 0;
				if (Sl[0]) {
					cout << "在对方和石怪的战斗中,你已经恢复了2000生命" << endl;
					if (maxhealth < health + 2000) health = maxhealth; 
					else health += 2000; 
				}
				Sleep(1000);
			}
			if (rand() % 4 == 0 && Sl[8]) {
				cout << "你使用技能召唤咒!召唤出石怪跟" << Hname << "战斗" << endl;
			}
			if (rand() % 3 && Sl[9]) {
				cout << "你使用技能万弹齐发!变出几十块石头" << endl;
				hbeat = 1;
			}
			if (rand() % 3 && Sl[10]) {
				cout << "你使用技能钻心咒!对方将疼痛5回合" << endl;
				hhurt += 5;
			}
			if (rand() % 3 && Sl[11]) {
				cout << "魂魄出窍!你使用夺魂咒,企图让" << Hname << "自己攻击自己!" << endl;
				Sleep((rand() % 1000) + 1000);
				cout << Hname << "被你控制了,开始攻击自己" << endl;
				Sleep(700);
				int ran = rand() % 40 - 20;
				if (hisA + ran > hisD) {
					cout << "对方发起进攻 自己扣血" << hisH - hisD + ran << "滴 剩余" << hisH - (hisA - hisD + ran) << "滴" << endl;
					hisH -= hisA - hisD + ran;
				}
				else cout << "对方发起进攻 自己扣血0滴 剩余" << hisH << "滴" << endl; 
			}
			if (rand() % 2 && Sl[12]) {
				cout << "你使用技能阿瓦达索命 " << Hname << "扣血" << hisH - hisH / 4 << "滴" << endl;
				hisH /= 4;
			}
			Sleep(1000);
			int ran = rand() % 40 - 20;
			if (rand() % 10000 > hisSP) {
				if (attack + ran > hisD) {
					cout << "你发起进攻 " << Hname << "扣血" << attack - hisD + ran << "滴 剩余" << hisH - (attack - hisD + ran) << "滴" << endl;
					hisH -= attack - hisD + ran;
				}
				else cout << "你发起进攻 " << Hname << "扣血0滴 剩余" << hisH << "滴" << endl; 
			}
			else {
				if (rand() % 2) cout << "你一脚踹了过去,但没有踢中" << endl; 
				else {
					cout << "你一脚踹了过去,但只擦着了腰" << endl;
					if ((attack / 3) + ran > hisD) {
						cout << Hname << "扣血" << (attack / 3) + ran - hisD << "滴 剩余" << hisH - ((attack / 3) + ran - hisD) << "滴" << endl;
						hisH -= (attack / 3) + ran - hisD;
					}
					else cout << Hname << "扣血0滴 剩余" << hisH << "滴" << endl;
				}
			}
		}
		Sleep(700);
		if (hhurt > 0) {
			hhurt -= 1;
			cout << "对方因中了你的钻心咒,正捂着心大叫呢 扣血200滴" << endl;
			hisH -= 200;
		}
		if (hisH <= 0) {
			if (hisS == 20 && rand() % 3 == 0) {
				cout << "对方发动技能:恢复如初 满血复活" << endl;
				hisH = ha;
				Sleep(1000);
			}
			else {
				cout << "对方死亡\n获得" << (his / 200) << "金币" << endl;
				money += (his / 200);
				if (ane == 3) D_Of_C++;
				if (ane1 == 3) D_Of_C1++;
				return 0;
			}
		}
		if (hfaint <= 0) {
			if (rand() % 3 == 0) {
				if (hisS == 14) {
					cout << "对方发动技能:快快复苏  生命加200" << endl;
					hisH += 200;
				}
				if (hisS == 15) {
					cout << "对方发动技能:盔甲护身  生命加50 防御增加50" << endl;
					hisH += 50; hisD += 50;
				}
				if (hisS == 17) {
					cout << "对方发动技能神锋无影 攻击增加200 扣血200滴" << endl;
					health -= 200; hisA += 200;
				}
				Sleep(1000);
			}
			int ran = rand() % 40 - 20;
			if (rand() % 10000 > speed) {
				if (hisA + ran > defense) {
					cout << Hname << "发起进攻 " << "你扣血" << hisA - defense + ran << "滴 剩余" << health - (hisA - defense + ran) << "滴" << endl;
					health -= hisA - defense + ran;
				}
				else cout << Hname << "发起进攻 " << "你扣血0滴 剩余" << health << "滴" << endl; 
			}
			else {
				if (rand() % 2) cout << Hname << "一脚踹了过来,但没有踢中" << endl; 
				else {
					cout << "对方一脚踹了过来,但只擦着了你的腰" << endl;
					if ((hisA / 3) + ran > hisD) {
						cout << "你扣血" << (hisA / 3) + ran - defense << "滴 剩余" << health - ((hisA / 3) + ran - defense) << "滴" << endl;
						health -= ((hisA / 3) + ran - defense);
					}
					else cout << "你扣血0滴 剩余" << health << "滴" << endl;
				}
			}
			Sleep(700);
			if (health <= 0) {
				if (Sl[6] && rand() % 2) {
					cout << "你发动技能:恢复如初 满血复活" << endl;
					health = maxhealth;
					Sleep(1000);
				}
				else {
					cout << "你死亡";
					health = 20;
					dead = true;
					return 0;
				}
			}
		}
	}
	return 0;
}
int fight(string Hname, int hisH, int hisA, int hisD, int hisS, int hisSP)
{
	int hfaint = 0, hhurt = 0, hbeat = 0;
	int mfaint = 0, mhurt = 0;
	dead = false;
	int ha = hisA;
	int his = hisA + hisD + hisH;
	while (1)
	{
		if (hfaint > 0) {
			if (rand() % 3 == 0) {
				cout << "对方使用技能:咒立停!停止了魔咒" << endl;
				hfaint = 0;
			}
			else hfaint -= 1;
		}
		if (hbeat == 1) {
			if (rand() % 10 == 0) {
				cout << "对方一躲,躲过了你的石头" << endl;
				hbeat = 0;
			}
			else {
				cout << "对方躲闪不急,石头正好撞在他的鼻子上 扣血50滴" << endl;
				hisH -= 50;
			}
		}
		if (mfaint > 0) {
			if (Sl[6]) mfaint = 0; 
			else mfaint -= 1; 
		}
		if (mhurt > 0) {
			if (Sl[6]) mhurt = 0; 
			else mhurt -= 1;
			cout << "你的心像被一把刀刺穿了一样 扣血200滴" << endl;
			health -= 200;
		}
		if (mfaint <= 0) {
			if (rand() % 3 && Sl[0]) {
				cout << "你使用技能快快复苏 生命增加200" << endl;
				health += 200;
			}
			if (rand() % 3 && Sl[1]) {
				cout << "你使用技能铁甲护身 生命增加100 防御增加50" << endl;
				health += 100;
				defense += 50;
			}
			if (rand() % 3 && Sl[2]) {
				cout << "你使用技能昏昏倒地 " << Hname << "一回合之内不能攻击" << endl;
				hfaint += 1;
			}
			if (rand() % 3 && Sl[3]) {
				cout << "你使用技能神锋无影 攻击增加200 扣血200滴" << endl;
				hisH -= 200; attack += 200;
			}
			if (rand() % 3 && Sl[5]) {
				if (rand() % 10) {
					cout << "你使用技能统统石化 " << Hname << "二回合之内不能攻击" << endl;
					hfain
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值