-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathknowledge.h
More file actions
127 lines (119 loc) · 4.25 KB
/
knowledge.h
File metadata and controls
127 lines (119 loc) · 4.25 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef CKNOWLEDGE_H
#define CKNOWLEDGE_H
#include "base.h"
#include "map.h"
#include "robots.h"
#include "statuswidget.h"
#include <QObject>
/**
* @brief
*Is created to save all the robots in one signle data structure
*/
union Robots{
CExplorerRobot *e; /**< Explorer Robots */
CTerminatorRobot *t; /**< Terminator Robots */
CNinjaRobot *n; /**< Ninja Robots */
CPredatorRobot *p; /**< Predator Robots */
};
/**
* @brief
*Saves all the information about a team that game needs to handle
*/
class team
{
public:
int color; /**< TODO */
QList<CExplorerRobot*> explorers; /**< TODO */
QList<CNinjaRobot*> ninjas; /**< TODO */
QList<CTerminatorRobot*> terminators; /**< TODO */
QList<CPredatorRobot*> predators; /**< TODO */
int rhodium; /**< TODO */
int platinum; /**< TODO */
int gold; /**< TODO */
bool active; /**< TODO */
QList<int> protectedCells; /**< TODO */
};
/**
* @brief
* The brain of the game, all the information needed to be shared between classes in the program are stored here
*/
class CKnowledge : public QObject
{
Q_OBJECT
public:
explicit CKnowledge(CStatusPrinter *_printer, QObject *parent = 0);
~CKnowledge();
/**
* @brief
* Returns the image of the robot considering following parameters
* @param id = Id of team
* @param model = Type of the robot
* @param direction = direction of the robot
* @return QPixmap
*/
inline QPixmap getRobotsPic(int id, int model, int direction){return robotsPics[id][model][direction];}
/**
* @brief
* For printing any text with any color in Status bar
* @param text = text you want to print
* @param color = selected color for text, default is black
*/
void debug(QString text, QColor color = QColor(0,0,0));
/**
* @brief
* Checks if a robot purchase is valid for team requested the purchase
* @param id = team id of the buyer
* @param num = number of robots team wants to buy
* @param model = type of robot requested for purchase
* @param pos = position that robot should be played on
* @param error = in case of invalid purchase request, returns why it is invalid
* @return bool
*/
bool canBuy(int id, int num, int model, int pos, QString &error);
/**
* @brief
* checks if a requested movement is valid
* @param id = Team id
* @param num = number of robots team wants to move
* @param model = type of robot
* @param from = curent position of robots
* @param to = destination
* @param error = in case of invalid move request, returns why it is invalid
* @return bool
*/
bool canGo(int id, int num, int model, int from, int to, QString &error);
QMap< int, price> robotsPrice; /**< prices of the robots map to the robot enum */
CMap *map; /**< The instance of map class */
QList<Robots> robots; /**< Not being used for now */
team teams[4]; /**< The 4 teams playing this game made of Team class */
Property(int, ActiveTeams, activeTeams); /**< Number of active teams */
PropertyGet(QPixmap***, RobotsPics, robotsPics); /**< pictures of robots, Usage: [Team][Robot][Direction] */
private:
CStatusPrinter *printer; /**< the pointer of printer is passed to this class which writes the data in Status Widget */
signals:
/**
* @brief
* If user creates a new map, it will tell the monitor widget to resize it's view port to fit all the map in
*/
void updateMonitorView();
public slots:
/**
* @brief
* Activate od deactivate a team due request of CGame
* @param i = team ID
* @param s = True(Activate) , False(Deactivate)
*/
void activateSlot(int i, bool s);
/**
* @brief
* Creates a new map with information sent from CLoadMapWdiget by mapGenerationSignal(int,int,int,int,int) signal
* @param _r = number of rows
* @param _c = number of columns
* @param _rh = Rhodium source available on map
* @param _pl = Platinum source available on map
* @param _gl = Gold source available on map
*/
void generateMap(int _r, int _c, int _rh, int _pl, int _gl);
};
extern CKnowledge* knowledge; /**< Extern the pointer to this class to be accesible for any class includes this file */
#endif // CKNOWLEDGE_H