- Send an event when Phase changes
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-06-16 14:10:33 +00:00
parent 96963fc5ac
commit 7804cbbd64
3 changed files with 22 additions and 0 deletions

View File

@@ -4,12 +4,14 @@
class MTGCardInstance; class MTGCardInstance;
class MTGGameZone; class MTGGameZone;
class Damage; class Damage;
class Phase;
class WEvent{ class WEvent{
public: public:
enum{ enum{
CHANGE_ZONE = 1, CHANGE_ZONE = 1,
DAMAGE = 2, DAMAGE = 2,
CHANGE_PHASE = 3,
}; };
int type; int type;
WEvent(int _type); WEvent(int _type);
@@ -32,4 +34,11 @@ public:
WEventDamage(Damage * _damage); WEventDamage(Damage * _damage);
}; };
class WEventPhaseChange: public WEvent{
public:
Phase * from;
Phase * to;
WEventPhaseChange(Phase * _from, Phase * _to);
};
#endif #endif

View File

@@ -80,8 +80,15 @@ void GameObserver::nextPlayer(){
} }
void GameObserver::nextGamePhase(){ void GameObserver::nextGamePhase(){
Phase * cPhaseOld = phaseRing->getCurrentPhase();
phaseRing->forward(); phaseRing->forward();
Phase * cPhase = phaseRing->getCurrentPhase(); Phase * cPhase = phaseRing->getCurrentPhase();
//Warn the layers about the phase Change
WEvent * e = NEW WEventPhaseChange(cPhaseOld, cPhase);
receiveEvent(e);
delete e;
currentGamePhase = cPhase->id; currentGamePhase = cPhase->id;
if (currentPlayer != cPhase->player) nextPlayer(); if (currentPlayer != cPhase->player) nextPlayer();

View File

@@ -2,6 +2,7 @@
#include "../include/MTGCardInstance.h" #include "../include/MTGCardInstance.h"
#include "../include/MTGGameZones.h" #include "../include/MTGGameZones.h"
#include "../include/Damage.h" #include "../include/Damage.h"
#include "../include/PhaseRing.h"
WEvent::WEvent(int _type){ WEvent::WEvent(int _type){
type=_type; type=_type;
@@ -15,4 +16,9 @@ WEventZoneChange::WEventZoneChange(MTGCardInstance * _card, MTGGameZone * _from,
WEventDamage::WEventDamage(Damage *_damage):WEvent(DAMAGE){ WEventDamage::WEventDamage(Damage *_damage):WEvent(DAMAGE){
damage = _damage; damage = _damage;
}
WEventPhaseChange::WEventPhaseChange(Phase * _from, Phase * _to):WEvent(CHANGE_PHASE){
from = _from;
to = _to;
} }