removed .orig files (astyle backups)

This commit is contained in:
2024-07-14 21:38:45 -04:00
parent af8bc4112c
commit c3b974c83c
4 changed files with 57 additions and 57 deletions

View File

@ -2,53 +2,53 @@
#include "constants.h" #include "constants.h"
cursor::cursor() { cursor::cursor() {
initscr(); initscr();
if (has_colors()) { if (has_colors()) {
start_color(); start_color();
init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK); init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
init_pair(COLOR_BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE); init_pair(COLOR_BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE);
} }
} }
cursor::~cursor() { cursor::~cursor() {
endwin(); endwin();
} }
int cursor::getcmd() const { int cursor::getcmd() const {
return getch(); return getch();
} }
void cursor::show() const { void cursor::show() const {
refresh(); refresh();
} }
void cursor::clear() const { void cursor::clear() const {
::clear(); ::clear();
} }
void cursor::print_char(const position &pos, const char ch, void cursor::print_char(const position &pos, const char ch,
const int attrs) const { const int attrs) const {
attrset(attrs); attrset(attrs);
mvaddch(pos.y, pos.x, ch); mvaddch(pos.y, pos.x, ch);
} }
void cursor::print_str(const position &pos, const std::string str, void cursor::print_str(const position &pos, const std::string str,
const int attrs) const { const int attrs) const {
attrset(attrs); attrset(attrs);
mvaddstr(pos.y, pos.x, str.c_str()); mvaddstr(pos.y, pos.x, str.c_str());
} }
bool check_terminal_size() { bool check_terminal_size() {
int max_x; int max_x;
int max_y; int max_y;
getmaxyx(stdscr, max_y, max_x); getmaxyx(stdscr, max_y, max_x);
return max_x >= DISPLAY_WIDTH && max_y >= DISPLAY_HEIGHT; return max_x >= DISPLAY_WIDTH && max_y >= DISPLAY_HEIGHT;
} }

View File

@ -37,20 +37,20 @@
class cursor final { class cursor final {
private: private:
public: public:
cursor(); cursor();
~cursor(); ~cursor();
int getcmd() const; int getcmd() const;
void show() const; void show() const;
void clear() const ; void clear() const ;
void print_char(const position &pos, const char ch, const int attrs) const; void print_char(const position &pos, const char ch, const int attrs) const;
void print_str(const position &head, const std::string str, void print_str(const position &head, const std::string str,
const int attrs) const; const int attrs) const;
}; };
// IMPORTANT: this will fail when terminal size changes // IMPORTANT: this will fail when terminal size changes

View File

@ -5,43 +5,43 @@ position::position(): x{0}, y{0} {}
position::position(int nx, int ny): x{nx}, y{ny} {} position::position(int nx, int ny): x{nx}, y{ny} {}
position position::operator+(const position &other) const { position position::operator+(const position &other) const {
position result{x + other.x, y + other.y}; position result{x + other.x, y + other.y};
return result; return result;
} }
position &position::operator=(const position &other) { position &position::operator=(const position &other) {
x = other.x; x = other.x;
y = other.y; y = other.y;
return *this; return *this;
} }
position &position::operator+=(const position &other) { position &position::operator+=(const position &other) {
return *this = *this + other; return *this = *this + other;
} }
bool position::operator==(const position &other) const { bool position::operator==(const position &other) const {
return x == other.x && y == other.y; return x == other.x && y == other.y;
} }
bool position::operator!=(const position &other) const { bool position::operator!=(const position &other) const {
return x != other.x || y != other.y; return x != other.x || y != other.y;
} }
bool position::operator<(const position &other) const { bool position::operator<(const position &other) const {
return y < other.y || x < other.x; return y < other.y || x < other.x;
} }
#include <iostream> #include <iostream>
size_t find(const std::vector<position> &sorted_list, size_t find(const std::vector<position> &sorted_list,
const position &target) { const position &target) {
// TODO: implement binary searching // TODO: implement binary searching
for (size_t i = 0; i < sorted_list.size(); ++i) for (size_t i = 0; i < sorted_list.size(); ++i)
if (sorted_list[i] == target) if (sorted_list[i] == target)
return i; return i;
return sorted_list.size(); return sorted_list.size();
} }
#include <algorithm> #include <algorithm>

View File

@ -11,20 +11,20 @@
// IMPORTANT: pass all RNG objects as references // IMPORTANT: pass all RNG objects as references
class RNG final { class RNG final {
private: private:
const unsigned int init_seed; const unsigned int init_seed;
int curr_rand_num; int curr_rand_num;
public: public:
RNG(); // use time(0) as the seed RNG(); // use time(0) as the seed
RNG(const unsigned int seed); // use a seed RNG(const unsigned int seed); // use a seed
int rand_num(); // returns a random number between 0 and RAND_MAX int rand_num(); // returns a random number between 0 and RAND_MAX
// IMPORTANT: all upper bounds are not included, all lower bounds are // IMPORTANT: all upper bounds are not included, all lower bounds are
int rand_between(const int lower_bound, const int upper_bound); int rand_between(const int lower_bound, const int upper_bound);
// returns a random number between 0 and upper_bound // returns a random number between 0 and upper_bound
int rand_under(const int upper_bound); int rand_under(const int upper_bound);
unsigned int get_init_seed() const; unsigned int get_init_seed() const;
int get_curr_rand_num() const; int get_curr_rand_num() const;
bool trial(const fraction &psuccess); bool trial(const fraction &psuccess);