瀏覽代碼

Removes a removable event if a draw occurs

Opuszek 1 月之前
父節點
當前提交
df8282cb7e
共有 2 個文件被更改,包括 13 次插入0 次删除
  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;