diff --git a/projects/mtg/include/ActionLayer.h b/projects/mtg/include/ActionLayer.h index 995443558..cde484400 100644 --- a/projects/mtg/include/ActionLayer.h +++ b/projects/mtg/include/ActionLayer.h @@ -12,6 +12,8 @@ #include "SimpleMenu.h" #include "MTGAbility.h" +#include + class GuiLayer; class Targetable; class WEvent; @@ -49,6 +51,7 @@ public: protected: ActionElement * currentWaitingAction; int cantCancel; + std::set mReactions; }; #endif diff --git a/projects/mtg/src/ActionLayer.cpp b/projects/mtg/src/ActionLayer.cpp index e811c51b3..50c664f12 100644 --- a/projects/mtg/src/ActionLayer.cpp +++ b/projects/mtg/src/ActionLayer.cpp @@ -242,7 +242,11 @@ int ActionLayer::isReactingToClick(MTGCardInstance * card) for (int i = 0; i < mCount; i++) { ActionElement * currentAction = (ActionElement *) mObjects[i]; - result += currentAction->isReactingToClick(card); + if (currentAction->isReactingToClick(card)) + { + ++result; + mReactions.insert(currentAction); + } } return result; @@ -256,13 +260,22 @@ int ActionLayer::reactToClick(MTGCardInstance * card) if (ae) return reactToClick(ae, card); - for (int i = 0; i < mCount; i++) + std::set::const_iterator iter = mReactions.begin(); + std::set::const_iterator end = mReactions.end(); + for (; iter !=end; ++iter) { - ActionElement * currentAction = (ActionElement *) mObjects[i]; - result += reactToClick(currentAction, card); + result += reactToClick(*iter, card); if (result) - return result; + break; } + +#ifdef WIN32 + // if we hit this, then something strange has happened with the click logic - reactToClick() + // should never be called if isReactingToClick() previously didn't have an object return true + assert(!mReactions.empty()); +#endif + + mReactions.clear(); return result; }