//===========================================================================//
// File:	mission.hh                                                          //
// Project: MUNGA           Brick: Application     								  //
// Contents: Interface specification for missions   								  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 02/19/95  JMA  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#if !defined(MISSION_HPP)
#	define MISSION_HPP

#	if !defined(CSTR_HPP)
#		include <cstr.hpp>
#	endif

#	if !defined(SCHAIN_HPP)
#		include <schain.hpp>
#	endif

#	if !defined(VCHAIN_HPP)
#		include <vchain.hpp>
#	endif

#	if !defined(RESOURCE_HPP)
#		include <resource.hpp>
#	endif

#	if !defined(HOST_HPP)
#		include <host.hpp>
#	endif

#	if !defined(SCNROLE_HPP)
#		include <scnrole.hpp>
#	endif

	class BitMap;

	//##########################################################################
	//#######################    MissionHostData    ############################
	//##########################################################################

	class MissionHostData:
		public Plug
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction, Destruction
	//
	public:
		MissionHostData(
			const CString &address_string,
			HostType host_type
		);
		virtual ~MissionHostData();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Accessors
	//
	public:
		CString
			GetAddressString()
				{return addressString;}
		HostType
			GetHostType()
				{return hostType;}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Private data
	//
	private:
		CString addressString;
		HostType hostType;
	};

	//##########################################################################
	//###########################    Mission    ################################
	//##########################################################################

	class Mission SIGNATURED
	{
		friend class Mission_HostIterator;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Public types
	//
	public:
		typedef Mission_HostIterator HostIterator;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction, Destruction, and Testing
	//
	public:
		Mission(
			NotationFile *notation_file,
			ResourceFile *resources
		);
		virtual ~Mission();

		Logical
			TestInstance() const;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Set the player data
	//
	public:
		virtual void
			SetPlayerData(NotationFile *notation_file);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Accessors
	//
	public:
		ResourceDescription::ResourceID
			GetMapID();
		ResourceDescription::ResourceID
			GetExistanceMapID();
		const char*
			GetDropZoneName()
				{Check(this); return dropZoneName;}
		const char*
			GetGameModel()
				{Check(this); return gameModel;}
		Logical
			IsDropZoneHost()
				{Check(this); return dropZoneHost;}
		const char*
			GetColorName()
				{Check(this); return colorName;}
		const char*
			GetBadgeName()
				{Check(this); return badgeName;}
		const char*
			GetMissionTime()
				{Check(this); return missionTime;}
		const char*
			GetMissionWeather()
				{Check(this); return missionWeather;}
		const char*
			GetScenarioName()
				{Check(this); return scenarioName;}

		int
			GetTeamID()
				{ Check(this); return teamID; }
		int
			GetPlayerCount()
				{Check(this); return playerCount;}

		const char*
			GetPositionName()
				{ Check(this); return positionName; }

		Scalar
			GetGameLength()
				{ Check(this); return gameLength; }

		BitMap*
			GetLargeNameBitmap(int index)
				{
					Check(this);
					return largeNameBitmapChain.Find(index);
				}

		BitMap*
			GetSmallNameBitmap(int index)
				{
					Check(this);
					return smallNameBitmapChain.Find(index);
				}

		BitMap*
			GetOrdinalBitmap(int index)
				{
					Check(this);
					return ordinalBitmapChain.Find(index);
				}

		BitMap*
			GetTeamBitmap(int team_index)
				{
					Check(this);
					return teamBitmapChain.Find(team_index);
				}

		BitMap*
			GetLandmarkBitmap(int landmark_index)
				{
					Check(this);
					return landmarkBitmapChain.Find(landmark_index);
				}

		int
			GetPlayerBitmapIndex() const
		{Check(this); return playerBitmapIndex;}

		ScenarioRole*
			GetScenarioRole(const CString &role_name)
		{
			Check(this);
			VChainIteratorOf<ScenarioRole*, CString> iterator(scenarioRoleChain);
			return iterator.Find(role_name);
		}

		void
			AddScenarioRole(ScenarioRole *scenario_role)
		{
			Check(this);
			Check(scenario_role);
			if (!GetScenarioRole(scenario_role->GetRoleName()))
			{
				scenarioRoleChain.AddValue(scenario_role, scenario_role->GetRoleName());
			}
		#if DEBUG_LEVEL > 0
			else
			{
				Tell(scenario_role->GetRoleName());
				Warn(" already exists not adding to Mission \n");
			}
		#endif
		}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Protected data
	//
	protected:

		ResourceDescription::ResourceID
			mapID,
			existanceMapID;
		SChainOf<MissionHostData*>
			missionHostSocket;
		char
			*colorName,
			*badgeName,
			*dropZoneName,
			*gameModel,
			*missionTime,
			*missionWeather,
			*scenarioName;

		Logical
			dropZoneHost;
		char
			*positionName;

		int
			teamID,
			playerCount;

		int
			playerBitmapIndex;

		VChainOf<ScenarioRole*, CString>
			scenarioRoleChain;

		VChainOf<BitMap*, int>
			largeNameBitmapChain,
			smallNameBitmapChain;

		VChainOf<BitMap*, int>
			ordinalBitmapChain;

		VChainOf<BitMap*, int>
			teamBitmapChain;

		VChainOf<BitMap*, int>
			landmarkBitmapChain;

		void
			LoadOrdinalBitmaps(NotationFile *notation_file);

		void
			LoadNameBitmaps(NotationFile *notation_file);

		void
			LoadTeamBitmaps(NotationFile *notation_file);

		void
			LoadLandmarkBitmaps(NotationFile *notation_file);

		Scalar
			gameLength;
	};

	inline ResourceDescription::ResourceID
		Mission::GetMapID()
	{
		Check(this);
		return mapID;
	}

	inline ResourceDescription::ResourceID
		Mission::GetExistanceMapID()
	{
		Check(this);
		return existanceMapID;
	}

	//##########################################################################
	//#####################    Mission_HostIterator    #########################
	//##########################################################################

	class Mission_HostIterator:
		public SChainIteratorOf<MissionHostData*>
	{
	public:
		Mission_HostIterator(Mission *mission);
		~Mission_HostIterator();
	};

#endif
