I wouldn't do this based on item name. Instead, I'd implement a system of modifiers to describe what an item does, something like...
{
name: "itemA",
displayName: "Slippers of Mighty Grace",
effects: [
{
type: "statCheck",
stat: "strength",
threshold: 31,
effectsIfMet: [
{
type: "statBoost",
stat: "agility",
value: 20
}
],
effectsIfNotMet: [
{
type: "statBoost",
stat: "agility",
value: 10
}
]
}
]
}
When you load this item from JSON, you string together a matching pattern of polymorphic effect nodes, each with their own Apply
method.
When the item is equipped, or when the character's status changes in a way that might affect equipment properties, you re-run the Apply()
methods of all equipped gear.