From e7f1733a8a77dc9101dff688231413af8134a747 Mon Sep 17 00:00:00 2001 From: RomulAugustus <87079566+RomulAugustus@users.noreply.github.com> Date: Mon, 25 Jul 2022 13:34:50 +0300 Subject: [PATCH] Fixes of syntax errors; minor edits out of minor - * made add_player_mark() also call the player instance to record mark into it's internal list * put the exception message into a separate variable for the sake of simpler representation --- GameMap.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/GameMap.py b/GameMap.py index 0d02c41..b325ab1 100644 --- a/GameMap.py +++ b/GameMap.py @@ -3,10 +3,10 @@ class GameMap: def __init__(self, max_size_x = float('inf'), max_size_y = float('inf')): self.max_size_x = max_size_x self.max_size_y = max_size_y - data = {} + self.data = {} def __str__(self): - return data + return str(self.data) def get_max_size_x(self): @@ -18,12 +18,15 @@ class GameMap: def add_player_mark(self, x, y, player): - if x <= max_size_x or y <= max_size_y: + if x <= self.max_size_x and y <= self.max_size_y: self.data[(x,y)] = player + player.record_mark(x, y) else: - raise IndexError("Mark added beyond preset max values (max_x - " + self.max_size_x + ", max_y - " + self.max_size_y + ".") + 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) def clear_map(self): self.data = {} + \ No newline at end of file