#include <iostream>
using namespace std;
#include <windows.h>
#include <string>
SYSTEMTIME time;
class Game
{
public:
Game();
BOOL choice(); //选择开始
BOOL zhandou(); //战斗
BOOL guaishang();
BOOL tiaozhanboss(int);
BOOL zhandoucaidan();
BOOL qiut;
BOOL shang();
int dengji;
int m,s,f;
int guanka;
void kaishi();//开始
void setjiaose(); //创建角色
void jiaoseshuxing();//角色属性
void setjindutiao(int);//进度条
void shopping();
string guainame;//="小哥布林";
string xiaoguainame[10];
string bsname;
string bossname[10];
private:
char ch1;
char shop;
char wq,fj,yp;
char name[20];//角色名字
int tili,i,j;
int bosstili,bosspower;
int manbosstili,yaohoutili,yaopinshuliang;
int power,fangyu,guaitili,guaipower,wuqipower,wuqitili,fangjutili,fangjupower,fangjufangyu;
int bosspower1,bosstili1,bosspower2,bosstili2,bosspower3,bosstili3;
int mantili,gold,jingyan,manguaitili;
string fangju;
string wuqi;
string y;
string x;
string yaopin;
};
BOOL Game::zhandou()
{
setjindutiao(50);
cout<<"\n\n\n\n\t\t\t";
cout<<guainame<<": 你是谁?想过去留下买路钱!\n";
cin>>ch1;
setjindutiao(1);
cout<<"\n\n\n\n\t\t\t";
cout<<name<<": 本人叫"<<name<<",你不要逼我~!\n";
cin>>ch1;
setjindutiao(1);
cout<<"\n\n\n\n\t\t\t";
cout<<guainame<<": "<<name<<",没听说过!这么嚣张的!接大爷几招\n";
cin>>ch1;
setjindutiao(1);
cout<<"\n\n\n\n\t\t\t";
cout<<name<<": 那得罪了\n";
cin>>ch1;
setjindutiao(50);
cout<<"\n\n\t\t“进入战斗”\n";
cout<<guainame<<"\n\t体力:"<<guaitili;
cout<<"\t攻击"<<guaipower<<"\n"<<endl;
cout<<name<<"\n\t体力:"<<tili;
cout<<"\t攻击"<<power<<endl;
cout<<"\n\t\t“战斗开始”\n\n";
cin>>ch1;
mantili=tili;
manguaitili=guaitili;
yaohoutili=tili;
while(manguaitili>0)
{
setjindutiao(1);
cout<<"\n\n\n";
cout<<guainame<<"一扳砖向"<<name<<"拍去\n";//怪进攻
cout<<name<<"想躲避可惜慢了点,中了这招!"<<"\t体力减:"<<guaipower<<endl; //被怪击中
mantili=mantili-guaipower;
if(false==shang())return false; //退出
cout<<guainame<<" 体力: "<<manguaitili<<"\n";
if(!zhandoucaidan())return true; //返回菜单
setjindutiao(1);
cout<<"\n\n\n\n";
if("空"!=wuqi)
{
cout<<name<<"拔出"<<wuqi<<"向"<<guainame<<"刺去\n";//人物进攻
cin>>ch1;
cout<<wuqi<<"果然威力不凡!正中"<<guainame<<"要害\t体力减:"<<power<<endl; //怪被击中
} else cout<<name<<"空手赤拳!使了一招还我漂漂拳!\n等"<<guainame<<"反应过来!拳头已经正中要害\n";
manguaitili=manguaitili-power;
if(false==shang())return false;
if(true==guaishang())
cout<<guainame<<" 体力: "<<manguaitili<<"\n";
cin>>ch1;
}
return true;
}
Game::Game():qiut(true),wuqipower(0),wuqitili(0),fangjutili(0),fangjupower(0),fangjufangyu(0)
{
power=20;tili=40;
dengji=0;
fangyu=0;
jingyan=0;
gold=0;
guanka=0;
yaopinshuliang=0;
guaipower=2;guaitili=20;
bosspower1=30;bosstili1=500;
bosspower2=60;bosstili2=120;
bosspower3=100;bosstili3=3000;
j=1;
wuqi="空";fangju="空";
yaopin="空";
xiaoguainame[1]="血色勇士";
xiaoguainame[2]="血色预言者";
xiaoguainame[3]="血色狗男女";
bossname[1]="克尔苏加德";
bossname[2]="伊利丹";
bossname[3]="基尔加丹";
}
void main()
{
begin:
Game game;
game.kaishi();
if(!game.choice())goto begin;
char ch,ch2;
int M;
while(game.qiut)
{
game.setjindutiao(50);
cout<<"\n\n\n\t\t\t1.去闯关\n\n\t\t\t2.挑战剧情boss\n\n\t\t\t3.人物属性和物品\n\n\t\t\t4.商店购物\n\n\t\t\t5.返回游戏目录\n请选择";
cin>>ch;
switch(ch)
{
case '1':/*闯关*/
if(game.dengji==0&&game.guanka==0||(game.dengji%5==0&&game.dengji>=5))
{
game.setjindutiao(50);
game.guanka+=1;
cout<<"\n\n\n\n\t\t\t《第"<<game.guanka<<"关》\n\n";
cin>>ch;
}
if(game.guanka==1)
{
game.guainame=game.xiaoguainame[1];
if(game.zhandou())break;
else game.qiut=false; goto begin;
}else if(game.guanka==2)
{
game.guainame=game.xiaoguainame[2];
if(game.zhandou())break;
else game.qiut=false; goto begin;
}else if(game.guanka==3)
{
game.guainame=game.xiaoguainame[3];
if(game.zhandou())break;
else game.qiut=false; goto begin;
}else
game.guainame="小强";
if(game.zhandou())break;
else game.qiut=false;
goto begin;
case '2':
game.setjindutiao(1);
for( M=1;M<4;M++)
{
cout<<"\n\n\n\n\t\t\t";
cout<<M<<"."<<game.bossname[M]<<"\n";
}
cout<<"你想挑战谁:";
cin>>ch2;
if('1'==ch2)
{
if(game.dengji>=15)
{
cout<<"挑战"<<game.bossname[1]<<endl;
if(!game.tiaozhanboss(1))
{
game.qiut=false;
goto begin;
}
}
else {
cout<<"\t\t\t你目前没有这个能力!等级到15级再来挑战\n";
cin>>ch2;
}
}else if('2'==ch2)
{
if(game.dengji>=25)
{
cout<<"挑战"<<game.bossname[2]<<endl;
if(!game.tiaozhanboss(2))
{
game.qiut=false;
goto begin;
}
}
else {
cout<<"\t\t\t你目前没有这个能力!等级到25级再来挑战\n";
cin>>ch2;
}
}else if('3'==ch2)
{
if(game.dengji>=35)
{
cout<<"挑战"<<game.bossname[3]<<endl;
if(!game.tiaozhanboss(3))
{
game.qiut=false;
goto begin;
}
}
else {
cout<<"\t\t\t你目前没有这个能力!等级到35级再来挑战\n";
cin>>ch2;
}
}
break;
case '3':
game.jiaoseshuxing();
break;
case '4':
game.shopping();
break;
case '5':
char q;
cout<<"确定退出?Y/N\n";
cin>>q;
if('y'==q||'Y'==q)
{
game.qiut=false;
goto begin;
}
else
break;
default:
cout<<"貌似你没选对\n";
break;
}
}
}
void Game::kaishi()
{
setjindutiao(50);
cout<<"\n\t\t欢迎进入\n\n"<<"\t\t魔兽\n"<<"\t\t\t与\n\t\t\t\t勇士\n";
cout<<"开始游戏\n";
cout<<"\t\t\t1.创建角色\n\n\t\t\t2.查看游戏介绍\n\n\t\t\t3.退出游戏.\n请选择:";
cin>>x;
}
BOOL Game::choice()
{
if("1"==x)
{
setjiaose();
}
else if("2"==x)
{
setjindutiao(50);
cout<<"\n\n<<游戏介绍和说明>>:\n@@@@@@@@@@@@@本人完全是兴趣爱好!才学C++ 1个月多几天,只为给像我这种级别的人看!高手飘过! 功能还在添加中!第一次写这个!走了很多弯路!有很多地方可以改的更加简单!但为了纪念第一次常识!故不作修改!!\n\n\t\t\t\t\t小屋子\n";
cin>>ch1;
}else if("3"==x)
{
qiut=false;
}else{
cout<<"\t*输入错误*\n";
return false;
}
}
void Game::setjiaose()
{
setjindutiao(50);
cout<<"\n\n\n\n\n\t\t角色名称:";
cin>>name;
cout<<"人物职业:(等待加入功能)\n";
}
void Game::jiaoseshuxing()
{
setjindutiao(50);
cout<<"\n人物: "<<name<<"\n等级: "<<dengji<<endl;
cout<<"攻击: "<<power<<"\t"<<"\n体力: "<<tili<<"\n防御: "<<fangyu<<endl;
cout<<"武器: "<<wuqi<<"\t"<<"\n防具: "<<fangju<<"\n药品: "<<yaopin<<"*"<<yaopinshuliang<<endl;
cout<<"金币: "<<gold<<"两"<<"\t经验: "<<jingyan<<endl;
cin>>ch1;
}
void Game::setjindutiao(int p)
{
system("cls");
GetLocalTime(&time);
m=time.wSecond;
s=time.wHour;
f=time.wMinute;
SetConsoleTitle("小屋子制作"); //标题
COORD pos; //定义一个位置变量
pos.X=2; //注意X要大写
pos.Y=1; //同上Y要大写
cout<<"╔═════════════════════╗"<<endl;
cout<<"║
║"<<endl;
cout<<"╚═════════════════════╝"<<endl;
cout<<"\t服务器时间:"<<s<<":"<<f;
cout<<"\t魔兽与勇士\n";
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); //设置光标在(2,1)位置
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12|1);
for(int i=0;i<21;i++)
{
Sleep(p);
cout<<"█";
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),3);
//字体色为白
cout<<endl;
cout<<endl;
}