#include<bits/stdc++.h>
#include<ctime>
#include<cstdlib>
#include <windows.h>
#include <conio.h>
using namespace std;
int generateRandomNumber(int min, int max) {
srand(time(0));
int random_number = rand() % (max - min + 1) + min;
return random_number;
}
struct sb{
string a;
char b;
int heart=100;
int hp=10000;
int sf=0;
};
bool ji(int a){
return a%2==0;
}
bool w(char a,char b){
return a=='a'&&b=='a';
}
int main(){
MessageBox (NULL, "欢迎来到巫师对决!", "温馨提示", MB_OK);
sb p1,p2;
cout<<"请输入玩家p1姓名:";
getline(cin,p1.a);
cout<<"请输入玩家p2姓名:";
getline(cin,p2.a);
cout<<"**********************"<<endl;
cout<<"***老顾客活动来袭!***"<<endl;
cout<<"*首充998可成为青铜VIP*"<<endl;
cout<<"首充1998可成为黄金VIP*"<<endl;
cout<<"首充999998可成为至尊VIP"<<endl;
cout<<"**超级划算!!!!!**"<<endl;
cout<<"******巫师对决战******"<<endl;
cout<<"*按c开始,按其他键退出*"<<endl;
cout<<"**********************"<<endl;
char choose;
cin>>choose;
if(choose=='c'){
cout<<"巫师大战即将开始!!!"<<endl;
}else{
cout<<"真的要退出么!(y是,n不是)"<<endl;
int cho;
cin>>cho;
if(cho=='y'){
cout<<"欢迎下次再玩!!!";
return 0;
}else if(cho=='n'){
cout<<"巫师大战即将开始!!!"<<endl;
}else{
cout<<"错误!!"<<endl;
cout<<"巫师大战即将开始!!!"<<endl;
}
}
int shu=1;
while(p1.heart>0&&p2.heart>0){
cout<<"第"<<shu<<"回合"<<endl;
if(ji(shu)==true){
cout<<p2.a<<"的回合"<<endl;
if(p2.hp!=0){
cout<<"a攻击,d防御,n闪躲:";
cin>>p2.b;
if(p2.b=='a'){
p2.hp=p2.hp-635;
}else if(p2.b=='d'){
p2.hp=p2.hp-650;
}else{
p2.hp=p2.hp-630;
}
}else{
cout<<"经验为0跳过"<<endl;
p2.hp=p2.hp+100;
}
}else{
cout<<p1.a<<"的回合"<<endl;
if(p1.hp!=0){
cout<<"a攻击,d防御,n闪躲:";
cin>>p1.b;
if(p1.b=='a'){
p1.hp=p1.hp-635;
}else if(p1.b=='d'){
p1.hp=p1.hp-650;
}else{
p1.hp=p1.hp-630;
}
}else{
cout<<"经验为0跳过"<<endl;
p1.hp=p1.hp+100;
}
}
cout<<"///"<<endl;
if(shu>=2){
if(ji(shu)==true){
if(w(p1.b,p2.b)==true){
if(p1.sf<=4){
cout<<"普攻-10"<<endl;
p2.heart=p2.heart-10;
p1.sf++;
}else{
int random_number=generateRandomNumber(10,100);
cout<<"暴击-"<<random_number<<endl;
p2.heart=p2.heart-random_number;
p1.sf=0;
}
}else{
if(p2.b=='d'){
cout<<"刮痧-0"<<endl;
p1.sf=0;
}else if(p2.b=='n'){
if(p2.hp>=p1.hp){
cout<<"刮痧-0"<<endl;
}else{
int random_number1=generateRandomNumber(1,10);
cout<<"削弱-"<<-random_number1+10<<endl;
p2.heart=p2.heart-10+random_number1;
}
p1.sf=0;
}
}
cout<<p2.a<<"的血量:"<<p2.heart<<endl;
cout<<p2.a<<"的经验:"<<p2.hp<<endl;
cout<<"///"<<endl;
}else{
if(w(p2.b,p1.b)==true){
if(p2.sf<=4){
cout<<"普攻-10"<<endl;
p1.heart=p1.heart-10;
p2.sf++;
}else{
int random_number4=generateRandomNumber(10,100);
cout<<"暴击-"<<random_number4<<endl;
p1.heart=p1.heart-random_number4;
p2.sf=0;
}
}else{
if(p1.b=='d'){
cout<<"刮痧-0"<<endl;
p2.sf=0;
}else if(p1.b=='n'){
if(p1.hp>=p2.hp){
cout<<"刮痧-0"<<endl;
}else{
int random_number2=generateRandomNumber(1,10);
cout<<"削弱-"<<-random_number2+10<<endl;
p1.heart=p1.heart-10+random_number2;
}
p2.sf=0;
}
}
cout<<p1.a<<"的血量:"<<p1.heart<<endl;
cout<<p1.a<<"的经验:"<<p1.hp<<endl;
cout<<"///"<<endl;
}
}
shu++;
}
if(p1.heart==0){
cout<<p2.a<<"赢"<<endl;
}else{
cout<<p1.a<<"赢"<<endl;
}
MessageBox (NULL, "欢迎下次再玩!", "温馨提示", MB_OK);
return 0;
}
02-17