mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-28 03:57:02 +02:00
Slight refactoring of CGHeroInstance::movementPointsAfterEmbark()
This commit is contained in:
parent
aae9e70771
commit
a0cd69e944
@ -1106,22 +1106,19 @@ CBonusSystemNode & CGHeroInstance::whereShouldBeAttached(CGameState * gs)
|
|||||||
|
|
||||||
int CGHeroInstance::movementPointsAfterEmbark(int MPsBefore, int basicCost, bool disembark, const TurnInfo * ti) const
|
int CGHeroInstance::movementPointsAfterEmbark(int MPsBefore, int basicCost, bool disembark, const TurnInfo * ti) const
|
||||||
{
|
{
|
||||||
int ret = 0; //take all MPs by default
|
std::unique_ptr<TurnInfo> turnInfoLocal;
|
||||||
bool localTi = false;
|
|
||||||
if(!ti)
|
if(!ti)
|
||||||
{
|
{
|
||||||
localTi = true;
|
turnInfoLocal = std::make_unique<TurnInfo>(this);
|
||||||
ti = new TurnInfo(this);
|
ti = turnInfoLocal.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!ti->hasBonusOfType(Bonus::FREE_SHIP_BOARDING))
|
||||||
|
return 0; // take all MPs by default
|
||||||
|
|
||||||
int mp1 = ti->getMaxMovePoints(disembark ? EPathfindingLayer::LAND : EPathfindingLayer::SAIL);
|
int mp1 = ti->getMaxMovePoints(disembark ? EPathfindingLayer::LAND : EPathfindingLayer::SAIL);
|
||||||
int mp2 = ti->getMaxMovePoints(disembark ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND);
|
int mp2 = ti->getMaxMovePoints(disembark ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND);
|
||||||
if(ti->hasBonusOfType(Bonus::FREE_SHIP_BOARDING))
|
int ret = static_cast<int>((MPsBefore - basicCost) * static_cast<double>(mp1) / mp2);
|
||||||
ret = static_cast<int>((MPsBefore - basicCost) * static_cast<double>(mp1) / mp2);
|
|
||||||
|
|
||||||
if(localTi)
|
|
||||||
delete ti;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user