#include "stdafx.h"
#include "War3TypesAndConstants.h"
#include "TilesetGroup.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTilesetGroup::CTilesetGroup()
{
	groupID = TG_CHAR_ID_UNDEFINED;
	groupName = TG_STR_NAME_UNDEFINED;
	tiles = "";
	cliffs = "";
}

CTilesetGroup::~CTilesetGroup()
{

}

void CTilesetGroup::AddTile(CWar3StrID tileID)
{
	int i, nbTiles;
	CString str;
	BOOL bFound = FALSE;

	nbTiles = tiles.length()/4;
	i = 0;
	while ((i < nbTiles) && !bFound)
	{
		str = tiles.substr(0,i*4);
		if (tileID == str.c_str())
		{
			bFound = TRUE;
		}
		i++;
	}
	if (FALSE == bFound)
	{
		tiles = tiles + tileID[0] + tileID[1] + tileID[2] + tileID[3];
	}
}

void CTilesetGroup::AddCliff(CWar3StrID cliffID)
{
	int i, nbCliffs;
	CString str;
	BOOL bFound = FALSE;

	nbCliffs = cliffs.length()/4;
	i = 0;
	while ((i < nbCliffs) && !bFound)
	{
		str = cliffs.substr(0,i*4);
		if (cliffID == str.c_str())
		{
			bFound = TRUE;
		}
		i++;
	}
	if (FALSE == bFound)
	{
		cliffs = cliffs + cliffID[0] + cliffID[1] + cliffID[2] + cliffID[3];
	}
}
