# Path: mgz/util.py
# class ModVersionAdapter(Adapter):
#     """Parse mod version."""
# 
#     def _decode(self, obj, context):
#         """Decode mod."""
#         number = int(obj)
#         mod_id = int(number / 1000)
#         mod_version = '.'.join(list(str(number % 1000)))
#         return {
#             'id': mod_id,
#             'name': const.MODS.get(mod_id, 'Unknown Mod'),
#             'version': mod_version
#         }
# 
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19
# 
# def find_version(ctx):
#     """Find version."""
#     if 'version' not in ctx:
#         return find_version(ctx._)
#     return ctx.version
# 
# def find_save_version(ctx):
#     """Find save version."""
#     if 'save_version' not in ctx:
#         return find_save_version(ctx._)
#     return ctx.save_version


from construct import Embedded, Float32l, If, Struct, this, Array
from mgz.util import ModVersionAdapter, Version, find_version, find_save_version
    "castle_high"/Float32l,
    "wonder_high"/Float32l,
    "total_tribute_sent"/Float32l,
    "convert_min_adj"/Float32l,
    "convert_max_adj"/Float32l,
    "convert_resist_min_adj"/Float32l,
    "convert_resist_max_adj"/Float32l,
    "convert_building_min"/Float32l,
    "convert_building_max"/Float32l,
    "convert_building_chance"/Float32l,
    "spies"/Float32l,
    "value_wonders_castles"/Float32l,
    "food_score"/Float32l,
    "wood_score"/Float32l,
    "stone_score"/Float32l,
    "gold_score"/Float32l,
    Embedded(If(lambda ctx: find_save_version(ctx) >= 11.76, Struct(
        "wood_bonus0"/Float32l,
        "food_bonus0"/Float32l,
        "relic_rate"/Float32l,
        "heresy"/Float32l,
        "theocracy"/Float32l,
        "crenellations"/Float32l,
        "construction_rate_mod"/Float32l,
        "hun_wonder_bonus"/Float32l,
        "spies_discount"/Float32l,
    ))),
    Embedded(If(lambda ctx: find_version(ctx) in (Version.DE, Version.HD), Struct(
        Array(this._._.num_header_data - 198, Float32l)
    ))),

# Path: mgz/util.py
# class ModVersionAdapter(Adapter):
#     """Parse mod version."""
# 
#     def _decode(self, obj, context):
#         """Decode mod."""
#         number = int(obj)
#         mod_id = int(number / 1000)
#         mod_version = '.'.join(list(str(number % 1000)))
#         return {
#             'id': mod_id,
#             'name': const.MODS.get(mod_id, 'Unknown Mod'),
#             'version': mod_version
#         }
# 
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19
# 
# def find_version(ctx):
#     """Find version."""
#     if 'version' not in ctx:
#         return find_version(ctx._)
#     return ctx.version
# 
# def find_save_version(ctx):
#     """Find save version."""
#     if 'save_version' not in ctx:
#         return find_save_version(ctx._)
#     return ctx.save_version


# Path: mgz/header/playerstats.py
from construct import Embedded, Float32l, If, Struct, this, Array
from mgz.util import ModVersionAdapter, Version, find_version, find_save_version

    "castle_high"/Float32l,
    "wonder_high"/Float32l,
    "total_tribute_sent"/Float32l,
    "convert_min_adj"/Float32l,
    "convert_max_adj"/Float32l,
    "convert_resist_min_adj"/Float32l,
    "convert_resist_max_adj"/Float32l,
    "convert_building_min"/Float32l,
    "convert_building_max"/Float32l,
    "convert_building_chance"/Float32l,
    "spies"/Float32l,
    "value_wonders_castles"/Float32l,
    "food_score"/Float32l,
    "wood_score"/Float32l,
    "stone_score"/Float32l,
    "gold_score"/Float32l,
    Embedded(If(lambda ctx: find_save_version(ctx) >= 11.76, Struct(
        "wood_bonus0"/Float32l,
        "food_bonus0"/Float32l,
        "relic_rate"/Float32l,
        "heresy"/Float32l,
        "theocracy"/Float32l,
        "crenellations"/Float32l,
        "construction_rate_mod"/Float32l,
        "hun_wonder_bonus"/Float32l,
        "spies_discount"/Float32l,
    ))),
    Embedded(If(lambda ctx: find_version(ctx) in (Version.DE, Version.HD), Struct(
        Array(this._._.num_header_data - 198, Float32l)
    ))),

    Embedded(If(lambda ctx: find_version(ctx) in [Version.USERPATCH15, Version.MCP], Struct(