2022-04-19 07:49:45 +00:00
|
|
|
import House
|
|
|
|
import Field
|
2022-04-04 06:16:33 +00:00
|
|
|
|
|
|
|
class Board(object):
|
|
|
|
|
2022-04-19 07:49:45 +00:00
|
|
|
""":version: 0.1
|
|
|
|
:author: Martin Putzlocher
|
2022-04-04 06:16:33 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
""" ATTRIBUTES
|
2022-04-19 07:49:45 +00:00
|
|
|
list_all_fields (private)
|
2022-04-04 06:16:33 +00:00
|
|
|
"""
|
|
|
|
|
2022-04-19 07:49:45 +00:00
|
|
|
def __init__(self, colors:list, number_of_players=4):
|
|
|
|
self.colors = colors
|
|
|
|
self.num_players = number_of_players
|
|
|
|
self._list_all_fields = list()
|
|
|
|
self.init_board()
|
|
|
|
|
2022-04-14 20:48:16 +00:00
|
|
|
def get_house_by_color(self, color = "black"):
|
2022-04-19 07:49:45 +00:00
|
|
|
"""Returns list of house fields of one color
|
|
|
|
|
|
|
|
:param string: color :
|
|
|
|
:param color: (Default value = "black")
|
|
|
|
:returns: House :
|
2022-04-14 20:48:16 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def init_board(self):
|
2022-04-19 07:49:45 +00:00
|
|
|
"""Initialize Board
|
|
|
|
|
|
|
|
|
|
|
|
:returns: author
|
2022-04-14 20:48:16 +00:00
|
|
|
|
|
|
|
"""
|
2022-04-19 07:49:45 +00:00
|
|
|
for n in range(self.num_players):
|
|
|
|
for i in range(10):
|
|
|
|
f = Field.Field(self, i, self.colors[n], house=False)
|
|
|
|
self._list_all_fields.append(f)
|
2022-04-19 08:15:33 +00:00
|
|
|
|
2022-04-19 07:49:45 +00:00
|
|
|
IDlist = [f.get_id() for f in self._list_all_fields]
|
|
|
|
print(IDlist)
|
|
|
|
|
2022-04-14 20:48:16 +00:00
|
|
|
def get_next_standard_field(self, current_field):
|
|
|
|
"""
|
|
|
|
|
2022-04-19 07:49:45 +00:00
|
|
|
:param Field: current_field :
|
|
|
|
:param current_field:
|
|
|
|
:returns: Field :
|
2022-04-14 20:48:16 +00:00
|
|
|
@author
|
2022-04-19 07:49:45 +00:00
|
|
|
|
2022-04-14 20:48:16 +00:00
|
|
|
"""
|
2022-04-19 08:15:33 +00:00
|
|
|
current_index = self._list_all_fields.index(current_field)
|
|
|
|
next_field = self._list_all_fields[current_index + 1]
|
|
|
|
return next_field
|
2022-04-14 20:48:16 +00:00
|
|
|
|
2022-04-19 08:15:33 +00:00
|
|
|
def get_next_field_by_color(self, current_field, color_of_stone = "black"):
|
2022-04-14 20:48:16 +00:00
|
|
|
"""
|
|
|
|
|
2022-04-19 07:49:45 +00:00
|
|
|
:param Field: current_field : Current field
|
|
|
|
:param string: color : Color of the stone requesting his next field.
|
|
|
|
:param current_field:
|
|
|
|
:param color: (Default value = "black")
|
|
|
|
:returns: Field :
|
2022-04-14 20:48:16 +00:00
|
|
|
@author
|
2022-04-19 07:49:45 +00:00
|
|
|
|
2022-04-14 20:48:16 +00:00
|
|
|
"""
|
2022-04-19 08:15:33 +00:00
|
|
|
current_field_color = current_field.get_color()
|
|
|
|
next_field = self.get_next_standard_field(current_field)
|
|
|
|
next_field_color = next_field.get_color()
|
|
|
|
|
|
|
|
if color_of_stone == next_field_color and current_field_color != next_field_color:
|
|
|
|
# TODO
|
|
|
|
# next_field = im Haus des aktuellen Spielers
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
return next_field
|
2022-04-04 06:16:33 +00:00
|
|
|
|
|
|
|
|