ActionElement.h: Replace defines, remove superfluous ";"

Defines do not follow scope rules, but enums do. Enum classes
even utilize strong type checking (but i am not sure about compiler
support for c++11 on all target platforms).
This commit is contained in:
Tobias Loose
2013-11-17 16:08:29 +01:00
parent c6dc51c7d3
commit 146872797b
3 changed files with 15 additions and 28 deletions
+9 -16
View File
@@ -9,10 +9,6 @@
#include <JGui.h> #include <JGui.h>
#include "MTGDefinitions.h" #include "MTGDefinitions.h"
#define INACTIVE 0
#define ACTION_REQUESTED 1
#define ACTIVE 2
class MTGCardInstance; class MTGCardInstance;
class ManaCost; class ManaCost;
class Targetable; class Targetable;
@@ -22,31 +18,33 @@ class WEvent;
class ActionElement: public JGuiObject class ActionElement: public JGuiObject
{ {
protected: protected:
int activeState; enum Activity{
Inactive,
ActionRequested,
Active
};
Activity activity;
TargetChooser * tc; TargetChooser * tc;
public: public:
GamePhase currentPhase; GamePhase currentPhase;
GamePhase newPhase; GamePhase newPhase;
int modal; int modal;
int waitingForAnswer; int waitingForAnswer;
int getActivity(); virtual void Update(float){}
virtual void Update(float){}; virtual void Render(){}
virtual void Render(){};
virtual int testDestroy() virtual int testDestroy()
{ {
return 0; return 0;
} }
;
virtual int destroy() virtual int destroy()
{ {
return 0; return 0;
} }
;
virtual bool CheckUserInput(JButton) virtual bool CheckUserInput(JButton)
{ {
return false; return false;
} }
;
ActionElement(int id); ActionElement(int id);
ActionElement(const ActionElement& copyFromMe); ActionElement(const ActionElement& copyFromMe);
TargetChooser * getActionTc(){return tc;} TargetChooser * getActionTc(){return tc;}
@@ -62,27 +60,22 @@ public:
{ {
return 0; return 0;
} }
;
virtual int stillInUse(MTGCardInstance *) virtual int stillInUse(MTGCardInstance *)
{ {
return 0; return 0;
} }
;
virtual int receiveEvent(WEvent *) virtual int receiveEvent(WEvent *)
{ {
return 0; return 0;
} }
;
virtual int reactToClick(MTGCardInstance *) virtual int reactToClick(MTGCardInstance *)
{ {
return 0; return 0;
} }
;
virtual const char * getMenuText() virtual const char * getMenuText()
{ {
return "Ability"; return "Ability";
} }
;
virtual ActionElement * clone() const = 0; virtual ActionElement * clone() const = 0;
}; };
+2 -8
View File
@@ -8,7 +8,7 @@
ActionElement::ActionElement(int id) : ActionElement::ActionElement(int id) :
JGuiObject(id) JGuiObject(id)
{ {
activeState = INACTIVE; activity = Inactive;
modal = 0; modal = 0;
waitingForAnswer = 0; waitingForAnswer = 0;
currentPhase = MTG_PHASE_INVALID; currentPhase = MTG_PHASE_INVALID;
@@ -18,7 +18,7 @@ ActionElement::ActionElement(int id) :
ActionElement::ActionElement(const ActionElement& a): JGuiObject(a) ActionElement::ActionElement(const ActionElement& a): JGuiObject(a)
{ {
activeState = a.activeState; activity = a.activity;
tc = a.tc ? a.tc->clone() : NULL; tc = a.tc ? a.tc->clone() : NULL;
currentPhase = a.currentPhase; currentPhase = a.currentPhase;
newPhase = a.newPhase; newPhase = a.newPhase;
@@ -31,12 +31,6 @@ ActionElement::~ActionElement()
SAFE_DELETE(tc); SAFE_DELETE(tc);
} }
int ActionElement::getActivity()
{
return activeState;
}
int ActionElement::isReactingToTargetClick(Targetable * object) int ActionElement::isReactingToTargetClick(Targetable * object)
{ {
if (MTGCardInstance * cObject = dynamic_cast<MTGCardInstance *>(object)) if (MTGCardInstance * cObject = dynamic_cast<MTGCardInstance *>(object))
+4 -4
View File
@@ -17,7 +17,7 @@ void MTGGamePhase::Update(float)
int newState = observer->getCurrentGamePhase(); int newState = observer->getCurrentGamePhase();
if (newState != currentState) if (newState != currentState)
{ {
activeState = ACTIVE; activity = Active;
animation = 4; animation = 4;
currentState = newState; currentState = newState;
} }
@@ -28,18 +28,18 @@ void MTGGamePhase::Update(float)
} }
else else
{ {
activeState = INACTIVE; activity = Inactive;
animation = 0; animation = 0;
} }
} }
bool MTGGamePhase::NextGamePhase() bool MTGGamePhase::NextGamePhase()
{ {
if (activeState == INACTIVE) if (activity == Inactive)
{ {
if (observer->currentActionPlayer == observer->currentlyActing()) if (observer->currentActionPlayer == observer->currentlyActing())
{ {
activeState = ACTIVE; activity = Active;
observer->userRequestNextGamePhase(); observer->userRequestNextGamePhase();
return true; return true;
} }