From 4cb7ca42003c177e3acc80075d7594e555966106 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 18 Oct 2024 16:37:02 +0200 Subject: fix command design pattern --- StepTileCommand.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'StepTileCommand.cpp') diff --git a/StepTileCommand.cpp b/StepTileCommand.cpp index ff5c6b2..cc7d62d 100644 --- a/StepTileCommand.cpp +++ b/StepTileCommand.cpp @@ -1,11 +1,18 @@ #include "StepTileCommand.h" -#include "Museum.h" +#include "Canvas.h" -void StepTileCommand::execute(unsigned int x, unsigned int y) { - Museum & museum = this->get_museum(); - if (x >= museum.canvas.data.columns) return; - if (y >= museum.canvas.data.rows) return; - Tile & tile = museum.canvas.get_tile(x, y); +using namespace std; + +StepTileCommand::StepTileCommand(Canvas & c, pair tile) : canvas(c) { + this->x = tile.first; + this->y = tile.second; +} + +void StepTileCommand::execute() { + Canvas & canvas = this->canvas; + if (this->x >= canvas.data.columns) return; + if (this->y >= canvas.data.rows) return; + Tile & tile = canvas.get_tile(this->x, this->y); tile.step(nullptr); tile.update(); } -- cgit v1.2.3