2022-04-19 07:49:45 +00:00
|
|
|
import Board
|
|
|
|
|
|
|
|
class Field():
|
|
|
|
|
|
|
|
""" Class of single field on game board
|
|
|
|
:version: 0.1
|
|
|
|
:author: Martin Putzlocher
|
2022-04-04 06:16:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
""" ATTRIBUTES
|
|
|
|
|
|
|
|
board (private)
|
|
|
|
|
|
|
|
occupied (private)
|
|
|
|
|
2022-04-14 20:48:16 +00:00
|
|
|
number (private)
|
|
|
|
|
|
|
|
color (private)
|
|
|
|
|
2022-04-04 06:16:33 +00:00
|
|
|
"""
|
|
|
|
|
2022-04-19 07:49:45 +00:00
|
|
|
def __init__(self, board:Board.Board=None, number:int=0, color:str="black", house:bool=False):
|
|
|
|
if board is None:
|
|
|
|
raise Exception("No Board Exception")
|
|
|
|
self.board = board
|
|
|
|
self._n = number
|
|
|
|
self._c = color
|
|
|
|
self._h = house
|
|
|
|
self._id = ""
|
|
|
|
self.set_id(color, number, house)
|
|
|
|
|
|
|
|
def get_id(self):
|
|
|
|
""" Get ID of field instance
|
|
|
|
"""
|
|
|
|
return self._id
|
|
|
|
|
|
|
|
def set_id(self, color:str, number:int, house:bool):
|
|
|
|
""" Set ID of field instance
|
|
|
|
|
|
|
|
:param color:str:
|
|
|
|
:param number:int:
|
|
|
|
:param house:bool:
|
|
|
|
|
2022-04-14 20:48:16 +00:00
|
|
|
"""
|
2022-04-19 07:49:45 +00:00
|
|
|
if house:
|
|
|
|
assert 0 <= number <= 3
|
|
|
|
self._id = "H" + color[:3] + str(number)
|
|
|
|
else:
|
|
|
|
assert 0 <= number <= 10
|
|
|
|
self._id = "S" + color[:3] + str(number)
|
|
|
|
return self._id
|
|
|
|
|
|
|
|
def get_next_field(self, color_of_stone = "black"):
|
|
|
|
"""Give back next field on board, dependent on the color of a stone on the current
|
2022-04-14 20:48:16 +00:00
|
|
|
field.
|
|
|
|
|
2022-04-19 07:49:45 +00:00
|
|
|
:param color_of_stone: Default value = "black")
|
|
|
|
:returns: Field :
|
|
|
|
@author : Martin Putzlocher
|
|
|
|
|
2022-04-14 20:48:16 +00:00
|
|
|
"""
|
2022-04-19 07:49:45 +00:00
|
|
|
return self.board.get_next_field_by_color(self, color_of_stone)
|
2022-04-14 20:48:16 +00:00
|
|
|
|
2022-04-04 06:16:33 +00:00
|
|
|
|
|
|
|
|