-
Notifications
You must be signed in to change notification settings - Fork 0
/
place.h
43 lines (37 loc) · 804 Bytes
/
place.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
#pragma once
#include "object.h"
// places are responsible for their inventory
// i.e. all the stuff on their tile
class Place : public Object {
public:
Place(int row, int col) {
location = {row, col};
}
bool is_clear() {
bool clear = true;
for (auto& a : inventory)
clear &= a->is(WALKABLE);
return clear & is(WALKABLE);
}
void display() {
Object::display();
for (auto& contents : inventory) {
contents->display();
}
}
};
class Floor : public Place {
public:
Floor(int row, int col) : Place(row, col) {
symbol = '.';
is(WALKABLE) = true;
}
};
class Wall : public Place {
public:
Wall(int row, int col) : Place(row, col) {
symbol = '#';
is(WALKABLE) = false;
color = WHITE;
}
};