其他分享
首页 > 其他分享> > EasyPrtSc sec[1.2] 发布!

EasyPrtSc sec[1.2] 发布!

作者:互联网

//HOMETAG
#include<bits/stdc++.h>
namespace EasilyPrtSc{
//this namespace is for you to be more easily print the things on the screen.
//copyright (c) dgklr , 2019.
//The program cannot ensure anything goes wrong.
//if you have some ideas, you can connect with us:
//  dgklr:guo_dgklr@qq.com
    #include <windows.h>
    #include <ctime>
    #include <conio.h>   
//------------------------includes-----------------------------------------
    using namespace std;
//------------------------namespace----------------------------------------
    #define chek(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
    #define col(co) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),co)
    #define pause system("pause > nul")
    #undef repeat
    #define repeat(a,b,c,g) for (int a=b,abck=(g>=0?1:-1);abck*(a)<=abck*(c);a+=g)
    #define br BACKGROUND_RED
    #define bg BACKGROUND_GREEN
    #define bb BACKGROUND_BLUE
    #define bi BACKGROUND_INTENSITY
    #define fr FOREGROUND_RED
    #define fg FOREGROUND_GREEN
    #define fb FOREGROUND_BLUE
    #define fi FOREGROUND_INTENSITY
    #define backcolor color^fi^bi
    #undef select
//------------------------definding things---------------------------------DEFTAG
    int M,N;
    // M,N values the lengths.
    // Please don't change it without using void init(int , int , int).
    static bool initialization = 0;
    // initalization values the screen has initialized.
    // ** Don't Change it! **
    int opt[110][110],optcol[110][110];
    // opt values the thing we want to print.
    // optcol values the color.
    int tmp[110][110],tmpcol[110][110];
    //tmp means the thing still on the screen.
    //tmp the same as optcol.
    int nx,ny;
    //it is also a very import thing.
    //It means where you print.
    int color;
    //It means the color you chioce.
    void gotoxy(int y, int x) {
    COORD pos = {x,y};
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hOut, pos);
    }
    //function of gotoxy.
    void HideCursor()
    {
    CONSOLE_CURSOR_INFO cursor_info = {1, 0};
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
    }
    void CreateScreenSize(int y,int x)
    {
    SMALL_RECT winPon={0,0,x-1,y-1};
    HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleWindowInfo(con,true,&winPon);
    }
    void flashScreen()
    { 
    repeat(i,1,N,1)
        repeat(j,1,M,1)
         {
        if (opt[i][j] != tmp[i][j] || optcol[i][j] != tmpcol[i][j])
            gotoxy(i-1,j-1),
            col(optcol[i][j]),
            putchar(opt[i][j]),
            tmp[i][j] = opt[i][j],
            tmpcol[i][j] = optcol[i][j]; 
        }
    }
    void CompulsionflashScreen()
    { 
    repeat(i,1,N,1)
        repeat(j,1,M,1)
         {
            gotoxy(i-1,j-1),
            col(optcol[i][j]),
            putchar(opt[i][j]),
            tmp[i][j] = opt[i][j],
            tmpcol[i][j] = optcol[i][j]; 
        }
    }
    //these function you can also use it from outside.
//-------------------------------------------------------------------------INITTAG
    void init(int lx,int ly,int syscol)
    { 
    //You must start this program before use the namespace.
    //otherwise, the program will output error.
    //write on the screen.
    color = syscol;
    col(syscol);
    cout << ' ';//what the fuck?
    system("cls");
    //Clear the screen.
    initialization = 1;
    //It means the program has started this program.
    // memset things.
    N = lx;
    M = ly;
    
    nx = 0;
    ny = 0;

    repeat(i,1,N,1)
        repeat(j,1,M,1)
        tmpcol[i][j] = optcol[i][j] = color;

    repeat(i,1,N,1)
        repeat(j,1,M,1)
        tmp[i][j] = opt[i][j] = ' ';
    CreateScreenSize(N,M);
    //Create the screen.
    }
    
    //This function is for the string to output.
    void output(string x)
    { 
    if  (!initialization) {
        cerr << "You have not do the init program!"<<endl;
        return;
    }
    int l = x.size();
    repeat(i,0,l-1,1)
    {
        if (x[i] == '\n')
         {
        nx++,ny=0;
        continue;
        }
        //col(color),gotoxy(nx,ny),putchar(x[i]);
        opt[nx][ny]=x[i];
        optcol[nx][ny]=color;
        ny++;
        if (ny >= M)
        ny=0,nx++;
    }
    flashScreen();
    }

    //This function is for the char* to output.
    void output(char x[])
    { 
    string xt = x;
    output(xt);
    }

    //This function is for string to output.
    //It means that:
    //   A-----B
    //   |     |
    //   |     |
    //   |     |
    //   .     .
    //   .     .
    //   .     .
    //A(begx,starty);
    //B(begx,endy).
    void output(string x,int begx,int starty,int endy)
    { 
    if (!initialization) {
        cerr << "You have not do the init program!"<<endl;
        return;
    }
    int l = x.size();
    nx = begx;
    ny = starty;
    repeat(i,0,l-1,1)
    {
        if (x[i] == '\n')
        {
        repeat(i,ny,endy,1)
            opt[nx][i] = ' ',optcol[nx][i] = color;
        nx++,ny=starty;
        continue;
        }
        //col(color),gotoxy(nx,ny),putchar(x[i]);
        opt[nx][ny]=x[i];
        optcol[nx][ny]=color;
        ny++;
        if (ny >= min(endy+1,M))
        ny=starty,nx++;
    }
    repeat(i,ny,endy,1)
       opt[nx][i] = ' ',optcol[nx][i] = color;
    nx++,ny=starty;
    flashScreen();
    }

    
    //This function is for char* to output.
    //It means that:
    //   A-----B
    //   |     |
    //   |     |
    //   |     |
    //   .     .
    //   .     .
    //   .     .
    //A(begx,starty);
    //B(begx,endy).
    void output(char x[],int begx,int starty,int endy)
    {
    string xt = x;
    output(xt,begx,starty,endy);
    }

//------------------------Msg Box------------------------------------------MSGTAG
    class msgbox{
    private:
    int begx,endx;
    int begy,endy;
    string title;
    //Attention! please put the size of title much smaller than the size.
    string note;
//  int color;
    int tp[110][110];
    int tpcol[110][110];
    public:
    void create(int x,int y,int xx,int yy,string title_tmp)
    {
        begx = x;
        begy = y;
        endx = xx;
        endy = yy;
        title = title_tmp;
       int len = title.size();
        
        if (len + 4 >= (endy - begy)) len = (endy - begy - 4);
        //if you don't see the warning....

        repeat(i,1,N,1)
        repeat(j,1,M,1)
            tp[i][j]=tmp[i][j],
            tpcol[i][j]=tmpcol[i][j];

        repeat(i,begy+2,begy+2+len-1,1)
        opt[begx][i] = title[i-begy-2],
        optcol[begx][i] = backcolor;
        opt[begx][begy] = '*';
        optcol[begx][begy] = backcolor;
        opt[begx][begy+1] = '*';
        optcol[begx][begy+1] = backcolor;

        repeat(i,begy+2+len,endy,1)
        opt[begx][i] = '*',
        optcol[begx][i] = backcolor;

        repeat(i,begx+1,endx,1)
        opt[i][endy] = opt[i][begy] = '*',
        optcol[i][endy] = optcol[i][begy] = backcolor;

        repeat(i,begy,endy,1)
        opt[endx][i] = '*',
        optcol[endx][i] = backcolor;
        flashScreen();
    }
    void create(int x,int y,int xx,int yy,char title_tmp[])
    {
        string p=title_tmp;
        create(x,y,xx,yy,p);
    }
    
    template <class T>
    void setnote(T x) 
    {
        repeat(i,begx+1,endx-1,1)
        repeat(j,begy+1,endy-1,1)
            opt[i][j] = ' ';
        repeat(i,begx+1,endx-1,1)
        repeat(j,begy+1,endy-1,1)
            optcol[i][j] = color;
        stringstream ss;
        ss << x;
        output(ss.str(),begx+1,begy+1,endy-1);
        getch();
        repeat(i,1,N,1)
        repeat(j,1,M,1)
            opt[i][j] = tp[i][j], optcol[i][j] = tpcol[i][j];
        flashScreen();
    }
    };/*Class: msgbox*/

//-------------------------Label-------------------------------------------LABELTAG
    class label{
    private:
    int begx,endx;
    int begy,endy;
    string title;
    //Attention! please put the size of title much smaller than the size.
    string note;
//  int color;
    int tp[110][110];
    int tpcol[110][110];
    public:
    void create(int x,int y,int xx,int yy,string title_tmp)
    {
        begx = x;
        begy = y;
        endx = xx;
        endy = yy;
        title = title_tmp;
        
        int len = title.size();
        
        if (len + 4 >= (endy - begy)) len = (endy - begy - 4);
        //if you don't see the warning....

        repeat(i,1,N,1)
        repeat(j,1,M,1)
            tp[i][j]=tmp[i][j],
            tpcol[i][j]=tmpcol[i][j];

        repeat(i,begy+2,begy+2+len-1,1)
        opt[begx][i] = title[i-begy-2],
        optcol[begx][i] = backcolor;
        opt[begx][begy] = '*';
        optcol[begx][begy] = backcolor;
        opt[begx][begy+1] = '*';
        optcol[begx][begy+1] = backcolor;

        repeat(i,begy+2+len,endy,1)
        opt[begx][i] = '*',
        optcol[begx][i] = backcolor;

        repeat(i,begx+1,endx,1)
        opt[i][endy] = opt[i][begy] = '*',
        optcol[i][endy] = optcol[i][begy] = backcolor;

        repeat(i,begy,endy,1)
        opt[endx][i] = '*',
        optcol[endx][i] = backcolor;
        flashScreen();
    }
    void create(int x,int y,int xx,int yy,char title_tmp[])
    {
        string p=title_tmp;
        create(x,y,xx,yy,p);
    }
    template <class T>
    void setnote(T x) 
    {
        stringstream ss;
        ss << x;
        repeat(i,begx+1,endx-1,1)
        repeat(j,begy+1,endy-1,1)
            opt[i][j] = ' ';
        output(ss.str(),begx+1,begy+1,endy-1);
        flashScreen();
    }
    };/*Class: label*/

//---------------------select----------------------------------------------SELTAG
    class selectbox{
    private:
    int tp[110][110];
    int tpcol[110][110];
    string choice[110];
    int begx,endx;
    int begy,endy;
    string title;
    int output_select(string x,int begx,int endx,int starty,int endy)
    {
       if (!initialization) {
        cerr << "You have not do the init program!"<<endl;
        return -1;
       }
        int l = x.size();
        nx = begx;
        ny = starty;
        repeat(i,0,l-1,1)
        {
        if (nx == endx+1)
        {
            flashScreen();
            return 1;
        }
        if (x[i] == '\n')
        {
            nx++,ny=starty;
            continue;
        }
        //col(color),gotoxy(nx,ny),putchar(x[i]);
        opt[nx][ny]=x[i];
        optcol[nx][ny]=color;
        ny++;
        if (ny >= min(endy+1,M))
            ny=starty,nx++;
        }
        flashScreen();
        return 0;
    }
    public:
    void create(int x,int y,int xx,int yy,string title_tmp)
    {
        begx = x;
        begy = y;
        endx = xx;
        endy = yy;
        title = title_tmp;
        
        int len = title.size();
        
        if (len + 4 >= (endy - begy)) len = (endy - begy - 4);
        //if you don't see the warning....

        repeat(i,1,N,1)
        repeat(j,1,M,1)
            tp[i][j]=tmp[i][j],
            tpcol[i][j]=tmpcol[i][j];

        repeat(i,begy+2,begy+2+len-1,1)
        opt[begx][i] = title[i-begy-2],
        optcol[begx][i] = backcolor;
        opt[begx][begy] = '*';
        optcol[begx][begy] = backcolor;
        opt[begx][begy+1] = '*';
        optcol[begx][begy+1] = backcolor;

        repeat(i,begy+2+len,endy,1)
        opt[begx][i] = '*',
        optcol[begx][i] = backcolor;

        repeat(i,begx+1,endx,1)
        opt[i][endy] = opt[i][begy] = '*',
        optcol[i][endy] = optcol[i][begy] = backcolor;

        repeat(i,begy,endy,1)
        opt[endx][i] = '*',
        optcol[endx][i] = backcolor;
        flashScreen();
    }
    void create(int x,int y,int xx,int yy,char title_tmp[])
    {
        string p=title_tmp;
        create(x,y,xx,yy,p);
    }
private:
    int private_output_select(string xt[],int hl,int n)
    {
        int tmpcolor = color;
        nx = begx;
        int flag = -1;
        repeat(i,1,n,1)
        {
        nx++;
        if (i == hl)
        {
            color = 255-color;
        }
        if (i == hl+1)
            flag = 0;
        string x = xt[i];
        int l = x.size();
//      nx = begx+1;
        ny = begy+1;
        repeat(j,0,l-1,1)
        {
            if (nx >= endx)
            {
            color = tmpcolor;
            if (flag == -1)
                return -1;
            else
                goto end;
            }
            if (x[i] == '\n')
            {
            nx++,ny=begy+1;
            continue;
            }
            //col(color),gotoxy(nx,ny),putchar(x[i]);
            opt[nx][ny]=x[j];
            optcol[nx][ny]=color;
            ny++;
            if (ny >= min(endy,M))
            ny=begy+1,nx++;
        }
        if (i == hl)
            color = tmpcolor;
        }
        end:
        color = tmpcolor;
        flashScreen();
        return 0;
    }
    void show(string x[],int hl,int n)
    {
        repeat(beg,1,n,1)
        {
        repeat(i,begx+1,endx-1,1)
            repeat(j,begy+1,endy-1,1)
            opt[i][j] = ' ';
        repeat(i,begx+1,endx-1,1)
            repeat(j,begy+1,endy-1,1)
            optcol[i][j] = color;
        string k[110];
        repeat(i,beg,n,1)
            k[i-beg+1] = x[i];
        if (private_output_select(k,hl-beg+1,n-beg+1)!=-1)
            return;
            
        }
    }
    public:
    //Please start it begin with '1';
    int setnote(string x[],int n)
    {
        repeat(i,begx+1,endx-1,1)
        repeat(j,begy+1,endy-1,1)
            opt[i][j] = ' ';
        char t=0;
        int hl = 1;
        while (t != 13)
        {
        show(x,hl,n);
        t = getch();
        if ((t == 'w' || t == 'W') && hl > 1) hl--;
        if ((t == 's' || t == 'S') && hl < n) hl++;
        }
        repeat(i,1,N,1)
        repeat(j,1,M,1)
            opt[i][j] = tp[i][j], optcol[i][j] = tpcol[i][j];
        flashScreen();
        return hl;
    }
    };
    //------------------------inputbox------------------------------------------INPUTTAG
    class inputbox{
    private:
    int begx,endx;
    int begy,endy;
    string title;
    //Attention! please put the size of title much smaller than the size.
    string note;
//  int color;
    int tp[110][110];
    int tpcol[110][110];
    public:
    void create(int x,int y,int yy,string title_tmp)
    {
        begx = x;
        begy = y;
        endx = x+2;
        endy = yy;
        title = title_tmp;
        int len = title.size();
        
        if (len + 4 >= (endy - begy)) len = (endy - begy - 4);
        //if you don't see the warning....

        repeat(i,1,N,1)
        repeat(j,1,M,1)
            tp[i][j]=tmp[i][j],
            tpcol[i][j]=tmpcol[i][j];

        repeat(i,begy+2,begy+2+len-1,1)
        opt[begx][i] = title[i-begy-2],
        optcol[begx][i] = backcolor;
        opt[begx][begy] = '*';
        optcol[begx][begy] = backcolor;
        opt[begx][begy+1] = '*';
        optcol[begx][begy+1] = backcolor;

        repeat(i,begy+2+len,endy,1)
        opt[begx][i] = '*',
        optcol[begx][i] = backcolor;

        repeat(i,begx+1,endx,1)
        opt[i][endy] = opt[i][begy] = '*',
        optcol[i][endy] = optcol[i][begy] = backcolor;

        repeat(i,begy,endy,1)
        opt[endx][i] = '*',
        optcol[endx][i] = backcolor;
        flashScreen();
    }
    void create(int x,int y,int yy,char title_tmp[])
    {
        string p=title_tmp;
        create(x,y,yy,p);
    }
    template <class T>
    void setnote(string x,T &E) 
    {
        x += '*';
        repeat(i,begx+1,endx-1,1)
        repeat(j,begy+1,endy-1,1)
            opt[i][j] = ' ';
        output(x,begx+1,begy+1,endy-1);
        optcol[begx+1][begy+x.size()] = backcolor;
        flashScreen();
        col(color),cin >> E;
        repeat(i,begy+x.size()+1,M,1)
        tmpcol[begx+1][i] = -1;
        repeat(i,1,N,1)
        repeat(j,1,M,1)
            opt[i][j] = tp[i][j], optcol[i][j] = tpcol[i][j];// tmpcol[i][j]=-1;
    //    CompulsionflashScreen();
        flashScreen();
        
    }
    template <class T>
    void setnote(char x[],T &E)
    {
        string xt = x;
        setnote(xt,E);
    }
    };/*Class: msgbox*/

    //------------------------stream------------------------------------------STREAMTAG
    class streambox{
    private:
    int begx,endx;
    int begy,endy;
    string title;
    int nowx;
    //Attention! please put the size of title much smaller than the size.
    string note;
//  int color;
    int tp[110][110];
    int tpcol[110][110];
    public:
    void create(int x,int y,int xx,int yy,string title_tmp)
    {

        nowx = 0;// To start with 0

        begx = x;
        begy = y;
        endx = xx;
        endy = yy;
        title = title_tmp;
        
        int len = title.size();
        
        if (len + 4 >= (endy - begy)) len = (endy - begy - 4);
        //if you don't see the warning....

        repeat(i,1,N,1)
        repeat(j,1,M,1)
            tp[i][j]=tmp[i][j],
            tpcol[i][j]=tmpcol[i][j];

        repeat(i,begy+2,begy+2+len-1,1)
        opt[begx][i] = title[i-begy-2],
        optcol[begx][i] = backcolor;
        opt[begx][begy] = '*';
        optcol[begx][begy] = backcolor;
        opt[begx][begy+1] = '*';
        optcol[begx][begy+1] = backcolor;

        repeat(i,begy+2+len,endy,1)
        opt[begx][i] = '*',
        optcol[begx][i] = backcolor;

        repeat(i,begx+1,endx,1)
        opt[i][endy] = opt[i][begy] = '*',
        optcol[i][endy] = optcol[i][begy] = backcolor;

        repeat(i,begy,endy,1)
        opt[endx][i] = '*',
        optcol[endx][i] = backcolor;
        flashScreen();
    }
    void create(int x,int y,int xx,int yy,char title_tmp[])
    {
        string p=title_tmp;
        create(x,y,xx,yy,p);
    }
    template <class T>
    void setnote(T x) 
    {
        repeat(i,begx+1,endx-1,1)
        repeat(j,begy+1,endy-1,1)
            opt[i][j]=' ',optcol[i][j] = color;
        stringstream ss;
        ss << x;
        
        note += ss.str();   
        int l = note.size();
        int tpnx = begx+1;
        int tpny = begy+1;
        repeat(i,nowx,l-1,1)
        {
        if (note[i] == '\n')
        {
            tpnx++,tpny=begy+1;
            continue;
        }
        tpny++;
        if (tpny >= min(endy,M-1))
            tpny=begy+1,tpnx++;
        }
        int tadd = tpnx - endx + 2;
        if (tadd <= 0) goto xt;
        tpnx = begx+1;
        tpny = begy+1;
        repeat(i,nowx,l-1,1)
        {
        if (tpnx == tadd+begx)
        {
            nowx = i;
            break;
        }
        if (note[i] == '\n')
        {
            tpnx++,tpny=begy+1;
            continue;
        }
        tpny++;
        if (tpny >= min(endy,M-1))
            tpny=begy+1,tpnx++;
        }
    xt:
        string tmp(note,nowx,note.size());
        output(tmp,begx+1,begy+1,endy-1);
    }
    };/*Class: streambox*/
};

Test Game:


using namespace EasilyPrtSc;


string choice[]={"","1. Buy things.","2. Fight.","3. Sleep (add 50 hp).","4. \?\?\?(a special thing)","5. fight with G(difficult)","exit"};
string shop[]={"","1. sharp knife.(ATK add 15)$ 50","2. king's sword(ATK add 400),$ 1000",
    "3. Valgulious(ATK add 1000,HP add 700) $ 2000, and answer one question",
    "4. Insania(ATK add 2000,HP add 1000) $ 3000, and answer one question",
    "5. Seniorious(ATK add 10000, HP add 2000) $5000, and answer one question"};

    int type;
    int money = 0;
    int life = 100;
    int ATK = 0;
    string name;

    
string p[] = {"","farmer","trader","fighter"};
label tp2;
label tp1;
streambox tp4;
void printtag()
{ 
    stringstream ss;
    ss << "Username: " << name << '\n' << "industry: " << p[type] << '\n'
    << "$ Money: " << money << '\n' << "HP: " << life << endl
    << "ATK: " << ATK << endl;
    tp2.setnote(ss.str());
}

int main()
{
    srand(time(NULL));
    //It is a test game.
    {
    stringstream ss;
    init(30,50,3);
    //Create Screen
    tp2.create(1,1,15,30,"Your profiles:");
    tp1.create(16,1,30,30,"Task&Tips");
    
    
    tp4.create(1,31,30,50,"stream");
    tp4.setnote("Open the game\n");
    inputbox a;
    a.create(10,3,27,"Hello!");

    a.setnote("what\'s your name?",name);

    string tt = "Username: ";
    tp2.setnote(tt+name);

    tp4.setnote("registered\nUsername: ");
    tp4.setnote(name);
    tp4.setnote('\n');
    //label tp3;
    pause;

    selectbox tp3;
    tp3.create(3,3,27,27,"Choice your industry");
    type = tp3.setnote(p,3);
    if (type == 1)
    ATK = 100,
    money = 100;
    else if (type == 2)
    ATK = 50,
    money = 200;
    else ATK = 300;
    ss << "Username: " << name << '\n' << "industry: " << p[type] << '\n'
    << "$ Money: " << money << '\n' << "HP: " << life << endl
    << "ATK: " << ATK << endl;
    tp2.setnote(ss.str());
    
    tp4.setnote("industry: ");
    tp4.setnote(p[type]);
    tp4.setnote('\n');
    ss.str("");

    ss << "Please read this tag as slow as you can.\n";
    tp1.setnote(ss.str());
    pause;
    
    ss << "Your target is to kill Gravity." << endl;
    tp1.setnote(ss.str());
    pause;

    ss << "Gravity is the biggest boss, but it recently killed by class 9 people." << endl;
    tp1.setnote(ss.str());
    pause;
    
    ss << "Before to deal with Gravity, you should add your ATK and HP." << endl;
    tp1.setnote(ss.str());
    pause;

    ss << "Good Luck!\n" ;
    tp1.setnote(ss.str());
    pause;

    tp1.setnote("");
    pause;
    }
    
    //tp2|tp4
    //---|
    //tp1|
    
    //switch box tp3;
    while (life > 0){
    selectbox tt;
    tt.create(10,5,25,35,"Choices");
    int tp = tt.setnote(choice,5);
    tp4.setnote("Choice: ");
    tp4.setnote(choice[tp]);
    tp4.setnote("\n");
    if (tp == 3)
    {
        tp4.setnote("HP += 50\n");
        printtag();
        life += 50;
        Sleep(5000);
    }
    if (tp == 1)
    {
        tt.create(10,5,25,35,"Shop");
        int o = tt.setnote(shop,5);
        tp4.setnote("Try to buy ");
        tp4.setnote(shop[o]);
        tp4.setnote("...");
        if (o == 1)
        {
        if (money < 50)
            tp4.setnote("Failed. No money left.\n");
        else
            tp4.setnote("Successful. ATK add 15.\n"),ATK+=15,money-=50;
        }
        if (o == 2)
        {
        if (money < 1000)
            tp4.setnote("Failed. No money left.\n");
        else
            tp4.setnote("Successful. ATK add 400.\n"),ATK+=400,money-=1000;
        }
        if (o == 3)
        { 
        if (money < 2000)
            tp4.setnote("Failed. No money left.\n");
        else
        {
            inputbox a;
            a.create(15,3,47,"Question");
            string k;
            a.setnote("Who use this sword?(First name)",k);
            if (k == "Ithea")
            tp4.setnote("Successful. ATK add 1000,HP add 700.\n"),ATK+=1000,life+=700,money-=2000;
            else
            { 
            tp4.setnote("Failed. Wrong answer.\n");
            msgbox tty;
            tty.create(10,10,20,20,"Sorry");
            tty.setnote("Sorry! Wrong Answer.");
            }
        }
        }
        if (o == 4)
        {
        if (money < 3000)
            tp4.setnote("Failed. No money left.\n");
        else
        {
            inputbox a;
            a.create(15,3,47,"Question");
            string k;
            a.setnote("Who use this sword?(First name)",k);
            if (k == "Nephren")
            tp4.setnote("Successful.ATK add 2000,HP add 1000.\n"),ATK+=2000,life+=1000,money-=1000;
            else
            {
            tp4.setnote("Failed. Wrong answer.\n");
            msgbox tty;
            tty.create(10,10,20,20,"Sorry");
            tty.setnote("Sorry! Wrong Answer.");
            }
        }
        }
        if (o == 5)
        {
        if (money < 5000)
            tp4.setnote("Failed. No money left.\n");
        else
        {
            inputbox a;
            a.create(15,3,47,"Question");
            string k;
            a.setnote("Who use this sword?(First name)",k);
            if (k == "Chtholly")
            tp4.setnote("Successful.ATK add 10000, HP add 2000.\n"),ATK+=10000,life+=2000,money-=5000;
            else
            {
            tp4.setnote("Failed. Wrong answer.\n");
            msgbox tty;
            tty.create(10,10,20,20,"Sorry");
            tty.setnote("Sorry! Wrong Answer.");
            }
        }
        }
    }
    if (tp == 2)
    {
        int ATKp = rand()%20 - 10 + min((int)(ATK*0.7),200);
        int HPp = rand()%20 - 10 + min((int)(life*0.5),400);
        int MON = (ATKp + HPp) / 5;
        stringstream ss;
        while (1){
        printtag();
        ss.str("");
        ss << "The enemy's Profile:\nATK: "<<ATKp <<endl<< "HP: "<<HPp
            << endl << "Money: " << MON << endl;
        tp1.setnote(ss.str());
        tt.create(3,3,15,35,"Choice");
        string tp_2[] = {"","Fight","Run away"};
        int res = tt.setnote(tp_2,2);
        tp4.setnote(tp_2[res]);
        tp4.setnote("\n");
        if (res == 2)
        {
            break;
        }
        if (res == 1)
        {
            life -= max(0,ATKp - ATK/5);
            HPp -= max(0,ATK - ATKp/5);
        }
        if (life <= 0)
        {
            msgbox tpp;
            stringstream sss;
            sss << "Game over.\nFinal ATK: " << ATK << endl
            << "Final Money: " << money << endl
            << "Level:" << ATK/100 + money/50;
            tp4.setnote(sss.str());
            tpp.create(10,10,35,25,"Sorry");
            tpp.setnote(sss.str());
            return 0;
        }
        if (HPp <= 0)
        {
            msgbox tpp;
            tp4.setnote("Killed.\n");
            tp4.setnote("money add ");
            tp4.setnote(MON);
            tp4.setnote("\n");
            money += MON;
            tpp.create(10,10,25,35,"Success");
            tpp.setnote("You successfully Killed the enemy.");
            break;
        }
        }

    }
    if (tp == 4)
    {
        int tag = rand()%100;
        if (tag < 30) life += 100;
        else if (tag < 50) ATK += 10;
        else life -= 100;
        printtag();
    }
    if (tp == 5)
    {
        int ATKp = 40000;
        int HPp = 70000;
        stringstream ss;
        while (1){
        printtag();
        ss.str("");
        ss << "The enemy's Profile:\nATK: "<<ATKp <<endl<< "HP: "<<HPp
            << endl;
        tp1.setnote(ss.str());
        tt.create(3,3,15,35,"Choice");
        string tp_2[] = {"","Fight","Run away"};
        int res = tt.setnote(tp_2,2);
        tp4.setnote(tp_2[res]);
        tp4.setnote("\n");
        if (res == 2)
        {
            break;
        }
        if (res == 1)
        {
            life -= max(0,ATKp - ATK/5);
            HPp -= max(0,ATK - ATKp/5);
        }
        if (life <= 0)
        {
            msgbox tpp;
            stringstream sss;
            sss << "Game over.\nFinal ATK: " << ATK << endl
            << "Final Money: " << money << endl
            << "Level:" << ATK/100 + money/50;
            tp4.setnote(sss.str());
            tpp.create(10,10,25,35,"Sorry");
            tpp.setnote(sss.str());
            return 0;
        }
        if (HPp <= 0)
        {
            msgbox tpp;
            tpp.create(10,10,25,35,"Success");
            tpp.setnote("You Win.");
            return 0;
        }
        }

    }
    printtag();
    }

}

标签:opt,repeat,1.2,EasyPrtSc,int,endy,sec,begx,begy
来源: https://www.cnblogs.com/dgklr/p/12074390.html