Explorar o código

Removes a removable event if a draw occurs

Opuszek hai 1 mes
pai
achega
df8282cb7e
Modificáronse 2 ficheiros con 13 adicións e 0 borrados
  1. 12 0
      lib/mapObjects/CGPandoraBox.cpp
  2. 1 0
      lib/mapObjects/CGPandoraBox.h

+ 12 - 0
lib/mapObjects/CGPandoraBox.cpp

@@ -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
 {
 	CRewardableObject::grantRewardWithMessage(gameEvents, contextHero, rewardIndex, markAsVisit);

+ 1 - 0
lib/mapObjects/CGPandoraBox.h

@@ -65,6 +65,7 @@ public:
 	}
 
 	void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override;
+	void battleFinished(IGameEventCallback & gameEvents, const CGHeroInstance *hero, const BattleResult &result) const override;
 protected:
 	void grantRewardWithMessage(IGameEventCallback & gameEvents, const CGHeroInstance * contextHero, int rewardIndex, bool markAsVisit) const override;