Skip to content

Commit

Permalink
Add areas in map renderer script (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
VDuchauffour authored Oct 20, 2024
1 parent 6a4d4ca commit 93134d6
Show file tree
Hide file tree
Showing 85 changed files with 54 additions and 7 deletions.
Binary file added Docs/Maps/areas/ARABIA_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/ARABIA_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/ARABIA_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/ARAGON_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/ARAGON_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/ARAGON_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/AUSTRIA_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/AUSTRIA_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/AUSTRIA_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BULGARIA_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BULGARIA_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BULGARIA_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BURGUNDY_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BURGUNDY_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BURGUNDY_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BYZANTIUM_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BYZANTIUM_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/BYZANTIUM_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/CASTILE_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/CASTILE_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/CASTILE_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/CORDOBA_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/CORDOBA_CORE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/CORDOBA_NORMAL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/DENMARK_BROADER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/Maps/areas/DENMARK_CORE.png
Binary file added Docs/Maps/areas/DENMARK_NORMAL.png
Binary file added Docs/Maps/areas/DUTCH_BROADER.png
Binary file added Docs/Maps/areas/DUTCH_CORE.png
Binary file added Docs/Maps/areas/DUTCH_NORMAL.png
Binary file added Docs/Maps/areas/ENGLAND_BROADER.png
Binary file added Docs/Maps/areas/ENGLAND_CORE.png
Binary file added Docs/Maps/areas/ENGLAND_NORMAL.png
Binary file added Docs/Maps/areas/FRANCE_BROADER.png
Binary file added Docs/Maps/areas/FRANCE_CORE.png
Binary file added Docs/Maps/areas/FRANCE_NORMAL.png
Binary file added Docs/Maps/areas/GENOA_BROADER.png
Binary file added Docs/Maps/areas/GENOA_CORE.png
Binary file added Docs/Maps/areas/GENOA_NORMAL.png
Binary file added Docs/Maps/areas/GERMANY_BROADER.png
Binary file added Docs/Maps/areas/GERMANY_CORE.png
Binary file added Docs/Maps/areas/GERMANY_NORMAL.png
Binary file added Docs/Maps/areas/HUNGARY_BROADER.png
Binary file added Docs/Maps/areas/HUNGARY_CORE.png
Binary file added Docs/Maps/areas/HUNGARY_NORMAL.png
Binary file added Docs/Maps/areas/KIEV_BROADER.png
Binary file added Docs/Maps/areas/KIEV_CORE.png
Binary file added Docs/Maps/areas/KIEV_NORMAL.png
Binary file added Docs/Maps/areas/LITHUANIA_BROADER.png
Binary file added Docs/Maps/areas/LITHUANIA_CORE.png
Binary file added Docs/Maps/areas/LITHUANIA_NORMAL.png
Binary file added Docs/Maps/areas/MOROCCO_BROADER.png
Binary file added Docs/Maps/areas/MOROCCO_CORE.png
Binary file added Docs/Maps/areas/MOROCCO_NORMAL.png
Binary file added Docs/Maps/areas/MOSCOW_BROADER.png
Binary file added Docs/Maps/areas/MOSCOW_CORE.png
Binary file added Docs/Maps/areas/MOSCOW_NORMAL.png
Binary file added Docs/Maps/areas/NORWAY_BROADER.png
Binary file added Docs/Maps/areas/NORWAY_CORE.png
Binary file added Docs/Maps/areas/NORWAY_NORMAL.png
Binary file added Docs/Maps/areas/NOVGOROD_BROADER.png
Binary file added Docs/Maps/areas/NOVGOROD_CORE.png
Binary file added Docs/Maps/areas/NOVGOROD_NORMAL.png
Binary file added Docs/Maps/areas/OTTOMAN_BROADER.png
Binary file added Docs/Maps/areas/OTTOMAN_CORE.png
Binary file added Docs/Maps/areas/OTTOMAN_NORMAL.png
Binary file added Docs/Maps/areas/POLAND_BROADER.png
Binary file added Docs/Maps/areas/POLAND_CORE.png
Binary file added Docs/Maps/areas/POLAND_NORMAL.png
Binary file added Docs/Maps/areas/PORTUGAL_BROADER.png
Binary file added Docs/Maps/areas/PORTUGAL_CORE.png
Binary file added Docs/Maps/areas/PORTUGAL_NORMAL.png
Binary file added Docs/Maps/areas/PRUSSIA_BROADER.png
Binary file added Docs/Maps/areas/PRUSSIA_CORE.png
Binary file added Docs/Maps/areas/PRUSSIA_NORMAL.png
Binary file added Docs/Maps/areas/SCOTLAND_BROADER.png
Binary file added Docs/Maps/areas/SCOTLAND_CORE.png
Binary file added Docs/Maps/areas/SCOTLAND_NORMAL.png
Binary file added Docs/Maps/areas/SWEDEN_BROADER.png
Binary file added Docs/Maps/areas/SWEDEN_CORE.png
Binary file added Docs/Maps/areas/SWEDEN_NORMAL.png
Binary file added Docs/Maps/areas/VENECIA_BROADER.png
Binary file added Docs/Maps/areas/VENECIA_CORE.png
Binary file added Docs/Maps/areas/VENECIA_NORMAL.png
61 changes: 54 additions & 7 deletions Docs/Tools/map_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@

from PIL import Image, ImageOps
from Consts import MINOR_CIVS
from Core import civilizations

from LocationsData import CIV_CORE_AREA, CIV_BROADER_AREA, CIV_NORMAL_AREA, CIV_PROVINCES
from CoreTypes import Civ, Province, ProvinceType
from Core import civilizations, plots

from LocationsData import (
CIV_AREAS,
CIV_CORE_AREA,
CIV_BROADER_AREA,
CIV_NORMAL_AREA,
CIV_PROVINCES,
)
from CoreTypes import Area, AreaType, Civ, Province, ProvinceType
from ProvinceMapData import PROVINCES_MAP

PROVINCES_MAP = np.asarray(PROVINCES_MAP)
Expand Down Expand Up @@ -242,7 +248,7 @@ def draw_bonuses_map(self, output_path: str) -> None:
img = self.upscale_map(img)
self.save_drawing(img, output_path, "bonuses")

def _extract_provinces(self, province):
def _extract_province(self, province):
plots = []
indices = np.where(PROVINCES_MAP == province.value)
for y, x in zip(indices[0], indices[1]):
Expand All @@ -252,14 +258,25 @@ def _extract_provinces(self, province):
def extract_provinces(self, provinces):
plots = []
for province in provinces:
plots.append(self._extract_provinces(province))
plots.append(self._extract_province(province))
plots = chain.from_iterable(plots)
return plots

def extract_areas(self, areas):
_plots = []
__plots = plots.rectangle(areas[Area.TILE_MIN], areas[Area.TILE_MAX])
__plots._factory = lambda x: x
_plots.append(
__plots.without(areas[Area.EXCEPTION_TILES]).add(areas[Area.ADDITIONAL_TILES])
)
_plots = chain.from_iterable(_plots)
_plots = [Plot(x, y, "", "", "", "", "") for (x, y) in _plots]
return _plots

def draw_provinces_map(self, output_path: str):
for province in Province:
img = self.base_img.copy()
img = self.draw(img, self._extract_provinces(province), PROVINCES_COLORS["potential"])
img = self.draw(img, self._extract_province(province), PROVINCES_COLORS["potential"])

img = self.apply_water(img)
img = self.draw_plot_properties(img, "is_peak")
Expand Down Expand Up @@ -295,6 +312,25 @@ def draw_provinces_stability_map(self, output_path: str):
img = self.upscale_map(img)
self.save_drawing(img, output_path + "/provinces_stability", f"{civ.key.name}")

def draw_areas_stability_map(self, output_path: str):
for civ in civilizations():
if civ.id not in MINOR_CIVS + [Civ.POPE.value]:
for area, color in [
(AreaType.CORE, "core"),
(AreaType.NORMAL, "historical"),
(AreaType.BROADER, "potential"),
]:
img = self.base_img.copy()
img = self.draw(
img,
self.extract_areas(CIV_AREAS[civ.key][area]),
PROVINCES_COLORS[color],
)
img = self.apply_water(img)
img = self.draw_plot_properties(img, "is_peak")
img = self.upscale_map(img)
self.save_drawing(img, output_path + "/areas", f"{civ.key.name}_{area.name}")

def normalize_plot(self, plots):
_plots = []
for plot in plots:
Expand All @@ -310,6 +346,7 @@ def run(
bonuses: bool,
provinces: bool,
provinces_stability: bool,
areas_stability: bool,
) -> None:
self.draw_base_map(output_path)
if rivers:
Expand All @@ -324,6 +361,8 @@ def run(
self.draw_provinces_map(output_path)
if provinces_stability:
self.draw_provinces_stability_map(output_path)
if areas_stability:
self.draw_areas_stability_map(output_path)


def main():
Expand Down Expand Up @@ -371,6 +410,12 @@ def main():
default=True,
help="Draw provinces stability map. Default to True",
)
parser.add_argument(
"--areas-stability",
action="store_true",
default=True,
help="Draw areas stability map. Default to True",
)
parser.add_argument(
"--all", action="store_true", default=False, help="Draw all maps. Default to False."
)
Expand All @@ -383,6 +428,7 @@ def main():
args.bonuses = True
args.provinces = True
args.provinces_stability = True
args.areas_stability = True

parser = WBSaveParser()
map = parser.parse(args.file)
Expand All @@ -395,6 +441,7 @@ def main():
args.bonuses,
args.provinces,
args.provinces_stability,
args.areas_stability,
)


Expand Down

0 comments on commit 93134d6

Please sign in to comment.