35 lines
993 B
Python
35 lines
993 B
Python
|
class Square:
|
||
|
# tworzenie pól
|
||
|
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
|
||
|
|
||
|
def empty_or_rival(self, color): # sprawdz
|
||
|
if self.has_piece() is False or self.is_rival(color): # 1 has piece (color)
|
||
|
return True
|
||
|
else:
|
||
|
return False
|
||
|
def empty_or_rival_knight(self, color): # sprawdz
|
||
|
if self.has_piece() is False or self.is_rival(color): # 1 has piece (color)
|
||
|
return True
|
||
|
else:
|
||
|
return False
|
||
|
|
||
|
@staticmethod
|
||
|
def on_board(*args):
|
||
|
for arg in args:
|
||
|
if arg < 0 or arg > 7:
|
||
|
return False
|
||
|
return True
|