-
Notifications
You must be signed in to change notification settings - Fork 0
/
FieldBuilder.h
36 lines (30 loc) · 921 Bytes
/
FieldBuilder.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
#pragma once
#include "GameConfigurator.h"
#include "Field.h"
/*
FuildBuilder is responsible for abstracting out the logic for
creating a field. It guarantees that a created field will
always be valid
*/
class FieldBuilder {
public:
FieldBuilder(GameConfigurator &gameConfigurator,
bool shouldRenderEveryGeneration) :
_field(nullptr) {
if (gameConfigurator.getFieldHeight() > 1 &&
gameConfigurator.getFieldWidth() > 1) {
_field = new Field(gameConfigurator.getFieldWidth(),
gameConfigurator.getFieldHeight(),
shouldRenderEveryGeneration);
gameConfigurator.populateField(*_field);
}
}
~FieldBuilder() {
delete _field;
}
Field* getField() {
return _field;
}
private:
Field *_field;
};