Skip to content

Commit

Permalink
Add some unmerged modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelmen323 committed Oct 2, 2024
1 parent dc5b827 commit 60fbe1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Config/modifiers.cwt
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ modifiers = {
modifier_army_sub_unit_paratrooper_defence_factor = army
modifier_army_sub_unit_paratrooper_max_org_factor = army
modifier_army_sub_unit_paratrooper_speed_factor = army
module_<module>_design_cost_factor = army
motorized_attack_factor = army
motorized_defence_factor = army
mountaineers_special_forces_contribution_factor = army
Expand Down Expand Up @@ -347,6 +348,7 @@ modifiers = {
subjects_autonomy_gain = autonomy

# country
enum[equipment_bonus_type]_design_cost_factor = country
additional_brigade_column_size = country
agency_upgrade_time = country
air_doctrine_cost_factor = country
Expand Down Expand Up @@ -478,6 +480,7 @@ modifiers = {
min_export = country
minimum_training_level = country
modifier_enemy_port_superiority_limit = country
module_<module>_design_cost_factor = army
monthly_population = country
naval_doctrine_cost_factor = country
naval_equipment_upgrade_xp_cost = country
Expand Down Expand Up @@ -514,6 +517,7 @@ modifiers = {
production_lack_of_resource_penalty_factor = country
production_oil_factor = country
production_speed_buildings_factor = country
production_speed_<building>_factor = country
railway_gun_bombardment_factor = country
refit_ic_cost = country
refit_speed = country
Expand Down Expand Up @@ -694,6 +698,7 @@ modifiers = {
invasion_preparation = naval
mines_planting_by_fleets_factor = naval
mines_sweeping_by_fleets_factor = naval
module_<module>_design_cost_factor = army
naval_accidents_chance = naval
naval_attrition = naval
naval_coordination = naval
Expand Down Expand Up @@ -773,6 +778,7 @@ modifiers = {
puppet_cost_factor = peace

# politics
<ideology>_drift = politics
drift_defence_factor = politics
embargo_cost_factor = politics
embargo_threshold_factor = politics
Expand Down
28 changes: 26 additions & 2 deletions tests/test_check_missing_modifiers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import re

path_to_config = "Config\\modifiers.cwt"
path_to_documentation = "Config\\script_documentation.json"
Expand All @@ -22,7 +23,7 @@ def check_missing_modifiers():
modifiers_dict[modifier['name']] = modifier['categories']
# Dynamic modifier
elif "groupname" in modifier.keys():
pass
modifiers_dict[modifier['groupname']] = modifier['categories']

# 2 Extract modifiers from config files
with open(path_to_config, 'r') as text_file:
Expand All @@ -31,7 +32,30 @@ def check_missing_modifiers():
# 3 Compare documentation and config
for key, values in modifiers_dict.items():
for value in values:
if f'{key} = {value}\n' not in config_file:
# Dynamic modifier
if "<" in key:
# Modifier starts with the token
if key[0] == '<':
stripped_key = key[key.index('>')+1:]
if f'{stripped_key} = {value}\n' not in config_file:
results.append(f'{key} = {value}')
# Modifier ends with the token
elif key[-1] == '>':
stripped_key = key[:key.index('<')]
pattern = stripped_key + r'.*? = ' + value
pattern_matches = re.findall(pattern, config_file)
if pattern_matches == []:
results.append(f'{key} = {value}')
# Token is somewhere in the middle of the modifier
else:
splitted_key = key.split('<')
key1 = splitted_key[0]
key2 = splitted_key[1][splitted_key[1].index('>')+1:]
pattern = key1 + r'.*?' + key2 + r' = ' + value
pattern_matches = re.findall(pattern, config_file)
if pattern_matches == []:
results.append(f'{key} = {value}')
elif f'{key} = {value}\n' not in config_file:
results.append(f'{key} = {value}')

# 4 Format the results
Expand Down

0 comments on commit 60fbe1c

Please sign in to comment.