#include "matrix.hpp"
#include <fmt/core.h>
#include "constants.hpp"

using namespace fmt;
using std::min, std::max;

namespace matrix {
  void dump(const std::string &msg, Matrix &map, int show_x, int show_y) {
    println("----------------- {}", msg);

    for(each_row it{map}; it.next();) {
      int cell = map[it.y][it.x];

      if(int(it.x) == show_x && int(it.y) == show_y) {
        print("{:x}<", cell);
      } else if(cell == WALL_PATH_LIMIT) {
        print("# ");
      } else if(cell == 0) {
        print(". ");
      } else if(cell > 15 && cell < 32) {
        print("{:x}+", cell - 16);
      } else if(cell > 31) {
        print("* ");
      } else {
        print("{:x} ", cell);
      }

      if(it.row) print("\n");
    }
  }
}
