removed all C-style casts
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
########## Variables ##########
|
########## Variables ##########
|
||||||
|
|
||||||
CXX = g++ # compiler
|
CXX = g++ # compiler
|
||||||
CXXFLAGS = -std=c++20 -g -Wall -MMD -O0 # compiler flags
|
CXXFLAGS = -std=c++20 -g -Wall -Wold-style-cast -MMD -O0 # compiler flags
|
||||||
MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} # makefile name
|
MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} # makefile name
|
||||||
|
|
||||||
SOURCES = $(wildcard *.cc) $(wildcard */*.cc) # source files (*.cc)
|
SOURCES = $(wildcard *.cc) $(wildcard */*.cc) # source files (*.cc)
|
||||||
|
@ -25,9 +25,10 @@ game_status CC3K::run() {
|
|||||||
|
|
||||||
if (tmp != -1) {
|
if (tmp != -1) {
|
||||||
curr_menu.reset();
|
curr_menu.reset();
|
||||||
curr_game = std::make_unique<game>((race)tmp,
|
curr_game =
|
||||||
enabled_features,
|
std::make_unique<game>(static_cast<race>(tmp),
|
||||||
in, out, rng);
|
enabled_features,
|
||||||
|
in, out, rng);
|
||||||
out->clear();
|
out->clear();
|
||||||
curr_game->print();
|
curr_game->print();
|
||||||
out->render();
|
out->render();
|
||||||
|
@ -46,39 +46,46 @@ enum game_command : int {game_command_terminate = 0,
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Character generation related
|
// Character generation related
|
||||||
static const int RACE_CNT = 17;
|
static const int RACE_CNT = 23;
|
||||||
enum race : int {rshade = 0, rdrow, rvampire, rtroll,
|
enum race : int {rshade = 0, rdrow, rvampire, rtroll,
|
||||||
rgoblin, rhuman, rdwarf, relf,
|
rgoblin, rhuman, rdwarf, relf,
|
||||||
rorc, rmerchant, rdragon, rhalfling,
|
rorc, rmerchant, rdragon, rhalfling,
|
||||||
rt_800, rmr_goose, rmonk, rbrawler,
|
rt_800, rmr_goose, rmonk, rbrawler,
|
||||||
rassassin
|
rassassin, rviking, rswordsman,
|
||||||
|
rleprechaun, rwitch, rhacker, rbaby_dragon
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char CHAR_REP[RACE_CNT] = {
|
static const char CHAR_REP[RACE_CNT] = {
|
||||||
's', 'd', 'v', 't', 'g', 'H', 'W', 'E', 'O', 'M', 'D', 'L',
|
's', 'd', 'v', 't', 'g', 'H', 'W', 'E', 'O', 'M', 'D', 'L',
|
||||||
't', 'g', 'm', 'b', 'a'
|
't', 'g', 'm', 'b', 'a',
|
||||||
|
'V', 'S', 'l', 'W', 'h', 'B'
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int MAX_HP[RACE_CNT] = {
|
static const int MAX_HP[RACE_CNT] = {
|
||||||
125, 150, INF, 120, 110, 140, 100, 140, 180, 30, 150, 100,
|
125, 150, INF, 120, 110, 140, 100, 140, 180, 30, 150, 100,
|
||||||
800, 130, 150, 120, 100
|
800, 130, 150, 120, 100,
|
||||||
|
150, 100, 60, 100, 90, 140
|
||||||
};
|
};
|
||||||
static const int STARTING_HP[RACE_CNT] = {
|
static const int STARTING_HP[RACE_CNT] = {
|
||||||
125, 150, 50, 120, 110, 140, 100, 140, 180, 30, 150, 100,
|
125, 150, 50, 120, 110, 140, 100, 140, 180, 30, 150, 100,
|
||||||
800, 130, 150, 120, 100
|
800, 130, 150, 120, 100,
|
||||||
|
150, 100, 60, 100, 90, 140
|
||||||
};
|
};
|
||||||
static const int STARTING_ATK[RACE_CNT] = {
|
static const int STARTING_ATK[RACE_CNT] = {
|
||||||
25, 25, 25, 25, 15, 20, 20, 30, 30, 70, 20, 15,
|
25, 25, 25, 25, 15, 20, 20, 30, 30, 70, 20, 15,
|
||||||
40, 25, 80, 15, 30
|
40, 25, 80, 15, 30,
|
||||||
|
30, 25, 10, 20, 15, 25
|
||||||
};
|
};
|
||||||
static const int STARTING_DEF[RACE_CNT] = {
|
static const int STARTING_DEF[RACE_CNT] = {
|
||||||
25, 15, 25, 15, 20, 20, 30, 10, 25, 5, 20, 20,
|
25, 15, 25, 15, 20, 20, 30, 10, 25, 5, 20, 20,
|
||||||
50, 20, 0, 20, 10
|
50, 20, 0, 20, 10,
|
||||||
|
25, 15, 15, 15, 30, 40
|
||||||
};
|
};
|
||||||
static const fraction STARTING_HR[RACE_CNT] = {
|
static const fraction STARTING_HR[RACE_CNT] = {
|
||||||
{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
|
{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
|
||||||
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
|
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
|
||||||
{1, 1}, {1, 1}, {100, 1}, {3, 4}, {1, 1}
|
{1, 1}, {1, 1}, {100, 1}, {3, 4}, {1, 1},
|
||||||
|
{1, 3}, {1, 1}, {1, 2}, {1, 2}, {1, 2}, {1, 3}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,6 @@ dragon::dragon(RNG *rng, const feature enabled_features, const position &pos,
|
|||||||
const int gen_room_num):
|
const int gen_room_num):
|
||||||
enemy_base{rng, enabled_features, rdragon, pos, gen_room_num, "D"} {}
|
enemy_base{rng, enabled_features, rdragon, pos, gen_room_num, "D"} {}
|
||||||
|
|
||||||
void dragon::print(output *out) {
|
|
||||||
out->print_char(pos, 'D', COLOR_PAIR(COLOR_RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *dragon::get_race_name() const {
|
const char *dragon::get_race_name() const {
|
||||||
return "Dragon";
|
return "Dragon";
|
||||||
}
|
}
|
||||||
@ -20,3 +16,7 @@ long_result dragon::act(level *lvl, character *pc, bool hostile) {
|
|||||||
|
|
||||||
return {fine, ""};
|
return {fine, ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dragon::dies(level *lvl) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -7,9 +7,9 @@ class dragon final: public enemy_base {
|
|||||||
public:
|
public:
|
||||||
dragon(RNG *rng, const feature enabled_features, const position &pos,
|
dragon(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num);
|
const int gen_room_num);
|
||||||
void print(output *out) override;
|
|
||||||
const char *get_race_name() const override;
|
const char *get_race_name() const override;
|
||||||
long_result act(level *lvl, character *pc, bool hostile) override;
|
long_result act(level *lvl, character *pc, bool hostile) override;
|
||||||
|
int dies(level *lvl) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,10 +6,6 @@ dwarf::dwarf(RNG *rng, const feature enabled_features, const position &pos,
|
|||||||
const int gen_room_num):
|
const int gen_room_num):
|
||||||
enemy_base{rng, enabled_features, rdwarf, pos, gen_room_num, "W"} {}
|
enemy_base{rng, enabled_features, rdwarf, pos, gen_room_num, "W"} {}
|
||||||
|
|
||||||
void dwarf::print(output *out) {
|
|
||||||
out->print_char(pos, 'W', COLOR_PAIR(COLOR_RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *dwarf::get_race_name() const {
|
const char *dwarf::get_race_name() const {
|
||||||
return "Dwarf";
|
return "Dwarf";
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ class dwarf final: public enemy_base {
|
|||||||
public:
|
public:
|
||||||
dwarf(RNG *rng, const feature enabled_features, const position &pos,
|
dwarf(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num);
|
const int gen_room_num);
|
||||||
void print(output *out) override;
|
|
||||||
const char *get_race_name() const override;
|
const char *get_race_name() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,10 +6,6 @@ elf::elf(RNG *rng, const feature enabled_features, const position &pos,
|
|||||||
const int gen_room_num):
|
const int gen_room_num):
|
||||||
enemy_base{rng, enabled_features, relf, pos, gen_room_num, "E"} {}
|
enemy_base{rng, enabled_features, relf, pos, gen_room_num, "E"} {}
|
||||||
|
|
||||||
void elf::print(output *out) {
|
|
||||||
out->print_char(pos, 'E', COLOR_PAIR(COLOR_RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *elf::get_race_name() const {
|
const char *elf::get_race_name() const {
|
||||||
return "Elf";
|
return "Elf";
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ class elf final: public enemy_base {
|
|||||||
public:
|
public:
|
||||||
elf(RNG *rng, const feature enabled_features, const position &pos,
|
elf(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num);
|
const int gen_room_num);
|
||||||
void print(output *out) override;
|
|
||||||
const char *get_race_name() const override;
|
const char *get_race_name() const override;
|
||||||
long_result attack(character *ch) override;
|
long_result attack(character *ch) override;
|
||||||
};
|
};
|
||||||
|
@ -9,10 +9,6 @@ halfling::halfling(RNG *rng, const feature enabled_features,
|
|||||||
const int gen_room_num):
|
const int gen_room_num):
|
||||||
enemy_base{rng, enabled_features, rhalfling, pos, gen_room_num, "L"} {}
|
enemy_base{rng, enabled_features, rhalfling, pos, gen_room_num, "L"} {}
|
||||||
|
|
||||||
void halfling::print(output *out) {
|
|
||||||
out->print_char(pos, 'L', COLOR_PAIR(COLOR_RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *halfling::get_race_name() const {
|
const char *halfling::get_race_name() const {
|
||||||
return "Halfling";
|
return "Halfling";
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,9 @@ class halfling final: public enemy_base {
|
|||||||
public:
|
public:
|
||||||
halfling(RNG *rng, const feature enabled_features, const position &pos,
|
halfling(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num);
|
const int gen_room_num);
|
||||||
void print(output *out) override;
|
|
||||||
const char *get_race_name() const override;
|
const char *get_race_name() const override;
|
||||||
long_result get_hit(character *ch, const int tATK,
|
long_result get_hit(character *ch, const int tATK,
|
||||||
const fraction &hit_rate);
|
const fraction &hit_rate) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
#include "human.h"
|
#include "human.h"
|
||||||
|
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
#include "../level.h"
|
||||||
|
|
||||||
human::human(RNG *rng, const feature enabled_features, const position &pos,
|
human::human(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num):
|
const int gen_room_num):
|
||||||
enemy_base{rng, enabled_features, rhuman, pos, gen_room_num, "H"} {}
|
enemy_base{rng, enabled_features, rhuman, pos, gen_room_num, "H"} {}
|
||||||
|
|
||||||
void human::print(output *out) {
|
|
||||||
out->print_char(pos, 'H', COLOR_PAIR(COLOR_RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *human::get_race_name() const {
|
const char *human::get_race_name() const {
|
||||||
return "Human";
|
return "Human";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int human::dies(level *lvl) {
|
||||||
|
lvl->add_gold(gold{pos, GOLD_NORMAL});
|
||||||
|
auto plist = lvl->get_available_around_all(pos);
|
||||||
|
lvl->add_gold(gold{rng->get_rand_in_vector(plist), GOLD_NORMAL});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -7,8 +7,8 @@ class human final: public enemy_base {
|
|||||||
public:
|
public:
|
||||||
human(RNG *rng, const feature enabled_features, const position &pos,
|
human(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num);
|
const int gen_room_num);
|
||||||
void print(output *out) override;
|
|
||||||
const char *get_race_name() const override;
|
const char *get_race_name() const override;
|
||||||
|
int dies(level *lvl) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
32
src/enemies/leprechaun.cc
Normal file
32
src/enemies/leprechaun.cc
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "leprechaun.h"
|
||||||
|
|
||||||
|
#include "../constants.h"
|
||||||
|
#include "../player.h"
|
||||||
|
|
||||||
|
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"} {}
|
||||||
|
|
||||||
|
const char *leprechaun::get_race_name() const {
|
||||||
|
return "Leprechaun";
|
||||||
|
}
|
||||||
|
|
||||||
|
long_result leprechaun::attack(character *ch) {
|
||||||
|
long_result res;
|
||||||
|
|
||||||
|
if (static_cast<player_base * >(ch)->get_gold() < STEAL_GOLD) {
|
||||||
|
res = ch->get_hit(this, BOOSTED_ATK, base_hit_rate);
|
||||||
|
res.msg = "l is angered because PC is too poor. " + res.msg;
|
||||||
|
} else {
|
||||||
|
res = ch->get_hit(this, ATK, base_hit_rate);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
18
src/enemies/leprechaun.h
Normal file
18
src/enemies/leprechaun.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __LEPRECHAUN_H__
|
||||||
|
#define __LEPRECHAUN_H__
|
||||||
|
|
||||||
|
#include "../enemy.h"
|
||||||
|
|
||||||
|
class leprechaun final: public enemy_base {
|
||||||
|
static const int STEAL_GOLD = 3;
|
||||||
|
static const int BOOSTED_ATK = 30;
|
||||||
|
static const int STARTING_GOLD = 5;
|
||||||
|
int gold_cnt;
|
||||||
|
public:
|
||||||
|
leprechaun(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
|
const int gen_room_num);
|
||||||
|
const char *get_race_name() const override;
|
||||||
|
virtual long_result attack(character *ch) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,15 +1,18 @@
|
|||||||
#include "merchant.h"
|
#include "merchant.h"
|
||||||
|
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
#include "../gold.h"
|
||||||
|
#include "../level.h"
|
||||||
|
|
||||||
merchant::merchant(RNG *rng, const feature enabled_features,
|
merchant::merchant(RNG *rng, const feature enabled_features,
|
||||||
const position &pos, const int gen_room_num):
|
const position &pos, const int gen_room_num):
|
||||||
enemy_base{rng, enabled_features, rmerchant, pos, gen_room_num, "M"} {}
|
enemy_base{rng, enabled_features, rmerchant, pos, gen_room_num, "M"} {}
|
||||||
|
|
||||||
void merchant::print(output *out) {
|
|
||||||
out->print_char(pos, 'M', COLOR_PAIR(COLOR_RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *merchant::get_race_name() const {
|
const char *merchant::get_race_name() const {
|
||||||
return "Merchant";
|
return "Merchant";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int merchant::dies(level *lvl) {
|
||||||
|
lvl->add_gold(gold{pos, GOLD_MERCHANT});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -7,8 +7,8 @@ class merchant final: public enemy_base {
|
|||||||
public:
|
public:
|
||||||
merchant(RNG *rng, const feature enabled_features, const position &pos,
|
merchant(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num);
|
const int gen_room_num);
|
||||||
void print(output *out) override;
|
|
||||||
const char *get_race_name() const override;
|
const char *get_race_name() const override;
|
||||||
|
int dies(level *lvl) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,10 +6,6 @@ orc::orc(RNG *rng, const feature enabled_features, const position &pos,
|
|||||||
const int gen_room_num):
|
const int gen_room_num):
|
||||||
enemy_base{rng, enabled_features, rorc, pos, gen_room_num, "O"} {}
|
enemy_base{rng, enabled_features, rorc, pos, gen_room_num, "O"} {}
|
||||||
|
|
||||||
void orc::print(output *out) {
|
|
||||||
out->print_char(pos, 'O', COLOR_PAIR(COLOR_RED));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *orc::get_race_name() const {
|
const char *orc::get_race_name() const {
|
||||||
return "Orc";
|
return "Orc";
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ class orc final: public enemy_base {
|
|||||||
public:
|
public:
|
||||||
orc(RNG *rng, const feature enabled_features, const position &pos,
|
orc(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
const int gen_room_num);
|
const int gen_room_num);
|
||||||
void print(output *out) override;
|
|
||||||
const char *get_race_name() const override;
|
const char *get_race_name() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
12
src/enemies/swordsman.cc
Normal file
12
src/enemies/swordsman.cc
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "swordsman.h"
|
||||||
|
|
||||||
|
#include "../constants.h"
|
||||||
|
|
||||||
|
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"} {}
|
||||||
|
|
||||||
|
const char *swordsman::get_race_name() const {
|
||||||
|
return "Swordsman";
|
||||||
|
}
|
13
src/enemies/swordsman.h
Normal file
13
src/enemies/swordsman.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef __SWORDSMAN_H__
|
||||||
|
#define __SWORDSMAN_H__
|
||||||
|
|
||||||
|
#include "../enemy.h"
|
||||||
|
|
||||||
|
class swordsman final: public enemy_base {
|
||||||
|
public:
|
||||||
|
swordsman(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
|
const int gen_room_num);
|
||||||
|
const char *get_race_name() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
27
src/enemies/viking.cc
Normal file
27
src/enemies/viking.cc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "viking.h"
|
||||||
|
|
||||||
|
#include "../constants.h"
|
||||||
|
|
||||||
|
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"} {}
|
||||||
|
|
||||||
|
const char *viking::get_race_name() const {
|
||||||
|
return "Viking";
|
||||||
|
}
|
||||||
|
|
||||||
|
long_result viking::attack(character *ch) {
|
||||||
|
auto res1 = ch->get_hit(this, ATK, base_hit_rate);
|
||||||
|
|
||||||
|
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};
|
||||||
|
else
|
||||||
|
return {hit, res1.msg + res2.msg};
|
||||||
|
}
|
14
src/enemies/viking.h
Normal file
14
src/enemies/viking.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef __VIKING_H__
|
||||||
|
#define __VIKING_H__
|
||||||
|
|
||||||
|
#include "../enemy.h"
|
||||||
|
|
||||||
|
class viking final: public enemy_base {
|
||||||
|
public:
|
||||||
|
viking(RNG *rng, const feature enabled_features, const position &pos,
|
||||||
|
const int gen_room_num);
|
||||||
|
const char *get_race_name() const override;
|
||||||
|
long_result attack(character *ch) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
16
src/enemy.cc
16
src/enemy.cc
@ -87,18 +87,6 @@ long_result enemy_base::get_hit(character *ch, const int tATK,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int enemy_base::dies(level *lvl) {
|
int enemy_base::dies(level *lvl) {
|
||||||
if (race == race::rdragon) {
|
|
||||||
return 0;
|
|
||||||
} else if (race == race::rmerchant) {
|
|
||||||
lvl->add_gold(gold{pos, GOLD_MERCHANT});
|
|
||||||
return 0;
|
|
||||||
} else if (race == race::rhuman) {
|
|
||||||
lvl->add_gold(gold{pos, GOLD_NORMAL});
|
|
||||||
auto plist = lvl->get_available_around_all(pos);
|
|
||||||
lvl->add_gold(gold{rng->get_rand_in_vector(plist), GOLD_NORMAL});
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rand_gold_drop(rng);
|
return rand_gold_drop(rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,3 +97,7 @@ enemy_base *get_enemy_at(const position &pos, const enemy_list &elist) {
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enemy_base::print(output *out) {
|
||||||
|
out->print_char(pos, CHAR_REP[race], COLOR_PAIR(COLOR_RED));
|
||||||
|
}
|
||||||
|
@ -24,6 +24,8 @@ public:
|
|||||||
virtual long_result get_hit(character *ch, const int tATK,
|
virtual long_result get_hit(character *ch, const int tATK,
|
||||||
const fraction &hit_rate) override;
|
const fraction &hit_rate) override;
|
||||||
|
|
||||||
|
void print(output *out) override;
|
||||||
|
|
||||||
virtual std::string get_abbrev() const override;
|
virtual std::string get_abbrev() const override;
|
||||||
|
|
||||||
virtual int dies(level *lvl);
|
virtual int dies(level *lvl);
|
||||||
|
@ -33,7 +33,7 @@ fraction &fraction::simplify() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float fraction::real() const {
|
float fraction::real() const {
|
||||||
return (float)numerator / denominator;
|
return static_cast<float>(numerator) / denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fraction::gcd(int a, int b) {
|
int fraction::gcd(int a, int b) {
|
||||||
|
@ -178,7 +178,7 @@ game_result game::run() {
|
|||||||
if (killer == nullptr)
|
if (killer == nullptr)
|
||||||
return {dead, "You died: killed by your own stupidity!"};
|
return {dead, "You died: killed by your own stupidity!"};
|
||||||
|
|
||||||
return {dead, (std::string)"You died: killed by a(n) " +
|
return {dead, std::string{"You died: killed by a(n) "} +
|
||||||
killer->get_race_name()};
|
killer->get_race_name()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ const int COMMANDS_CNT = 8;
|
|||||||
game_command get_direction(std::string &str) {
|
game_command get_direction(std::string &str) {
|
||||||
for (int i = 0; i < COMMANDS_CNT; ++i)
|
for (int i = 0; i < COMMANDS_CNT; ++i)
|
||||||
if (str == COMMANDS[i])
|
if (str == COMMANDS[i])
|
||||||
return (game_command)i;
|
return static_cast<game_command>(i);
|
||||||
|
|
||||||
return game_command_panic;
|
return game_command_panic;
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,14 @@ game_command console_input::get_command() {
|
|||||||
auto tmp = get_direction(cmd);
|
auto tmp = get_direction(cmd);
|
||||||
|
|
||||||
if (cmdtmp == "u")
|
if (cmdtmp == "u")
|
||||||
return (game_command)(tmp + apply_north);
|
return static_cast<game_command>
|
||||||
|
(tmp + apply_north);
|
||||||
else if (cmdtmp == "a")
|
else if (cmdtmp == "a")
|
||||||
return (game_command)(tmp + attack_north);
|
return static_cast<game_command>
|
||||||
|
(tmp + attack_north);
|
||||||
else
|
else
|
||||||
return (game_command)(tmp + throw_north);
|
return static_cast<game_command>
|
||||||
|
(tmp + throw_north);
|
||||||
} else if (cmd == "yes") {
|
} else if (cmd == "yes") {
|
||||||
return game_command::enter;
|
return game_command::enter;
|
||||||
} else if (cmd == "i") {
|
} else if (cmd == "i") {
|
||||||
@ -43,7 +46,8 @@ game_command console_input::get_command() {
|
|||||||
auto tmp = get_direction(cmd);
|
auto tmp = get_direction(cmd);
|
||||||
|
|
||||||
if (tmp != game_command_panic)
|
if (tmp != game_command_panic)
|
||||||
return (game_command)(tmp + move_north);
|
return static_cast<game_command>
|
||||||
|
(tmp + move_north);
|
||||||
}
|
}
|
||||||
|
|
||||||
return game_command_pass;
|
return game_command_pass;
|
||||||
|
@ -68,28 +68,36 @@ game_command curses_input::get_command() {
|
|||||||
|
|
||||||
switch (curse->getcmd()) {
|
switch (curse->getcmd()) {
|
||||||
case 'h':
|
case 'h':
|
||||||
return (game_command)(tmp + west);
|
return static_cast<game_command>
|
||||||
|
(tmp + west);
|
||||||
|
|
||||||
case 'j':
|
case 'j':
|
||||||
return (game_command)(tmp + south);
|
return static_cast<game_command>
|
||||||
|
(tmp + south);
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
return (game_command)(tmp + north);
|
return static_cast<game_command>
|
||||||
|
(tmp + north);
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
return (game_command)(tmp + east);
|
return static_cast<game_command>
|
||||||
|
(tmp + east);
|
||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
return (game_command)(tmp + northwest);
|
return static_cast<game_command>
|
||||||
|
(tmp + northwest);
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
return (game_command)(tmp + northeast);
|
return static_cast<game_command>
|
||||||
|
(tmp + northeast);
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
return (game_command)(tmp + southwest);
|
return static_cast<game_command>
|
||||||
|
(tmp + southwest);
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
return (game_command)(tmp + southeast);
|
return static_cast<game_command>
|
||||||
|
(tmp + southeast);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return game_command_panic;
|
return game_command_panic;
|
||||||
|
@ -30,11 +30,11 @@ game_command file_input::get_command() {
|
|||||||
auto tmp = get_direction(cmd);
|
auto tmp = get_direction(cmd);
|
||||||
|
|
||||||
if (cmdtmp == "u")
|
if (cmdtmp == "u")
|
||||||
return (game_command)(tmp + apply_north);
|
return static_cast<game_command>(tmp + apply_north);
|
||||||
else if (cmdtmp == "a")
|
else if (cmdtmp == "a")
|
||||||
return (game_command)(tmp + attack_north);
|
return static_cast<game_command>(tmp + attack_north);
|
||||||
else
|
else
|
||||||
return (game_command)(tmp + throw_north);
|
return static_cast<game_command>(tmp + throw_north);
|
||||||
} else if (cmd == "yes") {
|
} else if (cmd == "yes") {
|
||||||
return game_command::enter;
|
return game_command::enter;
|
||||||
} else if (cmd == "i") {
|
} else if (cmd == "i") {
|
||||||
@ -43,7 +43,8 @@ game_command file_input::get_command() {
|
|||||||
auto tmp = get_direction(cmd);
|
auto tmp = get_direction(cmd);
|
||||||
|
|
||||||
if (tmp != game_command_panic)
|
if (tmp != game_command_panic)
|
||||||
return tmp;
|
return static_cast<game_command>
|
||||||
|
(tmp + move_north);
|
||||||
}
|
}
|
||||||
|
|
||||||
return game_command_pass;
|
return game_command_pass;
|
||||||
|
@ -136,7 +136,8 @@ void level::gen_potions(RNG *rng, std::vector<position_list> &tiles) {
|
|||||||
pplist.reserve(cnt);
|
pplist.reserve(cnt);
|
||||||
|
|
||||||
for (int i = 0; i < cnt; ++i) {
|
for (int i = 0; i < cnt; ++i) {
|
||||||
pplist.push_back(new_potion((potion_type)rng->rand_under(max_type),
|
pplist.push_back(new_potion(static_cast<potion_type>
|
||||||
|
(rng->rand_under(max_type)),
|
||||||
get_rand_pos(rng, tiles)));
|
get_rand_pos(rng, tiles)));
|
||||||
plist.push_back(pplist[i].get());
|
plist.push_back(pplist[i].get());
|
||||||
}
|
}
|
||||||
|
@ -269,8 +269,8 @@ std::vector<game_map::room> game_map::distr_rooms(RNG *rng,
|
|||||||
// and the max height of the layer
|
// and the max height of the layer
|
||||||
for (std::size_t i = 0; i < room_dims.size(); ++i)
|
for (std::size_t i = 0; i < room_dims.size(); ++i)
|
||||||
if (room_dims[i].second == layer) {
|
if (room_dims[i].second == layer) {
|
||||||
l = std::min(l, (int)i);
|
l = std::min(l, static_cast<int>(i));
|
||||||
r = std::max(r, (int)i);
|
r = std::max(r, static_cast<int>(i));
|
||||||
layer_height = std::max(layer_height,
|
layer_height = std::max(layer_height,
|
||||||
room_dims[i].first.y);
|
room_dims[i].first.y);
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ std::vector<game_map::room> game_map::distr_rooms(RNG *rng,
|
|||||||
if (l == r) {
|
if (l == r) {
|
||||||
result.push_back({
|
result.push_back({
|
||||||
0, rng->rand_under(ACTUAL_MAP_WIDTH -
|
0, rng->rand_under(ACTUAL_MAP_WIDTH -
|
||||||
room_dims[l].first.x + 1),
|
room_dims[l].first.x + 1),
|
||||||
room_dims[l].first.x,
|
room_dims[l].first.x,
|
||||||
room_dims[l].first.y, {0, 0}, {0, 0}});
|
room_dims[l].first.y, {0, 0}, {0, 0}});
|
||||||
continue;
|
continue;
|
||||||
|
@ -74,7 +74,7 @@ void console_output::render() {
|
|||||||
out << std::endl;
|
out << std::endl;
|
||||||
|
|
||||||
out << get_code(contents[idx])
|
out << get_code(contents[idx])
|
||||||
<< (char)(contents[idx] ? contents[idx] : ' ');
|
<< static_cast<char>(contents[idx] ? contents[idx] : ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
|
@ -12,7 +12,7 @@ void file_output::render() {
|
|||||||
if (idx % DISPLAY_WIDTH == 0 && idx)
|
if (idx % DISPLAY_WIDTH == 0 && idx)
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
|
|
||||||
out << (char)(contents[idx] ? contents[idx] : ' ');
|
out << static_cast<char>(contents[idx] ? contents[idx] : ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
|
@ -72,7 +72,7 @@ long_result player_base::move(level *lvl,
|
|||||||
pos = p;
|
pos = p;
|
||||||
return {result::moved, ""};
|
return {result::moved, ""};
|
||||||
} else if ((tmp = get_enemy_at(p, lvl->get_elist())) != nullptr) {
|
} else if ((tmp = get_enemy_at(p, lvl->get_elist())) != nullptr) {
|
||||||
auto res = attack((character *)tmp);
|
auto res = attack(static_cast<character *>(tmp));
|
||||||
|
|
||||||
if (tmp->is_dead()) {
|
if (tmp->is_dead()) {
|
||||||
int g = tmp->dies(lvl);
|
int g = tmp->dies(lvl);
|
||||||
@ -170,7 +170,7 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) {
|
|||||||
} else {
|
} else {
|
||||||
inv.enabled = false;
|
inv.enabled = false;
|
||||||
return throw_potion(lvl, std::move(res.first),
|
return throw_potion(lvl, std::move(res.first),
|
||||||
(direction)res.second);
|
static_cast<direction>(res.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) {
|
|||||||
enemy_base *tmp = get_enemy_at(pos + MOVE[cmd - attack_north],
|
enemy_base *tmp = get_enemy_at(pos + MOVE[cmd - attack_north],
|
||||||
lvl->get_elist());
|
lvl->get_elist());
|
||||||
|
|
||||||
auto res = attack((character *)tmp);
|
auto res = attack(static_cast<character *>(tmp));
|
||||||
|
|
||||||
if (tmp != nullptr && tmp->is_dead()) {
|
if (tmp != nullptr && tmp->is_dead()) {
|
||||||
int g = tmp->dies(lvl);
|
int g = tmp->dies(lvl);
|
||||||
@ -284,7 +284,8 @@ std::pair<std::unique_ptr<potion>, int> player_base::inventory::run(
|
|||||||
if (owns.size()) {
|
if (owns.size()) {
|
||||||
std::unique_ptr<potion> tmp = std::move(owns[curr]);
|
std::unique_ptr<potion> tmp = std::move(owns[curr]);
|
||||||
owns.erase(owns.begin() + curr);
|
owns.erase(owns.begin() + curr);
|
||||||
return {std::move(tmp), (direction)(cmd - throw_north)};
|
return {std::move(tmp),
|
||||||
|
static_cast<direction>(cmd - throw_north)};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {nullptr, DIRECTION_CNT};
|
return {nullptr, DIRECTION_CNT};
|
||||||
@ -322,14 +323,14 @@ void player_base::inventory::print(output *out, unsigned long known_potions) {
|
|||||||
|
|
||||||
for (size_t i = 0; i < owns.size(); ++i) {
|
for (size_t i = 0; i < owns.size(); ++i) {
|
||||||
out->print_str({INV_LEFT + INV_POTION_OFFSET,
|
out->print_str({INV_LEFT + INV_POTION_OFFSET,
|
||||||
(int) i + INV_TOP + INV_Y_OFFSET},
|
static_cast<int>(i) + INV_TOP + INV_Y_OFFSET},
|
||||||
"potion of " +
|
"potion of " +
|
||||||
(known_potions & (1 << owns[i]->get_type()) ?
|
(known_potions & (1 << owns[i]->get_type()) ?
|
||||||
owns[i]->get_name() : (std::string)"??"));
|
owns[i]->get_name() : std::string{"??"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owns.size())
|
if (owns.size())
|
||||||
out->print_str({INV_LEFT + INV_CURSOR_OFFSET,
|
out->print_str({INV_LEFT + INV_CURSOR_OFFSET,
|
||||||
(int)curr + INV_TOP + INV_Y_OFFSET},
|
static_cast<int>(curr) + INV_TOP + INV_Y_OFFSET},
|
||||||
"->");
|
"->");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user