The Battle for Wesnoth  1.15.2+dev
player.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
17 #include "server/simple_wml.hpp"
18 
19 #include <ctime>
20 #include <set>
21 
22 namespace wesnothd {
23 
24 class player
25 {
26 public:
27  enum STATUS {
31  };
32 
33  player(const std::string& n, simple_wml::node& cfg, bool registered, const std::string& version, const std::string& source,
34  const std::size_t max_messages=4, const std::size_t time_period=10,
35  const bool moderator=false);
36 
37  void set_status(STATUS status);
38 
39  // mark a player as member of the game 'game_id' or as located in the lobby
40  void mark_available(const int game_id=0, const std::string& location="");
41 
42  //Mark a player as registered if he has authorized
43  void mark_registered(bool registered =true);
44  bool registered() const {return registered_;}
45 
46 
47  const std::string& name() const { return name_; }
48  const std::string& version() const { return version_; }
49  const std::string& source() const { return source_; }
50  const simple_wml::node* config_address() const { return &cfg_; }
51 
52  bool is_message_flooding();
53 
54  void set_moderator(bool moderator) { moderator_ = moderator; }
55  bool is_moderator() const { return moderator_; }
56 
57 private:
58  const std::string name_;
59  std::string version_;
60  std::string source_;
62 
64 
65  std::time_t flood_start_;
67  const std::size_t MaxMessages;
68  const std::time_t TimePeriod;
70  bool moderator_;
71 };
72 
73 } //namespace wesnothd
const simple_wml::node * config_address() const
Definition: player.hpp:50
const std::string & version() const
Definition: player.hpp:48
const std::string & name() const
Definition: player.hpp:47
const std::time_t TimePeriod
Definition: player.hpp:68
std::time_t flood_start_
Definition: player.hpp:65
bool is_moderator() const
Definition: player.hpp:55
const std::string & source() const
Definition: player.hpp:49
void mark_available(const int game_id=0, const std::string &location="")
Definition: player.cpp:60
player(const std::string &n, simple_wml::node &cfg, bool registered, const std::string &version, const std::string &source, const std::size_t max_messages=4, const std::size_t time_period=10, const bool moderator=false)
Definition: player.cpp:18
std::string version_
Definition: player.hpp:59
simple_wml::node & cfg_
Definition: player.hpp:61
bool registered_
Definition: player.hpp:63
bool registered() const
Definition: player.hpp:44
void mark_registered(bool registered=true)
Definition: player.cpp:73
void set_moderator(bool moderator)
Definition: player.hpp:54
STATUS status_
Definition: player.hpp:69
unsigned int messages_since_flood_start_
Definition: player.hpp:66
bool is_message_flooding()
Definition: player.cpp:79
void set_status(STATUS status)
Definition: player.cpp:40
Definition: ban.cpp:28
std::string source_
Definition: player.hpp:60
static map_location::DIRECTION n
const std::string name_
Definition: player.hpp:58
const std::size_t MaxMessages
Definition: player.hpp:67