mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Removes a removable event if a draw occurs
This commit is contained in:
@@ -294,6 +294,18 @@ void CGEvent::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGEvent::battleFinished(IGameEventCallback & gameEvents, const CGHeroInstance *hero, const BattleResult &result) const
|
||||||
|
{
|
||||||
|
if(result.winner == BattleSide::ATTACKER)
|
||||||
|
{
|
||||||
|
CRewardableObject::onHeroVisit(gameEvents, hero);
|
||||||
|
}
|
||||||
|
if(result.winner == BattleSide::NONE && removeAfterVisit) //rewards are lost if therer is a draw and an event is not repeatable
|
||||||
|
{
|
||||||
|
gameEvents.removeObject(this, result.attacker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGEvent::grantRewardWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const
|
void CGEvent::grantRewardWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const
|
||||||
{
|
{
|
||||||
CRewardableObject::grantRewardWithMessage(gameEvents, contextHero, rewardIndex, markAsVisit);
|
CRewardableObject::grantRewardWithMessage(gameEvents, contextHero, rewardIndex, markAsVisit);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override;
|
void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override;
|
||||||
|
void battleFinished(IGameEventCallback & gameEvents, const CGHeroInstance *hero, const BattleResult &result) const override;
|
||||||
protected:
|
protected:
|
||||||
void grantRewardWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const override;
|
void grantRewardWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user