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:[email protected]
    #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();
    }

}

原文地址:https://www.cnblogs.com/dgklr/p/12074390.html

时间: 2024-11-03 22:53:20

EasyPrtSc sec[1.2] 发布!的相关文章

安装PHP以及搭建博客(二)

安装wordpress 首先现在mysql上创建库 create database wordpress; 创建用户 grant all on wordpress.* to [email protected]'localhost' identified by '123456'; flush privileges; 调整nginx vim /application/nginx/conf/extra/blog.conf 在localtion下面添加 index index.php index.html

Maven发布web项目到tomcat

在java开发中经常要引入很多第三方jar包:然而无论是java web开发还是其他java项目的开发经常会由于缺少依赖包引来一些不必要的异常.常常也是因为这样的原因导致许多简单的缺包和版本问题耗费大量的精力.然而,开源世界并没有让java开发人员在这方面耗费过多的精力. Apache提供了Maven工具,对项目进行自动化的构建和发布.只需要在Maven的pom.xml文件中加入相应的配置项,剩余的工作交给maven就可以了.然而去喝杯茶做个安安静静的美男子.然而除了Maven外还有Gradle

Linux下电骡aMule Kademlia网络构建分析5 —— 资源的发布

资源发布请求消息的发送 在aMule中,主要用CSharedFileList class来管理共享给其它节点的文件.如我们前面在 Linux下电骡aMule Kademlia网络构建分析3 一文中分析的那样,aMule在启动的时候,会起一些定时器,以便于定期的执行一些任务.CamuleApp::OnCoreTimer()是其中之一,在这个函数中,我们可以看到这样的几行: // Publish files to server if needed. sharedfiles->Process(); 由

使用pm2以cluster mode 发布应用的方法

pm2以cluster集群方式发布app,可以高效地利用多核cpu,有效提升吞吐量.在上周对公司的redmine服务器进行性能调优后,深感ruby on rails的性能低下,这次测试nodejs的sails框架,被其性能深深折服. 以下是使用pm2发布nodejs 应用的经历: 一:记录出现的问题记录. 1. pm2 start app.js -i 0 当使用以上指令时,出现提示说pm2 的cluster模式非常不稳定,建议不使用.但是官网上面却是推荐使用,为什么呢? 原来我的node版本过低

最简单的基于librtmp的示例:发布(FLV通过RTMP发布)

本文记录一个基于libRTMP的发布流媒体的程序:Simplest libRTMP Send FLV.该程序可以将本地FLV文件发布到RTMP流媒体服务器.是最简单的基于libRTMP的流媒体发布示例. 流程图 使用librtmp发布RTMP流的可以使用两种API:RTMP_SendPacket()和RTMP_Write().使用RTMP_SendPacket()发布流的时候的函数执行流程图如下图所示.使用RTMP_Write()发布流的时候的函数执行流程图相差不大. 流程图中关键函数的作用如下

发布jar包至maven本地库及私服

pom文件见附件,如不打至私服,不需要 <distributionManagement> 标签 中的内容 C:\Users\chao.gao>E: E:\>cd E:\old_passform\jfinal_demo_for_jsp\WebRoot\WEB-INF\lib E:\old_passform\jfinal_demo_for_jsp\WebRoot\WEB-INF\lib>mvn install:install-file  -DgroupId=com.cloopen

RHCE之HTTPD+FTP+KickStart发布镜像,用于KVM的VM自动安装过程

最近在学习RHCE课程,上一篇简单的讲一下如何用HTTP来作为KVM的VM网络安装过程,请阅读:http://gshao.blog.51cto.com/3512873/1882093 今天讲到FTP+HTTP+KickStart发布,当然还有PXE安装RHEL(后续讲). 环境: 虚拟宿主机:RHEL 7.0 硬件:4vCPU+8G+40Gdisk IP地址:172.16.38.10 vnet ip地址:192.168.100.1 先截图上一篇装完rhel系统的样子: 回归到正文,今天讲HTTP

发布一个python服务框架iserver(带压力测试数据)

Iserver简介 Iserver是一个用python编写的网络服务框架(编译版本3.4.1),使用的是epool网络模型 测试机配置 处理器 2x Genuine Intel(R) CPU T2050 @ 1.60GHz 内存 2060MB (673MB used) nginx开启进程数 root 2413 2409 0 09:17 pts/0 00:00:00 grep -i nginx www 2414 2411 2 09:17 ? 00:00:00 nginx: worker proce

Redis 学习之持久化机制、发布订阅、虚拟内存

该问使用centos6.5 64位  redis3.2.8 一.持久化机制 Redis是一个支持持久化的内存数据库,redis会经常将内存中的数据同步到硬盘上来保证数据持久化,从而避免服务器宕机数据丢失问题,或者减少服务器内存消耗提高性能. 持久化方式: 1.Snapshotting:快照,redis默认持久化方式,这种方式是将内存中的数据以快照的方式写入到二进制文件中,默认的文件名为dump.rdb.可以通过配置设置自动做快照持久化的方式.我们可以配置redis在n秒内如果超过m个key被修改