StatsLogger.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(__INCLUDE_StatsLoggerh_INCLUDE__)
00022 #define __INCLUDE_StatsLoggerh_INCLUDE__
00023 
00024 #include <tank/Tank.h>
00025 #include <weapons/Weapon.h>
00026 #include <list>
00027 
00028 class StatsLogger
00029 {
00030 public:
00031         static StatsLogger *instance();
00032 
00033         struct TankRank
00034         {
00035                 TankRank() : rank(-1), skill(1000) {}
00036 
00037                 int rank;
00038                 int skill;
00039         };
00040 
00041         StatsLogger();
00042         virtual ~StatsLogger();
00043 
00044         virtual int getKillCount(const char *uniqueId) = 0;
00045         virtual void gameStart(std::list<Tank *> &tanks) = 0;
00046         virtual void roundStart(std::list<Tank *> &tanks) = 0;
00047 
00048         virtual std::list<std::string> getAliases(const char *unqiueId) = 0;
00049         virtual std::list<std::string> getIpAliases(const char *unqiueId) = 0;
00050         virtual TankRank tankRank(Tank *tank) = 0;
00051         virtual void updateStats(Tank *tank) = 0;
00052         virtual void periodicUpdate() = 0;
00053         virtual std::string allocateId() = 0;
00054         virtual unsigned int getStatsId(const char *uniqueId) = 0;
00055         virtual std::string getTopRanks() = 0;
00056         virtual std::string getPlayerInfo(const char *player) = 0;
00057         virtual void combinePlayers(unsigned int player1, unsigned int player2) = 0;
00058 
00059         virtual void tankConnected(Tank *tank) = 0;
00060         virtual void tankDisconnected(Tank *tank) = 0;
00061         virtual void tankJoined(Tank *tank) = 0;
00062 
00063         virtual void tankFired(Tank *firedTank, Weapon *weapon) = 0;
00064         virtual void tankResigned(Tank *resignedTank) = 0;
00065 
00066         virtual void tankKilled(Tank *firedTank, Tank *deadTank, Weapon *weapon) = 0;
00067         virtual void tankTeamKilled(Tank *firedTank, Tank *deadTank, Weapon *weapon) = 0;
00068         virtual void tankSelfKilled(Tank *firedTank, Weapon *weapon) = 0;
00069 
00070         virtual void tankWon(Tank *tank) = 0;
00071         virtual void tankOverallWinner(Tank *tank) = 0;
00072 
00073         virtual void weaponFired(Weapon *weapon, bool deathAni) = 0;
00074         virtual void weaponKilled(Weapon *weapon, bool deathAni) = 0;
00075 
00076 protected:
00077         static StatsLogger *instance_;
00078 
00079 };
00080 
00081 class StatsLoggerNone : public StatsLogger
00082 {
00083 public:
00084         StatsLoggerNone() {}
00085         virtual ~StatsLoggerNone() {}
00086 
00087         virtual int getKillCount(const char *uniqueId) { return 0; }
00088         virtual void gameStart(std::list<Tank *> &tanks) {}
00089         virtual void roundStart(std::list<Tank *> &tanks) {}
00090 
00091         virtual std::list<std::string> getAliases(const char *unqiueId) 
00092                 { std::list<std::string> result; return result; }
00093         virtual std::list<std::string> getIpAliases(const char *unqiueId) 
00094                 { std::list<std::string> result; return result; }
00095         virtual TankRank tankRank(Tank *tank) { return TankRank(); }
00096         virtual void updateStats(Tank *tank) {}
00097         virtual void periodicUpdate() {}
00098         virtual std::string allocateId() { return ""; }
00099         virtual unsigned int getStatsId(const char *uniqueId) { return 0; }
00100         virtual std::string getTopRanks() { return ""; }
00101         virtual std::string getPlayerInfo(const char *player) { return ""; }
00102         virtual void combinePlayers(unsigned int player1, unsigned int player2) {}
00103 
00104         virtual void tankConnected(Tank *tank) {}
00105         virtual void tankDisconnected(Tank *tank) {}
00106         virtual void tankJoined(Tank *tank) {}
00107 
00108         virtual void tankFired(Tank *firedTank, Weapon *weapon) {}
00109         virtual void tankResigned(Tank *resignedTank) {}
00110 
00111         virtual void tankKilled(Tank *firedTank, Tank *deadTank, Weapon *weapon) {}
00112         virtual void tankTeamKilled(Tank *firedTank, Tank *deadTank, Weapon *weapon) {}
00113         virtual void tankSelfKilled(Tank *firedTank, Weapon *weapon) {}
00114 
00115         virtual void tankWon(Tank *tank) {}
00116         virtual void tankOverallWinner(Tank *tank) {}
00117 
00118         virtual void weaponFired(Weapon *weapon, bool deathAni) {}
00119         virtual void weaponKilled(Weapon *weapon, bool deathAni) {}
00120 };
00121 
00122 #endif
00123 

Generated on Mon Feb 16 15:14:49 2009 for Scorched3D by  doxygen 1.5.3