The Battle for Wesnoth  1.19.5+dev
countdown_clock.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2024
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 "events.hpp"
18 #include <chrono>
19 
20 class team;
22 {
23  using clock = std::chrono::steady_clock;
24 
25 public:
28 
29  /** @returns ticks passed since last update */
30  std::chrono::milliseconds update_timestamp();
31 
32  void update_team();
33 
34  /** Inherited from pump_monitor */
35  virtual void process() override;
36 
37  /** @returns whether there is time left */
38  bool update();
39 
40  void maybe_play_sound();
41 
42 private:
44  clock::time_point last_timestamp_;
46 };
countdown_clock(team &team)
std::chrono::steady_clock clock
clock::time_point last_timestamp_
virtual void process() override
Inherited from pump_monitor.
std::chrono::milliseconds update_timestamp()
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:75