Beispiel #1
0
 def make_move(self, boards: List):
     if not isinstance(boards, list):
         raise PlayerTypeError("Player received non-list object: {} for make-a-move".format(boards))
     not_nested_list = any(not isinstance(b, list) for b in boards)
     if not_nested_list: 
         raise PlayerTypeError("Player should received a nested list object: {} in make-a-move".format(boards))
     return self.player.make_move(boards)
Beispiel #2
0
 def get_stone(self):
     stone = self.player.get_stone()
     if not isinstance(stone, str):
         raise PlayerTypeError("Player returned a non-string object: {} as it's stone".format(stone))
     if stone not in STONE:
         raise PlayerTypeError("Player returned the following invalid stone: {} as it's stone".format(stone))
     return stone
Beispiel #3
0
 def set_strategy(self, strategy):
     if not isinstance(strategy, PlayerStrategy):
         raise PlayerTypeError("Strategy Player received a non strategy object: {} as a strategy".format(strategy))
     self.player.set_strategy(strategy)
Beispiel #4
0
 def close_connection(self, shutdown):
     if not isinstance(shutdown, bool):
         raise PlayerTypeError("Proxy Player shutdown flag should be a boolean, instead: {}".format(shutdown))
     self.player.close_connection(shutdown)
Beispiel #5
0
 def set_conn(self, connection):
     if not isinstance(connection, socket):
         raise PlayerTypeError("Proxy Connection Player received a non socket object: {} as a connection".format(connection))
     self.player.set_conn(connection)
Beispiel #6
0
 def end_game(self):
     end_game_resp = self.player.end_game()         
     if not end_game_resp is False and not isinstance(end_game_resp, str):
         raise PlayerTypeError("Player returned a non-string object as it's end game message: {}".format(end_game_resp))
     return end_game_resp
Beispiel #7
0
 def receive_stones(self, stone: str):
     if not isinstance(stone, str):
         raise PlayerTypeError("Player received a non-string object: {} as it's stone".format(stone))
     if stone not in STONE: 
         raise PlayerTypeError("Player received an invalid stone: {}".format(stone))
     self.player.receive_stones(stone)
Beispiel #8
0
 def get_name(self):
     name = self.player.get_name()
     if not isinstance(name, str):
         raise PlayerTypeError("Player returned a non-string object: {} as it's name".format(name))
     return name
Beispiel #9
0
 def register(self):
     register_resp = self.player.register()
     if not register_resp is False and not isinstance(register_resp, str):
         raise PlayerTypeError("Player returned a non-string object: {} as it's name".format(register_resp))
     return register_resp