This updated Version did not support companion, it was taken out. Also I wouldn't calculate anything. In the old version gear was equipped with stats that weren't for the char. I would hard code in restrictions per class per Main and secondary stat, possibly a third per advanced class. And let this check per every slot with inventory if we got the same.