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:
@ -47,6 +47,8 @@ feature proc_args(int argc, char **argv,
|
||||
result |= FEATURE_THROW;
|
||||
} else if (str == "-R") {
|
||||
result |= FEATURE_REVISIT;
|
||||
} else if (str == "-e") {
|
||||
result |= FEATURE_EXTRA_STUFF;
|
||||
} else if (str == "-s") {
|
||||
++i;
|
||||
str = argv[i];
|
||||
@ -121,8 +123,8 @@ feature proc_args(int argc, char **argv,
|
||||
|
||||
if (result & FEATURE_NCURSES) {
|
||||
curse = std::make_unique<cursor>();
|
||||
in = std::make_unique<curses_input>(*curse);
|
||||
out = std::make_unique<curses_output>(*curse);
|
||||
in = std::make_unique<curses_input>(curse.get());
|
||||
out = std::make_unique<curses_output>(curse.get());
|
||||
}
|
||||
|
||||
if (result & FEATURE_SEED) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
-i : Enable inventory
|
||||
-t : Enable throw
|
||||
-R : Enable revisiting levels
|
||||
-e : Enable extra potions and races
|
||||
-s [seed] : Sets initial seed to seed
|
||||
-L [file] : Enable logging to file
|
||||
-I [file] : Reads commands from file. CANNOT BE USED WITH -n.
|
||||
|
@ -92,6 +92,7 @@ const feature FEATURE_SEED = 1 << 7;
|
||||
const feature FEATURE_MENU = 1 << 8;
|
||||
const feature FEATURE_IN_FILE = 1 << 9;
|
||||
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_FILE = 1 << 28;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "curses_input.h"
|
||||
|
||||
curses_input::curses_input(cursor &new_curse):
|
||||
curses_input::curses_input(cursor *new_curse):
|
||||
curse{new_curse} {}
|
||||
|
||||
game_command curses_input::get_command() {
|
||||
switch (curse.getcmd()) {
|
||||
switch (curse->getcmd()) {
|
||||
case 'h':
|
||||
return game_command::move_west;
|
||||
|
||||
@ -51,7 +51,7 @@ game_command curses_input::get_command() {
|
||||
return game_command_pass;
|
||||
}
|
||||
|
||||
switch (curse.getcmd()) {
|
||||
switch (curse->getcmd()) {
|
||||
case 'h':
|
||||
return game_command::apply_west;
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
class curses_input final: public input {
|
||||
private:
|
||||
cursor &curse;
|
||||
cursor *curse;
|
||||
public:
|
||||
curses_input(cursor &new_curse);
|
||||
curses_input(cursor *new_curse);
|
||||
game_command get_command() override;
|
||||
};
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "curses_output.h"
|
||||
|
||||
curses_output::curses_output(cursor &new_curse):
|
||||
curses_output::curses_output(cursor *new_curse):
|
||||
curse{new_curse} {}
|
||||
|
||||
void curses_output::render() {
|
||||
curse.show();
|
||||
curse->show();
|
||||
}
|
||||
|
||||
void curses_output::clear() {
|
||||
curse.clear();
|
||||
curse->clear();
|
||||
}
|
||||
|
||||
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)
|
||||
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,
|
||||
@ -27,7 +27,7 @@ void curses_output::print_str(const position &pos, const std::string &str,
|
||||
position tmp = pos;
|
||||
|
||||
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};
|
||||
|
||||
if (tmp.x >= DISPLAY_WIDTH)
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
class curses_output final : public display {
|
||||
private:
|
||||
cursor &curse;
|
||||
cursor *curse;
|
||||
public:
|
||||
curses_output(cursor &new_curse);
|
||||
curses_output(cursor *new_curse);
|
||||
|
||||
void render() override;
|
||||
void clear() override;
|
||||
|
16
src/game.h
16
src/game.h
@ -13,19 +13,19 @@
|
||||
class game final {
|
||||
private:
|
||||
feature features;
|
||||
input ∈
|
||||
display &out;
|
||||
logger &log;
|
||||
RNG &rng;
|
||||
input *in;
|
||||
display *out;
|
||||
logger *log;
|
||||
RNG *rng;
|
||||
|
||||
// IMPORTANT: during player generation,
|
||||
std::unique_ptr<character> player;
|
||||
public:
|
||||
game(const feature enabled_features,
|
||||
input &new_in,
|
||||
display &new_out,
|
||||
logger &new_log,
|
||||
RNG &new_rng);
|
||||
input *new_in,
|
||||
display *new_out,
|
||||
logger *new_log,
|
||||
RNG *new_rng);
|
||||
game_status run();
|
||||
private:
|
||||
int getcmd() const;
|
||||
|
Reference in New Issue
Block a user