added result screens
fixed bug about picking up two boosts crashing the game
This commit is contained in:
15
src/cc3k.cc
15
src/cc3k.cc
@ -24,7 +24,7 @@ game_status CC3K::run() {
|
||||
}
|
||||
|
||||
if (tmp != -1) {
|
||||
curr_menu = nullptr;
|
||||
curr_menu.reset();
|
||||
curr_game = std::make_unique<game>((race)tmp,
|
||||
enabled_features,
|
||||
in, out, rng);
|
||||
@ -45,7 +45,7 @@ game_status CC3K::run() {
|
||||
gresult = curr_game->run();
|
||||
|
||||
if (gresult.status == restart) {
|
||||
curr_game = nullptr;
|
||||
curr_game.reset();
|
||||
curr_menu = std::make_unique<menu>(enabled_features);
|
||||
out->clear();
|
||||
curr_menu->print(out, rng->get_init_seed());
|
||||
@ -70,7 +70,18 @@ game_status CC3K::run() {
|
||||
case dead:
|
||||
case won:
|
||||
case escaped:
|
||||
curr_game.reset();
|
||||
gresult.run(in);
|
||||
|
||||
if (gresult.status == restart) {
|
||||
curr_menu = std::make_unique<menu>(enabled_features);
|
||||
out->clear();
|
||||
curr_menu->print(out, rng->get_init_seed());
|
||||
out->render();
|
||||
gresult.status = main_menu;
|
||||
return main_menu;
|
||||
}
|
||||
|
||||
return terminated;
|
||||
|
||||
default:
|
||||
|
@ -37,7 +37,7 @@ void character::insert_effect(std::unique_ptr<potion> effect) {
|
||||
effects.push_back(std::move(effect));
|
||||
|
||||
for (int i = effects.size() - 1; i > 0 &&
|
||||
effect->get_priority() < effects[i - 1]->get_priority(); --i)
|
||||
effects[i]->get_priority() < effects[i - 1]->get_priority(); --i)
|
||||
std::swap(effects[i], effects[i - 1]);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ void cursor::show() const {
|
||||
}
|
||||
|
||||
void cursor::clear() const {
|
||||
// ::clear();
|
||||
}
|
||||
|
||||
void cursor::print_char(const position &pos, const char ch,
|
||||
|
@ -9,8 +9,10 @@ void curses_output::render() {
|
||||
curse->show();
|
||||
}
|
||||
|
||||
std::string BLANK(DISPLAY_BUFFER_SIZE, ' ');
|
||||
|
||||
void curses_output::clear() {
|
||||
curse->clear();
|
||||
print_str({0, 0}, BLANK, A_NORMAL);
|
||||
}
|
||||
|
||||
void curses_output::print_char(const position &pos, const char ch,
|
||||
|
105
src/result.cc
105
src/result.cc
@ -1,5 +1,6 @@
|
||||
#include "result.h"
|
||||
|
||||
#include "constants.h"
|
||||
|
||||
const char *WIN_SCREEN =
|
||||
"+-----------------------------------------------------------------------------+\
|
||||
@ -23,23 +24,113 @@ const char *WIN_SCREEN =
|
||||
| |\
|
||||
| |\
|
||||
| |\
|
||||
| Winner! |\
|
||||
| |\
|
||||
| |\
|
||||
| |\
|
||||
| > |\
|
||||
| |\
|
||||
| > |\
|
||||
| |\
|
||||
| |\
|
||||
| Press 'r' to restart and any other key to quit. |\
|
||||
| |\
|
||||
+-----------------------------------------------------------------------------+";
|
||||
|
||||
const position &MSG_START = {11, 24};
|
||||
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) {
|
||||
in->get_command();
|
||||
if (in->get_command() == game_restart)
|
||||
status = restart;
|
||||
}
|
||||
|
||||
void game_result::print(output *out) {
|
||||
out->print_str({0, 0}, WIN_SCREEN);
|
||||
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_YELLOW));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user