#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <nlohmann/json.hpp>
#include <fstream>
#include "map.hpp"
#include "worldbuilder.hpp"

using namespace fmt;
using namespace nlohmann;
using std::string;

TEST_CASE("bsp algo test", "[builder]") {
  Map map(31, 20);
  WorldBuilder builder(map);
  builder.generate();
}

TEST_CASE("pathing", "[builder]") {
  Map map(23, 14);
  WorldBuilder builder(map);
  builder.generate();

  matrix::dump("WALLS", map.$walls, 0,0);
  println("wall at 0,0=={}", map.$walls[0][0]);

  for(matrix::each_cell it{map.$walls}; it.next();) {
    if(map.$walls[it.y][it.x] == WALL_VALUE) {
      REQUIRE(map.iswall(it.x, it.y) == true);
      REQUIRE(map.can_move({it.x, it.y}) == false);
    } else {
      REQUIRE(map.iswall(it.x, it.y) == false);
      REQUIRE(map.can_move({it.x, it.y}) == true);
    }
  }
}
