From d8289105193707daede1a5b59137f18e20f20aeb Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 18 Oct 2024 15:48:14 +0200 Subject: (2/2) rename --- DeleteArtistTileBehavior.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 DeleteArtistTileBehavior.cpp (limited to 'DeleteArtistTileBehavior.cpp') diff --git a/DeleteArtistTileBehavior.cpp b/DeleteArtistTileBehavior.cpp new file mode 100644 index 0000000..091a251 --- /dev/null +++ b/DeleteArtistTileBehavior.cpp @@ -0,0 +1,28 @@ +#include + +#include "DeleteArtistTileBehavior.h" +#include "SetNeighborTileBehavior.h" +#include "Tile.h" +#include "Museum.h" + +using namespace std; + +DeleteArtistTileBehavior DeleteArtistTileBehavior::instance { DeleteArtistTileBehavior::type }; + +void DeleteArtistTileBehavior::step(Artist * artist) { + this->interactions++; + if (artist != nullptr) + this->museum->people.remove_artist(*artist); +} + +void DeleteArtistTileBehavior::update(Tile & tile) { + if (this->interactions == 0) return; + tile.set_type(SetNeighborTileBehavior::type); +} + +unique_ptr DeleteArtistTileBehavior::clone(Museum & museum) { + auto instance = new DeleteArtistTileBehavior(); + instance->museum = &museum; + return unique_ptr(instance); +} + -- cgit v1.2.3