2023-06-08 16:02:55 +02:00
|
|
|
class Square:
|
|
|
|
def __init__(self, row, column, piece=None):
|
|
|
|
self.row = row
|
|
|
|
self.column = column
|
|
|
|
self.piece = piece
|
|
|
|
|
|
|
|
def has_piece(self):
|
|
|
|
if self.piece is None:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
|
|
|
|
def is_rival(self, color):
|
|
|
|
if self.has_piece() is True and self.piece.color != color:
|
|
|
|
return True
|
|
|
|
|
2023-06-09 17:28:57 +02:00
|
|
|
def empty_or_rival(self, color):
|
2023-06-12 23:48:36 +02:00
|
|
|
if self.is_rival(color) is True or self.has_piece() is False:
|
2023-06-08 16:02:55 +02:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
@staticmethod
|
|
|
|
def on_board(*args):
|
|
|
|
for arg in args:
|
|
|
|
if arg < 0 or arg > 7:
|
|
|
|
return False
|
2023-06-09 16:07:08 +02:00
|
|
|
return True
|