finished the bulk of game

This commit is contained in:
2024-07-14 21:32:41 -04:00
parent b3475b7530
commit af8bc4112c
110 changed files with 1876 additions and 1481 deletions

View File

@ -2,101 +2,102 @@
#define __CONSTANTS_H__
#include <vector>
#include <ncurses.h>
#include <string>
#include "position.h"
const int INF = 0x3F3F3F3F;
enum error {none};
static const int INF = 0x3F3F3F3F;
// TODO: update result to include subject
// fine will waste a turn
enum result {fine, died, go_down, go_up, hit, moved,
miss, terminate, applied, applied_nothing,
toggle_the_world, restart_game, unknown
};
enum game_status {terminated, main_menu, in_game, options,
dead, won, escaped, restart
};
enum game_command {game_command_terminate = 0,
move_north, move_south, move_east, move_west,
move_northeast, move_northwest,
move_southeast, move_southwest,
apply_north, apply_south, apply_east, apply_west,
apply_northeast, apply_northwest,
apply_southeast, apply_southwest,
apply_panic, // for curses_input specifically
attack_north, attack_south, attack_east, attack_west,
attack_northeast, attack_northwest,
attack_southeast, attack_southwest,
up_stairs, down_stairs,
the_world, game_restart,
game_command_pass, game_command_panic
enum result : int {fine, died, go_down, go_up, hit, moved,
miss, terminate, applied, applied_nothing,
toggle_the_world, restart_game, unknown
};
// Character generation related
const int RACE_CNT = 12;
enum race {rshade = 0, rdrow, rvampire, rtroll,
rgoblin, rhuman, rdwarf, relf,
rorc, rmerchant, rdragon, rhalfling
};
const char *RACE_NAME[RACE_CNT] = {
"Shade", "Drow", "Vampire", "Troll",
"Goblin", "Human", "Dwarf", "Elf",
"Orc", "Merchant", "Dragon", "Halfling"
struct long_result {
result res;
std::string msg;
};
const int MAX_HP[RACE_CNT] = {
enum game_status : int {terminated, main_menu, in_game, options,
dead, won, escaped, restart, skip_turn
};
enum game_command : int {game_command_terminate = 0,
move_north, move_south, move_east, move_west,
move_northeast, move_northwest,
move_southeast, move_southwest,
apply_north, apply_south, apply_east, apply_west,
apply_northeast, apply_northwest,
apply_southeast, apply_southwest,
apply_panic, // for curses_input specifically
attack_north, attack_south, attack_east, attack_west,
attack_northeast, attack_northwest,
attack_southeast, attack_southwest,
up_stairs, down_stairs,
the_world, game_restart,
game_command_pass, game_command_panic,
enter
};
// Character generation related
static const int RACE_CNT = 12;
enum race : int {rshade = 0, rdrow, rvampire, rtroll,
rgoblin, rhuman, rdwarf, relf,
rorc, rmerchant, rdragon, rhalfling
};
static const char CHAR_REP[RACE_CNT] = {
's', 'd', 'v', 't', 'g', 'H', 'W', 'E', 'O', 'M', 'D', 'L'
};
static const int MAX_HP[RACE_CNT] = {
125, 150, INF, 120, 110, 140, 100, 140, 180, 30, 150, 100
};
const int STARTING_HP[RACE_CNT] = {
static const int STARTING_HP[RACE_CNT] = {
125, 150, 50, 120, 110, 140, 100, 140, 180, 30, 150, 100
};
const int STARTING_ATK[RACE_CNT] = {
static const int STARTING_ATK[RACE_CNT] = {
25, 25, 25, 25, 15, 20, 20, 30, 30, 70, 20, 15
};
const int STARTING_DEF[RACE_CNT] = {
static const int STARTING_DEF[RACE_CNT] = {
25, 15, 25, 15, 20, 20, 30, 10, 25, 5, 20, 20
};
// Potion-related
const int POTION_TYPE_CNT = 6;
const int DEFAULT_POTION_TYPE_CNT = 6;
enum potion_type {restore_health = 0, boost_atk, boost_def,
poison_health, wound_atk, wound_def
};
const char *POTION_REAL_NAME[POTION_TYPE_CNT] = {
"RH", "BA", "BD", "PH", "WA", "WD"
};
static const int POTION_TYPE_CNT = 6;
static const int DEFAULT_POTION_TYPE_CNT = 6;
enum potion_type : int {restore_health = 0, boost_atk, boost_def,
poison_health, wound_atk, wound_def
};
// Calculation priorities
const int CALC_ADD_BASE = 0;
const int CALC_MUL_BASE = 1;
const int CALC_ADD_LATER = 2;
const int CALC_MUL_LATER = 3;
const int CALC_ADD_FIXED = 4;
static const int CALC_ADD_BASE = 0;
static const int CALC_MUL_BASE = 1;
static const int CALC_ADD_LATER = 2;
static const int CALC_MUL_LATER = 3;
static const int CALC_ADD_FIXED = 4;
const int DIRECTION_CNT = 8;
static const int DIRECTION_CNT = 8;
// IMPORTANT: east is positive for x and SOUTH is positive for y
// initializes all directions to an int
enum direction { north = 0, south, east, west, northeast,
northwest, southeast, southwest
};
enum direction : int { north = 0, south, east, west, northeast,
northwest, southeast, southwest
};
const position MOVE[DIRECTION_CNT] = {
static const position MOVE[DIRECTION_CNT] = {
{0, -1}, {0, 1}, {1, 0}, {-1, 0},
{1, -1}, {-1, -1}, {1, 1}, {-1, 1}
};
const int MAP_HEIGHT = 25;
const int MAP_WIDTH = 79;
const int DISPLAY_HEIGHT = 30;
const int DISPLAY_WIDTH = 79;
const int DISPLAY_BUFFER_SIZE = DISPLAY_HEIGHT * DISPLAY_WIDTH +
DISPLAY_WIDTH * 3;
static const int MAP_HEIGHT = 25;
static const int MAP_WIDTH = 79;
static const int DISPLAY_HEIGHT = 30;
static const int DISPLAY_WIDTH = 79;
static const int DISPLAY_BUFFER_SIZE = DISPLAY_HEIGHT * DISPLAY_WIDTH +
DISPLAY_WIDTH * 3;
// TODO: list all extra features
// using constants to keep track of features
@ -105,38 +106,35 @@ const int DISPLAY_BUFFER_SIZE = DISPLAY_HEIGHT * DISPLAY_WIDTH +
// check if feature is enabled:
// features & FEATURE_XXX
typedef unsigned int feature; // can extend to unsigned long (long) if needed
const feature FEATURE_NCURSES = 1 << 0;
const feature FEATURE_RAND_MAP = 1 << 1;
const feature FEATURE_ENEMIES_CHASE = 1 << 2;
const feature FEATURE_INVENTORY = 1 << 3;
const feature FEATURE_THROW = 1 << 4;
const feature FEATURE_REVISIT = 1 << 5;
const feature FEATURE_LOG = 1 << 6;
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_EXTRA_LEVELS = 1 << 12;
const feature FEATURE_COLORFUL = 1 << 13;
static const feature FEATURE_NCURSES = 1 << 0;
static const feature FEATURE_RAND_MAP = 1 << 1;
static const feature FEATURE_ENEMIES_CHASE = 1 << 2;
static const feature FEATURE_INVENTORY = 1 << 3;
static const feature FEATURE_THROW = 1 << 4;
static const feature FEATURE_REVISIT = 1 << 5;
static const feature FEATURE_WALK_OVER = 1 << 6;
static const feature FEATURE_SEED = 1 << 7;
static const feature FEATURE_MENU = 1 << 8;
static const feature FEATURE_IN_FILE = 1 << 9;
static const feature FEATURE_OUT_FILE = 1 << 10;
static const feature FEATURE_EXTRA_STUFF = 1 << 11;
static const feature FEATURE_EXTRA_LEVELS = 1 << 12;
static const feature FEATURE_COLORFUL = 1 << 13;
const feature FEATURE_PANIC_SEED = 1 << 27;
const feature FEATURE_PANIC_FILE = 1 << 28;
const feature FEATURE_PANIC = 1 << 29;
const feature FEATURE_CONFLICT = 1 << 30;
const feature FEATURE_LIST_ARGS = 1 << 31;
static const feature FEATURE_PANIC_SEED = 1 << 27;
static const feature FEATURE_PANIC_FILE = 1 << 28;
static const feature FEATURE_PANIC = 1 << 29;
static const feature FEATURE_CONFLICT = 1 << 30;
static const feature FEATURE_LIST_ARGS = 1 << 31;
const int RETURN_FINE = 0;
const int RETURN_PANICKED = 1;
static const int RETURN_FINE = 0;
static const int RETURN_PANICKED = 1;
const int COLOR_BLACK_ON_WHITE = 8;
static const int COLOR_BLACK_ON_WHITE = 8;
typedef std::vector<position> position_list;
typedef std::vector<direction> direction_list;
const int GOLD_SMALL = 1;
const int GOLD_NORMAL = 2;
const int GOLD_MERCHANT = 4;
const int GOLD_DRAGON = 6;
static const int GOLD_SMALL = 1;
static const int GOLD_NORMAL = 2;
static const int GOLD_MERCHANT = 4;
static const int GOLD_DRAGON = 6;
#endif