Commit 1ccbd31d authored by louiz’'s avatar louiz’

Add a way to game the current world time

parent ceb4569e
......@@ -87,3 +87,8 @@ void Game::cast_callback(Message* message)
srl.turn());
}
}
utils::FloatingSeconds Game::current_world_time() const
{
return this->turn_handler.get_current_time();
}
......@@ -8,6 +8,7 @@
#include <world/world.hpp>
#include <world/entity.hpp>
#include <utils/time.hpp>
#include <game/turn_handler.hpp>
#include <game/occupants_handler.hpp>
......@@ -22,6 +23,7 @@ public:
void new_entity_callback(Message* msg);
void move_callback(Message* msg);
void cast_callback(Message* msg);
utils::FloatingSeconds current_world_time() const;
protected:
World world;
......
......@@ -103,6 +103,14 @@ unsigned long TurnHandler::get_current_turn() const
return this->current_turn;
}
utils::FloatingSeconds TurnHandler::get_current_time() const
{
auto total_ticks = this->get_current_turn() * TURN_TICKS +\
this->turn_advancement;
auto ticks_duration = utils::ticks(total_ticks);
return std::chrono::duration_cast<utils::FloatingSeconds>(ticks_duration);
}
std::deque<Turn>& TurnHandler::get_turns()
{
return this->turns;
......
......@@ -11,10 +11,11 @@
#include <functional>
#include <game/turn.hpp>
#include <utils/time.hpp>
#include <world/action.hpp>
using TurnNb = std::size_t;
using t_next_turn_callback = std::function< void(const TurnNb)>;
using t_next_turn_callback = std::function<void(const TurnNb)>;
/**
* The number of ticks contained in a turn
......@@ -60,6 +61,10 @@ public:
TurnNb get_current_turn() const;
std::deque<Turn>& get_turns();
TurnNb get_last_ready_turn() const;
/**
* Returns the time in seconds, spent so far in this TurnHandler
*/
utils::FloatingSeconds get_current_time() const;
private:
TurnHandler(const TurnHandler&);
......
......@@ -19,6 +19,8 @@
#include <iostream>
using namespace std::string_literals;
Camera::Camera(GameClient* game, Screen* screen):
ScreenElement(screen),
x(0),
......@@ -385,6 +387,8 @@ void Camera::draw()
else
this->game->get_debug_hud().add_debug_line("No entity under mouse");
this->game->get_debug_hud().add_debug_line("Current world time: "s + std::to_string(this->get_game_client()->current_world_time().count()));
this->draw(this->fog.get_sprite());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment