-
Notifications
You must be signed in to change notification settings - Fork 0
/
cell.h
52 lines (49 loc) · 1011 Bytes
/
cell.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
#ifndef __CELL_H__
#define __CELL_H__
#include "gamepiece.h"
// Cell class is one block of Floor class
// It's an observer to its neigboring cells
// It might have a pointer to an object
class Cell {
char type;
// type can be:
// ' ' - blank
// '.' - floor
// '\' - vertical wall
// '-' - horizontal wall
// '+' - door
// '#' - passage
// '/' - stairs
int num_neighbors;
Cell *neighbors[8];
// 0 - north
// 1 - north east
// 2 - east
// 3 - south east
// 4 - south
// 5 - south west
// 6 - west
// 7 - north west
GamePiece *piece;
public:
Cell();
~Cell();
// PRE: true
// POST: one of neighbors get filled
void attachNeighbor(Cell *neighbor);
void setType(char c);
GamePiece *getPiece();
void setPiece(GamePiece *piece);
GamePiece *releasePiece();
bool hasPlayer();
GamePiece *findPlayer();
void printCell();
// PRE: true
// POST: 0 - can't move
// 1 - can move
// 2 - door OR passage
// 3 - stairs
// 4 - gold
int canMove();
};
#endif