00001 /* $Id: player.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2003 - 2012 by David White <dave@whitevine.net> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program 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 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 #ifndef PLAYER_HPP_INCLUDED 00017 #define PLAYER_HPP_INCLUDED 00018 00019 00020 #include "simple_wml.hpp" 00021 00022 #include <ctime> 00023 #include <set> 00024 00025 namespace wesnothd { 00026 00027 class game; 00028 00029 class player 00030 { 00031 public: 00032 enum STATUS { 00033 LOBBY, 00034 PLAYING, 00035 OBSERVING 00036 }; 00037 00038 player(const std::string& n, simple_wml::node& cfg, bool registered, 00039 const size_t max_messages=4, const size_t time_period=10, 00040 const bool sp=false, const bool moderator=false); 00041 00042 void set_status(STATUS status); 00043 00044 // mark a player as member of the game 'game_id' or as located in the lobby 00045 void mark_available(const int game_id=0, const std::string& location=""); 00046 00047 //Mark a player as registered if he has authorized 00048 void mark_registered(bool registered =true); 00049 bool registered() const {return registered_;} 00050 00051 00052 const std::string& name() const { return name_; } 00053 bool selective_ping() const { return selective_ping_ ; } 00054 00055 const simple_wml::node* config_address() const { return &cfg_; } 00056 00057 bool is_message_flooding(); 00058 00059 /** 00060 * @return true iff the player is in a game 00061 */ 00062 bool in_game() const { return get_game() != NULL; } 00063 00064 /** 00065 * @return a pointer to the game the player is in, or NULL if he/she is not 00066 * in a game at the moment 00067 */ 00068 const game* get_game() const; 00069 00070 void set_game(game* g); 00071 00072 void set_moderator(bool moderator) { moderator_ = moderator; } 00073 bool is_moderator() const { return moderator_; } 00074 00075 private: 00076 const std::string name_; 00077 simple_wml::node& cfg_; 00078 const bool selective_ping_ ; 00079 00080 bool registered_; 00081 00082 time_t flood_start_; 00083 unsigned int messages_since_flood_start_; 00084 const size_t MaxMessages; 00085 const time_t TimePeriod; 00086 STATUS status_; 00087 bool moderator_; 00088 }; 00089 00090 } //namespace wesnothd 00091 00092 #endif
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:09 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |