12#include "game/player.h"
17 using blocks_t = int32_t;
20 constexpr blocks_t REGION_W = 8;
23 constexpr blocks_t REGION_H = 8;
25 using RegionSetBacking = uint16_t;
28 enum class RegionSet : RegionSetBacking {
34 RED = 1 << (8 + *PlayerColor::RED),
35 BLUE = 1 << (8 + *PlayerColor::BLUE),
36 GREEN = 1 << (8 + *PlayerColor::GREEN),
37 AQUA = 1 << (8 + *PlayerColor::AQUA),
38 YELLOW = 1 << (8 + *PlayerColor::YELLOW),
39 WHITE = 1 << (8 + *PlayerColor::WHITE),
40 BLACK = 1 << (8 + *PlayerColor::BLACK),
41 PINK = 1 << (8 + *PlayerColor::PINK),
46 inline RegionSet operator|(RegionSet lhs, RegionSet rhs) {
47 return static_cast<RegionSet
>(
static_cast<RegionSetBacking
>(lhs)
48 |
static_cast<RegionSetBacking
>(rhs));
51 inline void operator|=(RegionSet& lhs, RegionSet rhs) {
58 using std::runtime_error::runtime_error;
64 std::shared_ptr<Grid<RegionSet>> grid;
71 Map(std::shared_ptr<Grid<RegionSet>> grid);
74 const Grid<RegionSet>&
backing()
const override;
83 bool update_region(blocks_t x, blocks_t y, RegionSet regions);
90 RegionSet
regions_at(blocks_t x, blocks_t y)
const;
97 static std::unique_ptr<Map>
load_from(
const std::string& path);
100 namespace RegionSetHelper {
102 RegionSet from(PlayerColor color);
105 RegionSet from(
char value);
RegionSet regions_at(blocks_t x, blocks_t y) const
Definition map.cpp:27
bool update_region(blocks_t x, blocks_t y, RegionSet regions)
Definition map.cpp:17
static std::unique_ptr< Map > load_from(const std::string &path)
Definition map.cpp:36
const Grid< RegionSet > & backing() const override
Definition map.cpp:13