changes to characters and potions, work in progress
This commit is contained in:
31
src/map.cc
31
src/map.cc
@ -87,16 +87,25 @@ game_map::game_map(const std::string &map_data,
|
||||
room_data.push_back({0, 0, 0, 0});
|
||||
}
|
||||
|
||||
const position_list game_map::get_available_positions() const {
|
||||
return empty_spots;
|
||||
}
|
||||
|
||||
bool game_map::is_available(const position &pos) const {
|
||||
if (pos.x < 0 || pos.x >= MAP_WIDTH || pos.y < 0 || pos.y >= MAP_HEIGHT)
|
||||
return false;
|
||||
|
||||
int idx = remap_position(pos);
|
||||
return map[idx] < MAX_ROOM_CNT || map[idx] == '\\' || map[idx] == '>' ||
|
||||
map[idx] == '<' || map[idx] == '+' || map[idx] == '#';
|
||||
}
|
||||
|
||||
position_list game_map::get_available_around(const position &pos) const {
|
||||
position_list result;
|
||||
|
||||
for (int i = 0; i < DIRECTION_CNT; ++i)
|
||||
if (is_available(pos + MOVE[i]))
|
||||
result.push_back(pos + MOVE[i]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void game_map::print(display *out) const {
|
||||
for (std::size_t i = 0; i < map.size(); ++i)
|
||||
out->print_char(remap_index(i), map[i] <= 9 ? '.' : map[i],
|
||||
@ -132,6 +141,20 @@ position_list game_map::get_room_list(int idx) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<position_list> game_map::get_room_list() const {
|
||||
std::vector<position_list> result;
|
||||
result.reserve(room_data.size());
|
||||
|
||||
for (size_t i = 0; i < room_data.size(); ++i)
|
||||
result.push_back({});
|
||||
|
||||
for (size_t i = 0; i < map.size(); ++i)
|
||||
if (map[i] >= 0 && map[i] < MAX_ROOM_CNT)
|
||||
result[map[i]].push_back(remap_index(i));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<position, int>> game_map::gen_room_dims(RNG *rng) {
|
||||
position_list room_dim_list;
|
||||
room_dim_list.reserve(MAX_ROOM_CNT);
|
||||
|
Reference in New Issue
Block a user