def test_map_returns_correct_image_names(index_number, expected_value): """ Test the loaded map file returns expected image name. Regression test of get_data function. Uses test_1.json map for this. """ loaded_tileset = get_tiles_data(get_map_data("maps/test_1.json")) assert loaded_tileset[index_number]["image"] == expected_value
def as_dict(self, map_name): """ Return state as dictionary for sending with server """ return { "board": get_map_data(map_name), "robots": [robot.as_dict() for robot in self.robots] }
def whole_as_dict(self, map_name): """ Return whole state as dictionary for sending with server. """ return { "game_state": { "board": get_map_data(map_name), **self.robots_as_dict(), } }
def test_loading_of_tile_type_properties(id, tile_type, tile_properties): """ Test tile type and properties are correctly obtained from map data, that contains information of used tileset. Use test_1.json map, but all maps would work. All of them refers to the same external tileset (except for test_4.json). """ map_data = get_map_data("maps/test_maps/test_1.json") types, properties, path = get_tiles_properties(map_data) assert types[id] == tile_type assert properties[id] == tile_properties