#include "Map.h"

Map::Map() {
    reset();
}

void Map::reset() {
    for (int i = 0; i < MAP_CELL_NUM; i++) {
        for (int j = 0; j < MAP_CELL_NUM; j++) {
            if (i == 0 || i == MAP_CELL_NUM - 1 || j == 0 || j == MAP_CELL_NUM - 1)
                grid[i][j] = WALL;
            else
                grid[i][j] = BLANK;
        }
    }
}

CELL_Type Map::get(int x, int y) const {
    return static_cast<CELL_Type>(grid[x][y]);
}

void Map::set(int x, int y, CELL_Type type) {
    grid[x][y] = type;
}

CELL_Type Map::peek(int x, int y, Direction dir) const {
    switch (dir) {
        case UP:    return static_cast<CELL_Type>(grid[x][y - 1]);
        case DOWN:  return static_cast<CELL_Type>(grid[x][y + 1]);
        case LEFT:  return static_cast<CELL_Type>(grid[x - 1][y]);
        case RIGHT: return static_cast<CELL_Type>(grid[x + 1][y]);
    }
    return BLANK;
}
