def test_handle_take_turn3(self): # tests a client handling a take turn (penguin move) message, almost end of game c1 = Client("a", 1) msg_type1, msg1 = self.json_serializer.decode_message( ['playing-as', ['white']]) c1._Client__handle_playing_as(msg1) msg_type, msg = self.json_serializer.decode_message([ "take-turn", [{ "board": [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 2, 0, 0, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]], "players": [{ "score": 8, "places": [[2, 1], [3, 4], [3, 2]], "color": "white" }, { "score": 8, "places": [[4, 2], [3, 0], [2, 4]], "color": "brown" }, { "score": 10, "places": [[4, 0], [3, 3], [3, 1]], "color": "red" }] }, []] ]) output = c1._Client__handle_setup(msg) self.assertEqual(output, '[4, 1]')
def test_handle_setup3(self): # tests a client handling a setup (penguin placement) message, different color and 3 holes on the board c1 = Client("a", 1) msg_type1, msg1 = self.json_serializer.decode_message( ['playing-as', ['white']]) c1._Client__handle_playing_as(msg1) msg_type2, msg2 = self.json_serializer.decode_message([ "setup", [{ "board": [[0, 0, 0, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]], "players": [{ "score": 0, "places": [], "color": "red" }, { "score": 0, "places": [], "color": "white" }, { "score": 0, "places": [], "color": "brown" }] }] ]) output = c1._Client__handle_setup(msg2) self.assertEqual(output, '[0, 3]')