Ejemplo n.º 1
0
def get_modules(beta=False):
    game = 'HoI4_beta' if beta else 'HoI4'
    technologies = pyradox.parse_merge('common/technologies',
                                       game=game,
                                       merge_levels=1)['technologies']
    modules = pyradox.parse_merge('common/units/equipment/modules',
                                  game=game,
                                  merge_levels=1)['equipment_modules']

    for key, technology in technologies.items():
        if not isinstance(technology, pyradox.Tree): continue
        start_year = technology['start_year']
        for module_key in technology.find_all('enable_equipment_modules'):
            if module_key in modules:
                # print(module_key, start_year)
                if start_year is None:
                    start_year = module_year_fallback[module_key]
                modules[module_key]['start_year'] = start_year

    for module_key, module in modules.items():
        if module['start_year'] is None:
            print('No tech found for ' + module_key +
                  '; setting default year of ' + str(default_year))
            module['start_year'] = default_year

    return modules
Ejemplo n.º 2
0
def get_hulls(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    
    equipments = pyradox.parse_merge('common/units/equipment', game = game, filter_pattern = "ship_hull", merge_levels = 1)['equipments']
    
    archetypes = pyradox.Tree()
    # Compute archetypes.
    for key, hull in equipments.items():
        if hull['is_archetype']:
            hull = copy.deepcopy(hull)
            hull['module_slots'].resolve_references()
            archetypes[key] = hull
    
    hulls = pyradox.Tree()
    # Compute final hulls.
    for key, hull in equipments.items():
        if hull['is_buildable'] is False: continue
        
        hull = copy.deepcopy(hull)
        
        archetype = archetypes[hull['archetype']]
        hull.inherit(archetype)
        hull.weak_update(archetype)
        
        if 'parent' in hull:
            parent = hulls[hull['parent']]
            hull.inherit(parent)
        
        hull['module_slots'].resolve_references()
        hull['is_archetype'] = False
        hull['is_buildable'] = True
        
        hulls[key] = hull
    
    return archetypes, hulls
Ejemplo n.º 3
0
Archivo: ship.py Proyecto: ajul/pyradox
def get_modules(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    technologies = pyradox.parse_merge('common/technologies', game = game, merge_levels = 1)['technologies']
    modules = pyradox.parse_merge('common/units/equipment/modules', game = game, merge_levels = 1)['equipment_modules']
    
    for key, technology in technologies.items():
        if not isinstance(technology, pyradox.Tree): continue
        start_year = technology['start_year']
        for module_key in technology.find_all('enable_equipment_modules'):
            if module_key in modules:
                # print(module_key, start_year)
                if start_year is None:
                    start_year = module_year_fallback[module_key]
                modules[module_key]['start_year'] = start_year
    
    for module_key, module in modules.items():
        if module['start_year'] is None: 
            print('No tech found for ' + module_key + '; setting default year of ' + str(default_year))
            module['start_year'] = default_year
    
    return modules
Ejemplo n.º 4
0
import _initpath
import pyradox
import os
import copy
import math
import stellaris.weapon

txt_data = pyradox.parse_merge(['common', 'component_templates'],
                               game='Stellaris',
                               apply_defines=True)

default_values = pyradox.Tree()
default_values['hull_damage'] = 1.0
default_values['armor_damage'] = 1.0
default_values['shield_damage'] = 1.0
default_values['armor_penetration'] = 0.0
default_values['shield_penetration'] = 0.0
default_values['tracking'] = 0.0
default_values['prerequisites'] = 'Ship part strike craft scout 1'

result_data = pyradox.Tree()

for strike_craft in txt_data.find_all('strike_craft_component_template'):
    if strike_craft['hidden']: continue
    key = strike_craft['key']
    strike_craft.weak_update(default_values)
    strike_craft['size'] = 'hangar'
    result_data[key] = strike_craft

column_specs = [
    ('Weapon/Role', stellaris.weapon.icon_and_name_and_role),
Ejemplo n.º 5
0
import _initpath
import pyradox
import os
import copy
import math

import stellaris.weapon

csv_data = pyradox.csv.parse_file(
    ['common', 'component_templates', 'weapon_components.csv'],
    game='Stellaris')

txt_data = pyradox.parse_merge(['common', 'component_templates'],
                               game='Stellaris')

total_data = pyradox.Tree()

for weapon in txt_data.find_all('weapon_component_template'):
    if weapon['hidden']: continue
    key = weapon['key']
    total_data[key] = weapon + csv_data[key]

column_specs = [
    ('Weapon/Role', stellaris.weapon.icon_and_name_and_role),
    ('Size', stellaris.weapon.slot_string),
    ('{{icon|minerals}}<br/>Cost', '%(cost)d'),
    ('{{icon|power}}<br/>Power', lambda k, v: str(abs(v['power']))),
    ('{{icon|damage}}<br/>Average<br/>damage',
     lambda k, v: '%0.1f' % stellaris.weapon.average_damage(v)),
    ('{{icon|time}}<br/>Cooldown', '%(cooldown)d'),
    ('{{icon|weapons range}}<br/>Range', '%(range)d'),
Ejemplo n.º 6
0
def get_technologies(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    return pyradox.parse_merge('common/technologies', game = game, merge_levels = 1)['technologies']
Ejemplo n.º 7
0
def get_states(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    result = pyradox.parse_merge(['history', 'states'], game = 'HoI4')
    result.replaced_key_with_subkey('state', 'id')
    return result
Ejemplo n.º 8
0
def get_units(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    return pyradox.parse_merge('common/units', game = game, merge_levels = 1)['sub_units']
Ejemplo n.º 9
0
Archivo: load.py Proyecto: ajul/pyradox
def get_technologies(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    return pyradox.parse_merge('common/technologies', game = game, merge_levels = 1)['technologies']
Ejemplo n.º 10
0
Archivo: load.py Proyecto: ajul/pyradox
def get_states(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    result = pyradox.parse_merge(['history', 'states'], game = 'HoI4')
    result.replaced_key_with_subkey('state', 'id')
    return result
Ejemplo n.º 11
0
Archivo: load.py Proyecto: ajul/pyradox
def get_units(beta = False):
    game = 'HoI4_beta' if beta else 'HoI4'
    return pyradox.parse_merge('common/units', game = game, merge_levels = 1)['sub_units']
Ejemplo n.º 12
0
import _initpath
import pyradox
import os
import copy
import math
import stellaris.weapon

txt_data = pyradox.parse_merge(['common',
                                'component_templates'], game = 'Stellaris', apply_defines = True)

default_values = pyradox.Tree()
default_values['hull_damage'] = 1.0
default_values['armor_damage'] = 1.0
default_values['shield_damage'] = 1.0
default_values['armor_penetration'] = 0.0
default_values['shield_penetration'] = 0.0
default_values['tracking'] = 0.0
default_values['prerequisites'] = 'Ship part strike craft scout 1'

result_data = pyradox.Tree()

for strike_craft in txt_data.find_all('strike_craft_component_template'):
    if strike_craft['hidden']: continue
    key = strike_craft['key']
    strike_craft.weak_update(default_values)
    strike_craft['size'] = 'hangar'
    result_data[key] = strike_craft

column_specs = [
    ('Weapon/Role', stellaris.weapon.icon_and_name_and_role),
    ('Size', stellaris.weapon.slot_string),
Ejemplo n.º 13
0
import _initpath
import pyradox
import os
import copy
import math

import stellaris.weapon

csv_data = pyradox.csv.parse_file(['common',
                                   'component_templates',
                                   'weapon_components.csv'],
                                  game = 'Stellaris')

txt_data = pyradox.parse_merge(['common',
                                'component_templates'], game = 'Stellaris')

total_data = pyradox.Tree()

for weapon in txt_data.find_all('weapon_component_template'):
    if weapon['hidden']: continue
    key = weapon['key']
    total_data[key] = weapon + csv_data[key]

column_specs = [
    ('Weapon/Role', stellaris.weapon.icon_and_name_and_role),
    ('Size', stellaris.weapon.slot_string),
    ('{{icon|minerals}}<br/>Cost', '%(cost)d'),
    ('{{icon|power}}<br/>Power', lambda k, v: str(abs(v['power']))),
    ('{{icon|damage}}<br/>Average<br/>damage', lambda k, v: '%0.1f' % stellaris.weapon.average_damage(v)),
    ('{{icon|time}}<br/>Cooldown', '%(cooldown)d'),
    ('{{icon|weapons range}}<br/>Range', '%(range)d'),