地牢游戏

· · 个人记录

目前最新版本: 正式版 2.2.0

V2.2.0 正式版

源代码:

/*
 * 键位更新
 */

#include <windows.h>
#include <conio.h> // getch
#include <bits/stdc++.h>
using namespace std;

namespace _MD5
{
#define A 0x67452301
#define B 0xefcdab89
#define C 0x98badcfe
#define D 0x10325476

    const char str16[] = "0123456789abcdef";

    const unsigned int T[] =
    {
        0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
        0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
        0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
        0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
        0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
        0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
        0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
        0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
        0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
        0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
        0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
        0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
        0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
        0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
        0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
        0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
    };

    const unsigned int s[] = { 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
        5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
        4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
        6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
    };

    class MD5
    {
        private:
            unsigned int tempA, tempB, tempC, tempD, strlength;
        public:
            MD5()
            {
                tempA = A;
                tempB = B;
                tempC = C;
                tempD = D;
                strlength = 0;
            }
            // F函数
            unsigned int F(unsigned int b, unsigned int c, unsigned int d)
            {
                return (b & c) | ((~b) & d);
            }
            // G函数
            unsigned int G(unsigned int b, unsigned int c, unsigned int d)
            {
                return (b & d) | (c & (~d));
            }
            // H函数
            unsigned int H(unsigned int b, unsigned int c, unsigned int d)
            {
                return b ^ c ^ d;
            }
            // I函数
            unsigned int I(unsigned int b, unsigned int c, unsigned int d)
            {
                return c ^ (b | (~d));
            }
            // 移位操作函数
            unsigned int shift(unsigned int a, unsigned int n)
            {
                return (a << n) | (a >> (32 - n));
            }
            // 编码函数
            string encode(string src)
            {
                vector<unsigned int> rec = padding(src);
                for (unsigned int i = 0; i < strlength / 16; i++)
                {
                    unsigned int num[16];
                    for (int j = 0; j < 16; j++)
                    {
                        num[j] = rec[i * 16 + j];
                    }
                    iterateFunc(num, 16);
                }
                return format(tempA) + format(tempB) + format(tempC) + format(tempD);
            }
            // 循环压缩
            void iterateFunc(unsigned int *X, int size = 16)
            {
                unsigned int a = tempA,
                         b = tempB,
                         c = tempC,
                         d = tempD,
                         rec = 0,
                         g, k;
                for (int i = 0; i < 64; i++)
                {
                    if (i < 16)
                    {
                        // F迭代
                        g = F(b, c, d);
                        k = i;
                    }
                    else if (i < 32)
                    {
                        // G迭代
                        g = G(b, c, d);
                        k = (1 + 5 * i) % 16;
                    }
                    else if (i < 48)
                    {
                        // H迭代
                        g = H(b, c, d);
                        k = (5 + 3 * i) % 16;
                    }
                    else
                    {
                        // I迭代
                        g = I(b, c, d);
                        k = (7 * i) % 16;
                    }
                    rec = d;
                    d = c;
                    c = b;
                    b = b + shift(a + g + X[k] + T[i], s[i]);
                    a = rec;
                }
                tempA += a;
                tempB += b;
                tempC += c;
                tempD += d;
            }
            // 填充字符串
            vector<unsigned int> padding(string src)
            {
                // 以512位,64个字节为一组
                unsigned int num = ((src.length() + 8) / 64) + 1;
                vector<unsigned int> rec(num * 16);
                strlength = num * 16;
                for (unsigned int i = 0; i < src.length(); i++)
                {
                    // 一个unsigned int对应4个字节,保存4个字符信息
                    rec[i >> 2] |= (int)(src[i]) << ((i % 4) * 8);
                }
                // 补充1000...000
                rec[src.length() >> 2] |= (0x80 << ((src.length() % 4) * 8));
                // 填充原文长度
                rec[rec.size() - 2] = (src.length() << 3);
                return rec;
            }
            // 整理输出
            string format(unsigned int num)
            {
                string res = "";
                unsigned int base = 1 << 8;
                for (int i = 0; i < 4; i++)
                {
                    string tmp = "";
                    unsigned int b = (num >> (i * 8)) % base & 0xff;
                    for (int j = 0; j < 2; j++)
                    {
                        tmp = str16[b % 16] + tmp;
                        b /= 16;
                    }
                    res += tmp;
                }
                return res;
            }
    };
}
using namespace _MD5;

// 常量区
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
int dx[] = {-1, 1, 0, 0, 0}, dy[] = {0, 0, -1, 1, 0};
const int LEFT = 2, RIGHT = 1, UP = 8, DOWN = 4, STILL = 0;
const int PLAYER = 0, MONSTER = 1, BULLET = 2;
vector<int> inv =
{
    -1
};
vector<int> nomove =
{
    5
};
#define LINE 10 // 区块行数
#define COL 10 // 区块列数
#define WLINE 10 // 地图行数
#define WCOL 10 // 地图列数
#define DIM 3 // 维度总数
#define SUCCESS 0
#define FAIL 1

// 类型定义区
#define mtime_t unsigned long long // 精确到毫秒的时间单位定义
class Cursor // 控制台光标移动
{
    protected:
        stack<COORD> pre;
    public:
        Cursor()
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(hOut, &csbi);
            pre.push(csbi.dwCursorPosition);
        }
        void Goto(int x, int y)
        {
            pre.push({x, y});
            SetConsoleCursorPosition(hOut, pre.top());
        }
        BOOL Back()
        {
            if (pre.empty())
                return FAIL;
            pre.pop();
            if (pre.empty())
                return FAIL;
            SetConsoleCursorPosition(hOut, pre.top());
        }
        BOOL Empty()
        {
            return pre.empty();
        }
};
struct pos // 位置结构体
{
    int x;
    int y;
    int mapx;
    int mapy;
    int dim;
    string mp[LINE + 5][COL + 5];
    int dir; // bullet
    mtime_t stattm; // bullet
    int tox; // portal
    int toy; // portal
    int tomapx; // portal
    int tomapy; // portal
    int todim; // portal
    bool operator==(pos p)
    {
        return dim == p.dim && x == p.x && y == p.y && mapx == p.mapx && mapy == p.mapy;
    }
};

struct DOC // 存档结构体
{
    string player;
    int level;
    int monsterhp;
    string pas;
    int num;
};

// 变量区
pos monster, player, airdrop/*空投*/, portal[DIM][DIM]; // 传送门 [起始维度][目标维度]
Cursor cur;
vector<pos> bullet;
mtime_t st;
int monsterhp;
int speed;
int teleport = 20;
int level = 0;
int &mx = player.mapx, &my = player.mapy;
int &monx = monster.x, &mony = monster.y;
int &wmx = monster.mapx, &wmy = monster.mapy;
int &x = player.x, &y = player.y;
int bullcnt; // 弹药数量
int clip; // 弹夹数量
bool autoload = false;
bool autotp = false;
bool is_dodge = false;
bool is_defeat = false;
bool is_die = false;
int whole[DIM][WLINE + 5][WCOL + 5];
int cmx = 0, cmy = 0;
string s_dim[DIM] = {"主世界", "炙热域", "寒冰界"};
bool wrote;
mt19937 mt;
map<pair<int, int>, vector<int>> mem;
int numini;MD5 md5;

// 键位
int k_att_u = 'I', k_att_d = 'K', k_att_l = 'J', k_att_r = 'L', 
    k_reload = 'E', k_drop = 'R', k_tp = 'Q', k_ender_pearl = VK_SPACE, k_speed = VK_OEM_1, 
    k_autoreload = 'U', k_autotp = 'O', 
    k_hl_u = VK_UP, k_hl_d = VK_DOWN, k_hl_l = VK_LEFT, k_hl_r = VK_RIGHT,
    k_pl_u = 'W', k_pl_d = 'S', k_pl_l = 'A', k_pl_r = 'D'; // att : attack, hl : highlight, pl : player
int *keymap[19] = {&k_att_d, &k_att_u, &k_att_l, &k_att_r, &k_pl_d, &k_pl_u, &k_pl_l, &k_pl_r, &k_hl_d, &k_hl_u, &k_hl_l, &k_hl_r, &k_autoreload, &k_autotp, &k_drop, &k_ender_pearl, &k_reload, &k_tp, &k_speed};

// 键表
string keymp[256] = {
    "", // 00
    "Mouse Left", // 01
    "Mouse Right", // 02
    "", // 03
    "Mouse Mid", // 04
    "Mouse X1", // 05
    "Mouse X2", // 06
    "", // 07
    "Backspace", // 08
    "Tab", // 09
    "", // 0A
    "", // 0B
    "", // 0C
    "Enter", // 0D
    "", // 0E
    "", // 0F
    "", // 10
    "", // 11
    "", // 12
    "", // 13
    "Caps", // 14
    "", // 15
    "", // 16
    "", // 17
    "", // 18
    "", // 19
    "", // 1A
    "Esc", // 1B
    "", // 1C
    "", // 1D
    "", // 1E
    "", // 1F
    "Space", // 20
    "Pg up", // 21
    "Pg dn", // 22
    "End", // 23
    "Home", // 24
    "Left Arrow", // 25
    "Up Arrow", // 26
    "Right Arrow", // 27
    "Down Arrow", // 28
    "", // 29
    "", // 2A
    "", // 2B
    "", // 2C
    "", // 2D
    "", // 2E
    "", // 2F
    "0", // 30
    "1", // 31
    "2", // 32
    "3", // 33
    "4", // 34
    "5", // 35
    "6", // 36
    "7", // 37
    "8", // 38
    "9", // 39
    "", // 3A
    "", // 3B
    "", // 3C
    "", // 3D
    "", // 3E
    "", // 3F
    "", // 40
    "A", // 41
    "B", // 42
    "C", // 43
    "D", // 44
    "E", // 45
    "F", // 46
    "G", // 47
    "H", // 48
    "I", // 49
    "J", // 4A
    "K", // 4B
    "L", // 4C
    "M", // 4D
    "N", // 4E
    "O", // 4F
    "P", // 50
    "Q", // 51
    "R", // 52
    "S", // 53
    "T", // 54
    "U", // 55
    "V", // 56
    "W", // 57
    "X", // 58
    "Y", // 59
    "Z", // 5A
    "", // 5B
    "", // 5C
    "", // 5D
    "", // 5E
    "", // 5F
    "Num 0", // 60
    "Num 1", // 61
    "Num 2", // 62
    "Num 3", // 63
    "Num 4", // 64
    "Num 5", // 65
    "Num 6", // 66
    "Num 7", // 67
    "Num 8", // 68
    "Num 9", // 69
    "Num *", // 6A
    "Num +", // 6B
    "", // 6C
    "Num -", // 6D
    "Num .", // 6E
    "Num /", // 6F
    "F1", // 70
    "F2", // 71
    "F3", // 72
    "F4", // 73
    "F5", // 74
    "F6", // 75
    "F7", // 76
    "F8", // 77
    "F9", // 78
    "F10", // 79
    "F11", // 7A
    "F12", // 7B
    "F13", // 7C
    "F14", // 7D
    "F15", // 7E
    "F16", // 7F
    "F17", // 80
    "F18", // 81
    "F19", // 82
    "F20", // 83
    "F21", // 84
    "F22", // 85
    "F23", // 86
    "F24", // 87
    "", // 88
    "", // 89
    "", // 8A
    "", // 8B
    "", // 8C
    "", // 8D
    "", // 8E
    "", // 8F
    "Num Lock", // 90
    "Scroll Lock", // 91
    "", // 92
    "", // 93
    "", // 94
    "", // 95
    "", // 96
    "", // 97
    "", // 98
    "", // 99
    "", // 9A
    "", // 9B
    "", // 9C
    "", // 9D
    "", // 9E
    "", // 9F
    "Left Shift", // A0
    "Right Shift", // A1
    "Left Ctrl", // A2
    "Right Ctrl", // A3
    "Left Alt", // A4
    "Right Alt", // A5
    "", // A6
    "", // A7
    "", // A8
    "", // A9
    "", // AA
    "", // AB
    "", // AC
    "", // AD
    "", // AE
    "", // AF
    "", // B0
    "", // B1
    "", // B2
    "", // B3
    "", // B4
    "", // B5
    "", // B6
    "", // B7
    "", // B8
    "", // B9
    ";", // BA
    "=", // BB
    ",", // BC
    "-", // BD
    ".", // BE
    "/", // BF
    "`", // C0
    "", // C1
    "", // C2
    "", // C3
    "", // C4
    "", // C5
    "", // C6
    "", // C7
    "", // C8
    "", // C9
    "", // CA
    "", // CB
    "", // CC
    "", // CD
    "", // CE
    "", // CF
    "", // D0
    "", // D1
    "", // D2
    "", // D3
    "", // D4
    "", // D5
    "", // D6
    "", // D7
    "", // D8
    "", // D9
    "", // DA
    "[", // DB
    "\\", // DC
    "]", // DD
    "'", // DE
    "", // DF
    "", // E0
    "", // E1
    "", // E2
    "", // E3
    "", // E4
    "", // E5
    "", // E6
    "", // E7
    "", // E8
    "", // E9
    "", // EA
    "", // EB
    "", // EC
    "", // ED
    "", // EE
    "", // EF
    "", // F0
    "", // F1
    "", // F2
    "", // F3
    "", // F4
    "", // F5
    "", // F6
    "", // F7
    "", // F8
    "", // F9
    "", // FA
    "", // FB
    "", // FC
    "", // FD
    "", // FE
    "", // FF
};
vector<int> prockeys;

// 预处理函数区
#define kd(vk) (GetAsyncKeyState(vk) & 0x8000 ? 1 : 0)
#define SetColor(attr) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (attr))
#define defmap(n, b) void map##n(int ismon = false, int bn = 0)\
{\
    for (int i = 1; i <= LINE; i++)\
    {\
        for (int j = 1; j <= COL; j++)\
        {\
            if (b == 1)\
            {\
                if (ismon == 1) monster.mp[i][j] = "墙";\
                else if (ismon == 2) bullet[bn].mp[i][j] = "墙";\
                else player.mp[i][j] = "墙";\
            }\
            else\
            {\
                if (ismon) monster.mp[i][j] = "  ";\
                else if (ismon == 2) bullet[bn].mp[i][j] = "  ";\
                else player.mp[i][j] = "  ";\
            }\
        }\
    }\
}
#define prockeyspush prockeys.push_back
#define map(n) map##n()
#define defifmp(k) if(n == k) map##k(1);
#define bullmp(k, bn) if(n == k) map##k(2, bn);
#define IF(q) if (n == q)\
{\
    map##q();\
    for (int i = 1; i <= LINE; i++)\
    {\
        for (int j = 1; j <= COL; j++)\
        {\
            int isbull = false;\
            for (int k = 0; k < bullet.size(); k++)\
                if (i == bullet[k].x && j == bullet[k].y && mx == bullet[k].mapx && my == bullet[k].mapy && bullet[k].dir != -1)\
            {\
                isbull = bullet[k].dir == UP || bullet[k].dir == DOWN ? 1 : 2;\
                break;\
            }\
            SetColor(player.mp[i][j] == "墙" ? 0xf0 : i == x && j == y ? 0xc0 : i == monx && j == mony && mx == wmx && my == wmy ? 0xa0 : isbull ? 0x0e : i == airdrop.x && j == airdrop.y && mx == airdrop.mapx && my == airdrop.mapy ? BACKGROUND_BLUE | 0x80 : 0x07);\
            cout << (isbull == 1 ? "||" : isbull == 2 ? "==" : "  ");\
        }\
        cout << endl;\
    }\
}

// 函数定义区
defmap(0, (i == 1 || i == 10) && (j == 1 || j == 10)) // 各种地图
defmap(1, j == 10 || (j == 1 && (i == 1 || i == 10)))
defmap(2, j == 1 || (j == 10 && (i == 1 || i == 10)))
defmap(3, j == 1 || j == 10)
defmap(4, i == 10 || (i == 1 && (j == 1 || j == 10)))
defmap(5, i == 10 || j == 10 || (i == 1 && j == 1))
defmap(6, i == 10 || j == 1 || (i == 1 && j == 10))
defmap(7, i == 10 || j == 1 || j == 10)
defmap(8, i == 1 || (i == 10 && (j == 1 || j == 10)))
defmap(9, i == 1 || j == 10 || (i == 10 && j == 1))
defmap(10, i == 1 || j == 1 || (i == 10 && j == 10))
defmap(11, i == 1 || j == 1 || j == 10)
defmap(12, i == 1 || i == 10)
defmap(13, i == 1 || i == 10 || j == 10)
defmap(14, i == 1 || i == 10 || j == 1)
defmap(15, i == 1 || i == 10 || j == 1 || j == 10)
void monstermap(int n) // 控制怪物地图
{
    defifmp(0)
    defifmp(1)
    defifmp(2)
    defifmp(3)
    defifmp(4)
    defifmp(5)
    defifmp(6)
    defifmp(8)
    defifmp(9)
    defifmp(10)
    defifmp(11)
    defifmp(12)
    defifmp(13)
    defifmp(14)
    defifmp(15)
}
void bulletmap(int n, int bn) // 子弹地图
{
    bullmp(0, bn)
    bullmp(1, bn)
    bullmp(2, bn)
    bullmp(3, bn)
    bullmp(4, bn)
    bullmp(5, bn)
    bullmp(6, bn)
    bullmp(7, bn)
    bullmp(8, bn)
    bullmp(9, bn)
    bullmp(10, bn)
    bullmp(11, bn)
    bullmp(12, bn)
    bullmp(13, bn)
    bullmp(14, bn)
    bullmp(15, bn)
}


mtime_t getmtime() // 精确到毫秒的计时器
{
    SYSTEMTIME st;
    GetSystemTime(&st);
    mtime_t ret = st.wMilliseconds;
    ret += time(NULL) * 1000ull;
    return ret;
}


void debugf(const char *format, ...) // 格式化调试
{
    va_list va;
    va_start(va, format);
    char *buf = new char[1048576];
    vsprintf(buf, format, va);
    string s = buf;
    delete[] buf;
    va_end(va);
    if (format[0] == '@')
        MessageBoxA(NULL, s.data(), "debug", MB_OK);
}

string INIread(string sec, string key, string file = "./config.ini") // 配置文件读取
{
    char *buf = new char[1048576];
    string s(buf, GetPrivateProfileStringA(sec.data(), key.data(), "", buf, 1048576, file.data()));
    delete []buf;
    return s;
}
void nINIwrite(string sec, string key, int &val, string file = "./config.ini") // not write
{
    string tmp = INIread(sec, key);
    val = stoi(tmp);
}
void INIwrite(string sec, string key, string val = "", string file = "./config.ini") // 配置文件写入
{
    WritePrivateProfileStringA(sec.data(), key.data(), val.data(), file.data());
}

void transfer(pos &who, int dim_from, int dim_to) // 传送
{
    if (who == portal[dim_from][dim_to])
    {
        who.dim = portal[dim_from][dim_to].todim;
        who.mapx = portal[dim_from][dim_to].tomapx;
        who.mapy = portal[dim_from][dim_to].tomapy;
        who.x = portal[dim_from][dim_to].tox;
        who.y = portal[dim_from][dim_to].toy;
    }
}
void setwall(int x, int y, int w, int d = 0) // 在某区块设置某方向的墙
{
    whole[d][x][y] |= w;
}
bool mov(int x, int y, int &m = ::x, int &n = ::y, int ismon = false, int bn = 0) // 移动实体 return stucked
{

    if (ismon == MONSTER)
    {
        monstermap(whole[monster.dim][monster.mapx][monster.mapy] & 0xf);
        if (monster.mp[x][y] == "墙")
            return 1;
        m = x, n = y;
        return 0;
    }
    else if (ismon == BULLET)
    {
        bulletmap(whole[bullet[bn].dim][bullet[bn].mapx][bullet[bn].mapy] & 0xf, bn);
        if (bullet[bn].mp[x][y] == "墙")
            return 1;
        m = x, n = y;
        return 0;
    }
    else
    {
        {
            if (player.mp[x][y] == "墙")
                return 1;
            m = x, n = y;
            return 0;
        }
    }
}
void printm(int n) // 输出地图(界面)
{
    IF(0)
    IF(1)
    IF(2)
    IF(3)
    IF(4)
    IF(5)
    IF(6)
    IF(7)
    IF(8)
    IF(9)
    IF(10)
    IF(11)
    IF(12)
    IF(13)
    IF(14)
    IF(15)
    for (int i = 0; i <= WLINE; i++)
    {
        cur.Goto(COL * 2 + 6, i);
        cout << hex;
        for (int j = 0; j <= WCOL; j++)
        {
            SetColor
            (
                (i == mx && j == my ? FOREGROUND_RED : 0x08) |
                (i == wmx && j == wmy ? FOREGROUND_GREEN : 0x08) |
                ((i == airdrop.mapx && j == airdrop.mapy) ? FOREGROUND_BLUE : 0x08) |
                (cmx == i && cmy == j ? 0xf0 : 0x08)
                );
            cout << "[]";
            SetColor(0x07);
        }
        cur.Back();
    }
    cout << dec;
    cur.Goto(COL * 2 + 10 + WCOL * 2, 0);
    cout << "用时: " << time(NULL) - st << " sec.";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 1);
    cout << "怪血: " << monsterhp << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 2);
    cout << "等级: " << level;
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 3);
    cout << "弹药: " << bullcnt << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 4);
    cout << "弹夹: " << clip << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 5);
    cout << "紫颂果: " << teleport << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 6);
    cout << (speed ? "快" : "慢");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 7);
    cout << "自动换弹: " << (level < 5 ? "禁用" : autoload ? "开" : "关");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 8);
    cout << "保命瞬移: " << (level < 7 ? "禁用" : autotp ? "开" : "关");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 9);
    cout << "你当前维度:" << s_dim[player.dim];
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 10);
    cout << "鬼当前维度:" << s_dim[monster.dim];
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 11);
    cout << "高亮区块墙状态 (方向键): ";
    cout << (whole[player.dim][cmx][cmy] & UP ? "上" : "  ");
    cout << (whole[player.dim][cmx][cmy] & DOWN ? "下" : "  ");
    cout << (whole[player.dim][cmx][cmy] & LEFT ? "左" : "  ");
    cout << (whole[player.dim][cmx][cmy] & RIGHT ? "右" : "  ");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 12);
    cout << (wrote ? "记录已保存" : is_dodge ? "闪避      " : is_defeat ? "击退      " : "          ");
    cur.Back();
}
int judge(int &x, int &y, int &mx = ::mx, int &my = ::my) // 判断是否出区块
{
    if (x < 1)
    {
        x = LINE;
        mx--;
        return UP;
    }
    if (y < 1)
    {
        my--;
        y = COL;
        return LEFT;
    }
    if (x > LINE)
    {
        mx++;
        x = 1;
        return DOWN;
    }
    if (y > COL)
    {
        my++;
        y = 1;
        return RIGHT;
    }
    return STILL;
}
vector<int> dfsmap(pos now, pos man) // 怪物单次dfs
{
    vector<int> ret = inv;
    if (man.mapx != now.mapx || man.mapy != now.mapy)
        for (int i = 0; i < 4; i++)
    {
        pos n = now;
        n.mapx += dx[i];
        n.mapy += dy[i];
        pair<int, int> pii = make_pair(n.mapx, n.mapy);
        if (whole[now.dim][now.mapx][now.mapy] & (1 << (3 - i)))
            continue;
        if (whole[now.dim][n.mapx][n.mapy] & 16)
            continue; // 16 : visited
        vector<int> tmp;
        tmp = inv;
        if (mem[pii].empty())
        {
            whole[n.dim][n.mapx][n.mapy] |= 16;
            tmp.clear();
            mem[pii] = tmp = dfsmap(n, man);
            if (tmp == nomove)
            {
                tmp.clear();
                tmp.push_back(i);
            }
            else if (tmp != inv)
                tmp.insert(tmp.begin(), i);
            whole[n.dim][n.mapx][n.mapy] &= ~16;
        }
        else
        {
            tmp.clear();
            tmp = mem[pii];
            if (tmp == nomove)
            {
                tmp.clear();
                tmp.push_back(i);
            }
            else if (tmp != inv)
                tmp.insert(tmp.begin(), i);
        }
        if (ret == inv)
        {
            ret = tmp;
        }
        else if (ret.size() >= tmp.size())
        {
            ret = tmp;
        }
        //          Sleep(2);
    }
    else
    {
        ret.clear();
        ret.push_back(5);
        //      debugf("@finded");
    }
    return ret;
}
vector<int> dfs(pos now, pos man) // 怪物dfs 接下来:和人不同维度就直接奔传送门
{
    for (int d = 0; d < DIM; d++)
    {
        for (int i = 0; i < WLINE; i++)
        {
            for (int j = 0; j < WCOL; j++)
            {
                whole[d][i][j] &= ~16;
            }
        }
    }

    vector<int> ret;
    whole[now.dim][now.mapx][now.mapy] |= 16;
    ret = dfsmap(now, man);
    whole[now.dim][now.mapx][now.mapy] &= ~16;
    return ret;
}
void DelayPrint(string s, int del = 50) // 延时输出
{
    for (auto u : s)
    {
        if (u != '\b')
        {
            putchar(u);
        }
        else
        {
            printf("\b \b");
        }
        Sleep(del);
    }
}
void shoot(int dir) // 射击函数(生成子弹实体)
{
    if (bullcnt == 0)
        return;
    pos b;
    b.x = x;
    b.y = y;
    b.mapx = mx;
    b.mapy = my;
    b.stattm = getmtime();
    b.dir = dir;
    //  debugf("@s");
    bullet.push_back(b);
    Beep(320, 100);
    bullcnt--;
    //  debugf("@OK");
}
bool cmp(DOC m, DOC d) // 比较函数(排名)
{
    return m.level > d.level ? 1 : m.level == d.level ? m.monsterhp < d.monsterhp : 0;
}


void Start(int level, int num)
{
    string f = __FILE__;
    ShellExecuteA(NULL, "open", (f.substr(0, f.size() - 4) + ".exe").data(), (to_string(level) + " " + to_string(num)).data(), NULL, SW_SHOW);
}

// 线程函数区
DWORD WINAPI T_MonsterProc(LPVOID lpIgnore) // 怪物处理线程
{
    pos &me = monster, &man = player;
    // TODO: Process (AI): eat the man
    vector<int> method;
    int num = 0;
    pos lastman = {-1, -1, -1, -1};
    while (1)
    {
        if (is_die) ExitThread(0);
        int delay;
        if (level > 10)
            delay = 5;
        else if (level == 10)
            delay = 10;
        else if (level == 9)
            delay = 15;
        else if (level == 8)
            delay = 20;
        else if (level == 7)
            delay = 25;
        else if (level == 6)
            delay = 30;
        else if (level == 5)
            delay = 35;
        else if (level == 4)
            delay = 40;
        else if (level == 3)
            delay = 45;
        else if (level == 2)
            delay = 50;
        else if (level == 1)
            delay = 55;
        else
            delay = 100;
        delay *= 2;
        if (lastman.mapx != man.mapx || lastman.mapy != man.mapy)
        {
            //          debugf("@ifmethod");
            lastman = man;
            mem.clear();
            debugf("dfs start");
            method = dfs(me, man);
            debugf("dfs end, size %d, isinv %d", method.size(), method == inv);
            while (method == inv && (lastman.mapx == man.mapx && lastman.mapy == man.mapy))
            {
                mem.clear();
                debugf("dfs start");

                method = dfs(me, {me.x + (me.x == LINE ? -1 : 1), me.y + (me.y == COL ? -1 : 1), me.mapx, me.mapy});
                //              debugf("@dfs end, size %d, isinv %d", method.size(), method == inv);
                mem.clear();
                debugf("dfs start");
                method = dfs(me, man);
                //              debugf("@dfs end, size %d, isinv %d", method.size(), method == inv);
            }
            num = 0;
        }
        //      lastman = man;
        //      debugf("lastman = man");
        if (num < method.size())
        {
            pos lastme = me;
            while (me.mapx == lastme.mapx && me.mapy == lastme.mapy)

            {
                if (me.mapx == man.mapx && me.mapy == man.mapy)
                {
                    break;
                }
                bool stucked = mov(me.x + dx[method[num]], me.y + dy[method[num]], me.x, me.y, 1);
                debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
                debugf("judge %d", judge(me.x, me.y, me.mapx, me.mapy));
                Sleep(delay);
                if (stucked)
                {
                    int xx = me.x - WLINE / 2, yy = me.y - WCOL / 2;
                    if ((mt() & 1))
                    {
                        mov(me.x, me.y - (yy < 0 ? -1 : yy > 0 ? 1 : 0), me.x, me.y, 1);
                    }
                    else
                    {
                        mov(me.x - (xx < 0 ? -1 : xx > 0 ? 1 : 0), me.y, me.x, me.y, 1);
                    }
                }
            }
            debugf("num++");
            num++;
        }
        else if (me.mapx == man.mapx && me.mapy == man.mapy)
        {
            //          debugf("@elif");
            int xx = me.x - man.x, yy = me.y - man.y;
            if (mt() & 1)
            {
                mov(me.x, me.y - (yy < 0 ? -1 : yy > 0 ? 1 : 0), me.x, me.y, 1);
                debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
            }
            else
            {
                mov(me.x - (xx < 0 ? -1 : xx > 0 ? 1 : 0), me.y, me.x, me.y, 1);
                debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
            }
        }
        else
        {
            //          debugf("@");
        }
        //      else
        //      {
        //          int xx = me.x - WLINE / 2, yy = me.y - WCOL / 2;
        //          if(xx == 0)
        //          {
        //              mov(me.x, me.y - (yy < 0 ? -1 : yy > 0 ? 1 : 0), me.x, me.y, 1);
        //          }
        //          else
        //          {
        //              mov(me.x - (xx < 0 ? -1 : xx > 0 ? 1 : 0), me.y, me.x, me.y, 1);
        //          }
        //      }
        Sleep(delay);
        //      debugf("@@");
    }
}

DWORD WINAPI T_LetBulletFly(LPVOID lpIgnore) // 子弹移动处理线程
{
    mtime_t lastdefeat = 0;
    while (1)
    {
        if (is_die) ExitThread(0);
        for (int i = 0; i < bullet.size(); i++)
        {
            if (is_defeat && getmtime() - lastdefeat >= 20) is_defeat = false;
            if (bullet[i].dir == -1)
                continue;
            mtime_t tim = getmtime();
            int dtim = tim - bullet[i].stattm;
            if (dtim >= 5)
            {
                bullet[i].stattm = tim;
                if (mov(bullet[i].x + dx[bullet[i].dir], bullet[i].y + dy[bullet[i].dir], bullet[i].x, bullet[i].y, 2, i))
                    bullet.erase(bullet.begin() + i);
                debugf("bul %d %d", i, judge(bullet[i].x, bullet[i].y, bullet[i].mapx, bullet[i].mapy));
                if (bullet[i] == monster)
                {
                    if (monsterhp != 0)
                        monsterhp--;
                    if (mt() % (level) == 0) // 击退
                    {
                        lastdefeat = getmtime();
                        is_defeat = true;
                        mov(monster.x + dx[bullet[i].dir], monster.y + dy[bullet[i].dir], monster.x, monster.y, 1);
                        judge(monster.x, monster.y, monster.mapx, monster.mapy);
                    }
                    if (monsterhp != 0) // 中弹提示
                        Beep(650, 100);
                    bullet.erase(bullet.begin() + i);
                }
            }
        }
    }
}
DWORD WINAPI T_WriteMsg(LPVOID lpIgnore) // 保存记录线程
{
    while (1)
    {
        INIwrite(to_string(numini), "level", to_string(level));
        INIwrite(to_string(numini), "mhp", to_string(monsterhp));
        wrote = true;
        Sleep(500);
        wrote = false;
        Sleep(4500);
    }
}

DWORD WINAPI T_GOBeep(LPVOID lpIgnore) // 死亡音效线程
{
    Beep(1234, 1000);
    return 0;
}

DWORD WINAPI T_Shoot(LPVOID lpIgnore) // 射击管理线程(兼管高亮区块)
{
    while (1)
    {
        if (is_die) ExitThread(0);
        //      Sleep(25);
        if ((kd(k_att_u)))
        {
            shoot(0);
        }
        if ((kd(k_att_l)))
        {
            shoot(2);
        }
        if ((kd(k_att_d)))
        {
            shoot(1);
        }
        if ((kd(k_att_r)))
        {
            shoot(3);
        }
        if (kd(k_reload) && clip)
        {
            Sleep(1000);
            bullcnt = 20 * level;
            clip--;
        }
        if (autoload && bullcnt == 0)
        {
            Sleep(1000);
            bullcnt = 20 * level;
            clip--;
        }
        if (level >= 5 && kd(k_autoreload))
        {
            autoload = !autoload;
            Sleep(100);
        }
        if (level >= 7 && kd(k_autotp))
        {
            autotp = !autotp;
            Sleep(100);
        }
        if (kd(k_hl_u))
        {
            if (cmx) cmx--;
            Sleep(100);
        }
        if (kd(k_hl_d))
        {
            if (cmx < WLINE) cmx++;
            Sleep(100);
        }
        if (kd(k_hl_l))
        {
            if (cmy) cmy--;
            Sleep(100);
        }
        if (kd(k_hl_r))
        {
            if (cmy < WCOL) cmy++;
            Sleep(100);
        }
    }
}

DWORD WINAPI T_Move(LPVOID lpInore) // 玩家移动信息处理线程(兼管瞬移、空投、速度)
{
    int &m = x, &n = y;
    while (1)
    {
        if (is_die) ExitThread(0);
        if ((kd(k_pl_u)))
        {
            //          getch();
            mov(m - 1, n);
            judge(x, y);
        }
        if ((kd(k_pl_l)))
        {
            //          getch();
            mov(m, n - 1);
            judge(x, y);
        }
        if ((kd(k_pl_d)))
        {
            //          getch();
            mov(m + 1, n);
            judge(x, y);
        }
        if ((kd(k_pl_r)))
        {
            //          getch();
            mov(m, n + 1);
            judge(x, y);
        }
        if (kd(k_tp))
        {
            //          getch();
            if (teleport != 0)
            {
                player.mapx = mt() % WLINE;
                player.mapy = mt() % WCOL;
                player.x = LINE / 2;
                player.y = COL / 2;
                teleport--;
            }
            Sleep(100);
        }
        if (kd(k_ender_pearl))
        {
            if (teleport >= 5 || teleport < 0)
            {
                player.mapx = cmx;
                player.mapy = cmy;
                player.x = LINE / 2;
                player.y = COL / 2;
                teleport -= 5;
            }
            Sleep(100);
        }
        if (kd(k_drop))
        {
            //          getch();
            airdrop.dim = player.dim;
            airdrop.mapx = mt() % WLINE;
            airdrop.mapy = mt() % WCOL;
            airdrop.x = 1 + mt() % (LINE - 1);
            airdrop.y = 1 + mt() % (COL - 1);
        }
        if (kd(k_speed))
        {
            speed = !speed;
            Sleep(100);
        }
        else Sleep(speed ? 1 : 50);
    }
}

DWORD WINAPI T_Print(LPVOID lpIg) // 界面输出线程
{
    while (1)
    {
        if (is_die) ExitThread(0);
        cur.Goto(0, 0);
        printm(whole[player.dim][mx][my] & 0xf);
        Sleep(10);
    }
}
// 设置GUI
void printGUI(int NowSection = 0, int NowKey = 0, bool edit = 0)
{
    cur.Goto(0, 0);
    system("color 0f & cls");
    cout << "键位设置 (DELETE 编辑)" << endl << "--------" << endl;
    cout << "向下攻击\t";
    if(NowSection == 0 && NowKey == 0) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_att_d] << endl;
    if(NowSection == 0 && NowKey == 0) SetColor(0x0f);
    cout << "向上攻击\t";
    if(NowSection == 0 && NowKey == 1) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_att_u] << endl;
    if(NowSection == 0 && NowKey == 1) SetColor(0x0f);
    cout << "向左攻击\t";
    if(NowSection == 0 && NowKey == 2) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_att_l] << endl;
    if(NowSection == 0 && NowKey == 2) SetColor(0x0f);
    cout << "向右攻击\t";
    if(NowSection == 0 && NowKey == 3) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_att_r] << endl;
    if(NowSection == 0 && NowKey == 3) SetColor(0x0f);
    cout << "向下移动\t";
    if(NowSection == 0 && NowKey == 4) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_pl_d] << endl;
    if(NowSection == 0 && NowKey == 4) SetColor(0x0f);
    cout << "向上移动\t";
    if(NowSection == 0 && NowKey == 5) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_pl_u] << endl;
    if(NowSection == 0 && NowKey == 5) SetColor(0x0f);
    cout << "向左移动\t";
    if(NowSection == 0 && NowKey == 6) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_pl_l] << endl;
    if(NowSection == 0 && NowKey == 6) SetColor(0x0f);
    cout << "向右移动\t";
    if(NowSection == 0 && NowKey == 7) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_pl_r] << endl;
    if(NowSection == 0 && NowKey == 7) SetColor(0x0f);
    cout << "高亮向下\t";
    if(NowSection == 0 && NowKey == 8) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_hl_d] << endl;
    if(NowSection == 0 && NowKey == 8) SetColor(0x0f);
    cout << "高亮向上\t";
    if(NowSection == 0 && NowKey == 9) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_hl_u] << endl;
    if(NowSection == 0 && NowKey == 9) SetColor(0x0f);
    cout << "高亮向左\t";
    if(NowSection == 0 && NowKey == 10) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_hl_l] << endl;
    if(NowSection == 0 && NowKey == 10) SetColor(0x0f);
    cout << "高亮向右\t";
    if(NowSection == 0 && NowKey == 11) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_hl_r] << endl;
    if(NowSection == 0 && NowKey == 11) SetColor(0x0f);
    cout << "自动换弹\t";
    if(NowSection == 0 && NowKey == 12) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_autoreload] << endl;
    if(NowSection == 0 && NowKey == 12) SetColor(0x0f);
    cout << "保命瞬移\t";
    if(NowSection == 0 && NowKey == 13) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_autotp] << endl;
    if(NowSection == 0 && NowKey == 13) SetColor(0x0f);
    cout << "召唤空投\t";
    if(NowSection == 0 && NowKey == 14) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_drop] << endl;
    if(NowSection == 0 && NowKey == 14) SetColor(0x0f);
    cout << "末影珍珠\t";
    if(NowSection == 0 && NowKey == 15) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_ender_pearl] << endl;
    if(NowSection == 0 && NowKey == 15) SetColor(0x0f);
    cout << "补充弹药\t";
    if(NowSection == 0 && NowKey == 16) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_reload] << endl;
    if(NowSection == 0 && NowKey == 16) SetColor(0x0f);
    cout << "随机瞬移\t";
    if(NowSection == 0 && NowKey == 17) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_tp] << endl;
    if(NowSection == 0 && NowKey == 17) SetColor(0x0f);
    cout << "速度切换\t";
    if(NowSection == 0 && NowKey == 18) SetColor(edit ? 0xb0 : 0x70);
        cout << keymp[k_speed] << endl;
    if(NowSection == 0 && NowKey == 18) SetColor(0x0f);
}
void settingGUI()
{
    printGUI();
    int sec = 0, key = 0;
    int totsec = 1;
    vector<int> totkey = {19};
    while(1)
    {
        // TODO: Edit
        if(kd(VK_TAB))
        {
            sec = (sec + 1) % totsec;
            key = 0;
            printGUI(sec, key);
        }
        if(kd(VK_UP))
        {
            key = (key - 1 + totkey[sec]) % totkey[sec];
            printGUI(sec, key);
        }
        if(kd(VK_DOWN))
        {
            key = (key + 1) % totkey[sec];
            printGUI(sec, key);
        }
        if(kd(VK_DELETE))
        {
            printGUI(sec, key, true);
            int keyvk = 0;
            while(1)
            {
                bool f = 1;
                for(auto vk : prockeys)
                {
                    if(kd(vk))
                    {
                        keyvk = vk;
                        f = 0;
                        break;
                    }
                }
                if(f == 0) break;
            }
            *keymap[key] = keyvk;
            printGUI(sec, key);
        }
        if(kd(VK_ESCAPE))
        {
            return;
        }
        Sleep(20);
    }
}
// 主函数
int main(int argc, char *argv[])
{
    DWORD fdwMode;
    GetConsoleMode(hIn, &fdwMode);
    fdwMode |=
    ENABLE_INSERT_MODE;
    fdwMode &= ~ ENABLE_QUICK_EDIT_MODE;
    SetConsoleMode(hIn, fdwMode);
    GetConsoleMode(hOut, &fdwMode);
    fdwMode |=
    ENABLE_INSERT_MODE;
    fdwMode &= ~ ENABLE_QUICK_EDIT_MODE;
    SetConsoleMode(hOut, fdwMode);

    memset(&airdrop, -1, sizeof(airdrop));

    clip = 5; // 开始5弹夹

    if (argc == 1) // 刚点进来,存档管理界面
    {
        int n;
        if (INIread("doc", "num") == "") // 新人,没有配置文件
        {
            n = 0;
            INIwrite("doc", "num", "0");
            // 键位绑定配置
            INIwrite("key", "att_d", to_string(k_att_d));
            INIwrite("key", "att_u", to_string(k_att_u));
            INIwrite("key", "att_l", to_string(k_att_l));
            INIwrite("key", "att_r", to_string(k_att_r));
            INIwrite("key", "atrld", to_string(k_autoreload));
            INIwrite("key", "attp", to_string(k_autotp));
            INIwrite("key", "drp", to_string(k_drop));
            INIwrite("key", "ender", to_string(k_ender_pearl));
            INIwrite("key", "hl_d", to_string(k_hl_d));
            INIwrite("key", "hl_u", to_string(k_hl_u));
            INIwrite("key", "hl_l", to_string(k_hl_l));
            INIwrite("key", "hl_r", to_string(k_hl_r));
            INIwrite("key", "pl_d", to_string(k_pl_d));
            INIwrite("key", "pl_u", to_string(k_pl_u));
            INIwrite("key", "pl_l", to_string(k_pl_l));
            INIwrite("key", "pl_r", to_string(k_pl_r));
            INIwrite("key", "rld", to_string(k_reload));
            INIwrite("key", "tp", to_string(k_tp));
            INIwrite("key", "spd", to_string(k_speed));
        }
        else
        {
            n = stoi(INIread("doc", "num"));
            // 键位绑定配置
            nINIwrite("key", "att_d", (k_att_d));
            nINIwrite("key", "att_u", (k_att_u));
            nINIwrite("key", "att_l", (k_att_l));
            nINIwrite("key", "att_r", (k_att_r));
            nINIwrite("key", "atrld", (k_autoreload));
            nINIwrite("key", "attp", (k_autotp));
            nINIwrite("key", "drp", (k_drop));
            nINIwrite("key", "ender", (k_ender_pearl));
            nINIwrite("key", "hl_d", (k_hl_d));
            nINIwrite("key", "hl_u", (k_hl_u));
            nINIwrite("key", "hl_l", (k_hl_l));
            nINIwrite("key", "hl_r", (k_hl_r));
            nINIwrite("key", "pl_d", (k_pl_d));
            nINIwrite("key", "pl_u", (k_pl_u));
            nINIwrite("key", "pl_l", (k_pl_l));
            nINIwrite("key", "pl_r", (k_pl_r));
            nINIwrite("key", "rld", (k_reload));
            nINIwrite("key", "tp", (k_tp));
            nINIwrite("key", "spd", (k_speed));
        }
        DOC doc[n + 1];
        for (int i = 1; i <= n; i++)
        {
            doc[i].player = INIread(to_string(i), "player");
            doc[i].level = stoi(INIread(to_string(i), "level"));
            doc[i].monsterhp = stoi(INIread(to_string(i), "mhp"));
            doc[i].pas = INIread(to_string(i), "pas");
            doc[i].num = i;
        }
        sort(doc + 1, doc + n + 1, cmp);
        bool N = false, O = false, S = false;
        DelayPrint("地牢 Version 2.2\n", 1);
        if (INIread("program", "version") != "2.2")
        {
            DelayPrint("2.1 New features:\n*\t=) 排名 & 存档\n*\t=) md5加密存档\n*\t人性化的瞬移\n", 1);
            DelayPrint("2.2 News: Keysetting\n", 1);
            INIwrite("program", "version", "2.2");
        }
        docp:
            N = O = S = 0;
            DelayPrint("当前存档:\n", 1);
            DelayPrint("Rank  INI No.  Player         Level   MonsterHpLast\n---------------------------------------------------\n", 1);
            for (int i = 1; i <= n; i++)
            {
                printf("%-5d %-8d %-14s %-7d %-12d\n", i, doc[i].num, doc[i].player.data(), doc[i].level, doc[i].monsterhp);
            }
            DelayPrint("---------------------------------------------------\n新建存档(N)\n打开存档(O)\n选项设置(S)\n", 1);
            while (!N && !O && !S)
            {
                N = kd('N');
                O = kd('O');
                S = kd('S');
            }
            if (N) // 新建存档
            {
                system("cls");
                getch();
                cout << "Player name: \nPassword: ";
                cur.Goto(13, 0);
                string pl;
                getline(cin, pl);
                cur.Back();
                cur.Goto(10, 1);
                string psd;
                getline(cin, psd);
                INIwrite("doc", "num", to_string(n + 1));
                INIwrite(to_string(n + 1), "player", pl);
                INIwrite(to_string(n + 1), "level", "1");
                INIwrite(to_string(n + 1), "mhp", "10");
                INIwrite(to_string(n + 1), "pas", md5.encode(psd));
                // start
                Start(1, n + 1);
            }
            else if (O) // 打开存档
            {
                system("cls");
                getch();
                int num = 0;
                while (num <= 0 || num > n)
                {
                    cout << "Input rank: ";
                    string tmp;
                    getline(cin, tmp);
                    num = stoi(tmp);
                    //              cin.setstate(ios::goodbit);
                }
                cout << "Input password: " << flush;
                string psd;
                getline(cin, psd);
                MD5 md5;
                if (md5.encode(psd) != doc[num].pas)
                {
                    system("cls");
                    goto docp;
                }
                // start
                Start(doc[num].level, doc[num].num);
            }
            else if(S)
            {
                prockeyspush(0x01);
                prockeyspush(0x02);
                prockeyspush(0x04);
                prockeyspush(0x05);
                prockeyspush(0x06);
                prockeyspush(0x08);
                prockeyspush(0x09);
                prockeyspush(0x0d);
                prockeyspush(0x14);
                prockeyspush(0x1b);
                prockeyspush(0x90);
                prockeyspush(0x91);
                for(int i = 0x20; i <= 0x28; i++) prockeyspush(i);
                for(int i = 0x30; i <= 0x39; i++) prockeyspush(i);
                for(int i = 0x41; i <= 0x5a; i++) prockeyspush(i);
                for(int i = 0x60; i <= 0x6b; i++) prockeyspush(i);
                for(int i = 0x6d; i <= 0x87; i++) prockeyspush(i);
                for(int i = 0xa0; i <= 0xa5; i++) prockeyspush(i);
                for(int i = 0xba; i <= 0xc0; i++) prockeyspush(i);
                for(int i = 0xdb; i <= 0xde; i++) prockeyspush(i);
                // 设置界面
                settingGUI();
                system("cls");
                goto docp;
            }
            CloseHandle(hIn);
            return 0;
    }
    else if (argc == 2) return 0; // 不合规矩
    else // 开始吧
    {
        monsterhp = (level = stoi(argv[1])) * 10;
        numini = stoi(argv[2]);
    }
    SetConsoleTitle(level ? ("地牢 Lvl." + to_string(level)).data() : "地牢");
    teleport = level * 2;
    speed = 0;
    inv.resize(WLINE * WCOL + 5);
    fill(inv.begin(), inv.end(), -1);
    string cmd = "mode con cols=" + to_string(COL * 2 + 50 + WCOL * 2) + " lines=" + to_string(max(WLINE, LINE) + 5);
    cout << cmd << endl;
    Sleep(1000);
    system(cmd.data());
    Sleep(1000);
    monx = mony = 5;
    x = y = 2;
    wmx = WLINE;
    wmy = WCOL;
    mt.seed(st = time(NULL));
    int cnt = 0;
    for (int d = DIM - 1; d >= 0; d--) // 生成各维度的地图
    {
        do
        {
            ++cnt;
            if (cnt >= 5)
            {
                Start(level, numini);
                CloseHandle(hIn);
                return 0;
            }
            memset(whole, 0, sizeof whole);
            for (int i = 0; i <= WLINE; i++)
            {
                for (int j = 0; j <= WCOL; j++)
                {
                    if (i == j && j == 0)
                        continue;
                    if (i == WLINE && j == WCOL)
                        continue;
                    setwall(i, j, (mt() % 10 == UP) * UP);
                    setwall(i, j, (mt() % 10 == DOWN) * DOWN);
                    setwall(i, j, (mt() % 10 == LEFT) * LEFT);
                    setwall(i, j, (mt() % 10 == RIGHT) * RIGHT);
                }
            }
            for (int i = 0; i <= WLINE; i++)
            {
                setwall(i, 0, LEFT);
                setwall(i, WCOL, RIGHT);
            }
            for (int i = 0; i <= WCOL; i++)
            {
                setwall(0, i, UP);
                setwall(WLINE, i, DOWN);
            }
            for (int i = 0; i <= WLINE; i++) // 免得穿墙
            {
                for (int j = 0; j <= WCOL; j++)
                {
                    if (i != 0)
                    {
                        setwall(i, j, ((whole[0][i - 1][j] & DOWN) == DOWN) ? UP : 0);
                    }
                    if (i != WLINE)
                    {
                        setwall(i, j, ((whole[0][i + 1][j] & UP) == UP) ? DOWN : 0);
                    }
                    if (j != 0)
                    {
                        setwall(i, j, ((whole[0][i][j - 1] & RIGHT) == RIGHT) ? LEFT : 0);
                    }
                    if (j != WCOL)
                    {
                        setwall(i, j, ((whole[0][i][j + 1] & LEFT) == LEFT) ? RIGHT : 0);
                    }
                }
            }
            cout << '@';
        }
        while (dfs(monster, player) == inv);
        memcpy(whole[d], whole[0], sizeof(whole[d]));
    }

    //keybd_event(VK_LSHIFT, 0, 0, 0); // 帮你按一下shift
    //keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);
    system("cls");
    CreateThread(NULL, 0, T_MonsterProc, NULL, 0, NULL); // 启动线程
    CreateThread(NULL, 0, T_LetBulletFly, NULL, 0, NULL);
    CreateThread(NULL, 0, T_WriteMsg, NULL, 0, NULL);
    CreateThread(NULL, 0, T_Shoot, NULL, 0, NULL);
    CreateThread(NULL, 0, T_Move, NULL, 0, NULL);
    CreateThread(NULL, 0, T_Print, NULL, 0, NULL);
    // TODO
    CONSOLE_CURSOR_INFO cci; // 不显示光标
    GetConsoleCursorInfo(hOut, &cci);
    cci.bVisible = 0;
    SetConsoleCursorInfo(hOut, &cci);
    mtime_t lasthide = 0;
    while (1)
    {
        Sleep(10);
        if (monster == player) // 碰到了
        {
            if (autotp && teleport) // 瞬移
            {
                player.mapx = mt() % WLINE;
                player.mapy = mt() % WCOL;
                player.x = LINE / 2;
                player.y = COL / 2;
                teleport--;
            }
            else if (mt() % (level * 2) >= 2) // 死
                break;
            else // 闪避
            {
                is_dodge = 1;
                lasthide = getmtime();
            }
        }
        if (is_dodge && getmtime() - lasthide > 50) is_dodge = 0;
        if (airdrop == player) // 获得空投
        {
            clip += mt() % (level * 3);
            teleport += mt() % (level);
            memset(&airdrop, -1, sizeof(airdrop));
        }
        if (monsterhp == 0) // 怪死庆祝
        {
            INIwrite(to_string(numini), "level", to_string(level));
            INIwrite(to_string(numini), "mhp", to_string(monsterhp));
            SetColor(0x2d);
            CreateThread(NULL, 0, T_GOBeep, NULL, 0, NULL);
            DelayPrint("WIN!!!");
            Sleep(1000);
            Start(level + 1, numini);
            CloseHandle(hIn);
            return 0;
        }
    }
    is_die = true; // 死了,通知其他线程结束
    INIwrite(to_string(numini), "level", to_string(level));
    INIwrite(to_string(numini), "mhp", to_string(monsterhp));
    SetColor(0xc3);
    CreateThread(NULL, 0, T_GOBeep, NULL, 0, NULL);
    DelayPrint("Your computer has been fucked by the MEMZ trojan\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bGAME OVER!!!");
    Sleep(10000);
    CloseHandle(hIn);
    return 0;
}

V2.2.1 测试版

https://www.luogu.com.cn/paste/nbtfi7ce

2.2.2 不正常版

/*
 * 键位更新
 * 代码重构 (10.1) 
 */

#include <windows.h>
#include <conio.h> // getch
#include <bits/stdc++.h>
using namespace std;

namespace _MD5
{
#define A 0x67452301
#define B 0xefcdab89
#define C 0x98badcfe
#define D 0x10325476

    const char str16[] = "0123456789abcdef";

    const unsigned int T[] =
    {
        0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
        0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
        0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
        0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
        0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
        0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
        0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
        0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
        0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
        0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
        0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
        0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
        0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
        0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
        0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
        0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
    };

    const unsigned int s[] = { 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
        5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
        4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
        6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
    };

    class MD5
    {
        private:
            unsigned int tempA, tempB, tempC, tempD, strlength;
        public:
            MD5()
            {
                tempA = A;
                tempB = B;
                tempC = C;
                tempD = D;
                strlength = 0;
            }
            // F函数
            unsigned int F(unsigned int b, unsigned int c, unsigned int d)
            {
                return (b & c) | ((~b) & d);
            }
            // G函数
            unsigned int G(unsigned int b, unsigned int c, unsigned int d)
            {
                return (b & d) | (c & (~d));
            }
            // H函数
            unsigned int H(unsigned int b, unsigned int c, unsigned int d)
            {
                return b ^ c ^ d;
            }
            // I函数
            unsigned int I(unsigned int b, unsigned int c, unsigned int d)
            {
                return c ^ (b | (~d));
            }
            // 移位操作函数
            unsigned int shift(unsigned int a, unsigned int n)
            {
                return (a << n) | (a >> (32 - n));
            }
            // 编码函数
            string encode(string src)
            {
                vector<unsigned int> rec = padding(src);
                for (unsigned int i = 0; i < strlength / 16; i++)
                {
                    unsigned int num[16];
                    for (int j = 0; j < 16; j++)
                    {
                        num[j] = rec[i * 16 + j];
                    }
                    iterateFunc(num, 16);
                }
                return format(tempA) + format(tempB) + format(tempC) + format(tempD);
            }
            // 循环压缩
            void iterateFunc(unsigned int *X, int size = 16)
            {
                unsigned int a = tempA,
                         b = tempB,
                         c = tempC,
                         d = tempD,
                         rec = 0,
                         g, k;
                for (int i = 0; i < 64; i++)
                {
                    if (i < 16)
                    {
                        // F迭代
                        g = F(b, c, d);
                        k = i;
                    }
                    else if (i < 32)
                    {
                        // G迭代
                        g = G(b, c, d);
                        k = (1 + 5 * i) % 16;
                    }
                    else if (i < 48)
                    {
                        // H迭代
                        g = H(b, c, d);
                        k = (5 + 3 * i) % 16;
                    }
                    else
                    {
                        // I迭代
                        g = I(b, c, d);
                        k = (7 * i) % 16;
                    }
                    rec = d;
                    d = c;
                    c = b;
                    b = b + shift(a + g + X[k] + T[i], s[i]);
                    a = rec;
                }
                tempA += a;
                tempB += b;
                tempC += c;
                tempD += d;
            }
            // 填充字符串
            vector<unsigned int> padding(string src)
            {
                // 以512位,64个字节为一组
                unsigned int num = ((src.length() + 8) / 64) + 1;
                vector<unsigned int> rec(num * 16);
                strlength = num * 16;
                for (unsigned int i = 0; i < src.length(); i++)
                {
                    // 一个unsigned int对应4个字节,保存4个字符信息
                    rec[i >> 2] |= (int)(src[i]) << ((i % 4) * 8);
                }
                // 补充1000...000
                rec[src.length() >> 2] |= (0x80 << ((src.length() % 4) * 8));
                // 填充原文长度
                rec[rec.size() - 2] = (src.length() << 3);
                return rec;
            }
            // 整理输出
            string format(unsigned int num)
            {
                string res = "";
                unsigned int base = 1 << 8;
                for (int i = 0; i < 4; i++)
                {
                    string tmp = "";
                    unsigned int b = (num >> (i * 8)) % base & 0xff;
                    for (int j = 0; j < 2; j++)
                    {
                        tmp = str16[b % 16] + tmp;
                        b /= 16;
                    }
                    res += tmp;
                }
                return res;
            }
    };
}
using namespace _MD5;

// 常量区
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
int dx[] = {-1, 1, 0, 0, 0}, dy[] = {0, 0, -1, 1, 0}; // dfs 
const int LEFT = 2, RIGHT = 1, UP = 8, DOWN = 4, STILL = 0; // dir
enum TYPE
{
    WALL, AIR, PLAYER, MONSTER, AIRDROP, PORTAL, BULLET // 按显示主次排序 
};
struct BLOCK
{
    BLOCK() : type(TYPE::AIR), cnt(0)
    {
        display[0] = ' ';
        display[1] = ' ';
    }
    BLOCK(TYPE t) : type(t), cnt(0)
    {
        display[0] = ' ';
        display[1] = ' ';
        if(t == WALL) color = 0xf0;
    }
    BLOCK(TYPE t, unsigned long long c) : type(t), cnt(c)
    {
        display[0] = ' ';
        display[1] = ' ';
        if(t == WALL) color = 0xf0;
    }
    TYPE                type;
    unsigned long long  cnt;
    WORD                color;
    char                display[3];
    bool operator<(BLOCK b)
    {
        return (int)type != (int)b.type ? cnt < b.cnt : (int)type < (int)b.type;
    }
};
vector<int> inv =
{
    -1
};
vector<int> nomove =
{
    5
};
const int LINE = 10; // 区块行数
const int COL = 10; // 区块列数
const int WLINE = 10; // 地图行数
const int WCOL = 10; // 地图列数
const int DIM = 3; // 维度总数
int FPS = 100;
const int GUNTOT = 1;
#define SUCCESS 0
#define FAIL 1

// 类型定义区
#define mtime_t unsigned long long // 精确到毫秒的时间单位定义
class Cursor // 控制台光标移动
{
    protected:
        stack<COORD> pre;
    public:
        Cursor()
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(hOut, &csbi);
            pre.push(csbi.dwCursorPosition);
        }
        void Goto(int x, int y)
        {
            pre.push({x, y});
            SetConsoleCursorPosition(hOut, pre.top());
        }
        BOOL Back()
        {
            if (pre.empty())
                return FAIL;
            pre.pop();
            if (pre.empty())
                return FAIL;
            SetConsoleCursorPosition(hOut, pre.top());
        }
        BOOL Empty()
        {
            return pre.empty();
        }
};
struct ENTITY : BLOCK // 实体结构体
{ 
    ENTITY()
    {
        memset(this, 0, sizeof(*this));
    }
    int getx() { return mapx * COL + mapx + x + 1; } int gety() { return mapy * LINE + y + 1; }
    int             x;
    int             y;
    int             mapx;
    int             mapy;
    int             dim; // 实体位置(坐标)
    bool operator==(ENTITY p) // 是否重合 
    {
        return dim == p.dim && getx() == p.getx() && gety() == p.gety();
    }
}; 
struct E_BULLET : ENTITY
{
    E_BULLET()
    {
        type = BULLET;
    }
    int             dir; // 发射方向 
    mtime_t         stattm; // 发射时间
    int             bullet_type; // 子弹类型 
    void useless()
    {
        dir = -1;
        color = 0;
        display[0] = ' ';
        display[1] = ' ';
    }
};
struct E_MONSTER;
typedef bool (*BULLETPROC)(E_BULLET &, E_MONSTER &); // 返回值:子弹是否消失 
struct GUN
{
    WORD            color;
    char            display[3];
    BULLETPROC      BulletProc; // damage, effect, etc.
    mtime_t         movdelay; // 移动一格所需时间
    mtime_t         frozetm; // 冷却时间
    bool            locked;
    int             bullets_per_clip; // 单个弹夹所含子弹数 
    string          describe;

    mtime_t         lastuse; // 上次使用时间 
    int             bullet;
    int             clip;
};
struct E_PORTAL : ENTITY
{
    E_PORTAL()
    {
        type = PORTAL;
    }
    int             tox;
    int             toy;
    int             tomapx;
    int             tomapy;
    int             todim;
    int gettox() { return tomapx * COL + tox; } int gettoy() { return tomapy * LINE + toy; }
};
struct E_PLAYER : ENTITY
{
    E_PLAYER()
    {
        teleport = 20;
        color = 0xc0;
        type = PLAYER;
    }
    void Teleport(mt19937 mt)
    {
        if(teleport <= 0) return ;
        mapx = mt() % WLINE;
        mapy = mt() % WCOL;
        x = LINE / 2;
        y = COL / 2;
        teleport--;
    }
//  int             hp;
    int             level;
    GUN             gun[GUNTOT];
    int             teleport;
    bool            autoload;
    bool            autotp;
    bool            is_dodge;
    bool            is_defeat;
    bool            is_die;
    int             speed;
    int             nowgun;
};

struct EFFECT;

typedef bool (*EFFECTPROC)(EFFECT &, E_MONSTER &);

struct EFFECT
{
    mtime_t         start_time;
    EFFECTPROC      EffectProc;
};

struct E_MONSTER : ENTITY
{
    E_MONSTER()
    {
        color = 0xa0;
        type = MONSTER;
    }
    int             hp;
    vector<EFFECT>  noweffect;
};

struct E_AIRDROP : ENTITY
{
    E_AIRDROP()
    {
        reset();
        color = BACKGROUND_BLUE | BACKGROUND_INTENSITY;
        type = AIRDROP;
    }
    void reset()
    {
        dim = x = y = mapx = mapy = -1;
    }
    void random(mt19937 mt, E_PLAYER player)
    {
        dim         = player.dim;
        x           = mt() % COL;
        y           = mt() % LINE;
        mapx        = mt() % WCOL;
        mapy        = mt() % WLINE;
        teleport    = mt() % (player.level * 2);
        for(int i = 0; i < GUNTOT; i++)
        {
            if(player.gun[i].locked == false)
            {
                clip[i] += mt() % (player.level * 5000 / player.gun[i].frozetm);
                // 冷却时间越长白给越少 
            }
        }
    }
    void GetIfCan(E_PLAYER &player)
    {
        if(*this == player)
        {
            player.teleport += teleport;
            for(int i = 0; i < GUNTOT; i++)
            {
                if(player.gun[i].locked == false)
                {
                    player.gun[i].clip += this->clip[i];
                }
            }
            this->reset();
        }
    }
    int             teleport;
    int             clip[GUNTOT];
};


struct DOC // 存档结构体
{
    string          player;
    int             level;
    int             monsterhp;
    string          pas;
    int             num;
};

// 变量区
E_MONSTER           monster;
E_PLAYER            player;
E_AIRDROP           airdrop;
E_PORTAL            portal[DIM][DIM]; // [start][end]
Cursor              cur;
vector<E_BULLET>    bullet;
mtime_t             st;
int                 whole[DIM][WLINE + 5][WCOL + 5]; // 区块墙状态 
int                 cmx = 0,
                    cmy = 0; // 高亮格 
string              s_dim[DIM] = {"主世界", "炙热域", "寒冰界"};
bool                wrote;
mt19937             mt;
map
<
    pair<int, int>,
    vector<int>
>                   mem; // 记忆化 dfs
int                 numini;
MD5                 md5;
mtime_t             last_print = time(NULL) * 1000ull;
int                 ar_less = 5,
                    at_less = 7;
vector<BLOCK>       world[DIM][WLINE * LINE + 15][WCOL * COL + 15]; // 总地图 
int                 start_bullet_clip[GUNTOT] = {5};

// 键位
int                 k_att_u = 'I', k_att_d = 'K', k_att_l = 'J', k_att_r = 'L', 
                    k_reload = 'E', k_drop = 'R', k_tp = 'Q', k_ender_pearl = VK_SPACE, k_speed = VK_OEM_1, 
                    k_autoreload = 'U', k_autotp = 'O', 
                    k_hl_u = VK_UP, k_hl_d = VK_DOWN, k_hl_l = VK_LEFT, k_hl_r = VK_RIGHT,
                    k_pl_u = 'W', k_pl_d = 'S', k_pl_l = 'A', k_pl_r = 'D'; // att : attack, hl : highlight, pl : player
int                 *keymap[] = {&k_att_d, &k_att_u, &k_att_l, &k_att_r, &k_pl_d, &k_pl_u, &k_pl_l, &k_pl_r, &k_hl_d, &k_hl_u, &k_hl_l, &k_hl_r, &k_autoreload, &k_autotp, &k_drop, &k_ender_pearl, &k_reload, &k_tp, &k_speed};

// 键表
string              keymp[256] = {
    "", // 00
    "Mouse Left", // 01
    "Mouse Right", // 02
    "", // 03
    "Mouse Mid", // 04
    "Mouse X1", // 05
    "Mouse X2", // 06
    "", // 07
    "Backspace", // 08
    "Tab", // 09
    "", // 0A
    "", // 0B
    "", // 0C
    "Enter", // 0D
    "", // 0E
    "", // 0F
    "", // 10
    "", // 11
    "", // 12
    "", // 13
    "Caps", // 14
    "", // 15
    "", // 16
    "", // 17
    "", // 18
    "", // 19
    "", // 1A
    "Esc", // 1B
    "", // 1C
    "", // 1D
    "", // 1E
    "", // 1F
    "Space", // 20
    "Pg up", // 21
    "Pg dn", // 22
    "End", // 23
    "Home", // 24
    "Left Arrow", // 25
    "Up Arrow", // 26
    "Right Arrow", // 27
    "Down Arrow", // 28
    "", // 29
    "", // 2A
    "", // 2B
    "", // 2C
    "", // 2D
    "", // 2E
    "", // 2F
    "0", // 30
    "1", // 31
    "2", // 32
    "3", // 33
    "4", // 34
    "5", // 35
    "6", // 36
    "7", // 37
    "8", // 38
    "9", // 39
    "", // 3A
    "", // 3B
    "", // 3C
    "", // 3D
    "", // 3E
    "", // 3F
    "", // 40
    "A", // 41
    "B", // 42
    "C", // 43
    "D", // 44
    "E", // 45
    "F", // 46
    "G", // 47
    "H", // 48
    "I", // 49
    "J", // 4A
    "K", // 4B
    "L", // 4C
    "M", // 4D
    "N", // 4E
    "O", // 4F
    "P", // 50
    "Q", // 51
    "R", // 52
    "S", // 53
    "T", // 54
    "U", // 55
    "V", // 56
    "W", // 57
    "X", // 58
    "Y", // 59
    "Z", // 5A
    "", // 5B
    "", // 5C
    "", // 5D
    "", // 5E
    "", // 5F
    "Num 0", // 60
    "Num 1", // 61
    "Num 2", // 62
    "Num 3", // 63
    "Num 4", // 64
    "Num 5", // 65
    "Num 6", // 66
    "Num 7", // 67
    "Num 8", // 68
    "Num 9", // 69
    "Num *", // 6A
    "Num +", // 6B
    "", // 6C
    "Num -", // 6D
    "Num .", // 6E
    "Num /", // 6F
    "F1", // 70
    "F2", // 71
    "F3", // 72
    "F4", // 73
    "F5", // 74
    "F6", // 75
    "F7", // 76
    "F8", // 77
    "F9", // 78
    "F10", // 79
    "F11", // 7A
    "F12", // 7B
    "F13", // 7C
    "F14", // 7D
    "F15", // 7E
    "F16", // 7F
    "F17", // 80
    "F18", // 81
    "F19", // 82
    "F20", // 83
    "F21", // 84
    "F22", // 85
    "F23", // 86
    "F24", // 87
    "", // 88
    "", // 89
    "", // 8A
    "", // 8B
    "", // 8C
    "", // 8D
    "", // 8E
    "", // 8F
    "Num Lock", // 90
    "Scroll Lock", // 91
    "", // 92
    "", // 93
    "", // 94
    "", // 95
    "", // 96
    "", // 97
    "", // 98
    "", // 99
    "", // 9A
    "", // 9B
    "", // 9C
    "", // 9D
    "", // 9E
    "", // 9F
    "Left Shift", // A0
    "Right Shift", // A1
    "Left Ctrl", // A2
    "Right Ctrl", // A3
    "Left Alt", // A4
    "Right Alt", // A5
    "", // A6
    "", // A7
    "", // A8
    "", // A9
    "", // AA
    "", // AB
    "", // AC
    "", // AD
    "", // AE
    "", // AF
    "", // B0
    "", // B1
    "", // B2
    "", // B3
    "", // B4
    "", // B5
    "", // B6
    "", // B7
    "", // B8
    "", // B9
    ";", // BA
    "=", // BB
    ",", // BC
    "-", // BD
    ".", // BE
    "/", // BF
    "`", // C0
    "", // C1
    "", // C2
    "", // C3
    "", // C4
    "", // C5
    "", // C6
    "", // C7
    "", // C8
    "", // C9
    "", // CA
    "", // CB
    "", // CC
    "", // CD
    "", // CE
    "", // CF
    "", // D0
    "", // D1
    "", // D2
    "", // D3
    "", // D4
    "", // D5
    "", // D6
    "", // D7
    "", // D8
    "", // D9
    "", // DA
    "[", // DB
    "\\", // DC
    "]", // DD
    "'", // DE
    "", // DF
    "", // E0
    "", // E1
    "", // E2
    "", // E3
    "", // E4
    "", // E5
    "", // E6
    "", // E7
    "", // E8
    "", // E9
    "", // EA
    "", // EB
    "", // EC
    "", // ED
    "", // EE
    "", // EF
    "", // F0
    "", // F1
    "", // F2
    "", // F3
    "", // F4
    "", // F5
    "", // F6
    "", // F7
    "", // F8
    "", // F9
    "", // FA
    "", // FB
    "", // FC
    "", // FD
    "", // FE
    "", // FF
};
vector<int>         prockeys;

// 预处理函数区
#define kd(vk) (GetAsyncKeyState(vk) & 0x8000 ? 1 : 0)
#define SetColor(attr) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (attr))
//#define defmap(n, b) void map##n(int ismon = false, int bn = 0)\
//{\
//  for (int i = 1; i <= LINE; i++)\
//  {\
//      for (int j = 1; j <= COL; j++)\
//      {\
//          if (b == 1)\
//          {\
//              if (ismon == 1) monster.mp[i][j] = "墙";\
//              else if (ismon == 2) bullet[bn].mp[i][j] = "墙";\
//              else player.mp[i][j] = "墙";\
//          }\
//          else\
//          {\
//              if (ismon) monster.mp[i][j] = "  ";\
//              else if (ismon == 2) bullet[bn].mp[i][j] = "  ";\
//              else player.mp[i][j] = "  ";\
//          }\
//      }\
//  }\
//}
#define prockeyspush prockeys.push_back
//#define map(n) map##n()
//#define defifmp(k) if(n == k) map##k(1);
//#define bullmp(k, bn) if(n == k) map##k(2, bn);
//#define IF(q) if (n == q)\
//{\
//  map##q();\
//  for (int i = 1; i <= LINE; i++)\
//  {\
//      for (int j = 1; j <= COL; j++)\
//      {\
//          int isbull = false;\
//          for (int k = 0; k < bullet.size(); k++)\
//              if (i == bullet[k].x && j == bullet[k].y && mx == bullet[k].mapx && my == bullet[k].mapy && bullet[k].dir != -1)\
//          {\
//              isbull = bullet[k].dir == UP || bullet[k].dir == DOWN ? 1 : 2;\
//              break;\
//          }\
//          SetColor(player.mp[i][j] == "墙" ? 0xf0 : i == x && j == y ? 0xc0 : i == monster.x && j == monster.y && mx == monster.mapx && my == monster.mapy ? 0xa0 : isbull ? 0x0e : i == airdrop.x && j == airdrop.y && mx == airdrop.mapx && my == airdrop.mapy ? BACKGROUND_BLUE | 0x80 : 0x07);\
//          cout << (isbull == 1 ? "||" : isbull == 2 ? "==" : "  ");\
//      }\
//      cout << endl;\
//  }\
//}

// 函数定义区
//defmap(0, (i == 1 || i == 10) && (j == 1 || j == 10)) // 各种地图
//defmap(1, j == 10 || (j == 1 && (i == 1 || i == 10)))
//defmap(2, j == 1 || (j == 10 && (i == 1 || i == 10)))
//defmap(3, j == 1 || j == 10)
//defmap(4, i == 10 || (i == 1 && (j == 1 || j == 10)))
//defmap(5, i == 10 || j == 10 || (i == 1 && j == 1))
//defmap(6, i == 10 || j == 1 || (i == 1 && j == 10))
//defmap(7, i == 10 || j == 1 || j == 10)
//defmap(8, i == 1 || (i == 10 && (j == 1 || j == 10)))
//defmap(9, i == 1 || j == 10 || (i == 10 && j == 1))
//defmap(10, i == 1 || j == 1 || (i == 10 && j == 10))
//defmap(11, i == 1 || j == 1 || j == 10)
//defmap(12, i == 1 || i == 10)
//defmap(13, i == 1 || i == 10 || j == 10)
//defmap(14, i == 1 || i == 10 || j == 1)
//defmap(15, i == 1 || i == 10 || j == 1 || j == 10)
//void monstermap(int n) // 控制怪物地图
//{
//  defifmp(0)
//  defifmp(1)
//  defifmp(2)
//  defifmp(3)
//  defifmp(4)
//  defifmp(5)
//  defifmp(6)
//  defifmp(8)
//  defifmp(9)
//  defifmp(10)
//  defifmp(11)
//  defifmp(12)
//  defifmp(13)
//  defifmp(14)
//  defifmp(15)
//}
//void bulletmap(int n, int bn) // 子弹地图
//{
//  bullmp(0, bn)
//  bullmp(1, bn)
//  bullmp(2, bn)
//  bullmp(3, bn)
//  bullmp(4, bn)
//  bullmp(5, bn)
//  bullmp(6, bn)
//  bullmp(7, bn)
//  bullmp(8, bn)
//  bullmp(9, bn)
//  bullmp(10, bn)
//  bullmp(11, bn)
//  bullmp(12, bn)
//  bullmp(13, bn)
//  bullmp(14, bn)
//  bullmp(15, bn)
//}


mtime_t getmtime() // 精确到毫秒的计时器
{
    SYSTEMTIME st;
    GetSystemTime(&st);
    mtime_t ret = st.wMilliseconds;
    ret += time(NULL) * 1000ull;
    return ret;
}


void debugf(const char *format, ...) // 格式化调试
{
    va_list va;
    va_start(va, format);
    char *buf = new char[1048576];
    vsprintf(buf, format, va);
    string s = buf;
    delete[] buf;
    va_end(va);
    if (format[0] == '@')
        MessageBoxA(NULL, s.data(), "debug", MB_OK);
}

string INIread(string sec, string key, string file = "./config.ini") // 配置文件读取
{
    char *buf = new char[1048576];
    string s(buf, GetPrivateProfileStringA(sec.data(), key.data(), "", buf, 1048576, file.data()));
    delete []buf;
    return s;
}
void nINIwrite(string sec, string key, int &val, string file = "./config.ini") // not write
{
    string tmp = INIread(sec, key);
    val = stoi(tmp);
}
void INIwrite(string sec, string key, string val = "", string file = "./config.ini") // 配置文件写入
{
    WritePrivateProfileStringA(sec.data(), key.data(), val.data(), file.data());
}

void transfer(ENTITY &who, int dim_from, int dim_to) // 传送
{
    if (who == portal[dim_from][dim_to])
    {
        who.dim = portal[dim_from][dim_to].todim;
        who.mapx = portal[dim_from][dim_to].tomapx;
        who.mapy = portal[dim_from][dim_to].tomapy;
        who.x = portal[dim_from][dim_to].tox;
        who.y = portal[dim_from][dim_to].toy;
    }
}
void setwall(int x, int y, int w, int d = 0) // 在某区块设置某方向的墙
{
    whole[d][x][y] |= w;
}
bool mov(ENTITY &e, int dx, int dy) // 移动实体 return stucked
{
    if(world[e.dim][e.getx() + dx][e.gety() + dy][0].type == WALL)
    {
        return 1;
    }
    int x = e.getx() + dx;
    int y = e.gety() + dy;
    e.mapx = x / COL;
    e.mapy = y / LINE;
    e.x = x % COL;
    e.y = y % LINE;
    return 0;
}
void printm(int n) // 输出地图(界面)
{
    mtime_t now_fps = getmtime() - last_print;
    last_print = getmtime();
    for(int i = 1; i <= LINE; i ++)
    {
        for(int j = 1; j <= COL; j++)
        {
            SetColor(world[player.dim][player.mapx * LINE + i][player.mapy * COL + j][0].color);
            cout << world[player.dim][player.mapx * LINE + i][player.mapy * COL + j][0].display[0];
            cout << world[player.dim][player.mapx * LINE + i][player.mapy * COL + j][0].display[1];
            SetColor(0x07);
        }
        cout << endl;
    }
    for (int i = 0; i <= WLINE; i++)
    {
        cur.Goto(COL * 2 + 6, i);
        cout << hex;
        for (int j = 0; j <= WCOL; j++)
        {
            SetColor
                (
                 (i == monster.x && j == monster.y ? FOREGROUND_RED : 0x08) |
                 (i == monster.mapx && j == monster.mapy ? FOREGROUND_GREEN : 0x08) |
                 ((i == airdrop.mapx && j == airdrop.mapy) ? FOREGROUND_BLUE : 0x08) |
                 (cmx == i && cmy == j ? 0xf0 : 0x08)
                );
            cout << "[]";
            SetColor(0x07);
        }
        cur.Back();
    }
    cout << dec;
    cur.Goto(COL * 2 + 10 + WCOL * 2, 0);
    cout << "用时: " << time(NULL) - st << " sec.";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 1);
    cout << "怪血: " << monster.hp << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 2);
    cout << "等级: " << player.level;
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 3);
    cout << "目前枪械: " << player.gun[player.nowgun].describe << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 4);
    cout << "弹药: " << player.gun[player.nowgun].bullet << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 5);
    cout << "弹夹: " << player.gun[player.nowgun].clip << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 6);
    cout << "紫颂果: " << player.teleport << "   ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 7);
    cout << (player.speed ? "快" : "慢");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 8);
    cout << "自动换弹: " << (player.level < ar_less ? "禁用" : player.autoload ? "开" : "关");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 9);
    cout << "保命瞬移: " << (player.level < at_less ? "禁用" : player.autotp ? "开" : "关");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 10);
    cout << "你当前维度:" << s_dim[player.dim];
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 11);
    cout << "鬼当前维度:" << s_dim[monster.dim];
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 12);
    cout << "高亮区块墙状态: ";
    cout << (whole[player.dim][cmx][cmy] & UP ? "上" : "  ");
    cout << (whole[player.dim][cmx][cmy] & DOWN ? "下" : "  ");
    cout << (whole[player.dim][cmx][cmy] & LEFT ? "左" : "  ");
    cout << (whole[player.dim][cmx][cmy] & RIGHT ? "右" : "  ");
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 13);
    cout << "FPS: " << now_fps << "     ";
    cur.Back();
    cur.Goto(COL * 2 + 10 + WCOL * 2, 14);
    cout << (wrote ? "记录已保存" : player.is_dodge ? "闪避      " : player.is_defeat ? "击退      " : "          ");
    cur.Back();
}
//int judge(int &x, int &y, int &mx = ::mx, int &my = ::my) // 判断是否出区块
//{
//  if (x < 1)
//  {
//      x = LINE;
//      mx--;
//      return UP;
//  }
//  if (y < 1)
//  {
//      my--;
//      y = COL;
//      return LEFT;
//  }
//  if (x > LINE)
//  {
//      mx++;
//      x = 1;
//      return DOWN;
//  }
//  if (y > COL)
//  {
//      my++;
//      y = 1;
//      return RIGHT;
//  }
//  return STILL;
//}
vector<int> dfsmap(E_MONSTER now, E_PLAYER man) // 怪物单次dfs
{
    vector<int> ret = inv;
    if (man.mapx != now.mapx || man.mapy != now.mapy)
        for (int i = 0; i < 4; i++)
        {
            E_MONSTER n = now;
            n.mapx += dx[i];
            n.mapy += dy[i];
            pair<int, int> pii = make_pair(n.mapx, n.mapy);
            if (whole[now.dim][now.mapx][now.mapy] & (1 << (3 - i)))
                continue;
            if (whole[now.dim][n.mapx][n.mapy] & 16)
                continue; // 16 : visited
            vector<int> tmp;
            tmp = inv;
            if (mem[pii].empty())
            {
                whole[n.dim][n.mapx][n.mapy] |= 16;
                tmp.clear();
                mem[pii] = tmp = dfsmap(n, man);
                if (tmp == nomove)
                {
                    tmp.clear();
                    tmp.push_back(i);
                }
                else if (tmp != inv)
                    tmp.insert(tmp.begin(), i);
                whole[n.dim][n.mapx][n.mapy] &= ~16;
            }
            else
            {
                tmp.clear();
                tmp = mem[pii];
                if (tmp == nomove)
                {
                    tmp.clear();
                    tmp.push_back(i);
                }
                else if (tmp != inv)
                    tmp.insert(tmp.begin(), i);
            }
            if (ret == inv)
            {
                ret = tmp;
            }
            else if (ret.size() >= tmp.size())
            {
                ret = tmp;
            }
            //          Sleep(2);
        }
    else
    {
        ret.clear();
        ret.push_back(5);
        //      debugf("@finded");
    }
    return ret;
}
vector<int> dfs(E_MONSTER now, E_PLAYER man) // 怪物dfs 接下来:和人不同维度就直接奔传送门
{
    for (int d = 0; d < DIM; d++)
    {
        for (int i = 0; i < WLINE; i++)
        {
            for (int j = 0; j < WCOL; j++)
            {
                whole[d][i][j] &= ~16;
            }
        }
    }

    vector<int> ret;
    whole[now.dim][now.mapx][now.mapy] |= 16;
    ret = dfsmap(now, man);
    whole[now.dim][now.mapx][now.mapy] &= ~16;
    return ret;
}
void DelayPrint(string s, int del = 50) // 延时输出
{
    for (auto u : s)
    {
        if (u != '\b')
        {
            putchar(u);
        }
        else
        {
            printf("\b \b");
        }
        Sleep(del);
    }
}
void shoot(int dir) // 射击函数(生成子弹实体)
{
    if (player.gun[player.nowgun].bullet == 0)
        return;
    E_BULLET b;
    b.dim = player.dim;
    b.x = player.x;
    b.y = player.y;
    b.mapx = player.mapx;
    b.mapy = player.mapy;
    b.color = player.gun[player.nowgun].color;
    b.bullet_type = player.nowgun;
    b.display[0] = player.gun[player.nowgun].display[0];
    b.display[1] = player.gun[player.nowgun].display[1];
    b.type = BULLET;
    b.stattm = getmtime();
    b.dir = dir;
    //  debugf("@s");
    bullet.push_back(b);
    Beep(320, 100);
    player.gun[player.nowgun].bullet--;
    //  debugf("@OK");
}
bool cmp(DOC m, DOC d) // 比较函数(排名)
{
    return m.level > d.level ? 1 : m.level == d.level ? m.monsterhp < d.monsterhp : 0;
}

string filename;

void Start(int level, int num)
{
    string f = __FILE__;
    ShellExecuteA(NULL, "open", filename.data(), (to_string(level) + " " + to_string(num)).data(), NULL, SW_SHOW);
}

// 线程函数区
DWORD WINAPI T_MonsterProc(LPVOID lpIgnore) // 怪物处理线程
{
    E_MONSTER &me = monster;
    E_PLAYER &man = player;
    // TODO: Process (AI): eat the man
    vector<int> method;
    int num = 0;
    E_PLAYER lastman;
    memset(&lastman, -1, sizeof(lastman));
    if (player.is_die) ExitThread(0);
    int delay, level = player.level;
    if (level > 10)
        delay = 5;
    else if (level == 10)
        delay = 10;
    else if (level == 9)
        delay = 15;
    else if (level == 8)
        delay = 20;
    else if (level == 7)
        delay = 25;
    else if (level == 6)
        delay = 30;
    else if (level == 5)
        delay = 35;
    else if (level == 4)
        delay = 40;
    else if (level == 3)
        delay = 45;
    else if (level == 2)
        delay = 50;
    else if (level == 1)
        delay = 55;
    else
        delay = 100;
    delay *= 2;
    while (1)
    {
        if (lastman.mapx != man.mapx || lastman.mapy != man.mapy)
        {
            //          debugf("@ifmethod");
            lastman = man;
            mem.clear();
            debugf("dfs start");
            method = dfs(me, man);
            debugf("dfs end, size %d, isinv %d", method.size(), method == inv);
            while (method == inv && (lastman.mapx == man.mapx && lastman.mapy == man.mapy))
            {
                mem.clear();
                debugf("dfs start");
                E_PLAYER tmp;
                tmp.x = me.x + (me.x == LINE ? -1 : 1);
                tmp.y = me.y + (me.y == COL ? -1 : 1);
                tmp.mapx = me.mapx;
                tmp.mapy = me.mapy;
                method = dfs(me, tmp);
                //              debugf("@dfs end, size %d, isinv %d", method.size(), method == inv);
                mem.clear();
                debugf("dfs start");
                method = dfs(me, man);
                //              debugf("@dfs end, size %d, isinv %d", method.size(), method == inv);
            }
            num = 0;
        }
        //      lastman = man;
        //      debugf("lastman = man");
        if (num < method.size())
        {
            E_MONSTER lastme = me;
            while (me.mapx == lastme.mapx && me.mapy == lastme.mapy)

            {
                if (me.mapx == man.mapx && me.mapy == man.mapy)
                {
                    break;
                }
                bool stucked = mov(me, dx[method[num]],dy[method[num]]);
                debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
//              debugf("judge %d", judge(me.x, me.y, me.mapx, me.mapy));
                Sleep(delay);
                if (stucked)
                {
                    int xx = me.x - WLINE / 2, yy = me.y - WCOL / 2;
                    if ((mt() & 1))
                    {
                        mov(me, 0, - (yy < 0 ? -1 : yy > 0 ? 1 : 0));
                    }
                    else
                    {
                        mov(me, - (xx < 0 ? -1 : xx > 0 ? 1 : 0), 0);
                    }
                }
            }
            debugf("num++");
            num++;
        }
        else if (me.mapx == man.mapx && me.mapy == man.mapy)
        {
            //          debugf("@elif");
            int xx = me.x - man.x, yy = me.y - man.y;
            if (mt() & 1)
            {
                mov(me, 0, - (yy < 0 ? -1 : yy > 0 ? 1 : 0));
                debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
            }
            else
            {
                mov(me, - (xx < 0 ? -1 : xx > 0 ? 1 : 0), 0);
                debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
            }
        }
        else
        {
            //          debugf("@");
        }
        //      else
        //      {
        //          int xx = me.x - WLINE / 2, yy = me.y - WCOL / 2;
        //          if(xx == 0)
        //          {
        //              mov(me.x, me.y - (yy < 0 ? -1 : yy > 0 ? 1 : 0), me.x, me.y, 1);
        //          }
        //          else
        //          {
        //              mov(me.x - (xx < 0 ? -1 : xx > 0 ? 1 : 0), me.y, me.x, me.y, 1);
        //          }
        //      }
        Sleep(delay);
        //      debugf("@@");
    }
}

DWORD WINAPI T_LetBulletFly(LPVOID lpIgnore) // 子弹移动处理线程
{
    mtime_t lastdefeat = 0;
    while (1)
    {
        if (player.is_die) ExitThread(0);
        for (int i = 0; i < bullet.size(); i++)
        {
            if (player.is_defeat && getmtime() - lastdefeat >= 20) player.is_defeat = false;
            if (bullet[i].dir == -1)
                continue;

        }
    }
}
DWORD WINAPI T_WriteMsg(LPVOID lpIgnore) // 保存记录线程
{
    while (1)
    {
        INIwrite(to_string(numini), "level", to_string(player.level));
        INIwrite(to_string(numini), "mhp", to_string(monster.hp));
        INIwrite("key", "att_d", to_string(k_att_d));
        INIwrite("key", "att_u", to_string(k_att_u));
        INIwrite("key", "att_l", to_string(k_att_l));
        INIwrite("key", "att_r", to_string(k_att_r));
        INIwrite("key", "atrld", to_string(k_autoreload));
        INIwrite("key", "attp", to_string(k_autotp));
        INIwrite("key", "drp", to_string(k_drop));
        INIwrite("key", "ender", to_string(k_ender_pearl));
        INIwrite("key", "hl_d", to_string(k_hl_d));
        INIwrite("key", "hl_u", to_string(k_hl_u));
        INIwrite("key", "hl_l", to_string(k_hl_l));
        INIwrite("key", "hl_r", to_string(k_hl_r));
        INIwrite("key", "pl_d", to_string(k_pl_d));
        INIwrite("key", "pl_u", to_string(k_pl_u));
        INIwrite("key", "pl_l", to_string(k_pl_l));
        INIwrite("key", "pl_r", to_string(k_pl_r));
        INIwrite("key", "rld", to_string(k_reload));
        INIwrite("key", "tp", to_string(k_tp));
        INIwrite("key", "spd", to_string(k_speed));
        wrote = true;
        Sleep(500);
        wrote = false;
        for(int d = 0; d < DIM; d++)
        {
            for(int i = 0; i < LINE * WLINE; i++)
            {
                for(int j = 0; j < COL * WCOL; j++)
                {
                    sort(world[d][i][j].begin(), world[d][i][j].end());
                }
            }
        }
        Sleep(2500);
    }
}

DWORD WINAPI T_GOBeep(LPVOID lpIgnore) // 死亡音效线程
{
    Beep(1234, 1000);
    return 0;
}

DWORD WINAPI T_Shoot(LPVOID lpIgnore) // 射击管理线程(兼管高亮区块)
{
    while (1)
    {
        if (player.is_die) ExitThread(0);
        //      Sleep(25);
        if ((kd(k_att_u)))
        {
            shoot(0);
        }
        if ((kd(k_att_l)))
        {
            shoot(2);
        }
        if ((kd(k_att_d)))
        {
            shoot(1);
        }
        if ((kd(k_att_r)))
        {
            shoot(3);
        }
        if (kd(k_reload) && player.gun[player.nowgun].clip)
        {
            Sleep(1000);
            player.gun[player.nowgun].bullet = 20 * player.level;
            player.gun[player.nowgun].clip--;
        }
        if (player.autoload && player.gun[player.nowgun].bullet == 0)
        {
            Sleep(1000);
            player.gun[player.nowgun].bullet = 20 * player.level;
            player.gun[player.nowgun].clip--;
        }
        if (player.level >= ar_less && kd(k_autoreload))
        {
            player.autoload = !player.autoload;
            Sleep(100);
        }
        if (player.level >= at_less && kd(k_autotp))
        {
            player.autotp = !player.autotp;
            Sleep(100);
        }
        if (kd(k_hl_u))
        {
            if (cmx) cmx--;
            Sleep(100);
        }
        if (kd(k_hl_d))
        {
            if (cmx < WLINE) cmx++;
            Sleep(100);
        }
        if (kd(k_hl_l))
        {
            if (cmy) cmy--;
            Sleep(100);
        }
        if (kd(k_hl_r))
        {
            if (cmy < WCOL) cmy++;
            Sleep(100);
        }
    }
}

DWORD WINAPI T_Move(LPVOID lpInore) // 玩家移动信息处理线程(兼管瞬移、空投、速度)
{
    while (1)
    {
        if (player.is_die) ExitThread(0);
        if ((kd(k_pl_u)))
        {
            //          getch();
            mov(player, - 1, 0);
//          judge(x, y);
        }
        if ((kd(k_pl_l)))
        {
            //          getch();
            mov(player, 0, - 1);
//          judge(x, y);
        }
        if ((kd(k_pl_d)))
        {
            //          getch();
            mov(player, 1, 0);
//          judge(x, y);
        }
        if ((kd(k_pl_r)))
        {
            //          getch();
            mov(player, 0, 1);
//          judge(x, y);
        }
        if (kd(k_tp))
        {
            //          getch();
            if (player.teleport != 0)
            {
                player.Teleport(mt);
            }
            Sleep(100);
        }
        if (kd(k_ender_pearl))
        {
            if (player.teleport >= 5 || player.teleport < 0)
            {
                player.mapx = cmx;
                player.mapy = cmy;
                player.x = LINE / 2;
                player.y = COL / 2;
                player.teleport -= 5;
            }
            Sleep(100);
        }
        if (kd(k_drop))
        {
            //          getch();
            airdrop.random(mt, player);
        }
        if (kd(k_speed))
        {
            player.speed = !player.speed;
            Sleep(100);
        }
        else Sleep(player.speed ? 20 : 50);
    }
}

DWORD WINAPI T_Print(LPVOID lpIg) // 界面输出线程
{
    while (1)
    {
        if (player.is_die) ExitThread(0);
        cur.Goto(0, 0);
        printm(whole[player.dim][player.mapx][player.mapy] & 0xf);
        Sleep(1000 / FPS);
    }
}
// 设置GUI
void printGUI(int NowSection = 0, int NowKey = 0, bool edit = 0)
{
    cur.Goto(0, 0);
    system("color 0f & cls");
    cout << "键位设置 (DELETE 编辑)" << endl << "--------" << endl;
    cout << "向下攻击\t";
    if(NowSection == 0 && NowKey == 0) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_att_d] << endl;
    if(NowSection == 0 && NowKey == 0) SetColor(0x0f);
    cout << "向上攻击\t";
    if(NowSection == 0 && NowKey == 1) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_att_u] << endl;
    if(NowSection == 0 && NowKey == 1) SetColor(0x0f);
    cout << "向左攻击\t";
    if(NowSection == 0 && NowKey == 2) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_att_l] << endl;
    if(NowSection == 0 && NowKey == 2) SetColor(0x0f);
    cout << "向右攻击\t";
    if(NowSection == 0 && NowKey == 3) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_att_r] << endl;
    if(NowSection == 0 && NowKey == 3) SetColor(0x0f);
    cout << "向下移动\t";
    if(NowSection == 0 && NowKey == 4) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_pl_d] << endl;
    if(NowSection == 0 && NowKey == 4) SetColor(0x0f);
    cout << "向上移动\t";
    if(NowSection == 0 && NowKey == 5) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_pl_u] << endl;
    if(NowSection == 0 && NowKey == 5) SetColor(0x0f);
    cout << "向左移动\t";
    if(NowSection == 0 && NowKey == 6) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_pl_l] << endl;
    if(NowSection == 0 && NowKey == 6) SetColor(0x0f);
    cout << "向右移动\t";
    if(NowSection == 0 && NowKey == 7) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_pl_r] << endl;
    if(NowSection == 0 && NowKey == 7) SetColor(0x0f);
    cout << "高亮向下\t";
    if(NowSection == 0 && NowKey == 8) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_hl_d] << endl;
    if(NowSection == 0 && NowKey == 8) SetColor(0x0f);
    cout << "高亮向上\t";
    if(NowSection == 0 && NowKey == 9) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_hl_u] << endl;
    if(NowSection == 0 && NowKey == 9) SetColor(0x0f);
    cout << "高亮向左\t";
    if(NowSection == 0 && NowKey == 10) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_hl_l] << endl;
    if(NowSection == 0 && NowKey == 10) SetColor(0x0f);
    cout << "高亮向右\t";
    if(NowSection == 0 && NowKey == 11) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_hl_r] << endl;
    if(NowSection == 0 && NowKey == 11) SetColor(0x0f);
    cout << "自动换弹\t";
    if(NowSection == 0 && NowKey == 12) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_autoreload] << endl;
    if(NowSection == 0 && NowKey == 12) SetColor(0x0f);
    cout << "保命瞬移\t";
    if(NowSection == 0 && NowKey == 13) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_autotp] << endl;
    if(NowSection == 0 && NowKey == 13) SetColor(0x0f);
    cout << "召唤空投\t";
    if(NowSection == 0 && NowKey == 14) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_drop] << endl;
    if(NowSection == 0 && NowKey == 14) SetColor(0x0f);
    cout << "末影珍珠\t";
    if(NowSection == 0 && NowKey == 15) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_ender_pearl] << endl;
    if(NowSection == 0 && NowKey == 15) SetColor(0x0f);
    cout << "补充弹药\t";
    if(NowSection == 0 && NowKey == 16) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_reload] << endl;
    if(NowSection == 0 && NowKey == 16) SetColor(0x0f);
    cout << "随机瞬移\t";
    if(NowSection == 0 && NowKey == 17) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_tp] << endl;
    if(NowSection == 0 && NowKey == 17) SetColor(0x0f);
    cout << "速度切换\t";
    if(NowSection == 0 && NowKey == 18) SetColor(edit ? 0xb0 : 0x70);
    cout << keymp[k_speed] << endl;
    if(NowSection == 0 && NowKey == 18) SetColor(0x0f);
    cout << endl << "辅助功能最低启用关卡数" << endl << "--------" << endl;
    cout << "自动换弹\t";
    if(NowSection == 1 && NowKey == 0) SetColor(edit ? 0xb0 : 0x70);
    cout << ar_less << endl;
    if(NowSection == 1 && NowKey == 0) SetColor(0x0f);
    cout << "保命瞬移\t";
    if(NowSection == 1 && NowKey == 1) SetColor(edit ? 0xb0 : 0x70);
    cout << at_less << endl;
    if(NowSection == 1 && NowKey == 1) SetColor(0x0f);
}
void settingGUI()
{
    printGUI();
    int sec = 0, key = 0;
    int totsec = 2;
    vector<int> totkey = {19, 2};
    while(1)
    {
        // TODO: Edit
        if(kd(VK_TAB))
        {
            getch();
            sec = (sec + 1) % totsec;
            key = 0;
            printGUI(sec, key);
        }
        if(kd(VK_UP))
        {
            key = (key - 1 + totkey[sec]) % totkey[sec];
            printGUI(sec, key);
        }
        if(kd(VK_DOWN))
        {
            key = (key + 1) % totkey[sec];
            printGUI(sec, key);
        }
        if(sec == 0)
        {
            if(kd(VK_DELETE))
            {
                Sleep(50);
                printGUI(sec, key, true);
                int keyvk = 0;
                while(1)
                {
                    bool f = 1;
                    for(auto vk : prockeys)
                    {
                        if(kd(vk))
                        {
                            if(isupper(vk) || isdigit(vk) || vk == VK_RETURN || 0x60 <= vk && vk <= 0x6f || 0xba <= vk) getch();
                            keyvk = vk;
                            f = 0;
                            break;
                        }
                    }
                    if(kd(VK_DELETE))
                    {
                        keyvk = 0;
                        break;
                    }
                    if(f == 0) break;
                }
                *keymap[key] = keyvk;
                printGUI(sec, key);
            }
        }
        if(sec == 1)
        {
            if(kd(VK_DELETE))
            {
                printGUI(sec, key, true);
                int num = 0;
                while(!kd(VK_RETURN))
                {
                    for(int i = 0; i <= 9; i++)
                    {
                        if(kd('0' + i))
                        {
                            getch();
                            num = num * 10 + i;
                            if(key == 0) ar_less = num;
                            if(key == 1) at_less = num;
                            printGUI(sec, key, true);
                            Sleep(100);
                        }
                    }
                }
                while(getch() != '\r');
                printGUI(sec, key);
            }
        }
        if(kd(VK_ESCAPE))
        {
            return;
        }
        Sleep(100);
    }
}
// 主函数
int main(int argc, char *argv[])
{
    filename = argv[0]; // 启动文件名 
    DWORD fdwMode;
    GetConsoleMode(hIn, &fdwMode);
    fdwMode |=
        ENABLE_INSERT_MODE;
    fdwMode &= ~ ENABLE_QUICK_EDIT_MODE;
    SetConsoleMode(hIn, fdwMode); // 关闭快速编辑,打开插入模式 

    airdrop.reset();

    for(int i = 0; i < GUNTOT; i++)
        player.gun[i].clip = start_bullet_clip[i]; // 开始弹夹 

    if (argc == 1) // 刚点进来,存档管理界面
    {
        int n;
        if (INIread("doc", "num") == "") // 新人,没有配置文件
        {
            n = 0;
            INIwrite("doc", "num", "0");
            // 键位绑定配置
            INIwrite("key", "att_d", to_string(k_att_d));
            INIwrite("key", "att_u", to_string(k_att_u));
            INIwrite("key", "att_l", to_string(k_att_l));
            INIwrite("key", "att_r", to_string(k_att_r));
            INIwrite("key", "atrld", to_string(k_autoreload));
            INIwrite("key", "attp", to_string(k_autotp));
            INIwrite("key", "drp", to_string(k_drop));
            INIwrite("key", "ender", to_string(k_ender_pearl));
            INIwrite("key", "hl_d", to_string(k_hl_d));
            INIwrite("key", "hl_u", to_string(k_hl_u));
            INIwrite("key", "hl_l", to_string(k_hl_l));
            INIwrite("key", "hl_r", to_string(k_hl_r));
            INIwrite("key", "pl_d", to_string(k_pl_d));
            INIwrite("key", "pl_u", to_string(k_pl_u));
            INIwrite("key", "pl_l", to_string(k_pl_l));
            INIwrite("key", "pl_r", to_string(k_pl_r));
            INIwrite("key", "rld", to_string(k_reload));
            INIwrite("key", "tp", to_string(k_tp));
            INIwrite("key", "spd", to_string(k_speed));
        }
        else
        {
            n = stoi(INIread("doc", "num"));
            // 键位绑定配置
            nINIwrite("key", "att_d", (k_att_d));
            nINIwrite("key", "att_u", (k_att_u));
            nINIwrite("key", "att_l", (k_att_l));
            nINIwrite("key", "att_r", (k_att_r));
            nINIwrite("key", "atrld", (k_autoreload));
            nINIwrite("key", "attp", (k_autotp));
            nINIwrite("key", "drp", (k_drop));
            nINIwrite("key", "ender", (k_ender_pearl));
            nINIwrite("key", "hl_d", (k_hl_d));
            nINIwrite("key", "hl_u", (k_hl_u));
            nINIwrite("key", "hl_l", (k_hl_l));
            nINIwrite("key", "hl_r", (k_hl_r));
            nINIwrite("key", "pl_d", (k_pl_d));
            nINIwrite("key", "pl_u", (k_pl_u));
            nINIwrite("key", "pl_l", (k_pl_l));
            nINIwrite("key", "pl_r", (k_pl_r));
            nINIwrite("key", "rld", (k_reload));
            nINIwrite("key", "tp", (k_tp));
            nINIwrite("key", "spd", (k_speed));
        }
        DOC doc[n + 1];
        for (int i = 1; i <= n; i++)
        {
            doc[i].player = INIread(to_string(i), "player");
            doc[i].level = stoi(INIread(to_string(i), "level"));
            doc[i].monsterhp = stoi(INIread(to_string(i), "mhp"));
            doc[i].pas = INIread(to_string(i), "pas");
            doc[i].num = i;
        }
        sort(doc + 1, doc + n + 1, cmp);
        bool N = false, O = false, S = false;
        DelayPrint("地牢 Version 2.2\n", 1);
        if (INIread("program", "version") != "2.2")
        {
            DelayPrint("2.1 New features:\n*\t=) 排名 & 存档\n*\t=) md5加密存档\n*\t人性化的瞬移\n", 1);
            DelayPrint("2.2 News: Keysetting\n", 1);
            INIwrite("program", "version", "2.2");
        }
docp:
        N = O = S = 0;
        DelayPrint("当前存档:\n", 1);
        DelayPrint("Rank  INI No.  Player         Level   MonsterHpLast\n---------------------------------------------------\n", 1);
        for (int i = 1; i <= n; i++)
        {
            printf("%-5d %-8d %-14s %-7d %-12d\n", i, doc[i].num, doc[i].player.data(), doc[i].level, doc[i].monsterhp);
        }
        DelayPrint("---------------------------------------------------\n新建存档(N)\n打开存档(O)\n选项设置(S)\n", 1);
        char c = getch();
        if (c == 'n' || c == 'N') // 新建存档
        {
            system("cls");
//          getch();
            cout << "Player name: \nPassword: ";
            cur.Goto(13, 0);
            string pl;
            getline(cin, pl);
            cur.Back();
            cur.Goto(10, 1);
            string psd;
            getline(cin, psd);
            INIwrite("doc", "num", to_string(n + 1));
            INIwrite(to_string(n + 1), "player", pl);
            INIwrite(to_string(n + 1), "level", "1");
            INIwrite(to_string(n + 1), "mhp", "10");
            INIwrite(to_string(n + 1), "pas", md5.encode(psd));
            // start
            Start(1, n + 1);
        }
        else if (c == 'o' || c == 'O') // 打开存档
        {
            system("cls");
//          getch();
            int num = 0;
            while (num <= 0 || num > n)
            {
                cout << "Input rank: ";
                string tmp;
                getline(cin, tmp);
                num = stoi(tmp);
                //              cin.setstate(ios::goodbit);
            }
            cout << "Input password: " << flush;
            string psd;
            getline(cin, psd); // TODO: 关闭密码显示 
            MD5 md5;
            if (md5.encode(psd) != doc[num].pas)
            {
                system("cls");
                goto docp;
            }
            // start
            Start(doc[num].level, doc[num].num);
        }
        else if(c == 's' || c == 'S')
        {
            // 设置可控制键位 
            prockeyspush(0x01);
            prockeyspush(0x02);
            prockeyspush(0x04);
            prockeyspush(0x05);
            prockeyspush(0x06);
            prockeyspush(0x08);
            prockeyspush(0x09);
            prockeyspush(0x0d);
            prockeyspush(0x14);
            prockeyspush(0x1b);
            prockeyspush(0x90);
            prockeyspush(0x91);
            for(int i = 0x20; i <= 0x28; i++) prockeyspush(i);
            for(int i = 0x30; i <= 0x39; i++) prockeyspush(i);
            for(int i = 0x41; i <= 0x5a; i++) prockeyspush(i);
            for(int i = 0x60; i <= 0x6b; i++) prockeyspush(i);
            for(int i = 0x6d; i <= 0x87; i++) prockeyspush(i);
            for(int i = 0xa0; i <= 0xa5; i++) prockeyspush(i);
            for(int i = 0xba; i <= 0xc0; i++) prockeyspush(i);
            for(int i = 0xdb; i <= 0xde; i++) prockeyspush(i);
            // 设置界面
            settingGUI();
            system("cls");
            ShellExecuteA(NULL, "open", argv[0], NULL, NULL, SW_SHOW);
        }
//      player.is_die = true;
        return 0;
    }
    else if (argc == 2) return 0; // 不合规矩
    else // 开始吧
    {
        monster.hp = (player.level = stoi(argv[1])) * 10;
        numini = stoi(argv[2]);
    }
    SetConsoleTitle(player.level ? ("地牢 Lvl." + to_string(player.level)).data() : "地牢");
    player.teleport = player.level * 2;
    player.speed = 0;
    inv.resize(WLINE * WCOL + 5); // 死路返回值 
    fill(inv.begin(), inv.end(), -1);

    string cmd = "mode con cols=" + to_string(COL * 2 + 50 + WCOL * 2) + " lines=" + to_string(max(WLINE, LINE) + 5);
    cout << cmd << endl;
    Sleep(1000);
    system(cmd.data());
    Sleep(1000);
    monster.x = monster.y = 5;
    player.x = player.y = 2;
    monster.mapx = WLINE;
    monster.mapy = WCOL;
    mt.seed(st = time(NULL));
    int cnt = 0;
    for(int d = 0; d < DIM; d++)
    {
        for(int i = 0; i < LINE * WLINE; i++)
        {
            for(int j = 0; j < COL * WCOL; j++)
            {
                world[d][i][j].push_back(AIR);
            }
        }
    }
    for (int d = DIM - 1; d >= 0; d--) // 生成各维度的地图
    {
        cout << "DIM " << d << ' ';
        do
        {
            ++cnt;
            if (cnt >= 5)
            {
                Start(player.level, numini);
                player.is_die = true;
                return 0;
            }
            memset(whole, 0, sizeof whole);
            for (int i = 0; i <= WLINE; i++)
            {
                for (int j = 0; j <= WCOL; j++)
                {
                    if (i == j && j == 0)
                        continue;
                    if (i == WLINE && j == WCOL)
                        continue;
                    setwall(i, j, (mt() % 10 == UP) * UP);
                    setwall(i, j, (mt() % 10 == DOWN) * DOWN);
                    setwall(i, j, (mt() % 10 == LEFT) * LEFT);
                    setwall(i, j, (mt() % 10 == RIGHT) * RIGHT);
                }
            }
            for (int i = 0; i <= WLINE; i++)
            {
                setwall(i, 0, LEFT);
                setwall(i, WCOL, RIGHT);
            }
            for (int i = 0; i <= WCOL; i++)
            {
                setwall(0, i, UP);
                setwall(WLINE, i, DOWN);
            }
            for (int i = 0; i <= WLINE; i++) // 免得穿墙
            {
                for (int j = 0; j <= WCOL; j++)
                {
                    if (i != 0)
                    {
                        setwall(i, j, ((whole[0][i - 1][j] & DOWN) == DOWN) ? UP : 0);
                    }
                    if (i != WLINE)
                    {
                        setwall(i, j, ((whole[0][i + 1][j] & UP) == UP) ? DOWN : 0);
                    }
                    if (j != 0)
                    {
                        setwall(i, j, ((whole[0][i][j - 1] & RIGHT) == RIGHT) ? LEFT : 0);
                    }
                    if (j != WCOL)
                    {
                        setwall(i, j, ((whole[0][i][j + 1] & LEFT) == LEFT) ? RIGHT : 0);
                    }
                }
            }
            cout << '@';
        }
        while (dfs(monster, player) == inv);
        memcpy(whole[d], whole[0], sizeof(whole[d]));
        cout << '#';
        // 对大地图进行处理
        for(int i = 0; i <= WLINE; i++)
        {
            for(int j = 0; j <= WCOL; j++)
            {
//              world[d][i * LINE + 1][j * COL + 1][0] = WALL;
//              world[d][i * LINE + 9][j * COL + 1][0] = WALL;
//              world[d][i * LINE + 9][j * COL + 9][0] = WALL;
//              world[d][i * LINE + 1][j * COL + 9][0] = WALL;
//              if(whole[d][i][j] & UP) // 设置向上的墙
//                  for(int k = 2; k <= 8; k++)
//                      world[d][i * LINE + k][j * COL][0] = WALL;
//              if(whole[d][i][j] & DOWN)
//                  for(int k = 2; k <= 8; k++)
//                      world[d][i * LINE + k][j * COL + 9][0] = WALL;
//              if(whole[d][i][j] & LEFT)
//                  for(int k = 2; k <= 8; k++)
//                      world[d][i * LINE][j * COL + k][0] = WALL;
//              if(whole[d][i][j] & RIGHT)
//                  for(int k = 2; k <= 8; k++)
//                      world[d][i * LINE + 9][j * COL + k][0] = WALL;
                world[d][i * LINE + 1][j * COL + 1].push_back(WALL);
                world[d][i * LINE + 9][j * COL + 1].push_back(WALL);
                world[d][i * LINE + 9][j * COL + 9].push_back(WALL);
                world[d][i * LINE + 1][j * COL + 9].push_back(WALL);
                if(whole[d][i][j] & UP) // 设置向上的墙
                    for(int k = 2; k <= 8; k++)
                        world[d][i * LINE + k][j * COL].push_back(WALL);
                if(whole[d][i][j] & DOWN)
                    for(int k = 2; k <= 8; k++)
                        world[d][i * LINE + k][j * COL + 9].push_back(WALL);
                if(whole[d][i][j] & LEFT)
                    for(int k = 2; k <= 8; k++)
                        world[d][i * LINE][j * COL + k].push_back(WALL);
                if(whole[d][i][j] & RIGHT)
                    for(int k = 2; k <= 8; k++)
                        world[d][i * LINE + 9][j * COL + k].push_back(WALL);
            }
        }
        cout << '#' << endl;
    }

    //keybd_event(VK_LSHIFT, 0, 0, 0); // 帮你按一下shift
    //keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);
    system("cls");
    CreateThread(NULL, 0, T_MonsterProc, NULL, 0, NULL); // 启动线程
    CreateThread(NULL, 0, T_LetBulletFly, NULL, 0, NULL);
    CreateThread(NULL, 0, T_WriteMsg, NULL, 0, NULL);
    CreateThread(NULL, 0, T_Shoot, NULL, 0, NULL);
    CreateThread(NULL, 0, T_Move, NULL, 0, NULL);
    CreateThread(NULL, 0, T_Print, NULL, 0, NULL);
    // TODO
    CONSOLE_CURSOR_INFO cci; // 不显示光标
    GetConsoleCursorInfo(hOut, &cci);
    cci.bVisible = 0;
    SetConsoleCursorInfo(hOut, &cci);
    mtime_t lasthide = 0;
    while (1)
    {
        Sleep(10);
        if (monster == player) // 碰到了
        {
            if (player.autotp) // 瞬移
            {
                player.Teleport(mt);
            }
            else if (mt() % (player.level * 2) >= 2) // 死
                break;
            else // 闪避
            {
                player.is_dodge = 1;
                lasthide = getmtime();
            }
        }
        if (player.is_dodge && getmtime() - lasthide > 50) player.is_dodge = 0;
        airdrop.GetIfCan(player);
        if (monster.hp == 0) // 怪死庆祝
        {
            INIwrite(to_string(numini), "level", to_string(player.level));
            INIwrite(to_string(numini), "mhp", to_string(monster.hp));
            SetColor(0x2d);
            CreateThread(NULL, 0, T_GOBeep, NULL, 0, NULL);
            DelayPrint("WIN!!!");
            Sleep(1000);
            Start(player.level + 1, numini);
            player.is_die = true;
            return 0;
        }
    }
    player.is_die = true; // 死了,通知其他线程结束
    INIwrite(to_string(numini), "level", to_string(player.level));
    INIwrite(to_string(numini), "mhp", to_string(monster.hp));
    SetColor(0xc3);
    CreateThread(NULL, 0, T_GOBeep, NULL, 0, NULL);
    DelayPrint("Your computer has been fucked by the MEMZ trojan\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bGAME OVER!!!");
    Sleep(10000);
    return 0;
}