Open main menu

Talk:List of provinces

List - This article is considered a List-class article on the wiki quality scale


The table body can be generated with the following script:

import hoi4
import re
import os
import json
import pyradox

state_database = pyradox.txt.parse_merge('history/states', game='HoI4')
states = list(state_database.find_all('state'))

airports = pyradox.txt.parse_file('map/airports.txt', game='HoI4')
rocketsites = pyradox.txt.parse_file('map/rocketsites.txt', game='HoI4')
adj_rules_db = pyradox.txt.parse_file('map/adjacency_rules.txt', game='HoI4')

states.sort(key=lambda x: x['id'])

province_to_vp = {}  # victory points can be declared in any state
for state in states:
    vp_iter = state['history'].find_all('victory_points')
    for p, value in zip(vp_iter, vp_iter):
        province_to_vp[p] = value

for state in states:
    for pid in sorted(state.find_all('provinces')):
        state_l10n = pyradox.get_localisation('state_' + str(state['id']), 'HoI4')
            naval_base = state['history']['buildings'][pid]['naval_base'] or 0
        except (IndexError, TypeError):
            naval_base = 0
        optional = []
        for strait in adj_rules_db.find_all('adjacency_rule'):
            if pid in strait.find_all('required_provinces'):
                strait_l10n = pyradox.get_localisation(strait['name'], 'HoI4')
        vp = province_to_vp.get(pid, 0)
        name = pyradox.get_localisation(f'victory_points_{pid}', 'HoI4')
        if name and not vp:
            name += '<ref name=unused />'
        if not name:
            name = state_l10n + '<ref name=fallback />' if vp else ''
            '|', state['id'],
            '||', state_l10n,
            '||', state['history']['owner'],
            '||', pid,
            '||', name,
            '||', f'{vp:g}', # some points have trailing decimal places
            '||', 'True' if pid == airports[state['id']] else 'false',
            '||', 'True' if pid == rocketsites[state['id']] else 'false',
            '||', naval_base,
            '||', *optional)

feel free to update this comment when using an updated script Bitmode (talk) 11:09, 12 January 2020 (UTC)

victory pointsEdit

Just as a warning when generating the table from files: a victory point does not need to be defined in the state it belongs to. This currently is the case for Grodno (province 3393). Bitmode (talk) 08:51, 11 January 2020 (UTC)

named provinces without victory pointsEdit

There are a bunch of province names that don't show up in the game (and are currently missing in the table) because they don't have victory points. Should we include them? Bitmode (talk) 08:54, 11 January 2020 (UTC)

Return to "List of provinces" page.