''' 2021-06-04 In conjunction with civ_wb_save_to_dict.py Turns Custom Dictionary into an image png Screenshots are just as good... # # # Created on Mar 9, 2018 @author: Brett Paufler Copyright Brett Paufler Will need to come back to this pulls Terrain type assigns a color makes a simple bitmap png image TerrainType TERRAIN_OCEAN TERRAIN_COAST TERRAIN_SNOW TERRAIN_TUNDRA TERRAIN_GRASS TERRAIN_PLAINS TERRAIN_DESERT PlotTypes 0 = Mountains 1 = Hills 2 = Regular 3 = Coast or Ocean FeatureType FEATURE_JUNGLE FEATURE_FOREST FEATURE_ICE FEATURE_OASIS ''' import numpy as np from civ_wb_save_to_dict import get_wb_save_files from civ_wb_save_to_dict import parse_worldbuildersave from skimage.io import imsave simple_color_chart = { 'TERRAIN_OCEAN': (125, 125, 255), 'TERRAIN_COAST': (200, 200, 255), 'TERRAIN_SNOW': (255, 255, 255), 'TERRAIN_GRASS': (125, 255, 125), 'TERRAIN_PLAINS': (125, 125, 25), 'TERRAIN_DESERT': (200, 100, 50), 'TERRAIN_TUNDRA': (125, 75, 0) } def map_all(): for file_path in get_wb_save_files(): map_dict = parse_worldbuildersave(file_path) img = make_simple_map_img(map_dict) print file_path save_name = file_path.replace( '\\input\\', '\\output\\') save_name = save_name.replace( 'CivBeyondSwordWBSave', 'png') print save_name imsave(save_name, img) def make_simple_map_img(map_dict): grid_width = int(map_dict['map']['grid width']) grid_height = int(map_dict['map']['grid height']) #grid = np.ndarray grid = np.ndarray( (grid_height, grid_width, 3), np.uint8) for plot in map_dict['plots']: #print plot x = int(plot['x']) y = grid_height - int(plot['y']) - 1 color = simple_color_chart[plot['TerrainType']] #print x, y, color #print type(x), type(y) grid[y, x] = color for player in map_dict['players']: if 'StartingY' in player: x = int(player['StartingX']) y = (grid_height - 1 - int(player['StartingY'])) color = (0, 0, 0) print x, y, color grid[y, x] = color #print 'Has City' return grid #print grid_width, grid_height if __name__ == '__main__': map_all()