2023-08-14 03:20:27 +04:00
|
|
|
/*
|
|
|
|
* TurnTimerHandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-08-30 02:17:29 +04:00
|
|
|
#include "../lib/TurnTimerInfo.h"
|
|
|
|
|
2023-08-14 03:20:27 +04:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-08-14 23:31:44 +04:00
|
|
|
class CStack;
|
2023-08-14 03:20:27 +04:00
|
|
|
class PlayerColor;
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
class CGameHandler;
|
|
|
|
|
|
|
|
class TurnTimerHandler
|
2023-08-30 03:11:46 +04:00
|
|
|
{
|
2023-08-14 03:20:27 +04:00
|
|
|
CGameHandler & gameHandler;
|
|
|
|
const int turnTimePropagateFrequency = 5000;
|
2023-08-14 23:31:44 +04:00
|
|
|
const int turnTimePropagateFrequencyCrit = 1000;
|
|
|
|
const int turnTimePropagateThreshold = 3000;
|
2023-08-30 03:11:46 +04:00
|
|
|
std::map<PlayerColor, TurnTimerInfo> timers;
|
|
|
|
std::map<PlayerColor, int> lastUpdate;
|
2023-08-28 01:10:04 +04:00
|
|
|
std::recursive_mutex mx;
|
2023-08-14 03:20:27 +04:00
|
|
|
|
2023-08-29 15:48:42 +04:00
|
|
|
void onPlayerMakingTurn(PlayerColor player, int waitTime);
|
|
|
|
void onBattleLoop(int waitTime);
|
|
|
|
|
2023-08-30 02:17:29 +04:00
|
|
|
bool timerCountDown(int & timerToApply, int initialTimer, PlayerColor player, int waitTime);
|
|
|
|
bool isPvpBattle() const;
|
|
|
|
void sendTimerUpdate(PlayerColor player);
|
|
|
|
|
2023-08-14 03:20:27 +04:00
|
|
|
public:
|
|
|
|
TurnTimerHandler(CGameHandler &);
|
|
|
|
|
2023-08-26 05:39:29 +04:00
|
|
|
void onGameplayStart(PlayerColor player);
|
|
|
|
void onPlayerGetTurn(PlayerColor player);
|
2023-08-22 14:14:50 +04:00
|
|
|
void onBattleStart();
|
2023-08-22 01:49:50 +04:00
|
|
|
void onBattleNextStack(const CStack & stack);
|
2023-08-30 02:17:29 +04:00
|
|
|
void onBattleEnd();
|
2023-08-29 15:48:42 +04:00
|
|
|
void update(int waitTime);
|
2023-08-28 04:40:35 +04:00
|
|
|
void setTimerEnabled(PlayerColor player, bool enabled);
|
2023-08-14 03:20:27 +04:00
|
|
|
};
|