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

Show available creatures in owned dwellings on right-click

This commit is contained in:
Ivan Savenko 2023-11-02 15:49:45 +02:00
parent f039b20653
commit 1ebb151b41
2 changed files with 25 additions and 0 deletions

View File

@ -335,6 +335,30 @@ void CGDwelling::newTurn(CRandomGenerator & rand) const
updateGuards();
}
std::vector<Component> CGDwelling::getPopupComponents(PlayerColor player) const
{
if (getOwner() != player)
return {};
std::vector<Component> result;
if (ID == Obj::CREATURE_GENERATOR1 && !creatures.empty())
{
for (auto const & creature : creatures.front().second)
result.emplace_back(ComponentType::CREATURE, creature, creatures.front().first);
}
if (ID == Obj::CREATURE_GENERATOR4)
{
for (auto const & creatureLevel : creatures)
{
if (!creatureLevel.second.empty())
result.emplace_back(ComponentType::CREATURE, creatureLevel.second.back(), creatureLevel.first);
}
}
return result;
}
void CGDwelling::updateGuards() const
{
//TODO: store custom guard config and use it

View File

@ -55,6 +55,7 @@ private:
void setPropertyDer(ui8 what, ui32 val) override;
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
std::vector<Component> getPopupComponents(PlayerColor player) const override;
void updateGuards() const;
void heroAcceptsCreatures(const CGHeroInstance *h) const;