#include <fstream>
#include <ctime>
#include <random>

#include "Dungeon.h"

using namespace std;

int main()
{
    srand(time(0));
    //setting file stream
    ofstream out;
    out.open("dungeon.txt");
    if(out.fail()){
        perror("dungeon.txt");
        return 1;
    }

    //generating and initializing dungeon
    char **dungeon = new char*[D_HEIGHT];
    for (int i = 0; i < D_HEIGHT; i++)
        dungeon[i] = new char[D_WIDTH];
    Dungeon dung;
    dung.genDungeon(dungeon);

    //print dungeon to the file
    for (int y = 0; y<D_HEIGHT; y++){
        for (int x = 0; x<D_WIDTH; x++){
            out << dungeon[y][x];
        }
        out << "\n";
    }

    // De-Allocate memory to prevent memory leak and close the file
    for (int i = 0; i < D_HEIGHT; ++i)
        delete [] dungeon[i];
    delete [] dungeon;
    out.close();

    return 0;
}