【The Best Game】能量世界2

· · 个人记录

#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1 : 0)
#define Large(x, y) ((Large){x, y})
using namespace std;

void Color(int a)
{
    //白 
    if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    //绿 
    if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
    //红 
    if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
    //蓝 
    if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
    //粉
    if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE); 
    //黄
    if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN); 
    //灰 
    if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    //棕
    if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN); 
    //随机
    if(a == -1) Color(rand() % 8); 
}

void clear() { system("cls"); }

char input()
{
    while(1)
    {
        if(_kbhit())
        {
            return _getch();
        }
    }
}

char input(int i, int j)
{
    while(1)
    {
        char x = input();
        if(x >= i && x <= j) return x;
    }
}

//在[a, b)之间产生一个随机整数
int random(int a, int b)
{
    int c=(rand() % (a-b))+ a;
    return c;
}

void SetPos(COORD a)// set cursor 
{
    HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(out, a);
}

void SetPos(int i, int j)// set cursor
{
    COORD pos={short(i), short(j)};
    if(j < 0) SetPos({0, 39});
    else SetPos(pos);
}

void HideCursor()
{
    CONSOLE_CURSOR_INFO cursor_info = {1, 0}; 
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}

// 获取鼠标点击位置
POINT p;
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h = GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;

COORD getpos()
{
    if(KEY_DOWN(VK_LBUTTON))
    {
        POINT p;
        GetCursorPos(&p);
        ScreenToClient(h, &p);
        GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
        int x = p.x /= consoleCurrentFont.dwFontSize.X;
        int y = p.y /= consoleCurrentFont.dwFontSize.Y;
        SetPos(x, y);
        return {x, y};
    }
    if(KEY_DOWN(VK_RBUTTON))
    {
        POINT p;
        GetCursorPos(&p);
        ScreenToClient(h, &p);
        GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
        int x = p.x /= consoleCurrentFont.dwFontSize.X;
        int y = p.y /= consoleCurrentFont.dwFontSize.Y;
        SetPos(x, y);
        return {x, y};
    }
    return {-1, -1};
}

//高精度系统
struct Large
{
    double a; //前7位
    long long e; //位数

    void jinwei(); //进位 
    string num(); //显示 
    string intnum();
};

void Large::jinwei()
{
    if(a == 0) e = 0;
    while(abs(a) >= 10.0)
    {
        a /= 10.0;
        e++;
    }
    while(abs(a) < 1 && abs(a) != 0)
    {
        a *= 10.0;
        e--;
    }
}

string Large::num()
{
    if(e >= 6) return (to_string(a) + "e" + to_string(e));
    else return to_string(a * pow(10, e));
}

string Large::intnum()
{
    if(e >= 3) return (to_string(int(a)) + "e" + to_string(e));
    else return to_string(int(a * pow(10, e)));
}

bool operator>(const Large& ll1, const Large& ll2)
{
    Large l1 = ll1, l2 = ll2;
    l1.jinwei();
    l2.jinwei();
    if(l1.e > l2.e)
    {
        return true;
    }
    else if(l1.e < l2.e)
    {
        return false;
    }
    else
    {
        if(l1.a > l2.a) return true;
        else return false;
    }
}

bool operator>=(const Large& ll1, const Large& ll2)
{
    Large l1 = ll1, l2 = ll2;
    l1.jinwei();
    l2.jinwei();
    if(l1.e > l2.e)
    {
        return true;
    }
    else if(l1.e < l2.e)
    {
        return false;
    }
    else
    {
        if(l1.a >= l2.a) return true;
        else return false;
    }
}

bool operator<(const Large& ll1, const Large& ll2)
{
    Large l1 = ll1, l2 = ll2;
    l1.jinwei();
    l2.jinwei();
    if(l1.e < l2.e)
    {
        return true;
    }
    else if(l1.e > l2.e)
    {
        return false;
    }
    else
    {
        if(l1.a < l2.a) return true;
        else return false;
    }
}

bool operator<=(const Large& ll1, const Large& ll2)
{
    Large l1 = ll1, l2 = ll2;
    l1.jinwei();
    l2.jinwei();
    if(l1.e < l2.e)
    {
        return true;
    }
    else if(l1.e > l2.e)
    {
        return false;
    }
    else
    {
        if(l1.a <= l2.a) return true;
        else return false;
    }
}

Large operator+(const Large& l1, const Large& l2)
{
    Large ans;
    if(l1.e > l2.e)
    {
        ans.a = l1.a + l2.a / pow(10, l1.e - l2.e);
        ans.e = l1.e;
    }
    else if(l2.e > l1.e)
    {
        ans.a = l2.a + l1.a / pow(10, l2.e - l1.e);
        ans.e = l2.e;
    }
    else
    {
        ans.a = l1.a + l2.a;
        ans.e = l1.e;
    }
    ans.jinwei();
    return ans;
}

Large operator-(const Large& l1, const Large& l2)
{
    Large ans;
    if(l1.e > l2.e)
    {
        ans.a = l1.a - l2.a / pow(10, l1.e - l2.e);
        ans.e = l1.e;
    }
    else if(l2.e > l1.e)
    {
        ans.a = -l2.a + l1.a / pow(10, l2.e - l1.e);
        ans.e = l2.e;
    }
    else
    {
        ans.a = l1.a - l2.a;
        ans.e = l1.e;
    }
    ans.jinwei();
    return ans;
}

Large operator*(const Large& l1, const Large& l2)
{
    Large ans;
    ans.a = l1.a * l2.a;
    ans.e = l1.e + l2.e;
    ans.jinwei();
    return ans;
}

Large operator/(const Large& l1, const Large& l2)
{
    Large ans;
    if(l2.a == 0)
    {
        ans.a = 0;
        ans.e = 0;
        return ans;
    }
    else
    {
        ans.a = l1.a / l2.a;
        ans.e = l1.e - l2.e;
        ans.jinwei();
        return ans;
    }
}

Large log10(const Large& l1)
{
    Large ans;
    ans.a = l1.e;
    ans.e = 0;
    ans.jinwei();
    return ans;
}

Large log(const Large &l1)
{
    Large ans;
    ans.a = l1.e * (log(10));
    ans.e = 0;
    ans.jinwei();
    return ans;
}

Large sqrt(const Large& l1)
{
    Large ans;
    ans.a = sqrt(l1.a);
    ans.e = l1.a / 2;
    ans.jinwei();
    return ans;
}

//**************************************************************************
//**************************游戏界面**************************************** 

Large money = {1, 0};
Large cnt[8] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}};
Large price[8] = {{1, 0}, {1, 1}, {1, 2}, {1, 4}, {1, 8}, {1, 16}, {1, 32}, {1, 40}};
Large pricex[8] ={{1, 2}, {1, 5}, {1, 8}, {1, 11}, {1, 14}, {1, 17}, {1, 20}, {1, 23}};
Large cntx[8] = {{1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}};

Large xcnt[8];

int boost = 0, evolution = 0, chaos = 0;
Large cp = {0, 0};

long long lixian_clock, lixian;

bool cptree[2010];
bool chaoschall[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 

bool autobuy[8] = {0, 0, 0, 0, 0, 0, 0, 0};
bool autoboost = 0;
bool autoevolution = 0;
bool autochaos = 0;

int nowchaoschall = 0;

Large goumai_beishu, nowchaosaddcp;
Large boost_power, evolution_power;
Large maxmoneyinchaos = {1, 0};
Large mincptochaos = {1, 0};

int goumai_huanchong = 0;

void OUTS()
{
    ofstream fout("EWIIDt.txt", ios::out);
    fout << money.a << ' ' << money.e << endl;
    for(int i = 0;i < 8;i++)
    {
        fout << cnt[i].a << ' ' << cnt[i].e << ' ';
        fout << price[i].a << ' ' << price[i].e << ' ';
        fout << pricex[i].a << ' ' << pricex[i].e << ' ';
        fout << cntx[i].a << ' ' << cntx[i].e << ' ';
        fout << endl;
    }
    fout << boost << endl;
    fout << evolution << endl;
    fout << chaos << endl;
    fout << cp.a << ' ' << cp.e << endl;
    fout << time(0) << endl;
    int cntcpt = 0;
    for(int i = 0;i < 2010;i++)
    {
        if(cptree[i]) cntcpt++;
    }
    fout << cntcpt << endl;
    for(int i = 0;i < 2010;i++)
    {
        if(cptree[i]) fout << i << ' ';
    }
    fout << endl;
    for(int i = 0;i < 8;i++) fout << autobuy[i] << ' ';
    fout << endl;
    fout << autoboost << endl; 
    fout << autoevolution << endl;
    fout << autochaos << endl;
    fout << maxmoneyinchaos.a << ' ' << maxmoneyinchaos.e << endl;
    fout << mincptochaos.a << ' ' << mincptochaos.e << endl;
    for(int i = 0;i < 10;i++) fout << chaoschall[i] << ' ';
    fout << endl;
    fout << nowchaoschall << endl;
}

void INS()
{
    ifstream fin("EWIIDt.txt", ios::in);
    fin >> money.a >> money.e;
    for(int i = 0;i < 8;i++)
    {
        fin >> cnt[i].a >> cnt[i].e;
        fin >> price[i].a >> price[i].e;
        fin >> pricex[i].a >> pricex[i].e;
        fin >> cntx[i].a >> cntx[i].e;
    }
    fin >> boost;
    fin >> evolution;
    fin >> chaos;
    fin >> cp.a >> cp.e;
    fin >> lixian_clock;
    lixian = (time(0) - lixian_clock) * 40;
    int cntcpt;
    fin >> cntcpt;
    for(int i = 0;i < cntcpt;i++)
    {
        int xn;
        fin >> xn;
        cptree[xn] = true;
    }
    for(int i = 0;i < 8;i++) fin >> autobuy[i];
    fin >> autoboost;
    fin >> autoevolution;
    fin >> autochaos;
    fin >> maxmoneyinchaos.a >> maxmoneyinchaos.e;
    fin >> mincptochaos.a >> mincptochaos.e;
    for(int i = 0;i < 10;i++) fin >> chaoschall[i];
    fin >> nowchaoschall;
}

bool canbuy(int i)
{
    if(money >= price[i]) return true;
    else return false;
}

void buy(int i)
{
    if(canbuy(i))
    {
        money = money - price[i];
        cnt[i] = cnt[i] + Large(1, 0);
        cntx[i] = cntx[i] * goumai_beishu;
        price[i] = price[i] * pricex[i];

        double zengsu = 1.0;
        if(cptree[33]) zengsu *= 0.9;
        if(cptree[71]) zengsu *= 0.7;

        if(price[i] >= Large(1, 100))
        {
            zengsu *= 2;
            pricex[i] = pricex[i] * Large(zengsu, 0);
        }
        if(price[i] >= Large(1.79, 308))
        {
            zengsu *= 3;
            pricex[i] = pricex[i] * Large(zengsu, 0);
        }
        if(price[i] >= Large(1, 3000))
        {
            zengsu *= 6;
            pricex[i] = pricex[i] * Large(zengsu, 0);
        }
        if(price[i] >= Large(1, 4000))
        {
            zengsu *= 300;
            pricex[i] = pricex[i] * Large(zengsu, 0);
        }
    }
}

void buyboost()
{
    if(money >= Large(1, boost * 5 * sqrt(boost / 4.0) + 5))
    {
        money = !cptree[31] ? Large(1, 0) : Large(1, 30);
        for(int i = 0;i < 8;i++) cnt[i] = {0, 0}, cntx[i] = {1, 0};
        if(cptree[41]) for(int i = 0;i < 8;i++) cntx[i] = cntx[i] * goumai_beishu * goumai_beishu;
        price[0] = {1, 0}, price[1] = {1, 1}, price[2] = {1, 2}, price[3] = {1, 4}, price[4] = {1, 8}, price[5] = {1, 16}, price[6] = {1, 32}, price[7] = {1, 40};
        pricex[0] = {1, 2}, pricex[1] = {1, 5}, pricex[2] = {1, 8}, pricex[3] = {1, 11}, pricex[4] = {1, 14}, pricex[5] = {1, 17}, pricex[6] = {1, 20}, pricex[7] = {1, 23};

        boost++;
    }
}

void buyevolution()
{
    if(money >= Large(1, evolution * 15 * sqrt(evolution / 3.0) + 15))
    {
        money = !cptree[31] ? Large(1, 0) : Large(1, 30);
        for(int i = 0;i < 8;i++) cnt[i] = {0, 0}, cntx[i] = {1, 0};
        if(cptree[41]) for(int i = 0;i < 8;i++) cntx[i] = cntx[i] * goumai_beishu * goumai_beishu;
        price[0] = {1, 0}, price[1] = {1, 1}, price[2] = {1, 2}, price[3] = {1, 4}, price[4] = {1, 8}, price[5] = {1, 16}, price[6] = {1, 32}, price[7] = {1, 40};
        pricex[0] = {1, 2}, pricex[1] = {1, 5}, pricex[2] = {1, 8}, pricex[3] = {1, 11}, pricex[4] = {1, 14}, pricex[5] = {1, 17}, pricex[6] = {1, 20}, pricex[7] = {1, 23};

        boost = (cptree[12] ? (cptree[73] ? 50 : 4) : 0);
        evolution++;
    }
}

void buychaos(bool autobuying)
{
    Large Mubiao = {1.79, 308};
    if(nowchaoschall == 1) Mubiao = Large(1, 600);
    else if(nowchaoschall == 2) Mubiao = Large(1, 1200);
    else if(nowchaoschall != 0) Mubiao = Large(1, 2147483647);

    bool canbuychaos = false;
    if(!cptree[82] && cnt[7] >= Large(1 + chaos / 2, 0)) canbuychaos = true;
    else if(cptree[82]
    && money >= Mubiao
    && ((autobuying && nowchaosaddcp >= mincptochaos) || (!autobuying))) canbuychaos = true;
    if(cptree[82]
    && nowchaoschall != 0
    && (money >= Mubiao)) canbuychaos = true;
    if(canbuychaos)
    {
        money = !cptree[31] ? Large(1, 0) : Large(1, 30);
        for(int i = 0;i < 8;i++) cnt[i] = {0, 0}, cntx[i] = {1, 0};
        if(cptree[41]) for(int i = 0;i < 8;i++) cntx[i] = cntx[i] * goumai_beishu * goumai_beishu;
        price[0] = {1, 0}, price[1] = {1, 1}, price[2] = {1, 2}, price[3] = {1, 4}, price[4] = {1, 8}, price[5] = {1, 16}, price[6] = {1, 32}, price[7] = {1, 40};
        pricex[0] = {1, 2}, pricex[1] = {1, 5}, pricex[2] = {1, 8}, pricex[3] = {1, 11}, pricex[4] = {1, 14}, pricex[5] = {1, 17}, pricex[6] = {1, 20}, pricex[7] = {1, 23};

        boost = (cptree[12] ? (cptree[73] ? 50 : 4) : 0);
        evolution = (cptree[12] ? (cptree[73] ? 15 : 1) : 0);
        chaos++;

        if(!cptree[82]) cp = cp + Large(1, 0);
        else cp = cp + nowchaosaddcp;

        maxmoneyinchaos = {1, 0};

        chaoschall[nowchaoschall] = true;
        nowchaoschall = 0;
    }
}

void chaoschallengereset()
{
    money = !cptree[31] ? Large(1, 0) : Large(1, 30);
    for(int i = 0;i < 8;i++) cnt[i] = {0, 0}, cntx[i] = {1, 0};
    if(cptree[41]) for(int i = 0;i < 8;i++) cntx[i] = cntx[i] * goumai_beishu * goumai_beishu;
    price[0] = {1, 0}, price[1] = {1, 1}, price[2] = {1, 2}, price[3] = {1, 4}, price[4] = {1, 8}, price[5] = {1, 16}, price[6] = {1, 32}, price[7] = {1, 40};
    pricex[0] = {1, 2}, pricex[1] = {1, 5}, pricex[2] = {1, 8}, pricex[3] = {1, 11}, pricex[4] = {1, 14}, pricex[5] = {1, 17}, pricex[6] = {1, 20}, pricex[7] = {1, 23};

    boost = (cptree[12] ? (cptree[73] ? 50 : 4) : 0);
    evolution = (cptree[12] ? (cptree[73] ? 15 : 1) : 0);
}

void add()
{
    boost_power = Large((cptree[11] ? 4.0 : 2.0), 0);
    if(chaoschall[2]) boost_power = boost_power + Large(boost, 0);

    evolution_power = Large((cptree[13] ? 0.4 : 0.2), 0);

    goumai_beishu = Large(2, 0) + Large(evolution, 0) * evolution_power + Large((cptree[22] ? 1.5 : 0.0), 0);
    if(chaoschall[1]) goumai_beishu = goumai_beishu + Large(2, 0);

    nowchaosaddcp.a = (maxmoneyinchaos.e % 308) * 1.0 / 30.8; nowchaosaddcp.e = maxmoneyinchaos.e / 308; nowchaosaddcp.jinwei();


    if(autochaos) buychaos(true);
    if(autoevolution) buyevolution();
    if(autoboost) buyboost();
    for(int i = 0;i < 8;i++)
    {
        if(autobuy[i])
        {
            if(!cptree[30]) buy(i);
            else
            {
                while(canbuy(i)) buy(i);
            }
        }
    }

    for(int i = 0;i < 8;i++)
    {
        xcnt[i] = Large(0.025, 0) * cntx[i]
        * (cptree[2] ? Large(1, 1) : Large(1, 0))
        * (cptree[43] ? Large(5, 1) : Large(1, 0));
        if(cptree[52]) xcnt[i].e *= 2;

        for(int j = 0;j < boost;j++)
        {
            xcnt[i] = xcnt[i] * boost_power;
        }

        if(cptree[60] && (i == 0 || i == 1 || i == 6 || i == 7)) xcnt[i] = xcnt[i] * Large(chaos, 0);
        if(cptree[62] && (i == 2 || i == 3 || i == 4 || i == 5)) xcnt[i] = xcnt[i] * Large(chaos, 0);
        if(cptree[64]) xcnt[i] = xcnt[i] * Large(chaos, 0);

        if(nowchaoschall == 2 && i >= 4 && i <= 7) xcnt[i] = Large(0, 0);

        if(nowchaoschall == 1) xcnt[i].e *= 0.4;
    }
    money = money + (cnt[0] * xcnt[0]);
    if(money > maxmoneyinchaos) maxmoneyinchaos = money;
    for(int i = 0;i < 7;i++)
    {
        Large temp = cnt[i] + (cnt[i + 1] * xcnt[i + 1]);
        cnt[i] = temp;
    }
}


void MAIN()
{
    int page = 0, pagemax = 0;
    if(chaos > 0) pagemax += 2;
    if(cptree[82]) pagemax += 1;

    int oldclock = clock();
    system("cls");
    int flag = 0;

    cout << "离线刻度数:" << min((long long)108000, lixian) << endl;
    cout << "正在计算中(按R可以将刻度减半)" << endl;

    for(int i = 0;i < min((long long)108000, lixian);i++)
    {
        add();
        if(_kbhit())
        {
            char x = _getch();
            if(x == 'r') lixian = (lixian >= 108000 ? 54000 : lixian / 2);
        }
    }

    system("pause");
    system("cls");
    int xpage = 0;
    while(1)
    {
        flag++;
        if(flag % 20 == 0) OUTS(); 
        while(clock() - oldclock < 25)
        {

        }
        add();
        if(goumai_huanchong) goumai_huanchong--;

        Color(0);
        SetPos(5, 2);
        cout << "                                   ";
        SetPos(5, 2);
        cout << "<-- 上一页";
        SetPos(80, 2);
        cout << "                                   ";
        SetPos(105, 2);
        cout << "下一页 -->";

        SetPos(20, 2);
        if(page == 0) cout << "暂无更多页面";
        if(page == 1) cout << "能量体";
        if(page == 2) cout << "混沌";
        if(page == 3) cout << "自动购买器";

        SetPos(90, 2);
        if(page == 0 && chaos > 0) cout << "混沌";
        if(page == 0 && chaos <= 0) cout << "需要:混沌";
        if(page == 1) cout << "自动购买器";
        if(page == 2 && cptree[82]) cout << "混沌挑战"; 
        if(page == 2 && !cptree[82]) cout << "需要:复兴";
        if(page == 3) cout << "暂无更多页面";

        SetPos(45, 2);
        cout << "如果无法更改页面可以重启界面";

        COORD pos = getpos();
        if(pos.X >= 5 && pos.X <= 15 && pos.Y >= 1 && pos.Y <= 3 && !goumai_huanchong)
        {
            page = max(0, page - 1);
            goumai_huanchong = 20;
            system("cls");
        }
        else if(pos.X >= 105 && pos.X <= 115 && pos.Y >= 1 && pos.Y <= 3 && !goumai_huanchong)
        {
            page = min(pagemax, page + 1);
            goumai_huanchong = 20;
            system("cls");
        }

        if(page == 0)
        {
            Color(0);
            SetPos(40, 4);
            cout << "能量                  "; 
            SetPos(40, 4);
            cout << "能量  " << money.num();
            SetPos(83, 4);
            cout << "                   ";
            SetPos(75, 4);
            Color(5);
            cout << "每秒能量  " << (cnt[0] * xcnt[0] * Large(40, 0)).num();
            SetPos(12, 4);
            cout << "                 ";
            SetPos(12, 4);
            cout << "购买倍数:X" << goumai_beishu.num();
            Color(0); 
            SetPos(42, 6);
            cout << "                                      ";
            SetPos(42, 6);
            if(nowchaoschall == 0) cout << "你当前不在挑战中";
            else cout << "你目前处于混沌挑战" << nowchaoschall << "中  按R放弃挑战";

            string nengliangtiname[8] = {"一", "二", "三", "四", "五", "六", "七", "八"};
            for(int i = 0;i < 8;i++)
            {
                SetPos(22, 8 + i * 2);
                cout << "                  ";
                SetPos(46, 8 + i * 2);
                cout << "                  ";
                SetPos(73, 8 + i * 2);
                cout << "    "; 
                SetPos(84, 8 + i * 2);
                cout << "                  ";
                Color(0);
                SetPos(6, 8 + i * 2);
                cout << nengliangtiname[i] << "重能量体:倍数" << (xcnt[i] * Large(40, 0)).num() << "X";
                SetPos(46, 8 + i * 2);
                Color(2), cout << cnt[i].num();
                Color(0);

                SetPos(68, 8 + i * 2);
                cout << "进度 ";
                double qian = money.e + log10(money.a);
                double xianzai = price[i].e + log10(price[i].a);
                double beishu = pricex[i].e;
                SetPos(73, 8 + i * 2);
                cout << int(100 * (qian - xianzai + beishu) / (xianzai - xianzai + beishu));
                SetPos(76, 8 + i * 2), cout << "%   ";

                cout << " 需要";
                SetPos(84, 8 + i * 2);
                if(i >= 1 && cnt[i - 1].a == 0) Color(2);
                else if(money >= price[i]) Color(1);
                else Color(4);
                cout << "   " << price[i].intnum();
                Color(0);
                cout << "   能量";
            }

            Color(0);
            SetPos(13, 24);
            cout << "  ";
            SetPos(38, 24);
            cout << "             ";
            SetPos(6, 24);
            cout << "跃迁:[" << boost << "]";
            SetPos(27, 24);
            cout << "需要 能量  ";
            Color(4), cout << Large(1, boost * 5 * sqrt(boost / 4.0) + 5).num();
            Color(0);
            SetPos(60, 24);
            cout << "Q 以进行跃迁";
            SetPos(80, 24);
            cout << "给予能量体倍数:" << boost_power.num();

            Color(0);
            SetPos(13, 26);
            cout << "  ";
            SetPos(38, 26);
            cout << "             ";
            SetPos(6, 26);
            cout << "进化:[" << evolution << "]";
            SetPos(27, 26);
            cout << "需要 能量  ";
            Color(4), cout << Large(1, evolution * 15 * sqrt(evolution / 3.0) + 15).num();
            Color(0);
            SetPos(60, 26);
            cout << "W 以进行进化";
            SetPos(80, 26);
            cout << "提高能量体购买倍数:+" << evolution_power.num();

            Color(0);
            SetPos(13, 28);
            cout << "  ";
            SetPos(36, 28);
            cout << "             ";
            SetPos(80, 28);
            cout << "                      ";
            SetPos(6, 28);
            cout << "混沌:[" << chaos << "]";
            if(!cptree[82])
            {
                SetPos(27, 28);
                cout << "需要 第八能量体   ";
                Color(4), cout << 1 + chaos / 2;
                Color(0);
            }
            else
            {
                SetPos(27, 28);
                cout << "需要 能量  ";
                Color(4);
                if(nowchaoschall == 0) cout << "1.79e308";
                else if(nowchaoschall == 1) cout << "1e600";
                else if(nowchaoschall == 2) cout << "1e1200";
                Color(0);
            }
            SetPos(60, 28);
            cout << "E 以进行混沌";
            SetPos(80, 28);
            if(!cptree[82]) cout << "获得一个混沌点数"; 
            else cout << "获得 " << nowchaosaddcp.intnum() << " 混沌点数";

            if(_kbhit())
            {
                char x = _getch();
                if(x >= '1' && x <= '8')
                {
                    int i = x - '1';
                    buy(i);
                }
                else if(x == 'q')
                {
                    buyboost();
                }
                else if(x == 'w')
                {
                    buyevolution();
                }
                else if(x == 'e')
                {
                    buychaos(false);
                }
                else if(x == 'r' && nowchaoschall != 0)
                {
                    chaoschallengereset();
                    nowchaoschall = 0;
                }
            }
        }
        else if(page == 1)
        {
            SetPos(12, 4);
            cout << "           ";
            Color(0);
            SetPos(6, 4);
            cout << "混沌点数CP:";
            Color(5);
            SetPos(12, 4);
            cout << cp.num();
            Color(0);

            SetPos(12, 8);
            Color(5);
            cout << "混沌升级";

            int cccc = 1;

            COORD x = getpos();
            int oy = x.Y;
            if(oy >= 14 && oy <= 19) xpage = max(xpage - 1, 0), clear();
            if(oy >= 29 && oy <= 34) xpage = min(xpage + 1, 70), clear();

            Large spp[1000];
            for(int i = 0;i < 1000;i++) spp[i] = {0, 0};
            string jieshao[1000];
            vector<int> qianzhi[1000];

            spp[2] = {1, 0};
            jieshao[2] = "所有能量体以10X效率运转";
            qianzhi[2].push_back(-1);

            spp[11] = {2, 0};
            jieshao[11] = "跃迁以2X效果运转";
            qianzhi[11].push_back(2);

            spp[12] = {1, 0};
            jieshao[12] = "混沌从4个跃迁+1个进化开始,进化从4个跃迁开始"; 
            qianzhi[12].push_back(2);

            spp[13] = {2, 0};
            jieshao[13] = "进化以2X效果运转"; 
            qianzhi[13].push_back(2);

            spp[20] = {4, 0};
            jieshao[20] = "开启跃迁自动购买器";
            qianzhi[20].push_back(11);

            spp[22] = {5, 0};
            jieshao[22] = "能量体购买倍数+1.5";
            qianzhi[22].push_back(11);
            qianzhi[22].push_back(12);
            qianzhi[22].push_back(13);

            spp[24] = {4, 0};
            jieshao[24] = "开启进化自动购买器";
            qianzhi[24].push_back(13);

            spp[30] = {1, 0};
            jieshao[30] = "能量体自动购买器获得无限批次";
            qianzhi[30].push_back(20);

            spp[31] = {3, 0};
            jieshao[31] = "混沌、进化、跃迁从1e30能量开始";
            qianzhi[31].push_back(22);

            spp[33] = {8, 0};
            jieshao[33] = "能量体价格增速的增速X0.9";
            qianzhi[33].push_back(22);

            spp[34] = {4, 0};
            jieshao[34] = "开启自动混沌";
            qianzhi[34].push_back(24);

            spp[41] = {4, 0};
            jieshao[41] = "重置能量体时获得两次免费倍数";
            qianzhi[41].push_back(31);
            qianzhi[41].push_back(30);

            spp[43] = {4, 0};
            jieshao[43] = "能量体获得50X强化";
            qianzhi[43].push_back(33);
            qianzhi[43].push_back(34);

            spp[52] = {1, 0};
            jieshao[52] = "能量体加成倍数^2";
            qianzhi[52].push_back(41);
            qianzhi[52].push_back(43); 

            spp[60] = {2, 1};
            jieshao[60] = "1、2、7、8能量体获得等同于混沌次数的加成";
            qianzhi[60].push_back(52);

            spp[62] = {2, 1};
            jieshao[62] = "3、4、5、6能量体获得等同于混沌次数的加成";
            qianzhi[62].push_back(52);

            spp[64] = {2, 1};
            jieshao[64] = "所有能量体获得平方根于混沌次数的加成"; 
            qianzhi[64].push_back(52);

            spp[71] = {1, 1};
            jieshao[71] = "所有能量体价格增长增速降低30%";
            qianzhi[71].push_back(60);
            qianzhi[71].push_back(62);

            spp[73] = {1, 1};
            jieshao[73] = "混沌后从50个跃迁、15个进化开始,进化从50个跃迁开始";
            qianzhi[73].push_back(62);
            qianzhi[73].push_back(64);

            spp[82] = {3, 1};
            jieshao[82] = "混沌复兴";
            qianzhi[82].push_back(71);
            qianzhi[82].push_back(73); 

            spp[90] = {1, 8};
            jieshao[90] = "开启混沌挑战1";
            qianzhi[90].push_back(82);

            spp[91] = {1, 9};
            jieshao[91] = "开启混沌挑战2";
            qianzhi[91].push_back(82); 

            if(cp >= Large(0, 0))
            {
                int ss = 1;
                for(int i = max(xpage - 2, 0);i <= max(xpage - 2, 0) + 3;i++)
                {
                    ss++;
                    int y = 0;
                    bool flag = true;
                    int xuyao = -1;
                    for(int y = 0;y <= 4;y++)
                    {
                        SetPos(10 + y * 20, 4 + ss * 5);
                        if(spp[i * 10 + y] > Large(0, 0))
                        {
                            flag = true;
                            int pianyi = 0;
                            for(int j = 0;j < qianzhi[i * 10 + y].size();j++)
                            {
                                if(!(qianzhi[i * 10 + y][j] == -1 || cptree[qianzhi[i * 10 + y][j]]))
                                {
                                    flag = false;
                                    xuyao = qianzhi[i * 10 + y][j];
                                }
                            }
                            if(cptree[i * 10 + y]) Color(1);
                            else if(flag && !cptree[i * 10 + y] && cp >= spp[i * 10 + y]) Color(5);
                            else if(flag && !cptree[i * 10 + y] && cp < spp[i * 10 + y]) Color(2);
                            else if(!flag && !cptree[i * 10 + y]) Color(4);
                            else Color(6);
                            if(flag)
                            {
                                for(int j = 0;j < jieshao[i * 10 + y].size();j++)
                                {
                                    cout << jieshao[i * 10 + y][j];
                                    if(j != 0 && j % 18 == 0)
                                    {
                                        SetPos(10 + y * 20, 5 + pianyi + ss * 5);
                                        pianyi++;
                                    } 
                                }
                            }
                            else
                            {
                                if(!flag) cout << "???"; 
                            }
                            SetPos(10 + y * 20, 7 + ss * 5);
                            cout << "价格:" << spp[i * 10 + y].intnum();

                        }
                    }
                }
            }

            COORD pos = getpos();
            if(pos.Y >= 14 && pos.Y <= 34)
            {
                int y = (pos.X - 10) / 20;
                int oy = pos.Y;
                {
                    pos.Y += max(xpage - 2, 0) * 5;
                    bool flag = true;
                    for(int j = 0;j < qianzhi[((pos.Y - 14) / 5) * 10 + y].size();j++)
                    {
                        if(!(qianzhi[((pos.Y - 14) / 5) * 10 + y][j] == -1 || cptree[qianzhi[((pos.Y - 14) / 5) * 10 + y][j]]))
                        {
                            flag = false;
                        }
                    }
                    if(cp >= spp[((pos.Y - 14) / 5) * 10 + y]
                    && spp[((pos.Y - 14) / 5) * 10 + y] > Large(0, 0)
                    && flag
                    && !cptree[(pos.Y - 14) / 5 * 10 + y])
                    {
                        cp = cp - spp[(pos.Y - 14) / 5 * 10 + y];
                        cptree[(pos.Y - 14) / 5 * 10 + y] = true;
                        clear();
                    }
                }
            }

            if(_kbhit())
            {
                char x = _getch();
                if(x == 'q')
                {
                    return;
                }
            }
        }
        else if(page == 2)
        {
            SetPos(6, 4);
            Color(5);
            cout << "自动购买器【每秒可以购买整整40次】";
            SetPos(6, 6);
            Color(0);
            cout << "自动购买能量体:";
            for(int i = 0;i < 8;i++)
            {
                if(!autobuy[i]) Color(2);
                else Color(5);
                cout << i + 1 << ' ';
            }
            SetPos(6, 8);
            Color(0);
            cout << "1~8 开启或关闭自动购买器";

            if(cptree[20])
            {
                SetPos(6, 10);
                cout << "自动购买跃迁:";
                if(!autoboost) Color(2);
                else Color(5);
                cout << 'q';
                SetPos(6, 12);
                Color(0);
                cout << "Q 开启或关闭自动跃迁器";
            }

            if(cptree[24])
            {
                SetPos(6, 14);
                cout << "自动购买进化:";
                if(!autoevolution) Color(2);
                else Color(5);
                cout << 'w';
                SetPos(6, 16);
                Color(0);
                cout << "W 开启或关闭自动进化器";
            }

            if(cptree[34])
            {
                SetPos(6, 18);
                cout << "自动混沌:";
                if(!autochaos) Color(2);
                else Color(5);
                cout << 'e';
                SetPos(6, 20);
                Color(0);
                cout << "E 开启或关闭自动混沌";
                if(cptree[82])
                {
                    SetPos(33, 18);
                    cout << "当前自动混沌需要的CP:";
                    Color(2), cout << mincptochaos.intnum();
                    Color(0);
                    SetPos(33, 20);
                    cout << "D更改,格式:X Y,为保证运行,其中X应为1~9间整数,Y应为1~10^17间整数,即变为XeYcp";
                }
            }

            if(_kbhit())
            {
                char x = _getch();
                if(x >= '1' && x <= '8')
                {
                    autobuy[x - '1'] = !autobuy[x - '1'];
                }
                else if(x == 'q' && cptree[20])
                {
                    autoboost = !autoboost;
                }
                else if(x == 'w' && cptree[24])
                {
                    autoevolution = !autoevolution;
                }
                else if(x == 'e' && cptree[34])
                {
                    autochaos = !autochaos;
                }
                else if(x == 'd' && cptree[82])
                {
                    SetPos(55, 18);
                    cout << "                    ";
                    SetPos(55, 18);
                    int x, y;
                    cin >> x >> y;
                    mincptochaos = Large(x, y);
                }
            }
        }
        else if(page == 3)
        {
            SetPos(6, 4);
            Color(5), cout << "混沌挑战 (按1~9进入挑战)";
            Color(0);

            SetPos(6, 8);
            cout << "                        ";

            SetPos(6, 6);
            cout << "挑战会使得你的某一方面效率大幅降低,目标是在调整后达到一定的能量";
            SetPos(6, 8);
            cout << "你目前处于的挑战:";
            if(nowchaoschall == 0) cout << "无挑战";
            else cout << nowchaoschall;

            Color(0);
            SetPos(6, 10);
            cout << "挑战名";
            SetPos(30, 10);
            cout << "挑战内容";
            SetPos(70, 10);
            cout << "挑战目标";
            SetPos(90, 10);
            cout << "挑战奖励";

            if(cptree[90])
            {
                SetPos(6, 12);
                Color(2), cout << "混沌挑战1";
                if(chaoschall[1]) cout << "(OK)";
                SetPos(30, 12);
                Color(1), cout << "所有能量体产能下降:^0.4"; 
                SetPos(70, 12);
                Color(5), cout << "1e600能量";
                SetPos(90, 12);
                Color(4), cout << "能量体购买倍数+2";
            }

            if(cptree[91])
            {
                SetPos(6, 14);
                Color(2), cout << "混沌挑战2";
                if(chaoschall[2]) cout << "(OK)";
                SetPos(30, 14);
                Color(1), cout << "仅有1~4能量体有产能";
                SetPos(70, 14);
                Color(5), cout << "1e1200能量";
                SetPos(90, 14);
                Color(4), cout << "跃迁越多,效果越强大";
            }

            if(_kbhit())
            {
                char x = _getch();
                if(x == '1' && cptree[90])
                {
                    chaoschallengereset();
                    nowchaoschall = 1;
                }
                else if(x == '2' && cptree[91])
                {
                    chaoschallengereset();
                    nowchaoschall = 2;
                }
            }
        }

        oldclock = clock();
    }
}

int main()
{
    system("mode con cols=120 lines=40");
    HideCursor();
    HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
    DWORD mode;
    GetConsoleMode(hStdin, &mode);
    mode &= ~ENABLE_QUICK_EDIT_MODE;
    SetConsoleMode(hStdin, mode);CONSOLE_CURSOR_INFO cursor_info={1,0}; 
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
    Color(0);

    SetPos(6, 2);
    cout << "The Energy World ii";
    Color(2);
    SetPos(8, 4);
    cout << "能 量 世 界  2";
    SetPos(6, 8);
    Color(3); 
    system("pause");
    INS();
    OUTS();
    MAIN();
    Color(0); 
}