#include <allegro.h>
#include <winalleg.h>
#include "erkMap.h"

erkTTHive::erkTTHive()
{
}

erkTTHive::~erkTTHive()
{
}

void erkTTHive::Update(erkTile_p pTile)
{
	if(pTile->GetMap()->GetTeamCount(pTile->IsLit()) >= EU_MAX_UNITS  ||  ((rand()>>7)&0x7))
		return;

	erkUnit_p pUnit = new erkUnit();
	if(pTile->IsLit())
	{
		pUnit->SetColor(makecol(255, rand()%64, rand()%64));
	}
	else
	{
		pUnit->SetColor(makecol(rand()%64, rand()%64, 255));
	}

	pUnit->SetSide(pTile->IsLit());
	pUnit->SetType(EU_UT_WORKER);
	pTile->AddUnit(pUnit);
	pTile->GetMap()->AddUnit(pUnit);
}
