1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Implemented giving bonuses to commanders

This commit is contained in:
Ivan Savenko
2025-05-07 22:44:44 +03:00
parent 434da3ffe1
commit 6b6199d3a4
7 changed files with 25 additions and 2 deletions

View File

@@ -175,6 +175,7 @@ void Rewardable::Info::configureReward(Rewardable::Configuration & object, vstd:
reward.removeObject = source["removeObject"].Bool();
reward.heroBonuses = randomizer.loadBonuses(source["bonuses"]);
reward.commanderBonuses = randomizer.loadBonuses(source["commanderBonuses"]);
reward.playerBonuses = randomizer.loadBonuses(source["playerBonuses"]);
reward.guards = randomizer.loadCreatures(source["guards"], rng, variables);

View File

@@ -157,6 +157,15 @@ void Rewardable::Interface::grantRewardAfterLevelup(const Rewardable::VisitInfo
cb->giveHeroBonus(&gb);
}
if (hero->getCommander())
{
for(const Bonus & bonus : info.reward.commanderBonuses)
{
GiveBonus gb(GiveBonus::ETarget::HERO_COMMANDER, hero->id, bonus);
cb->giveHeroBonus(&gb);
}
}
for(const Bonus & bonus : info.reward.playerBonuses)
{
GiveBonus gb(GiveBonus::ETarget::PLAYER, hero->getOwner(), bonus);

View File

@@ -87,6 +87,7 @@ struct DLL_LINKAGE Reward final
/// list of bonuses, e.g. morale/luck
std::vector<Bonus> heroBonuses;
std::vector<Bonus> commanderBonuses;
std::vector<Bonus> playerBonuses;
/// skills that hero may receive or lose
@@ -147,6 +148,7 @@ struct DLL_LINKAGE Reward final
if (h.version >= Handler::Version::REWARDABLE_EXTENSIONS)
{
h & playerBonuses;
h & commanderBonuses;
}
h & grantedArtifacts;
if (h.version >= Handler::Version::REWARDABLE_EXTENSIONS)