// MissionReport.cpp: implementation of the CMissionReport class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "mw4gameed2.h"
#include "MissionReport.h"

char *CZoneReport::BasicTypeName[CMissionReport::MR_TYPECOUNT]={ 
	"Turrets",
		"Culturals",
		"Mechs",
		"Vehicles",
		"Buildings",
		"Navpoints",
		"Dropzones",
		"Ais",
		"Noncoms",
		"Paths",
		"Cameraships",
		"EffectGenerators",
		"Objective",
		"SearchLight",
		"Unidentifyable"
};	


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

CMissionReport::CMissionReport()
{
	ZoneCount=0;
	CountTypes();
}

void CZoneReport::GetReport(CString &report)
{
	int i;
	report="";
	CString tstr;
	
	tstr.Format("Total Entities=%i\n",EntityCount);
	report+=tstr;
	report+="\n";
	
	for(i=0;i<MR_TYPECOUNT;i++) 
	{
	if(BasicTypeCount[i]>0)
		{
		tstr.Format("%-90s%i\n",BasicTypeName[i],BasicTypeCount[i]);
		report+=tstr;
		}
	}
	
	report+="\n";
	
	tstr.Format("Total Unique Models=%i\n",UniqueModelCount);
	report+=tstr;
	report+="\n";
	
	for(i=0;i<UniqueModelCount;i++) 
	{
		tstr.Format("%-90s%i\n",Models[i].Name+"("+BasicTypeName[Models[i].Type]+")",Models[i].Count);
		report+=tstr;
	}
	
	
	report+="\n";
	
	tstr.Format("Total Tile Bound Violators=%i\n",ViolatorCount);
	report+=tstr;
	report+="\n";
	
	if(ViolatorCount>0)
	{
		tstr.Format("Vioilators:\n",ViolatorCount);
		report+=tstr;
		
		for(i=0;i<ViolatorCount;i++) 
		{
			tstr.Format("%s\n",Violators[i].Name);
			report+=tstr;
		}
	}
	
}

CZoneReport::~CZoneReport()
{
	delete []Violators;
	delete []Models;
}


void CMissionReport::GetReport(CString &report)
{
	int i;
	CString tstr;
	report="";
	
	tstr.Format("Mission Name %s\n",MissionName);
	report+=tstr;
	report+="\n";
	
	CZoneReport::GetReport(tstr);
	report+=tstr;
	
	for(i=0;i<ZoneCount;i++)
	{
		report+="\n------------------------------------------------------------------------------\n";
		tstr.Format("Mission = %s Zone =(%C,%C)\n\n",MissionName,ZoneRep[i].RChar,ZoneRep[i].CChar);
		report+=tstr;
		ZoneRep[i].GetReport(tstr);
		report+=tstr;
		
	}
	
	report+="\n Map Tile Info-------------------------------------------------------------------\n\n";
	
	CString trep;
	int r,c;
	
	for(r=0;r<TileRows;r++)
	{
		if(r==0)
		{
			tstr.Format("  |",c);
			trep+=tstr;
			
			for(c=0;c<TileCols;c++)
			{
				tstr.Format("  %c|",'a'+c);
				trep+=tstr;
			}
			trep+="\n";
		
		tstr.Format("--+",c);
		trep+=tstr;
		for(c=0;c<TileCols;c++)
		{
			tstr.Format("---+",c);
			trep+=tstr;
			
		}
		trep+="\n";	
			
		}
			tstr.Format(" %c|",'A'+r);
			trep+=tstr;
			
			for(c=0;c<TileCols;c++)
			{
				tstr.Format("%3i|",TileEntityCount[(TileRows-(r+1))*TileCols+(TileCols-(c+1))]);
				trep+=tstr;
			}
		trep+="\n";
		
		tstr.Format("--+",c);
		trep+=tstr;
		for(c=0;c<TileCols;c++)
		{
			tstr.Format("---+",c);
			trep+=tstr;
			
		}
		trep+="\n";
	}
	
	report+=trep;
	
}

CMissionReport::~CMissionReport()
{
	delete []ZoneRep;
}
