The character data format uses the eq
field to hold equipped items. The locations in this object are nested into groups, for example:
{
"eq": {
"head": [
{
"name": "Head",
"item": null
},
{
"name": "Necklace 1",
"item": null
}
]
}
}
This makes it rather difficult to locate equipped items in the list, since it requires a nested loop.
As an alternative, the slot category could be indicated within the location itself:
{
"eq": [
{
"name": "Head",
"item": null,
"slot": "head"
},
{
"name": "Necklace 1",
"item": null,
"slot": "head"
}
]
}
This would make it much easier to find items in the equipped list, since iterating through the nested arrays wouldn't be required. For output, the flat array could simply be sorted using the slot value. To equip, find the first location in the flat array with the matching slot and write into it, or if none exist, fail. Unequipping would be an equally simple loop through the list, merely comparing with the item.