changed unique_ptr access to using raw pointers to denote non-ownership

added new flag -e for extra stuff (potions/races)
IMPORTANT: main.cc is undergoing rework
This commit is contained in:
2024-07-12 09:58:30 -04:00
parent b3300b8e7c
commit c9e96b5e6e
8 changed files with 26 additions and 22 deletions

View File

@ -47,6 +47,8 @@ feature proc_args(int argc, char **argv,
result |= FEATURE_THROW; result |= FEATURE_THROW;
} else if (str == "-R") { } else if (str == "-R") {
result |= FEATURE_REVISIT; result |= FEATURE_REVISIT;
} else if (str == "-e") {
result |= FEATURE_EXTRA_STUFF;
} else if (str == "-s") { } else if (str == "-s") {
++i; ++i;
str = argv[i]; str = argv[i];
@ -121,8 +123,8 @@ feature proc_args(int argc, char **argv,
if (result & FEATURE_NCURSES) { if (result & FEATURE_NCURSES) {
curse = std::make_unique<cursor>(); curse = std::make_unique<cursor>();
in = std::make_unique<curses_input>(*curse); in = std::make_unique<curses_input>(curse.get());
out = std::make_unique<curses_output>(*curse); out = std::make_unique<curses_output>(curse.get());
} }
if (result & FEATURE_SEED) { if (result & FEATURE_SEED) {

View File

@ -18,6 +18,7 @@
-i : Enable inventory -i : Enable inventory
-t : Enable throw -t : Enable throw
-R : Enable revisiting levels -R : Enable revisiting levels
-e : Enable extra potions and races
-s [seed] : Sets initial seed to seed -s [seed] : Sets initial seed to seed
-L [file] : Enable logging to file -L [file] : Enable logging to file
-I [file] : Reads commands from file. CANNOT BE USED WITH -n. -I [file] : Reads commands from file. CANNOT BE USED WITH -n.

View File

@ -92,6 +92,7 @@ const feature FEATURE_SEED = 1 << 7;
const feature FEATURE_MENU = 1 << 8; const feature FEATURE_MENU = 1 << 8;
const feature FEATURE_IN_FILE = 1 << 9; const feature FEATURE_IN_FILE = 1 << 9;
const feature FEATURE_OUT_FILE = 1 << 10; const feature FEATURE_OUT_FILE = 1 << 10;
const feature FEATURE_EXTRA_STUFF = 1 << 11;
const feature FEATURE_PANIC_SEED = 1 << 27; const feature FEATURE_PANIC_SEED = 1 << 27;
const feature FEATURE_PANIC_FILE = 1 << 28; const feature FEATURE_PANIC_FILE = 1 << 28;

View File

@ -1,10 +1,10 @@
#include "curses_input.h" #include "curses_input.h"
curses_input::curses_input(cursor &new_curse): curses_input::curses_input(cursor *new_curse):
curse{new_curse} {} curse{new_curse} {}
game_command curses_input::get_command() { game_command curses_input::get_command() {
switch (curse.getcmd()) { switch (curse->getcmd()) {
case 'h': case 'h':
return game_command::move_west; return game_command::move_west;
@ -51,7 +51,7 @@ game_command curses_input::get_command() {
return game_command_pass; return game_command_pass;
} }
switch (curse.getcmd()) { switch (curse->getcmd()) {
case 'h': case 'h':
return game_command::apply_west; return game_command::apply_west;

View File

@ -8,9 +8,9 @@
class curses_input final: public input { class curses_input final: public input {
private: private:
cursor &curse; cursor *curse;
public: public:
curses_input(cursor &new_curse); curses_input(cursor *new_curse);
game_command get_command() override; game_command get_command() override;
}; };

View File

@ -1,14 +1,14 @@
#include "curses_output.h" #include "curses_output.h"
curses_output::curses_output(cursor &new_curse): curses_output::curses_output(cursor *new_curse):
curse{new_curse} {} curse{new_curse} {}
void curses_output::render() { void curses_output::render() {
curse.show(); curse->show();
} }
void curses_output::clear() { void curses_output::clear() {
curse.clear(); curse->clear();
} }
void curses_output::print_char(const position &pos, const char ch, void curses_output::print_char(const position &pos, const char ch,
@ -16,7 +16,7 @@ void curses_output::print_char(const position &pos, const char ch,
if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT) if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT)
return; return;
curse.print_char(pos, ch, attrs); curse->print_char(pos, ch, attrs);
} }
void curses_output::print_str(const position &pos, const std::string &str, void curses_output::print_str(const position &pos, const std::string &str,
@ -27,7 +27,7 @@ void curses_output::print_str(const position &pos, const std::string &str,
position tmp = pos; position tmp = pos;
for (std::size_t i = 0; i < str.length(); ++i) { for (std::size_t i = 0; i < str.length(); ++i) {
curse.print_char(tmp, str[i], attrs); curse->print_char(tmp, str[i], attrs);
tmp += {1, 0}; tmp += {1, 0};
if (tmp.x >= DISPLAY_WIDTH) if (tmp.x >= DISPLAY_WIDTH)

View File

@ -8,9 +8,9 @@
class curses_output final : public display { class curses_output final : public display {
private: private:
cursor &curse; cursor *curse;
public: public:
curses_output(cursor &new_curse); curses_output(cursor *new_curse);
void render() override; void render() override;
void clear() override; void clear() override;

View File

@ -13,19 +13,19 @@
class game final { class game final {
private: private:
feature features; feature features;
input &in; input *in;
display &out; display *out;
logger &log; logger *log;
RNG &rng; RNG *rng;
// IMPORTANT: during player generation, // IMPORTANT: during player generation,
std::unique_ptr<character> player; std::unique_ptr<character> player;
public: public:
game(const feature enabled_features, game(const feature enabled_features,
input &new_in, input *new_in,
display &new_out, display *new_out,
logger &new_log, logger *new_log,
RNG &new_rng); RNG *new_rng);
game_status run(); game_status run();
private: private:
int getcmd() const; int getcmd() const;