1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Show total movement cost for multi-turn paths

This commit is contained in:
Ivan Savenko
2025-02-08 20:32:11 +00:00
parent c13edc8af3
commit 2468ab54ea
14 changed files with 20 additions and 28 deletions

View File

@@ -47,6 +47,7 @@
#include "../../lib/mapObjects/CGTownInstance.h"
#include "../../lib/mapping/CMapDefines.h"
#include "../../lib/pathfinder/CGPathNode.h"
#include "../../lib/pathfinder/TurnInfo.h"
#include "../../lib/spells/ISpellMechanics.h"
#include "../../lib/spells/Problem.h"
@@ -776,13 +777,26 @@ void AdventureMapInterface::showMoveDetailsInStatusbar(const CGHeroInstance & he
{
const int maxMovementPointsAtStartOfLastTurn = pathNode.turns > 0 ? hero.movementPointsLimit(pathNode.layer == EPathfindingLayer::LAND) : hero.movementPointsRemaining();
const int movementPointsLastTurnCost = maxMovementPointsAtStartOfLastTurn - pathNode.moveRemains;
const int remainingPointsAfterMove = pathNode.turns == 0 ? pathNode.moveRemains : 0;
const int remainingPointsAfterMove = pathNode.moveRemains;
int totalMovementCost = 0;
for (int i = 0; i <= pathNode.turns; ++i)
{
auto turnInfo = hero.getTurnInfo(i);
if (pathNode.layer == EPathfindingLayer::SAIL)
totalMovementCost += turnInfo->getMovePointsLimitWater();
else
totalMovementCost += turnInfo->getMovePointsLimitLand();
}
totalMovementCost -= pathNode.moveRemains;
std::string result = VLC->generaltexth->translate("vcmi.adventureMap", pathNode.turns > 0 ? "moveCostDetails" : "moveCostDetailsNoTurns");
boost::replace_first(result, "%TURNS", std::to_string(pathNode.turns));
boost::replace_first(result, "%POINTS", std::to_string(movementPointsLastTurnCost));
boost::replace_first(result, "%REMAINING", std::to_string(remainingPointsAfterMove));
boost::replace_first(result, "%TOTAL", std::to_string(totalMovementCost));
GH.statusbar()->write(result);
}