capitalized all enums
This commit is contained in:
46
src/cc3k.cc
46
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<menu>(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<menu>(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;
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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] = {
|
||||
|
@ -31,17 +31,17 @@ std::unique_ptr<enemy_base> 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<enemy_base> new_enemy(RNG *rng, const position &pos,
|
||||
r = get_normal_race(rng);
|
||||
|
||||
switch (r) {
|
||||
case rdwarf:
|
||||
case DWARF:
|
||||
return make_unique<dwarf>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rhuman:
|
||||
case HUMAN:
|
||||
return make_unique<human>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case relf:
|
||||
case ELF:
|
||||
return make_unique<elf>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rorc:
|
||||
case ORC:
|
||||
return make_unique<orc>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rmerchant:
|
||||
case MERCHANT:
|
||||
return make_unique<merchant>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rhalfling:
|
||||
case HALFLING:
|
||||
return make_unique<halfling>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rviking:
|
||||
case VIKING:
|
||||
return make_unique<viking>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rswordsman:
|
||||
case SWORDSMAN:
|
||||
return make_unique<swordsman>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rleprechaun:
|
||||
case LEPRECHAUN:
|
||||
return make_unique<leprechaun>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rwitch:
|
||||
case WITCH:
|
||||
return make_unique<witch>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rhacker:
|
||||
case HACKER:
|
||||
return make_unique<hacker>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
case rbaby_dragon:
|
||||
case BABY_DRAGON:
|
||||
return make_unique<baby_dragon>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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) {
|
||||
|
@ -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";
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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. "};
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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<player_base *>(ch)->add_gold(-STEAL_GOLD);
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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,7 +13,7 @@ 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)) {
|
||||
if (res.res == HIT && rng->trial(POTION_RATE)) {
|
||||
res.msg += "W's potion spilled onto PC. ";
|
||||
potion_type type =
|
||||
static_cast<potion_type>(rng->rand_under(
|
||||
|
10
src/enemy.cc
10
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) {
|
||||
|
42
src/game.cc
42
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};
|
||||
|
@ -12,5 +12,5 @@ game_command get_direction(std::string &str) {
|
||||
if (str == COMMANDS[i])
|
||||
return static_cast<game_command>(i);
|
||||
|
||||
return game_command_panic;
|
||||
return GAME_COMMAND_PANIC;
|
||||
}
|
||||
|
@ -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<game_command>
|
||||
(tmp + apply_north);
|
||||
(tmp + APPLY_NORTH);
|
||||
else if (cmdtmp == "a")
|
||||
return static_cast<game_command>
|
||||
(tmp + attack_north);
|
||||
(tmp + ATTACK_NORTH);
|
||||
else
|
||||
return static_cast<game_command>
|
||||
(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<game_command>
|
||||
(tmp + move_north);
|
||||
(tmp + MOVE_NORTH);
|
||||
}
|
||||
|
||||
return game_command_pass;
|
||||
return GAME_COMMAND_PASS;
|
||||
}
|
||||
|
@ -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<game_command>
|
||||
(tmp + west);
|
||||
(tmp + WEST);
|
||||
|
||||
case 'j':
|
||||
return static_cast<game_command>
|
||||
(tmp + south);
|
||||
(tmp + SOUTH);
|
||||
|
||||
case 'k':
|
||||
return static_cast<game_command>
|
||||
(tmp + north);
|
||||
(tmp + NORTH);
|
||||
|
||||
case 'l':
|
||||
return static_cast<game_command>
|
||||
(tmp + east);
|
||||
(tmp + EAST);
|
||||
|
||||
case 'y':
|
||||
return static_cast<game_command>
|
||||
(tmp + northwest);
|
||||
(tmp + NORTHWEST);
|
||||
|
||||
case 'u':
|
||||
return static_cast<game_command>
|
||||
(tmp + northeast);
|
||||
(tmp + NORTHEAST);
|
||||
|
||||
case 'b':
|
||||
return static_cast<game_command>
|
||||
(tmp + southwest);
|
||||
(tmp + SOUTHWEST);
|
||||
|
||||
case 'n':
|
||||
return static_cast<game_command>
|
||||
(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;
|
||||
}
|
||||
|
@ -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<game_command>
|
||||
(tmp + apply_north);
|
||||
(tmp + APPLY_NORTH);
|
||||
else if (cmdtmp == "a")
|
||||
return static_cast<game_command>
|
||||
(tmp + attack_north);
|
||||
(tmp + ATTACK_NORTH);
|
||||
else
|
||||
return static_cast<game_command>
|
||||
(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<game_command>
|
||||
(tmp + move_north);
|
||||
(tmp + MOVE_NORTH);
|
||||
}
|
||||
|
||||
return game_command_pass;
|
||||
return GAME_COMMAND_PASS;
|
||||
}
|
||||
|
@ -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;
|
||||
|
36
src/menu.cc
36
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:
|
||||
|
20
src/pc.cc
20
src/pc.cc
@ -17,34 +17,34 @@ std::unique_ptr<player_base> init_player(RNG *rng,
|
||||
using std::make_unique;
|
||||
|
||||
switch (r) {
|
||||
case rgoblin:
|
||||
case GOBLIN:
|
||||
return make_unique<goblin>(rng, enabled_features);
|
||||
|
||||
case rdrow:
|
||||
case DROW:
|
||||
return make_unique<drow>(rng, enabled_features);
|
||||
|
||||
case rshade:
|
||||
case SHADE:
|
||||
return make_unique<shade>(rng, enabled_features);
|
||||
|
||||
case rtroll:
|
||||
case TROLL:
|
||||
return make_unique<troll>(rng, enabled_features);
|
||||
|
||||
case rvampire:
|
||||
case VAMPIRE:
|
||||
return make_unique<vampire>(rng, enabled_features);
|
||||
|
||||
case rt_800:
|
||||
case RT_800:
|
||||
return make_unique<t_800>(rng, enabled_features);
|
||||
|
||||
case rassassin:
|
||||
case ASSASSIN:
|
||||
return make_unique<assassin>(rng, enabled_features);
|
||||
|
||||
case rmonk:
|
||||
case MONK:
|
||||
return make_unique<monk>(rng, enabled_features);
|
||||
|
||||
case rbrawler:
|
||||
case BRAWLER:
|
||||
return make_unique<brawler>(rng, enabled_features);
|
||||
|
||||
case rmr_goose:
|
||||
case MR_GOOSE:
|
||||
return make_unique<mr_goose>(rng, enabled_features);
|
||||
|
||||
default:
|
||||
|
102
src/player.cc
102
src/player.cc
@ -38,7 +38,7 @@ int player_base::get_HP() const {
|
||||
|
||||
long_result player_base::apply(std::unique_ptr<potion> 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<potion> 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<character *>(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<potion> 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<potion> 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<character *>(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<std::unique_ptr<potion>, 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<potion> tmp = std::move(owns[curr]);
|
||||
owns.erase(owns.begin() + curr);
|
||||
@ -289,13 +289,13 @@ std::pair<std::unique_ptr<potion>, 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<potion> tmp = std::move(owns[curr]);
|
||||
owns.erase(owns.begin() + curr);
|
||||
return {std::move(tmp),
|
||||
static_cast<direction>(cmd - throw_north)};
|
||||
static_cast<direction>(cmd - THROW_NORTH)};
|
||||
}
|
||||
|
||||
return {nullptr, DIRECTION_CNT};
|
||||
|
@ -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;
|
||||
|
@ -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, ""};
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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. "};
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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. "};
|
||||
}
|
||||
|
@ -18,47 +18,47 @@
|
||||
|
||||
std::unique_ptr<potion> new_potion(potion_type type, const position &pos) {
|
||||
switch (type) {
|
||||
case restore_health:
|
||||
return std::make_unique<class restore_health>(pos);
|
||||
case RESTORE_HEALTH:
|
||||
return std::make_unique<restore_health>(pos);
|
||||
|
||||
case boost_atk:
|
||||
return std::make_unique<class boost_atk>(pos);
|
||||
case BOOST_ATK:
|
||||
return std::make_unique<boost_atk>(pos);
|
||||
|
||||
case boost_def:
|
||||
return std::make_unique<class boost_def>(pos);
|
||||
case BOOST_DEF:
|
||||
return std::make_unique<boost_def>(pos);
|
||||
|
||||
case poison_health:
|
||||
return std::make_unique<class poison_health>(pos);
|
||||
case POISON_HEALTH:
|
||||
return std::make_unique<poison_health>(pos);
|
||||
|
||||
case wound_atk:
|
||||
return std::make_unique<class wound_atk>(pos);
|
||||
case WOUND_ATK:
|
||||
return std::make_unique<wound_atk>(pos);
|
||||
|
||||
case wound_def:
|
||||
return std::make_unique<class wound_def>(pos);
|
||||
case WOUND_DEF:
|
||||
return std::make_unique<wound_def>(pos);
|
||||
|
||||
case continuous_restoration:
|
||||
return std::make_unique<class continuous_restoration>(pos);
|
||||
case CONTINUOUS_RESTORATION:
|
||||
return std::make_unique<continuous_restoration>(pos);
|
||||
|
||||
case savage_strike:
|
||||
return std::make_unique<class savage_strike>(pos);
|
||||
case SAVAGE_STRIKE:
|
||||
return std::make_unique<savage_strike>(pos);
|
||||
|
||||
case echoing_resilience:
|
||||
return std::make_unique<class echoing_resilience>(pos);
|
||||
case ECHOING_RESIL:
|
||||
return std::make_unique<echoing_resilience>(pos);
|
||||
|
||||
case tempest_tantrum:
|
||||
return std::make_unique<class tempest_tantrum>(pos);
|
||||
case TEMPEST_TANTRUM:
|
||||
return std::make_unique<tempest_tantrum>(pos);
|
||||
|
||||
case bezerk_brew:
|
||||
return std::make_unique<class bezerk_brew>(pos);
|
||||
case BEZERK_BREW:
|
||||
return std::make_unique<bezerk_brew>(pos);
|
||||
|
||||
case borrow_life:
|
||||
return std::make_unique<class borrow_life>(pos);
|
||||
case BORROW_LIFE:
|
||||
return std::make_unique<borrow_life>(pos);
|
||||
|
||||
case fine_booze:
|
||||
return std::make_unique<class fine_booze>(pos);
|
||||
case FINE_BOOZE:
|
||||
return std::make_unique<fine_booze>(pos);
|
||||
|
||||
case ironclad_ward:
|
||||
return std::make_unique<class ironclad_ward>(pos);
|
||||
case IRONCLAD_WARD:
|
||||
return std::make_unique<ironclad_ward>(pos);
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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]);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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]);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user