#include <iostream>
#include <fstream>

#include "Tile.hpp"

using namespace std;

//Remember to validate maxLocalX and maxLocalY before
//creating a series of map files. Incorrect size will
//cause the rest of the game to crash - they are listed
//under "The Forging.hpp"
const unsigned short maxLocalX = 50;	//For local reference to a mini-map
const unsigned short maxLocalY = 50;	//For local reference to a mini-map
const short _MaxX = 2;
const short _MaxY = 2;

int main()
{
	char inputName[13];
	ofstream outPut;
	Tile newMap[maxLocalX][maxLocalY];

	//Loops purposedly designed to start in the negative, and then increment to
	//one above maximum to create 'out of bound' maps so when the player moves
	//within one map file range of these borders, they will be projected as 
	//'developer tiles' and know not to go that way (and it's a cheap way to keep
	//the player from trying to go beyond the world's edge.
	for(short y = -1; y < _MaxY + 1; ++y)
	{
		for(short x = -1; x < _MaxX + 1; ++x)
		{
			sprintf(inputName, "%d %d.txt", (x), (y)); outPut.open(inputName);

			for(unsigned short Y = 0; Y < maxLocalY; ++Y)
				for(unsigned short X = 0; X < maxLocalX; ++X)
				{
					if((x < 0) || (y < 0) || (x == _MaxX) || (y > _MaxY))
					{
						newMap[X][Y].setGround(0);
						newMap[X][Y].setResource(0);
						newMap[X][Y].setAmount(0);
					}
					else
						newMap[X][Y].genRandom();
				}
		
		for(short outY = 0; outY < maxLocalY; ++outY)
		{
			for(short outX = 0; outX < maxLocalX; ++outX)
			{
				outPut << newMap[outX][outY].getGround() << " " << 
					      newMap[outX][outY].getResource() << " " << 
						  newMap[outX][outY].getAmount() << " ";
			}
			outPut << "\n";
		}

		outPut.close();

		}
	}

	return 0;
}