def __handle_take_turn(self, arguments):
        """
        Handle a start message.

        JSON value -> JSON value
        """
        state = State.from_json(arguments[0])
        actions = [Move.from_json(action) for action in arguments[1]]
        return self.__player.tt(state, actions).print_json()
Ejemplo n.º 2
0
 def tt(self, state, actions):
     error = "Player did not return an Action to tt method"
     actions = [action.print_json() for action in actions]
     response = self.__send_request("take-turn",
                                    [state.print_json(), actions],
                                    is_json_action, error)
     if response is False:
         return Skip()
     else:
         return Move.from_json(response)
Ejemplo n.º 3
0
 def test_from_json(self):
     jsons = [[[0, 0], [1, 0]], [[2, 0], [3, 0]], [[3, 1], [1, 2]],
              [[0, 0], [6, 3]]]
     moves = [
         Move((0, 0), (1, 0)),
         Move((2, 0), (3, 0)),
         Move((3, 1), (1, 2)),
         Move((0, 0), (6, 3))
     ]
     for json, move in zip(jsons, moves):
         m = Move.from_json(json)
         self.assertEqual(move.print_json(), m.print_json())
         self.assertEqual(move, m)