这次更新了后台!版本1.4,大家多多支持!

#include <bits/stdc++.h>
#include <windows.h>
#include <time.h>

using namespace std;

long long zhujuegongji=5,zhujueshengming=5,sxsm=5;//主角设置
int baoji=0;//攻击
long long sjsjb=0;//金币
int ntgs=0;//怪物
int htz=0;//商店进阶
int hst=0,pldhyf=0,cqdhkz=0,hx=0,hr=0;//商店
int htmmpd=0,htmmcs=5;//后台密码判断

void color(int a);
void ks();
void zd();
void gwck();
void kszd();
void huosheng();
void sd();
void zt();
void ht();
void gotoxy(short x, short y);//移动光标
void sd2();
void kg();

void gotoxy(short x, short y)
{
	COORD position = { x, y };
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut, position);
}
void color (int a) {//颜色函数
	SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), a);
}
void ks()
{
	cout<<"===========================================    我的钱包:"<<sjsjb<<"\n";
    cout<<"|1.战斗  2.状态  3.背包  4.商店  5.后台   |              \n";
    cout<<"===========================================              \n";
    cout<<"输入>>>";
    string a1and4xz;
    cin>>a1and4xz;
    if(a1and4xz!="1"&&a1and4xz!="2"&&a1and4xz!="3"&&a1and4xz!="4"&&a1and4xz!="5")
    {
	    cout<<"别乱输!\n";
	    Sleep(700);
	    system("cls");
	    ks();
    }
    if(a1and4xz=="1")
    {
    	system("cls");
        zd();
	}
	if(a1and4xz=="2")
	{
		system("cls");
		zt();
	}
	if(a1and4xz=="4")
	{
		system("cls");
		sd();
	}
	if(a1and4xz=="5")
	{
		system("cls");
		ht();
	}
}
void zd()
{
	color(60);
	cout<<"====================================\n";
	cout<<"             战斗                   \n";
	cout<<"====================================\n";
	cout<<"【1.怪物查看   2.开始战斗    3.返回】\n";
	string zdxz1and2;
	cin>>zdxz1and2;
	if(zdxz1and2=="1")
	{
	    system("cls");
		gwck();	
	}
	if(zdxz1and2=="2")
	{
		system("cls");
		kszd();
	}
	if(zdxz1and2=="3")
	{
		system("cls");
		Sleep(700);
		ks();
	}
}
void gwck()
{
	color(30);
	cout<<"1.退出                   2.前往战斗                                     \n";
	cout<<"------------------------------------------------------------------------\n";
	cout<<"【1级怪物】牛头怪兽 Ta拥有较厚的血量,但是攻击却很低.|属性:攻击1,生命10|\n";
	if(ntgs!=1)
	cout<<"【2级怪物】              请先打败一级怪物才能查看2级怪物!\n";
	if(ntgs==1)
	cout<<"【2级怪物】格伦巨石 Ta是个没有感情的石头,伤害较高.|属性:攻击6,生命12   \n";
	string gwcktc;
	cin>>gwcktc;
	if(gwcktc=="1")
	{
		color(60);
		Sleep(700);
		system("cls");
	    zd();
    }
    if(gwcktc=="2")
	{
		color(60);
		Sleep(700);
		system("cls");
	    kszd();
    }
	if(gwcktc!="2"&&gwcktc!="1")
	{
		cout<<"别乱输!\n";
	    Sleep(700);
	    system("cls");
	    color(30);
	    gwck();
	}
	if(gwcktc!="1" && gwcktc!="2")
    {
	    cout<<"别乱输!\n";
	    Sleep(700);
	    system("cls");
	    gwck();
    }
}
void kszd()
{
	cout<<"输入怪物等级[1到15级]\n";
	cout<<">>>";
	string gwdjzd;
	cin>>gwdjzd;
	string gwmz;
	int gwsm=0,gwgj=0;
	if(gwdjzd=="1")
	{
	    gwmz="牛头怪兽";
	    gwsm+=10;
		gwgj+=1;
    }
    if(gwdjzd=="2")
    {
    	gwmz="格伦巨石";
		gwsm+=12;
		gwgj+=6;
	}
	for(int i=1;i<=900;i++)
	{
		if(gwsm==0||gwsm<0)
		{
			if(gwdjzd=="1")ntgs++;
			Sleep(2000);
			system("cls");
		    huosheng();
		}
		if(sxsm==0||sxsm<0)
		{
			cout<<"你输了!你可以尝试升级装备和恢复血量!\n";
			Sleep(2000);
			system("cls");
			zd();
		}
	    cout<<"_____________________________________________________\n";
	    cout<<"*&&PK开始!你与"<<gwmz<<"战斗,现在是第"<<i<<"回合&&*\n";
    	cout<<"-----------------------------------------------------\n";
	    cout<<"怪物攻击力:"<<gwgj<<"    你的攻击力:"<<zhujuegongji<<endl;
	    cout<<"怪物生命:"<<gwsm<<"       你的生命:"<<sxsm<<endl;
	    cout<<"=====================================================\n";
	    cout<<"1.战斗                                         2.逃跑\n";
	    cout<<"输入>>>";
		string zhandouandtaopao;
		cin>>zhandouandtaopao;
		if(zhandouandtaopao=="1")
		{
			 srand((int)time(0));
            for (int i=0; i<2; i++)
            {
                baoji+=rand()%3;
            }
            if(baoji>=6)
            {
            	cout<<"\n\n\n\t怪物使用了重击!砰的一声巨响你被打掉了"<<baoji<<"点血\n";
			    sxsm-=baoji;
		    }
			gwsm-=zhujuegongji;
			sxsm-=gwgj;
		    cout<<"\n\n\n\n你们打的不可开交,你们越打越累,就暂停休息了...\n";
		    cout<<"其中,你的生命剩下:"<<sxsm<<"点"<<endl;
		    cout<<"怪物生命剩下:"<<gwsm<<"点"<<endl;
		}
		if(zhandouandtaopao=="2")
		{
			Sleep(700);
			system("cls");
			zd();
		}	
    }
}
void huosheng()
{
	if(sxsm==0||sxsm<0)
	{
		cout<<"你输了!你可以尝试升级装备和恢复血量!\n";
		Sleep(2000);
		system("cls");
		zd();
	}
	srand((int)time(0));
    for (int i=0; i<2; i++)
    {
        sjsjb+=rand()%50;
    }
	cout<<"恭喜你获胜了!";
	cout<<"此次你的生命还有"<<sxsm;
	cout<<"点,你一共有"<<sjsjb<<"金币!\n";
	cout<<"===========================================================\n";
	cout<<"1.返回                                     2.继续战斗\n";
	string huoshengsr;
	cin>>huoshengsr;
	if(huoshengsr=="1")
	{
		Sleep(700);
		system("cls");
		zd();
	}
	if(huoshengsr=="2")
	{
		Sleep(700);
		system("cls");
		kszd();
	}
}
void zt()
{
	cout<<"==================================\n";
	cout<<"211.退出\n";
	cout<<"==================================\n";
	cout<<"我的状态:\n";
	cout<<"总生命:"<<zhujueshengming<<"\n";
	cout<<"现在拥有的生命:"<<sxsm<<"\n";
	cout<<"攻击:"<<zhujuegongji<<"\n";
	cout<<"==================================\n";
	string zttc;
	cin>>zttc;
	if(zttc=="211")
	{
		Sleep(700);
		system("cls");
		ks();
	}
}
void sd()
{
	string mdx;
	cout<<"============================================================\n";
	cout<<"   黑市商店\n";
	cout<<"你好啊,欢迎来到商店!                  211.退出\n";
	cout<<"你需要些什么呢?                        我的钱包:"<<sjsjb<<"元\n";
	cout<<"============================================================\n";
	if(hst==0)
	cout<<"1.黑手套        *39元 |生命加2点\n";
	if(hst==1)
	cout<<"1.黑手套        已卖光\n";
	if(pldhyf==0)
	cout<<"2.破了的黑衣服  *109元|生命加10点\n";
	if(pldhyf==1)
	cout<<"2.破了的黑衣服  已卖光\n";
	if(cqdhkz==0)
	cout<<"3.残缺的黑裤子  *90元 |生命加9点\n";
	if(cqdhkz==1)
	cout<<"3.残缺的黑裤子  已卖光\n";
	if(hx==0)
	cout<<"4.黑鞋          *50元 |生命加5点\n";
	if(hx==1)
	cout<<"4.黑鞋          已卖光\n";
	if(hr==0)
	cout<<"5.黑刃          *200元|攻击加20\n";
	if(hr==1)
	cout<<"5.黑刃          已卖光\n";
	cout<<"6.生命药水      *10元 |生命恢复加满\n";
	if(htz!=5)
	{
	    cout<<"============================================================\n";
	    cout<<"                请买完黑的套装才能买下一套                  \n";
	    cout<<"============================================================\n";
	}
	if(htz==5)
	{
		cout<<"============================================================\n";
	    cout<<"                翻到下一页请输入“翻页 ”                   \n";
	    cout<<"============================================================\n";
	}
	cout<<"输入>>>";
	cin>>mdx;
	if(mdx=="1")
	{
		if(hst==1)
		{
			cout<<"该商品已卖光!请购买别的商品!\n";
			Sleep(1000);
			system("cls");
			sd();
		}
		if(sjsjb>=39)
		{
			sjsjb-=39,htz++,hst++,zhujueshengming+=2;
		    cout<<"\n成功够买黑手套!您还剩下"<<sjsjb<<"元,欢迎再买!\n";
		    Sleep(1000);
		    system("cls");
		    sd();
		}
		else
		{
			cout<<"您钱不够,下次再来吧!\n";
			Sleep(2000);system("cls");
			ks();
		}
	}
	if(mdx=="2")
	{
		if(pldhyf==1)
		{
			cout<<"该商品已卖光!请购买别的商品!\n";
			Sleep(1000);
			system("cls");
			sd();
		}
		if(sjsjb>=109)
		{
			sjsjb-=109,htz++,pldhyf++,zhujueshengming+=10;
		    cout<<"\n成功够买破了的黑衣服!您还剩下"<<sjsjb<<"元,欢迎再买!\n";
		    Sleep(1000);
		    system("cls");
		    sd();
		}
		else
		{
			cout<<"您钱不够,下次再来吧!\n";
			Sleep(2000);system("cls");
			ks();
		}
	}
	if(mdx=="3")
	{
		if(cqdhkz==1)
		{
			cout<<"该商品已卖光!请购买别的商品!\n";
			Sleep(1000);
			system("cls");
			sd();
		}
		if(sjsjb>=90)
		{
			sjsjb-=90,htz++,cqdhkz++,zhujueshengming+=9;
		    cout<<"\n成功够买残缺的黑裤子!您还剩下"<<sjsjb<<"元,欢迎再买!\n";
		    Sleep(1000);
		    system("cls");
		    sd();
		}
		else
		{
			cout<<"您钱不够,下次再来吧!\n";
			Sleep(2000);system("cls");
			ks();
		}
	}
	if(mdx=="4")
	{
		if(hx==1)
		{
			cout<<"该商品已卖光!请购买别的商品!\n";
			Sleep(1000);
			system("cls");
			sd();
		}
		if(sjsjb>=50)
		{
			sjsjb-=50,htz++,hx++,zhujueshengming+=5;
		    cout<<"\n成功够买黑鞋!您还剩下"<<sjsjb<<"元,欢迎再买!\n";
		    Sleep(1000);
		    system("cls");
		    sd();
		}
		else
		{
			cout<<"您钱不够,下次再来吧!\n";
			Sleep(2000);system("cls");
			ks();
		}
	}
	if(mdx=="5")
	{
		if(hr==1)
		{
			cout<<"该商品已卖光!请购买别的商品!\n";
			Sleep(1000);
			system("cls");
			sd();
		}
		if(sjsjb>=200)
		{
			sjsjb-=200,htz++,hr++,zhujuegongji+=20;
		    cout<<"\n成功够买黑刃!您还剩下"<<sjsjb<<"元,欢迎再买!\n";
		    Sleep(1000);
		    system("cls");
		    sd();
		}
		else
		{
			cout<<"您钱不够,下次再来吧!\n";
			Sleep(2000);system("cls");
			ks();
		}
	}
	if(mdx=="6")
	{
		if(sjsjb>=10)
		{
			sjsjb-=10;
			sxsm=(zhujueshengming-sxsm)+sxsm;
		    cout<<"\n成功够买生命药水!您还剩下"<<sjsjb<<"元,欢迎再买!\n";
		    Sleep(1000);
		    system("cls");
		    sd();
		}
		else
		{
			cout<<"您钱不够,下次再来吧!\n";
			Sleep(2000);system("cls");
			ks();
		}
	}
	if(mdx=="翻页")
	{
		if(htz!=5)
		{
			cout<<"您没凑齐黑套装,请您凑齐!\n";
		}
		if(htz==5)
		{
			Sleep(1000);
			system("cls");
			sd2();
		}
	}
	if(mdx=="211")
	{
		Sleep(700);
		system("cls");
		ks();
	}
}
void sd2()
{
	cout<<"============================================================\n";
	cout<<"   黑市商店[初级]\n";
	cout<<"你好啊,欢迎来到商店!                  211.退出\n";
	cout<<"你需要些什么呢?                        我的钱包:"<<sjsjb<<"元\n";
	cout<<"============================================================\n";
	
}
void ht()
{
	if(htmmcs!=5&&htmmcs!=4&&htmmcs!=3&&htmmcs!=2&&htmmcs!=1)
	{
		cout<<"您的次数用光!\n";
		Sleep(1000);
		system("cls");
		ks();
	}
	cout<<"=====*【后台管理 简称开挂 测试Bug】*=================================\n";
	cout<<"请输入管理者密码和管理者邮箱地址!      想退出就在管理密码那输入211\n";
	cout<<"=====*【想要后台密码就问陈诺】*======================================\n";
	gotoxy(0,3);
	cout<<"管理密码:";
	gotoxy(0,4);
	cout<<"\n邮箱地址:               @QQ.com";
	string htmm,htmm2;
	gotoxy(10,3);
	cin>>htmm;
	if(htmm=="211")
	{
		Sleep(700);
		system("cls");
		ks();
	}
	if(htmm=="cn886CN")
	{
		htmmpd++;
	}
	gotoxy(10,5);
	cin>>htmm2;
	if(htmm2=="2871213217")
	{
		htmmpd++;
	}
	if(htmmpd==2)
	{
	     cout<<"输入正确!\n";
	     Sleep(700);
	     system("cls");
	     kg();
    }
	if(htmmcs!=5&&htmmcs!=4&&htmmcs!=3&&htmmcs!=2&&htmmcs!=1)
    {
    	Sleep(700);
    	system("cls");
    	gotoxy(30,30);
    	cout<<"次数用光!\n";
    	Sleep(1000);
    	system("cls");
    	ks();
    	
	}
	if(htmmpd!=2)
	{
		htmmcs-=1;
	    cout<<"输入错误!请检查!您还剩"<<htmmcs<<"次输入机会\n";
	    Sleep(1000);
	    system("cls");
	    ht();
    }
	Sleep(2000);
	system("cls");
	
}
void kg()
{
	cout<<"欢迎进入后台!\n";
	cout<<"后台服务:\n";
	cout<<"=======================\n";
	cout<<"1.金币加9999\n";
	cout<<"2.血量加9999\n";
	cout<<"3.现有血量加9999\n";
	cout<<"4.攻击加9999\n";
	cout<<"211.退出\n";
	cout<<"=======================\n";
	cout<<"输入>>>";
	string htsr;
	cin>>htsr;
	if(htsr=="1")
	{
		cout<<"成功获得效果 *金币加9999\n";
		sjsjb+=9999;
		Sleep(1000);
		system("cls");
		kg();
	}
	if(htsr=="2")
	{
		cout<<"成功获得效果 *血量加9999\n";
		zhujueshengming+=9999;
		Sleep(1000);
		system("cls");
		kg();
	}
	if(htsr=="3")
	{
		cout<<"成功获得效果 *现有血量加9999\n";
		sxsm+=9999;
		Sleep(1000);
		system("cls");
		kg();
	}
	if(htsr=="4")
	{
		cout<<"成功获得效果 *攻击加9999\n";
		zhujuegongji+=9999;
		Sleep(1000);
		system("cls");
		kg();
	}
	if(htsr=="211")
	{
		cout<<"成功退出\n";
		Sleep(1000);
		system("cls");
		ht();
	}
}
int main()
{
	color(8);
	cout<<"作者:陈诺\n\n\n";
	color(30);
	cout<<"---->&勇者打恶龙(测试版1.4)&<------\n\n\n";
	color(15);
	cout<<"    >&控制:按数字和回车    &<\n";
	cout<<"    >&数字是选择,回车是确定&<\n\n\n";
	color(30);
	cout<<"---->&按回车开始游戏!&<------------\n\n";
	color(15);
	int ksyxjm=cin.get();
	color(60);
	system("cls");
	ks();
	return 0;
}