欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C++写的简易的控制台游戏

程序员文章站 2022-04-14 21:55:20
无意中找到大一用C++写的文字游戏,哈哈 命名不规范,很多地方都不完善,但是这是我入程序员这一行的第一个作品! ......

无意中找到大一用c++写的文字游戏,哈哈

命名不规范,很多地方都不完善,但是这是我入程序员这一行的第一个作品!

 

#include "stdafx.h"
#include<iostream>
#include <string>
#include<vector>
#include<windows.h>
#include<time.h>
#include<conio.h>
#include<fstream>
using namespace std;
bool setconsolecolor(word forcegroundcolor)

{
    handle handle = getstdhandle(std_output_handle);
    if (handle == 0)
        return false;
    bool ret = setconsoletextattribute(handle, forcegroundcolor);
    return(ret == true);
}
struct juese
{
};
struct wuqi
{
    int str;
    int wuqiqian;
    int baoji;
};
struct fangju
{
    int def;
    int fangjuqian;
};
struct danyao
{
    int danyaoxiaoguo;
    int danyaoqian;
    int danyaoliang;
};
struct guai1
{
    int guai1str;
    int guai1def;
    int guai1hp;
    int guai1hpm;
    int guai1money;
};
struct zhizun
{
    string zhizunname;
    int zhizunstr;
    int zhizundef;
    int zhizunhp;
    int zhizunhpm;
};
struct npc
{
    int npcstr;
    int npcdef;
    int npchp;
    int npchpm;
    int npcmoney;
};
struct you
{
    int youstr;
    int youdef;
    int youhp;
    int youhpm;
    int yoump;
    int exp;
    int expm;
    int money;
    int jibie;
    int wuqi;
    int fangju;
    int zhiye;
};

npc npc1 = {1000,200,5000,5000,10000};
npc npc2 = { 500,100,3000,3000,5000 };
npc npc3 = { 200,50,1000,1000,2000 };
you you = { 10,10,10,10,100,0,15,0,0,0};
guai1 guai1 = { 8,8,8,8,10 };
zhizun zhizun1 = { "无上主宰",10000,10000,1000000,1000000 };
guai1 jushou = { 20,30,100,100,200 };
struct xuetiao
{
    string xuetiao1 = "---------------------------";
    string xuetiao2 = "|";
    char nidexueliang[26] = "|||||||||||||||||||||||||";
    void xueliang(int a,int b)
    {
        cout << xuetiao1 << endl;
        cout << xuetiao2;
        for (unsigned ix = 0; ix < double(a)/double(b)* 25; ++ix)
        {
            cout << nidexueliang[ix];
        }
        cout << xuetiao2[0] << endl;
        cout << xuetiao1 << endl;
    };

};
danyao d1= { 30,100,0 };
danyao d2 = { 100,250,0 };
danyao d3 = { 0,1000,0 };
danyao d4 = { 20,200,0 };
danyao d5 = { 50,300,0 };
danyao d6 = { 20,300,0 };
danyao d7 = { 1000,1000,0 };
wuqi w1 = { 10,100,10 };
wuqi w2 = { 20,300,30 };
wuqi w3 = { 20,500,60 };
wuqi w4 = { 60,1000,10 };
wuqi w5 = { 100,1500,50 };
wuqi w6 = { 120,2000,10 };
wuqi w7 = { 500,5000,10 };
fangju f1 = { 10,100 };
fangju f2 = { 15,300 };
fangju f3 = { 20,500 };
fangju f4 = { 70,1000 };
fangju f5 = { 100,1500 };
fangju f6 = { 300,3000 };
fangju f7 = { 666,5000 };


unsigned i(0);
int temp[3];
vector<wuqi> w;
vector<fangju> f;
vector<danyao> d;

xuetiao nidexue;
xuetiao guaidexue;

//此处暂时收起来

void kaiju()
{
    fstream kaiju;
    kaiju.open("kaiju.txt", ios::out);
    kaiju << "**********************************************************************************************************" << endl;
    kaiju << "*|------------------------------------------------------------------------------------------------------|*" << endl;
    kaiju << "*|                                                                                                      |*" << endl;
    kaiju << "*|                                       异界修仙记(第二部)                                           |*" << endl;
    kaiju << "*|                                                                                                      |*" << endl;
    kaiju << "*|                 按1:开始新游戏                                     按2:打开存档                     |*" << endl;
    kaiju << "*|                                                                                                      |*" << endl;
    kaiju << "*|                                                                                                      |*" << endl;
    kaiju << "*|                                                                                                      |*" << endl;
    kaiju << "*|------------------------------------------------------------------------------------------------------|*" << endl;
    kaiju << "**********************************************************************************************************" << endl;
    kaiju << "新版本:" << endl;
    kaiju << "最大更新!:不再是文字打怪,更有游戏感。" << endl;
    kaiju << "1.加入存档系统,游戏中随时可以存档,再次打开可以继续上次的(第一次玩请不要按2)" << endl;
    kaiju << "2.可以选择职业,剑士,战士,刺客" << endl;
    kaiju << "3.加入了血影阁系统,可以接任务" << endl;
    kaiju << "4.防具和武器拥有新的属性" << endl;
    kaiju << "9.血量显示方式改进" << endl;
    kaiju << "10.修正了游戏公平性" << endl;
    kaiju.close();
    string kaijustr;
    kaiju.open("kaiju.txt", ios::in);
    while (getline(kaiju, kaijustr))
    {
        cout << kaijustr << endl;
    }
    kaiju.close();
}

void ducundang()
{
    vector<int>v;
    unsigned i1(0);
    string cundangstr;
    cout << "              这里是您的存档" << endl;
    fstream cundang1;
    string buffer;
    cundang1.open("cundang1.txt", ios::in);
    while (getline(cundang1, buffer))
    {
        int num = atoi(buffer.c_str());//强转int型
        v.push_back(num);
    }
    cout << "您的职业:";
    if (v[8] == 1)cout << "剑士" << endl;
    else if (v[8] == 2)cout << "刺客" << endl;
    else cout << "战士" << endl;
    cout << "您的等级为" << v[0] << endl;//等级
    cundang1.close();
    you.jibie = v[0];
    you.exp = v[3];
    you.expm = v[7];
    you.money = v[4];
    you.youdef = v[2];
    you.youhp = v[5];
    you.youhpm = v[6];
    you.youstr = v[1];
    you.zhiye = v[8];
    you.yoump = v[9];
    guai1.guai1hp = v[10];
    guai1.guai1hpm = v[11];
    guai1.guai1def = v[12];
    guai1.guai1money = v[13];
    guai1.guai1str = v[14];
    you.wuqi = v[15];
    you.fangju = v[16];
    d1.danyaoliang = v[17];
    d2.danyaoliang = v[18];
    d3.danyaoliang = v[19];
    d4.danyaoliang = v[20];
    d5.danyaoliang = v[21];
    d6.danyaoliang = v[22];
    d7.danyaoliang = v[23];

    string ducundangstr;
s2:    cout << "继续游戏?y/n" << endl;
    cin >> ducundangstr;
    if (ducundangstr == "n")
    {
        kaiju();
    }
    else if (ducundangstr != "y")
    {
        system("cls");
        goto s2;
    }
    else
    {
        system("cls");
    }

}
void xiecundang()
{
    fstream cundang1;
    cundang1.open("cundang1.txt", ios::out);
    cundang1 << you.jibie << endl;//等级
    cundang1 << you.youstr << endl;
    cundang1 << you.youdef << endl;
    cundang1 << you.exp << endl;
    cundang1 << you.money << endl;
    cundang1 << you.youhp << endl;
    cundang1 << you.youhpm << endl;
    cundang1 << you.expm << endl;
    cundang1 << you.zhiye << endl;
    cundang1 << you.yoump << endl;
    cundang1 << guai1.guai1hp << endl;
    cundang1 << guai1.guai1hpm << endl;
    cundang1 << guai1.guai1def << endl;
    cundang1 << guai1.guai1money << endl;
    cundang1 << guai1.guai1str << endl;
    cundang1 << you.wuqi << endl;
    cundang1 << you.fangju << endl;
    cundang1 << d1.danyaoliang << endl;
    cundang1 << d2.danyaoliang << endl;
    cundang1 << d3.danyaoliang << endl;
    cundang1 << d4.danyaoliang << endl;
    cundang1 << d5.danyaoliang << endl;
    cundang1 << d6.danyaoliang << endl;
    cundang1 << d7.danyaoliang << endl;
    cundang1.close();
    cout << "存档成功!" << endl;
}

void start()
{
    system("cls");
    setconsolecolor(foreground_green);
    string str1 = "欢迎来到本游戏第二部,游戏体验方面将有极大的改善。";
    string str2 = "一天,一清和他的女朋友在回华电的路上";
    string str3 = "突然两人穿越到未知之地";
    for (i = 0; i<str1.length(); i++)
    {
        cout << str1[i];
        sleep(80);
    }
    setconsolecolor(foreground_red);
    cout << endl;
    for (i = 0; i < str2.length(); i++)
    {
        cout << str2[i];
        sleep(80);
    }
    cout << endl;
    for (i = 0; i < str3.length(); i++)
    {
        cout << str3[i];
        sleep(100);
    }
    system("cls");
    setconsolecolor(foreground_green);
    cout << "                           " << "华电大陆" << endl << endl;
    string str4 = "两人发现来到了陌生的一个世界,既然来了,二人下定决心要成为至尊。";
    string str6 = ".............";
    for (i = 0; i < str4.length(); i++)
    {
        cout << str4[i];
        sleep(70);
    }
    cout << endl;
    for (i = 0; i < str6.length(); i++)
    {
        cout << str6[i];
        sleep(80);
    }
    system("cls");
}

void zhiye()
{
    cout << "请选择您的职业" << endl;
    cout << "1.剑士         2.刺客          3.战士" << endl << endl << endl;
    cout << "1.剑士:攻守平衡的职业" << endl;
    cout << "2.刺客:注重输出的职业" << endl;
    cout << "3.战士:注重防御的职业" << endl;
    string zhiyestr;
    cin >> zhiyestr;
    if (zhiyestr == "1")you.zhiye = 1;
    else if (zhiyestr == "2")you.zhiye = 2;
    else if (zhiyestr == "3")you.zhiye = 3;
    else
    {
        cout << "您的输入有误,请重新输入" << endl;
        zhiye();
    }
    system("cls");
}

int main()
{
s1:    kaiju();
    string n1;
    cin >> n1;
    if (n1 == "1")
    {
        start();
        zhiye();
    }
    else if (n1 == "2")
    {
        system("cls");
        ducundang();
    }
    else {
        system("cls");
        goto s1;
    }
    setconsolecolor(foreground_green);
    temp[2] = temp[3] = 0;
    w.push_back(w1);
    w.push_back(w2);
    w.push_back(w3);
    w.push_back(w4);
    w.push_back(w5);
    w.push_back(w6);
    w.push_back(w7);
    f.push_back(f1);
    f.push_back(f2);
    f.push_back(f3);
    f.push_back(f4);
    f.push_back(f5);
    f.push_back(f6);
    f.push_back(f7);
    d.push_back(d1);
    d.push_back(d2);
    d.push_back(d3);
    d.push_back(d4);
    d.push_back(d5);
    d.push_back(d6);
    d.push_back(d7);
step:    string n;
    void daguai(int, int, int, int,int), zhuangtai(), shangdian(), author(), xueyinlou(), chengjiu();
    while (zhizun1.zhizunhp >= 0)
    {

        cout << "----------------------------------------------" << endl;
        cout << "|--1.打小怪修炼------------2.前往险地打巨兽--|" << endl;
        cout << "|--3.查看状态--------------4.血影楼----------|" << endl;
        cout << "|--5.访问商店--------------6.挑战至尊--------|" << endl;
        cout << "|--z.制作者信息------------------------------|" << endl;
        cout << "|--c.存档------------------q.退出游戏--------|" << endl;
        cout << "|--------------------------------------------|" << endl;
        cin >> n;
        if (n == "1")
        {
            daguai(guai1.guai1hp,guai1.guai1hpm,guai1.guai1str,guai1.guai1def,guai1.guai1money);
        }
        else if (n == "2")daguai(jushou.guai1hp,jushou.guai1hpm,jushou.guai1str,jushou.guai1def,jushou.guai1money);
        else if (n == "3")zhuangtai();
        else if (n == "4")xueyinlou();
        else if (n == "5")shangdian();
        else if (n == "6")daguai(zhizun1.zhizunhp, zhizun1.zhizunhpm, zhizun1.zhizunstr, zhizun1.zhizundef,0);
        else if (n == "z")author();
        else if (n == "c")xiecundang();
        else if (n == "q")break;
        else 
        {
            system("cls");
            continue;
        }
        if (you.youhp <= 0)
        {
            cout << "你在异界死亡,回华电上课吧,哇哈哈!" << endl;
            cout << "继续玩吗?y/n   注意:有存档才可继续玩" << endl;
            string y;
            cin >> y;
            if (y == "y")
                ducundang();
            else
            break;
        }
        cout << "按任意键继续" << endl;
        string p;
        cin >> p;
        if (p == "a")
        {
            system("cls");
            goto step;
        }
        else
        {
            system("cls");
            goto step;
        }
    }
        system("pause");
    return exit_success;
}


void shengjila()
{
    if (you.zhiye == 1)//剑士
    {
        you.youstr +=3;
        you.youdef +=2;
        you.youhp = you.youhpm = you.youhpm + 10;
        cout << "恭喜你升级了,物理攻击变为:" << you.youstr << "防御变为" << you.youdef << endl;
    }
    else if (you.zhiye == 3)//战士
    {
        you.youstr += 1;
        you.youdef += 5;
        you.youhp = you.youhpm = you.youhpm + 12;
        cout << "恭喜你升级了,物理攻击变为:" << you.youstr << "防御变为" << you.youdef << endl;
    }
    else if (you.zhiye == 2)//刺客
    {
        you.youstr += 5;
        you.youdef += 1;
        you.youhp = you.youhpm = you.youhpm + 8;
        cout << "恭喜你升级了,物理攻击变为:" << you.youstr << "防御变为" << you.youdef << endl;
    }
    if (you.jibie == 5)
    {
        cout << "你已经成为一方强者,寻常人物无法与你抗衡,不过,到至尊的路还很漫长" << endl;
    }
    if (you.jibie == 10)
    {
        cout << "你已经十分强大了,在江湖上有了一定的威望,继续努力吧" << endl;
    }
    if (you.jibie == 20)
    {
        cout << "您已经是一代宗师,大佬受我一拜!!" << endl;
    }
    you.exp = 0;
    you.expm += 10;
    you.jibie++;
    guai1.guai1money += 3;
    jushou.guai1money += 10;
    guai1.guai1hpm += 10;
    guai1.guai1hp = guai1.guai1hpm;
    guai1.guai1str += 1;

}
void victory(int guaim)
{
    if (guaim == guai1.guai1money) {
        cout << "恭喜你杀死了小怪,获得金币" << guai1.guai1money << endl;
        cout << "获得经验:" << 10 << endl;
        cout << "当前等级:" << you.jibie << endl;
        you.exp += 10;
        you.money += guai1.guai1money;
        guai1.guai1hp = guai1.guai1hpm;
        guai1.guai1def += 2;
        if (you.exp >= you.expm)
            shengjila();
    }
    else if (guaim == jushou.guai1money) {
        cout << "恭喜你杀死了巨兽,获得金币" << jushou.guai1money << endl;
        cout << "获得经验:" << 200 << endl;
        you.exp += 200;
        jushou.guai1hp=jushou.guai1hpm += 100;
        jushou.guai1def += 10;
        jushou.guai1str += 15;
        jushou.guai1money += 50;
        you.money += jushou.guai1money;
        if (you.exp >= you.expm)
            shengjila();
    }
    else if (guaim == 0)
    {
        void author();
        cout << "恭喜您,打通关本游戏!" << endl;
        author();
    }
    else if(guaim==npc1.npcmoney||guaim==npc2.npcmoney||guaim==npc3.npcmoney)
    {
        cout << "完成血影楼任务!" << endl;
        you.money += guaim;
    }
}


void zhuangtai()
{
    string chenghao="初入江湖";
    cout << "***************************************************************" << endl;
    cout << "               您的职业:" << endl;
    if (you.zhiye == 1)cout << "剑士" << endl;
    else if (you.zhiye == 2)cout << "刺客" << endl;
    else cout << "战士" << endl;
    if (you.jibie >= 5 && you.jibie < 10)
        chenghao = "一方高手";
    else if (you.jibie >= 10 && you.jibie < 20)
        chenghao = "江湖高手";
    else if (you.jibie >= 20 && you.jibie < 30)
        chenghao = "一代宗师";
    else if (you.jibie >= 30)
        chenghao = "一代传奇";
    cout << "您在江湖上的名声:" << chenghao << endl;
    cout << "您的等级:" << you.jibie << endl;
    cout << "hp:" << you.youhp << "/" << you.youhpm << endl;
    nidexue.xueliang(you.youhp,you.youhpm);
    cout << "您的物理攻击:" << you.youstr << endl;
    cout << "您的防御:" << you.youdef << endl;
    cout << "金币:" << you.money << endl;
    cout << "您的武器:";
    if (you.wuqi == 1) cout << "多兰之刃";
    else if (you.wuqi == 2) cout << "风暴巨剑";
    else if (you.wuqi == 3) cout << "无尽之刃";
    else if (you.wuqi == 4) cout << "破军长剑";
    else if (you.wuqi == 5) cout << "雷神之锤";
    else if (you.wuqi == 6) cout << "血影神刃";
    else if (you.wuqi == 1) cout << "无名长剑";
    else cout << "无";
    cout << endl;
    cout << "您的防具:";
    if (you.fangju == 1) cout << "多兰之盾";
    else if (you.fangju == 2) cout << "日炎斗篷";
    else if (you.fangju == 3) cout << "荆棘之甲";
    else if (you.fangju == 4) cout << "振奋铠甲";
    else if (you.fangju == 5) cout << "狂徒铠甲";
    else if (you.fangju == 6) cout << "重装铠甲";
    else if (you.fangju == 7) cout << "无名铠甲";
    else cout << "无" << endl;
    cout << "您会心一击伤害:" <<you.youstr*3<<endl;
    cout << "***************************************************************" << endl;
    cout << endl;
}
//完成

//完成
void daguai(int guaihp,int guaihpm,int guaistr,int guaidef,int guaim)
{
    srand(time(null));
    void vic1();
    void shiyong();
    string c;
    int b, cishu(2);
    do
    {
        system("cls");
    step1:    if (you.youhp <= 0) { break; }
        cout << "你的hp" << endl;
        nidexue.xueliang(you.youhp,you.youhpm);
        cout << you.youhp << "/" << you.youhpm << endl;
        cout << endl;
        cout << "怪的hp:" << endl;
        guaidexue.xueliang(guaihp,guaihpm);
        cout << guaihp << "/" << guaihpm<< endl;
        cout << "攻击=a 全力一击=w 技能=e 逃跑=b 使用物品=c" << '\n';
        cin >> c;
        if (c == "w")
        {
            cout << "您使用:" << endl;

            cout << "怪大叫一声" << endl;

        }
        if (c == "a")
        {
            int baoji(0);
            b = you.youstr * 2 -guaidef * 3 / 2 + you.youstr * 4 / guaidef;
            for (i = 0; i < 7; i++)
            {
                if (you.wuqi == 1)
                    baoji = w[i].baoji;
            }
            if (rand() % 100 <= baoji)            //%10概率发生重击
            {
                b *= 2;
                cout << "发出暴击:";
                cout << endl;
            }
            if (b <= 0) b = 1;
            guaihp-= b;
            if (guaihp <= 0) {
                guaihp = 0;
                cout << "怪物大叫一声,倒在地上" << '\n';
            }
            if (you.wuqi == 5)
            {
                you.youhp += b / 2;
                cout << "吸血效果,你回复" << b / 2 << "滴血";
            }
            if (guaihp>0)
            {
                b = guaistr* 2 - you.youdef * 3 / 2 + guaistr * 4 / you.youdef;
                if (b <= 0) b = 1;
                you.youhp -= b;
                system("cls");
                goto step1;
            }
        }
        if (c == "c")
        {
            shiyong();
            b =guaistr * 2 - you.youdef * 3 / 2 + guaistr * 4 / you.youdef;
            if (b <= 0) b = 1;
            you.youhp -= b;
            system("cls");
            goto step1;
        }
        if (c == "w")
        {
            cishu -= 1;
            if (cishu > 0)
            {
                guaihp -= you.youstr;
                system("cls");
                goto step1;
            }
        }
        if (c == "b")
        {
            cout << "逃跑成功 hp-5" << '\n';
            if (you.youhp>5)you.youhp -= 5;
            break;
        }
    } while (guaihp>0);
    if (guaihp<= 0) victory(guaim);
}
//完成

void author()
{
    string str0 = "计算机系1704班许一清", str00 = "下一部作品将是图形化游戏";
    cout << "                   ";
    for (i = 0; i < str0.length(); i++)
    {
        cout << str0[i];
        sleep(80);
    }
    cout << endl;
    cout << "                   ";
    for (i = 0; i < str00.length(); i++)
    {
        cout << str00[i];
        sleep(80);
    }
    cout << endl;
}
//完成
void shangdian()
{
    void wuqidian();
    void danyaodian();
    void fangjudian();
    void shenmidian();
    cout << "                    " << "这里是华电大陆最全面的商行" << endl;
    cout << "1.深渊武器店" << endl;
    cout << "2.神草丹药店" << endl;
    cout << "3.玄武防具店" << endl;
    string d;
    cin >> d;
    if (d == "1")wuqidian();
    else if (d == "2")danyaodian();
    else if (d == "3")fangjudian();
    else
        cout << "不存在的" << endl;
}
void wuqidian()
{
    string b;
    int f;
    cout << "             " << "欢迎来到深渊武器店,这里应有尽有" << endl;
    cout << "1.多兰之刃 ¥100 物理攻击+10   无属性" << endl;
    cout << "2.风暴巨剑 ¥300 物理攻击+15   加20暴击" << endl;
    cout << "3.无尽之刃 ¥500 物理攻击+20   加50暴击" << endl;
    cout << "4.破军长剑 ¥1000 物理攻击+60   无属性" << endl;
    cout << "5.雷神之锤 ¥1500 物理攻击+100    加40暴击" << endl;
    cout << "6.血影神刀 ¥2000 物理攻击+120    吸血50%" << endl;
    cout << "7.无名之剑 ¥5000 物理攻击+500     无属性" << endl;
    cout << "q.退出" << endl;
    cin >> b;
    if (b == "q") cout << "退出!" << '\n' << '\n';
    else if (b != "1"&&b != "2"&&b != "3"&&b != "4"&&b != "5"&&b != "6"&&b != "7")cout << "输入错误!" << '\n' << '\n';
    else {
        if (b == "1") f = 1;
        if (b == "2") f = 2;
        if (b == "3") f = 3;
        if (b == "4") f = 4;
        if (b == "5") f = 5;
        if (b == "6") f = 6;
        if (b == "7") f = 7;
        if (you.money<w[f - 1].wuqiqian) cout << "失败" << '\n' << '\n';
        else
        {
            you.money -= w[f - 1].wuqiqian;
            you.wuqi = f;
            you.youstr = you.youstr + w[f - 1].str - temp[2];
            temp[2] = w[f - 1].str;
            cout << "购买成功" << '\n' << '\n';
        }
    }
}
void danyaodian()
{

    string b;
    int c, f;
    cout << "1.回血丹 ¥100 hp+30" << '\n';
    cout << "2.大补丹 ¥250 hp+100" << '\n';
    cout << "3.和尚乐 ¥1000 hp+100%" << '\n';
    cout << "4.大力丸 ¥200 物理攻击永久升20" << '\n';
    cout << "5.升血丹 ¥300  最大生命值永久升50" << '\n';
    cout << "6.神龙丹 ¥300 物理防御永久升20 " << '\n';
    cout << "7.一清丹 ¥1000 效果未知???" << '\n';
    cout << "退出=q" << '\n';
    cin >> b;
    if (b == "q")  cout << "退出!" << '\n' << '\n';
    else if (b != "1" && b != "2" && b != "3" && b != "4" && b != "5"&&b != "6"&&b != "7")
        cout << "输入错误!" << '\n' << '\n';
    else {
        cout << "要几颗?(请不要输入非数字)" << '\n';
        cin >> c;
        if (c <= 0)
        {
            for (;;)
            {
                cout << "重新输入" << '\n';
                cin >> c;
                if (c>0) break;
            }
        }
        if (b == "1") f = 1;
        if (b == "2") f = 2;
        if (b == "3") f = 3;
        if (b == "4") f = 4;
        if (b == "5") f = 5;
        if (b == "6") f = 6;
        if (b == "7") f = 7;
        if (you.money<d[f - 1].danyaoqian* c) cout << "失败" << '\n' << '\n';
        else {
            you.money -= d[f - 1].danyaoqian * c;
            d[f - 1].danyaoliang += c;
            cout << "购买成功" << '\n' << '\n';
        }
    }
}
void fangjudian()
{
    string b;
    int f;
    cout << "             " << "欢迎来到深渊武器店,这里应有尽有" << endl;
    cout << "1.多兰之盾 ¥100 物理防御+10   " << endl;
    cout << "2.日炎斗篷 ¥300 物理防御+15   " << endl;
    cout << "3.荆棘之甲 ¥500 物理防御+20   " << endl;
    cout << "4.振奋铠甲 ¥1000 物理防御+70  " << endl;
    cout << "5.狂徒铠甲 ¥1500 物理防御+100 " << endl;
    cout << "6.重装铠甲 ¥3000 物理防御+300 " << endl;
    cout << "7.无名铠甲 ¥5000 物理防御+666 " << endl;
    cout << "q.退出" << endl;
    cin >> b;
    if (b == "q") cout << "退出!" << '\n' << '\n';
    else if (b != "1"&&b != "2"&&b != "3"&&b != "4"&&b != "5"&&b != "6"&&b != "7")cout << "输入错误!" << '\n' << '\n';
    else {
        if (b == "1") f = 1;
        if (b == "2") f = 2;
        if (b == "3") f = 3;
        if (b == "4") f = 4;
        if (b == "5") f = 5;
        if (b == "6") f = 6;
        if (b == "7") f = 7;
        if (you.money<f[f - 1].fangjuqian) cout << "失败" << '\n' << '\n';
        else
        {
            you.money -= f[f - 1].fangjuqian;
            you.fangju = f;
            you.youdef = you.youdef + f[f - 1].def - temp[3];
            temp[3] = f[f - 1].def;
            cout << "购买成功" << '\n' << '\n';
        }
    }
}


void shiyong()
{
    cout << "1 回血丹有" << d[0].danyaoliang << "个" << '\n';
    cout << "2 大补丹有" << d[1].danyaoliang << "个" << '\n';
    cout << "3 和尚乐有" << d[2].danyaoliang << "个" << '\n';
    cout << "4 大力丸有" << d[3].danyaoliang << "个" << '\n';
    cout << "5 升血丹有" << d[4].danyaoliang << "个" << '\n';
    cout << "6 神龙丹有" << d[5].danyaoliang << "个" << '\n';
    cout << "7 一清丹有" << d[6].danyaoliang << "个" << '\n';
    int c;
    cout << "使用丹药=";
    cin >> c;
    if (d[c - 1].danyaoliang == 0) cout << "失败!!!!" << '\n' << '\n';
    else
    {
        d[c - 1].danyaoliang--;
        switch (c)
        {
        case 1:cout << "生命回复" << '\n'; you.youhp += d[0].danyaoxiaoguo;
            if (you.youhp > you.youhpm) you.youhp = you.youhpm;
            break;
        case 2:cout << "生命回复" << '\n'; you.youhp += d[1].danyaoxiaoguo;
            if (you.youhp > you.youhpm) you.youhp = you.youhpm;
            break;
        case 3:cout << "满血" << '\n'; you.youhp = you.youhpm;
            break;
        case 4:cout << "物理攻击+" << '\n'; you.youstr += d[3].danyaoxiaoguo;
            break;
        case 5:cout << " 生命上线+" << '\n';
            you.youhpm += d[4].danyaoxiaoguo;
            break;
        case 6:cout << " 物理防御+" << '\n';
            you.youdef += d[5].danyaoxiaoguo;
            break;
        case 7:cout << " 迷之效果" << '\n';
            you.exp += d[6].danyaoxiaoguo;
        }
    }
}

void xueyinlou()
{
    cout << "                   " << "血影楼" << endl;
    cout << "杀手通缉榜,有能力才可以领任务" << endl;
    cout << "1.无名者  $10000        要求:物理攻击500可接任务" << endl;
    cout << "2.深渊大魔头$5000     要求:拥有血影神刀可接任务" << endl;
    cout << "3.无极巨魔 $2000       要求:30级以上可接任务" << endl;
    cout << "按q退出" << endl;
    string xylstr;
    cin >> xylstr;
    if (xylstr == "1")
    {
        if (you.youstr >= 500)
            daguai(npc1.npchp,npc1.npchpm,npc1.npcstr,npc1.npcdef,npc1.npcmoney);
        else
        {
            cout << "条件不够!回去继续修炼吧" << endl;
            cout << "按任意键返回" << endl;
            string strn;
            cin >> strn;
            if (strn == "q")
            {
                system("cls");
                xueyinlou();
            }
            else
            {
                system("cls");
                xueyinlou();
            }

        }
    }
    else if (xylstr == "2")
    {
        {
            if (you.wuqi==5)
                daguai(npc2.npchp, npc2.npchpm, npc2.npcstr, npc2.npcdef, npc2.npcmoney);
            else
            {
                cout << "条件不够!回去继续修炼吧" << endl;
                cout << "按任意键返回" << endl;
                string strn;
                cin >> strn;
                if (strn == "q")
                {
                    system("cls");
                    xueyinlou();
                }
                else
                {
                    system("cls");
                    xueyinlou();
                }

            }
        }
    }
    else if (xylstr == "3")
    {
        {
            if (you.jibie>=30)
                daguai(npc3.npchp, npc3.npchpm, npc3.npcstr, npc3.npcdef, npc3.npcmoney);
            else
            {
                cout << "条件不够!回去继续修炼吧" << endl;
                cout << "按任意键返回" << endl;
                string strn;
                cin >> strn;
                if (strn == "q")
                {
                    system("cls");
                    xueyinlou();
                }
                else
                {
                    system("cls");
                    xueyinlou();
                }

            }
        }
    }
    else if (xylstr == "q")
    {
        system("cls");
    }
    else
    {
        system("cls");
        xueyinlou();
    }
}