juk0de / mtf2json

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

Patchwork armor support (v0.1.4) #5

Closed juk0de closed 4 months ago

juk0de commented 4 months ago

Implements support for patchwork armor (see #4), by changing the armor and structure JSON layout and checking for nested keys.

Here is an example for the ZEU-X mech, that raises an exception during conversion without this PR:

MTF:

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

JSON:

"armor": {                              
    "type": "Patchwork",                
    "left_arm": {                       
        "pips": 26,                     
        "type": "Reactive(Inner Sphere)"
    },                                  
    "right_arm": {                      
        "pips": 26,                     
        "type": "Reactive(Inner Sphere)"
    },                                  
    "left_torso": {                     
        "front": {                      
            "pips": 26,                 
            "type": "Standard(IS/Clan)" 
        },                              
        "rear": {                       
            "pips": 8                   
        }                               
    },                                  
    "right_torso": {                    
        "front": {                      
            "pips": 26,                 
            "type": "Standard(IS/Clan)" 
        },                              
        "rear": {                       
            "pips": 8                   
        }                               
    },                                  
    "center_torso": {                   
        "front": {                      
            "pips": 38,                 
            "type": "Standard(IS/Clan)" 
        },                              
        "rear": {                       
            "pips": 12                  
        }                               
    },                                  
    "head": {                           
        "pips": 9,                      
        "type": "Standard(IS/Clan)"     
    },                                  
    "left_leg": {                       
        "pips": 34,                     
        "type": "Reactive(Inner Sphere)"
    },                                  
    "right_leg": {                      
        "pips": 34,                     
        "type": "Reactive(Inner Sphere)"
    }                                   
},