//
// Created by m on 12/14/21.
//

#include "tilemap.hpp"
#include "../engine/utility/point.hpp"
#include "../engine/modules/logger.hpp"
#include <fmt/format.h>

void TileMap::draw_floor(int x, int y) {
    Logger::log(LogLevel::DEBUG, fmt::format("Drawing floor at x: {} y: {}", x, y));
    grid.insert(x, y, floor_tile);
}

void TileMap::draw_wall(int x, int y) {
    Logger::log(LogLevel::DEBUG, fmt::format("Drawing wall at x: {} y: {}", x, y));
    grid.insert(x, y, wall_tile);
}

char TileMap::get_tile(int x, int y) {
    return grid.get(x, y);
}

void TileMap::fill(bool wall) {
    Logger::log(LogLevel::DEBUG, fmt::format("Running fill with wall: {}", wall));
    for(Point p : grid.get_range()) {
        if(wall) {
            draw_wall(p.x, p.y);
        }
        else {
            draw_floor(p.x, p.y);
        }
    }

}

bool TileMap::is_wall(int x, int y) {
    return get_tile(x, y) == wall_tile;
}

int TileMap::get_width() {
    return grid.get_width();
}

int TileMap::get_height() {
    return grid.get_height();
}
