Merge branch 'master' of peisongxiao.com:~/cs246/a5

This commit is contained in:
2024-07-20 15:31:48 -04:00
53 changed files with 397 additions and 397 deletions

View File

@ -10,17 +10,17 @@ CC3K::CC3K(const feature enabled_features,
out->clear(); out->clear();
curr_menu->print(out, rng->get_init_seed()); curr_menu->print(out, rng->get_init_seed());
out->render(); out->render();
gresult.status = game_status::main_menu; gresult.status = game_status::MAIN_MENU;
} }
game_status CC3K::run() { game_status CC3K::run() {
switch (gresult.status) { switch (gresult.status) {
case main_menu: { case MAIN_MENU: {
auto tmp = curr_menu->run(in); auto tmp = curr_menu->run(in);
if (tmp == -2) { if (tmp == -2) {
gresult.status = terminated; gresult.status = TERMINATED;
return terminated; return TERMINATED;
} }
if (tmp != -1) { if (tmp != -1) {
@ -32,34 +32,34 @@ game_status CC3K::run() {
out->clear(); out->clear();
curr_game->print(); curr_game->print();
out->render(); out->render();
gresult.status = in_game; gresult.status = IN_GAME;
return in_game; return IN_GAME;
} }
out->clear(); out->clear();
curr_menu->print(out, rng->get_init_seed()); curr_menu->print(out, rng->get_init_seed());
out->render(); out->render();
return main_menu; return MAIN_MENU;
} }
case in_game: { case IN_GAME: {
gresult = curr_game->run(); gresult = curr_game->run();
if (gresult.status == restart) { if (gresult.status == RESTART) {
curr_game.reset(); curr_game.reset();
curr_menu = std::make_unique<menu>(enabled_features); curr_menu = std::make_unique<menu>(enabled_features);
out->clear(); out->clear();
curr_menu->print(out, rng->get_init_seed()); curr_menu->print(out, rng->get_init_seed());
out->render(); out->render();
gresult.status = main_menu; gresult.status = MAIN_MENU;
return main_menu; return MAIN_MENU;
} else if (gresult.status == in_game) { } else if (gresult.status == IN_GAME) {
out->clear(); out->clear();
curr_game->print(); curr_game->print();
out->render(); out->render();
return in_game; return IN_GAME;
} else if (gresult.status == terminated) { } else if (gresult.status == TERMINATED) {
return terminated; return TERMINATED;
} }
out->clear(); out->clear();
@ -68,26 +68,26 @@ game_status CC3K::run() {
return gresult.status; return gresult.status;
} }
case dead: case DEAD:
case won: case WON:
case escaped: case ESCAPED:
curr_game.reset(); curr_game.reset();
gresult.run(in); gresult.run(in);
if (gresult.status == restart) { if (gresult.status == RESTART) {
curr_menu = std::make_unique<menu>(enabled_features); curr_menu = std::make_unique<menu>(enabled_features);
out->clear(); out->clear();
curr_menu->print(out, rng->get_init_seed()); curr_menu->print(out, rng->get_init_seed());
out->render(); out->render();
gresult.status = main_menu; gresult.status = MAIN_MENU;
return main_menu; return MAIN_MENU;
} }
return terminated; return TERMINATED;
default: default:
break; break;
} }
return terminated; return TERMINATED;
} }

View File

@ -49,7 +49,7 @@ result character::calc_effects() {
effects[i]->apply(this->race, HP, ATK, DEF, base_hit_rate); effects[i]->apply(this->race, HP, ATK, DEF, base_hit_rate);
if (is_dead()) if (is_dead())
return result::died; return result::DIED;
if (effects[i]->get_duration() != 0) if (effects[i]->get_duration() != 0)
tmp.push_back(std::move(effects[i])); tmp.push_back(std::move(effects[i]));
@ -59,7 +59,7 @@ result character::calc_effects() {
std::swap(tmp, effects); std::swap(tmp, effects);
return result::fine; return result::NOTHING;
} }
void character::discard_level_effects() { void character::discard_level_effects() {

View File

@ -8,12 +8,10 @@
static const int INF = 0x3F3F3F3F; static const int INF = 0x3F3F3F3F;
// TODO: update result to include subject enum result : int {NOTHING, DIED, GO_DOWN, GO_UP, HIT, MOVED,
// fine will waste a turn MISS, TERMINATE, APPLIED, APPLIED_NOTHING,
enum result : int {fine, died, go_down, go_up, hit, moved, TOGGLE_THE_WORLD, RESTART_GAME, UNKNOWN,
miss, terminate, applied, applied_nothing, INVENTORY, THROWN
toggle_the_world, restart_game, unknown,
inventory, thrown
}; };
struct long_result { struct long_result {
@ -21,40 +19,40 @@ struct long_result {
std::string msg; std::string msg;
}; };
enum game_status : int {terminated, main_menu, in_game, options, enum game_status : int {TERMINATED, MAIN_MENU, IN_GAME, OPTIONS,
dead, won, escaped, restart DEAD, WON, ESCAPED, RESTART
}; };
enum game_command : int {game_command_terminate = 0, enum game_command : int {GAME_COMMAND_TERMINATE = 0,
move_north, move_south, move_east, move_west, MOVE_NORTH, MOVE_SOUTH, MOVE_EAST, MOVE_WEAT,
move_northeast, move_northwest, MOVE_NORTHEAST, MOVE_NORTHWEST,
move_southeast, move_southwest, MOVE_SOUTHEAST, MOVE_SOUTHWEST,
apply_north, apply_south, apply_east, apply_west, APPLY_NORTH, APPLY_SOUTH, APPLY_EAST, APPLY_WEST,
apply_northeast, apply_northwest, APPLY_NORTHEAST, APPLY_NORTHWEST,
apply_southeast, apply_southwest, APPLY_SOUTHEAST, APPLY_SOUTHWEST,
apply_panic, // for curses_input specifically APPLY_PANIC, // for curses_input specifically
attack_north, attack_south, attack_east, attack_west, ATTACK_NORTH, ATTACK_SOUTH, ATTACK_EAST, ATTACK_WEST,
attack_northeast, attack_northwest, ATTACK_NORTHEAST, ATTACK_NORTHWEST,
attack_southeast, attack_southwest, ATTACK_SOUTHEAST, ATTACK_SOUTHWEST,
up_stairs, down_stairs, UP_STAIRS, DOWN_STAIRS,
the_world, game_restart, THE_WORLD, GAME_RESTART,
game_command_pass, game_command_panic, GAME_COMMAND_PASS, GAME_COMMAND_PANIC,
enter, toggle_inventory, ENTER, TOGGLE_INVENTORY,
throw_north, throw_south, throw_east, throw_west, THROW_NORTH, THROW_SOUTH, THROW_EAST, THROW_WEST,
throw_northeast, throw_northwest, THROW_NORTHEAST, THROW_NORTHWEST,
throw_southeast, throw_southwest, THROW_SOUTHEAST, THROW_SOUTHWEST,
select_shade, select_drow, select_vampire, SELECT_SHADE, SELECT_DROW, SELECT_VAMPIRE,
select_goblin, select_troll SELECT_GOBLIN, SELECT_TROLL
}; };
// Character generation related // Character generation related
static const int RACE_CNT = 23; static const int RACE_CNT = 23;
enum race : int {rshade = 0, rdrow, rvampire, rtroll, enum race : int {SHADE = 0, DROW, VAMPIRE, TROLL,
rgoblin, rhuman, rdwarf, relf, GOBLIN, HUMAN, DWARF, ELF,
rorc, rmerchant, rdragon, rhalfling, ORC, MERCHANT, DRAGON, HALFLING,
rt_800, rmr_goose, rmonk, rbrawler, RT_800, MR_GOOSE, MONK, BRAWLER,
rassassin, rviking, rswordsman, ASSASSIN, VIKING, SWORDSMAN,
rleprechaun, rwitch, rhacker, rbaby_dragon LEPRECHAUN, WITCH, HACKER, BABY_DRAGON
}; };
static const char CHAR_REP[RACE_CNT] = { static const char CHAR_REP[RACE_CNT] = {
@ -94,12 +92,12 @@ static const fraction STARTING_HR[RACE_CNT] = {
// Potion-related // Potion-related
static const int POTION_TYPE_CNT = 14; static const int POTION_TYPE_CNT = 14;
static const int DEFAULT_POTION_TYPE_CNT = 6; static const int DEFAULT_POTION_TYPE_CNT = 6;
enum potion_type : int {restore_health = 0, boost_atk, boost_def, enum potion_type : int {RESTORE_HEALTH = 0, BOOST_ATK, BOOST_DEF,
poison_health, wound_atk, wound_def, POISON_HEALTH, WOUND_ATK, WOUND_DEF,
continuous_restoration, savage_strike, CONTINUOUS_RESTORATION, SAVAGE_STRIKE,
echoing_resilience, tempest_tantrum, ECHOING_RESIL, TEMPEST_TANTRUM,
bezerk_brew, borrow_life, BEZERK_BREW, BORROW_LIFE,
fine_booze, ironclad_ward FINE_BOOZE, IRONCLAD_WARD
}; };
// Calculation priorities // Calculation priorities
@ -111,8 +109,8 @@ static const int CALC_LAST = 2;
static const int DIRECTION_CNT = 8; static const int DIRECTION_CNT = 8;
// IMPORTANT: east is positive for x and SOUTH is positive for y // IMPORTANT: east is positive for x and SOUTH is positive for y
// initializes all directions to an int // initializes all directions to an int
enum direction : int { north = 0, south, east, west, northeast, enum direction : int { NORTH = 0, SOUTH, EAST, WEST, NORTHEAST,
northwest, southeast, southwest NORTHWEST, SOUTHEAST, SOUTHWEST
}; };
static const position MOVE[DIRECTION_CNT] = { static const position MOVE[DIRECTION_CNT] = {

View File

@ -31,17 +31,17 @@ std::unique_ptr<enemy_base> new_dragon(RNG *rng, const position &pos,
const int EXCNT = 12; const int EXCNT = 12;
const race EXCHOICES[EXCNT] = { const race EXCHOICES[EXCNT] = {
rhuman, rdwarf, rhalfling, relf, rorc, rmerchant, HUMAN, DWARF, HALFLING, ELF, ORC, MERCHANT,
rviking, rswordsman, rleprechaun, rwitch, rhacker, rbaby_dragon VIKING, SWORDSMAN, LEPRECHAUN, WITCH, HACKER, BABY_DRAGON
}; };
const int CNT = 18; const int CNT = 18;
const race CHOICES[CNT] = { const race CHOICES[CNT] = {
rhuman, rhuman, rhuman, rhuman, HUMAN, HUMAN, HUMAN, HUMAN,
rdwarf, rdwarf, rdwarf, DWARF, DWARF, DWARF,
rhalfling, rhalfling, rhalfling, rhalfling, rhalfling, HALFLING, HALFLING, HALFLING, HALFLING, HALFLING,
relf, relf, ELF, ELF,
rorc, rorc, ORC, ORC,
rmerchant, rmerchant MERCHANT, MERCHANT
}; };
enum race get_extra_race(RNG *rng) { enum race get_extra_race(RNG *rng) {
@ -65,51 +65,51 @@ std::unique_ptr<enemy_base> new_enemy(RNG *rng, const position &pos,
r = get_normal_race(rng); r = get_normal_race(rng);
switch (r) { switch (r) {
case rdwarf: case DWARF:
return make_unique<dwarf>(rng, enabled_features, return make_unique<dwarf>(rng, enabled_features,
pos, which_room); pos, which_room);
case rhuman: case HUMAN:
return make_unique<human>(rng, enabled_features, return make_unique<human>(rng, enabled_features,
pos, which_room); pos, which_room);
case relf: case ELF:
return make_unique<elf>(rng, enabled_features, return make_unique<elf>(rng, enabled_features,
pos, which_room); pos, which_room);
case rorc: case ORC:
return make_unique<orc>(rng, enabled_features, return make_unique<orc>(rng, enabled_features,
pos, which_room); pos, which_room);
case rmerchant: case MERCHANT:
return make_unique<merchant>(rng, enabled_features, return make_unique<merchant>(rng, enabled_features,
pos, which_room); pos, which_room);
case rhalfling: case HALFLING:
return make_unique<halfling>(rng, enabled_features, return make_unique<halfling>(rng, enabled_features,
pos, which_room); pos, which_room);
case rviking: case VIKING:
return make_unique<viking>(rng, enabled_features, return make_unique<viking>(rng, enabled_features,
pos, which_room); pos, which_room);
case rswordsman: case SWORDSMAN:
return make_unique<swordsman>(rng, enabled_features, return make_unique<swordsman>(rng, enabled_features,
pos, which_room); pos, which_room);
case rleprechaun: case LEPRECHAUN:
return make_unique<leprechaun>(rng, enabled_features, return make_unique<leprechaun>(rng, enabled_features,
pos, which_room); pos, which_room);
case rwitch: case WITCH:
return make_unique<witch>(rng, enabled_features, return make_unique<witch>(rng, enabled_features,
pos, which_room); pos, which_room);
case rhacker: case HACKER:
return make_unique<hacker>(rng, enabled_features, return make_unique<hacker>(rng, enabled_features,
pos, which_room); pos, which_room);
case rbaby_dragon: case BABY_DRAGON:
return make_unique<baby_dragon>(rng, enabled_features, return make_unique<baby_dragon>(rng, enabled_features,
pos, which_room); pos, which_room);

View File

@ -4,7 +4,7 @@
baby_dragon::baby_dragon(RNG *rng, const feature enabled_features, baby_dragon::baby_dragon(RNG *rng, const feature enabled_features,
const position &pos, const int gen_room_num): const position &pos, const int gen_room_num):
enemy_base{rng, enabled_features, rbaby_dragon, pos, gen_room_num, "B"} {} enemy_base{rng, enabled_features, BABY_DRAGON, pos, gen_room_num, "B"} {}
const char *baby_dragon::get_race_name() const { const char *baby_dragon::get_race_name() const {
return "Baby_Dragon"; return "Baby_Dragon";

View File

@ -4,7 +4,7 @@
dragon::dragon(RNG *rng, const feature enabled_features, const position &pos, dragon::dragon(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rdragon, pos, gen_room_num, "D"} {} enemy_base{rng, enabled_features, DRAGON, pos, gen_room_num, "D"} {}
const char *dragon::get_race_name() const { const char *dragon::get_race_name() const {
return "Dragon"; return "Dragon";
@ -14,7 +14,7 @@ long_result dragon::act(level *lvl, character *pc, bool hostile) {
if (is_adjacent(pos, pc->get_pos()) && hostile) if (is_adjacent(pos, pc->get_pos()) && hostile)
return attack(pc); return attack(pc);
return {fine, ""}; return {NOTHING, ""};
} }
int dragon::dies(level *lvl) { int dragon::dies(level *lvl) {

View File

@ -4,7 +4,7 @@
dwarf::dwarf(RNG *rng, const feature enabled_features, const position &pos, dwarf::dwarf(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rdwarf, pos, gen_room_num, "W"} {} enemy_base{rng, enabled_features, DWARF, pos, gen_room_num, "W"} {}
const char *dwarf::get_race_name() const { const char *dwarf::get_race_name() const {
return "Dwarf"; return "Dwarf";

View File

@ -4,7 +4,7 @@
elf::elf(RNG *rng, const feature enabled_features, const position &pos, elf::elf(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, relf, pos, gen_room_num, "E"} {} enemy_base{rng, enabled_features, ELF, pos, gen_room_num, "E"} {}
const char *elf::get_race_name() const { const char *elf::get_race_name() const {
return "Elf"; return "Elf";
@ -13,18 +13,18 @@ const char *elf::get_race_name() const {
long_result elf::attack(character *ch) { long_result elf::attack(character *ch) {
auto res1 = ch->get_hit(this, ATK, base_hit_rate); auto res1 = ch->get_hit(this, ATK, base_hit_rate);
if (res1.res == result::died) if (res1.res == result::DIED)
return res1; return res1;
if (ch->get_race() == rdrow) if (ch->get_race() == DROW)
return res1; return res1;
auto res2 = ch->get_hit(this, ATK, base_hit_rate); auto res2 = ch->get_hit(this, ATK, base_hit_rate);
if (res1.res == miss && res2.res == miss) if (res1.res == MISS && res2.res == MISS)
return {miss, res1.msg + res2.msg}; return {MISS, res1.msg + res2.msg};
else if (res2.res == died) else if (res2.res == DIED)
return {died, res1.msg + res2.msg}; return {DIED, res1.msg + res2.msg};
else else
return {hit, res1.msg + res2.msg}; return {HIT, res1.msg + res2.msg};
} }

View File

@ -4,7 +4,7 @@
hacker::hacker(RNG *rng, const feature enabled_features, const position &pos, hacker::hacker(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rhacker, pos, gen_room_num, "h"} {} enemy_base{rng, enabled_features, HACKER, pos, gen_room_num, "h"} {}
const char *hacker::get_race_name() const { const char *hacker::get_race_name() const {
return "Hacker"; return "Hacker";
@ -18,12 +18,12 @@ long_result hacker::get_hit(character *ch, const int tATK,
HP -= tmp; HP -= tmp;
if (HP == 0) if (HP == 0)
return {result::hit, rand_str()}; return {result::HIT, rand_str()};
return {result::hit, rand_str()}; return {result::HIT, rand_str()};
} }
return {miss, rand_str()}; return {MISS, rand_str()};
} }
std::string hacker::rand_str() { std::string hacker::rand_str() {

View File

@ -7,7 +7,7 @@ fraction halfling::HIT_RATE_MUL = {1, 2};
halfling::halfling(RNG *rng, const feature enabled_features, halfling::halfling(RNG *rng, const feature enabled_features,
const position &pos, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rhalfling, pos, gen_room_num, "L"} {} enemy_base{rng, enabled_features, HALFLING, pos, gen_room_num, "L"} {}
const char *halfling::get_race_name() const { const char *halfling::get_race_name() const {
return "Halfling"; return "Halfling";
@ -23,17 +23,17 @@ long_result halfling::get_hit(character *ch, const int tATK,
HP -= tmp; HP -= tmp;
if (HP == 0) if (HP == 0)
return {result::hit, return {result::HIT,
"PC deals " + std::to_string(tmp) + "PC deals " + std::to_string(tmp) +
" damage to " + abbrev + " (" + " damage to " + abbrev + " (" +
std::to_string(HP) + " HP). " + std::to_string(HP) + " HP). " +
abbrev + " is slain by PC. "}; abbrev + " is slain by PC. "};
return {result::hit, "PC deals " + return {result::HIT, "PC deals " +
std::to_string(tmp) + " damage to " + abbrev + " (" + std::to_string(tmp) + " damage to " + abbrev + " (" +
std::to_string(HP) + " HP). "}; std::to_string(HP) + " HP). "};
} }
return {miss, "PC tried to hit " + abbrev + return {MISS, "PC tried to hit " + abbrev +
" but missed. The halfling laughed. "}; " but missed. The halfling laughed. "};
} }

View File

@ -5,7 +5,7 @@
human::human(RNG *rng, const feature enabled_features, const position &pos, human::human(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rhuman, pos, gen_room_num, "H"} {} enemy_base{rng, enabled_features, HUMAN, pos, gen_room_num, "H"} {}
const char *human::get_race_name() const { const char *human::get_race_name() const {
return "Human"; return "Human";

View File

@ -7,7 +7,7 @@
leprechaun::leprechaun(RNG *rng, const feature enabled_features, leprechaun::leprechaun(RNG *rng, const feature enabled_features,
const position &pos, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rleprechaun, pos, gen_room_num, "l"}, enemy_base{rng, enabled_features, LEPRECHAUN, pos, gen_room_num, "l"},
gold_cnt{STARTING_GOLD} {} gold_cnt{STARTING_GOLD} {}
const char *leprechaun::get_race_name() const { const char *leprechaun::get_race_name() const {
@ -23,7 +23,7 @@ long_result leprechaun::attack(character *ch) {
} else { } else {
res = ch->get_hit(this, ATK, base_hit_rate); res = ch->get_hit(this, ATK, base_hit_rate);
if (res.res == hit) { if (res.res == HIT) {
res.msg += "l steals " + std::to_string(STEAL_GOLD) + res.msg += "l steals " + std::to_string(STEAL_GOLD) +
" pieces of gold from PC. "; " pieces of gold from PC. ";
static_cast<player_base *>(ch)->add_gold(-STEAL_GOLD); static_cast<player_base *>(ch)->add_gold(-STEAL_GOLD);

View File

@ -6,7 +6,7 @@
merchant::merchant(RNG *rng, const feature enabled_features, merchant::merchant(RNG *rng, const feature enabled_features,
const position &pos, const int gen_room_num): const position &pos, const int gen_room_num):
enemy_base{rng, enabled_features, rmerchant, pos, gen_room_num, "M"} {} enemy_base{rng, enabled_features, MERCHANT, pos, gen_room_num, "M"} {}
const char *merchant::get_race_name() const { const char *merchant::get_race_name() const {
return "Merchant"; return "Merchant";

View File

@ -4,7 +4,7 @@
orc::orc(RNG *rng, const feature enabled_features, const position &pos, orc::orc(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rorc, pos, gen_room_num, "O"} {} enemy_base{rng, enabled_features, ORC, pos, gen_room_num, "O"} {}
const char *orc::get_race_name() const { const char *orc::get_race_name() const {
return "Orc"; return "Orc";

View File

@ -5,7 +5,7 @@
swordsman::swordsman(RNG *rng, const feature enabled_features, swordsman::swordsman(RNG *rng, const feature enabled_features,
const position &pos, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rswordsman, pos, gen_room_num, "S"} {} enemy_base{rng, enabled_features, SWORDSMAN, pos, gen_room_num, "S"} {}
const char *swordsman::get_race_name() const { const char *swordsman::get_race_name() const {
return "Swordsman"; return "Swordsman";

View File

@ -4,7 +4,7 @@
viking::viking(RNG *rng, const feature enabled_features, const position &pos, viking::viking(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rviking, pos, gen_room_num, "V"} {} enemy_base{rng, enabled_features, VIKING, pos, gen_room_num, "V"} {}
const char *viking::get_race_name() const { const char *viking::get_race_name() const {
return "Viking"; return "Viking";
@ -13,15 +13,15 @@ const char *viking::get_race_name() const {
long_result viking::attack(character *ch) { long_result viking::attack(character *ch) {
auto res1 = ch->get_hit(this, ATK, base_hit_rate); auto res1 = ch->get_hit(this, ATK, base_hit_rate);
if (res1.res == result::died) if (res1.res == result::DIED)
return res1; return res1;
auto res2 = ch->get_hit(this, ATK, base_hit_rate); auto res2 = ch->get_hit(this, ATK, base_hit_rate);
if (res1.res == miss && res2.res == miss) if (res1.res == MISS && res2.res == MISS)
return {miss, res1.msg + res2.msg}; return {MISS, res1.msg + res2.msg};
else if (res2.res == died) else if (res2.res == DIED)
return {died, res1.msg + res2.msg}; return {DIED, res1.msg + res2.msg};
else else
return {hit, res1.msg + res2.msg}; return {HIT, res1.msg + res2.msg};
} }

View File

@ -4,7 +4,7 @@
witch::witch(RNG *rng, const feature enabled_features, const position &pos, witch::witch(RNG *rng, const feature enabled_features, const position &pos,
const int gen_room_num): const int gen_room_num):
enemy_base{rng, enabled_features, rwitch, pos, gen_room_num, "Z"} {} enemy_base{rng, enabled_features, WITCH, pos, gen_room_num, "Z"} {}
const char *witch::get_race_name() const { const char *witch::get_race_name() const {
return "Witch"; return "Witch";
@ -13,14 +13,16 @@ const char *witch::get_race_name() const {
long_result witch::attack(character *ch) { long_result witch::attack(character *ch) {
auto res = ch->get_hit(this, ATK, base_hit_rate); auto res = ch->get_hit(this, ATK, base_hit_rate);
if (res.res == hit && rng->trial(POTION_RATE)) { if (res.res == HIT && rng->trial(POTION_RATE)) {
res.msg += "W's potion spilled onto PC. ";
potion_type type = potion_type type =
static_cast<potion_type>(rng->rand_under( static_cast<potion_type>(rng->rand_under(
(enabled_features & FEATURE_EXTRA_STUFF) ? (enabled_features & FEATURE_EXTRA_STUFF) ?
POTION_TYPE_CNT : POTION_TYPE_CNT :
DEFAULT_POTION_TYPE_CNT)); DEFAULT_POTION_TYPE_CNT));
ch->apply_effect(new_potion(type, {0, 0})); auto npotion = new_potion(type, {0, 0});
res.msg += std::string("Z's potion of ") +
npotion->get_name() + " spilled onto PC. ";
ch->apply_effect(std::move(npotion));
} }
return res; return res;

View File

@ -35,7 +35,7 @@ long_result enemy_base::act(level *lvl, character *pc, bool hostile) {
} }
pos = target; pos = target;
return {fine, ""}; return {NOTHING, ""};
} }
int choices_cnt = 0; int choices_cnt = 0;
@ -52,7 +52,7 @@ long_result enemy_base::act(level *lvl, character *pc, bool hostile) {
if (choices_cnt) if (choices_cnt)
pos = choices[rng->rand_under(choices_cnt)]; pos = choices[rng->rand_under(choices_cnt)];
return {fine, ""}; return {NOTHING, ""};
} }
long_result enemy_base::attack(character *ch) { long_result enemy_base::attack(character *ch) {
@ -71,18 +71,18 @@ long_result enemy_base::get_hit(character *ch, const int tATK,
HP -= tmp; HP -= tmp;
if (HP == 0) if (HP == 0)
return {result::hit, return {result::HIT,
"PC deals " + std::to_string(tmp) + "PC deals " + std::to_string(tmp) +
" damage to " + abbrev + " (" + " damage to " + abbrev + " (" +
std::to_string(HP) + " HP). " + std::to_string(HP) + " HP). " +
abbrev + " is slain by PC. "}; abbrev + " is slain by PC. "};
return {result::hit, "PC deals " + return {result::HIT, "PC deals " +
std::to_string(tmp) + " damage to " + abbrev + " (" + std::to_string(tmp) + " damage to " + abbrev + " (" +
std::to_string(HP) + " HP). "}; std::to_string(HP) + " HP). "};
} }
return {miss, "PC tried to hit " + abbrev + " but missed. "}; return {MISS, "PC tried to hit " + abbrev + " but missed. "};
} }
int enemy_base::dies(level *lvl) { int enemy_base::dies(level *lvl) {

View File

@ -82,7 +82,7 @@ character *game::move_enemies() {
continue; continue;
} }
bool hostile = ch->get_race() == rmerchant ? bool hostile = ch->get_race() == MERCHANT ?
hostile_merchants : true; hostile_merchants : true;
auto res = auto res =
ch->act(levels[curr_level].get(), player.get(), hostile); ch->act(levels[curr_level].get(), player.get(), hostile);
@ -107,15 +107,15 @@ game_result game::run() {
} }
switch (res.res) { switch (res.res) {
case result::terminate: case result::TERMINATE:
return {terminated, ""}; return {TERMINATED, ""};
case result::died: case result::DIED:
return {dead, "You died: killed by your own stupidity!"}; return {DEAD, "You died: killed by your own stupidity!"};
case result::go_down: { case result::GO_DOWN: {
if (curr_level == max_level - 1) if (curr_level == max_level - 1)
return {won, "You won! You collected " + return {WON, "You won! You collected " +
std::to_string(player->get_gold()) + std::to_string(player->get_gold()) +
" pieces of gold after " + " pieces of gold after " +
std::to_string(curr_turn + 1) + std::to_string(curr_turn + 1) +
@ -136,9 +136,9 @@ game_result game::run() {
break; break;
} }
case result::go_up: { case result::GO_UP: {
if (curr_level == 0) if (curr_level == 0)
return {escaped, "You escaped the dungeon with " + return {ESCAPED, "You escaped the dungeon with " +
std::to_string(player->get_gold()) + std::to_string(player->get_gold()) +
" pieces of gold after " + " pieces of gold after " +
std::to_string(curr_turn + 1) + std::to_string(curr_turn + 1) +
@ -155,19 +155,19 @@ game_result game::run() {
break; break;
} }
case toggle_the_world: case result::TOGGLE_THE_WORLD:
the_world = !the_world; the_world = !the_world;
player->start_turn(); player->start_turn();
break; break;
case restart_game: case RESTART_GAME:
return {restart, ""}; return {RESTART, ""};
case unknown: case UNKNOWN:
case fine: case NOTHING:
case applied_nothing: case APPLIED_NOTHING:
case inventory: case INVENTORY:
return {in_game, ""}; return {IN_GAME, ""};
default: default:
player->start_turn(); player->start_turn();
@ -179,19 +179,19 @@ game_result game::run() {
player->calc_effects(); player->calc_effects();
if (player->is_dead()) if (player->is_dead())
return {dead, "You died: killed by your own stupidity!"}; return {DEAD, "You died: killed by your own stupidity!"};
auto killer = move_enemies(); auto killer = move_enemies();
if (player->is_dead()) { if (player->is_dead()) {
if (killer == nullptr) if (killer == nullptr)
return {dead, "You died: killed by your own stupidity!"}; return {DEAD, "You died: killed by your own stupidity!"};
return {dead, std::string{"You died: killed by a(n) "} + return {DEAD, std::string{"You died: killed by a(n) "} +
killer->get_race_name()}; killer->get_race_name()};
} }
return {in_game, ""}; return {IN_GAME, ""};
} }
const position STATUS_RACE{0, 25}; const position STATUS_RACE{0, 25};

View File

@ -12,5 +12,5 @@ game_command get_direction(std::string &str) {
if (str == COMMANDS[i]) if (str == COMMANDS[i])
return static_cast<game_command>(i); return static_cast<game_command>(i);
return game_command_panic; return GAME_COMMAND_PANIC;
} }

View File

@ -12,53 +12,53 @@ game_command console_input::get_command() {
in >> cmd; in >> cmd;
if (in.eof()) if (in.eof())
return game_command_terminate; return GAME_COMMAND_TERMINATE;
if (cmd == "q") if (cmd == "q")
return game_command_terminate; return GAME_COMMAND_TERMINATE;
else if (cmd == "f") else if (cmd == "f")
return the_world; return THE_WORLD;
else if (cmd == "r") else if (cmd == "r")
return game_restart; return GAME_RESTART;
else if (cmd == "u" || cmd == "a" || cmd == "T") { else if (cmd == "u" || cmd == "a" || cmd == "T") {
auto cmdtmp = cmd; auto cmdtmp = cmd;
in >> cmd; in >> cmd;
if (in.eof()) if (in.eof())
return game_command_panic; return GAME_COMMAND_PANIC;
auto tmp = get_direction(cmd); auto tmp = get_direction(cmd);
if (cmdtmp == "u") if (cmdtmp == "u")
return static_cast<game_command> return static_cast<game_command>
(tmp + apply_north); (tmp + APPLY_NORTH);
else if (cmdtmp == "a") else if (cmdtmp == "a")
return static_cast<game_command> return static_cast<game_command>
(tmp + attack_north); (tmp + ATTACK_NORTH);
else else
return static_cast<game_command> return static_cast<game_command>
(tmp + throw_north); (tmp + THROW_NORTH);
} else if (cmd == "yes") { } else if (cmd == "yes") {
return game_command::enter; return game_command::ENTER;
} else if (cmd == "i") { } else if (cmd == "i") {
return toggle_inventory; return TOGGLE_INVENTORY;
} else if (cmd == "s") { } else if (cmd == "s") {
return select_shade; return SELECT_SHADE;
} else if (cmd == "d") { } else if (cmd == "d") {
return select_drow; return SELECT_DROW;
} else if (cmd == "v") { } else if (cmd == "v") {
return select_vampire; return SELECT_VAMPIRE;
} else if (cmd == "g") { } else if (cmd == "g") {
return select_goblin; return SELECT_GOBLIN;
} else if (cmd == "t") { } else if (cmd == "t") {
return select_troll; return SELECT_TROLL;
} else { } else {
auto tmp = get_direction(cmd); auto tmp = get_direction(cmd);
if (tmp != game_command_panic) if (tmp != GAME_COMMAND_PANIC)
return static_cast<game_command> return static_cast<game_command>
(tmp + move_north); (tmp + MOVE_NORTH);
} }
return game_command_pass; return GAME_COMMAND_PASS;
} }

View File

@ -10,98 +10,98 @@ 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_WEAT;
case 'j': case 'j':
return game_command::move_south; return game_command::MOVE_SOUTH;
case 'k': case 'k':
return game_command::move_north; return game_command::MOVE_NORTH;
case 'l': case 'l':
return game_command::move_east; return game_command::MOVE_EAST;
case 'y': case 'y':
return game_command::move_northwest; return game_command::MOVE_NORTHWEST;
case 'u': case 'u':
return game_command::move_northeast; return game_command::MOVE_NORTHEAST;
case 'b': case 'b':
return game_command::move_southwest; return game_command::MOVE_SOUTHWEST;
case 'n': case 'n':
return game_command::move_southeast; return game_command::MOVE_SOUTHEAST;
case 'a': case 'a':
tmp = apply_north; tmp = APPLY_NORTH;
break; // wait for another command break; // wait for another command
case '<': case '<':
return game_command::up_stairs; return game_command::UP_STAIRS;
case '>': case '>':
return game_command::down_stairs; return game_command::DOWN_STAIRS;
case 'q': case 'q':
return game_command_terminate; return GAME_COMMAND_TERMINATE;
case 'f': case 'f':
return game_command::the_world; return game_command::THE_WORLD;
case 'r': case 'r':
return game_restart; return GAME_RESTART;
case 'e': case 'e':
return game_command::enter; return game_command::ENTER;
case 'i': case 'i':
return toggle_inventory; return TOGGLE_INVENTORY;
case 't': case 't':
tmp = throw_north; tmp = THROW_NORTH;
break; break;
default: default:
return game_command_pass; return GAME_COMMAND_PASS;
} }
switch (curse->getcmd()) { switch (curse->getcmd()) {
case 'h': case 'h':
return static_cast<game_command> return static_cast<game_command>
(tmp + west); (tmp + WEST);
case 'j': case 'j':
return static_cast<game_command> return static_cast<game_command>
(tmp + south); (tmp + SOUTH);
case 'k': case 'k':
return static_cast<game_command> return static_cast<game_command>
(tmp + north); (tmp + NORTH);
case 'l': case 'l':
return static_cast<game_command> return static_cast<game_command>
(tmp + east); (tmp + EAST);
case 'y': case 'y':
return static_cast<game_command> return static_cast<game_command>
(tmp + northwest); (tmp + NORTHWEST);
case 'u': case 'u':
return static_cast<game_command> return static_cast<game_command>
(tmp + northeast); (tmp + NORTHEAST);
case 'b': case 'b':
return static_cast<game_command> return static_cast<game_command>
(tmp + southwest); (tmp + SOUTHWEST);
case 'n': case 'n':
return static_cast<game_command> return static_cast<game_command>
(tmp + southeast); (tmp + SOUTHEAST);
default: default:
return game_command_panic; return GAME_COMMAND_PANIC;
} }
return game_command::game_command_panic; return game_command::GAME_COMMAND_PANIC;
} }

View File

@ -12,53 +12,53 @@ game_command file_input::get_command() {
in >> cmd; in >> cmd;
if (in.eof()) if (in.eof())
return game_command_terminate; return GAME_COMMAND_TERMINATE;
if (cmd == "q") if (cmd == "q")
return game_command_terminate; return GAME_COMMAND_TERMINATE;
else if (cmd == "f") else if (cmd == "f")
return the_world; return THE_WORLD;
else if (cmd == "r") else if (cmd == "r")
return game_restart; return GAME_RESTART;
else if (cmd == "u" || cmd == "a" || cmd == "T") { else if (cmd == "u" || cmd == "a" || cmd == "T") {
auto cmdtmp = cmd; auto cmdtmp = cmd;
in >> cmd; in >> cmd;
if (in.eof()) if (in.eof())
return game_command_panic; return GAME_COMMAND_PANIC;
auto tmp = get_direction(cmd); auto tmp = get_direction(cmd);
if (cmdtmp == "u") if (cmdtmp == "u")
return static_cast<game_command> return static_cast<game_command>
(tmp + apply_north); (tmp + APPLY_NORTH);
else if (cmdtmp == "a") else if (cmdtmp == "a")
return static_cast<game_command> return static_cast<game_command>
(tmp + attack_north); (tmp + ATTACK_NORTH);
else else
return static_cast<game_command> return static_cast<game_command>
(tmp + throw_north); (tmp + THROW_NORTH);
} else if (cmd == "yes") { } else if (cmd == "yes") {
return game_command::enter; return game_command::ENTER;
} else if (cmd == "i") { } else if (cmd == "i") {
return toggle_inventory; return TOGGLE_INVENTORY;
} else if (cmd == "s") { } else if (cmd == "s") {
return select_shade; return SELECT_SHADE;
} else if (cmd == "d") { } else if (cmd == "d") {
return select_drow; return SELECT_DROW;
} else if (cmd == "v") { } else if (cmd == "v") {
return select_vampire; return SELECT_VAMPIRE;
} else if (cmd == "g") { } else if (cmd == "g") {
return select_goblin; return SELECT_GOBLIN;
} else if (cmd == "t") { } else if (cmd == "t") {
return select_troll; return SELECT_TROLL;
} else { } else {
auto tmp = get_direction(cmd); auto tmp = get_direction(cmd);
if (tmp != game_command_panic) if (tmp != GAME_COMMAND_PANIC)
return static_cast<game_command> return static_cast<game_command>
(tmp + move_north); (tmp + MOVE_NORTH);
} }
return game_command_pass; return GAME_COMMAND_PASS;
} }

View File

@ -28,7 +28,7 @@ int main(int argc, char **argv) {
CC3K game_proc(enabled_features, in.get(), out.get(), rng.get()); CC3K game_proc(enabled_features, in.get(), out.get(), rng.get());
while (1) while (1)
if (game_proc.run() == game_status::terminated) if (game_proc.run() == game_status::TERMINATED)
break; break;
return RETURN_FINE; return RETURN_FINE;

View File

@ -7,8 +7,8 @@ const int EXTRA_CNT = 10;
const int HOR_INCRM = 5; const int HOR_INCRM = 5;
const enum race RACES[EXTRA_CNT] = { const enum race RACES[EXTRA_CNT] = {
rshade, rdrow, rgoblin, rvampire, rtroll, SHADE, DROW, GOBLIN, VAMPIRE, TROLL,
rmonk, rassassin, rmr_goose, rbrawler, rt_800 MONK, ASSASSIN, MR_GOOSE, BRAWLER, RT_800
}; };
const position RACE_POS[EXTRA_CNT] = { const position RACE_POS[EXTRA_CNT] = {
@ -81,53 +81,53 @@ int menu::run(input *in) {
auto cmd = in->get_command(); auto cmd = in->get_command();
switch (cmd) { switch (cmd) {
case game_command::enter: case game_command::ENTER:
return RACES[curr]; return RACES[curr];
case move_north: { case MOVE_NORTH: {
if (curr > 0) if (curr > 0)
--curr; --curr;
break; break;
} }
case move_south: { case MOVE_SOUTH: {
if (curr < limit - 1) if (curr < limit - 1)
++curr; ++curr;
break; break;
} }
case move_east: { case MOVE_EAST: {
if (curr + HOR_INCRM < limit) if (curr + HOR_INCRM < limit)
curr += HOR_INCRM; curr += HOR_INCRM;
break; break;
} }
case move_west: { case MOVE_WEAT: {
if (curr - HOR_INCRM >= 0) if (curr - HOR_INCRM >= 0)
curr -= HOR_INCRM; curr -= HOR_INCRM;
break; break;
} }
case select_shade: case SELECT_SHADE:
return rshade; return SHADE;
case select_drow: case SELECT_DROW:
return rdrow; return DROW;
case select_goblin: case SELECT_GOBLIN:
return rgoblin; return GOBLIN;
case select_troll: case SELECT_TROLL:
return rtroll; return TROLL;
case select_vampire: case SELECT_VAMPIRE:
return rvampire; return VAMPIRE;
case game_command_terminate: case GAME_COMMAND_TERMINATE:
return -2; return -2;
default: default:

View File

@ -17,34 +17,34 @@ std::unique_ptr<player_base> init_player(RNG *rng,
using std::make_unique; using std::make_unique;
switch (r) { switch (r) {
case rgoblin: case GOBLIN:
return make_unique<goblin>(rng, enabled_features); return make_unique<goblin>(rng, enabled_features);
case rdrow: case DROW:
return make_unique<drow>(rng, enabled_features); return make_unique<drow>(rng, enabled_features);
case rshade: case SHADE:
return make_unique<shade>(rng, enabled_features); return make_unique<shade>(rng, enabled_features);
case rtroll: case TROLL:
return make_unique<troll>(rng, enabled_features); return make_unique<troll>(rng, enabled_features);
case rvampire: case VAMPIRE:
return make_unique<vampire>(rng, enabled_features); return make_unique<vampire>(rng, enabled_features);
case rt_800: case RT_800:
return make_unique<t_800>(rng, enabled_features); return make_unique<t_800>(rng, enabled_features);
case rassassin: case ASSASSIN:
return make_unique<assassin>(rng, enabled_features); return make_unique<assassin>(rng, enabled_features);
case rmonk: case MONK:
return make_unique<monk>(rng, enabled_features); return make_unique<monk>(rng, enabled_features);
case rbrawler: case BRAWLER:
return make_unique<brawler>(rng, enabled_features); return make_unique<brawler>(rng, enabled_features);
case rmr_goose: case MR_GOOSE:
return make_unique<mr_goose>(rng, enabled_features); return make_unique<mr_goose>(rng, enabled_features);
default: default:

View File

@ -38,7 +38,7 @@ int player_base::get_HP() const {
long_result player_base::apply(std::unique_ptr<potion> p) { long_result player_base::apply(std::unique_ptr<potion> p) {
if (p == nullptr) if (p == nullptr)
return {result::applied_nothing, return {result::APPLIED_NOTHING,
"PC tried to breathe the magic in the air. "}; "PC tried to breathe the magic in the air. "};
std::string name = p->get_name(); std::string name = p->get_name();
@ -47,17 +47,17 @@ long_result player_base::apply(std::unique_ptr<potion> p) {
apply_effect(std::move(p)); apply_effect(std::move(p));
if (race == rt_800) if (race == RT_800)
return {result::applied, return {result::APPLIED,
"PC gets rusty joints (-50 HP). "}; "PC gets rusty joints (-50 HP). "};
return {result::applied, return {result::APPLIED,
"PC applied potion of " + name + ". "}; "PC applied potion of " + name + ". "};
} }
long_result player_base::attack(character *ch) { long_result player_base::attack(character *ch) {
if (ch == nullptr) if (ch == nullptr)
return {result::fine, return {result::NOTHING,
"PC tried to attack thin air. "}; "PC tried to attack thin air. "};
return ch->get_hit(this, ATK, base_hit_rate); return ch->get_hit(this, ATK, base_hit_rate);
@ -70,7 +70,7 @@ long_result player_base::move(level *lvl,
if (lvl->is_available(p, true)) { if (lvl->is_available(p, true)) {
pos = p; pos = p;
return {result::moved, ""}; return {result::MOVED, ""};
} else if ((tmp = get_enemy_at(p, lvl->get_elist())) != nullptr) { } else if ((tmp = get_enemy_at(p, lvl->get_elist())) != nullptr) {
auto res = attack(static_cast<character *>(tmp)); auto res = attack(static_cast<character *>(tmp));
@ -90,15 +90,15 @@ long_result player_base::move(level *lvl,
} }
} else if (lvl->get_up_stairs() == p && } else if (lvl->get_up_stairs() == p &&
enabled_features & FEATURE_REVISIT) { enabled_features & FEATURE_REVISIT) {
return {result::go_up, "PC went up the stairs. "}; return {result::GO_UP, "PC went up the stairs. "};
} else if (lvl->get_down_stairs() == p) { } else if (lvl->get_down_stairs() == p) {
return {result::go_down, "PC went down the stairs. "}; return {result::GO_DOWN, "PC went down the stairs. "};
} else if (lvl->is_available(p, true)) { } else if (lvl->is_available(p, true)) {
pos = p; pos = p;
return {result::moved, ""}; return {result::MOVED, ""};
} }
return {result::fine, "PC tried to move into non-existent space. "}; return {result::NOTHING, "PC tried to move into non-existent space. "};
} }
long_result player_base::get_hit(character *ch, const int tATK, long_result player_base::get_hit(character *ch, const int tATK,
@ -109,18 +109,18 @@ long_result player_base::get_hit(character *ch, const int tATK,
HP -= tmp; HP -= tmp;
if (HP == 0) if (HP == 0)
return {result::died, return {result::DIED,
ch->get_abbrev() + " deals " + ch->get_abbrev() + " deals " +
std::to_string(tmp) + std::to_string(tmp) +
" damage to PC. PC is slain by " + " damage to PC. PC is slain by " +
ch->get_abbrev() + ". "}; ch->get_abbrev() + ". "};
return {result::hit, ch->get_abbrev() + " deals " + return {result::HIT, ch->get_abbrev() + " deals " +
std::to_string(tmp) + std::to_string(tmp) +
" damage to PC. "}; " damage to PC. "};
} }
return {result::miss, ch->get_abbrev() + " tried to hit PC but missed. "}; return {result::MISS, ch->get_abbrev() + " tried to hit PC but missed. "};
} }
void player_base::add_gold(int amount) { void player_base::add_gold(int amount) {
@ -130,7 +130,7 @@ void player_base::add_gold(int amount) {
long_result player_base::throw_potion(level *lvl, std::unique_ptr<potion> p, long_result player_base::throw_potion(level *lvl, std::unique_ptr<potion> p,
direction dir) { direction dir) {
if (p == nullptr) if (p == nullptr)
return {fine, "PC tried to throw a vial of air. "}; return {NOTHING, "PC tried to throw a vial of air. "};
position tmp{pos}; position tmp{pos};
@ -139,23 +139,23 @@ long_result player_base::throw_potion(level *lvl, std::unique_ptr<potion> p,
size_t flag = lvl->what_is_at(tmp); size_t flag = lvl->what_is_at(tmp);
if (flag & WHAT_WALL) if (flag & WHAT_WALL)
return {thrown, "The potion shattered against a wall. "}; return {THROWN, "The potion shattered against a wall. "};
else if (flag & WHAT_ENEMY) { else if (flag & WHAT_ENEMY) {
character *ch = lvl->get_elist()[flag ^ WHAT_ENEMY]; character *ch = lvl->get_elist()[flag ^ WHAT_ENEMY];
ch->apply_effect(std::move(p)); ch->apply_effect(std::move(p));
return {thrown, "The potion's contents spilled on " + return {THROWN, "The potion's contents spilled on " +
ch->get_abbrev() + ". "}; ch->get_abbrev() + ". "};
} }
} }
return {thrown, "The potion shattered against the floor. "}; return {THROWN, "The potion shattered against the floor. "};
} }
long_result player_base::interpret_command(level *lvl, game_command cmd) { long_result player_base::interpret_command(level *lvl, game_command cmd) {
if (inv.enabled) { if (inv.enabled) {
if (cmd == toggle_inventory || cmd == game_command_terminate) { if (cmd == TOGGLE_INVENTORY || cmd == GAME_COMMAND_TERMINATE) {
inv.enabled = false; inv.enabled = false;
return {result::inventory, ""}; return {result::INVENTORY, ""};
} else { } else {
auto res = inv.run(cmd, enabled_features); auto res = inv.run(cmd, enabled_features);
@ -164,10 +164,10 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) {
inv.enabled = false; inv.enabled = false;
return apply(std::move(res.first)); return apply(std::move(res.first));
} else if (res.first == nullptr) { } else if (res.first == nullptr) {
return {result::inventory, ""}; return {result::INVENTORY, ""};
} else if (res.second == DIRECTION_CNT) { } else if (res.second == DIRECTION_CNT) {
inv.enabled = false; inv.enabled = false;
return {result::thrown, return {result::THROWN,
"PC tried to throw a vial of air. "}; "PC tried to throw a vial of air. "};
} else { } else {
inv.enabled = false; inv.enabled = false;
@ -177,10 +177,10 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) {
} }
} }
if (cmd == game_command_terminate) { if (cmd == GAME_COMMAND_TERMINATE) {
return {result::terminate, ""}; return {result::TERMINATE, ""};
} else if (cmd >= move_north && cmd <= move_southwest) { } else if (cmd >= MOVE_NORTH && cmd <= MOVE_SOUTHWEST) {
auto res = move(lvl, pos + MOVE[cmd - move_north]); auto res = move(lvl, pos + MOVE[cmd - MOVE_NORTH]);
gold g{{0, 0}, 0}; gold g{{0, 0}, 0};
int gold_tmp = 0; int gold_tmp = 0;
@ -209,16 +209,16 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) {
return res; return res;
} else if (cmd >= apply_north && cmd <= apply_southwest) { } else if (cmd >= APPLY_NORTH && cmd <= APPLY_SOUTHWEST) {
size_t idx = get_potion_at(pos + MOVE[cmd - apply_north], size_t idx = get_potion_at(pos + MOVE[cmd - APPLY_NORTH],
lvl->get_plist()); lvl->get_plist());
auto res = apply(lvl->detach_potion(idx)); auto res = apply(lvl->detach_potion(idx));
return res; return res;
} else if (cmd == apply_panic) { } else if (cmd == APPLY_PANIC) {
return {result::fine, return {result::NOTHING,
"PC tried to use in some non-existent direction. "}; "PC tried to use in some non-existent direction. "};
} else if (cmd >= attack_north && cmd <= attack_southwest) { } else if (cmd >= ATTACK_NORTH && cmd <= ATTACK_SOUTHWEST) {
enemy_base *tmp = get_enemy_at(pos + MOVE[cmd - attack_north], enemy_base *tmp = get_enemy_at(pos + MOVE[cmd - ATTACK_NORTH],
lvl->get_elist()); lvl->get_elist());
auto res = attack(static_cast<character *>(tmp)); auto res = attack(static_cast<character *>(tmp));
@ -236,32 +236,32 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) {
} }
return res; return res;
} else if (cmd == up_stairs) { } else if (cmd == UP_STAIRS) {
if (lvl->get_up_stairs() == pos && if (lvl->get_up_stairs() == pos &&
enabled_features & FEATURE_REVISIT) enabled_features & FEATURE_REVISIT)
return {go_up, "PC went up the stairs. "}; return {GO_UP, "PC went up the stairs. "};
return {result::fine, return {result::NOTHING,
"PC tried to fly through the ceiling. "}; "PC tried to fly through the ceiling. "};
} else if (cmd == down_stairs) { } else if (cmd == DOWN_STAIRS) {
if (lvl->get_down_stairs() == pos) if (lvl->get_down_stairs() == pos)
return {go_down, "PC went down the stairs. "}; return {GO_DOWN, "PC went down the stairs. "};
return {result::fine, return {result::NOTHING,
"PC tried to dig through the floor. "}; "PC tried to dig through the floor. "};
} else if (cmd == the_world) { } else if (cmd == THE_WORLD) {
return{toggle_the_world, "PC toggled Stand: The World! "}; return{TOGGLE_THE_WORLD, "PC toggled Stand: The World! "};
} else if (cmd == game_restart) { } else if (cmd == GAME_RESTART) {
return {restart_game, ""}; return {RESTART_GAME, ""};
} else if (cmd == game_command_pass) { } else if (cmd == GAME_COMMAND_PASS) {
return {result::fine, ""}; return {result::NOTHING, ""};
} else if (cmd == toggle_inventory && } else if (cmd == TOGGLE_INVENTORY &&
enabled_features & FEATURE_INVENTORY) { enabled_features & FEATURE_INVENTORY) {
inv.start(); inv.start();
return {result::inventory, ""}; return {result::INVENTORY, ""};
} }
return {unknown, "PC tried to produce some undefined behaviour. "}; return {UNKNOWN, "PC tried to produce some undefined behaviour. "};
} }
void player_base::inventory::start() { void player_base::inventory::start() {
@ -271,17 +271,17 @@ void player_base::inventory::start() {
std::pair<std::unique_ptr<potion>, int> player_base::inventory::run( std::pair<std::unique_ptr<potion>, int> player_base::inventory::run(
game_command cmd, const feature enabled_features) { game_command cmd, const feature enabled_features) {
if (cmd == move_north) { if (cmd == MOVE_NORTH) {
if (curr != 0) if (curr != 0)
--curr; --curr;
return {nullptr, 0}; return {nullptr, 0};
} else if (cmd == move_south) { } else if (cmd == MOVE_SOUTH) {
if (curr < owns.size() - 1) if (curr < owns.size() - 1)
++curr; ++curr;
return {nullptr, 0}; return {nullptr, 0};
} else if (cmd == enter) { } else if (cmd == ENTER) {
if (owns.size()) { if (owns.size()) {
std::unique_ptr<potion> tmp = std::move(owns[curr]); std::unique_ptr<potion> tmp = std::move(owns[curr]);
owns.erase(owns.begin() + curr); owns.erase(owns.begin() + curr);
@ -289,13 +289,13 @@ std::pair<std::unique_ptr<potion>, int> player_base::inventory::run(
} }
return {nullptr, -1}; return {nullptr, -1};
} else if (cmd >= throw_north && cmd <= throw_southwest && } else if (cmd >= THROW_NORTH && cmd <= THROW_SOUTHWEST &&
enabled_features & FEATURE_THROW) { enabled_features & FEATURE_THROW) {
if (owns.size()) { if (owns.size()) {
std::unique_ptr<potion> tmp = std::move(owns[curr]); std::unique_ptr<potion> tmp = std::move(owns[curr]);
owns.erase(owns.begin() + curr); owns.erase(owns.begin() + curr);
return {std::move(tmp), return {std::move(tmp),
static_cast<direction>(cmd - throw_north)}; static_cast<direction>(cmd - THROW_NORTH)};
} }
return {nullptr, DIRECTION_CNT}; return {nullptr, DIRECTION_CNT};

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
assassin::assassin(RNG *rng, const feature enabled_features): assassin::assassin(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rassassin} {}; player_base{rng, enabled_features, race::ASSASSIN} {};
const char *assassin::get_race_name() const { const char *assassin::get_race_name() const {
return "Assassin"; return "Assassin";
@ -11,14 +11,14 @@ const char *assassin::get_race_name() const {
long_result assassin::attack(character *ch) { long_result assassin::attack(character *ch) {
if (ch == nullptr) if (ch == nullptr)
return {result::fine, return {result::NOTHING,
"PC tried to assassinate thin air. "}; "PC tried to assassinate thin air. "};
auto res = ch->get_hit(this, ATK, base_hit_rate); auto res = ch->get_hit(this, ATK, base_hit_rate);
if (res.res == hit && rng->trial(INSTAKILL_RATE)) { if (res.res == HIT && rng->trial(INSTAKILL_RATE)) {
ch->get_hit(this, INF, INF_HIT_RATE); ch->get_hit(this, INF, INF_HIT_RATE);
return {hit, "PC assassinated " + ch->get_abbrev() + ". "}; return {HIT, "PC assassinated " + ch->get_abbrev() + ". "};
} }
return res; return res;

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
brawler::brawler(RNG *rng, const feature enabled_features): brawler::brawler(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rbrawler} {}; player_base{rng, enabled_features, race::BRAWLER} {};
const char *brawler::get_race_name() const { const char *brawler::get_race_name() const {
return "Tavern Brawler"; return "Tavern Brawler";
@ -11,7 +11,7 @@ const char *brawler::get_race_name() const {
long_result brawler::attack(character *ch) { long_result brawler::attack(character *ch) {
if (ch == nullptr) if (ch == nullptr)
return {result::fine, return {result::NOTHING,
"PC tried to attack thin air. "}; "PC tried to attack thin air. "};
// hits twice // hits twice
@ -26,5 +26,5 @@ long_result brawler::attack(character *ch) {
return {res3.res, res1.msg + res2.msg + res3.msg}; return {res3.res, res1.msg + res2.msg + res3.msg};
} }
return {fine, ""}; return {NOTHING, ""};
} }

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
drow::drow(RNG *rng, const feature enabled_features): drow::drow(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rdrow} {} player_base{rng, enabled_features, race::DROW} {}
const char *drow::get_race_name() const { const char *drow::get_race_name() const {
return "Drow"; return "Drow";

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
goblin::goblin(RNG *rng, const feature enabled_features): goblin::goblin(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rgoblin} {}; player_base{rng, enabled_features, race::GOBLIN} {};
const char *goblin::get_race_name() const { const char *goblin::get_race_name() const {
return "Goblin"; return "Goblin";
@ -11,7 +11,7 @@ const char *goblin::get_race_name() const {
long_result goblin::attack(character *ch) { long_result goblin::attack(character *ch) {
if (ch == nullptr) if (ch == nullptr)
return {result::fine, return {result::NOTHING,
"PC tried to attack thin air. "}; "PC tried to attack thin air. "};
auto res = ch->get_hit(this, ATK, base_hit_rate); auto res = ch->get_hit(this, ATK, base_hit_rate);
@ -30,7 +30,7 @@ long_result goblin::get_hit(character *ch, const int tATK,
int tmp = calc_dmg(tATK, DEF); int tmp = calc_dmg(tATK, DEF);
std::string msg = ""; std::string msg = "";
if (ch->get_race() == rorc) { if (ch->get_race() == ORC) {
msg += "PC feels scared. "; msg += "PC feels scared. ";
tmp *= ORC_DMG_MUL; tmp *= ORC_DMG_MUL;
} }
@ -42,12 +42,12 @@ long_result goblin::get_hit(character *ch, const int tATK,
" damage to PC. "; " damage to PC. ";
if (HP == 0) if (HP == 0)
return {result::died, return {result::DIED,
msg + "PC is slain by " + msg + "PC is slain by " +
ch->get_abbrev() + ". "}; ch->get_abbrev() + ". "};
return {result::hit, msg}; return {result::HIT, msg};
} }
return {result::miss, ch->get_abbrev() + " tried to hit PC but missed. "}; return {result::MISS, ch->get_abbrev() + " tried to hit PC but missed. "};
} }

View File

@ -3,15 +3,15 @@
#include "../constants.h" #include "../constants.h"
monk::monk(RNG *rng, const feature enabled_features): monk::monk(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, rmonk} {} player_base{rng, enabled_features, MONK} {}
const char *monk::get_race_name() const { const char *monk::get_race_name() const {
return "Monk"; return "Monk";
} }
void monk::start_turn() { void monk::start_turn() {
ATK = STARTING_ATK[rmonk]; ATK = STARTING_ATK[MONK];
DEF = STARTING_DEF[rmonk]; DEF = STARTING_DEF[MONK];
base_hit_rate = {1, 1}; base_hit_rate = {1, 1};
HP = HP + GAIN_HP < MAX_HP[rmonk] ? HP + GAIN_HP : MAX_HP[rmonk]; HP = HP + GAIN_HP < MAX_HP[MONK] ? HP + GAIN_HP : MAX_HP[MONK];
} }

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
mr_goose::mr_goose(RNG *rng, const feature enabled_features): mr_goose::mr_goose(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rmr_goose} { player_base{rng, enabled_features, race::MR_GOOSE} {
// sets all bits to 1 // sets all bits to 1
known_potions = (1 << POTION_TYPE_CNT) - 1; known_potions = (1 << POTION_TYPE_CNT) - 1;
} }

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
shade::shade(RNG *rng, const feature enabled_features): shade::shade(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rshade} {} player_base{rng, enabled_features, race::SHADE} {}
const char *shade::get_race_name() const { const char *shade::get_race_name() const {
return "Shade"; return "Shade";

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
t_800::t_800(RNG *rng, const feature enabled_features): t_800::t_800(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rt_800} {} player_base{rng, enabled_features, race::RT_800} {}
const char *t_800::get_race_name() const { const char *t_800::get_race_name() const {
return "T-800"; return "T-800";

View File

@ -3,15 +3,15 @@
#include "../constants.h" #include "../constants.h"
troll::troll(RNG *rng, const feature enabled_features): troll::troll(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, rtroll} {} player_base{rng, enabled_features, TROLL} {}
const char *troll::get_race_name() const { const char *troll::get_race_name() const {
return "Troll"; return "Troll";
} }
void troll::start_turn() { void troll::start_turn() {
ATK = STARTING_ATK[rtroll]; ATK = STARTING_ATK[TROLL];
DEF = STARTING_DEF[rtroll]; DEF = STARTING_DEF[TROLL];
base_hit_rate = {1, 1}; base_hit_rate = {1, 1};
HP = HP + GAIN_HP < MAX_HP[rtroll] ? HP + GAIN_HP : MAX_HP[rtroll]; HP = HP + GAIN_HP < MAX_HP[TROLL] ? HP + GAIN_HP : MAX_HP[TROLL];
} }

View File

@ -3,7 +3,7 @@
#include "../constants.h" #include "../constants.h"
vampire::vampire(RNG *rng, const feature enabled_features): vampire::vampire(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rvampire} {}; player_base{rng, enabled_features, race::VAMPIRE} {};
const char *vampire::get_race_name() const { const char *vampire::get_race_name() const {
return "Vampire"; return "Vampire";
@ -11,23 +11,23 @@ const char *vampire::get_race_name() const {
long_result vampire::attack(character *ch) { long_result vampire::attack(character *ch) {
if (ch == nullptr) if (ch == nullptr)
return {result::fine, return {result::NOTHING,
"PC tried to drain thin air. "}; "PC tried to drain thin air. "};
auto res = ch->get_hit(this, ATK, base_hit_rate); auto res = ch->get_hit(this, ATK, base_hit_rate);
if (res.res == miss) if (res.res == MISS)
return {miss, res.msg + "PC is unhappy. "}; return {MISS, res.msg + "PC is unhappy. "};
if (ch->get_race() == rdwarf) { if (ch->get_race() == DWARF) {
HP -= GAIN_HP; HP -= GAIN_HP;
if (is_dead()) if (is_dead())
return {died, ""}; return {DIED, ""};
return {hit, res.msg + "PC accidentally drained themselves. "}; return {HIT, res.msg + "PC accidentally drained themselves. "};
} }
HP += GAIN_HP; HP += GAIN_HP;
return {hit, res.msg + "PC is happy. "}; return {HIT, res.msg + "PC is happy. "};
} }

View File

@ -18,47 +18,47 @@
std::unique_ptr<potion> new_potion(potion_type type, const position &pos) { std::unique_ptr<potion> new_potion(potion_type type, const position &pos) {
switch (type) { switch (type) {
case restore_health: case RESTORE_HEALTH:
return std::make_unique<class restore_health>(pos); return std::make_unique<restore_health>(pos);
case boost_atk: case BOOST_ATK:
return std::make_unique<class boost_atk>(pos); return std::make_unique<boost_atk>(pos);
case boost_def: case BOOST_DEF:
return std::make_unique<class boost_def>(pos); return std::make_unique<boost_def>(pos);
case poison_health: case POISON_HEALTH:
return std::make_unique<class poison_health>(pos); return std::make_unique<poison_health>(pos);
case wound_atk: case WOUND_ATK:
return std::make_unique<class wound_atk>(pos); return std::make_unique<wound_atk>(pos);
case wound_def: case WOUND_DEF:
return std::make_unique<class wound_def>(pos); return std::make_unique<wound_def>(pos);
case continuous_restoration: case CONTINUOUS_RESTORATION:
return std::make_unique<class continuous_restoration>(pos); return std::make_unique<continuous_restoration>(pos);
case savage_strike: case SAVAGE_STRIKE:
return std::make_unique<class savage_strike>(pos); return std::make_unique<savage_strike>(pos);
case echoing_resilience: case ECHOING_RESIL:
return std::make_unique<class echoing_resilience>(pos); return std::make_unique<echoing_resilience>(pos);
case tempest_tantrum: case TEMPEST_TANTRUM:
return std::make_unique<class tempest_tantrum>(pos); return std::make_unique<tempest_tantrum>(pos);
case bezerk_brew: case BEZERK_BREW:
return std::make_unique<class bezerk_brew>(pos); return std::make_unique<bezerk_brew>(pos);
case borrow_life: case BORROW_LIFE:
return std::make_unique<class borrow_life>(pos); return std::make_unique<borrow_life>(pos);
case fine_booze: case FINE_BOOZE:
return std::make_unique<class fine_booze>(pos); return std::make_unique<fine_booze>(pos);
case ironclad_ward: case IRONCLAD_WARD:
return std::make_unique<class ironclad_ward>(pos); return std::make_unique<ironclad_ward>(pos);
default: default:
break; break;

View File

@ -4,13 +4,13 @@
#include "../constants.h" #include "../constants.h"
bezerk_brew::bezerk_brew(const position &pos): bezerk_brew::bezerk_brew(const position &pos):
potion{potion_type::bezerk_brew, DURATION, pos} {} potion{potion_type::BEZERK_BREW, DURATION, pos} {}
void bezerk_brew::apply(const enum race &race, int &HP, int &ATK, void bezerk_brew::apply(const enum race &race, int &HP, int &ATK,
int &DEF, fraction &base_hit_rate) { int &DEF, fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
ATK *= ATK_MUL * (race == rdrow ? DROW_POTION_MUL : 1); ATK *= ATK_MUL * (race == DROW ? DROW_POTION_MUL : 1);
DEF *= DEF_MUL * (race == rdrow ? DROW_POTION_MUL : 1); DEF *= DEF_MUL * (race == DROW ? DROW_POTION_MUL : 1);
--remaining_duration; --remaining_duration;
} }
} }

View File

@ -6,14 +6,14 @@
boost_atk::boost_atk(const position &pos): boost_atk::boost_atk(const position &pos):
potion{potion_type::boost_atk, -1, pos} {} potion{potion_type::BOOST_ATK, -1, pos} {}
void boost_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF, void boost_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) { fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = BOOST_ATK; int tmp = BOOST_ATK;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
ATK += tmp; ATK += tmp;

View File

@ -5,14 +5,14 @@
boost_def::boost_def(const position &pos): boost_def::boost_def(const position &pos):
potion{potion_type::boost_def, -1, pos} {} potion{potion_type::BOOST_DEF, -1, pos} {}
void boost_def::apply(const enum race &race, int &HP, int &ATK, int &DEF, void boost_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) { fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = BOOST_DEF; int tmp = BOOST_DEF;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
DEF += tmp; DEF += tmp;

View File

@ -4,18 +4,18 @@
#include "../constants.h" #include "../constants.h"
borrow_life::borrow_life(const position &pos): borrow_life::borrow_life(const position &pos):
potion{potion_type::borrow_life, DURATION, pos} {} potion{potion_type::BORROW_LIFE, DURATION, pos} {}
void borrow_life::apply(const enum race &race, int &HP, int &ATK, void borrow_life::apply(const enum race &race, int &HP, int &ATK,
int &DEF, fraction &base_hit_rate) { int &DEF, fraction &base_hit_rate) {
if (remaining_duration == DURATION) if (remaining_duration == DURATION)
HP += GIVE_HP * (race == rdrow ? DROW_POTION_MUL : 1); HP += GIVE_HP * (race == DROW ? DROW_POTION_MUL : 1);
if (remaining_duration != 0) if (remaining_duration != 0)
--remaining_duration; --remaining_duration;
if (remaining_duration == 0) { if (remaining_duration == 0) {
HP -= LOSE_HP * (race == rdrow ? DROW_POTION_MUL : 1); HP -= LOSE_HP * (race == DROW ? DROW_POTION_MUL : 1);
HP = HP < 0 ? 0 : HP; HP = HP < 0 ? 0 : HP;
} }
} }

View File

@ -4,14 +4,14 @@
#include "../constants.h" #include "../constants.h"
continuous_restoration::continuous_restoration(const position &pos): continuous_restoration::continuous_restoration(const position &pos):
potion{potion_type::continuous_restoration, DURATION, pos} {} potion{potion_type::CONTINUOUS_RESTORATION, DURATION, pos} {}
void continuous_restoration::apply(const enum race &race, int &HP, int &ATK, void continuous_restoration::apply(const enum race &race, int &HP, int &ATK,
int &DEF, fraction &base_hit_rate) { int &DEF, fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = GAIN_HEALTH; int tmp = GAIN_HEALTH;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
HP = std::min(HP + tmp, MAX_HP[race]); HP = std::min(HP + tmp, MAX_HP[race]);

View File

@ -4,16 +4,16 @@
#include "../constants.h" #include "../constants.h"
echoing_resilience::echoing_resilience(const position &pos): echoing_resilience::echoing_resilience(const position &pos):
potion{potion_type::echoing_resilience, DURATION, pos} {} potion{potion_type::ECHOING_RESIL, DURATION, pos} {}
void echoing_resilience::apply(const enum race &race, int &HP, int &ATK, void echoing_resilience::apply(const enum race &race, int &HP, int &ATK,
int &DEF, fraction &base_hit_rate) { int &DEF, fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = GAIN_HEALTH * (race == rdrow ? DROW_POTION_MUL : 1); int tmp = GAIN_HEALTH * (race == DROW ? DROW_POTION_MUL : 1);
HP = std::min(HP + tmp, MAX_HP[race]); HP = std::min(HP + tmp, MAX_HP[race]);
ATK -= LOSE_ATK * (race == rdrow ? DROW_POTION_MUL : 1); ATK -= LOSE_ATK * (race == DROW ? DROW_POTION_MUL : 1);
DEF -= LOSE_DEF * (race == rdrow ? DROW_POTION_MUL : 1); DEF -= LOSE_DEF * (race == DROW ? DROW_POTION_MUL : 1);
ATK = ATK < 0 ? 0 : ATK; ATK = ATK < 0 ? 0 : ATK;
DEF = DEF < 0 ? 0 : DEF; DEF = DEF < 0 ? 0 : DEF;

View File

@ -4,19 +4,19 @@
#include "../constants.h" #include "../constants.h"
fine_booze::fine_booze(const position &pos): fine_booze::fine_booze(const position &pos):
potion{potion_type::fine_booze, DURATION, pos} {} potion{potion_type::FINE_BOOZE, DURATION, pos} {}
void fine_booze::apply(const enum race &race, int &HP, int &ATK, void fine_booze::apply(const enum race &race, int &HP, int &ATK,
int &DEF, fraction &base_hit_rate) { int &DEF, fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = GAIN_HP; int tmp = GAIN_HP;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
HP = std::min(HP + tmp, MAX_HP[race]); HP = std::min(HP + tmp, MAX_HP[race]);
if (race == rbrawler) if (race == BRAWLER)
base_hit_rate = HR_TB; base_hit_rate = HR_TB;
else else
base_hit_rate *= HR_MUL; base_hit_rate *= HR_MUL;

View File

@ -4,13 +4,13 @@
#include "../constants.h" #include "../constants.h"
ironclad_ward::ironclad_ward(const position &pos): ironclad_ward::ironclad_ward(const position &pos):
potion{potion_type::ironclad_ward, DURATION, pos} {} potion{potion_type::IRONCLAD_WARD, DURATION, pos} {}
void ironclad_ward::apply(const enum race &race, int &HP, int &ATK, void ironclad_ward::apply(const enum race &race, int &HP, int &ATK,
int &DEF, fraction &base_hit_rate) { int &DEF, fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
ATK *= ATK_MUL * (race == rdrow ? DROW_POTION_MUL : 1); ATK *= ATK_MUL * (race == DROW ? DROW_POTION_MUL : 1);
DEF *= DEF_MUL * (race == rdrow ? DROW_POTION_MUL : 1); DEF *= DEF_MUL * (race == DROW ? DROW_POTION_MUL : 1);
base_hit_rate *= HR_MUL; base_hit_rate *= HR_MUL;
--remaining_duration; --remaining_duration;
} }

View File

@ -4,14 +4,14 @@
#include "../constants.h" #include "../constants.h"
poison_health::poison_health(const position &pos): poison_health::poison_health(const position &pos):
potion{potion_type::poison_health, 1, pos} {} potion{potion_type::POISON_HEALTH, 1, pos} {}
void poison_health::apply(const enum race &race, int &HP, int &ATK, int &DEF, void poison_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) { fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = LOSE_HEALTH; int tmp = LOSE_HEALTH;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
HP = std::max(HP - tmp, 0); HP = std::max(HP - tmp, 0);

View File

@ -4,14 +4,14 @@
#include "../constants.h" #include "../constants.h"
restore_health::restore_health(const position &pos): restore_health::restore_health(const position &pos):
potion{potion_type::restore_health, 1, pos} {} potion{potion_type::RESTORE_HEALTH, 1, pos} {}
void restore_health::apply(const enum race &race, int &HP, int &ATK, int &DEF, void restore_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) { fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = GAIN_HEALTH; int tmp = GAIN_HEALTH;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
HP = std::min(HP + tmp, MAX_HP[race]); HP = std::min(HP + tmp, MAX_HP[race]);

View File

@ -4,12 +4,12 @@
#include "../constants.h" #include "../constants.h"
savage_strike::savage_strike(const position &pos): savage_strike::savage_strike(const position &pos):
potion{potion_type::savage_strike, DURATION, pos} {} potion{potion_type::SAVAGE_STRIKE, DURATION, pos} {}
void savage_strike::apply(const enum race &race, int &HP, int &ATK, int &DEF, void savage_strike::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) { fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
ATK *= ATK_MUL * (race == rdrow ? DROW_POTION_MUL : 1); ATK *= ATK_MUL * (race == DROW ? DROW_POTION_MUL : 1);
base_hit_rate *= HR_MUL; base_hit_rate *= HR_MUL;
--remaining_duration; --remaining_duration;
} }

View File

@ -4,17 +4,17 @@
#include "../constants.h" #include "../constants.h"
tempest_tantrum::tempest_tantrum(const position &pos): tempest_tantrum::tempest_tantrum(const position &pos):
potion{potion_type::tempest_tantrum, DURATION, pos} {} potion{potion_type::TEMPEST_TANTRUM, DURATION, pos} {}
void tempest_tantrum::apply(const enum race &race, int &HP, int &ATK, void tempest_tantrum::apply(const enum race &race, int &HP, int &ATK,
int &DEF, fraction &base_hit_rate) { int &DEF, fraction &base_hit_rate) {
if (remaining_duration == DURATION) if (remaining_duration == DURATION)
HP -= HP_RD_PERCENTAGE * HP * HP -= HP_RD_PERCENTAGE * HP *
(race == rdrow ? DROW_POTION_MUL : 1); (race == DROW ? DROW_POTION_MUL : 1);
if (remaining_duration != 0) { if (remaining_duration != 0) {
ATK *= ATK_MUL * (race == rdrow ? DROW_POTION_MUL : 1); ATK *= ATK_MUL * (race == DROW ? DROW_POTION_MUL : 1);
DEF *= DEF_MUL * (race == rdrow ? DROW_POTION_MUL : 1); DEF *= DEF_MUL * (race == DROW ? DROW_POTION_MUL : 1);
--remaining_duration; --remaining_duration;
} }
} }

View File

@ -4,14 +4,14 @@
#include "../constants.h" #include "../constants.h"
wound_atk::wound_atk(const position &pos): wound_atk::wound_atk(const position &pos):
potion{potion_type::wound_atk, -1, pos} {} potion{potion_type::WOUND_ATK, -1, pos} {}
void wound_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF, void wound_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) { fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = WOUND_ATK; int tmp = WOUND_ATK;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
ATK = std::max(ATK - tmp, 0); ATK = std::max(ATK - tmp, 0);

View File

@ -4,14 +4,14 @@
#include "../constants.h" #include "../constants.h"
wound_def::wound_def(const position &pos): wound_def::wound_def(const position &pos):
potion{potion_type::wound_def, -1, pos} {} potion{potion_type::WOUND_DEF, -1, pos} {}
void wound_def::apply(const enum race &race, int &HP, int &ATK, int &DEF, void wound_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
fraction &base_hit_rate) { fraction &base_hit_rate) {
if (remaining_duration != 0) { if (remaining_duration != 0) {
int tmp = WOUND_DEF; int tmp = WOUND_DEF;
if (race == rdrow) if (race == DROW)
tmp *= DROW_POTION_MUL; tmp *= DROW_POTION_MUL;
DEF = std::max(DEF - tmp, 0); DEF = std::max(DEF - tmp, 0);

View File

@ -104,8 +104,8 @@ const int MAX_MSG_LEN = 71;
const std::string DOTS = "..."; const std::string DOTS = "...";
void game_result::run(input *in) { void game_result::run(input *in) {
if (in->get_command() == game_restart) if (in->get_command() == GAME_RESTART)
status = restart; status = RESTART;
} }
void game_result::print(output *out) { void game_result::print(output *out) {
@ -115,17 +115,17 @@ void game_result::print(output *out) {
} }
switch (status) { switch (status) {
case won: case WON:
out->print_str({0, 0}, WIN_SCREEN); out->print_str({0, 0}, WIN_SCREEN);
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_YELLOW)); out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_YELLOW));
break; break;
case escaped: case ESCAPED:
out->print_str({0, 0}, ESC_SCREEN); out->print_str({0, 0}, ESC_SCREEN);
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_GREEN)); out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_GREEN));
break; break;
case dead: case DEAD:
out->print_str({0, 0}, LOSE_SCREEN); out->print_str({0, 0}, LOSE_SCREEN);
out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_RED)); out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_RED));
break; break;