diff --git a/projects/mtg/include/WEvent.h b/projects/mtg/include/WEvent.h index 612289e2c..ce3d5804f 100644 --- a/projects/mtg/include/WEvent.h +++ b/projects/mtg/include/WEvent.h @@ -4,12 +4,14 @@ class MTGCardInstance; class MTGGameZone; class Damage; +class Phase; class WEvent{ public: enum{ CHANGE_ZONE = 1, DAMAGE = 2, + CHANGE_PHASE = 3, }; int type; WEvent(int _type); @@ -32,4 +34,11 @@ public: WEventDamage(Damage * _damage); }; +class WEventPhaseChange: public WEvent{ +public: + Phase * from; + Phase * to; + WEventPhaseChange(Phase * _from, Phase * _to); +}; + #endif diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index de9f0b531..0c7777767 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -80,8 +80,15 @@ void GameObserver::nextPlayer(){ } void GameObserver::nextGamePhase(){ + Phase * cPhaseOld = phaseRing->getCurrentPhase(); phaseRing->forward(); Phase * cPhase = phaseRing->getCurrentPhase(); + + //Warn the layers about the phase Change + WEvent * e = NEW WEventPhaseChange(cPhaseOld, cPhase); + receiveEvent(e); + delete e; + currentGamePhase = cPhase->id; if (currentPlayer != cPhase->player) nextPlayer(); diff --git a/projects/mtg/src/WEvent.cpp b/projects/mtg/src/WEvent.cpp index 106962934..197765665 100644 --- a/projects/mtg/src/WEvent.cpp +++ b/projects/mtg/src/WEvent.cpp @@ -2,6 +2,7 @@ #include "../include/MTGCardInstance.h" #include "../include/MTGGameZones.h" #include "../include/Damage.h" +#include "../include/PhaseRing.h" WEvent::WEvent(int _type){ type=_type; @@ -15,4 +16,9 @@ WEventZoneChange::WEventZoneChange(MTGCardInstance * _card, MTGGameZone * _from, WEventDamage::WEventDamage(Damage *_damage):WEvent(DAMAGE){ damage = _damage; +} + +WEventPhaseChange::WEventPhaseChange(Phase * _from, Phase * _to):WEvent(CHANGE_PHASE){ + from = _from; + to = _to; } \ No newline at end of file