1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Handle timer for tactic phase

This commit is contained in:
nordsoft 2023-08-28 02:00:02 +04:00
parent 4ee47b01ae
commit 7dc1717ec6

View File

@ -151,11 +151,21 @@ void TurnTimerHandler::onBattleLoop(int waitTime)
std::lock_guard<std::recursive_mutex> guard(mx);
const auto * stack = gs->curB.get()->battleGetStackByID(gs->curB->getActiveStackID());
if(!stack || !stack->getOwner().isValidPlayer())
return;
ui8 side = 0;
const CStack * stack = nullptr;
bool isTactisPhase = gs->curB.get()->battleTacticDist() > 0;
auto & state = gs->players.at(gs->curB->getSidePlayer(stack->unitSide()));
if(isTactisPhase)
side = gs->curB.get()->battleGetTacticsSide();
else
{
stack = gs->curB.get()->battleGetStackByID(gs->curB->getActiveStackID());
if(!stack || !stack->getOwner().isValidPlayer())
return;
side = stack->unitSide();
}
auto & state = gs->players.at(gs->curB->getSidePlayer(side));
auto turnTimerUpdateApplier = [&](TurnTimerInfo & tTimer, int waitTime)
{
@ -192,9 +202,14 @@ void TurnTimerHandler::onBattleLoop(int waitTime)
else
{
BattleAction doNothing;
doNothing.actionType = EActionType::DEFEND;
doNothing.side = stack->unitSide();
doNothing.stackNumber = stack->unitId();
doNothing.side = side;
if(isTactisPhase)
doNothing.actionType = EActionType::END_TACTIC_PHASE;
else
{
doNothing.actionType = EActionType::DEFEND;
doNothing.stackNumber = stack->unitId();
}
gameHandler.battles->makePlayerBattleAction(state.color, doNothing);
}
}