Compare commits

..

4 Commits

Author SHA1 Message Date
RomulAugustus
7377f74d92 made the base 2022-07-25 13:35:07 +03:00
RomulAugustus
e7f1733a8a 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
2022-07-25 13:34:50 +03:00
RomulAugustus
4e5388bd12 fixed empty class 2022-07-25 13:33:08 +03:00
RomulAugustus
12d64e5cbd Create .gitignore 2022-07-25 13:32:51 +03:00
4 changed files with 24 additions and 4 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
tester.py

View File

@ -0,0 +1,2 @@
class GameLogic():
pass

View File

@ -3,10 +3,10 @@ class GameMap:
def __init__(self, max_size_x = float('inf'), max_size_y = float('inf')): def __init__(self, max_size_x = float('inf'), max_size_y = float('inf')):
self.max_size_x = max_size_x self.max_size_x = max_size_x
self.max_size_y = max_size_y self.max_size_y = max_size_y
data = {} self.data = {}
def __str__(self): def __str__(self):
return data return str(self.data)
def get_max_size_x(self): def get_max_size_x(self):
@ -18,12 +18,15 @@ class GameMap:
def add_player_mark(self, x, y, player): 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 self.data[(x,y)] = player
player.record_mark(x, y)
else: 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): def clear_map(self):
self.data = {} self.data = {}

View File

@ -0,0 +1,13 @@
class Player():
def __init__(self, name, color):
self.name = name
self.color = color
self.markList = []
def __str__(self):
return "Player " + self.name + ': ' + "Color - " + self.color + "\n " + str(self.markList)
def record_mark(self, x, y):
self.markList.append((x, y))