• 个人简介

    三角洲的号:难洛王

    多个游戏代码

    #include<bits/stdc++.h>
    #include<cstdio>
    #include<cstdlib>
    #include<ctime>
    #include<windows.h>
    using namespace std;
    struct IDname
    {
        int geshu;
        string NAME;
    };
    IDname jue_se[100];
    struct ID
    {
        int num;
        bool life;
        string name;
        int know;
        int how;
    };
    ID player[21];
    int n, MY, kill1, kill2;
    char a;
    bool jieyao = 1, duyao = 1;
    int lieren, shouwei = 0;
    void init1()
    {
        jue_se[1].NAME = "村民 ";
        jue_se[2].NAME = "狼人 ";
        jue_se[3].NAME = "女巫 ";
        jue_se[4].NAME = "预言家 ";
        jue_se[5].NAME = "猎人 ";
        jue_se[6].NAME = "守卫 ";
    }
    void init2(int nn)
    {
        switch (nn)
        {
        case 6:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 2;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 0;
            jue_se[5].geshu = 0;
            jue_se[6].geshu = 0;
            break;
        case 7:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 2;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 0;
            jue_se[6].geshu = 0;
            break;
        case 8:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 3;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 0;
            jue_se[6].geshu = 0;
            break;
        case 9:
            jue_se[1].geshu = 3;
            jue_se[2].geshu = 3;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 0;
            break;
        case 10:
            jue_se[1].geshu = 4;
            jue_se[2].geshu = 3;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 0;
            break;
        case 11:
            jue_se[1].geshu = 4;
            jue_se[2].geshu = 4;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 0;
            break;
        case 12:
            jue_se[1].geshu = 4;
            jue_se[2].geshu = 4;
            jue_se[3].geshu = 1;
            jue_se[4].geshu = 1;
            jue_se[5].geshu = 1;
            jue_se[6].geshu = 1;
            break;
        default:
            cout << "输入错误,再见" << endl;
            exit(0);
            break;
        }
    }
    int van[10] = { 7,4,6,43,35,1,2,8,20,19 };
    void init3(int nn)
    {
        srand(time(0));
        Sleep(rand() % 44);
        int x = 10000;
        int t = rand();
        srand(time(NULL));
        int y = van[(rand() % 100 * van[rand() % 10] + t) % 10];
        if (nn <= 6)
            x = abs(x * 6 / y) % 3 + 1;
        else if (nn <= 8)
            x = abs(x * 7 / y) % 4 + 1;
        else if (nn <= 11)
            x = abs(x * 8 / y) % 5 + 1;
        else if (nn <= 14)
            x = abs(x * 9 / y) % 6 + 1;
        do
        {
            if (nn <= 6)
                x = x % 3 + 1;
            else if (nn <= 8)
                x = x % 4 + 1;
            else if (nn <= 11)
                x = x % 5 + 1;
            else if (nn <= 14)
                x = x % 6 + 1;
            if (jue_se[x].geshu > 0)
            {
                player[nn].name = jue_se[x].NAME;
                if (player[nn].name == "猎人 ")
                    lieren = nn;
                if (player[nn].name == "守卫 ")
                    shouwei = nn;
                player[nn].life = 1;
                player[nn].num = nn;
                player[nn].know = 0;
                jue_se[x].geshu--;
                player[nn].how = 0;
                break;
            }
        } while (jue_se[x].geshu == 0);
    }
    void printhhh()
    {
        int cm = 0;
        int sz = 0;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 0)
                continue;
            else if (player[i].name == "村民 ")
                cm++;
            else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 " || player[i].name == "守卫 ")
                sz++;
        }
        if (sz == 0 || cm == 0)
            cout << "狼人阵营胜利" << endl;
        else
            cout << "好人阵营胜利" << endl;
        for (int i = 1; i <= n; i++)
        {
            cout << left << setw(3) << player[i].num << ": " << player[i].name << " ";
            if (player[i].life == 0)
                cout << "死亡" << "\t";
            else
                cout << "存活" << "\t";
            if (player[i].how == 0)
                cout << "最终存活 " << endl;
            else if (player[i].how == 1)
                cout << "最终被狼人杀死" << endl;
            else if (player[i].how == 2)
                cout << "最终被投票投死" << endl;
            else if (player[i].how == 3)
                cout << "最终被女巫毒死" << endl;
            else if (player[i].how == 4)
                cout << "最终被猎人射杀" << endl;
        }
        system("pause");
        system("pause");
        system("pause");
    }
    void print(int day, int ti)
    {
        HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
        if (ti == 0)
            SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
        else
            SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
        cout << "\t\t\t\t第" << day << "天 ";
        if (ti == 0)
            cout << "白天" << endl;
        else
            cout << "夜晚" << endl;
        cout << "我的位置:" << MY << "号" << endl;
        for (int i = 1; i <= 6; i++)
        {
            cout << player[i].num << "号位 ";
        }
        cout << endl;
        for (int i = 1; i <= 6; i++)
        {
            if (player[i].life == 1)
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                cout << "存活 ";
            }
            else
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
                cout << "已死亡 ";
            }
        }
        if (ti == 0)
            SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
        else
            SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
        cout << endl;
        for (int i = 1; i <= 6; i++)
        {
            if (player[i].know == 0)
                cout << "未知 ";
            else if (player[i].know == 1)
            {
                if (player[i].name == "狼人 ")
                    cout << "狼人 ";
                else
                    cout << "好人 ";
            }
            else if (player[i].know == 2)
                cout << player[i].name << " ";
        }
        cout << endl << endl;
        for (int i = 7; i <= n; i++)
        {
            if (i < 10)
                cout << player[i].num << "号位 ";
            else
                cout << player[i].num << "号位 ";
        }
        cout << endl;
        for (int i = 7; i <= n; i++)
        {
            if (player[i].life == 1)
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                cout << "存活 ";
            }
            else
            {
                if (ti == 0)
                    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
                else
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
                cout << "已死亡 ";
            }
        }
        if (ti == 0)
            SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
        else
            SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
        cout << endl;
        for (int i = 7; i <= n; i++)
        {
            if (player[i].know == 0)
                cout << "未知 ";
            else if (player[i].know == 1)
            {
                if (player[i].name == "狼人 ")
                    cout << "狼人 ";
                else
                    cout << "好人 ";
            }
            else if (player[i].know == 2)
                cout << player[i].name << " ";
        }
        cout << endl << endl;
    }
    int shou = 0;
    void shoushui(int hhh, int hhhh)
    {
        int x;
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "守~卫~请~睁~眼~~~" << endl;
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        if (MY == shouwei && player[MY].life == 1)
        {
            cout << "请问你要守护谁?" << endl << "输入:";
            cin >> x;
            while (x == shou || x<1 || x>n || player[x].life == 0)
            {
                cout << "输入错误,请重新输入" << endl << "输入:";
                cin >> x;
            }
            shou = x;
        }
        else if (player[shouwei].life == 1)
        {
            cout << "请问你要守护谁?" << endl;
            Sleep(rand() % 98);
            srand(time(0));
            x = rand() % n + 1;
            while (x == shou || player[x].life == 0)
            {
                Sleep(rand() % 98);
                srand(time(0));
                x = rand() % n + 1;
            }
            shou = x;
        }
        else
        {
            cout << "请问你要守护谁?" << endl;
            Sleep(3000);
            shou = -1;
        }
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "守~卫~请~闭~眼~~~" << endl;
    }
    struct tou
    {
        int xxx;
        int num;
        int toupiaoquan;
    };
    tou TOU[13];
    bool cmp(tou x, tou y)
    {
        if (x.xxx == y.xxx)
            return x.num < y.num;
        return x.xxx > y.xxx;
    }
    bool cmp1(tou x, tou y)
    {
        return x.num < y.num;
    }
    void toupiao(int ddd, int nnn)
    {
        //--------1--------
        int x;
        Sleep(2000);
        system("cls");
        print(ddd, nnn);
        cout << "现在大家请投票";
        for (int i = 1; i <= 3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        cout << endl;
        for (int i = 1; i <= n; i++)
        {
            TOU[i].num = i;
            TOU[i].toupiaoquan = 1;
            TOU[i].xxx = 0;
        }
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1)
            {
                Sleep(3000);
                if (i == MY)
                {
                    cout << "请投票...(0弃权)" << endl;
                    cin >> x;
                    while (player[x].life == 0 && x != 0)
                    {
                        cin >> x;
                    }
                    if (x == 0)
                        cout << MY << "号玩家弃权" << endl;
                    else
                        cout << MY << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    srand(time(0));
                    if (player[i].name == "狼人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i))
                        {
                            Sleep(rand() % 98);
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else if (player[i].name == "预言家 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i))
                        {
                            Sleep(rand() % 98);
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || x == i))
                        {
                            Sleep(rand() % 98);
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                }
                if (x != 0)
                    TOU[x].xxx++;
            }
        }
        Sleep(3000);
        sort(TOU + 1, TOU + n + 1, cmp);
        if (TOU[2].xxx != TOU[1].xxx)
        {
            cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
            player[TOU[1].num].life = 0;
            player[TOU[1].num].how = 2;
            Sleep(3000);
            return;
        }
        else
        {
            TOU[1].toupiaoquan = 0;
            TOU[2].toupiaoquan = 0;
            system("cls");
            print(ddd, nnn);
            cout << TOU[1].num << "号," << TOU[2].num << "号";
            int i;
            for (i = 3; i <= n; i++)
            {
                if (TOU[i].xxx == TOU[1].xxx)
                {
                    TOU[i].toupiaoquan = 0;
                    cout << "," << TOU[i].num << "号";
                }
                else
                    break;
            }
            if (i == n + 1)
            {
                for (int i = 1; i <= n; i++)
                    TOU[i].toupiaoquan = 1;
            }
            cout << "平票" << endl;
        }
        //--------2--------
        sort(TOU + 1, TOU + n + 1, cmp1);
        cout << "请再次投票";
        for (int i = 1; i <= 3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        cout << endl;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
            {
                Sleep(3000);
                if (i == MY)
                {
                    cout << "请投票...(0弃权)" << endl;
                    cin >> x;
                    while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
                    {
                        cin >> x;
                    }
                    if (x == 0)
                        cout << MY << "号玩家弃权" << endl;
                    else
                        cout << MY << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    srand(time(0));
                    if (player[i].name == "狼人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else if (player[i].name == "预言家 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                }
                if (x != 0 && TOU[i].toupiaoquan == 1)
                    TOU[x].xxx++;
            }
        }
        Sleep(3000);
        sort(TOU + 1, TOU + n + 1, cmp);
        if (TOU[2].xxx != TOU[1].xxx)
        {
            cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
            player[TOU[1].num].life = 0;
            player[TOU[1].num].how = 2;
            Sleep(3000);
            return;
        }
        else
        {
            TOU[1].toupiaoquan = 0;
            TOU[2].toupiaoquan = 0;
            system("cls");
            print(ddd, nnn);
            cout << TOU[1].num << "号," << TOU[2].num << "号";
            int i;
            for (i = 3; i <= n; i++)
            {
                if (TOU[i].xxx == TOU[1].xxx)
                {
                    TOU[i].toupiaoquan = 0;
                    cout << "," << TOU[i].num << "号";
                }
                else
                    break;
            }
            if (i == n + 1)
            {
                for (int i = 1; i <= n; i++)
                    TOU[i].toupiaoquan = 1;
            }
            cout << "平票" << endl;
        }
        //--------3--------
        sort(TOU + 1, TOU + n + 1, cmp1);
        cout << "请再次投票";
        for (int i = 1; i <= 3; i++)
        {
            cout << ".";
            Sleep(500);
        }
        cout << endl;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
            {
                Sleep(3000);
                if (i == MY)
                {
                    cout << "请投票...(0弃权)" << endl;
                    cin >> x;
                    while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
                    {
                        cin >> x;
                    }
                    if (x == 0)
                        cout << MY << "号玩家弃权" << endl;
                    else
                        cout << MY << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    srand(time(0));
                    if (player[i].name == "狼人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else if (player[i].name == "预言家 " || player[i].name == "猎人 ")
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                    else
                    {
                        x = rand() % (n + 1);
                        while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
                        {
                            srand(time(0));
                            x = rand() % (n + 1);
                        }
                        if (x == 0)
                            cout << i << "号玩家弃权" << endl;
                        else
                            cout << i << "号玩家投给了" << x << "号玩家" << endl;
                    }
                }
                if (x != 0 && TOU[i].toupiaoquan == 1)
                    TOU[x].xxx++;
            }
        }
        Sleep(3000);
        sort(TOU + 1, TOU + n + 1, cmp);
        if (TOU[2].xxx != TOU[1].xxx)
        {
            cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
            player[TOU[1].num].life = 0;
            player[TOU[1].num].how = 2;
        }
        else
        {
            cout << "投票结束,无人出局" << endl;
        }
        Sleep(5000);
    }
    bool game_over()
    {
        int pingmin = 0;
        int langren = 0;
        int shenzhi = 0;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 0)
                continue;
            if (player[i].name == "狼人 ")
                langren++;
            else if (player[i].name == "村民 ")
                pingmin++;
            else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 ")
                shenzhi++;
        }
        if (shenzhi == 0 || langren == 0 || pingmin == 0)
            return 1;
        return 0;
    }
    void night()
    {
        system("cls");
        system("color 0f");
        print(1, 1);
        cout << "天~黑~请~闭~眼~~~" << endl;
        if (n >= 12)
            shoushui(1, 1);
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "狼~人~请~睁~眼~~~" << endl;
        if (player[MY].name == "狼人 ")
        {
            Sleep(1000);
            cout << "你的同伴有:";
            for (int i = 1; i <= n; i++)
            {
                if (i == MY)
                    continue;
                if (player[i].name == "狼人 ")
                {
                    cout << player[i].num << "号 ";
                    player[i].know = 2;
                }
            }
            Sleep(3000);
            cout << endl << "请问你们要杀谁:" << endl << "输入:";
            cin >> kill1;
            Sleep(1500);
            system("cls");
            print(1, 1);
            cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
        }
        else
        {
            Sleep(4000);
            system("cls");
            print(1, 1);
            cout << "请问你们要杀谁?" << endl;
            do
            {
                Sleep(rand() % 18);
                srand(time(0));
                int x = rand() % n + 1;
                if (player[x].name != "狼人 " && player[x].life == 1)
                {
                    kill1 = x;
                    break;
                }
            } while (1);
            Sleep(5000);
        }
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "狼~人~请~闭~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(1, 1);
        cout << "女~巫~请~睁~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(1, 1);
        if (player[MY].name == "女巫 " && player[MY].life == 1)
        {
            Sleep(1000);
            if (jieyao == 1)
            {
                cout << "今晚" << kill1 << "号玩家被杀" << endl;
                Sleep(500);
                cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    system("cls");
                    print(1, 1);
                    cout << "请问你要毒吗???" << endl;
                    Sleep(2000);
                    system("cls");
                    print(1, 1);
                    cout << "今晚" << kill1 << "号玩家被你解救" << endl;
                    jieyao = 0;
                    if (shou != kill1)
                        kill1 = 0;
                }
                else
                {
                    if (shou == kill1)
                        kill1 = 0;
                    Sleep(2000);
                    system("cls");
                    print(1, 1);
                    cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                    cin >> a;
                    if (a == 'A')
                    {
                        cout << "请问你要毒谁???" << endl << "输入:";
                        cin >> kill2;
                        while (player[kill2].life != 1)
                        {
                            cout << "输入错误,请重新输入:" << endl;
                            cin >> kill2;
                        }
                        duyao = 0;
                    }
                }
            }
            else
            {
                if (shou == kill1)
                    kill1 = 0;
                Sleep(2000);
                system("cls");
                print(1, 1);
                cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    cout << "请问你要毒谁???" << endl << "输入:";
                    cin >> kill2;
                    while (player[kill2].life != 1)
                    {
                        cout << "输入错误,请重新输入:" << endl;
                        cin >> kill2;
                    }
                    duyao = 0;
                }
            }
        }
        else
        {
            bool b = 0;
            cout << "请问你是否要用解药???" << endl;
            int FFF = 0, kkkk;
            for (int i = 1; i <= n; i++)
            {
                if (player[i].life == 1 && player[i].name == "村民 ")
                    FFF++;
                if (player[i].name == "女巫 ")
                    kkkk = i;
            }
            if (jieyao == 1 && player[kkkk].life == 1)
            {
                if (FFF == 1)
                {
                    if (shou == kill1)
                        jieyao = 1;
                    else
                        jieyao = 0;
                    kill1 = 0;
                    b = 1;
                }
                else
                    for (int i = 1; i <= n; i++)
                    {
                        if (player[i].name == "女巫 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                        else if (player[i].name == "预言家 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                    }
            }
            Sleep(3000);
            if (b == 0 && duyao == 1 && player[kkkk].life == 1)
            {
                system("cls");
                print(1, 1);
                cout << "请问你是否要用毒药???" << endl;
                srand(time(0));
                int x = rand() % 2;
                Sleep(1500);
                cout << "请问你要毒谁???" << endl;
                if (x == 1)
                {
                    duyao = 0;
                    int y = rand() % n + 1;
                    while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
                        y = rand() % n + 1;
                    kill2 = y;
                }
            }
            else
            {
                Sleep(3000);
                system("cls");
                print(1, 1);
                cout << "请问你是否要用毒药???" << endl;
                Sleep(3000);
                cout << "请问你要毒谁???" << endl;
                Sleep(3000);
            }
        }
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "女~巫~请~闭~眼~~~" << endl;
        if (n > 6)
        {
            Sleep(3000);
            system("cls");
            print(1, 1);
            cout << "预~言~家~请~睁~眼~~~" << endl;
            if (player[MY].name == "预言家 ")
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl << "输入:";
                int x;
                cin >> x;
                player[x].know = 1;
                Sleep(2000);
                system("cls");
                print(1, 1);
                cout << "他的身份是:";
                if (player[x].name == "狼人 ")
                    cout << "狼人" << endl;
                else
                    cout << "好人" << endl;
                Sleep(3000);
            }
            else
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl;
                Sleep(3000);
                system("cls");
                print(1, 1);
                cout << "他的身份是:......";
                Sleep(3000);
            }
            Sleep(3000);
            system("cls");
            print(1, 1);
            cout << "预~言~家~请~闭~眼~~~" << endl;
        }
        Sleep(3000);
        if (kill1 != 0)
            player[kill1].life = 0;
        if (kill2 != 0)
            player[kill2].life = 0;
        player[kill1].how = 1;
        player[kill2].how = 3;
        system("cls");
        system("color F0");
        print(2, 0);
    }
    void night2(int hhh, int hhhh)
    {
        system("cls");
        system("color 0f");
        print(hhh, hhhh);
        cout << "天~黑~请~闭~眼~~~" << endl;
        if (n >= 12)
            shoushui(hhh, hhhh);
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "狼~人~请~睁~眼~~~" << endl;
        if (player[MY].name == "狼人 " && player[MY].life == 1)
        {
            Sleep(3000);
            cout << endl << "请问你们要杀谁:" << endl << "输入:";
            cin >> kill1;
            Sleep(1500);
            system("cls");
            print(hhh, hhhh);
            cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
        }
        else
        {
            Sleep(4000);
            system("cls");
            print(hhh, hhhh);
            cout << "请问你们要杀谁?" << endl;
            do
            {
                srand(time(0));
                int x = rand() % n + 1;
                if (player[x].name != "狼人 " && player[x].life == 1)
                {
                    kill1 = x;
                    break;
                }
            } while (1);
            Sleep(5000);
        }
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "狼~人~请~闭~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(hhh, hhhh);
        cout << "女~巫~请~睁~眼~~~" << endl;
        Sleep(2000);
        system("cls");
        print(hhh, hhhh);
        if (player[MY].name == "女巫 " && player[MY].life == 1)
        {
            Sleep(1000);
            if (jieyao == 1)
            {
                cout << "今晚" << kill1 << "号玩家被杀" << endl;
                Sleep(500);
                cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    system("cls");
                    print(hhh, hhhh);
                    cout << "请问你要毒吗???" << endl;
                    Sleep(2000);
                    system("cls");
                    print(hhh, hhhh);
                    cout << "今晚" << kill1 << "号玩家被你解救" << endl;
                    jieyao = 0;
                    if (shou != kill1)
                        kill1 = 0;
                }
                else
                {
                    if (shou == kill1)
                        kill1 = 0;
                    Sleep(2000);
                    system("cls");
                    print(hhh, hhhh);
                    cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                    cin >> a;
                    if (a == 'A')
                    {
                        cout << "请问你要毒谁???" << endl << "输入:";
                        cin >> kill2;
                        while (player[kill2].life != 1)
                        {
                            cout << "输入错误,请重新输入:" << endl;
                            cin >> kill2;
                        }
                        duyao = 0;
                    }
                }
            }
            else if (duyao == 1)
            {
                if (shou == kill1)
                    kill1 = 0;
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    cout << "请问你要毒谁???" << endl << "输入:";
                    cin >> kill2;
                    while (player[kill2].life != 1)
                    {
                        cout << "输入错误,请重新输入:" << endl;
                        cin >> kill2;
                    }
                    duyao = 0;
                }
            }
            else
            {
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "请问你要毒吗???" << endl;
            }
        }
        else
        {
            bool b = 0;
            cout << "请问你是否要用解药???" << endl;
            int FFF = 0, kkkk;
            for (int i = 1; i <= n; i++)
            {
                if (player[i].life == 1 && player[i].name == "村民 ")
                    FFF++;
                if (player[i].name == "女巫 ")
                    kkkk = i;
            }
            if (jieyao == 1 && player[kkkk].life == 1)
            {
                if (FFF == 1)
                {
                    if (shou == kill1)
                        jieyao = 1;
                    else
                        jieyao = 0;
                    kill1 = 0;
                    b = 1;
                }
                else
                    for (int i = 1; i <= n; i++)
                    {
                        if (player[i].name == "女巫 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                        else if (player[i].name == "预言家 " && kill1 == i)
                        {
                            kill1 = 0;
                            if (shou == kill1)
                                jieyao = 1;
                            else
                                jieyao = 0;
                            b = 1;
                            break;
                        }
                    }
            }
            Sleep(3000);
            if (b == 0 && duyao == 1 && player[kkkk].life == 1)
            {
                system("cls");
                print(hhh, hhhh);
                cout << "请问你是否要用毒药???" << endl;
                srand(time(0));
                int x = rand() % 2;
                Sleep(1500);
                cout << "请问你要毒谁???" << endl;
                if (x == 1)
                {
                    duyao = 0;
                    int y = rand() % n + 1;
                    while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
                        y = rand() % n + 1;
                    kill2 = y;
                }
            }
            else
            {
                Sleep(3000);
                system("cls");
                print(hhh, hhhh);
                cout << "请问你是否要用毒药???" << endl;
                Sleep(3000);
                cout << "请问你要毒谁???" << endl;
                Sleep(3000);
            }
        }
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "女~巫~请~闭~眼~~~" << endl;
        if (n > 6)
        {
            Sleep(3000);
            system("cls");
            print(hhh, hhhh);
            cout << "预~言~家~请~睁~眼~~~" << endl;
            if (player[MY].name == "预言家 " && player[MY].life == 1)
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl << "输入:";
                int x;
                cin >> x;
                player[x].know = 1;
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "他的身份是:";
                if (player[x].name == "狼人 ")
                    cout << "狼人" << endl;
                else
                    cout << "好人" << endl;
                Sleep(3000);
            }
            else
            {
                Sleep(3000);
                cout << "请问你想查验谁???" << endl;
                Sleep(3000);
                system("cls");
                print(hhh, hhhh);
                cout << "他的身份是:......";
                Sleep(3000);
            }
            Sleep(3000);
            system("cls");
            print(hhh, hhhh);
            cout << "预~言~家~请~闭~眼~~~" << endl;
        }
        Sleep(3000);
        if (kill1 != 0)
            player[kill1].life = 0;
        if (kill2 != 0)
            player[kill2].life = 0;
        player[kill1].how = 1;
        player[kill2].how = 3;
        system("cls");
        system("color F0");
        print(hhh + 1, 0);
    }
    bool lr = 0;
    void panduanlieren()
    {
        if (lr == 1)
            return;
        if (MY == lieren)
        {
            cout << "请射杀一名玩家" << endl;
            int x;
            cin >> x;
            while (player[x].life != 1)
            {
                cout << "输入错误,请重新输入" << endl;
                cin >> x;
            }
            Sleep(1000);
            cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
            player[x].life = 0;
            player[x].how = 4;
        }
        else if (n >= 9)
        {
            srand(time(0));
            int x = rand() % n + 1;
            while (player[x].life != 1)
            {
                x = rand() % n + 1;
            }
            Sleep(1000);
            cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
            player[x].life = 0;
            player[x].how = 4;
        }
        lr = 1;
    }
    void print1()
    {
        cout << "天亮了,昨晚";
        if (kill1 != 0 || kill2 != 0)
        {
            cout << kill1 << "号";
            if (kill2 != 0)
            {
                cout << "," << kill2 << "号";
                kill2 = 0;
            }
            cout << "被杀" << endl;
        }
        else
            cout << "是平安夜" << endl;
    }
    int main()
    {
        system("cls");
        cout << " " << "狼人杀online" << endl;
        cout << "请输入人数个数:" << endl;
        scanf("%d", &n);
        cout << "加载时间长,请耐心等待";
        init1();
        init2(n);
        int k = 1;
        do
        {
            srand(time(0));
            init3(k);
            cout << ".";
            Sleep(17);
            k++;
        } while (k <= n);
        system("cls");
        system("color F0");
        cout << "游戏即将开始";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        Sleep(1500);
        cout << endl << endl << "请大家查看身份牌......" << endl;
        Sleep(45);
        srand(time(0));
        MY = rand() % n + 1;
        cout << "您的身份是:" << player[MY].name << endl;
        Sleep(500);
        cout << "在" << player[MY].num << "号位上" << endl;
        system("pause");
        system("cls");
        player[MY].know = 2;
        print(1, 0);
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night();
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(2, 0);
        system("cls");
        print(2, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(2, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(3, 0);
        system("cls");
        print(3, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(3, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(4, 0);
        system("cls");
        print(4, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(4, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(5, 0);
        system("cls");
        print(5, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(5, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(6, 0);
        system("cls");
        print(6, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        cout << "即将进入夜晚";
        for (int i = 1; i <= 6; i++)
        {
            cout << ".";
            Sleep(500);
        }
        night2(6, 1);
        print1();
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        if (player[lieren].life == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        toupiao(7, 0);
        system("cls");
        print(7, 0);
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        else if (player[lieren].life == 0 && lr == 0)
        {
            panduanlieren();
        }
        if (game_over())
        {
            Sleep(1000);
            system("cls");
            cout << "游戏结束" << endl; printhhh();
            return 0;
        }
        while (1)
            system("pause");
        return 0;
    }
    
    
    
    
    #include<windows.h>
    #include<conio.h>
    #define cl system("cls")
    #define wt Sleep(1000)
    #define swt Sleep(667)
    #define ssw Sleep(333)
    #define sr srand((rand()+1)*time(NULL)+expr+nowtime+1);
    #define ll long long
    #define INF 0x3f3f3f3f
    #define mx(a,b) ((a)>(b)?(a):(b))
    #define mn(a,b) ((a)<(b)?(a):(b))
    using namespace std;
    ll hp,atk,dmg,lev,mhp,matk,expr,ndexp,skexp,wpexp;
    ll hpx,atkx,mhpx,matkx,levx,dmgx;
    ll rd;
    ll nowtime=time(NULL);
    string code,str;
    char wd[10]={'[',']','|','\\','`','^','_','{','}','~'};
    char c;
    string opt;
    vector<int> sk,csk,wp,cwp;
    int nowsk,nowskx,nowene,enecount=4,nowwp,nwp;
    bool err,fsk[20],fwp[20];
    bool outloop;
    int sklist[50]={0,0,0,0,1,1,1,2,2,3,3,4},skcount=11;
    int wplist[50]={0,0,0,0,0,1,1,1,1,2,2},wpcount=10;
    struct skills
    {
    	string name;
    	double mul;
    	int type;
    };
    struct weapons
    {
    	string name;
    	double mul;
    	int color;
    };
    struct enemy
    {
    	int boss;
    	string say,dsay;
    	string name;
    	int namelg;
    	int sklg;
    	string skx[105];
    	double mulx[105];
    	int lhp,latk,lexp;
    	int mode;
    };
    struct elem
    {
    	string name;
    	int color;
    	int mix[7];
    };
    skills skl[20]={{},{"拳",1,0},{"脚",1.2,0},{"劈",1.1,1},{"回血",1,2}};
    weapons wpl[20]={{},{"木剑",1,7},{"铁剑",1.2,7},{"静水流涌之辉",10.13,9},{"万世流涌大典",12.18,9}};
    enemy e[11]={{},
    {0,"\"我是逆蝶~\"","","逆蝶",4,2,{"","创","扎"},{0,1,1.1},50,5,100,1},
    {0,"\"你猜我为什么叫赌徒?\"","","赌徒",4,3,{"","拳","掌","枪"},{0,0.8,1,11.45},80,5,250,2},
    {2,"\"玩恶魔轮盘赌吗?\"","\"你赢了,这是你应得的\"","赌神[BOSS]",10,6,{"","空弹","空弹","水弹","实弹","实弹","实弹"},{0,0,0,0.15,0.8,0.8,0.8},6,1,2500,2},
    {1,"\"鸡蛋鸭蛋荷包蛋,我全都爱吃~\"","\"柠檬熟了...\"","刘土墨[伪BOSS]",14,1,{"","射击"},{0,-11.45},250,100,1145,1}};
    elem ele[8]={{"风",11,{}},{"岩",6,{}},{"雷",5,{}},{"草",10,{}},{"水",1,{}},{"火",4,{}},{"冰",3,{}},{"物",7,{}}};
    void start();
    void hurt(int,int);
    void showhp();
    void fight(int,ll);
    void rdup();
    string getcode();
    void incode(string);
    char apb(int);
    int getc(char);
    int bwd(char);
    ll pw(int,int);
    void swapsk();
    void getsk(); 
    void changewp();
    void getwp();
    void setpos(int,int);
    void setcolor(int);
    bool havesk(int);
    bool havewp(int);
    int main()
    {
    	start();
    	nowtime=time(NULL);
    	while(true)
    	{
    		cl;
    		if(nowtime!=time(NULL))
    		{
    			expr+=(time(NULL)-nowtime)*ndexp/100;
    			cout<<"在线经验增加 "<<(time(NULL)-nowtime)*ndexp/100<<" 点"<<endl;
    			nowtime=time(NULL);
    			swt;
    			cl;
    		}
    		cout<<"请选择接下来的操作:1)升级 2)技能 3)武器 4)打怪 5)获取存档码 6)输入存档码"<<endl;
    		while(true)
    		{
    			if(kbhit())
    			{
    				c=_getch();
    				if(c=='1')
    				{
    					cout<<"加载中"<<endl;
    					ssw;
    					cl;
    					rdup();
    					break;
    				}
    				if(c=='2')
    				{
    					cout<<"加载中"<<endl;
    					ssw;
    					outloop=false;
    					while(true)
    					{
    						cl;
    						skexp=(sk.size()-1)*300;
    						cout<<"当前技能:"<<endl;
    						for(int i=1;i<sk.size();i++)
    						{
    							cout<<i<<":"<<skl[sk[i]].name<<endl;
    						}
    						cout<<"升级所需经验: "<<skexp<<endl;
    						cout<<"当前经验: "<<expr<<endl;
    						swt;
    						cout<<"请选择接下来的操作 1)切换技能位置 2)抽取技能 3)离开"<<endl;
    						while(true)
    						{
    							if(kbhit())
    							{
    								c=_getch();
    								if(c=='1')
    								{
    									cout<<"请输入切换技能的编号"<<endl;
    									swapsk();
    									break;
    								}
    								if(c=='2')
    								{
    									if(expr>=skexp)
    									{
    										expr-=skexp;
    										getsk();
    									}
    									else
    									{
    										cout<<"经验不足"<<endl;
    										wt;
    										cl;
    									}
    									break;
    								}
    								if(c=='3')
    								{
    									cl;
    									outloop=true;
    									break;
    								}
    							}
    						}
    						if(outloop)
    						{
    							break;
    						}
    					}
    					break;
    				}
    				if(c=='3')
    				{
    					cout<<"加载中"<<endl;
    					ssw;
    					outloop=false;
    					while(true)
    					{
    						cl;
    						wpexp=(wp.size()-1)*300;
    						cout<<"当前武器:"<<endl;
    						setcolor(wpl[wp[nowwp]].color);
    						cout<<wpl[wp[nowwp]].name<<endl;
    						setcolor(7);
    						cout<<"已有武器:"<<endl;
    						for(int i=1;i<wp.size();i++)
    						{
    							cout<<i<<":";
    							setcolor(wpl[wp[i]].color);
    							cout<<wpl[wp[i]].name<<endl;
    							setcolor(7);
    						}
    						cout<<"抽武器所需经验:"<<wpexp<<endl;
    						cout<<"当前经验:"<<expr<<endl;
    						swt;
    						cout<<"请输入接下来的操作 1)切换武器 2)抽取武器 3)离开"<<endl;
    						while(true)
    						{
    							if(kbhit())
    							{
    								c=_getch();
    								if(c=='1')
    								{
    									cout<<"请输入切换武器的编号"<<endl;
    									changewp();
    									break;
    								}
    								if(c=='2')
    								{
    									if(expr>=wpexp)
    									{
    										expr-=wpexp;
    										getwp();
    									}
    									else
    									{
    										cout<<"经验不足"<<endl;
    										wt;
    										cl;
    									}
    									break;
    								}
    								if(c=='3')
    								{
    									cl;
    									outloop=true;
    									break;
    								}
    							}
    						}
    						if(outloop)
    						{
    							break;
    						}
    					}
    					break;
    				}
    				if(c=='4')
    				{
    					outloop=false;
    					cout<<"加载中"<<endl;
    					ssw;
    					cl;
    					cout<<"请输入要挑战的敌人 ";
    					for(int i=1;i<=enecount;i++)
    					{
    						cout<<i<<")"<<e[i].name<<" ";
    					}
    					cout<<enecount+1<<")退出";
    					cout<<endl;
    					while(true)
    					{
    						if(kbhit())
    						{
    							c=_getch();
    							if(c==enecount+1+48)
    							{
    								outloop=true;
    								break;
    							}
    							for(int i=1;i<=enecount;i++)
    							{
    								if(c==i+48)
    								{
    									if(e[i].boss==0)
    									{
    										cout<<"请输入敌人等级:"<<endl;
    										cin>>levx;
    										if(1<=levx&&levx<=1e10)
    										{
    											fight(i,levx);
    										}
    										else
    										{
    											cout<<"无效操作"<<endl; 
    										}
    										outloop=true;
    										break;
    									}
    									if(e[i].boss==1||e[i].boss==2)
    									{
    										fight(i,1);
    										outloop=true;
    										break;
    									}
    								}
    							}
    						}
    						if(outloop)
    						{
    							break;
    						}
    					}
    					if(outloop)
    					{
    						break;
    					}
    				}
    				if(c=='5')
    				{
    					cout<<"加载中"<<endl;
    					ssw;
    					cl;
    					cout<<"以下是存档码: "<<endl;
    					cout<<getcode()<<endl;
    					return 0;
    				}
    				if(c=='6')
    				{
    					cout<<"加载中"<<endl;
    					ssw;
    					cl;
    					cout<<"请输入存档码: "<<endl;
    					cin>>str;
    					incode(str);
    					if(err==true)
    					{
    						cout<<"存档码错误"<<endl;
    						wt;
    					}
    					else
    					{
    						if(nowwp!=0)
    						{
    							nowwp=nwp;
    						}
    						sk.clear();
    						sk.push_back(0);
    						for(int i=0;i<csk.size();i++)
    						{
    							sk.push_back(csk[i]);
    						}
    						wp.clear();
    						wp.push_back(3);
    						for(int i=0;i<cwp.size();i++)
    						{
    							wp.push_back(cwp[i]);
    						}
    					}
    					cl;
    					break;
    				}
    			}
    		}
    	}
    	return 0;
    }
    void start()
    {
    	lev=1;
    	ndexp=lev*300;
    	skexp=300;
    	wpexp=300;
    	expr=0;
    	mhp=128;
    	matk=16;
    	sk.push_back(0);
    	sk.push_back(1);
    	wp.push_back(3);
    	wp.push_back(1);
    	nowwp=1;
    }
    void hurt(ll d,int t,int s)
    {
    	if(t==1)
    	{
    		cout<<"你";
    		if(skl[sk[s]].type==1)
    		{
    			cout<<"拿起";
    			setcolor(wpl[wp[nowwp]].color);
    			cout<<"["<<wpl[wp[nowwp]].name<<"]";
    			setcolor(7);
    			cout<<",";
    		}
    		cout<<"使用了";
    		if(wp[nowwp]==3)
    		{
    			if(skl[sk[s]].type==1)
    			{
    				setcolor(9);
    				cout<<"[独舞之邀]";
    				setcolor(7);
    			}
    			else
    			{
    				if(skl[sk[s]].type==2)
    				{
    					setcolor(9);
    					cout<<"[孤心沙龙]";
    					setcolor(7);
    				}
    				else
    				{
    					cout<<"["<<skl[sk[s]].name<<"]";
    				}
    			}
    		}
    		else
    		{
    			cout<<"["<<skl[sk[s]].name<<"]";
    		}
    		if(skl[sk[nowsk]].type==2&&e[nowene].boss!=2)
    		{
    			cout<<"回复了 "<<d<<" 点血量"<<endl;
    		}
    		else
    		{
    			if(e[nowene].boss==2&&skl[sk[s]].name!="拳")
    			{
    				cout<<endl;
    				cout<<"但被 "<<e[nowene].name<<" 强制更改为了[拳],"<<endl;
    			}
    			cout<<"对 "<<e[nowene].name<<" 造成了 "<<d<<" 点伤害"<<endl;
    		}
    	}
    	else
    	{
    		cout<<e[nowene].name<<" 使用了["<<e[nowene].skx[nowskx]<<"],";
    		cout<<"对你造成了 "<<d<<" 点伤害"<<endl;
    	}
    }
    void showhp()
    {
    	hp=mn(hp,mhp);
    	hpx=mn(hpx,mhpx);
    	int sh=mx(0,mx(int(sh>0),hp*40/mhp));
    	int shx=mx(0,mx(int(shx>0),hpx*40/mhpx));
    	setcolor(7);
    	cout<<"你的血量:";
    	for(int i=1;i<=e[nowene].namelg;i++)
    	{
    		cout<<" ";
    	}
    	cout<<"(";
    	setcolor(4);
    	for(int i=1;i<=sh/2;i++)
    	{
    		cout<<"#";
    	}
    	if(sh%2==1)
    	{
    		cout<<"_";
    	}
    	for(int i=1;i<=20-sh/2-(sh%2==1);i++)
    	{
    		cout<<" ";
    	}
    	setcolor(7);
    	cout<<")";
    	cout<<endl;
    	cout<<e[nowene].name<<" 的血量: (";
    	setcolor(4);
    	for(int i=1;i<=shx/2;i++)
    	{
    		cout<<"#";
    	}
    	if(shx%2==1)
    	{
    		cout<<"_";
    	}
    	for(int i=1;i<=20-shx/2-(shx%2==1);i++)
    	{
    		cout<<" ";
    	}
    	setcolor(7);
    	cout<<")";
    	cout<<endl;
    }
    void fight(int ene,ll elev)
    {
    	cl;
    	nowene=ene;
    	nowsk=1;
    	nowskx=1;
    	hp=mhp;
    	atk=matk;
    	cout<<e[ene].say<<endl;
    	swt;
    	if(e[ene].boss==0||e[ene].boss==1)
    	{
    		mhpx=e[ene].lhp*elev,matkx=e[ene].latk*elev;
    		hpx=mhpx,atkx=matkx;
    	}
    	if(e[ene].boss==2)
    	{
    		mhpx=(e[ene].lhp+0.5)*matk,matkx=e[ene].latk*mhp;
    		hpx=mhpx,atkx=matkx;
    	}
    	while(hpx>0&&hp>0)
    	{
    		if(e[ene].boss==2)
    		{
    			dmg=atk;
    		}
    		else
    		{
    			if(skl[sk[nowsk]].type==0)
    			{
    				dmg=skl[sk[nowsk]].mul*atk;
    			}
    			if(skl[sk[nowsk]].type==1)
    			{
    				dmg=(skl[sk[nowsk]].mul*wpl[wp[nowwp]].mul)*atk;
    			}
    			if(skl[sk[nowsk]].type==2)
    			{
    				if(wp[nowwp]==3)
    				{
    					dmg=10.13*atk;
    				}
    				else
    				{
    					dmg=skl[sk[nowsk]].mul*atk;
    				}
    				
    			}
    		}
    		dmgx=e[ene].mulx[nowskx]*matkx;
    		if(skl[sk[nowsk]].type==2&&e[ene].boss!=2)
    		{
    			hp+=dmg;
    		}
    		else
    		{
    			hpx-=dmg;
    		}
    		hurt(dmg,1,nowsk);
    		showhp();
    		if(hpx<=0)
    		{
    			swt;
    			break;
    		}
    		if(e[ene].boss==0)
    		{
    			swt;
    		}
    		if(e[ene].boss==1||e[ene].boss==2)
    		{
    			wt;
    		}
    		hp-=dmgx;
    		hurt(dmgx,0,0);
    		showhp();
    		if(e[ene].boss==0)
    		{
    			swt;
    		}
    		if(e[ene].boss==1||e[ene].boss==2)
    		{
    			wt;
    		}
    		nowsk=nowsk%(sk.size()-1)+1;
    		if(e[ene].mode==1)
    		{
    			nowskx=nowskx%(e[ene].sklg)+1;
    		}
    		if(e[ene].mode==2)
    		{
    			sr;
    			nowskx=rand()%e[ene].sklg+1;
    		}
    	}
    	if(hp>0)
    	{
    		if(e[ene].dsay!="")
    		{
    			cout<<e[ene].dsay<<endl;
    			wt;
    		}
    		cout<<"你胜利了"<<endl;
    		if(e[ene].boss==0)
    		{
    			expr+=levx*e[ene].lexp;
    			cout<<"你获得了 "<<levx*e[ene].lexp<<" 点经验"<<endl;
    		}
    		if(e[ene].boss==1)
    		{
    			expr+=e[ene].lexp;
    			cout<<"你获得了 "<<e[ene].lexp<<" 点经验"<<endl;
    		}
    		if(e[ene].boss==2)
    		{
    			expr+=lev*e[ene].lexp;
    			cout<<"你获得了 "<<lev*e[ene].lexp<<" 点经验"<<endl;
    		}
    	}
    	else
    	{
    		cout<<"你失败了"<<endl;
    	}
    	wt;
    	cl;
    }
    void up()
    {
    	if(expr>=ndexp)
    	{
    		expr-=ndexp;
    		lev+=1;
    		ndexp=lev*(200+5*sqrt(lev));
    		mhp+=64+int(sqrt(mhp));
    		matk+=8+int(sqrt(matk));
    	}
    	else
    	{
    		cout<<"经验不足"<<endl;
    		wt;
    	}
    }
    void rdup()
    {
    	ru:	
    	cout<<"等级: "<<lev<<endl;
    	cout<<"血量: "<<mhp<<endl;
    	cout<<"攻击: "<<matk<<endl;
    	cout<<"经验: "<<expr<<endl;
    	cout<<"升级所需经验: "<<ndexp<<endl;
    	swt;
    	cout<<"是否升级? 1)升级 2)离开"<<endl;
    	while(true)
    	{
    		if(kbhit())
    		{
    			c=_getch();
    			if(c=='1')
    			{
    				up();
    				cl;
    				goto ru;
    				break;
    			}
    			if(c=='2')
    			{
    				cl;
    				return;
    			}
    		}
    	}
    }
    string getcode()
    {
    	code="";
    	sr;
    	rd=rand();
    	ll lx=lev+114514+rd*13;
    	ll hx=mhp+1919+rd*11;
    	ll ax=matk+810+rd*9;
    	ll ex=expr+182376+rd*7;
    	ll nx=ndexp+1013+rd*5;
    	ll skex=skexp+114+rd*18;
    	ll nwpx=max(1,nowwp)+376+rd*rd;
    	ll skx=0;
    	ll wpx=0;
    	for(int i=1;i<sk.size();i++)
    	{
    		skx*=11;
    		skx+=11*sk[i];
    	}
    	skx+=514+rd*10;
    	for(int i=1;i<wp.size();i++)
    	{
    		wpx*=11;
    		wpx+=11*wp[i];
    	}
    	wpx+=182+rd*14;
    	while(lx!=0)
    	{
    		code+=apb(lx%84);
    		lx/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(hx!=0)
    	{
    		code+=apb(hx%84);
    		hx/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(ax!=0)
    	{
    		code+=apb(ax%84);
    		ax/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(ex!=0)
    	{
    		code+=apb(ex%84);
    		ex/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(nx!=0)
    	{
    		code+=apb(nx%84);
    		nx/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(skex!=0)
    	{
    		code+=apb(skex%84);
    		skex/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(skx!=0)
    	{
    		code+=apb(skx%84);
    		skx/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(wpx!=0)
    	{
    		code+=apb(wpx%84);
    		wpx/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(nwpx!=0)
    	{
    		code+=apb(nwpx%84);
    		nwpx/=84;
    	}
    	sr;
    	code+=wd[rand()%10];
    	while(rd!=0)
    	{
    		code+=apb(rd%84);
    		rd/=84;
    	}
    	return code;
    }
    char apb(int x)
    {
    	if(x<=25)
    	{
    		return char(x+65);
    	}
    	else
    	{
    		if(26<=x&&x<=51)
    		{
    			return char(x+71);
    		}
    		else
    		{
    			return char(x-19);
    		}
    	}
    }
    int getc(char x)
    {
    	int y=int(x);
    	if(bwd(x)!=-1)
    	{
    		return -1;
    	}
    	if(65<=y&&y<=90)
    	{
    		return y-65;
    	}
    	else
    	{
    		if(97<=y&&y<=122)
    		{
    			return y-71;
    		}
    		else
    		{
    			if(33<=y&&y<=64)
    			{
    				return y+19;
    			}
    			else
    			{
    				err=true;
    			}
    		}
    	}
    }
    void incode(string x)
    {
    	csk.clear();
    	cwp.clear();
    	memset(fsk,0,sizeof(fsk));
    	memset(fwp,0,sizeof(fwp));
    	err=false;
    	string s[20];
    	int y=0,z=0;
    	ll lx=0,hx=0,ax=0,ex=0,nx=0,skx=0,skex=0,wpx=0,nwpx=0;
    	for(int i=0;i<x.size();i++)
    	{
    		if(bwd(x[i])!=-1)
    		{
    			y++;
    		}
    		else
    		{
    			s[y]+=x[i];
    		}
    	}
    	if(y!=9)
    	{
    		if(y==10||s[10]=="1013")
    		{
    			nowwp=0;
    		}
    		else
    		{
    			err=true;
    			return;
    		}
    	}
    	for(int i=0;i<s[9].size();i++)
    	{
    		z+=getc(s[9][i])*pw(84,i);
    	}
    	for(int i=0;i<s[0].size();i++)
    	{
    		lx+=getc(s[0][i])*pw(84,i);
    	}
    	lx-=z*13+114514;
    	for(int i=0;i<s[1].size();i++)
    	{
    		hx+=getc(s[1][i])*pw(84,i);
    	}
    	hx-=z*11+1919;
    	for(int i=0;i<s[2].size();i++)
    	{
    		ax+=getc(s[2][i])*pw(84,i);
    	}
    	ax-=z*9+810;
    	for(int i=0;i<s[3].size();i++)
    	{
    		ex+=getc(s[3][i])*pw(84,i);
    	}
    	ex-=z*7+182376;
    	for(int i=0;i<s[4].size();i++)
    	{
    		nx+=getc(s[4][i])*pw(84,i);
    	}
    	nx-=z*5+1013;
    	for(int i=0;i<s[5].size();i++)
    	{
    		skex+=getc(s[5][i])*pw(84,i);
    	}
    	skex-=z*18+114;
    	for(int i=0;i<s[6].size();i++)
    	{
    		skx+=getc(s[6][i])*pw(84,i);
    	}
    	skx-=z*10+514;
    	for(int i=0;i<s[7].size();i++)
    	{
    		wpx+=getc(s[7][i])*pw(84,i);
    	}
    	wpx-=z*14+182;
    	for(int i=0;i<s[8].size();i++)
    	{
    		nwpx+=getc(s[8][i])*pw(84,i);
    	}
    	nwpx-=z*z+376;
    	nwp=nwpx;
    	int t=0;
    	ll skxx=skx;
    	while(skxx!=0)
    	{
    		skxx/=11;
    		csk.push_back(0);
    	}
    	csk.pop_back();
    	while(skx!=0)
    	{
    		if(fsk[skx%11]==true)
    		{
    			err=true;
    			return;
    		}
    		fsk[skx%11]=true;
    		csk[csk.size()-t]=skx%11;
    		skx/=11;
    		t++;
    	}
    	t=0;
    	ll wpxx=wpx;
    	while(wpxx!=0)
    	{
    		wpxx/=11;
    		cwp.push_back(0);
    	}
    	cwp.pop_back();
    	while(wpx!=0)
    	{
    		if(fwp[wpx%11]==true)
    		{
    			err=true;
    			return;
    		}
    		fwp[wpx%11]=true;
    		cwp[cwp.size()-t]=wpx%11;
    		wpx/=11;
    		t++;
    	}
    	if(lx<=0||hx<=0||ax<=0||ex<0||nx<=0||skex<=0||nwp<0||nwp>cwp.size())
    	{
    		err=true;
    		return;
    	}
    	else
    	{
    		lev=lx,mhp=hx,matk=ax,expr=ex,ndexp=nx,skexp=skex;
    	}
    }
    int bwd(char x)
    {
    	for(int i=0;i<=9;i++)
    	{
    		if(x==wd[i])
    		{
    			return i;
    		}
    	}
    	return -1;
    }
    ll pw(int x,int y)
    {
    	ll z=1;
    	for(int i=1;i<=y;i++)
    	{
    		z*=x;
    	}
    	return z;
    }
    void swapsk()
    {
    	int x=0,y=0;
    	cout<<"请输入第一个技能:"<<endl;
    	cin>>x;
    	cout<<"请输入第二个技能:"<<endl;
    	cin>>y;
    	if(x>=1&&x<sk.size()&&y>=1&&y<sk.size()&&x!=y)
    	{
    		swap(sk[x],sk[y]);
    		cout<<"切换技能成功"<<endl;
    		swt;
    		cl;
    		return;
    	}
    	if(x>=1&&x<sk.size()&&y>=1&&y<sk.size()&&x==y)
    	{
    		cout<<"和自己换?无不无聊啊 (-_-')"<<endl;
    		wt;
    		cl;
    		return;
    	}
    	cout<<"技能切换失败"<<endl;
    	wt;
    	cl;
    }
    void getsk()
    {
    	sr;
    	int t=rand()%skcount+1;
    	if(havesk(sklist[t])==false&&sklist[t]!=0)
    	{
    		cout<<"抽取成功,抽中了技能["<<skl[sklist[t]].name<<"]"<<endl;
    		sk.push_back(sklist[t]);
    		wt;
    		cl;
    	}
    	else
    	{
    		cout<<"抽取失败"<<endl;
    		wt;
    		cl;
    	}
    }
    void changewp()
    {
    	int x=0;
    	cin>>x;
    	if(x>=1&&x<wp.size())
    	{
    		nowwp=x;
    		return;
    	}
    	cout<<"切换武器失败"<<endl;
    	wt;
    	cl;
    }
    void getwp()
    {
    	sr;
    	int t=rand()%wpcount+1;
    	if(havewp(wplist[t])==false&&wplist[t]!=0)
    	{
    		cout<<"抽取成功,抽中了武器";
    		setcolor(wpl[wplist[t]].color);
    		cout<<"["<<wpl[wplist[t]].name<<"]"<<endl;
    		setcolor(7);
    		wp.push_back(wplist[t]);
    		wt;
    		cl;
    	}
    	else
    	{
    		cout<<"抽取失败"<<endl;
    		wt;
    		cl;
    	}
    }
    void setpos(int x,int y)
    {
    	COORD posx;
    	posx.X=x;
    	posx.Y=y;
    	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),posx);
    }
    void setcolor(int x)
    {
    	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
    }
    bool havesk(int x)
    {
    	for(int i=1;i<sk.size();i++)
    	{
    		if(sk[i]==x)
    		{
    			return true;
    		}
    	}
    	return false;
    }
    bool havewp(int x)
    {
    	for(int i=1;i<wp.size();i++)
    	{
    		if(wp[i]==x)
    		{
    			return true;
    		}
    	}
    	return false;
    }
    /*
    更新日志:
    v0.1.0:
    基础功能
    v0.1.1:
    由于某些人的Dev-C++比较旧,
    就把auto去掉了 
    */
    //iIV}wlK~RKG~q@=tv|z@K|e7G{YjK^%+H^Ye"L{Wf
    
    
    
    
    
  • 通过的题目

  • 最近活动

  • 最近编写的题解

题目标签

语言基础
201
竞赛
118
循环语句
117
动态规划
101
NOIP
84
字符串
84
其他
81
年份
68
搜索
66
字符数组
58
数据结构
56
一维数组
49
贪心
47
选择语句
44
二维数组
44
普及组
42
python
41
语言入门
39
一本通
37
递归
36