//
//  House.hpp
//  Game
//
//  Created by Darvydas on 26/01/2019.
//

#pragma once

#include <vector>
#include "cocos2d.h"
#include "Game/GameScene/World/Objects/Helper.hpp"
#include "Game/GameScene/World/Objects/Tile.hpp"

namespace Game
{
    namespace Map
    {
#define kTileAlive '#'
#define kTileDead '-'
#define kTileObject 'x'
        
        class CHouse
        {
        public:
            
            CHouse(int level);
            
            Objects::EGroundTileType GetGroundTileType(int x, int y);
            bool IsItGround(int x, int y);
            
            std::pair<int, int> getEmptyPosition(std::string strType = "", int width = 1, int height = 1);
            
            void setTileValue(int x, int y, char c);
            
            char getTileValue(int x, int y);
            
            int getWidth();
            int getHeight();
            
        private:
            
            bool isAllTilesEmpty(int x, int y, int width, int height);
            bool isOutOfRange(int x, int y, int width, int height);
            bool tileExists(int x, int y);
            bool isTouching(int x, int y, int width, int height);
            bool isSeperatedByWall(int x, int y, int witdh, int height);
            
            void placeRoom(int x, int y, int width, int height);
            
            void printRoom();
            
            void generateRooms();
            
            void cleanUpMap();
            
        private:
            
            std::vector<char> m_vTiles;
            
            int m_level, m_width, m_height, m_roomCount, m_roomWidthMin, m_roomWidthMax, m_roomHeightMin, m_roomHeightMax;
        };
    }
}
