src/core/serverapi/player.h
00001 //------------------------------------------------------------------------------
00002 // player.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301, USA.
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2010 "Blzut3" <admin@maniacsvault.net>
00022 //------------------------------------------------------------------------------
00023 #ifndef __PLAYER_H_
00024 #define __PLAYER_H_
00025 
00026 #define MAX_TEAMS 4
00027 
00028 #include "global.h"
00029 #include <QHash>
00030 #include <QString>
00031 
00035 class MAIN_EXPORT Player
00036 {
00037         public:
00038                 enum PlayerTeam
00039                 {
00040                         TEAM_BLUE,
00041                         TEAM_RED,
00042                         TEAM_GREEN,
00043                         TEAM_GOLD,
00044 
00045                         TEAM_NONE = 0xFF
00046                 };
00047 
00048                 Player();
00049                 Player(const QString &name, unsigned short score, unsigned short ping, PlayerTeam team=TEAM_NONE, bool spectator=false, bool bot=false);
00050 
00051                 const QString   &name() const { return playerName; }
00052                 short                   score() const { return currentScore; }
00053                 unsigned short  ping() const { return currentPing; }
00054                 bool                    isSpectating() const { return spectator; }
00055                 bool                    isBot() const { return bot; }
00056                 bool                    isTeamlessBot() const { return bot && team == TEAM_NONE; }
00057                 PlayerTeam              teamNum() const { return team; }
00058 
00059                 bool                    operator==(const Player& other) const;
00060 
00064                 QString                 nameFormatted() const;
00065 
00071                 QString                 nameColorTagsStripped() const;
00072 
00077                 static QString  colorizeString(const QString &str, int def=4);
00078 
00079         protected:
00080                 static const char       colorChart[22][7];
00081 
00082                 QString                 playerName;
00083                 short                   currentScore;
00084                 unsigned short  currentPing;
00085                 bool                    spectator;
00086                 bool                    bot;
00087                 PlayerTeam              team;
00088 };
00089 
00090 uint qHash(const Player& player);
00091 
00092 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator