2023-08-22 17:45:13 +02:00
|
|
|
/*
|
|
|
|
* TurnOrderProcessor.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
|
|
|
|
|
|
|
|
#include "../../lib/GameConstants.h"
|
|
|
|
|
|
|
|
class CGameHandler;
|
|
|
|
|
|
|
|
class TurnOrderProcessor : boost::noncopyable
|
|
|
|
{
|
|
|
|
CGameHandler * gameHandler;
|
|
|
|
|
|
|
|
std::set<PlayerColor> awaitingPlayers;
|
|
|
|
std::set<PlayerColor> actingPlayers;
|
|
|
|
std::set<PlayerColor> actedPlayers;
|
|
|
|
|
|
|
|
/// Returns true if waiting player can act alongside with currently acting player
|
|
|
|
bool canActSimultaneously(PlayerColor active, PlayerColor waiting) const;
|
|
|
|
|
|
|
|
/// Returns true if left player must act before right player
|
|
|
|
bool mustActBefore(PlayerColor left, PlayerColor right) const;
|
|
|
|
|
|
|
|
/// Returns true if player is ready to start turn
|
|
|
|
bool canStartTurn(PlayerColor which) const;
|
|
|
|
|
|
|
|
/// Starts turn for all players that can start turn
|
|
|
|
void tryStartTurnsForPlayers();
|
|
|
|
|
|
|
|
void doStartNewDay();
|
|
|
|
void doStartPlayerTurn(PlayerColor which);
|
2023-08-24 12:36:35 +02:00
|
|
|
void doEndPlayerTurn(PlayerColor which);
|
2023-08-22 17:45:13 +02:00
|
|
|
|
2023-08-24 20:35:01 +02:00
|
|
|
bool playerAwaitsTurn(PlayerColor which) const;
|
|
|
|
bool playerMakingTurn(PlayerColor which) const;
|
|
|
|
bool playerAwaitsNewDay(PlayerColor which) const;
|
|
|
|
|
2023-08-22 17:45:13 +02:00
|
|
|
public:
|
|
|
|
TurnOrderProcessor(CGameHandler * owner);
|
|
|
|
|
|
|
|
/// Add new player to handle (e.g. on game start)
|
|
|
|
void addPlayer(PlayerColor which);
|
|
|
|
|
|
|
|
/// NetPack call-in
|
2023-08-24 12:36:35 +02:00
|
|
|
bool onPlayerEndsTurn(PlayerColor which);
|
|
|
|
|
2023-08-24 20:35:01 +02:00
|
|
|
/// Ends player turn and removes this player from turn order
|
2023-08-24 12:36:35 +02:00
|
|
|
void onPlayerEndsGame(PlayerColor which);
|
2023-08-22 17:45:13 +02:00
|
|
|
|
|
|
|
/// Start game (or resume from save) and send YourTurn pack to player(s)
|
|
|
|
void onGameStarted();
|
|
|
|
|
2023-08-24 20:35:01 +02:00
|
|
|
template<typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
2023-08-22 17:45:13 +02:00
|
|
|
{
|
|
|
|
h & awaitingPlayers;
|
|
|
|
h & actingPlayers;
|
|
|
|
h & actedPlayers;
|
|
|
|
}
|
|
|
|
};
|