Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/player_stats.h @ 9505

Last change on this file since 9505 was 9505, checked in by patrick, 18 years ago

changing the team color now works and a little cleanup

File size: 3.1 KB
Line 
1/*!
2 * @file player_stats.h
3 * @brief Definition of PlayerStats
4 */
5
6#ifndef _PLAYER_STATS_H
7#define _PLAYER_STATS_H
8
9#include "synchronizeable.h"
10#include "playable.h"
11#include "message_manager.h"
12
13#include <string>
14#include <list>
15
16enum
17{
18  TEAM_NOTEAM = -3,
19  TEAM_RANDOM = -2,
20  TEAM_SPECTATOR = -1
21};
22
23struct PlayerScore
24{
25  std::string name;
26  int score;
27};
28typedef std::list<PlayerScore> TeamScoreList;
29typedef std::map<int,TeamScoreList> ScoreList;
30
31//! A class for storing player information
32class PlayerStats : public Synchronizeable
33{
34
35  public:
36    PlayerStats( const TiXmlElement* root = NULL );
37    PlayerStats( int userId );
38    virtual ~PlayerStats();
39
40    virtual void varChangeHandler( std::list<int> & id );
41
42    static PlayerStats * getStats( int userId );
43
44    inline int getUserId(){ return userId; }
45
46    inline int getTeamId(){ return teamId; }
47    inline void setTeamId( int teamId ){ this->teamId = teamId; }
48
49    void setPreferedTeamIdHandler( int newTeamId);
50    inline int getPreferedTeamId(){ return preferedTeamId; }
51    inline void setPreferedTeamId( int preferedTeamId ) { this->preferedTeamId = preferedTeamId; }
52
53    inline int getScore(){ return score; }
54    inline void setScore( int score ){ this->score = score; }
55
56    inline int getPlayableClassId(){ return playableClassId; }
57    void setPlayableClassId( int classId ){ this->playableClassId = classId; };
58
59    inline int getPlayableUniqueId(){ return playableUniqueId; }
60    void setPlayableUniqueId( int uniqueId );
61
62    inline std::string getModelFileName(){ return modelFileName; }
63    inline void setModelFileName( std::string filename ){ modelFileName = filename; }
64
65    Playable * getPlayable();
66
67    inline std::string getNickName(){ return this->nickName; }
68    void setNickName( std::string nick );
69    static bool changeNickHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
70    void shellNick( const std::string&  newNick );
71
72    static void deleteAllPlayerStats();
73
74    static ScoreList getScoreList();
75
76
77  private:
78    void init();
79
80
81  private:
82    // handles for SynchronizeableVars
83    int              userId_handle;
84    int              teamId_handle;
85    int              preferedTeamId_handle;
86    int              score_handle;
87    int              playableClassId_handle;
88    int              playableUniqueId_handle;
89    int              modelFileName_handle;
90    int              nickName_handler;
91
92    int              userId;                    //!< userId
93    int              teamId;                    //!< teamId
94    int              preferedTeamId;            //!< preferedTeamId
95
96    std::string      nickName;                  //!< players nickname
97    std::string      oldNickName;               //!< nickname player had before
98
99    int              score;                     //!< users score points
100    int              playableClassId;           //!< players playable class id
101    int              playableUniqueId;          //!< playable's uniqueId
102    std::string      modelFileName;             //!< model filename
103
104    Playable *       playable;                  //!< pointer to players playable
105};
106
107#endif /* _PLAYER_STATS_H */
Note: See TracBrowser for help on using the repository browser.