// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: ALL
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

// Purpose: This wraps a single user's stats on a single leaderboard.

#ifndef BD_STATS_INFO_H
#define BD_STATS_INFO_H

#include <bdCore/bdCore.h>
#include <bdLobby/bdLobbyCommon/bdQueryParams.h>
#include <bdLobby/bdLobbyCommon/bdQueryResult.h>
#include <bdLobby/bdLobbyCommon/bdLobbyServicesCommon.h>

// this is the id of the first user defined search
#define BD_STATS_FIRST_USER_SEARCH_ID 201

/// Wraps a single user's stats on a single leaderboard. 
/// This class should be derived from and its serialize/deserialize functions
/// should be overridden so that title-specific statistics can be transmitted
/// to the MatchMaking+ service.
class bdStatsInfo : public bdQueryParams
{
	public:

		BD_DECLARE_NEW_AND_DELETE_OPERATORS

		/// Default constructor.
		bdStatsInfo();

		/// Constructor.
		/// Construct this bdStatsInfo with a specific leaderBoard ID and user ID.
		/// \param leaderBoardID[in]	The ID of the title leaderboard that 
		///								these stats are associated with.
		/// \param entity[in]			The team/userID that these stats belong to.
		/// \param rating[in]			
		bdStatsInfo(const bdInt64 rating);

		/// Destructor.
		virtual ~bdStatsInfo();

		/// Serialize the stats for transmission to the MatchMaking+ service.
		/// \param param[out]	This is returned with the stats written to it.
		virtual void serialize(bdBitBuffer &buffer);

		/// Deserialize the stats from a buffer.
		/// \param param[in]	This buffer contains stats transmitted by the 
		///						MatchMaking+ service.
		/// \return 
		///		- True, the buffer was de-serialized correctly.
		///		- False, there was an error de-serializing the buffer.
		virtual bdBool deserialize(bdBitBufferRef buffer);

		/// Set the overall rating for these stats.
		/// In order for the leaderboard to function correctly, this function
		/// should be used to rate this stat object as finely as possible. The
		/// value of the rating should be derived from the values of the title
		/// specific statistics, as implemented in the derived class.
		/// A higher value will result in a higher ranking.
		/// \param	rating[in]	The statistic's overall rating.
		void setRating(const bdInt64 rating);

		/// Get the overall rating for these stats.
		/// \return	The rating.
		bdInt64 getRating() const;

		/// Get the rank for these stats.
		/// \return	The rank.
		bdUInt64 getRank() const;

		/// Set the entityID for these stats.
		/// \param[in] The entityID to set.
		void setEntityID(const bdEntityID entityID);

		/// Get the entityID for these stats.
		/// \return	The entityID.
		bdEntityID getEntityID() const;

		/// Get the entityName for these stats.
		/// \return	The entityName.
		void setEntityName(const bdNChar8 *const buf);

		/// Get the entityName for these stats.
		/// \return	The entityName.
		void getEntityName(bdNChar8* buf, const bdUInt32 bufSize) const;

		/// \return number of fields which are serialised in bdStatsInfo::serialize()
		virtual bdUInt getNumFields() const;

	protected:

		/// the entity (i.e. either team or user) id
		bdEntityID m_entityID;

		/// Entity's rating, 64 bit
		bdInt64 m_rating;

		/// Entity's rank
		bdUInt64 m_rank;

		/// Entity's name
		bdNChar8 m_entityName[BD_MAX_USERNAME_LENGTH+1];
};

#endif // BD_STATS_INFO_H
