From 64c43c91dcdd8de80e0678183e944b2924955c80 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 19 Sep 2023 19:46:27 +0300 Subject: [PATCH] Added hardcoded min/max simturns duration --- server/processors/TurnOrderProcessor.cpp | 17 +++++++++++++---- server/processors/TurnOrderProcessor.h | 5 ++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/server/processors/TurnOrderProcessor.cpp b/server/processors/TurnOrderProcessor.cpp index 028a8fce0..3ccf3b7c7 100644 --- a/server/processors/TurnOrderProcessor.cpp +++ b/server/processors/TurnOrderProcessor.cpp @@ -24,7 +24,13 @@ TurnOrderProcessor::TurnOrderProcessor(CGameHandler * owner): } -int TurnOrderProcessor::simturnsTurnsLimit() const +int TurnOrderProcessor::simturnsTurnsMaxLimit() const +{ + // TODO + return 28; +} + +int TurnOrderProcessor::simturnsTurnsMinLimit() const { // TODO return 7; @@ -45,9 +51,6 @@ bool TurnOrderProcessor::canActSimultaneously(PlayerColor active, PlayerColor wa assert(activeInfo); assert(waitingInfo); - if (gameHandler->getDate(Date::DAY) > simturnsTurnsLimit()) - return false; - if (gameHandler->hasBothPlayersAtSameConnection(active, waiting)) { // only one AI and one human can play simultaneoulsy from single connection @@ -55,6 +58,12 @@ bool TurnOrderProcessor::canActSimultaneously(PlayerColor active, PlayerColor wa return false; } + if (gameHandler->getDate(Date::DAY) < simturnsTurnsMinLimit()) + return true; + + if (gameHandler->getDate(Date::DAY) > simturnsTurnsMaxLimit()) + return false; + if (playersInContact(active, waiting)) return false; diff --git a/server/processors/TurnOrderProcessor.h b/server/processors/TurnOrderProcessor.h index 569597e16..8812f0099 100644 --- a/server/processors/TurnOrderProcessor.h +++ b/server/processors/TurnOrderProcessor.h @@ -22,7 +22,10 @@ class TurnOrderProcessor : boost::noncopyable std::set actedPlayers; /// Returns date on which simturns must end unconditionally - int simturnsTurnsLimit() const; + int simturnsTurnsMaxLimit() const; + + /// Returns date until which simturns must play unconditionally + int simturnsTurnsMinLimit() const; /// Returns true if players are close enough to each other for their heroes to meet on this turn bool playersInContact(PlayerColor left, PlayerColor right) const;