
#include "stdio.h"

#include "ui/onerror.hpp"
#include "mod/habitat.hpp"
#include "mod/robot.hpp"
#include "mod/data.hpp"


int main(int argc, char **argv)
{	
	CError MainError;
	CHabitat Habitat;
	CRobot Robot ( Habitat.GetDataAddr(), Habitat.GetSocketAddr() );
	char *host = argv[1];
	char *gamer_name = argv[2];
	int portno = 4774;
		if ( argc < 3 ) MainError.OnError(ERROR_MAIN_WITHOUT_PARAMETERS);
		if ( strlen(argv[2] ) > STRING_SIZE ) MainError.OnError(ERROR_MAIN_LONG_GAMER_NAME);
	
		//-------------------------
		Habitat.Init(host, portno, gamer_name);

			//------------------------- 
			while ( ! Robot.IsWin() ) {
				Habitat.Analyze();
				Robot.Pass();
			}
			//=========================

		Habitat.Destroy();
}

