from Player import * from Board import * from GameView import * class GameController(object): """:version: :author: """ """ ATTRIBUTES list_of_players (private) board (private) game_view (private) """ COLORS=["black", "yellow", "green", "red", "blue", "purple"] def __init__(self, number_of_players:int=4): 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): """Add a player to the game :param name: Name of the player :param color: Color of the player :returns: Player : p """ p = Player(name, color) self.list_of_players.append(p) return p def remove_player(self, color): """ Remove player from game :param color: Color of the player to be removed :returns: True """ found = False for p in self.list_of_players: if p.color == color: self.list_of_players.remove(p) found = True print("Player with color {} removed".format(color)) else: pass # still not found if found == False: print("No player with color {} available for extractin.".format(color)) return True