From a465c966a70194ad796b03f5f304254371abbae1 Mon Sep 17 00:00:00 2001 From: RomulAugustus <87079566+RomulAugustus@users.noreply.github.com> Date: Mon, 25 Jul 2022 17:49:19 +0300 Subject: [PATCH] added another condition to adding marks --- GameMap.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GameMap.py b/GameMap.py index 15f6a14..35cbc09 100644 --- a/GameMap.py +++ b/GameMap.py @@ -20,6 +20,11 @@ class GameMap: def add_mark(self, x, y, player): if (x <= self.max_size_x and y <= self.max_size_y) and (x >= 0 and y >= 0): self.data[(x,y)] = player + if (x, y) not in self.data: + self.data[(x,y)] = player + else: + errorMessage = "The mark is already busy by the Player" + self.data[(x, y)].get_name() + raise KeyError(errorMessage) else: errorMessage = "The mark" + str((x,y)) + " is beyond preset max values, max_x - " + str(self.max_size_x) + ", max_y - " + str(self.max_size_y) raise IndexError(errorMessage)