diff --git a/src/cc3k.cc b/src/cc3k.cc index 8cdc04b..52536d4 100644 --- a/src/cc3k.cc +++ b/src/cc3k.cc @@ -10,17 +10,17 @@ CC3K::CC3K(const feature enabled_features, out->clear(); curr_menu->print(out, rng->get_init_seed()); out->render(); - gresult.status = game_status::main_menu; + gresult.status = game_status::MAIN_MENU; } game_status CC3K::run() { switch (gresult.status) { - case main_menu: { + case MAIN_MENU: { auto tmp = curr_menu->run(in); if (tmp == -2) { - gresult.status = terminated; - return terminated; + gresult.status = TERMINATED; + return TERMINATED; } if (tmp != -1) { @@ -32,34 +32,34 @@ game_status CC3K::run() { out->clear(); curr_game->print(); out->render(); - gresult.status = in_game; - return in_game; + gresult.status = IN_GAME; + return IN_GAME; } out->clear(); curr_menu->print(out, rng->get_init_seed()); out->render(); - return main_menu; + return MAIN_MENU; } - case in_game: { + case IN_GAME: { gresult = curr_game->run(); - if (gresult.status == restart) { + if (gresult.status == RESTART) { curr_game.reset(); curr_menu = std::make_unique(enabled_features); out->clear(); curr_menu->print(out, rng->get_init_seed()); out->render(); - gresult.status = main_menu; - return main_menu; - } else if (gresult.status == in_game) { + gresult.status = MAIN_MENU; + return MAIN_MENU; + } else if (gresult.status == IN_GAME) { out->clear(); curr_game->print(); out->render(); - return in_game; - } else if (gresult.status == terminated) { - return terminated; + return IN_GAME; + } else if (gresult.status == TERMINATED) { + return TERMINATED; } out->clear(); @@ -68,26 +68,26 @@ game_status CC3K::run() { return gresult.status; } - case dead: - case won: - case escaped: + case DEAD: + case WON: + case ESCAPED: curr_game.reset(); gresult.run(in); - if (gresult.status == restart) { + if (gresult.status == RESTART) { curr_menu = std::make_unique(enabled_features); out->clear(); curr_menu->print(out, rng->get_init_seed()); out->render(); - gresult.status = main_menu; - return main_menu; + gresult.status = MAIN_MENU; + return MAIN_MENU; } - return terminated; + return TERMINATED; default: break; } - return terminated; + return TERMINATED; } diff --git a/src/characters.cc b/src/characters.cc index 2939fd1..0c46493 100644 --- a/src/characters.cc +++ b/src/characters.cc @@ -49,7 +49,7 @@ result character::calc_effects() { effects[i]->apply(this->race, HP, ATK, DEF, base_hit_rate); if (is_dead()) - return result::died; + return result::DIED; if (effects[i]->get_duration() != 0) tmp.push_back(std::move(effects[i])); @@ -59,7 +59,7 @@ result character::calc_effects() { std::swap(tmp, effects); - return result::fine; + return result::NOTHING; } void character::discard_level_effects() { diff --git a/src/constants.h b/src/constants.h index be621b4..ee4671e 100644 --- a/src/constants.h +++ b/src/constants.h @@ -8,12 +8,10 @@ static const int INF = 0x3F3F3F3F; -// TODO: update result to include subject -// fine will waste a turn -enum result : int {fine, died, go_down, go_up, hit, moved, - miss, terminate, applied, applied_nothing, - toggle_the_world, restart_game, unknown, - inventory, thrown +enum result : int {NOTHING, DIED, GO_DOWN, GO_UP, HIT, MOVED, + MISS, TERMINATE, APPLIED, APPLIED_NOTHING, + TOGGLE_THE_WORLD, RESTART_GAME, UNKNOWN, + INVENTORY, THROWN }; struct long_result { @@ -21,40 +19,40 @@ struct long_result { std::string msg; }; -enum game_status : int {terminated, main_menu, in_game, options, - dead, won, escaped, restart +enum game_status : int {TERMINATED, MAIN_MENU, IN_GAME, OPTIONS, + DEAD, WON, ESCAPED, RESTART }; -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, toggle_inventory, - throw_north, throw_south, throw_east, throw_west, - throw_northeast, throw_northwest, - throw_southeast, throw_southwest, - select_shade, select_drow, select_vampire, - select_goblin, select_troll +enum game_command : int {GAME_COMMAND_TERMINATE = 0, + MOVE_NORTH, MOVE_SOUTH, MOVE_EAST, MOVE_WEAT, + 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, TOGGLE_INVENTORY, + THROW_NORTH, THROW_SOUTH, THROW_EAST, THROW_WEST, + THROW_NORTHEAST, THROW_NORTHWEST, + THROW_SOUTHEAST, THROW_SOUTHWEST, + SELECT_SHADE, SELECT_DROW, SELECT_VAMPIRE, + SELECT_GOBLIN, SELECT_TROLL }; // Character generation related static const int RACE_CNT = 23; -enum race : int {rshade = 0, rdrow, rvampire, rtroll, - rgoblin, rhuman, rdwarf, relf, - rorc, rmerchant, rdragon, rhalfling, - rt_800, rmr_goose, rmonk, rbrawler, - rassassin, rviking, rswordsman, - rleprechaun, rwitch, rhacker, rbaby_dragon +enum race : int {SHADE = 0, DROW, VAMPIRE, TROLL, + GOBLIN, HUMAN, DWARF, ELF, + ORC, MERCHANT, DRAGON, HALFLING, + RT_800, MR_GOOSE, MONK, BRAWLER, + ASSASSIN, VIKING, SWORDSMAN, + LEPRECHAUN, WITCH, HACKER, BABY_DRAGON }; static const char CHAR_REP[RACE_CNT] = { @@ -94,12 +92,12 @@ static const fraction STARTING_HR[RACE_CNT] = { // Potion-related static const int POTION_TYPE_CNT = 14; 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, - continuous_restoration, savage_strike, - echoing_resilience, tempest_tantrum, - bezerk_brew, borrow_life, - fine_booze, ironclad_ward +enum potion_type : int {RESTORE_HEALTH = 0, BOOST_ATK, BOOST_DEF, + POISON_HEALTH, WOUND_ATK, WOUND_DEF, + CONTINUOUS_RESTORATION, SAVAGE_STRIKE, + ECHOING_RESIL, TEMPEST_TANTRUM, + BEZERK_BREW, BORROW_LIFE, + FINE_BOOZE, IRONCLAD_WARD }; // Calculation priorities @@ -111,8 +109,8 @@ static const int CALC_LAST = 2; 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 : int { north = 0, south, east, west, northeast, - northwest, southeast, southwest +enum direction : int { NORTH = 0, SOUTH, EAST, WEST, NORTHEAST, + NORTHWEST, SOUTHEAST, SOUTHWEST }; static const position MOVE[DIRECTION_CNT] = { diff --git a/src/enemies.cc b/src/enemies.cc index 7b9c036..762c9b1 100644 --- a/src/enemies.cc +++ b/src/enemies.cc @@ -31,17 +31,17 @@ std::unique_ptr new_dragon(RNG *rng, const position &pos, const int EXCNT = 12; const race EXCHOICES[EXCNT] = { - rhuman, rdwarf, rhalfling, relf, rorc, rmerchant, - rviking, rswordsman, rleprechaun, rwitch, rhacker, rbaby_dragon + HUMAN, DWARF, HALFLING, ELF, ORC, MERCHANT, + VIKING, SWORDSMAN, LEPRECHAUN, WITCH, HACKER, BABY_DRAGON }; const int CNT = 18; const race CHOICES[CNT] = { - rhuman, rhuman, rhuman, rhuman, - rdwarf, rdwarf, rdwarf, - rhalfling, rhalfling, rhalfling, rhalfling, rhalfling, - relf, relf, - rorc, rorc, - rmerchant, rmerchant + HUMAN, HUMAN, HUMAN, HUMAN, + DWARF, DWARF, DWARF, + HALFLING, HALFLING, HALFLING, HALFLING, HALFLING, + ELF, ELF, + ORC, ORC, + MERCHANT, MERCHANT }; enum race get_extra_race(RNG *rng) { @@ -65,51 +65,51 @@ std::unique_ptr new_enemy(RNG *rng, const position &pos, r = get_normal_race(rng); switch (r) { - case rdwarf: + case DWARF: return make_unique(rng, enabled_features, pos, which_room); - case rhuman: + case HUMAN: return make_unique(rng, enabled_features, pos, which_room); - case relf: + case ELF: return make_unique(rng, enabled_features, pos, which_room); - case rorc: + case ORC: return make_unique(rng, enabled_features, pos, which_room); - case rmerchant: + case MERCHANT: return make_unique(rng, enabled_features, pos, which_room); - case rhalfling: + case HALFLING: return make_unique(rng, enabled_features, pos, which_room); - case rviking: + case VIKING: return make_unique(rng, enabled_features, pos, which_room); - case rswordsman: + case SWORDSMAN: return make_unique(rng, enabled_features, pos, which_room); - case rleprechaun: + case LEPRECHAUN: return make_unique(rng, enabled_features, pos, which_room); - case rwitch: + case WITCH: return make_unique(rng, enabled_features, pos, which_room); - case rhacker: + case HACKER: return make_unique(rng, enabled_features, pos, which_room); - case rbaby_dragon: + case BABY_DRAGON: return make_unique(rng, enabled_features, pos, which_room); diff --git a/src/enemies/baby_dragon.cc b/src/enemies/baby_dragon.cc index b121f47..d599008 100644 --- a/src/enemies/baby_dragon.cc +++ b/src/enemies/baby_dragon.cc @@ -4,7 +4,7 @@ baby_dragon::baby_dragon(RNG *rng, const feature enabled_features, 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 { return "Baby_Dragon"; diff --git a/src/enemies/dragon.cc b/src/enemies/dragon.cc index 03313c4..64a70d0 100644 --- a/src/enemies/dragon.cc +++ b/src/enemies/dragon.cc @@ -4,7 +4,7 @@ dragon::dragon(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Dragon"; @@ -14,7 +14,7 @@ long_result dragon::act(level *lvl, character *pc, bool hostile) { if (is_adjacent(pos, pc->get_pos()) && hostile) return attack(pc); - return {fine, ""}; + return {NOTHING, ""}; } int dragon::dies(level *lvl) { diff --git a/src/enemies/dwarf.cc b/src/enemies/dwarf.cc index a92825b..7a8d798 100644 --- a/src/enemies/dwarf.cc +++ b/src/enemies/dwarf.cc @@ -4,7 +4,7 @@ dwarf::dwarf(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Dwarf"; diff --git a/src/enemies/elf.cc b/src/enemies/elf.cc index e071e9b..54d7a34 100644 --- a/src/enemies/elf.cc +++ b/src/enemies/elf.cc @@ -4,7 +4,7 @@ elf::elf(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Elf"; @@ -13,18 +13,18 @@ const char *elf::get_race_name() const { long_result elf::attack(character *ch) { auto res1 = ch->get_hit(this, ATK, base_hit_rate); - if (res1.res == result::died) + if (res1.res == result::DIED) return res1; - if (ch->get_race() == rdrow) + if (ch->get_race() == DROW) return res1; auto res2 = ch->get_hit(this, ATK, base_hit_rate); - if (res1.res == miss && res2.res == miss) - return {miss, res1.msg + res2.msg}; - else if (res2.res == died) - return {died, res1.msg + res2.msg}; + if (res1.res == MISS && res2.res == MISS) + return {MISS, res1.msg + res2.msg}; + else if (res2.res == DIED) + return {DIED, res1.msg + res2.msg}; else - return {hit, res1.msg + res2.msg}; + return {HIT, res1.msg + res2.msg}; } diff --git a/src/enemies/hacker.cc b/src/enemies/hacker.cc index d4ba6a4..bb3fb25 100644 --- a/src/enemies/hacker.cc +++ b/src/enemies/hacker.cc @@ -4,7 +4,7 @@ hacker::hacker(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Hacker"; @@ -18,12 +18,12 @@ long_result hacker::get_hit(character *ch, const int tATK, HP -= tmp; 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() { diff --git a/src/enemies/halfling.cc b/src/enemies/halfling.cc index f757e8d..3142870 100644 --- a/src/enemies/halfling.cc +++ b/src/enemies/halfling.cc @@ -7,7 +7,7 @@ fraction halfling::HIT_RATE_MUL = {1, 2}; halfling::halfling(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Halfling"; @@ -23,17 +23,17 @@ long_result halfling::get_hit(character *ch, const int tATK, HP -= tmp; if (HP == 0) - return {result::hit, + return {result::HIT, "PC deals " + std::to_string(tmp) + " damage to " + abbrev + " (" + std::to_string(HP) + " HP). " + 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(HP) + " HP). "}; } - return {miss, "PC tried to hit " + abbrev + + return {MISS, "PC tried to hit " + abbrev + " but missed. The halfling laughed. "}; } diff --git a/src/enemies/human.cc b/src/enemies/human.cc index c0685ba..723256f 100644 --- a/src/enemies/human.cc +++ b/src/enemies/human.cc @@ -5,7 +5,7 @@ human::human(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Human"; diff --git a/src/enemies/leprechaun.cc b/src/enemies/leprechaun.cc index 7e27fac..7ed979b 100644 --- a/src/enemies/leprechaun.cc +++ b/src/enemies/leprechaun.cc @@ -7,7 +7,7 @@ leprechaun::leprechaun(RNG *rng, const feature enabled_features, const position &pos, 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} {} const char *leprechaun::get_race_name() const { @@ -23,7 +23,7 @@ long_result leprechaun::attack(character *ch) { } else { 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) + " pieces of gold from PC. "; static_cast(ch)->add_gold(-STEAL_GOLD); diff --git a/src/enemies/merchant.cc b/src/enemies/merchant.cc index 3d33cc5..5d24bc4 100644 --- a/src/enemies/merchant.cc +++ b/src/enemies/merchant.cc @@ -6,7 +6,7 @@ merchant::merchant(RNG *rng, const feature enabled_features, 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 { return "Merchant"; diff --git a/src/enemies/orc.cc b/src/enemies/orc.cc index dfdbfa9..ca0b8be 100644 --- a/src/enemies/orc.cc +++ b/src/enemies/orc.cc @@ -4,7 +4,7 @@ orc::orc(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Orc"; diff --git a/src/enemies/swordsman.cc b/src/enemies/swordsman.cc index cdaf9b7..fd7ddb6 100644 --- a/src/enemies/swordsman.cc +++ b/src/enemies/swordsman.cc @@ -5,7 +5,7 @@ swordsman::swordsman(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Swordsman"; diff --git a/src/enemies/viking.cc b/src/enemies/viking.cc index ab0d8b1..9b3f56d 100644 --- a/src/enemies/viking.cc +++ b/src/enemies/viking.cc @@ -4,7 +4,7 @@ viking::viking(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Viking"; @@ -13,15 +13,15 @@ const char *viking::get_race_name() const { long_result viking::attack(character *ch) { auto res1 = ch->get_hit(this, ATK, base_hit_rate); - if (res1.res == result::died) + if (res1.res == result::DIED) return res1; auto res2 = ch->get_hit(this, ATK, base_hit_rate); - if (res1.res == miss && res2.res == miss) - return {miss, res1.msg + res2.msg}; - else if (res2.res == died) - return {died, res1.msg + res2.msg}; + if (res1.res == MISS && res2.res == MISS) + return {MISS, res1.msg + res2.msg}; + else if (res2.res == DIED) + return {DIED, res1.msg + res2.msg}; else - return {hit, res1.msg + res2.msg}; + return {HIT, res1.msg + res2.msg}; } diff --git a/src/enemies/witch.cc b/src/enemies/witch.cc index c501133..8fe0315 100644 --- a/src/enemies/witch.cc +++ b/src/enemies/witch.cc @@ -4,7 +4,7 @@ witch::witch(RNG *rng, const feature enabled_features, const position &pos, 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 { return "Witch"; @@ -13,14 +13,16 @@ const char *witch::get_race_name() const { long_result witch::attack(character *ch) { auto res = ch->get_hit(this, ATK, base_hit_rate); - if (res.res == hit && rng->trial(POTION_RATE)) { - res.msg += "W's potion spilled onto PC. "; + if (res.res == HIT && rng->trial(POTION_RATE)) { potion_type type = static_cast(rng->rand_under( (enabled_features & FEATURE_EXTRA_STUFF) ? 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; diff --git a/src/enemy.cc b/src/enemy.cc index 29df745..4400851 100644 --- a/src/enemy.cc +++ b/src/enemy.cc @@ -35,7 +35,7 @@ long_result enemy_base::act(level *lvl, character *pc, bool hostile) { } pos = target; - return {fine, ""}; + return {NOTHING, ""}; } int choices_cnt = 0; @@ -52,7 +52,7 @@ long_result enemy_base::act(level *lvl, character *pc, bool hostile) { if (choices_cnt) pos = choices[rng->rand_under(choices_cnt)]; - return {fine, ""}; + return {NOTHING, ""}; } long_result enemy_base::attack(character *ch) { @@ -71,18 +71,18 @@ long_result enemy_base::get_hit(character *ch, const int tATK, HP -= tmp; if (HP == 0) - return {result::hit, + return {result::HIT, "PC deals " + std::to_string(tmp) + " damage to " + abbrev + " (" + std::to_string(HP) + " HP). " + 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(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) { diff --git a/src/game.cc b/src/game.cc index 5ffb547..7b92269 100644 --- a/src/game.cc +++ b/src/game.cc @@ -82,7 +82,7 @@ character *game::move_enemies() { continue; } - bool hostile = ch->get_race() == rmerchant ? + bool hostile = ch->get_race() == MERCHANT ? hostile_merchants : true; auto res = ch->act(levels[curr_level].get(), player.get(), hostile); @@ -107,15 +107,15 @@ game_result game::run() { } switch (res.res) { - case result::terminate: - return {terminated, ""}; + case result::TERMINATE: + return {TERMINATED, ""}; - case result::died: - return {dead, "You died: killed by your own stupidity!"}; + case result::DIED: + return {DEAD, "You died: killed by your own stupidity!"}; - case result::go_down: { + case result::GO_DOWN: { if (curr_level == max_level - 1) - return {won, "You won! You collected " + + return {WON, "You won! You collected " + std::to_string(player->get_gold()) + " pieces of gold after " + std::to_string(curr_turn + 1) + @@ -136,9 +136,9 @@ game_result game::run() { break; } - case result::go_up: { + case result::GO_UP: { if (curr_level == 0) - return {escaped, "You escaped the dungeon with " + + return {ESCAPED, "You escaped the dungeon with " + std::to_string(player->get_gold()) + " pieces of gold after " + std::to_string(curr_turn + 1) + @@ -155,19 +155,19 @@ game_result game::run() { break; } - case toggle_the_world: + case result::TOGGLE_THE_WORLD: the_world = !the_world; player->start_turn(); break; - case restart_game: - return {restart, ""}; + case RESTART_GAME: + return {RESTART, ""}; - case unknown: - case fine: - case applied_nothing: - case inventory: - return {in_game, ""}; + case UNKNOWN: + case NOTHING: + case APPLIED_NOTHING: + case INVENTORY: + return {IN_GAME, ""}; default: player->start_turn(); @@ -179,19 +179,19 @@ game_result game::run() { player->calc_effects(); 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(); if (player->is_dead()) { 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()}; } - return {in_game, ""}; + return {IN_GAME, ""}; } const position STATUS_RACE{0, 25}; diff --git a/src/input.cc b/src/input.cc index e0a3ab3..c321421 100644 --- a/src/input.cc +++ b/src/input.cc @@ -12,5 +12,5 @@ game_command get_direction(std::string &str) { if (str == COMMANDS[i]) return static_cast(i); - return game_command_panic; + return GAME_COMMAND_PANIC; } diff --git a/src/input/console_input.cc b/src/input/console_input.cc index 3e58618..d4a8de3 100644 --- a/src/input/console_input.cc +++ b/src/input/console_input.cc @@ -12,53 +12,53 @@ game_command console_input::get_command() { in >> cmd; if (in.eof()) - return game_command_terminate; + return GAME_COMMAND_TERMINATE; if (cmd == "q") - return game_command_terminate; + return GAME_COMMAND_TERMINATE; else if (cmd == "f") - return the_world; + return THE_WORLD; else if (cmd == "r") - return game_restart; + return GAME_RESTART; else if (cmd == "u" || cmd == "a" || cmd == "T") { auto cmdtmp = cmd; in >> cmd; if (in.eof()) - return game_command_panic; + return GAME_COMMAND_PANIC; auto tmp = get_direction(cmd); if (cmdtmp == "u") return static_cast - (tmp + apply_north); + (tmp + APPLY_NORTH); else if (cmdtmp == "a") return static_cast - (tmp + attack_north); + (tmp + ATTACK_NORTH); else return static_cast - (tmp + throw_north); + (tmp + THROW_NORTH); } else if (cmd == "yes") { - return game_command::enter; + return game_command::ENTER; } else if (cmd == "i") { - return toggle_inventory; + return TOGGLE_INVENTORY; } else if (cmd == "s") { - return select_shade; + return SELECT_SHADE; } else if (cmd == "d") { - return select_drow; + return SELECT_DROW; } else if (cmd == "v") { - return select_vampire; + return SELECT_VAMPIRE; } else if (cmd == "g") { - return select_goblin; + return SELECT_GOBLIN; } else if (cmd == "t") { - return select_troll; + return SELECT_TROLL; } else { auto tmp = get_direction(cmd); - if (tmp != game_command_panic) + if (tmp != GAME_COMMAND_PANIC) return static_cast - (tmp + move_north); + (tmp + MOVE_NORTH); } - return game_command_pass; + return GAME_COMMAND_PASS; } diff --git a/src/input/curses_input.cc b/src/input/curses_input.cc index 7a833ea..e946de8 100644 --- a/src/input/curses_input.cc +++ b/src/input/curses_input.cc @@ -10,98 +10,98 @@ game_command curses_input::get_command() { switch (curse->getcmd()) { case 'h': - return game_command::move_west; + return game_command::MOVE_WEAT; case 'j': - return game_command::move_south; + return game_command::MOVE_SOUTH; case 'k': - return game_command::move_north; + return game_command::MOVE_NORTH; case 'l': - return game_command::move_east; + return game_command::MOVE_EAST; case 'y': - return game_command::move_northwest; + return game_command::MOVE_NORTHWEST; case 'u': - return game_command::move_northeast; + return game_command::MOVE_NORTHEAST; case 'b': - return game_command::move_southwest; + return game_command::MOVE_SOUTHWEST; case 'n': - return game_command::move_southeast; + return game_command::MOVE_SOUTHEAST; case 'a': - tmp = apply_north; + tmp = APPLY_NORTH; break; // wait for another command case '<': - return game_command::up_stairs; + return game_command::UP_STAIRS; case '>': - return game_command::down_stairs; + return game_command::DOWN_STAIRS; case 'q': - return game_command_terminate; + return GAME_COMMAND_TERMINATE; case 'f': - return game_command::the_world; + return game_command::THE_WORLD; case 'r': - return game_restart; + return GAME_RESTART; case 'e': - return game_command::enter; + return game_command::ENTER; case 'i': - return toggle_inventory; + return TOGGLE_INVENTORY; case 't': - tmp = throw_north; + tmp = THROW_NORTH; break; default: - return game_command_pass; + return GAME_COMMAND_PASS; } switch (curse->getcmd()) { case 'h': return static_cast - (tmp + west); + (tmp + WEST); case 'j': return static_cast - (tmp + south); + (tmp + SOUTH); case 'k': return static_cast - (tmp + north); + (tmp + NORTH); case 'l': return static_cast - (tmp + east); + (tmp + EAST); case 'y': return static_cast - (tmp + northwest); + (tmp + NORTHWEST); case 'u': return static_cast - (tmp + northeast); + (tmp + NORTHEAST); case 'b': return static_cast - (tmp + southwest); + (tmp + SOUTHWEST); case 'n': return static_cast - (tmp + southeast); + (tmp + SOUTHEAST); default: - return game_command_panic; + return GAME_COMMAND_PANIC; } - return game_command::game_command_panic; + return game_command::GAME_COMMAND_PANIC; } diff --git a/src/input/file_input.cc b/src/input/file_input.cc index 104498b..5935ebb 100644 --- a/src/input/file_input.cc +++ b/src/input/file_input.cc @@ -12,53 +12,53 @@ game_command file_input::get_command() { in >> cmd; if (in.eof()) - return game_command_terminate; + return GAME_COMMAND_TERMINATE; if (cmd == "q") - return game_command_terminate; + return GAME_COMMAND_TERMINATE; else if (cmd == "f") - return the_world; + return THE_WORLD; else if (cmd == "r") - return game_restart; + return GAME_RESTART; else if (cmd == "u" || cmd == "a" || cmd == "T") { auto cmdtmp = cmd; in >> cmd; if (in.eof()) - return game_command_panic; + return GAME_COMMAND_PANIC; auto tmp = get_direction(cmd); if (cmdtmp == "u") return static_cast - (tmp + apply_north); + (tmp + APPLY_NORTH); else if (cmdtmp == "a") return static_cast - (tmp + attack_north); + (tmp + ATTACK_NORTH); else return static_cast - (tmp + throw_north); + (tmp + THROW_NORTH); } else if (cmd == "yes") { - return game_command::enter; + return game_command::ENTER; } else if (cmd == "i") { - return toggle_inventory; + return TOGGLE_INVENTORY; } else if (cmd == "s") { - return select_shade; + return SELECT_SHADE; } else if (cmd == "d") { - return select_drow; + return SELECT_DROW; } else if (cmd == "v") { - return select_vampire; + return SELECT_VAMPIRE; } else if (cmd == "g") { - return select_goblin; + return SELECT_GOBLIN; } else if (cmd == "t") { - return select_troll; + return SELECT_TROLL; } else { auto tmp = get_direction(cmd); - if (tmp != game_command_panic) + if (tmp != GAME_COMMAND_PANIC) return static_cast - (tmp + move_north); + (tmp + MOVE_NORTH); } - return game_command_pass; + return GAME_COMMAND_PASS; } diff --git a/src/main.cc b/src/main.cc index c1be3c2..d1c71a6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -28,7 +28,7 @@ int main(int argc, char **argv) { CC3K game_proc(enabled_features, in.get(), out.get(), rng.get()); while (1) - if (game_proc.run() == game_status::terminated) + if (game_proc.run() == game_status::TERMINATED) break; return RETURN_FINE; diff --git a/src/menu.cc b/src/menu.cc index e1a81cc..14a4cc9 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -7,8 +7,8 @@ const int EXTRA_CNT = 10; const int HOR_INCRM = 5; const enum race RACES[EXTRA_CNT] = { - rshade, rdrow, rgoblin, rvampire, rtroll, - rmonk, rassassin, rmr_goose, rbrawler, rt_800 + SHADE, DROW, GOBLIN, VAMPIRE, TROLL, + MONK, ASSASSIN, MR_GOOSE, BRAWLER, RT_800 }; const position RACE_POS[EXTRA_CNT] = { @@ -81,53 +81,53 @@ int menu::run(input *in) { auto cmd = in->get_command(); switch (cmd) { - case game_command::enter: + case game_command::ENTER: return RACES[curr]; - case move_north: { + case MOVE_NORTH: { if (curr > 0) --curr; break; } - case move_south: { + case MOVE_SOUTH: { if (curr < limit - 1) ++curr; break; } - case move_east: { + case MOVE_EAST: { if (curr + HOR_INCRM < limit) curr += HOR_INCRM; break; } - case move_west: { + case MOVE_WEAT: { if (curr - HOR_INCRM >= 0) curr -= HOR_INCRM; break; } - case select_shade: - return rshade; + case SELECT_SHADE: + return SHADE; - case select_drow: - return rdrow; + case SELECT_DROW: + return DROW; - case select_goblin: - return rgoblin; + case SELECT_GOBLIN: + return GOBLIN; - case select_troll: - return rtroll; + case SELECT_TROLL: + return TROLL; - case select_vampire: - return rvampire; + case SELECT_VAMPIRE: + return VAMPIRE; - case game_command_terminate: + case GAME_COMMAND_TERMINATE: return -2; default: diff --git a/src/pc.cc b/src/pc.cc index 4952d55..6c46153 100644 --- a/src/pc.cc +++ b/src/pc.cc @@ -17,34 +17,34 @@ std::unique_ptr init_player(RNG *rng, using std::make_unique; switch (r) { - case rgoblin: + case GOBLIN: return make_unique(rng, enabled_features); - case rdrow: + case DROW: return make_unique(rng, enabled_features); - case rshade: + case SHADE: return make_unique(rng, enabled_features); - case rtroll: + case TROLL: return make_unique(rng, enabled_features); - case rvampire: + case VAMPIRE: return make_unique(rng, enabled_features); - case rt_800: + case RT_800: return make_unique(rng, enabled_features); - case rassassin: + case ASSASSIN: return make_unique(rng, enabled_features); - case rmonk: + case MONK: return make_unique(rng, enabled_features); - case rbrawler: + case BRAWLER: return make_unique(rng, enabled_features); - case rmr_goose: + case MR_GOOSE: return make_unique(rng, enabled_features); default: diff --git a/src/player.cc b/src/player.cc index 0c38fcb..acc3db9 100644 --- a/src/player.cc +++ b/src/player.cc @@ -38,7 +38,7 @@ int player_base::get_HP() const { long_result player_base::apply(std::unique_ptr p) { if (p == nullptr) - return {result::applied_nothing, + return {result::APPLIED_NOTHING, "PC tried to breathe the magic in the air. "}; std::string name = p->get_name(); @@ -47,17 +47,17 @@ long_result player_base::apply(std::unique_ptr p) { apply_effect(std::move(p)); - if (race == rt_800) - return {result::applied, + if (race == RT_800) + return {result::APPLIED, "PC gets rusty joints (-50 HP). "}; - return {result::applied, + return {result::APPLIED, "PC applied potion of " + name + ". "}; } long_result player_base::attack(character *ch) { if (ch == nullptr) - return {result::fine, + return {result::NOTHING, "PC tried to attack thin air. "}; 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)) { pos = p; - return {result::moved, ""}; + return {result::MOVED, ""}; } else if ((tmp = get_enemy_at(p, lvl->get_elist())) != nullptr) { auto res = attack(static_cast(tmp)); @@ -90,15 +90,15 @@ long_result player_base::move(level *lvl, } } else if (lvl->get_up_stairs() == p && 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) { - 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)) { 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, @@ -109,18 +109,18 @@ long_result player_base::get_hit(character *ch, const int tATK, HP -= tmp; if (HP == 0) - return {result::died, + return {result::DIED, ch->get_abbrev() + " deals " + std::to_string(tmp) + " damage to PC. PC is slain by " + ch->get_abbrev() + ". "}; - return {result::hit, ch->get_abbrev() + " deals " + + return {result::HIT, ch->get_abbrev() + " deals " + std::to_string(tmp) + " 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) { @@ -130,7 +130,7 @@ void player_base::add_gold(int amount) { long_result player_base::throw_potion(level *lvl, std::unique_ptr p, direction dir) { 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}; @@ -139,23 +139,23 @@ long_result player_base::throw_potion(level *lvl, std::unique_ptr p, size_t flag = lvl->what_is_at(tmp); 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) { character *ch = lvl->get_elist()[flag ^ WHAT_ENEMY]; 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() + ". "}; } } - 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) { if (inv.enabled) { - if (cmd == toggle_inventory || cmd == game_command_terminate) { + if (cmd == TOGGLE_INVENTORY || cmd == GAME_COMMAND_TERMINATE) { inv.enabled = false; - return {result::inventory, ""}; + return {result::INVENTORY, ""}; } else { 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; return apply(std::move(res.first)); } else if (res.first == nullptr) { - return {result::inventory, ""}; + return {result::INVENTORY, ""}; } else if (res.second == DIRECTION_CNT) { inv.enabled = false; - return {result::thrown, + return {result::THROWN, "PC tried to throw a vial of air. "}; } else { inv.enabled = false; @@ -177,10 +177,10 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) { } } - if (cmd == game_command_terminate) { - return {result::terminate, ""}; - } else if (cmd >= move_north && cmd <= move_southwest) { - auto res = move(lvl, pos + MOVE[cmd - move_north]); + if (cmd == GAME_COMMAND_TERMINATE) { + return {result::TERMINATE, ""}; + } else if (cmd >= MOVE_NORTH && cmd <= MOVE_SOUTHWEST) { + auto res = move(lvl, pos + MOVE[cmd - MOVE_NORTH]); gold g{{0, 0}, 0}; int gold_tmp = 0; @@ -209,16 +209,16 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) { return res; - } else if (cmd >= apply_north && cmd <= apply_southwest) { - size_t idx = get_potion_at(pos + MOVE[cmd - apply_north], + } else if (cmd >= APPLY_NORTH && cmd <= APPLY_SOUTHWEST) { + size_t idx = get_potion_at(pos + MOVE[cmd - APPLY_NORTH], lvl->get_plist()); auto res = apply(lvl->detach_potion(idx)); return res; - } else if (cmd == apply_panic) { - return {result::fine, + } else if (cmd == APPLY_PANIC) { + return {result::NOTHING, "PC tried to use in some non-existent direction. "}; - } else if (cmd >= attack_north && cmd <= attack_southwest) { - enemy_base *tmp = get_enemy_at(pos + MOVE[cmd - attack_north], + } else if (cmd >= ATTACK_NORTH && cmd <= ATTACK_SOUTHWEST) { + enemy_base *tmp = get_enemy_at(pos + MOVE[cmd - ATTACK_NORTH], lvl->get_elist()); auto res = attack(static_cast(tmp)); @@ -236,32 +236,32 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) { } return res; - } else if (cmd == up_stairs) { + } else if (cmd == UP_STAIRS) { if (lvl->get_up_stairs() == pos && 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. "}; - } else if (cmd == down_stairs) { + } else if (cmd == DOWN_STAIRS) { 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. "}; - } else if (cmd == the_world) { - return{toggle_the_world, "PC toggled Stand: The World! "}; - } else if (cmd == game_restart) { - return {restart_game, ""}; - } else if (cmd == game_command_pass) { - return {result::fine, ""}; - } else if (cmd == toggle_inventory && + } else if (cmd == THE_WORLD) { + return{TOGGLE_THE_WORLD, "PC toggled Stand: The World! "}; + } else if (cmd == GAME_RESTART) { + return {RESTART_GAME, ""}; + } else if (cmd == GAME_COMMAND_PASS) { + return {result::NOTHING, ""}; + } else if (cmd == TOGGLE_INVENTORY && enabled_features & FEATURE_INVENTORY) { 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() { @@ -271,17 +271,17 @@ void player_base::inventory::start() { std::pair, int> player_base::inventory::run( game_command cmd, const feature enabled_features) { - if (cmd == move_north) { + if (cmd == MOVE_NORTH) { if (curr != 0) --curr; return {nullptr, 0}; - } else if (cmd == move_south) { + } else if (cmd == MOVE_SOUTH) { if (curr < owns.size() - 1) ++curr; return {nullptr, 0}; - } else if (cmd == enter) { + } else if (cmd == ENTER) { if (owns.size()) { std::unique_ptr tmp = std::move(owns[curr]); owns.erase(owns.begin() + curr); @@ -289,13 +289,13 @@ std::pair, int> player_base::inventory::run( } return {nullptr, -1}; - } else if (cmd >= throw_north && cmd <= throw_southwest && + } else if (cmd >= THROW_NORTH && cmd <= THROW_SOUTHWEST && enabled_features & FEATURE_THROW) { if (owns.size()) { std::unique_ptr tmp = std::move(owns[curr]); owns.erase(owns.begin() + curr); return {std::move(tmp), - static_cast(cmd - throw_north)}; + static_cast(cmd - THROW_NORTH)}; } return {nullptr, DIRECTION_CNT}; diff --git a/src/player/assassin.cc b/src/player/assassin.cc index b4accd2..3be4ad3 100644 --- a/src/player/assassin.cc +++ b/src/player/assassin.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 { return "Assassin"; @@ -11,14 +11,14 @@ const char *assassin::get_race_name() const { long_result assassin::attack(character *ch) { if (ch == nullptr) - return {result::fine, + return {result::NOTHING, "PC tried to assassinate thin air. "}; 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); - return {hit, "PC assassinated " + ch->get_abbrev() + ". "}; + return {HIT, "PC assassinated " + ch->get_abbrev() + ". "}; } return res; diff --git a/src/player/brawler.cc b/src/player/brawler.cc index acea17b..cf5b019 100644 --- a/src/player/brawler.cc +++ b/src/player/brawler.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 { return "Tavern Brawler"; @@ -11,7 +11,7 @@ const char *brawler::get_race_name() const { long_result brawler::attack(character *ch) { if (ch == nullptr) - return {result::fine, + return {result::NOTHING, "PC tried to attack thin air. "}; // hits twice @@ -26,5 +26,5 @@ long_result brawler::attack(character *ch) { return {res3.res, res1.msg + res2.msg + res3.msg}; } - return {fine, ""}; + return {NOTHING, ""}; } diff --git a/src/player/drow.cc b/src/player/drow.cc index 5337a6a..6135cf3 100644 --- a/src/player/drow.cc +++ b/src/player/drow.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 { return "Drow"; diff --git a/src/player/goblin.cc b/src/player/goblin.cc index 3ca3756..8b6c983 100644 --- a/src/player/goblin.cc +++ b/src/player/goblin.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 { return "Goblin"; @@ -11,7 +11,7 @@ const char *goblin::get_race_name() const { long_result goblin::attack(character *ch) { if (ch == nullptr) - return {result::fine, + return {result::NOTHING, "PC tried to attack thin air. "}; 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); std::string msg = ""; - if (ch->get_race() == rorc) { + if (ch->get_race() == ORC) { msg += "PC feels scared. "; tmp *= ORC_DMG_MUL; } @@ -42,12 +42,12 @@ long_result goblin::get_hit(character *ch, const int tATK, " damage to PC. "; if (HP == 0) - return {result::died, + return {result::DIED, msg + "PC is slain by " + 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. "}; } diff --git a/src/player/monk.cc b/src/player/monk.cc index ff3a20c..4aae4fd 100644 --- a/src/player/monk.cc +++ b/src/player/monk.cc @@ -3,15 +3,15 @@ #include "../constants.h" 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 { return "Monk"; } void monk::start_turn() { - ATK = STARTING_ATK[rmonk]; - DEF = STARTING_DEF[rmonk]; + ATK = STARTING_ATK[MONK]; + DEF = STARTING_DEF[MONK]; 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]; } diff --git a/src/player/mr_goose.cc b/src/player/mr_goose.cc index 94109ef..91f5896 100644 --- a/src/player/mr_goose.cc +++ b/src/player/mr_goose.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 known_potions = (1 << POTION_TYPE_CNT) - 1; } diff --git a/src/player/shade.cc b/src/player/shade.cc index 3b9fffb..02c6ce5 100644 --- a/src/player/shade.cc +++ b/src/player/shade.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 { return "Shade"; diff --git a/src/player/t_800.cc b/src/player/t_800.cc index f84380d..99b05fe 100644 --- a/src/player/t_800.cc +++ b/src/player/t_800.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 { return "T-800"; diff --git a/src/player/troll.cc b/src/player/troll.cc index aaca9b9..a60a37a 100644 --- a/src/player/troll.cc +++ b/src/player/troll.cc @@ -3,15 +3,15 @@ #include "../constants.h" 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 { return "Troll"; } void troll::start_turn() { - ATK = STARTING_ATK[rtroll]; - DEF = STARTING_DEF[rtroll]; + ATK = STARTING_ATK[TROLL]; + DEF = STARTING_DEF[TROLL]; 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]; } diff --git a/src/player/vampire.cc b/src/player/vampire.cc index 874e064..71c628a 100644 --- a/src/player/vampire.cc +++ b/src/player/vampire.cc @@ -3,7 +3,7 @@ #include "../constants.h" 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 { return "Vampire"; @@ -11,23 +11,23 @@ const char *vampire::get_race_name() const { long_result vampire::attack(character *ch) { if (ch == nullptr) - return {result::fine, + return {result::NOTHING, "PC tried to drain thin air. "}; auto res = ch->get_hit(this, ATK, base_hit_rate); - if (res.res == miss) - return {miss, res.msg + "PC is unhappy. "}; + if (res.res == MISS) + return {MISS, res.msg + "PC is unhappy. "}; - if (ch->get_race() == rdwarf) { + if (ch->get_race() == DWARF) { HP -= GAIN_HP; 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; - return {hit, res.msg + "PC is happy. "}; + return {HIT, res.msg + "PC is happy. "}; } diff --git a/src/potions.cc b/src/potions.cc index aa4e001..e64492e 100644 --- a/src/potions.cc +++ b/src/potions.cc @@ -18,47 +18,47 @@ std::unique_ptr new_potion(potion_type type, const position &pos) { switch (type) { - case restore_health: - return std::make_unique(pos); + case RESTORE_HEALTH: + return std::make_unique(pos); - case boost_atk: - return std::make_unique(pos); + case BOOST_ATK: + return std::make_unique(pos); - case boost_def: - return std::make_unique(pos); + case BOOST_DEF: + return std::make_unique(pos); - case poison_health: - return std::make_unique(pos); + case POISON_HEALTH: + return std::make_unique(pos); - case wound_atk: - return std::make_unique(pos); + case WOUND_ATK: + return std::make_unique(pos); - case wound_def: - return std::make_unique(pos); + case WOUND_DEF: + return std::make_unique(pos); - case continuous_restoration: - return std::make_unique(pos); + case CONTINUOUS_RESTORATION: + return std::make_unique(pos); - case savage_strike: - return std::make_unique(pos); + case SAVAGE_STRIKE: + return std::make_unique(pos); - case echoing_resilience: - return std::make_unique(pos); + case ECHOING_RESIL: + return std::make_unique(pos); - case tempest_tantrum: - return std::make_unique(pos); + case TEMPEST_TANTRUM: + return std::make_unique(pos); - case bezerk_brew: - return std::make_unique(pos); + case BEZERK_BREW: + return std::make_unique(pos); - case borrow_life: - return std::make_unique(pos); + case BORROW_LIFE: + return std::make_unique(pos); - case fine_booze: - return std::make_unique(pos); + case FINE_BOOZE: + return std::make_unique(pos); - case ironclad_ward: - return std::make_unique(pos); + case IRONCLAD_WARD: + return std::make_unique(pos); default: break; diff --git a/src/potions/bezerk_brew.cc b/src/potions/bezerk_brew.cc index 74ed312..4272955 100644 --- a/src/potions/bezerk_brew.cc +++ b/src/potions/bezerk_brew.cc @@ -4,13 +4,13 @@ #include "../constants.h" 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, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { - ATK *= ATK_MUL * (race == rdrow ? DROW_POTION_MUL : 1); - DEF *= DEF_MUL * (race == rdrow ? DROW_POTION_MUL : 1); + ATK *= ATK_MUL * (race == DROW ? DROW_POTION_MUL : 1); + DEF *= DEF_MUL * (race == DROW ? DROW_POTION_MUL : 1); --remaining_duration; } } diff --git a/src/potions/boost_atk.cc b/src/potions/boost_atk.cc index 83a1596..e8738ac 100644 --- a/src/potions/boost_atk.cc +++ b/src/potions/boost_atk.cc @@ -6,14 +6,14 @@ 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, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = BOOST_ATK; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; ATK += tmp; diff --git a/src/potions/boost_def.cc b/src/potions/boost_def.cc index 7425a25..b7ed65b 100644 --- a/src/potions/boost_def.cc +++ b/src/potions/boost_def.cc @@ -5,14 +5,14 @@ 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, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = BOOST_DEF; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; DEF += tmp; diff --git a/src/potions/borrow_life.cc b/src/potions/borrow_life.cc index 73fca92..f7411b6 100644 --- a/src/potions/borrow_life.cc +++ b/src/potions/borrow_life.cc @@ -4,18 +4,18 @@ #include "../constants.h" 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, int &DEF, fraction &base_hit_rate) { 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) --remaining_duration; 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; } } diff --git a/src/potions/continuous_restoration.cc b/src/potions/continuous_restoration.cc index a5f8c4e..1078ddb 100644 --- a/src/potions/continuous_restoration.cc +++ b/src/potions/continuous_restoration.cc @@ -4,14 +4,14 @@ #include "../constants.h" 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, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = GAIN_HEALTH; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; HP = std::min(HP + tmp, MAX_HP[race]); diff --git a/src/potions/echoing_resilience.cc b/src/potions/echoing_resilience.cc index 762d0d3..9c4b2a6 100644 --- a/src/potions/echoing_resilience.cc +++ b/src/potions/echoing_resilience.cc @@ -4,16 +4,16 @@ #include "../constants.h" 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, int &DEF, fraction &base_hit_rate) { 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]); - ATK -= LOSE_ATK * (race == rdrow ? DROW_POTION_MUL : 1); - DEF -= LOSE_DEF * (race == rdrow ? DROW_POTION_MUL : 1); + ATK -= LOSE_ATK * (race == DROW ? DROW_POTION_MUL : 1); + DEF -= LOSE_DEF * (race == DROW ? DROW_POTION_MUL : 1); ATK = ATK < 0 ? 0 : ATK; DEF = DEF < 0 ? 0 : DEF; diff --git a/src/potions/fine_booze.cc b/src/potions/fine_booze.cc index a7f1239..9e57e15 100644 --- a/src/potions/fine_booze.cc +++ b/src/potions/fine_booze.cc @@ -4,19 +4,19 @@ #include "../constants.h" 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, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = GAIN_HP; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; HP = std::min(HP + tmp, MAX_HP[race]); - if (race == rbrawler) + if (race == BRAWLER) base_hit_rate = HR_TB; else base_hit_rate *= HR_MUL; diff --git a/src/potions/ironclad_ward.cc b/src/potions/ironclad_ward.cc index a474190..6077c06 100644 --- a/src/potions/ironclad_ward.cc +++ b/src/potions/ironclad_ward.cc @@ -4,13 +4,13 @@ #include "../constants.h" 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, int &DEF, fraction &base_hit_rate) { if (remaining_duration != 0) { - ATK *= ATK_MUL * (race == rdrow ? DROW_POTION_MUL : 1); - DEF *= DEF_MUL * (race == rdrow ? DROW_POTION_MUL : 1); + ATK *= ATK_MUL * (race == DROW ? DROW_POTION_MUL : 1); + DEF *= DEF_MUL * (race == DROW ? DROW_POTION_MUL : 1); base_hit_rate *= HR_MUL; --remaining_duration; } diff --git a/src/potions/poison_health.cc b/src/potions/poison_health.cc index 102f011..1f2e178 100644 --- a/src/potions/poison_health.cc +++ b/src/potions/poison_health.cc @@ -4,14 +4,14 @@ #include "../constants.h" 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, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = LOSE_HEALTH; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; HP = std::max(HP - tmp, 0); diff --git a/src/potions/restore_health.cc b/src/potions/restore_health.cc index e3be45a..6d15909 100644 --- a/src/potions/restore_health.cc +++ b/src/potions/restore_health.cc @@ -4,14 +4,14 @@ #include "../constants.h" 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, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = GAIN_HEALTH; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; HP = std::min(HP + tmp, MAX_HP[race]); diff --git a/src/potions/savage_strike.cc b/src/potions/savage_strike.cc index 275f52e..a7bbdd3 100644 --- a/src/potions/savage_strike.cc +++ b/src/potions/savage_strike.cc @@ -4,12 +4,12 @@ #include "../constants.h" 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, fraction &base_hit_rate) { 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; --remaining_duration; } diff --git a/src/potions/tempest_tantrum.cc b/src/potions/tempest_tantrum.cc index c010f2b..f7911cc 100644 --- a/src/potions/tempest_tantrum.cc +++ b/src/potions/tempest_tantrum.cc @@ -4,17 +4,17 @@ #include "../constants.h" 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, int &DEF, fraction &base_hit_rate) { if (remaining_duration == DURATION) HP -= HP_RD_PERCENTAGE * HP * - (race == rdrow ? DROW_POTION_MUL : 1); + (race == DROW ? DROW_POTION_MUL : 1); if (remaining_duration != 0) { - ATK *= ATK_MUL * (race == rdrow ? DROW_POTION_MUL : 1); - DEF *= DEF_MUL * (race == rdrow ? DROW_POTION_MUL : 1); + ATK *= ATK_MUL * (race == DROW ? DROW_POTION_MUL : 1); + DEF *= DEF_MUL * (race == DROW ? DROW_POTION_MUL : 1); --remaining_duration; } } diff --git a/src/potions/wound_atk.cc b/src/potions/wound_atk.cc index cf4c186..9597c34 100644 --- a/src/potions/wound_atk.cc +++ b/src/potions/wound_atk.cc @@ -4,14 +4,14 @@ #include "../constants.h" 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, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = WOUND_ATK; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; ATK = std::max(ATK - tmp, 0); diff --git a/src/potions/wound_def.cc b/src/potions/wound_def.cc index db705fc..3b28388 100644 --- a/src/potions/wound_def.cc +++ b/src/potions/wound_def.cc @@ -4,14 +4,14 @@ #include "../constants.h" 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, fraction &base_hit_rate) { if (remaining_duration != 0) { int tmp = WOUND_DEF; - if (race == rdrow) + if (race == DROW) tmp *= DROW_POTION_MUL; DEF = std::max(DEF - tmp, 0); diff --git a/src/result.cc b/src/result.cc index 764439f..ffce8d6 100644 --- a/src/result.cc +++ b/src/result.cc @@ -104,8 +104,8 @@ const int MAX_MSG_LEN = 71; const std::string DOTS = "..."; void game_result::run(input *in) { - if (in->get_command() == game_restart) - status = restart; + if (in->get_command() == GAME_RESTART) + status = RESTART; } void game_result::print(output *out) { @@ -115,17 +115,17 @@ void game_result::print(output *out) { } switch (status) { - case won: + case WON: out->print_str({0, 0}, WIN_SCREEN); out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_YELLOW)); break; - case escaped: + case ESCAPED: out->print_str({0, 0}, ESC_SCREEN); out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_GREEN)); break; - case dead: + case DEAD: out->print_str({0, 0}, LOSE_SCREEN); out->print_str(MSG_START, msg, COLOR_PAIR(COLOR_RED)); break;