Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/blink/src/lib/network/player_stats.h @ 10767

Last change on this file since 10767 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.2 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
23
24struct PlayerScore
25{
26  std::string name;
27  int score;
28};
29
30
31typedef std::list<PlayerScore> TeamScoreList;
32typedef std::map<int,TeamScoreList> ScoreList;
33
34
35//! A class for storing player information
36class PlayerStats : public Synchronizeable
37{
38  ObjectListDeclaration(PlayerStats);
39  public:
40    PlayerStats( const TiXmlElement* root = NULL );
41    PlayerStats( int userId );
42    virtual ~PlayerStats();
43
44    virtual void varChangeHandler( std::list<int> & id );
45
46    static PlayerStats * getStats( int userId );
47    inline int getAssignedUserId(){ return this->assignedUserId; }
48
49
50    inline int getTeamId(){ return teamId; }
51    inline void setTeamId( int teamId ){ this->teamId = teamId; }
52
53    inline int getPreferedTeamId(){ return preferedTeamId; }
54    inline void setPreferedTeamId( int preferedTeamId ) { this->preferedTeamId = preferedTeamId; }
55
56    inline int getScore(){ return score; }
57    inline void setScore( int score ){ this->score = score; }
58
59    inline int getPlayableClassId(){ return playableClassId; }
60    void setPlayableClassId( const ClassID& classId ){ this->playableClassId = classId.id(); };
61
62    inline int getPlayableUniqueId(){ return playableUniqueId; }
63    void setPlayableUniqueId( int uniqueId );
64
65    inline std::string getModelFileName(){ return modelFileName; }
66    inline void setModelFileName( std::string filename ){ modelFileName = filename; }
67
68    Playable * getPlayable();
69
70    inline std::string getNickName(){ return this->nickName; }
71    void setNickName( std::string nick );
72    static bool changeNickHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId  );
73    void shellNick( const std::string&  newNick );
74
75    static void deleteAllPlayerStats();
76
77    static ScoreList getScoreList();
78
79
80  private:
81    void init();
82
83
84  private:
85    // handles for SynchronizeableVars
86    int              userId_handle;
87    int              teamId_handle;
88    int              preferedTeamId_handle;
89    int              score_handle;
90    int              playableClassId_handle;
91    int              playableUniqueId_handle;
92    int              modelFileName_handle;
93    int              nickName_handler;
94
95    int              assignedUserId;            //!< userId
96    int              teamId;                    //!< teamId
97    int              preferedTeamId;            //!< preferedTeamId
98
99    std::string      nickName;                  //!< players nickname
100    std::string      oldNickName;               //!< nickname player had before
101
102    int              score;                     //!< users score points
103    int              playableClassId;           //!< players playable class id
104    int              playableUniqueId;          //!< playable's uniqueId
105    std::string      modelFileName;             //!< model filename
106
107    Playable *       playable;                  //!< pointer to players playable
108};
109
110#endif /* _PLAYER_STATS_H */
Note: See TracBrowser for help on using the repository browser.