aboutsummaryrefslogtreecommitdiff
path: root/Tile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tile.cpp')
-rw-r--r--Tile.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/Tile.cpp b/Tile.cpp
index cb7b89b..d73abe7 100644
--- a/Tile.cpp
+++ b/Tile.cpp
@@ -4,18 +4,21 @@
#include "TileAppearance.h"
#include "TileBehavior.h"
-Tile::Tile() {
- this->data = {};
- this->update();
+Tile::Tile(Museum & museum, TileData data) : museum(museum) {
+ this->set_data(data);
}
-Tile::Tile(TileData data) {
+void Tile::set_data(TileData data) {
this->data = data;
- this->update();
+ this->color = TileAppearance::get_color(this->data.type);
+ this->behavior = TileBehavior::get_strategy(this->data.type).clone(this->museum);
}
void Tile::update() {
- this->color = TileAppearance::get_color(this->data.type);
- this->behavior = TileBehavior::get_strategy(this->data.type).clone();
+ this->behavior->update(*this);
+}
+
+void Tile::step() {
+ this->behavior->step();
}