89 bool valid()
const {
return x >= 0 &&
y >= 0; }
91 bool valid(
const int parWidth,
const int parHeight)
const
92 {
return ((
x >= 0) && (
y >= 0) && (
x < parWidth) && (
y < parHeight)); }
94 bool valid(
const int parWidth,
const int parHeight,
const int border)
const
97 bool matches_range(
const std::string& xloc,
const std::string& yloc)
const;
123 y += ((
x & 1) && (a.
x & 1));
159 void add(
int x_diff,
int y_diff) {
x += x_diff;
y += y_diff; }
205 std::ostream &
operator<<(std::ostream &
s,
const std::vector<map_location>& v);
213 return (l.wml_x()) * 16384 + (l.wml_y()) + 2000;
A config object defines a single node in a WML file, with access to child nodes.
@ border
The border of the map.
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
std::size_t distance_between(const map_location &a, const map_location &b)
Function which gives the number of hexes between two tiles (i.e.
void write_locations(const std::vector< map_location > &locs, config &cfg)
Write a vector of locations into a config adding keys x=x1,x2,..,xn and y=y1,y2,.....
std::ostream & operator<<(std::ostream &s, const map_location &l)
Dumps a position on a stream, for debug purposes.
void read_locations(const config &cfg, std::vector< map_location > &locs)
Parse x,y keys of a config into a vector of locations.
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
void write_location_range(const std::set< map_location > &locs, config &cfg)
Write a set of locations into a config using ranges, adding keys x=x1,..,xn and y=y1a-y1b,...
Encapsulates the map of the game.
map_location & vector_sum_assign(const map_location &a)
map_location & vector_difference_assign(const map_location &a)
static DIRECTION parse_direction(const std::string &str)
bool valid(const int parWidth, const int parHeight) const
map_location vector_negation() const
static const std::vector< DIRECTION > & default_dirs()
Default list of directions.
std::pair< int, int > get_in_basis_N_NE() const
static DIRECTION rotate_right(DIRECTION d, signed int k)
map_location(int x, int y)
void add(int x_diff, int y_diff)
DIRECTION
Valid directions which can be moved in our hexagonal world.
friend std::size_t hash_value(const map_location &a)
map_location get_direction(DIRECTION dir, unsigned int n=1u) const
bool operator==(const map_location &a) const
static std::vector< DIRECTION > parse_directions(const std::string &str)
Parse_directions takes a comma-separated list, and filters out any invalid directions.
map_location vector_sum(const map_location &a) const
DIRECTION get_relative_dir(const map_location &loc, map_location::RELATIVE_DIR_MODE mode) const
map_location rotate_right_around_center(const map_location ¢er, int k) const
bool operator!=(const map_location &a) const
bool operator<(const map_location &a) const
static DIRECTION rotate_right(DIRECTION d, unsigned int k=1u)
bool valid(const int parWidth, const int parHeight, const int border) const
static const map_location & null_location()
map_location(int x, int y, wml_loc)
static std::string write_translated_direction(DIRECTION dir)
map_location get_direction(DIRECTION dir, signed int n) const
void write(config &cfg) const
bool matches_range(const std::string &xloc, const std::string &yloc) const
static DIRECTION get_opposite_dir(DIRECTION d)
map_location plus(int x_diff, int y_diff) const
int do_compare(const map_location &a) const
three-way comparator
static const map_location & ZERO()
static std::string write_direction(DIRECTION dir)
std::size_t operator()(const map_location &l) const noexcept
static map_location::DIRECTION n
static map_location::DIRECTION s