Initialisierung von Board und Häusern
This commit is contained in:
		@@ -38,11 +38,10 @@ class Board(object):
 | 
			
		||||
            for i in range(10):
 | 
			
		||||
                f = Field.Field(self, i, self.colors[n], house=False)
 | 
			
		||||
                self._list_all_fields.append(f)
 | 
			
		||||
 | 
			
		||||
        IDlist = [f.get_id() for f in self._list_all_fields]
 | 
			
		||||
        print(IDlist)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def get_next_standard_field(self, current_field):
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
@@ -52,9 +51,11 @@ class Board(object):
 | 
			
		||||
        @author
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        pass
 | 
			
		||||
        current_index = self._list_all_fields.index(current_field)
 | 
			
		||||
        next_field = self._list_all_fields[current_index + 1]
 | 
			
		||||
        return next_field
 | 
			
		||||
 | 
			
		||||
    def get_next_field_by_color(self, current_field, color = "black"):
 | 
			
		||||
    def get_next_field_by_color(self, current_field, color_of_stone = "black"):
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        :param Field: current_field : Current field
 | 
			
		||||
@@ -65,8 +66,16 @@ class Board(object):
 | 
			
		||||
        @author
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        curr_id = current_field.get_id()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,21 +7,11 @@ class Field():
 | 
			
		||||
    :author: Martin Putzlocher
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    """ ATTRIBUTES
 | 
			
		||||
 | 
			
		||||
    board  (private)
 | 
			
		||||
 | 
			
		||||
    occupied  (private)
 | 
			
		||||
 | 
			
		||||
    number  (private)
 | 
			
		||||
 | 
			
		||||
    color  (private)
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def __init__(self, board:Board.Board=None, number:int=0, color:str="black", house:bool=False):
 | 
			
		||||
        """ Constructor
 | 
			
		||||
        """
 | 
			
		||||
        if board is None:
 | 
			
		||||
            raise Exception("No Board Exception")
 | 
			
		||||
        self.board = board
 | 
			
		||||
@@ -30,6 +20,7 @@ class Field():
 | 
			
		||||
        self._h = house
 | 
			
		||||
        self._id = ""
 | 
			
		||||
        self.set_id(color, number, house)
 | 
			
		||||
        self.occupied = False
 | 
			
		||||
 | 
			
		||||
    def get_id(self):
 | 
			
		||||
        """ Get ID of field instance
 | 
			
		||||
@@ -52,8 +43,18 @@ class Field():
 | 
			
		||||
            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
 | 
			
		||||
    def get_number(self):
 | 
			
		||||
        """ Get the number 0...9 of the field
 | 
			
		||||
        """
 | 
			
		||||
        return self._n
 | 
			
		||||
 | 
			
		||||
    def get_color(self):
 | 
			
		||||
        """ Get the color of the field
 | 
			
		||||
        """
 | 
			
		||||
        return self._c
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
         field.
 | 
			
		||||
 | 
			
		||||
        :param color_of_stone: Default value = "black")
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,10 @@ class GameController(object):
 | 
			
		||||
        self.list_of_players = list()
 | 
			
		||||
        for i in range(number_of_players):
 | 
			
		||||
            self.add_player("Player " + str(i), GameController.COLORS[i])
 | 
			
		||||
        print([[p.name, p.color] for p in self.list_of_players])
 | 
			
		||||
        self.board = Board(GameController.COLORS, number_of_players)
 | 
			
		||||
        for p in self.list_of_players:
 | 
			
		||||
            p.init_house(self.board)
 | 
			
		||||
        self.game_view = GameView()
 | 
			
		||||
 | 
			
		||||
    def add_player(self, name, color):
 | 
			
		||||
 
 | 
			
		||||
@@ -22,9 +22,12 @@ class Player():
 | 
			
		||||
    def __init__(self, name:str="Nobody", color:str="black"):
 | 
			
		||||
        self.name = name
 | 
			
		||||
        self.color = color
 | 
			
		||||
        self.house = House()
 | 
			
		||||
        self.house = None
 | 
			
		||||
        self.set_of_stones = list()
 | 
			
		||||
 | 
			
		||||
    def init_house(self, board):
 | 
			
		||||
        self.house = House(board, self.color)
 | 
			
		||||
 | 
			
		||||
    def take_turn(self):
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user