juk0de / mtf2json

Convert MegaMek's MTF format to JSON.
GNU General Public License v3.0
2 stars 0 forks source link

Patchwork armor may raise exceptions #4

Closed juk0de closed 2 months ago

juk0de commented 2 months ago

Description Patchwork armor currently raises an exception because the entries may contain "subkeys" (nested keys) that describe the armor type for each location, e. g.:

Armor:Patchwork
LA Armor:Reactive(Inner Sphere):26
RA Armor:Reactive(Inner Sphere):26
LT Armor:Standard(IS/Clan):26
RT Armor:Standard(IS/Clan):26
CT Armor:Standard(IS/Clan):38
HD Armor:Standard(IS/Clan):9
LL Armor:Reactive(Inner Sphere):34
RL Armor:Reactive(Inner Sphere):34
RTL Armor:8
RTR Armor:8
RTC Armor:12

Note that not all locations have a type subkey. In that case it's probably (hopefully?) safe to assume that it means "Standard(IS/Clan)".

Example mech: Zeus X ZEU-X. Error raised: ValueError: invalid literal for int() with base 10: 'Reactive(Inner Sphere)'

Possible Solution Restructure the armor section and group by location:

"armor": {
    "type": "Patchwork",
    "left_arm": {
        "pips": 26,
        "type": "Reactive(Inner Sphere)"
    [...]
    "left_torso": {
        "front": {
            "pips": 15,
            "type": "Standard(IS/Clan)"
        }
        "rear": {
            "pips": 5,
            "type":  "Standard(IS/Clan)"
    },
    [...]
},

In order to keep the JSON layout consistent, the structure section should be changed accordingly (i.e. remove the structure.pips subsection).

This solution breaks compatibility because it modifies the JSON data structure.