/* $Id: bonuspack.hpp,v 1.7 2005/10/10 11:10:04 chfreund Exp $ */ #ifndef _BONUSPACK_HPP_ #define _BONUSPACK_HPP_ /**********************************************************/ #include "bonus.hpp" /**********************************************************/ //! a "bag", the avatars carry their collected boni with them class BonusPack : public Serializable { public: BonusPack( World *const worldPointer ); virtual ~BonusPack(); //! \name get information about the bonus pack //@{ inline bool hasBonus( const int objectID ) const { DBG(2) checkIDRange( objectID, "hasBonus" ); return m_bag[objectID] != NULL; } Bonus*& operator [] ( const int objectID ) { DBG(2) checkIDRange( objectID, "operator []" ); return m_bag[objectID]; } //@} //! \name modifying the bonus pack's bonus //@{ //! adds the bonus in the bonus pack /*! Adds the bonus in the bonus pack. If this bonus type is * already present in the pack, it will be added. \b Note * that the passed bonus must not exist any more as part * of the world (removed with World::unhookObject()) */ void add( Bonus* newBonus ); //! removes bonus from the bag and deletes it void remove( const int bonusID ); //! updates the bonus pack in one time step void update( Avatar *const avatar ); //@} //! resets the bonus pack for a respawn /*! This function resets the bonus pack NOT to the state * after its creation, but to the state, it should be in * after an avatar dies. For example non-persistent boni * are removed from the bonus pack. */ void resetForRespawn(); void setWorldPointer( World* wp ) { m_worldPointer = wp; } //! \name (de)serialization //@{ virtual Uint32 getSerializeBufferSize() const; virtual void serialize( Uint8*& bufferPointer ) const; virtual void deserialize( Uint8*& bufferPointer ); //@} protected: //! auxiliary function for checking the range of a bonus ID void checkIDRange( const int ID, const char* const fn ) const; //! pointer to bonus collection Bonus **m_bag; //! world pointer (we need it for deserializations) World * m_worldPointer; }; /**********************************************************/ #endif // _BONUSPACK_HPP_