/* $Id: scorekeeper.hpp,v 1.16.4.1 2006/01/20 11:23:31 chfreund Exp $ */ #ifndef _SCOREKEEPER_HPP_ #define _SCOREKEEPER_HPP_ /******************************************************************************/ #include "constants.hpp" #include "audio.hpp" #include "messages.hpp" #include "serializable.hpp" #include "goal.hpp" #include class World; class Ball; /******************************************************************************/ class Scorekeeper: public Serializable { public: Scorekeeper( void ) {}; virtual ~Scorekeeper( void ); void initialize( World* const world ); void setupGameMode( void ); void playerDamagedPlayer( const Uint8 shooter, const Uint8 victim, const Sint32 damage, const bool killingVictim ); void playerScoredGoal( Ball* ball, const Uint8 playerOrTeamID ); bool isTeamPlay( void ); Uint8 getGameMode( void ) const { return m_gameMode; } bool setGameMode( const Uint8 gameMode ); void placeNewBall( void ); void replaceBall( Ball* ball ); Sint32 getFragsForPlayer( const Uint8 playerID ) { return m_score[playerID].nFrags; } Sint32 getKillsForPlayer( const Uint8 playerID ) { return m_score[playerID].nKills; } Sint32 getDeathsForPlayer( const Uint8 playerID ) { return m_score[playerID].nDeaths; } Sint32 getDamageForPlayer( const Uint8 playerID ) { return m_score[playerID].nDamage; } Sint32 getFragsForTeam( const Uint8 teamID ) { return m_teamScore[teamID].nFrags; } Sint32 getKillsForTeam( const Uint8 teamID ) { return m_teamScore[teamID].nKills; } Sint32 getDeathsForTeam( const Uint8 teamID ) { return m_teamScore[teamID].nDeaths; } Sint32 getDamageForTeam( const Uint8 teamID ) { return m_teamScore[teamID].nDamage; } void resetPlayerScore( const Uint8 playerID ) { m_score[playerID].nFrags = m_score[playerID].nKills = m_score[playerID].nDeaths = m_score[playerID].nDamage = 0; } void resetTeamScore( const Uint8 teamID ) { m_score[teamID].nFrags = m_score[teamID].nKills = m_score[teamID].nDeaths = m_score[teamID].nDamage = 0; } void setMessageSink( MessageSink* sink ) { m_messageSink = sink; } void reset( void ); virtual void serialize( Uint8*& bufferPointer ) const; virtual void deserialize( Uint8*& bufferPointer ); virtual Uint32 getSerializeBufferSize() const; private: struct Score { Sint32 nFrags, nKills, nDeaths, nDamage; }; Score m_score[MAX_NUMBER_OF_PLAYERS]; Score m_teamScore[MAX_NUMBER_OF_PLAYERS]; Uint8 m_gameMode; std::vector m_goal; World* m_world; static Mix_Chunk* m_cashSample; MessageSink m_defaultMessageSink; MessageSink* m_messageSink; }; /******************************************************************************/ #endif // _SCOREKEEPER_HPP_