www.pudn.com > uoth_src.zip > Character.h


#ifndef DSSI_CHARACTER_H 
#define DSSI_CHARACTER_H 
 
//----------------------------------------------------------------------------- 
//  
// @doc 
// 
// @module	Character.h - Character information | 
// 
// This module contains the character information 
// 
// Copyright (c) 2002 - Descartes Systems Sciences, Inc. 
// 
// All rights reserved. 
// 
// Redistribution and use in source and binary forms, with or without  
// modification, are permitted provided that the following conditions are  
// met: 
//  
// 1. Redistributions of source code must retain the above copyright notice,  
//    this list of conditions and the following disclaimer.  
// 2. Neither the name of Descartes Systems Sciences, Inc nor the names of  
//    its contributors may be used to endorse or promote products derived  
//    from this software without specific prior written permission. 
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT  
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR  
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR  
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING  
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS  
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
// 
// @end 
// 
// $History: ExpatImpl.h $ 
//       
//----------------------------------------------------------------------------- 
 
//----------------------------------------------------------------------------- 
// 
// Required include files 
// 
//----------------------------------------------------------------------------- 
 
#include  
#include "ExpatImpl.h" 
#include "uoth.h" 
 
//----------------------------------------------------------------------------- 
// 
// Forward definitions 
// 
//----------------------------------------------------------------------------- 
 
class CDataParser; 
 
//----------------------------------------------------------------------------- 
// 
// Helper structure 
// 
//----------------------------------------------------------------------------- 
 
class CMapCounts 
{ 
public: 
	int		m_nIndex; 
	int		m_anCounts [Max_Level]; 
}; 
 
//----------------------------------------------------------------------------- 
// 
// Class definition 
// 
//----------------------------------------------------------------------------- 
 
class CCharacter 
{ 
public: 
 
	enum _Element 
	{ 
		Unknown			= 0, 
		Character		= 1, 
		Name			= 2, 
		MapCounts		= 3, 
	}; 
 
// @access Constructors and destructors 
public: 
 
	// @cmember General constructor 
 
	CCharacter (); 
 
	// @cmember General constructor 
 
	CCharacter (const CCharacter &src) : m_strName (src .m_strName) 
	{ 
		m_vMapCounts .Append (src .m_vMapCounts); 
	} 
 
	// @cmember General destructor 
 
	~CCharacter (); 
 
// @cmember Public methods 
public: 
 
	// @cmember Initialize 
 
	void Init (bool fConstruct); 
 
	// @cmember Start a treasure 
 
	void OnStart (CDataParser *pParser, const XML_Char **papszAttrs); 
 
	// @cmember Start an XML element 
 
	void OnStartElement (CDataParser *pParser,  
		const XML_Char *pszName, const XML_Char **papszAttrs); 
 
	// @cmember End an XML element 
 
	void OnEndElement (CDataParser *pParser,  
		const XML_Char *pszName); 
 
	// @cmember Locate a map count for the given treasure 
 
	CMapCounts *FindMapCounts (int nIndex); 
 
	// @cmember Adjust the count of a map 
 
	void AdjustCount (int nTreasure, int nLevel, bool fAdd); 
 
	// @cmember Write to a stream 
 
	void Write (FILE *fp); 
 
// @access Public static methods 
public: 
 
	// @cmember Find a character 
 
	static CCharacter *Find (LPCTSTR pszName); 
 
	// @cmember Add a character 
 
	static CCharacter *Add (LPCTSTR pszName); 
 
	// @cmember Delete the given character 
 
	static void Delete (CCharacter *pCharacter); 
 
	// @cmember Get max index of level  
 
	static int GetMaxLevel (CMapCounts *pCounts); 
 
	// @cmember Get the current character 
 
	static CCharacter *GetCurrent (); 
 
	// @cmember Set the current character 
 
	static void SetCurrent (CCharacter *pCharacter); 
 
	// @cmember Set the default current 
 
	static void GetDefaultCurrent (); 
 
// @access Protected methods 
protected: 
 
	// @cmember Get the element number 
 
	_Element GetElement (const XML_Char *pszName); 
 
// @access Public members 
public: 
	CString							m_strName; 
	CAtlArray 			m_vMapCounts; 
	static CAtlArray 	gm_vCharacters; 
}; 
 
#endif // DSSI_CHARACTER_H