-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.py
More file actions
38 lines (29 loc) · 1 KB
/
Cell.py
File metadata and controls
38 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from Player import Player, PlayerColor
from typing import List, Any
class Cell:
"""
A single cell from the board. Position is listed as 0,0.
"""
def __init__(self, x_pos: int, y_pos: int, contents: Any = None):
self.x_pos = x_pos
self.y_pos = y_pos
self.contents = contents
def is_occupied(self) -> bool:
if self.contents is None:
return False
else:
return True
def get_board_representation(self) -> str:
# If empty return what an empty cell looks like
# Otherwise, have the occupant decide how it wants to be displayed
if self.is_occupied():
return self.contents.get_board_representation()
else:
return "__"
def __repr__(self) -> str:
return f"Cell({self.x_pos},{self.y_pos}: {self.contents})"
if __name__ == "__main__":
test_cell = Cell(0,0)
print(type(test_cell))
print(type(test_cell.is_occupied))
print(test_cell.get_board_representation())