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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user