mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Use and check movement points in town portal.
* fixes mantiss 0002031
This commit is contained in:
parent
d564520f04
commit
6c334174d9
@ -709,15 +709,23 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
|
||||
std::vector <int> availableTowns;
|
||||
std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
|
||||
|
||||
vstd::erase_if(Towns, [](const CGTownInstance * t)
|
||||
vstd::erase_if(Towns, [this](const CGTownInstance * t)
|
||||
{
|
||||
const auto relations = LOCPLINT->cb->getPlayerRelations(t->tempOwner, LOCPLINT->playerID);
|
||||
const auto relations = owner->myInt->cb->getPlayerRelations(t->tempOwner, owner->myInt->playerID);
|
||||
return relations == PlayerRelations::ENEMIES;
|
||||
});
|
||||
|
||||
|
||||
if (Towns.empty())
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[124]);
|
||||
owner->myInt->showInfoDialog(CGI->generaltexth->allTexts[124]);
|
||||
return;
|
||||
}
|
||||
|
||||
const int movementCost = (h->getSpellSchoolLevel(sp) >= 3) ? 200 : 300;
|
||||
|
||||
if(h->movement < movementCost)
|
||||
{
|
||||
owner->myInt->showInfoDialog(CGI->generaltexth->allTexts[125]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,22 @@ bool TownPortalMechanics::applyAdventureEffects(const SpellCastEnvironment * env
|
||||
}
|
||||
|
||||
}
|
||||
env->moveHero(parameters.caster->id, town->visitablePos() + parameters.caster->getVisitableOffset() ,1);
|
||||
|
||||
const int movementCost = (parameters.caster->getSpellSchoolLevel(owner) >= 3) ? 200 : 300;
|
||||
|
||||
if(parameters.caster->movement < movementCost)
|
||||
{
|
||||
env->complain("This hero has not enough movement points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(env->moveHero(parameters.caster->id, town->visitablePos() + parameters.caster->getVisitableOffset() ,1))
|
||||
{
|
||||
SetMovePoints smp;
|
||||
smp.hid = parameters.caster->id;
|
||||
smp.val = std::max<ui32>(0, parameters.caster->movement - movementCost);
|
||||
env->sendAndApply(&smp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user