-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameObservers.h
84 lines (81 loc) · 2.24 KB
/
GameObservers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include <list>
#include <string>
#include<iostream>
using namespace std;
class WarzoneGame;
class Observer
{
public:
virtual void Update() =0;
~Observer();
Observer(const Observer& obs);
Observer& operator = ( const Observer& obs);
friend ostream &operator << (ostream& out, const Observer& o);
protected:
Observer();
};
//superclass of model
class Subject
{
public:
virtual void Attach(Observer* o);
virtual void Detach(Observer* o);
virtual void Notify();
Subject();
~Subject();
Subject(const Subject& obs);
Subject& operator = (const Subject& obs);
friend ostream& operator << (ostream& out, const Subject& o);
private:
std::list<Observer*>* _observers;
};
//phase view
class GameScreen : public Observer
{
public:
GameScreen();
GameScreen(WarzoneGame* s);
~GameScreen();
void Update();
void displayReinforcementPhase();
void displayIssuOrdersPhase();
void displayExecuteOrdersPhase();
void clearScreen();
GameScreen(const GameScreen& obs);
GameScreen& operator = (const GameScreen& obs);
friend ostream& operator << (ostream& out, const GameScreen& o);
private:
WarzoneGame* _subject;
};
//stats view
class StatsScreen : public Observer
{
public:
StatsScreen();
StatsScreen(WarzoneGame* s);
~StatsScreen();
void Update();
void Display();
void displayWin();
void clearScreen();
StatsScreen(const StatsScreen& obs);
StatsScreen& operator = (const StatsScreen& obs);
friend ostream& operator << (ostream& out, const StatsScreen& o);
private:
WarzoneGame* _subject;
};
//controller
class GameController
{
public:
GameController(GameScreen* newView, StatsScreen* otherView, WarzoneGame* newModel);
void controlGame();
GameController(const GameController& obs);
GameController& operator = (const GameController& obs);
friend ostream& operator << (ostream& out, const GameController o);
private:
GameScreen* gameView;
StatsScreen* statsView;
WarzoneGame* gameModel;
};