예제 #1
0
 def __parse_and_execute_move(self, web_client, text):
     turn_from = text.split('-')[0].lower()
     turn_to = text.split('-')[1].lower()
     move = coordinate_conversion.Convert().coordinates(turn_from, turn_to)
     response = self.game.execute_turn(move[0], move[1], move[2], move[3])
     print(f"response {response}")
     self.__post_response(web_client, response)
예제 #2
0
 def playermove(self):
     turn = self.get_move_from_player()
     move = coordinate_conversion.Convert().coordinates(turn[0], turn[1])
     if self.game.execute_turn(move[0],move[1],move[2],move[3]) == 'invalid move':
         print('Invalid move - try again')
 def test_convert_coordinates(self):
     convert = coordinate_conversion.Convert()
     assert convert.coordinates('a1','a2') == [7, 0, 6, 0]
     assert convert.coordinates('a7','c5') == [1, 0, 3, 2]
 def test_convert_errors(self):
     convert = coordinate_conversion.Convert()
     assert convert.coordinates('xx','') == [0, 0, 7, 7]
     assert convert.coordinates('aaaaa','a99') == [0, 0, 7, 7]
     assert convert.coordinates('','') == [0, 0, 7, 7]