Files
Blitz/include/blitz/protocol/packets/UpdateGameStatePacket.h
Persson-dev c2c6f1f033
All checks were successful
Linux arm64 / Build (push) Successful in 4m59s
C'est important la doc (#43)
C'est très long

Co-authored-by: Morph01 <thibaut6969delastreet@gmail.com>
Reviewed-on: #43
Co-authored-by: Persson-dev <sim16.prib@gmail.com>
Co-committed-by: Persson-dev <sim16.prib@gmail.com>
2024-04-11 17:17:40 +02:00

72 lines
1.9 KiB
C++

#pragma once
/**
* \file UpdateGameStatePacket.h
* \brief File containing the blitz::protocol::UpdateGameStatePacket class
*/
#include "blitz/game/Game.h"
#include "blitz/protocol/Protocol.h"
namespace blitz {
namespace protocol {
/**
* \class UpdateGameStatePacket
* \brief Packet for updating the game state.
* %Packet structure :
* | PacketType |
* |-----------------------------|
* | PacketType::UpdateGameState |
*
* | Field Name | Field Type | Notes |
* |--------------------|-------------------|----------------------------------------------|
* | Game State | GameState | The new game state |
* | Time Remaining | std::uint64_t | The time remaining in the current game state |
*/
class UpdateGameStatePacket : public Packet {
private:
game::GameState m_GameState;
std::uint64_t m_TimeRemaining;
public:
/**
* \brief Default constructor.
*/
UpdateGameStatePacket() {}
/**
* \brief Constructor.
* \param a_GameState The new game state.
* \param a_TimeRemaining The time remaining in the current game state.
*/
UpdateGameStatePacket(game::GameState a_GameState, std::uint64_t a_TimeRemaining = 0) :
m_GameState(a_GameState), m_TimeRemaining(a_TimeRemaining) {}
virtual ~UpdateGameStatePacket() {}
virtual DataBuffer Serialize(bool packetID = true) const;
virtual void Deserialize(DataBuffer& data);
virtual void Dispatch(PacketHandler* handler) const;
/**
* \brief Get the new game state.
* \return The new game state.
*/
game::GameState GetGameState() const {
return m_GameState;
}
/**
* \brief Get the time remaining in the current game state.
* \return The time remaining in the current game state.
*/
std::uint64_t GetTimeRemaining() const {
return m_TimeRemaining;
}
virtual PacketType GetType() const {
return PacketType::UpdateGameState;
}
};
} // namespace protocol
} // namespace blitz