C++

Terminal

/* Need comments? Fuck you! >:D *
 * Chrysalis is the best queen! *
 * CODING BAD!                  */
#include <iostream>
#include <iomanip>
#include <time.h>
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
#include <cstring>
#include <process.h>
using namespace std;
HANDLE hConsole;


enum color {
   cBLACK=0,     cDARK_BLUE=1,    cDARK_GREEN=2, cDARK_CYAN=3,
   cDARK_RED=4,  cDARK_MAGENTA=5, cBROWN=6,      cLIGHT_GRAY=7,
   cDARK_GRAY=8, cBLUE=9,         cGREEN=10,     cCYAN=11,
   cRED=12,      cMAGENTA=13,     cYELLOW=14,    cWHITE=15 };


class Screen
{
    public:
        void cl()
        {
            system("cls");
        }
        void init_graph()
        {
            COORD console_size = {80, 25};
            hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
                    FILE_SHARE_READ | FILE_SHARE_WRITE,
                    0L, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0L);
            SetConsoleScreenBufferSize(hConsole, console_size);
        }
        void set_clr(color background, color foreground)
        {
            SetConsoleTextAttribute( hConsole, (WORD)((background << 4) | foreground) );
        }
        void cur_pos(int x, int y)
        {
            COORD cursor_pos;
            cursor_pos.X = x - 1;
            cursor_pos.Y = y - 1;
            SetConsoleCursorPosition(hConsole, cursor_pos);
        }
        void line(char ch,int weight,int pause)
        {
            for (int q = 0; q<weight;q++)
            {
                cout << ch;
                Sleep(pause);
            }
            cout << '\n';
        }
        void pause(int ms)
        {
            Sleep(ms);
        }
        void beep(int height,int hz)
        {
            Beep(height,hz);
        }
};

class Levels:public Screen
{
    public:
        bool ChangelinesServer(bool snd, bool login, string inp, string Changelines_Server_position)
        {
            /*cl();
            pause(2000);
            cout << "Connecting";
            line('.',5,750);
            cout << '\n';
            pause(2000);
            if (snd == true)
            {
                beep(450,50);
                beep(650,50);
                beep(850,50);
            }
            cout << "Done!\nConnected to \'Changelines Co. Server\'\n";
            pause(3000);*/
            if (login == false)
            {
                set_clr(cBLACK,cRED);
                cout << "Bad login and/or password\n";
                set_clr(cBLACK,cWHITE);
                cout << "Press any key to end session...";
                _getch();
                goto CLOSE_ChangelinesServer_notWork;       /* "GOTO"! FUCK YEAH!!*/
            }
            else
            {
                /*cout << "Press any key to continue...";
                _getch();
                system("cls");*/

                cout << "Changelines Co. Server\nHLC Terminal(R) v10.0x.xx\n";
                line('#',45,0);
                do
                {
                    cout << '>';
                    cin >> inp;

                    /*++++++++++++++++++++++*/
                    if (inp == "dir" && Changelines_Server_position == "/")
                    {
                        cout << "DIR of " << Changelines_Server_position <<'\n'
                            << setw(5) << "<DIR>" << setw(10) << "hwd1/\n"
                            << setw(5) << "<DIR>" << setw(10) << "hwd2/\n"
                            << setw(5) << "<DIR>" << setw(10) << "hwd3/\n"
                            << setw(5) << "<DIR>" << setw(10) << "hwd4/\n";
                    }
                    /*++++++++++++++++++++++*/
                    if (inp == "help")
                    {
                        cout << "**HELP LIST** (Changelines Co. Server)\n"
                            << "help         - show a list of available commands\n"
                            << "cls          - clear screen\n"
                            << "dir          - to view directory\n"
                            << "sound        - enable/disable beep. Now = " << snd <<'\n'
                            << "disconnect   - to disconnect from this server\n"
                            << "about        - get information about this server\n"
                            << "read_file    - open (read) file\n"
                            << "   [file_name]\n"
                            << "download     - download file on the server\n"
                            << "   [file_name]\n"
                            << "exit\n";
                    }
                    if (inp == "cls")
                    {
                        cl();
                    }
                    if (inp == "sound")
                    {
                        if (snd == false)
                        {
                            snd = true;
                            cout << "sound = " << snd << '\n';
                        }
                        else
                        {
                            snd = false;
                            cout << "sound = " << snd << '\n';
                        }
                    }
                    if (inp == "about")
                    {
                        set_clr(cBLACK, cBLUE);
                        cout <<
"\n\n"
"                                  ^^\n"
"                                  **\n"
"                                <****>\n"
"                                <****>\n"
"                              <***/\\***>\n"
"                              <***/\\***>\n"
"                            <***\\ /\\ /***>\n"
"                            <*** \\/\\/ ***>\n"
"                           <*** \\ /\\ / ***>\n"
"                          <*** \\ \\/\\/ / ***>\n"
"                         <*** \\ \\ /\\ / / ***>\n"
"                        <*** \\ \\ \\/\\/ / / ***>\n"
"                        <***\\ \\ \\ /\\ / / /***>\n"
"                        <*** \\ \\ \\/\\/ / / ***>\n"
"                        <***  \\ \\ /\\ / /  ***>\n"
"                          <*** \\ \\/\\/ / ***>\n"
"                            <***\\ /\\ /***>\n"
"                               <*\\/\\/*>\n"
"                                 </\\>\n"
"                                  !!\n"
"                                  !!\n"
"                                  ::\n";
                        set_clr(cBLACK,cWHITE);
                        cout <<
"    Changelines Co.";
                        set_clr(cBLACK,cBLUE);
                        cout <<
"               ..";
                        set_clr(cBLACK, cWHITE);
                        cout <<
"         Corporation(R) 1997-2016\n\n";
                    }
                    if (inp == "disconnect")
                    {
                        cout << "Are you sure? (1/0): ";
                        char ch;
                        ch = _getche();
                        if (ch == '1')
                        {
                            /*goto MAIN_TERMINAL;*/
                        }
                    }
                    /*&&&&&&&&&&&&*/
                    if (
                        inp != "help" &&
                        inp != "cls" &&
                        inp != "dir" &&
                        inp != "sound" &&
                        inp != "disconnect" &&
                        inp != "about" &&
                        inp != "read_file" &&
                        inp != "download" &&
                        inp != "exit"
                       )
                    {
                        cout << "The \'" << inp << "\' is not available or is not used in this system\n";
                    }
                }
                while (inp != "exit");
            }
            CLOSE_ChangelinesServer_notWork:
            return snd;
        }
/*&&&&&&&&&&&&&&&&&&&&&&&&&*/
/*void GlitchServerInformation()
{
        cl();
        pause(2000);
        cout << "Connecting";
        line('.',5,750);
        cout << "53r\\/3r d035 n07 3xi57\n";
}*/
/*&&&&&&&&&&&&&&&&&&&&&&&&&*/
/*void TutorialServer()
{
        cl();
        pause(2000);
        cout << "Connecting";
        s.line('.',5,750);
        cout << "Server is not available now\n";
}*/
/*&&&&&&&&&&&&&&&&&&&&&&&&&*/
/*void DevNullPlayer()
{
        cl();
        pause(2000);
        cout << "Connecting";
        line('.',10,1000);
        set_clr(cBLACK,cRED);
        cout << "FATAL ERROR!\nSYSTEM CRASHED";
        _getch();
        set_clr(cBLACK,cWHITE);
}*/
};

int main()
{
    bool    /*servReq = false,*/    sound = true, haveLogin = true;             /*sound = false*/
    string inp, msn, srvn, Changelines_Server_position = "/";
    Screen s;
    Levels lev;
    s.init_graph();
    s.set_clr(cBLACK,cWHITE);
    /*&&&&&&&&&&&&&&&&&&&&&&&&&*/
    /*
    MAIN_TERMINAL:
    cout << "HLC Terminal(R) v10.05.14\nAll rights reserved\nObserve the case of letters\n";
    s.line('#',45,0);
    do
    {
        cout << '>';
        cin >> inp;
        if (inp == "help")
        {
            cout << "*HELP LIST*\n"
                 << "help         - show a list of available commands\n"
                 << "cls          - clear screen\n"
                 << "sound        - enable/disable beep. Now = " << sound <<'\n'
                 << "servers_list - to view a list of servers\n"
                 << "connect      - to connect to the server\n"
                 << "   [server_number]\n"
                 << "mailbox      - to view the messages list\n"
                 << "mailread     - for message reading\n"
                 << "   [message_number]\n"
                 << "exit\n";
        }
        if (inp == "mailbox" && servReq == false)
        {
            cout << "1 message(-s)\n";
            s.line('*',10,0);
            cout << "\n1) From: noName | Re: Don\'t forget\n\nUse \'mailread\' and then \'[message_number]\' for message reading\n";
        }
        if (inp == "mailread")
        {
            cout << "Message number: ";
            cin >> msn;
            if (inp == "mailread" && msn == "1")
            {
                s.cl();
                cout << "From: noName | Re: Don\'t forget\n";
                s.line('#',50,0);
                cout << "\nHello, my dear friend.\n"
                    << "I hope you have not forgotten about our agreement? Of course you forgot. Well,\n"
                    << "you still have a few hours before deadline. Let me remind you what files are\nneeded:\n"
                    << "\n\n\n"
                    << "P.S. List of servers will be added automatically.If you want,you can be trained.\n"
                    << "Simply connect to the server, and carefully read the instructions.\n"
                    << "File downloaded to the server with glitches\n"
                    << "\n                                     With love, your ";
                s.set_clr(cBLACK,cRED);
                cout << "Nightmare\n";
                s.set_clr(cBLACK,cWHITE);
                servReq = true;
                _getch();
                if (sound == true)
                {
                    s.beep(10,5000);
                }
                cout << "Servers list be updated\n";
            }
            else
            {
                if (inp == "mailread" && msn != "1")
                {
                    cout << "Message is not available or does not exist\n";
                }
            }
        }
        if (inp == "cls")
        {
            s.cl();
        }
        if (inp == "servers_list")
        {
            if (servReq == false)
            {
                cout << "No servers available\n";
            }
            else
            {
                s.line('#',20,50);
                cout << "1) Changelines Co. Server       || Your goal here\n"
                    << "2) Glitch Server                || Our world\n"
                    << "3) Fake Server #16              || Tutorial\n"
                    << "4) Fake Server #511             || \"dev/null\"\n\n"
                    << "To connect to the server using \'connect\' and then \'server_number\'\n";
            }
        }
        if (inp == "connect" && servReq == false)
        {
            cout << "Server number: ";
            cin >> srvn;
        }
        if (inp == "connect" && servReq == true)
        {
            cout << "Server number: ";
            cin >> srvn;
            if (srvn == "1")
            {
                ChangelinesServer_notWork(sound);
            }
            if (srvn == "2")
            {
                GlitchServerInformation();
            }
            if (srvn == "3")
            {
                TutorialServer();
            }
            if (srvn == "4")
            {
                DevNullPlayer();
            }
            if (srvn != "1" && srvn != "2" && srvn != "3" && srvn != "4")
            {
                cout << "Server with this number does not exist or is not available at the moment\n";
            }
        }
        if (inp == "sound")
        {
            if (sound == false)
            {
                sound = true;
                cout << "Sound = " << sound << '\n';
            }
            else
            {
                sound = true;
                cout << "Sound = " << sound << '\n';
            }
        }*/
        /*----------------*/
        /*if (inp != "help" &&
            inp != "cls" &&
            inp != "sound" &&
            inp != "servers_list" &&
            inp != "connect" &&
            inp != "mailbox" &&
            inp != "mailread" &&
            inp != "exit"
           )
        {
            cout << "The \'" << inp << "\' is not available or is not used in this system\n";
        }
    }
    while(inp != "exit");*/
    /*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
    lev.ChangelinesServer(sound, haveLogin, inp, Changelines_Server_position);
    /*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
    /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
    return 0;
}
Добавлено: 05 Сентября 2014 02:18:56 Добавил: Андрей Ковальчук Нравится 0
Добавить
Комментарии:
Нету комментариев для вывода...