The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
player.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef PLAYER_HPP_INCLUDED
16 #define PLAYER_HPP_INCLUDED
17 
18 
19 #include "simple_wml.hpp"
20 
21 #include <ctime>
22 #include <set>
23 
24 namespace wesnothd {
25 
26 class game;
27 
28 class player
29 {
30 public:
31  enum STATUS {
35  };
36 
37  player(const std::string& n, simple_wml::node& cfg, bool registered,
38  const size_t max_messages=4, const size_t time_period=10,
39  const bool sp=false, const bool moderator=false);
40 
41  void set_status(STATUS status);
42 
43  // mark a player as member of the game 'game_id' or as located in the lobby
44  void mark_available(const int game_id=0, const std::string& location="");
45 
46  //Mark a player as registered if he has authorized
47  void mark_registered(bool registered =true);
48  bool registered() const {return registered_;}
49 
50 
51  const std::string& name() const { return name_; }
52  bool selective_ping() const { return selective_ping_ ; }
53 
54  const simple_wml::node* config_address() const { return &cfg_; }
55 
56  bool is_message_flooding();
57 
58  /**
59  * @return true iff the player is in a game
60  */
61  bool in_game() const { return get_game() != nullptr; }
62 
63  /**
64  * @return a pointer to the game the player is in, or nullptr if he/she is not
65  * in a game at the moment
66  */
67  const game* get_game() const;
68 
69  void set_game(game* g);
70 
71  void set_moderator(bool moderator) { moderator_ = moderator; }
72  bool is_moderator() const { return moderator_; }
73 
74 private:
77  const bool selective_ping_ ;
78 
80 
81  time_t flood_start_;
83  const size_t MaxMessages;
84  const time_t TimePeriod;
86  bool moderator_;
87 };
88 
89 } //namespace wesnothd
90 
91 #endif
const size_t MaxMessages
Definition: player.hpp:83
void set_game(game *g)
GLboolean GLboolean g
Definition: glew.h:7319
void mark_available(const int game_id=0, const std::string &location="")
Definition: player.cpp:62
const std::string & name() const
Definition: player.hpp:51
simple_wml::node & cfg_
Definition: player.hpp:76
bool registered_
Definition: player.hpp:79
const bool selective_ping_
Definition: player.hpp:77
bool in_game() const
Definition: player.hpp:61
player(const std::string &n, simple_wml::node &cfg, bool registered, const size_t max_messages=4, const size_t time_period=10, const bool sp=false, const bool moderator=false)
Definition: player.cpp:21
bool selective_ping() const
Definition: player.hpp:52
Encapsulates the map of the game.
Definition: location.hpp:38
void mark_registered(bool registered=true)
Definition: player.cpp:75
void set_moderator(bool moderator)
Definition: player.hpp:71
STATUS status_
Definition: player.hpp:85
unsigned int messages_since_flood_start_
Definition: player.hpp:82
bool is_moderator() const
Definition: player.hpp:72
const time_t TimePeriod
Definition: player.hpp:84
bool is_message_flooding()
Definition: player.cpp:81
void set_status(STATUS status)
Definition: player.cpp:42
GLclampd n
Definition: glew.h:5903
Definition: ban.cpp:28
time_t flood_start_
Definition: player.hpp:81
const game * get_game() const
const simple_wml::node * config_address() const
Definition: player.hpp:54
bool registered() const
Definition: player.hpp:48
GLsizei const GLcharARB ** string
Definition: glew.h:4503
const std::string name_
Definition: player.hpp:75