137 lines
8.3 KiB
C++
137 lines
8.3 KiB
C++
#include "result.h"
|
|
|
|
#include "constants.h"
|
|
|
|
const char *WIN_SCREEN =
|
|
"+-----------------------------------------------------------------------------+\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| ___________ |\
|
|
| '._==_==_=_.' |\
|
|
| .-\\: /-. |\
|
|
| | (|:. |) | |\
|
|
| '-|:. |-' |\
|
|
| \\::. / |\
|
|
| '::. .' |\
|
|
| ) ( |\
|
|
| _.' '._ |\
|
|
| `.......` |\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| Winner! |\
|
|
| |\
|
|
| |\
|
|
| > |\
|
|
| |\
|
|
| |\
|
|
| Press 'r' to restart and any other key to quit. |\
|
|
| |\
|
|
+-----------------------------------------------------------------------------+";
|
|
|
|
const char *ESC_SCREEN =
|
|
"+-----------------------------------------------------------------------------+\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| __ |\
|
|
| _/o \\ |\
|
|
| /_ | | / |\
|
|
| W\\ / |//// |\
|
|
| \\ \\ __________||//|/ |\
|
|
| \\ \\/ /|/-//- |\
|
|
| | ----- // -- |\
|
|
| | ----- /- |\
|
|
| | ----- / |\
|
|
| \\ / |\
|
|
| \\_/ \\___/ |\
|
|
| \\ // |\
|
|
| ||| |\
|
|
| ||| |\
|
|
| Z_>> |\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
| Chicken! |\
|
|
| |\
|
|
| > |\
|
|
| |\
|
|
| |\
|
|
| Press 'r' to restart and any other key to quit. |\
|
|
| |\
|
|
+-----------------------------------------------------------------------------+";
|
|
|
|
|
|
const char *LOSE_SCREEN =
|
|
"+-----------------------------------------------------------------------------+\
|
|
| |\
|
|
| _ /) |\
|
|
| / )/ ) |\
|
|
| |/)\\) |\
|
|
| /\\_ |\
|
|
| \\__|= |\
|
|
| ( ) |\
|
|
| __)(__ |\
|
|
| _____/ \\\\_____ |\
|
|
| | || |\
|
|
| | _ ___ _ || |\
|
|
| | | \\ | | \\ || |\
|
|
| | | | | | | || |\
|
|
| | |_/ | |_/ || |\
|
|
| | | \\ | | || |\
|
|
| | | \\ | | || |\
|
|
| | | \\. _|_. | . || |\
|
|
| | || |\
|
|
| * | * ** * ** |** ** |\
|
|
| \\))...../.,(//,,..,,\\||(,,.,\\\\,.((// |\
|
|
| |\
|
|
| Loser! |\
|
|
| |\
|
|
| > |\
|
|
| |\
|
|
| |\
|
|
| Press 'r' to restart and any other key to quit. |\
|
|
| |\
|
|
+-----------------------------------------------------------------------------+";
|
|
|
|
const position &MSG_START = {4, 24};
|
|
const int MAX_MSG_LEN = 71;
|
|
const std::string DOTS = "...";
|
|
|
|
void game_result::run(input *in) {
|
|
if (in->get_command() == GAME_RESTART)
|
|
status = RESTART;
|
|
}
|
|
|
|
void game_result::print(output *out) {
|
|
if (msg.length() > MAX_MSG_LEN) {
|
|
msg.resize(MAX_MSG_LEN - DOTS.length());
|
|
msg += DOTS;
|
|
}
|
|
|
|
switch (status) {
|
|
case WON:
|
|
out->print_str({0, 0}, WIN_SCREEN);
|
|
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_YELLOW));
|
|
break;
|
|
|
|
case ESCAPED:
|
|
out->print_str({0, 0}, ESC_SCREEN);
|
|
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_GREEN));
|
|
break;
|
|
|
|
case DEAD:
|
|
out->print_str({0, 0}, LOSE_SCREEN);
|
|
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_RED));
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|