The Battle for Wesnoth  1.17.0-dev
player.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 
20 #include <ctime>
21 #include <set>
22 
23 namespace wesnothd {
24 
25 class player
26 {
27 public:
28  enum STATUS {
32  };
33 
34  player(const std::string& n, simple_wml::node& cfg, int id, bool registered, const std::string& version, const std::string& source,
35  unsigned long long login_id, const std::size_t max_messages=4, const std::size_t time_period=10,
36  const bool moderator=false);
37 
38  void set_status(STATUS status);
39 
40  // mark a player as member of the game 'game_id' or as located in the lobby
41  void mark_available(const int game_id=0, const std::string& location="");
42 
43  //Mark a player as registered if he has authorized
44  void mark_registered(bool registered =true);
45  bool registered() const {return registered_;}
46 
47 
48  const std::string& name() const { return name_; }
49  const std::string& version() const { return version_; }
50  const std::string& source() const { return source_; }
51  const simple_wml::node* config_address() const { return &cfg_; }
52 
53  bool is_message_flooding();
54 
55  void set_moderator(bool moderator) { moderator_ = moderator; }
56  bool is_moderator() const { return moderator_; }
57 
58  unsigned long long get_login_id() const { return login_id_; };
59 
60 private:
61  const std::string name_;
62  std::string version_;
63  std::string source_;
65 
67 
68  std::time_t flood_start_;
70  const std::size_t MaxMessages;
71  const std::time_t TimePeriod;
73  bool moderator_;
74  unsigned long long login_id_;
75 };
76 
77 } //namespace wesnothd
const simple_wml::node * config_address() const
Definition: player.hpp:51
const std::string & version() const
Definition: player.hpp:49
const std::string & name() const
Definition: player.hpp:48
unsigned long long login_id_
Definition: player.hpp:74
const std::time_t TimePeriod
Definition: player.hpp:71
std::time_t flood_start_
Definition: player.hpp:68
bool is_moderator() const
Definition: player.hpp:56
unsigned long long get_login_id() const
Definition: player.hpp:58
const std::string & source() const
Definition: player.hpp:50
void mark_available(const int game_id=0, const std::string &location="")
Definition: player.cpp:62
std::string version_
Definition: player.hpp:62
player(const std::string &n, simple_wml::node &cfg, int id, bool registered, const std::string &version, const std::string &source, unsigned long long login_id, const std::size_t max_messages=4, const std::size_t time_period=10, const bool moderator=false)
Definition: player.cpp:18
simple_wml::node & cfg_
Definition: player.hpp:64
bool registered_
Definition: player.hpp:66
bool registered() const
Definition: player.hpp:45
void mark_registered(bool registered=true)
Definition: player.cpp:75
void set_moderator(bool moderator)
Definition: player.hpp:55
STATUS status_
Definition: player.hpp:72
unsigned int messages_since_flood_start_
Definition: player.hpp:69
bool is_message_flooding()
Definition: player.cpp:81
void set_status(STATUS status)
Definition: player.cpp:42
std::string source_
Definition: player.hpp:63
static map_location::DIRECTION n
const std::string name_
Definition: player.hpp:58
const std::size_t MaxMessages
Definition: player.hpp:70